Skip to content

FluidDexT1OperationsDebt ​

Git Source

Inherits:SecondaryHelpers

Title: FluidDexT1

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_);

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

borrowPerfect ​

This function allows users to borrow tokens in equal proportion to the current debt pool ratio

solidity
function borrowPerfect(uint256 shares_, uint256 minToken0Borrow_, uint256 minToken1Borrow_, address to_)
    public
    _onlyDelegateCall
    returns (uint256 token0Amt_, uint256 token1Amt_);

Parameters

NameTypeDescription
shares_uint256The number of shares to borrow
minToken0Borrow_uint256Minimum amount of token0 to borrow
minToken1Borrow_uint256Minimum amount of token1 to borrow
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 token0Amt_ & token1Amt_

Returns

NameTypeDescription
token0Amt_uint256Amount of token0 borrowed
token1Amt_uint256Amount of token1 borrowed

paybackPerfect ​

This function allows users to pay back borrowed tokens in equal proportion to the current debt pool ratio

solidity
function paybackPerfect(uint256 shares_, uint256 maxToken0Payback_, uint256 maxToken1Payback_, bool estimate_)
    public
    payable
    _onlyDelegateCall
    returns (uint256 token0Amt_, uint256 token1Amt_);

Parameters

NameTypeDescription
shares_uint256The number of shares to pay back
maxToken0Payback_uint256Maximum amount of token0 to pay back
maxToken1Payback_uint256Maximum amount of token1 to pay back
estimate_boolIf true, function will revert with estimated payback amounts without executing the payback

Returns

NameTypeDescription
token0Amt_uint256Amount of token0 paid back
token1Amt_uint256Amount of token1 paid back