Skip to content

FluidDexT1OperationsDebt ​

Git Source

Inherits:SecondaryHelpers

Implements core logics for Fluid Dex protocol. Note Token transfers happen directly from user to Liquidity contract and vice-versa.

Functions ​

constructor ​

solidity
constructor(ConstantViews memory constantViews_) SecondaryHelpers(constantViews_);

_onlyDelegateCall ​

solidity
modifier _onlyDelegateCall();

borrow ​

This function allows users to borrow tokens in any proportion from the debt pool

solidity
function borrow(uint256 token0Amt_, uint256 token1Amt_, uint256 maxSharesAmt_, address to_)
    public
    _onlyDelegateCall
    returns (uint256 shares_);

Parameters

NameTypeDescription
token0Amt_uint256The amount of token0 to borrow
token1Amt_uint256The amount of token1 to borrow
maxSharesAmt_uint256The maximum amount of shares the user is willing to receive
to_addressRecipient of swapped tokens. If to_ == address(0) then out tokens will be sent to msg.sender. If to_ == ADDRESS_DEAD then function will revert with shares_

Returns

NameTypeDescription
shares_uint256The amount of borrow shares minted to represent the borrowed amount

payback ​

This function allows users to payback tokens in any proportion to the debt pool

solidity
function payback(uint256 token0Amt_, uint256 token1Amt_, uint256 minSharesAmt_, bool estimate_)
    public
    payable
    _onlyDelegateCall
    returns (uint256 shares_);

Parameters

NameTypeDescription
token0Amt_uint256The amount of token0 to payback
token1Amt_uint256The amount of token1 to payback
minSharesAmt_uint256The minimum amount of shares the user expects to burn
estimate_boolIf true, function will revert with estimated shares without executing the payback

Returns

NameTypeDescription
shares_uint256The amount of borrow shares burned for the payback

paybackPerfectInOneToken ​

This function allows users to payback their debt with perfect shares in one token

solidity
function paybackPerfectInOneToken(uint256 shares_, uint256 maxToken0_, uint256 maxToken1_, bool estimate_)
    public
    payable
    _onlyDelegateCall
    returns (uint256 paybackAmt_);

Parameters

NameTypeDescription
shares_uint256The number of shares to burn for payback
maxToken0_uint256The maximum amount of token0 the user is willing to pay (set to 0 if paying back in token1)
maxToken1_uint256The maximum amount of token1 the user is willing to pay (set to 0 if paying back in token0)
estimate_boolIf true, the function will revert with the estimated payback amount without executing the payback

Returns

NameTypeDescription
paybackAmt_uint256The amount of tokens paid back in the chosen token