Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Latest commit

 

History

History
60 lines (44 loc) · 2.42 KB

README.md

File metadata and controls

60 lines (44 loc) · 2.42 KB

Autofarm V2

Deployment

  1. Assign team roles JSON at ./config/roles.json.
  2. Set environment variables TREASURY_ADDRESS and SAV_ADDRESS.
  3. Run forge script script/deploy-autofarm.sol --rpc-url bsc --private-key $PRIVATE_KEY --verify --verifier etherscan --broadcast.

WHAT'S NEW in V2

ERC4626 Tokenized Vault Standard compatibility:

  • Transferable shares (for future Zap/Router implementation)
  • Initial shares:token ratio is always 1-to-1

0% Entrance fee

  • Profits are vested over a period of 6 hours

Improved compounding

  • New on-chain calculation for ideal compounding interval
  • Dynamic fees: Fairer distribution of fees depending on APR.
  • Ideal liquidity ratio: Calculate ideal ratio before adding liquidity

Gas optimisations

  • Use immutable for permanent data (saves gas like constant)
  • Use SSTORE2 to reduce gas for reading/writing storage vars
  • Reduced number of subswaps: Swap altogether to one of the tokens (e.g. WBNB) then swap ~half of the WBNB to the other token
  • Bypass dex router, swap directly through pairs to remove
  • Aggregate fees to FeesController and convert to AUTO, burn etc in bulk

Improved security

  • Team-decentralized emergency pause button. Assets will be withdrawn from the farm into the Strat.
  • Trustless rescue operations: Allow devs to call arbitrary contracts that do not involve the Strat's asset token.
  • Automated testing by forking mainnet for all vaults before deployment.

Design Principles

Immutability

As with V1, Strats are not equipped with centralised migrator method, nor is the core Strat behaviour configurable after deployment, such as the Strat's contract code, underlying asset and farm, earned token, and compounding swaps path. This ensures users' risk assessments upon their deposit is respected.

Progressive decentralization

Allowing team members from different timezones to pause Strats and unlock assets increases the response time to emergency situations. The Strats are also equipped with Rescue Operations method, which is centralised but trustless.

Composability

StratX4 is agnostic of the underlying farming and compounding logic. This allows faster development of new vaults.

Bibliography