Sperax
Search…
⌃K

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. 1.
    Protocol Yield - The yield is collected in multiple tokens through pool fee (USDC, FRAX, VST, etc) and farm rewards (like CRV, FXS, VSTA, 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. 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. 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. 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 Frax and VST into the Curve pool and then stakes the LP token in the Frax gauge to earn FXS and VSTA tokens. Protocol earns FXS and VSTA token.
  1. 1.
    Sell the FXS tokens for Frax using Fraxswap
  2. 2.
    Mint USDs using the Frax collected
  3. 3.
    Transfer the USDs to the Buyback contract.
  4. 4.
    Deposit USDs Mint and Redemption Fees directly into the Buyback contract as and when they are collected
  5. 5.
    Users can view the amount of USDs left in the contract
  6. 6.
    USDs is bought by the users using their SPA and contract receives SPA against the USDs

Technical Specification

Buyback Architechture

View Functions

  1. 1.
    getSPAReqdForUSDs - Input the target USDs amount to receive and get an estimate of how many SPA tokens are needed.
    1. 1.
      Function: getSPAReqdForUSDs(uint256 _usdsAmount) external view returns (uint256)
    2. 2.
      Input : _usdsAmount is the amount of USDs to purchase
    3. 3.
      Output: Estimated amount of SPA required
    4. 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. 2.
    getUsdsOutForSpa - Input the amount of SPA to be sold and get an estimate of how many USDs can be purchased.
    1. 1.
      Function: getUsdsOutForSpa(uint256 _spaIn) external view returns (uint256)
    2. 2.
      Input : _spaIn is the amount of SPA to be sold
    3. 3.
      Output: Estimated amount of USDs to be received
    4. 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. 1.
    buyUSDs - Purchase USDs with SPA
    1. 1.
      Function: buyUSDs(uint256 _spaIn, uint256 _minUSDsOut) external
    2. 2.
      Input : _spaIn is the amount of SPA to be sold _minUSDsOut is the minimum amount of USDs to be received
    3. 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. 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. 2.
    buyUSDs - Purchase USDs with SPA (arbitrary USDs receipt)
    1. 1.
      Function: buyUSDs(address _receiver, uint256 _spaIn, uint256 _minUSDsOut) external
    2. 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. 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. 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.