A complete script to automatically yield farm and compound through Solidex using ethersjs
Saddle is partners with Solidex and Solidly on Fantom network. Being active defi participants ourselves, some Saddle staff members are LPing, staking, and/or farming through Solidex. We thought it might be fun to share with the community an example of what one of our personal farming scripts looks like. The script assumes that you are LPing in the USDC/SYN
pool. It will harvest your rewards once you have accumulated $500 claimable and will sell to LP in the SOLID/SOLIDsex
pool for additional yield while holding $SEX
This script has 6 Steps that run on a regular internal:
- Fetch the pending rewards for your account
- Get the USDC price of the reward tokens (
SOLID
andSEX
)
Continue only if you rewards are worth >$500
- Claim all of your rewards
- Swap 1/2 of your awarded
SOLID
toSOLIDsex
- Add liquidity to the Solidly
SOLID/SOLIDsex
pool - Deposit Solidly lpToken into Solidex pool
- Install dependencies
npm ci
- Create
.env
file and add your wallet's keyPRIVATE_KEY=xxx
- Run the script
npm run start
Set POLLING_INTERVAL_MS
, USD_THRESHOLD
, and GAS_PRICE
to fit your needs
Note that the Solidex contracts use true/false
in their routes to denote stable/volatile
pools.
For example, the following code will give you the exchange rate through the stable pool (sAMM) rather than volatile pool (vAMM)
await routerContract.getAmountsOut(
amount,
[
[TOKENS.SOLID.address, TOKENS.SOLIDSEX.address, true],
]
)
This is not financial advice. This script exists for demonstration purposes only and should not be used with real funds. Don't share your wallet's private key with anyone and don't check it into a git repo. We accept no liability for how anyone chooses to use this script.