Autonomint
Blockchain Docs
Blockchain Docs
  • GETTING STARTED
    • Overview
    • Contracts Overview
  • Core Contracts
    • Borrowing
    • CDS
    • Treasury
    • Options
    • MultiSign
    • BorrowLiquidation
    • GlobalVariables
  • Core Logics
    • Borrowing Logics
    • CDS Logics
    • Treasury Logics
    • Options Logics
    • BorrowLiquidation Logics
  • Deployed Contracts Addresses
Powered by GitBook
On this page
  • Write Functions
  • deposit
  • withdraw
  • redeemUSDT
  • calculateCumulativeRate
  • calculateCumulativeValue
  • cdsAmountToReturn
  • Setter Functions
  • Update Functions
  • ReadFunctions
  1. Core Contracts

CDS

The CDS is another main user facing contract in Autonomint protocol, where users can deposit stablecoins like USDa, USDT to get yields.

During withdraw the user can get the deposited amount based on collateral price change between deposit and withdraw, Options fees and liquidation gains if opted.

There is a redeemUSDT option also available to get the USDT, for that equal amount of USDa needs to be burn from the user.

Write Functions

deposit

function deposit(
        uint128 usdtAmount,
        uint128 usdaAmount,
        bool liquidate,
        uint128 liquidationAmount,
        uint128 lockingPeriod ) payable 
Param Name
Type
Description

usdtAmount

uint128

Amount USDT token user is depositing.

usdaAmount

uint128

Amount USDa token user is depositing.

liquidate

bool

Whether the user is opted for liquidation gains.

liquidationAmount

uint128

Opted liquidation amount.

lockingPeriod

uint128

How long the user is willing to stay deposited in protocol.

msg.value

uint256

Lz transaction fee.

The user can able to deposit up to USDT $20K, for that the same amount of USDa is minted. After it reaches the 20K limit, the user must deposit minimum USDa amount of 80% of total depositing amount. There is an locking period option is also available to lock the deposited amount by user itself. User can also opt for liquidation gains i.e. the user can use this deposited amount to be used for liquidating collaterals.

withdraw

function withdraw(
    uint64 index,
    uint256 excessProfitCumulativeValue,
    uint256 nonce,
    bytes memory signature
) public payable
Param Name
Type
Description

index

uint64

Index of the user's position, tries to withdraw.

excessProfitCumulativeValue

uint256

The cumulative value of the excess profit, needs to remove from the upside.

nonce

uint256

Nonce of the signer who signed the signsture.

signature

bytes

Excess profit cumulative value signed by admin 2.

msg.value

uint256

Lz transaction fee.

The withdraw amount is calculated by

  • price change of collateral between deposit and withdraw.

  • option fees earned by the user by protecting the borrower's collateral.

  • If opted for liquidation, then the user will get protected liquidated position value and collateral.

Option fees earned by user is calculated by using cumulative rate.

redeemUSDT

function redeemUSDT(uint128 usdaAmount, uint64 usdaPrice, uint64 usdtPrice) payable
Param Name
Type
Description

usdaAmount

uint128

USDa amount the user is willing to exchange.

usdaPrice

uint64

USDa price.

usdtPrice

uint64

USDT price.

msg.value

uint256

Lz transaction fee.

After user transferred USDa to the protocol through redeemUSDT() method, the same value of USDT is transferred to the user. Then the acquired USDa is burned to maintain the USDa always pegged to $1.

calculateCumulativeRate

function calculateCumulativeRate(uint128 fees) payable
Param Name
Type
Description

fees

uint128

Option fees to give to CDS users.

msg.value

uint256

Lz transaction fee.

The option fees is distributed to the CDS users by using cumulative rate. During deposit the normalized amount of the deposited amount of the user is stored. When the user withdraws, the normalized amount is multiplied with current cumulative rate to get the deposited amount with option fees.

This function is only called by Borrowing contract.

calculateCumulativeValue

function calculateCumulativeValue(
    uint256 vaultBal,
    uint256 globalTotalCdsDepositedAmount,
    uint128 _price
)external
Param Name
Type
Description

vaultBal

uint256

Total collateral deposited by borrowers in ETH value in all chains.

globalTotalCdsDepositedAmount

uint256

Total CDS deposited amount in all chains

_price

uint128

Current ETH price.

Calculates the cumulative value based on comparing last stored ETH price and current ETH price multiplied with Vault to CDS ratio.

This function is only called by Borrowing contract.

cdsAmountToReturn

function cdsAmountToReturn(
    address _user,
    uint64 index,
    uint128 cumulativeValue,
    bool cumulativeValueSign,
    uint256 excessProfitCumulativeValue
) private view returns (uint256)

Calculates the USDa amount to return to the user during withdraw, based on price fluctuations and collateral amount in borrow since deposit.

Setter Functions

Update Functions

ReadFunctions

PreviousBorrowingNextTreasury

Last updated 6 months ago

Function Name
Param Name
Param Type
Description
Function Name
Param Name
Param Type
Description
Function Name
Param Name
Param Type
Description
Function Name
Param Name
Param Type
Description
Function Name
Param Name
Param Type
Description
Function Name
Param Name
Param Type
Description
Function Name
Param Name
Param Type
Description
Function Name
Param Name
Param Type
Description
Function Name
Param Name
Param Type
Description
Function Name
Param Name
Param Type
Description
Function Name
Param Name
Param Type
Description
Function Name
Param Name
Param Type
Description
Function Name
Param Name
Param Type
Description
Function Name
Param Name
Param Type
Description
Function Name
Param Name
Param Type
Description
Function Name
Description
Param Name
Param Type
Function Name
Description
Param Name
Param Type
Function Name
Description
Param Name
Param Type
Function Name
Description
Param Name
Param Type
Function Name
Description
Param Name
Param Type
Function Name
Description
Param Name
Param Type

setAdmin

_admin

address

Admin address.

setBorrowingContract

_address

address

Borrowing contract address.

setTreasury

_treasury

address

Treasury contract address.

setBorrowLiquidation

_address

address

BorrowLiquidation contract address.

setWithdrawTimeLimit

_timeLimit

uint64

CDS withdraw locking period.

setUSDaLimit

percent

uint8

USDa percent, the user must deposit after $20k USDT.

setUsdtLimit

amount

uint64

USDT limit.

setDstEid

_eid

uint32

Destination chain EID.

setAdminTwo

hashedAddress32

bytes

Hashed admin two address.

updateLastEthPrice

priceAtEvent

uint128

ETH price to update.

updateLiquidationInfo

index, liquidationData

uint128,struct LiquidationInfo

Liquidation Info to update.

updateTotalAvailableLiquidationAmount

amount

uint128

Available liquidation amount to update.

updateTotalCdsDepositedAmount

_amount

uint256

CDS amount to update.

updateTotalCdsDepositedAmountWithOptionFees

_amount

uint256

CDS amount with option fees to update.

updateDownsideProtected

downsideProtectedAmount

uint128

Downside protected amount during borrow withdraw.

getLatestData

Gets the latest ETH price.

getCumulativeValue

Gets the current cumulative value.

omniChainData, value, gains

uint128,struct LiquidationInfo

getOptionsFeesProportions

Gives the options fees to get from other chains based on given options fees.

optionsFees

uint256

getCDSDepositDetails

Gets the cds details for the given address and index, and total index of the address.

depositor, index

address, uint64

getTotalCdsDepositedAmount

Get the total CDS deposited amount.

getTotalCdsDepositedAmountWithOptionsFees

Get the total CDS deposited amount with options fees.