Skip to content

Commit

Permalink
Merge pull request #65 from securesecrets/docs-router-error-notes
Browse files Browse the repository at this point in the history
Docs router error notes
  • Loading branch information
AustinWoetzel authored Nov 27, 2023
2 parents e7a7e1a + 59cf9a0 commit d35d5cf
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
5 changes: 0 additions & 5 deletions .changeset/curvy-tomatoes-drop.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/slimy-jokes-pull.md

This file was deleted.

12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# shadejs

## 1.0.4

### Patch Changes

- af89f58: type exports added

## 1.0.3

### Patch Changes

- 352f79d: add missing types field in package.json#exports

## 1.0.2

### Patch Changes
Expand Down
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.
:::

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@shadeprotocol/shadejs",
"description": "The Typescript SDK for Shade Protocol",
"version": "1.0.2",
"version": "1.0.4",
"author": "Secure Secrets",
"bugs": {
"url": "https://github.com/securesecrets/shadejs/issues"
Expand Down

0 comments on commit d35d5cf

Please sign in to comment.