TermRepoCollateralManager.sol

This contract belongs to the Term Servicer group of contracts and is specific to a Term Repo deployment. This contract enforces margin maintenance rules for adding/withdrawing, and liquidating tokens.

TermRepoCollateralManager

This contract enforces margin maintenance rules for adding/withdrawing, repurchasing and liquidating collateral

This contract belongs to the Term Servicer group of contracts and is specific to a Term Repo deployment

ADMIN_ROLE

bytes32 ADMIN_ROLE

AUCTION_LOCKER

bytes32 AUCTION_LOCKER

DEVOPS_ROLE

bytes32 DEVOPS_ROLE

INITIALIZER_ROLE

bytes32 INITIALIZER_ROLE

SERVICER_ROLE

bytes32 SERVICER_ROLE

ROLLOVER_MANAGER

bytes32 ROLLOVER_MANAGER

ROLLOVER_TARGET_AUCTIONEER_ROLE

bytes32 ROLLOVER_TARGET_AUCTIONEER_ROLE

termRepoId

bytes32 termRepoId

liquidationsPaused

bool liquidationsPaused

termContractPaired

bool termContractPaired

numOfAcceptedCollateralTokens

uint8 numOfAcceptedCollateralTokens

deMinimisMarginThreshold

uint256 deMinimisMarginThreshold

liquidateDamangesDueToProtocol

uint256 liquidateDamangesDueToProtocol

netExposureCapOnLiquidation

uint256 netExposureCapOnLiquidation

termRepoServicer

contract ITermRepoServicer termRepoServicer

purchaseToken

address purchaseToken

termPriceOracle

contract ITermPriceOracle termPriceOracle

termRepoLocker

contract ITermRepoLocker termRepoLocker

termController

contract ITermController termController

emitter

contract ITermEventEmitter emitter

collateralTokens

address[] collateralTokens

encumberedCollateralBalances

mapping(address => uint256) encumberedCollateralBalances

maintenanceCollateralRatios

mapping(address => uint256) maintenanceCollateralRatios

initialCollateralRatios

mapping(address => uint256) initialCollateralRatios

liquidatedDamages

mapping(address => uint256) liquidatedDamages

lockedCollateralLedger

mapping(address => mapping(address => uint256)) lockedCollateralLedger

isCollateralTokenAccepted

modifier isCollateralTokenAccepted(address token)

whileLiquidationsNotPaused

modifier whileLiquidationsNotPaused()

notTermContractPaired

modifier notTermContractPaired()

constructor

constructor() public

initialize

function initialize(string termRepoId_, uint256 liquidateDamangesDueToProtocol_, uint256 netExposureCapOnLiquidation_, uint256 deMinimisMarginThreshold_, address purchaseToken_, struct Collateral[] collateralTokens_, contract ITermEventEmitter emitter_, address termInitializer_) external

pairTermContracts

function pairTermContracts(address termRepoLocker_, address termRepoServicer_, address termAuctionBidLocker_, address termAuction_, address termController_, address termPriceOracle_, address termRepoRolloverManager_, address devopsMultisig_, address adminWallet_) external

externalLockCollateral

function externalLockCollateral(address collateralToken, uint256 amount) external

Parameters

externalUnlockCollateral

function externalUnlockCollateral(address collateralToken, uint256 amount) external

Parameters

batchLiquidation

function batchLiquidation(address borrower, uint256[] closureAmounts) external

Parameters

batchLiquidationWithRepoToken

function batchLiquidationWithRepoToken(address borrower, uint256[] closureRepoTokenAmounts) external

Parameters

batchDefault

function batchDefault(address borrower, uint256[] closureAmounts) external

Parameters

calculateMintableExposure

function calculateMintableExposure(address collateralToken, uint256 amountToLock) external view returns (struct ExponentialNoError.Exp)

Parameters

getCollateralBalances

function getCollateralBalances(address borrower) external view returns (address[], uint256[])

Parameters

Return Values

getCollateralBalance

function getCollateralBalance(address borrower, address collateralToken) external view returns (uint256)

Parameters

Return Values

encumberedCollateralRemaining

function encumberedCollateralRemaining() external view returns (bool)

Return Values

auctionLockCollateral

function auctionLockCollateral(address bidder, address collateralToken, uint256 amount) external

Parameters

auctionUnlockCollateral

function auctionUnlockCollateral(address bidder, address collateralToken, uint256 amount) external

Parameters

acceptRolloverCollateral

function acceptRolloverCollateral(address borrower, address collateralToken, uint256 amount) external

Parameters

transferRolloverCollateral

function transferRolloverCollateral(address borrower, uint256 rolloverProportion, address rolloverTermRepoLocker) external returns (address[], uint256[])

Parameters

Return Values

approveRolloverAuction

function approveRolloverAuction(address rolloverAuction) external

Parameters

unlockCollateralOnRepurchase

function unlockCollateralOnRepurchase(address borrower) external

Parameters

journalBidCollateralToCollateralManager

function journalBidCollateralToCollateralManager(address borrower, address[] collateralTokenAddresses, uint256[] collateralTokenAmounts) external

Parameters

mintOpenExposureLockCollateral

function mintOpenExposureLockCollateral(address borrower, address collateralToken, uint256 amount) external

Parameters

reopenToNewAuction

function reopenToNewAuction(struct TermAuctionGroup termAuctionGroup) external

Parameters

pauseLiquidations

function pauseLiquidations() external

unpauseLiquidations

function unpauseLiquidations() external

isBorrowerInShortfall

function isBorrowerInShortfall(address borrower) public view returns (bool)

Parameters

Return Values

getCollateralMarketValue

function getCollateralMarketValue(address borrower) public view returns (uint256)

Parameters

Return Values

_lockCollateral

function _lockCollateral(address borrower, address collateralToken, uint256 amount) internal

_unlockCollateral

function _unlockCollateral(address borrower, address collateralToken, uint256 amount, bool decrementEncumberedCollateral) internal

_partialUnlockCollateral

function _partialUnlockCollateral(address borrower, uint256 unlockProportion, address destinationwallet) internal returns (uint256[])

_validateBatchLiquidationForFullLiquidation

function _validateBatchLiquidationForFullLiquidation(address borrower, address liquidator, uint256[] closureTokenAmounts) internal returns (bool)

A helper function to validate various conditions required to liquidate

Return Values

_unencumberRemainingBorrowerCollateralOnZeroObligation

function _unencumberRemainingBorrowerCollateralOnZeroObligation(address borrower) internal

_withinNetExposureCapOnLiquidation

function _withinNetExposureCapOnLiquidation(address borrower) internal view returns (bool)

_collateralSeizureAmounts

function _collateralSeizureAmounts(uint256 amountToCover_, address collateralToken) internal view returns (uint256, uint256)

returns total amount of collateral seized in liquidation and the amount of that total going protocol

_transferLiquidationCollateral

function _transferLiquidationCollateral(address borrower, address liquidator, address collateralAddress, uint256 closureAmount, uint256 collateralSeizureAmount, uint256 collateralSeizureProtocolShare, bool isDefault) internal

A helper function to transfer tokens and update relevant state variables and mappings

_isAcceptedCollateralToken

function _isAcceptedCollateralToken(address token_) internal view returns (bool)

_usdValueOfBalances

function _usdValueOfBalances(mapping(address => uint256) _tokenBalances) internal view returns (uint256)

_authorizeUpgrade

function _authorizeUpgrade(address impl) internal

required override by the OpenZeppelin UUPS module

Parameters

Last updated