- Clone repo.
- Approve unlimited
TEMPLEspending to0xBA12222222228d8Ba445958a75a0704d566BF2C8(balancer vault) - Approve unlimited
FRAXspending to0x98257C876ACe5009e7B97843F8c71b3AE795c71E(temple amm router) $ export INFURA=<your_infura_key>$ export PRIVATE_KEY=<your_private_key>- Edit
parametersinbot/index.ts $ yarn start
- Get balancer temple > dai quote using SOR(smart order routing) from balancer-sdk
- Assume dai and frax always peg, pass the dai output from last step as frax input to get frax > temple quote
- Subtract the output from step 2 with the input from step 1 to get possible
- Use the price parameters in the
parametersto convert temple profit to ether and estimate the net profit in ether - Estimate the gas of both balancer swap and temple swap and sum them up, catch errors if they happen.
- Subtract estimated net profit in ether with the estimated gas cost to get possible
gross profit - If the gross profit is > 0, pack the transactions as a flashbot bundle and send it to the flashbots relay
- Wait for the result, in this version the program will exit(0) after a success swap
- Could do a slight modification to make it swap the dai to frax and keep looping the process.
- Could refactor the codes using multicall and better architecture to speed up the process
- Could add another tx to make it an atomic process of Temple > DAI > FRAX > Temple