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_ROLEAUCTION_LOCKER
bytes32 AUCTION_LOCKERDEVOPS_ROLE
bytes32 DEVOPS_ROLEINITIALIZER_ROLE
bytes32 INITIALIZER_ROLESERVICER_ROLE
bytes32 SERVICER_ROLEROLLOVER_MANAGER
bytes32 ROLLOVER_MANAGERROLLOVER_TARGET_AUCTIONEER_ROLE
bytes32 ROLLOVER_TARGET_AUCTIONEER_ROLEtermRepoId
bytes32 termRepoIdliquidationsPaused
bool liquidationsPausedtermContractPaired
bool termContractPairednumOfAcceptedCollateralTokens
uint8 numOfAcceptedCollateralTokensdeMinimisMarginThreshold
uint256 deMinimisMarginThresholdliquidatedDamagesDueToProtocol
uint256 liquidatedDamagesDueToProtocolnetExposureCapOnLiquidation
uint256 netExposureCapOnLiquidationtermRepoServicer
contract ITermRepoServicer termRepoServicerpurchaseToken
address purchaseTokentermPriceOracle
contract ITermPriceOracle termPriceOracletermRepoLocker
contract ITermRepoLocker termRepoLockertermController
contract ITermController termControlleremitter
contract ITermEventEmitter emittercollateralTokens
address[] collateralTokensencumberedCollateralBalances
mapping(address => uint256) encumberedCollateralBalancesmaintenanceCollateralRatios
mapping(address => uint256) maintenanceCollateralRatiosinitialCollateralRatios
mapping(address => uint256) initialCollateralRatiosliquidatedDamages
mapping(address => uint256) liquidatedDamageslockedCollateralLedger
mapping(address => mapping(address => uint256)) lockedCollateralLedgerisCollateralTokenAccepted
modifier isCollateralTokenAccepted(address token)whileLiquidationsNotPaused
modifier whileLiquidationsNotPaused()notTermContractPaired
modifier notTermContractPaired()constructor
constructor() publicinitialize
function initialize(string termRepoId_, uint256 liquidatedDamagesDueToProtocol_, uint256 netExposureCapOnLiquidation_, uint256 deMinimisMarginThreshold_, address purchaseToken_, struct Collateral[] collateralTokens_, contract ITermEventEmitter emitter_, address termInitializer_) externalpairTermContracts
function pairTermContracts(address termRepoLocker_, address termRepoServicer_, address termAuctionBidLocker_, address termAuction_, address termController_, address termPriceOracle_, address termRepoRolloverManager_, address devopsMultisig_, address adminWallet_) externalexternalLockCollateral
function externalLockCollateral(address collateralToken, uint256 amount) externalParameters
collateralToken
address
The address of the collateral token to lock
amount
uint256
The amount of collateral token to lock
externalUnlockCollateral
function externalUnlockCollateral(address collateralToken, uint256 amount) externalParameters
collateralToken
address
The address of the collateral token to unlock
amount
uint256
The amount of collateral token to unlock
batchLiquidation
function batchLiquidation(address borrower, uint256[] closureAmounts) externalParameters
borrower
address
The address of the borrower
closureAmounts
uint256[]
An array specifying the amounts of Term Repo exposure the liquidator proposes to cover in liquidation; an amount is required to be specified for each collateral token
batchLiquidationWithRepoToken
function batchLiquidationWithRepoToken(address borrower, uint256[] closureRepoTokenAmounts) externalParameters
borrower
address
The address of the borrower
closureRepoTokenAmounts
uint256[]
An array specifying the amounts of Term Repo Tokens the liquidator proposes to cover borrower repo exposure in liquidation; an amount is required to be specified for each collateral token
batchDefault
function batchDefault(address borrower, uint256[] closureAmounts) externalParameters
borrower
address
The address of the borrower
closureAmounts
uint256[]
An array specifying the amounts of Term Repo exposure the liquidator proposes to cover in liquidation; an amount is required to be specified for each collateral token
calculateMintableExposure
function calculateMintableExposure(address collateralToken, uint256 amountToLock) external view returns (struct ExponentialNoError.Exp)Parameters
collateralToken
address
The collateral token address of tokens locked
amountToLock
uint256
The amount of collateral tokens to lock
getCollateralBalances
function getCollateralBalances(address borrower) external view returns (address[], uint256[])Parameters
borrower
address
The address of the borrower
Return Values
[0]
address[]
An array of collateral token addresses
[1]
uint256[]
An array collateral token balances locked on behalf of borrower
getCollateralBalance
function getCollateralBalance(address borrower, address collateralToken) external view returns (uint256)Parameters
borrower
address
The address of the borrower
collateralToken
address
The collateral token address to query
Return Values
[0]
uint256
uint256 The amount of collateralToken locked on behalf of borrower
encumberedCollateralRemaining
function encumberedCollateralRemaining() external view returns (bool)Return Values
[0]
bool
bool A boolean that tests whether any encumbered collateral remains locked
auctionLockCollateral
function auctionLockCollateral(address bidder, address collateralToken, uint256 amount) externalParameters
bidder
address
The bidder's address
collateralToken
address
The address of the token to be used as collateral
amount
uint256
The amount of the token to lock
auctionUnlockCollateral
function auctionUnlockCollateral(address bidder, address collateralToken, uint256 amount) externalParameters
bidder
address
The bidder's address
collateralToken
address
The address of the token used as collateral
amount
uint256
The amount of collateral tokens to unlock
acceptRolloverCollateral
function acceptRolloverCollateral(address borrower, address collateralToken, uint256 amount) externalParameters
borrower
address
The address of the borrower
collateralToken
address
The address of a collateral token
amount
uint256
The amount of collateral tokens to lock
transferRolloverCollateral
function transferRolloverCollateral(address borrower, uint256 rolloverProportion, address rolloverTermRepoLocker) external returns (address[], uint256[])Parameters
borrower
address
The borrower's address
rolloverProportion
uint256
The proportion of the collateral to be unlocked, equal to the proportion of the collateral repaid
rolloverTermRepoLocker
address
The address of the new TermRepoLocker contract to roll into
Return Values
[0]
address[]
An array representing a list of accepted collateral token addresses
[1]
uint256[]
An array containing the amount of collateral tokens to pairoff and transfer to new TermRepoLocker to roll into
approveRolloverAuction
function approveRolloverAuction(address rolloverAuction) externalParameters
rolloverAuction
address
The address of the rollover auction
unlockCollateralOnRepurchase
function unlockCollateralOnRepurchase(address borrower) externalParameters
borrower
address
The address of the borrower
journalBidCollateralToCollateralManager
function journalBidCollateralToCollateralManager(address borrower, address[] collateralTokenAddresses, uint256[] collateralTokenAmounts) externalParameters
borrower
address
The address of the borrower
collateralTokenAddresses
address[]
Collateral token addresses
collateralTokenAmounts
uint256[]
Collateral token amounts
mintOpenExposureLockCollateral
function mintOpenExposureLockCollateral(address borrower, address collateralToken, uint256 amount) externalParameters
borrower
address
The address of the borrower
collateralToken
address
Collateral token addresse
amount
uint256
Collateral token amount
reopenToNewAuction
function reopenToNewAuction(struct TermAuctionGroup termAuctionGroup) externalParameters
termAuctionGroup
struct TermAuctionGroup
A struct of auction contracts
pauseLiquidations
function pauseLiquidations() externalunpauseLiquidations
function unpauseLiquidations() externalisBorrowerInShortfall
function isBorrowerInShortfall(address borrower) public view returns (bool)Parameters
borrower
address
The address of the borrower
Return Values
[0]
bool
Boolean testing whether the given borrower is in shortfall or margin deficit
getCollateralMarketValue
function getCollateralMarketValue(address borrower) public view returns (uint256)Parameters
borrower
address
The address of the borrower
Return Values
[0]
uint256
The market value of borrower's locked collateral denominated in USD
_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
[0]
bool
A boolean for whether borrower position eligible for full liquidation
_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) internalA 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) internalrequired override by the OpenZeppelin UUPS module
Parameters
impl
address
new impl address for proxy upgrade
Last updated