Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update swap aggregator (frontend quote) integrations #20

Open
SamusElderg opened this issue Jan 25, 2023 · 0 comments
Open

Update swap aggregator (frontend quote) integrations #20

SamusElderg opened this issue Jan 25, 2023 · 0 comments

Comments

@SamusElderg
Copy link
Collaborator

Currently 1inch etc must be using some complex logic to calculate swap estimated outputs for their frontend/api for SPv2 pools, now that we have an easy swapQuote endpoint we should reach out and make this easier for them

Endpoint details below 👇

/v1/swapQuote?inputAddr=0x...&outputAddr=0x...&inputUnits=100000000000000000000

Returns estimated swap output for swapping InputToken * InputUnits -> OutputToken via SpartanProtocol V2 AMM.
inputUnits type is WEI (not units). So if you want to swap 1.00 BNB/unit you would enter 1000000000000000000.
The return amount is also in WEI as a string, so interfaces will need to convert from WEI -> units for users.
When swapping to/from BNB you can enter either the WBNB address (0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c) or the BNB address (0x0000000000000000000000000000000000000000) the API will convert both to the corresponding correct WBNB pool.

Request

GET https://api.spartanprotocol.org/api/v1/swapQuote?inputAddr=0x55d398326f99059fF775485246999027B3197955&outputAddr=0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56&inputUnits=100000000000000000000

Response

"100019501036169151511"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant