RepoTokenList.sol#RepoTokenList
State Variables
NULL_NODE
address internal constant NULL_NODE = address(0);
INVALID_AUCTION_RATE
uint256 internal constant INVALID_AUCTION_RATE = 0;
ZERO_AUCTION_RATE
uint256 internal constant ZERO_AUCTION_RATE = 1;
Functions
getRepoTokenMaturity
Retrieves the redemption (maturity) timestamp of a repoToken
This function calls the config()
method on the repoToken to retrieve its configuration details, including the redemption timestamp, which it then returns.
function getRepoTokenMaturity(address repoToken) internal view returns (uint256 redemptionTimestamp);
Parameters
repoToken
address
The address of the repoToken
Returns
redemptionTimestamp
uint256
The timestamp indicating when the repoToken matures
_getNext
Get the next node in the list
function _getNext(RepoTokenListData storage listData, address current) private view returns (address);
Parameters
listData
RepoTokenListData
The list data
current
address
The current node
Returns
<none>
address
The next node
_count
Count the number of nodes in the list
function _count(RepoTokenListData storage listData) private view returns (uint256 count);
Parameters
listData
RepoTokenListData
The list data
Returns
count
uint256
The number of nodes in the list
holdings
Returns an array of addresses representing the repoTokens currently held in the list data
This function iterates through the list of repoTokens and returns their addresses in an array. It first counts the number of repoTokens, initializes an array of that size, and then populates the array with the addresses of the repoTokens.
function holdings(RepoTokenListData storage listData) internal view returns (address[] memory holdingsArray);
Parameters
listData
RepoTokenListData
The list data
Returns
holdingsArray
address[]
An array of addresses of the repoTokens held in the list
getRepoTokenWeightedTimeToMaturity
Get the weighted time to maturity of the strategy's holdings of a specified repoToken
function getRepoTokenWeightedTimeToMaturity(address repoToken, uint256 repoTokenBalanceInBaseAssetPrecision)
internal
view
returns (uint256 weightedTimeToMaturity);
Parameters
repoToken
address
The address of the repoToken
repoTokenBalanceInBaseAssetPrecision
uint256
The balance of the repoToken in base asset precision
Returns
weightedTimeToMaturity
uint256
The weighted time to maturity in seconds x repoToken balance in base asset precision
getCumulativeRepoTokenData
This function calculates the cumulative weighted time to maturity and cumulative amount of all repoTokens in the list.
The repoToken
and repoTokenAmount
parameters are optional and provide flexibility to adjust the calculations to include the provided repoToken and amount. If repoToken
is set to address(0)
or repoTokenAmount
is 0
, the function calculates the cumulative data without specific token adjustments.
function getCumulativeRepoTokenData(
RepoTokenListData storage listData,
ITermDiscountRateAdapter discountRateAdapter,
address repoToken,
uint256 repoTokenAmount,
uint256 purchaseTokenPrecision
) internal view returns (uint256 cumulativeWeightedTimeToMaturity, uint256 cumulativeRepoTokenAmount, bool found);
Parameters
listData
RepoTokenListData
The list data
discountRateAdapter
ITermDiscountRateAdapter
The discount rate adapter
repoToken
address
The address of the repoToken (optional)
repoTokenAmount
uint256
The amount of the repoToken (optional)
purchaseTokenPrecision
uint256
The precision of the purchase token
Returns
cumulativeWeightedTimeToMaturity
uint256
The cumulative weighted time to maturity for all repoTokens
cumulativeRepoTokenAmount
uint256
The cumulative repoToken amount across all repoTokens
found
bool
Whether the specified repoToken was found in the list
getPresentValue
Get the present value of repoTokens
Aggregates the present value of all repoTokens in the list.
function getPresentValue(
RepoTokenListData storage listData,
ITermDiscountRateAdapter discountRateAdapter,
uint256 purchaseTokenPrecision
) internal view returns (uint256 totalPresentValue);
Parameters
listData
RepoTokenListData
The list data
discountRateAdapter
ITermDiscountRateAdapter
The discount rate adapter
purchaseTokenPrecision
uint256
The precision of the purchase token
Returns
totalPresentValue
uint256
The total present value of the repoTokens
_getRepoTokenTimeToMaturity
Calculates the time remaining until a repoToken matures
This function calculates the difference between the redemption timestamp and the current block timestamp to determine how many seconds are left until the repoToken reaches its maturity.
function _getRepoTokenTimeToMaturity(uint256 redemptionTimestamp) private view returns (uint256);
Parameters
redemptionTimestamp
uint256
The redemption timestamp of the repoToken
Returns
<none>
uint256
uint256 The time remaining (in seconds) until the repoToken matures
removeAndRedeemMaturedTokens
Removes and redeems matured repoTokens from the list data
Iterates through the list of repoTokens and removes those that have matured. If a matured repoToken has a balance, the function attempts to redeem it. This helps maintain the list by clearing out matured repoTokens and redeeming their balances.
function removeAndRedeemMaturedTokens(RepoTokenListData storage listData) internal;
Parameters
listData
RepoTokenListData
The list data
validateRepoToken
Validates a repoToken against specific criteria
early exit because list is sorted
Ensures the repoToken is deployed, matches the purchase token, is not matured, and meets collateral requirements. Reverts with InvalidRepoToken
if any validation check fails.
function validateRepoToken(RepoTokenListData storage listData, ITermRepoToken repoToken, address asset)
internal
view
returns (bool isRepoTokenValid, uint256 redemptionTimestamp);
Parameters
listData
RepoTokenListData
The list data
repoToken
ITermRepoToken
The repoToken to validate
asset
address
The address of the base asset
Returns
isRepoTokenValid
bool
Whether the repoToken is valid
redemptionTimestamp
uint256
The redemption timestamp of the validated repoToken
validateAndInsertRepoToken
Validate and insert a repoToken into the list data
function validateAndInsertRepoToken(
RepoTokenListData storage listData,
ITermRepoToken repoToken,
ITermDiscountRateAdapter discountRateAdapter,
address asset
) internal returns (bool validRepoToken, uint256 redemptionTimestamp);
Parameters
listData
RepoTokenListData
The list data
repoToken
ITermRepoToken
The repoToken to validate and insert
discountRateAdapter
ITermDiscountRateAdapter
The discount rate adapter
asset
address
The address of the base asset
Returns
validRepoToken
bool
Whether the repoToken is valid
redemptionTimestamp
uint256
The redemption timestamp of the validated repoToken
insertSorted
Insert a repoToken into the list in a sorted manner
Inserts the repoToken
into the listData
while maintaining the list sorted by the repoTokens' maturity timestamps. The function iterates through the list to find the correct position for the new repoToken
and updates the pointers accordingly.
function insertSorted(RepoTokenListData storage listData, address repoToken) internal;
Parameters
listData
RepoTokenListData
The list data
repoToken
address
The address of the repoToken to be inserted
Errors
InvalidRepoToken
error InvalidRepoToken(address token);
Last updated