IFluidLiquidityLogic ​
Inherits:IFluidLiquidityAdmin
Functions ​
operate ​
Single function which handles supply, withdraw, borrow & payback
to trigger skipping in / out transfers (gas optimization):
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.valuemust be 0.- Amounts must be either:
- supply(+) == borrow(+), withdraw(-) == payback(-).
- Liquidity must be on the winning side (deposit < borrow OR payback < withdraw).
solidity
function operate(
address token_,
int256 supplyAmount_,
int256 borrowAmount_,
address withdrawTo_,
address borrowTo_,
bytes calldata callbackData_
) external payable returns (uint256 memVar3_, uint256 memVar4_);Parameters
| Name | Type | Description |
|---|---|---|
token_ | address | address of token (0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native) |
supplyAmount_ | int256 | if +ve then supply, if -ve then withdraw, if 0 then nothing |
borrowAmount_ | int256 | if +ve then borrow, if -ve then payback, if 0 then nothing |
withdrawTo_ | address | if withdrawal then to which address |
borrowTo_ | address | if borrow then to which address |
callbackData_ | bytes | callback data passed to liquidityCallback method of protocol |
Returns
| Name | Type | Description |
|---|---|---|
memVar3_ | uint256 | updated supplyExchangePrice |
memVar4_ | uint256 | updated borrowExchangePrice |
operateOnBehalfOf ​
Same as operate but executes against onBehalf_'s position instead of msg.sender's. Only callable by auths or governance. Token transfers still come from msg.sender: native token uses msg.value, while ERC20 still pulls funds via msg.sender.liquidityCallback(). Only supply (+ve supplyAmount) and payback (-ve borrowAmount) are allowed; no withdrawals or borrows. Bypasses user and token pauses, so a paused position can still be topped up or repaid.
solidity
function operateOnBehalfOf(
address onBehalf_,
address token_,
int256 supplyAmount_,
int256 borrowAmount_,
bytes calldata callbackData_
) external payable returns (uint256 memVar3_, uint256 memVar4_);Parameters
| Name | Type | Description |
|---|---|---|
onBehalf_ | address | the address (protocol) whose position to operate on. Must be != address(0) and must have a configured position (via admin) for the given token. |
token_ | address | address of token (0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native) |
supplyAmount_ | int256 | if +ve then supply, if 0 then nothing. Must be >= 0. |
borrowAmount_ | int256 | if -ve then payback, if 0 then nothing. Must be <= 0. At least one of supplyAmount_ or borrowAmount_ must be non-zero. |
callbackData_ | bytes | must be empty (length 0). Custom callbackData-powered transfer shortcuts like SKIP_TRANSFERS / NET_TRANSFERS are not supported for onBehalfOf. |
Returns
| Name | Type | Description |
|---|---|---|
memVar3_ | uint256 | updated supplyExchangePrice |
memVar4_ | uint256 | updated borrowExchangePrice |