IProtocol ​
liquidityCallback ​
function liquidityCallback(address token_, uint256 amount_, bytes data_) external
CoreInternals ​
_supplyOrWithdraw ​
function _supplyOrWithdraw(address token_, int256 amount_, uint256 supplyExchangePrice_) internal returns (int256 newSupplyInterestRaw_, int256 newSupplyInterestFree_)
_supply or withdraw for both with interest & interest free. positive amount_
is deposit, negativeamount*
is withdraw.*
_borrowOrPayback ​
function _borrowOrPayback(address token_, int256 amount_, uint256 borrowExchangePrice_) internal returns (int256 newBorrowInterestRaw_, int256 newBorrowInterestFree_)
_borrow or payback for both with interest & interest free. positive amount_
is borrow, negativeamount*
is payback.*
_isInOutBalancedOut ​
function _isInOutBalancedOut(int256 supplyAmount_, int256 borrowAmount_, address withdrawTo_, address borrowTo_, bytes callbackData_) internal view returns (bool)
_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)._
FluidLiquidityUserModule ​
Fluid Liquidity public facing endpoint logic contract that implements the operate()
method. operate can be used to deposit, withdraw, borrow & payback funds, given that they have the necessary user config allowance. Interacting users must be allowed via the Fluid Liquidity AdminModule first. Intended users are thus allow-listed protocols, e.g. the Lending protocol (fTokens), Vault protocol etc.
For view methods / accessing data, use the "LiquidityResolver" periphery contract.
OperateMemoryVars ​
struct for vars used in operate() that would otherwise cause a Stack too deep error
struct OperateMemoryVars {
bool skipTransfers;
uint256 supplyExchangePrice;
uint256 borrowExchangePrice;
uint256 supplyRawInterest;
uint256 supplyInterestFree;
uint256 borrowRawInterest;
uint256 borrowInterestFree;
uint256 totalAmounts;
uint256 exchangePricesAndConfig;
}
operate ​
function operate(address token_, int256 supplyAmount_, int256 borrowAmount_, address withdrawTo_, address borrowTo_, bytes callbackData_) external payable returns (uint256 memVar3_, uint256 memVar4_)
inheritdoc IFluidLiquidity