Borrowing
The borrowing.sol is one of the main user facing contracts in the protocol. It exposes the way to add liquidity to the protocol.
Write functions
depositTokens
strikePercent
enum StrikePrice
Strike price percentage chosen by user.
strikePrice
uint64
Strike price chosen by user.
volatility
uint256
Collateral volatility.
depositingAmount
uint256
User depositing amount.
assetName
enum AssetName
Collateral type depositing by user.
msg.value
uint256
Includes user depositing amount with LZ transaction fees.
After ratio and option fees calculation, half of the collateral is deposited to external protocol. The USDa are minted to the user with option fees deducted. Then it updates the global data by calling LZ's send function.
withDraw
toAddress
address
Address of the borrower.
index
uint64
Index of the borrower's position tries to withdraw.
odosAssembledData
bytes
Odos Execution/Assembled data got from Odos API to Swap collateral to USDT.
signature
bytes
Odos assembled data signed by admin 2.
msg.value
uint256
LZ transaction fees.
Withdraws 50% of the deposited collateral from the protocol after user pays the debt amount. The 50% of the deposited amount is credited to the user with strike price gains and for the remaining they are given with ABOND token which is fungible. Later they can use the ABOND tokens to redeem yields from external protocol and 50% of the deposited collateral.
For collaterals other than ETH, the borrower will get entire deposited amount during withdraw.
When repaying, the Borrowing contract must have allowance() to spend funds on behalf of msg.sender. This can be done via the standard ERC20 approve() method on the underlying token contract.
liquidate
user
address
Address of the borrower.
index
uint64
Index of the borrower's position.
liquidationType
struct LiquidationType
Defines the type of liquidation needs to be done.
msg.value
uint256
LZ transaction fees.
There are currently 2 liquidation types present.
Liquidate by using CDS funds - ONE.
Liquidate by taking short position in synthetix with 1x leverage - TWO.
Liquidates the positions whose collateral value becomes 80%.Liquidates the position based on the opted type by admin. Then during withdraw in CDS, the profits and liquidated collaterals are given to the users based on there proportions.
redeemYields
user
address
Address of the user who is redeeming.
aBondAmount
uint128
Amount of ABOND tokens user wants to redeem.
The user provides ABOND tokens to redeem yields from external protocol. Based on the eth backed and cumulative rate of that ABOND token the yield is calculated and given to the user.
When redeeming, the Borrowing contract must have allowance() to spend funds on behalf of msg.sender. This can be done via the standard ERC20 approve() method on the underlying token contract.
renewOptions
index
uint64
Index of the position to renew.
Renews the 20% downside protection of the borrower position by 30 days by providing USDa tokens.
When renewing, the Borrowing contract must have allowance() to spend funds on behalf of msg.sender. This can be done via the standard ERC20 approve() method on the underlying token contract.
calculateRatio
amount
uint256
Collateral amount the user is going to deposit.
currentEthPrice
uint256
Current collateral price.
Calculates the ratio of Collateral value to the total CDS amount in protocol. Updates the total collateral value locked and net CDS amount value based on collateral price changes.
updateRatePerSecByUSDaPrice
Updates the interest rate per second based on USDa price. This function can only be called by admin.
calculateCumulativeRate
Calculate the current cumulative rate based on APR and time interval between events.
Setter Functions
setAdmin
_admin
Admin who will do core operations.
address
setTreasury
_treasury
Treasury contract address.
address
setOptions
_options
Options contract address.
address
setBorrowLiquidation
_borrowLiquidation
BorrowLiquidation contract address
address
setLTV
_LTV
LTV ratio.
uint8
setAPR
_ratePerSec
Interest rate per second based on annual interest.
uint128
setBondRatio
_bondRatio
ABOND to USDa ratio
uint64
Read Functions
getAbondYields
user
address
Address of the user who is redeeming ABOND.
aBondAmount
uint128
Amount of ABONDs to redeem.
Returns the collateral backed for this ABOND, redeemable collateral amount with external protocol interest and USDa amount got from liquidation.
getUSDValue
Returns the exchange rate to ETH and USD value of the collateral.
getLTV
getOptionFeesToPay
Returns the option fees the borrower needs to pay to renew the 20% downside protection.
Last updated