CoreInternals

Git Source

Inherits:Error, CommonHelpers, Events

Functions

_supplyOrWithdraw

supply or withdraw for both with interest & interest free. positive amount_ is deposit, negative amount_ is withdraw.

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.

function _borrowOrPayback(address token_, int256 amount_, uint256 borrowExchangePrice_)
    internal
    returns (int256 newBorrowInterestRaw_, int256 newBorrowInterestFree_);

_isInOutBalancedOut

*checks if supplyAmount_ & borrowAmount amounts balance themselves out (checked before calling this method):

  • supply(+) == borrow(+), withdraw(-) == payback(-). (DEX protocol use-case)
  • withdrawTo_ / borrowTo_ must be msg.sender (protocol)
  • callbackData_ MUST be encoded so that "from" address is at last 20 bytes (if this optimization is desired), 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.*
function _isInOutBalancedOut(int256 supplyAmount_, address withdrawTo_, address borrowTo_, bytes memory callbackData_)
    internal
    view
    returns (bool);