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

NameTypeDescription

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) external

Parameters

NameTypeDescription

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) external

Parameters

NameTypeDescription

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) external

Parameters

NameTypeDescription

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) external

Parameters

NameTypeDescription

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

NameTypeDescription

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

NameTypeDescription

borrower

address

The address of the borrower

Return Values

NameTypeDescription

[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

NameTypeDescription

borrower

address

The address of the borrower

collateralToken

address

The collateral token address to query

Return Values

NameTypeDescription

[0]

uint256

uint256 The amount of collateralToken locked on behalf of borrower

encumberedCollateralRemaining

function encumberedCollateralRemaining() external view returns (bool)

Return Values

NameTypeDescription

[0]

bool

bool A boolean that tests whether any encumbered collateral remains locked

auctionLockCollateral

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

Parameters

NameTypeDescription

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) external

Parameters

NameTypeDescription

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) external

Parameters

NameTypeDescription

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

NameTypeDescription

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

NameTypeDescription

[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) external

Parameters

NameTypeDescription

rolloverAuction

address

The address of the rollover auction

unlockCollateralOnRepurchase

function unlockCollateralOnRepurchase(address borrower) external

Parameters

NameTypeDescription

borrower

address

The address of the borrower

journalBidCollateralToCollateralManager

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

Parameters

NameTypeDescription

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) external

Parameters

NameTypeDescription

borrower

address

The address of the borrower

collateralToken

address

Collateral token addresse

amount

uint256

Collateral token amount

reopenToNewAuction

function reopenToNewAuction(struct TermAuctionGroup termAuctionGroup) external

Parameters

NameTypeDescription

termAuctionGroup

struct TermAuctionGroup

A struct of auction contracts

pauseLiquidations

function pauseLiquidations() external

unpauseLiquidations

function unpauseLiquidations() external

isBorrowerInShortfall

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

Parameters

NameTypeDescription

borrower

address

The address of the borrower

Return Values

NameTypeDescription

[0]

bool

Boolean testing whether the given borrower is in shortfall or margin deficit

getCollateralMarketValue

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

Parameters

NameTypeDescription

borrower

address

The address of the borrower

Return Values

NameTypeDescription

[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

NameTypeDescription

[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) 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

NameTypeDescription

impl

address

new impl address for proxy upgrade

Last updated