Buyback Contract
Buyback contract is designed to decentralize the SPA buyback process while adding a boosting mechanism to continuously grow USDs TVL with protocol revenue (Yield + Fee). This contract allows users to directly purchase USDs with SPA. The available-for-purchase USDs comes from two sources - USDs mint/redeem fees and USDs yield. The contract distributes 50% of the SPA bought back from users to veSPA holders as reward and burns the rest.
Protocol Yield - The yield is collected in multiple tokens through pool fee (USDC, FRAX, etc) and farm rewards (like FXS, STG etc.). This yield is converted to USDs. A portion is sent to buyback contract and remaining to auto-yield reserve.
Swap yield tokens to eligible collateral tokens (for minting USDs) using DEXes based on the path of lowest slippage
Mint USDs using the collateral tokens
Deposit 50% of the yield (USDs received in previous step) that will be used to buyback SPA into the buyback contract and the rest of the USDs is transferred back to the USDs vault’s auto-yield reserve. Yield share percentage is set to 50% currently and can be changed in future through governance.
Protocol Fee - Mint and redemption fee from the USDs protocol is collected in the form of USDs. This component is directly deposited to the Buyback contract.
Buyback SPA - Any users or external wallet can view the USDs balance in the Buyback contract and sell their SPA tokens for USDs.
Burn 2.0 - 50% of the SPA received in step 4 is burnt and remaining 50% is sent to veSPA rewarder. The burn percentage can be changed through governance.
Example flow of the buyback contract:
Sperax protocol deposits USDC.e to Stargate strategy (Stargate-LP USDC.e) and stakes LP tokens. Protocol earns STG token.
Sell STG tokens for USDC.e
Mint USDs from USDC.e
Transfer USDs to the Buyback contract.
Deposit USDs Mint and Redemption Fees directly into the Buyback contract as and when they are collected
Users can view the amount of USDs left in the contract
USDs is bought by the users using their SPA and contract receives SPA against the USDs
Technical Specification
Buyback Architechture
View Functions
getSPAReqdForUSDs - Input the target USDs amount to receive and get an estimate of how many SPA tokens are needed.
Function: getSPAReqdForUSDs(uint256 _usdsAmount) external view returns (uint256)
Input : _usdsAmount is the amount of USDs to purchase
Output: Estimated amount of SPA required
Example: Suppose getSPAReqdForUSDs(1e18) returns 100*1e18. It means the contract estimates that one will need to speed 100 SPA to purchase 1 USDs at this moment.
getUsdsOutForSpa - Input the amount of SPA to be sold and get an estimate of how many USDs can be purchased.
Function: getUsdsOutForSpa(uint256 _spaIn) external view returns (uint256)
Input : _spaIn is the amount of SPA to be sold
Output: Estimated amount of USDs to be received
Example: Suppose getSPAReqdForUSDs(100*1e18) returns 1e18. It means the contract estimates that one will receive 1 USDs after spending 100 SPA.
User End Write Functions
buyUSDs - Purchase USDs with SPA
Function: buyUSDs(uint256 _spaIn, uint256 _minUSDsOut) external
Input : _spaIn is the amount of SPA to be sold _minUSDsOut is the minimum amount of USDs to be received
Output : The contract will extract _spaIn amount of SPA from the wallet executing the transaction, exchange it to USDs, and send USDs back to the wallet
Example : Suppose wallet A triggers buyUSDs(100*1e18, 1e18) (after he has already approved the Buyback contract to spend its SPA). The contract will extract 100 SPA from A, exchange it to USDs, and send USDs back to A.
buyUSDs - Purchase USDs with SPA (arbitrary USDs receipt)
Function: buyUSDs(address _receiver, uint256 _spaIn, uint256 _minUSDsOut) external
Input : _receiver is the receiver of the purchased USDs _spaIn is the amount of SPA to be sold _minUSDsOut is the minimum amount of USDs to be received
Output : The contract will extract _spaIn amount of SPA from the wallet executing the transaction, exchange it to USDs, and send USDs to the _receiver wallet
Example : Suppose wallet A triggers buyUSDs(B, 100*1e18, 1e18) (after he has already approved the Buyback contract to spend its SPA). The contract will extract 100 SPA from A, exchange it to USDs, and send USDs to B.
Last updated