SecondaryHelpers ​
constructor ​
solidity
constructor(struct Structs.ConstantViews constantViews_) internal
_getSwapAndDeposit ​
solidity
function _getSwapAndDeposit(uint256 c_, uint256 d_, uint256 e_, uint256 f_, uint256 i_) internal pure returns (uint256 shares_)
Parameters ​
Name | Type | Description |
---|---|---|
c_ | uint256 | tokenA amount to swap and deposit |
d_ | uint256 | tokenB imaginary reserves |
e_ | uint256 | tokenA imaginary reserves |
f_ | uint256 | tokenA real reserves |
i_ | uint256 | tokenB real reserves |
_getUpdatedColReserves ​
solidity
function _getUpdatedColReserves(uint256 newShares_, uint256 totalOldShares_, struct Structs.CollateralReserves c_, bool mintOrBurn_) internal pure returns (struct Structs.CollateralReserves c2_)
Updates collateral reserves based on minting or burning of shares
Parameters ​
Name | Type | Description |
---|---|---|
newShares_ | uint256 | The number of new shares being minted or burned |
totalOldShares_ | uint256 | The total number of shares before the operation |
c_ | struct Structs.CollateralReserves | The current collateral reserves |
mintOrBurn_ | bool | True if minting shares, false if burning shares |
Return Values ​
Name | Type | Description |
---|---|---|
c2_ | struct Structs.CollateralReserves | The updated collateral reserves after the operation |
_getWithdrawAndSwap ​
solidity
function _getWithdrawAndSwap(uint256 c_, uint256 d_, uint256 e_, uint256 f_, uint256 g_) internal pure returns (uint256 shares_)
Parameters ​
Name | Type | Description |
---|---|---|
c_ | uint256 | tokenA current real reserves (aka reserves before withdraw & swap) |
d_ | uint256 | tokenB current real reserves (aka reserves before withdraw & swap) |
e_ | uint256 | tokenA: final imaginary reserves - real reserves (aka reserves outside range after withdraw & swap) |
f_ | uint256 | tokenB: final imaginary reserves - real reserves (aka reserves outside range after withdraw & swap) |
g_ | uint256 | tokenA perfect amount to withdraw |
_getBorrowAndSwap ​
solidity
function _getBorrowAndSwap(uint256 c_, uint256 d_, uint256 e_, uint256 f_, uint256 g_) internal pure returns (uint256 shares_)
Parameters ​
Name | Type | Description |
---|---|---|
c_ | uint256 | tokenA current debt before swap (aka debt before borrow & swap) |
d_ | uint256 | tokenB current debt before swap (aka debt before borrow & swap) |
e_ | uint256 | tokenA final imaginary reserves (reserves after borrow & swap) |
f_ | uint256 | tokenB final imaginary reserves (reserves after borrow & swap) |
g_ | uint256 | tokenA perfect amount to borrow |
_getUpdateDebtReserves ​
solidity
function _getUpdateDebtReserves(uint256 shares_, uint256 totalShares_, struct Structs.DebtReserves d_, bool mintOrBurn_) internal pure returns (struct Structs.DebtReserves d2_)
Updates debt and reserves based on minting or burning shares
_This function calculates the new debt and reserves when minting or burning shares. It updates the following for both tokens:
- Debt
- Real Reserves
- Imaginary Reserves The calculation is done proportionally based on the ratio of shares to total shares. For minting, it adds the proportional amount. For burning, it subtracts the proportional amount._
Parameters ​
Name | Type | Description |
---|---|---|
shares_ | uint256 | The number of shares to mint or burn |
totalShares_ | uint256 | The total number of shares before the operation |
d_ | struct Structs.DebtReserves | The current debt and reserves |
mintOrBurn_ | bool | True if minting, false if burning |
Return Values ​
Name | Type | Description |
---|---|---|
d2_ | struct Structs.DebtReserves | The updated debt and reserves |
_getSwapAndPaybackOneTokenPerfectShares ​
solidity
function _getSwapAndPaybackOneTokenPerfectShares(uint256 a_, uint256 b_, uint256 c_, uint256 d_, uint256 i_, uint256 j_) internal pure returns (uint256 tokenAmt_)
Parameters ​
Name | Type | Description |
---|---|---|
a_ | uint256 | tokenA new imaginary reserves (imaginary reserves after perfect payback but not swap yet) |
b_ | uint256 | tokenB new imaginary reserves (imaginary reserves after perfect payback but not swap yet) |
c_ | uint256 | tokenA current debt |
d_ | uint256 | tokenB current debt & final debt (tokenB current & final debt remains same) |
i_ | uint256 | tokenA new reserves (reserves after perfect payback but not swap yet) |
j_ | uint256 | tokenB new reserves (reserves after perfect payback but not swap yet) |
_getSwapAndPayback ​
solidity
function _getSwapAndPayback(uint256 c_, uint256 d_, uint256 e_, uint256 f_, uint256 g_) internal pure returns (uint256 shares_)
Parameters ​
Name | Type | Description |
---|---|---|
c_ | uint256 | tokenA debt before swap & payback |
d_ | uint256 | tokenB debt before swap & payback |
e_ | uint256 | tokenA imaginary reserves before swap & payback |
f_ | uint256 | tokenB imaginary reserves before swap & payback |
g_ | uint256 | tokenA perfect amount to payback |
_arbitrage ​
solidity
function _arbitrage(uint256 dexVariables_, uint256 dexVariables2_, struct Structs.PricesAndExchangePrice pex_) internal
This function is called after user operations to balance the pools It swaps tokens between the collateral and debt pools to align their prices The function updates the oracle price based on the arbitrage results
This function performs arbitrage between the collateral and debt pools
Parameters ​
Name | Type | Description |
---|---|---|
dexVariables_ | uint256 | The current state of dex variables |
dexVariables2_ | uint256 | Additional dex variables |
pex_ | struct Structs.PricesAndExchangePrice | Struct containing prices and exchange rates |