skip-mev / skip-go-cosmwasm-contracts

CosmWasm Contracts for Skip Go
Apache License 2.0
27 stars 25 forks source link

🐛 Astroport Slippage Fix #76

Closed NotJeremyLiu closed 11 months ago

NotJeremyLiu commented 11 months ago

Background

This PR

Swap Side

  1. Adds a max_spread amount of .50 (50%) to the Astroport router swaps, which is the max limit that can be set (Previously without setting this param, the max_spread defaulted to Astroport's default of .005)

Query Side:

  1. Asserts the max spread limit is not crossed in both swap exact in and swap exact out simulation query for Astroport
  2. Changes/refactors swap exact in simulation to call simulation query on each pool instead of the router (since the router doesn't return back enough info to assert the max spread limit calculation enforcement) for Astroport

Testing

  1. Tested the new swap in query gives back the same result as the astroport router:
  2. Tested that the max_spread_assertion query fails when expected
  3. Tested a successful swap tx that was previously failing with an error of max slippage limit crossed: https://www.mintscan.io/osmosis/tx/4867E0A4914F90CB6F97406406B8F67B3D8A44AF845BC090ACDFCFE2A3B4F246?height=12288371