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.

  1. 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.

  2. 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.

  3. Buyback SPA - Any users or external wallet can view the USDs balance in the Buyback contract and sell their SPA tokens for USDs.

  4. 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.

  1. Sell STG tokens for USDC.e

  2. Mint USDs from USDC.e

  3. Transfer USDs to the Buyback contract.

  4. Deposit USDs Mint and Redemption Fees directly into the Buyback contract as and when they are collected

  5. Users can view the amount of USDs left in the contract

  6. USDs is bought by the users using their SPA and contract receives SPA against the USDs

Technical Specification

Buyback Architechture

View Functions

  1. getSPAReqdForUSDs - Input the target USDs amount to receive and get an estimate of how many SPA tokens are needed.

    1. Function: getSPAReqdForUSDs(uint256 _usdsAmount) external view returns (uint256)

    2. Input : _usdsAmount is the amount of USDs to purchase

    3. Output: Estimated amount of SPA required

    4. 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.

  2. getUsdsOutForSpa - Input the amount of SPA to be sold and get an estimate of how many USDs can be purchased.

    1. Function: getUsdsOutForSpa(uint256 _spaIn) external view returns (uint256)

    2. Input : _spaIn is the amount of SPA to be sold

    3. Output: Estimated amount of USDs to be received

    4. 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

  1. buyUSDs - Purchase USDs with SPA

    1. Function: buyUSDs(uint256 _spaIn, uint256 _minUSDsOut) external

    2. Input : _spaIn is the amount of SPA to be sold _minUSDsOut is the minimum amount of USDs to be received

    3. 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

    4. 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.

  2. buyUSDs - Purchase USDs with SPA (arbitrary USDs receipt)

    1. Function: buyUSDs(address _receiver, uint256 _spaIn, uint256 _minUSDsOut) external

    2. 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

    3. 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

    4. 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