Comment on page
Borrowing and Stabilizers
This page documents some of the contract calls.
JTV = JuniorTrancheValue STV = SeniorTrancheValue
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.
If the Equity Ratio goes below this minimum, the stabilizer will be defaulted.
100% is 1.000.000
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
Represented by the senior tranche. It is the amount of debt that the stabilizer took.
Returns the total debt of the stabilizer, this is: sweep_borrowed + accrued_fee
Loan limit of Sweep that represents the max debt in SWEEP a borrower can take.
Current junior tranche value. Note: If zero the borrower lost his/her investment. If negative, the system started to lose senior tranche value.
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.
Gets the current fee to be paid.
Note: this is calculated by
AF = b * s * (t / y)
b: sweep borrowed amount
s: spread ratio
t: time period we pay the rate
y: time in one year
Represents the amount of time to wait, in seconds, for a repayment after executing a margin_call, before getting into default.
Represents the deadline of the Stabilizer to repay call_amount of SWEEP before getting into default.
Note: this is calculated by
call_time = block.timestamp + call_delay
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.
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.
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.
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"
string calldata _link
- 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
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.
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).
function borrow(uint256 _sweep_amount)
Burns the sweep_amount parameter amount of tokens in the sweep contract. Note: this function reduces the debt decreasing the sweep_borrowed (senior tranche).
function repay(uint256 sweep_amount)
Buys sweep from the Stabilizer's balance to the AMM at amm_price rate (swaps USDX to SWEEP).
function buy(uint256 _usdx_amount, uint256 _amountOutMin)
Sells sweep from the Stabilizer's balance to the AMM at amm_price rate (swaps SWEEP to USDX).
function sell(uint256 _sweep_amount, uint256 _amountOutMin)
Buys sweep from the Stabilizer's balance to the borrower at target_price rate (swaps USDX to SWEEP).
function buySWEEP(uint256 _usdx_amount)
Sells sweep from the Stabilizer's balance to the borrower at target_price rate (swaps SWEEP to USDX).
function sellSWEEP(uint256 _sweep_amount)
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.
function withdraw(address _token, uint256 _amount)
Pays the protocol spread on the borrowed sweep over time. The Fee is paid when borrowing and repaying too.
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.
Freezes the Stabilizer. Mint, Sell, Buy, Burn, Invest and Withdraw cannot be executed.
function setFrozen(bool _frozen)
Changes the current borrower who manage the investment actions.
function setBorrower(address _borrower)
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.
function invest(uint256 _usdx_amount, uint256 _sweep_amount)
Redeems the investment by selling tokens or withdrawing positions, depending on the kind of asset the the Stabilizer is investing into.
function divest(uint256 _amount)
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.
Sends the rewards from the On-Chain-Assets to the Borrower.
Last modified 3mo ago