CoreInternals ​
Inherits:Error, CommonHelpers, Events
Functions ​
_supplyOrWithdraw ​
supply or withdraw for both with interest & interest free. positive amount_
is deposit, negative amount_
is withdraw.
solidity
function _supplyOrWithdraw(address token_, int256 amount_, uint256 supplyExchangePrice_)
internal
returns (int256 newSupplyInterestRaw_, int256 newSupplyInterestFree_);
_borrowOrPayback ​
borrow or payback for both with interest & interest free. positive amount_
is borrow, negative amount_
is payback.
solidity
function _borrowOrPayback(address token_, int256 amount_, uint256 borrowExchangePrice_)
internal
returns (int256 newBorrowInterestRaw_, int256 newBorrowInterestFree_);
_isInOutBalancedOut ​
*checks if supplyAmount_
& borrowAmount_
amounts transfers can be skipped (DEX-protocol use-case).
- Requirements:
callbackData_
MUST be encoded so that "from" address is the last 20 bytes in the last 32 bytes slot, also for native token operations where liquidityCallback is not triggered! from address must come at last position if there is more data. I.e. encode like: abi.encode(otherVar1, otherVar2, FROM_ADDRESS). Note dynamic types used with abi.encode come at the end so if dynamic types are needed, you must use abi.encodePacked to ensure the from address is at the end.- this "from" address must match withdrawTo_ or borrowTo_ and must be ==
msg.sender
callbackData_
must in addition to the from address as described above include bytes32 SKIP_TRANSFERS in the slot before (bytes 32 to 63)msg.value
must be 0.- Amounts must be either:
- supply(+) == borrow(+), withdraw(-) == payback(-).
- Liquidity must be on the winning side (deposit < borrow OR payback < withdraw).*
solidity
function _isInOutBalancedOut(
int256 supplyAmount_,
int256 borrowAmount_,
address withdrawTo_,
address borrowTo_,
bytes memory callbackData_
) internal view returns (bool);