-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Seamless Rebalance Orders using Flash Loan Routing not being solved.
Overview
Seamless is looking to use the flash-loan-router and app data to allow solvers to rebalance Seamless's Leverage Tokens.
Moving forward we are also considering using programmatic orders to create these orders.
We have worked through the design and submitted rebalance orders to production using Flash Loan Router using two approaches
- Using the Settlement Contract as the flash loan receiver. Rebalance Order Cow Explorer
- Using the Maker as the flash loan receiver and using approvals to ensure flash loan repayment. Rebalance Order Cow Explorer
We have been able to test locally ensuring that the scenario 2 works with a custom solver. However the production orders, although profitable, we're not solved.
This request is to review the seamless rebalancing logic to ensure that we are creating orders correctly.
Below you will find detailed information including the order payloads and sample scripts used to create the orders.
Appendix A - Order using Settlement Contract as Receiver
-
LeverageToken : 0xE282a1A02A7b607d616B3311fE528d1Af4A31233
-
RebalanceAdapter : 0x527bFa9a7A48264D1E64b0064E9a54e0145946eb
-
Pre Approvals from Maker
-
Flash Loan
- Buy Token wstETH
- Liquidity Provider: Aave Pool
0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2 - Protocol Adapter: Aave Flash Borrower
0x7d9C4DeE56933151Bc5C909cfe09DEf0d315CB4A - Receiver : Settlement Contract
0x9008d19f58aabd9ed0d60971565aa8510560ab41
-
Pre Hooks
- AaveBorrower approve function of Approves wstETH to Cow Settlement (maxUint256)
- TransferFrom AaveBorrower to CowSettlement (amountIn(flashLoanAmount))
- Approve RebalanceAdapter for wstETH for maxUint256
- RebalanceAdapter take function for amountOut (flashLoanAmount+ fee)
-
Settlement
- Sell Token (WETH) comes from Maker
- Buy Token (wstETH) comes from Solver
-
Post Hook
- Transfer wstETH to AaveBorrower(buyAmount)
- AaveBorrower approve wstEth to AavePool (maxUint256)
-
Flash Loan Repayment (Custom Solver)
- Flash Loan Borrower repays wstETH (+ fee) to Aave Pool
Appendix B - Order using Maker as Receiver and approvals
- Rebalance Order Cow Explorer
- RebalanceScipt.ts
- Order Payload
- Order AppData
- LeverageToken : 0xeE2aE3A033154dE692f1E14B4E8fBAD5Bce18E7a
- RebalanceAdapter : 0x0aD07431771021Bb861De576c964B5e00b02b3Bf
Maker - has dust of the Collateral Token wstETH
- Pre Approvals from Maker
- Sell Token (WETH) to cowVaultRelayer
- Sell Token (WETH) to cowStandardTrampoline
- Buy Token (wstETH) to cowStandardTrampoline
- Buy Token (wstETH) to aaveBorrower
- Flash Loan
- Buy Token wstETH
- Liquidity Provider: Aave Pool
0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2 - Protocol Adapter: Aave Flash Borrower
0x7d9C4DeE56933151Bc5C909cfe09DEf0d315CB4A - Receiver : Cow Standard Trampoline
0x60Bf78233f48eC42eE3F101b9a05eC7878728006
- Pre Hooks
- Approves wstETH to the Rebalance Adapter
- Rebalance Adapter Take Call using flash loaned wstETH and returning WETH to the Cow Standard Trampoline
- transfers WETH to the Maker (to be used in Settlement)
- Settlement
- Sell Token (WETH) comes from Maker
- Buy Token (wstETH) comes from Solver
- Post Hook
- Cow TransferFrom Maker Buy Token (wstETH) to AaveBorrower
- Flash Loan Repayment (Custom Solver)
- Flash Loan Borrower repays wstETH (+ fee) to Aave Pool