Borrowing and Stabilizers
Borrowing process page describes the steps that a borrower will go through.
This page documents some of the contract calls.
Equations
JTV = JuniorTrancheValue STV = SeniorTrancheValue
SWEEP units
SWEEP has 18 decimal points. So when adding a transaction with a SWEEP amount of token it should have 18 more zeros than the desired amount. Same as with Ether.
Storage
Equity Ratio
If the Equity Ratio goes below this minimum, the stabilizer will be defaulted.
Minimum Equity Ratio
100% is 1.000.000
Fee
100% is 1.000.000
The spread fee is the value that the stabilizer uses to calculate how much fee should it pay in SWEEP tokens to the treasury for the borrowed amount.
The accrued fee is the product of: sweep_borrowed * time_elapsed * spread_fee
Sweep Borrowed
Represented by the senior tranche. It is the amount of debt that the stabilizer took.
Debt
Returns the total debt of the stabilizer, this is: sweep_borrowed + accrued_fee
Loan Limit
Loan limit of Sweep that represents the max debt in SWEEP a borrower can take.
Junior Tranche Value
Current junior tranche value. Note: If zero the borrower lost his/her investment. If negative, the system started to lose senior tranche value.
Default State
When a Stabilizer is defaulted the borrower cannot mint any more sweep or withdraw funds. Returns true if the EquityRatio is below the Minimum Equity Ratio. Will also return true if the Stabilizer is delayed in its payback when divesting.
Accrued Fee
Gets the current fee to be paid.
Note: this is calculated by
Call Delay
Represents the amount of time to wait, in seconds, for a repayment after executing a margin_call, before getting into default.
Call Time
Represents the deadline of the Stabilizer to repay call_amount of SWEEP before getting into default.
Note: this is calculated by
Call Amount
Represents the amount to be swapped in the AMM and then repaid. The intention is to attempt to peg the AMM price to the Target Price. In case it is not taken to 0 by repaying, the stabilizer will default at the call_time.
Liquidator Discount
When a Stabilizer is defaulted anyone can liquidate it by repaying its debt and getting back its assets at a discount. It is a percentage where 100% is 1.000.000.
Borrower Role
Adding to the borrower equity / junior tranche
Send USDC or SWEEP to the Stabilizer address to add to the equity or junior tranche. The borrower can call "withdraw" to get tokens out.
Configure
Sets the initial configuration of the Stabilizer. This configuration will be analyzed by the protocol and if accepted, used to include the Stabilizer in the minter list of Sweep.
The borrower starts by calling "configure" to propose terms in the stabilizer
The borrower calls "propose" to send these terms to protocol governance
The protocol can approve the proposal by adding to the Sweep coin minter list, or "reject"
min_equity_ratio: Minimum equity ratio, in percent. 100% = 1,000,000
spread_fee: A fee to the protocol, in percent
loan_limit: The proposed loan limit in SWEEP (10^18 = 1)
liquidator_discount: in percent
call_delay: Amount of time between getting a call and a default. In seconds. Use 0 for on-chain assets that can be sold automatically.
link: A URL link to a Web page that describes the borrower and the asset
Propose
Sends the Stabilizer to the protocol. Conceptually, this is a request to approve the loan and the loan limit, with the configured terms and asset. Mechanically, it changes the account that controls configuration to the protocol/governance admin.
Borrow
Asks the stabilizer to mint a certain amount of sweep token. You will be able to mint if the debt amount keeps the new equity ratio bigger than the minimum equity ratio. Note: this function increments the debt increasing the sweep_borrowed (senior tranche).
Repay
Burns the sweep_amount parameter amount of tokens in the sweep contract. Note: this function reduces the debt decreasing the sweep_borrowed (senior tranche).
Buy
Buys sweep from the Stabilizer's balance to the AMM at amm_price rate (swaps USDX to SWEEP).
Sell
Sells sweep from the Stabilizer's balance to the AMM at amm_price rate (swaps SWEEP to USDX).
Buy SWEEP
Buys sweep from the Stabilizer's balance to the borrower at target_price rate (swaps USDX to SWEEP).
Sell SWEEP
Sells sweep from the Stabilizer's balance to the borrower at target_price rate (swaps SWEEP to USDX).
Withdraw
The borrower can take money out by calling this function. It will pass if the state after transacting doesn't put the stabilizer into default.
Pay Fee
Pays the protocol spread on the borrowed sweep over time. The Fee is paid when borrowing and repaying too.
Admin Role
Reject a Proposed Configuration
Changes the account that control the global configuration to the borrower. If the borrower/stabilizer is approved, the admin will add the Stabilizer to the minters whitelist in the SWEEP contract.
Freeze the Stabilizer
Freezes the Stabilizer. Mint, Sell, Buy, Burn, Invest and Withdraw cannot be executed.
Set a Borrower
Changes the current borrower who manage the investment actions.
Asset Functions
Invest
Uses USDX and SWEEP balances to buy a token or deposit money into a protocol or to send them to a wallet. This depends on the asset's internal implementation.
Divest
Redeems the investment by selling tokens or withdrawing positions, depending on the kind of asset the the Stabilizer is investing into.
Liquidate
If the stabilizer is defaulted, this function calls repay and if it succeeds, the caller of the function gets the assets at a discount.
In order to execute the liquidate function. The liquidator must approve an amount equal to the getLiquidationValue() amount, that value can be fetched from the stabilizer.
Collect
Sends the rewards from the On-Chain-Assets to the Borrower.
Last updated