Skip to content

Commit

Permalink
Merge pull request #66 from securesecrets/develop
Browse files Browse the repository at this point in the history
update docs for router error clarity
  • Loading branch information
AustinWoetzel authored Nov 27, 2023
2 parents 6159c09 + d35d5cf commit 752e747
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/calculations/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function calculateRoute({
pairs,
tokens,
}:{
inputTokenAmount: BigNumber,
inputTokenAmount: BigNumber, // amount in uDenom
inputTokenContractAddress: string,
path: string[], // path determined by getPossiblePaths
pairs: BatchPairsInfo,
Expand All @@ -47,6 +47,9 @@ function calculateRoute({
::: tip
We pass in a list of all possible tokens (TokensConfig) so that we have access to their decimals for uDenom conversions. This is not the most elegant solution as it may be preferrable to reference your own data store for token data. In that case, you can create your own route calculator and use the ShadeJS one as a guide.
:::
::: warning
Ensure tokenConfig contains no duplicate tokens as this will trigger an error in order to prevent a bad config from being used.
:::
```ts
type TokenConfig = {
tokenContractAddress: string,
Expand Down Expand Up @@ -99,4 +102,7 @@ function getRoutes({
::: warning
This function optimizes for maximizing the output token amount only. It does NOT factor in the value of the gas for the extra hops (i.e. gas multiplier) relative to the value of tokens received. This will especially impact small trades where there is perceived arbitrage opportunities through certain paths, without factoring in the gas cost to perform the arbitrage. It is recommended that you create your own route calculator to handle token values and use the one provided here as a guide.
:::
::: tip
Any errors encountered during a route calculation (ex: stableswap price impact tolerance exceeded, bad token config, missing pair data, etc.) will result in skipping this route as an option in the output. Errors in all possible routes will return an empty array, meaning that no successful route exists. You are encouraged to modify this example router if you wish to collect specific errors on each possible route and do something with that error data.
:::

0 comments on commit 752e747

Please sign in to comment.