Skip to content

Commit

Permalink
Merge pull request #120 from securesecrets/price-impact-error-improve…
Browse files Browse the repository at this point in the history
…ment

Price impact error improvement
  • Loading branch information
AustinWoetzel authored Mar 29, 2024
2 parents 211e3a2 + 80f593f commit def9038
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-taxis-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shadeprotocol/shadejs": patch
---

clarity around price impact error
2 changes: 1 addition & 1 deletion src/lib/swap/stableswapCurve/stable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ test('slippage calculations correct', () => {

// slippage limit
conf = getConfSmallPool();
expect(() => conf.swapToken0WithToken1(BigNumber(100000000))).toThrowError(/^The slippage of this trade.*/);
expect(() => conf.swapToken0WithToken1(BigNumber(100000000))).toThrowError(/^The price impact of this trade.*/);
});

test('py correct', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/swap/stableswapCurve/stable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ export class StableConfig {
tradeDirIs0For1,
});
if (priceImpact.isGreaterThan(this.priceImpactLimit) || priceImpact.isLessThan(BigNumber(0))) {
throw Error(`The slippage of this trade is outside of the acceptable range of 0% - ${this.priceImpactLimit}%.`);
throw Error(`The price impact of this trade (${priceImpact.toString()}%) is outside of the acceptable range of 0% - ${this.priceImpactLimit}%.`);
}
}

Expand Down

0 comments on commit def9038

Please sign in to comment.