kinto-core icon indicating copy to clipboard operation
kinto-core copied to clipboard

Draft: MasterSwapper

Open rrecuero opened this issue 8 months ago • 1 comments

Description

On Kinto:

  1. User wallet creates an intent to swap with min amount out and deadline.
  2. Relayer pulls all the assets from all the swaps and sends assets to users minus the swap fee.
  3. Every x mins check for misbalances, we call bridge out to bridge out the excess asset.

Offchain:

  • Similar to balancer we just need to settle the net amount of asset changes after all the swaps, reducing number of swap operations and gas required. Then we need to purchase on whatever chain the difference and bridge back to Kinto to the master swapper contract.

For example if we start with 50 WETH and 50 stETH in the swapper and there are 10 swaps and in the end we end up with 60stETH and 40WETH, then we need to bridge our 10stETH, swapped that 10stETH for WETH and bridge the WETH back to Kinto to the master swapper contract.

Type of change

  • [ ] Bug fix
  • [X] New feature
  • [ ] Breaking change
  • [ ] Dependency changes
  • [ ] Deployment
  • [ ] Forge Script
  • [ ] Code refactor / cleanup
  • [ ] Documentation or wording changes
  • [ ] Other

Checklist:

  • [ ] The diff is legible and has no extraneous changes
  • [ ] Complex code has been commented, including external interfaces
  • [ ] Tests have 100% code coverage
  • [ ] The base branch is either main, or there's a description of how to merge

Issue Resolution

rrecuero avatar Jun 19 '24 17:06 rrecuero