Skip to content

Commit

Permalink
Version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Sluder committed Nov 25, 2024
1 parent 6c577d6 commit b15444a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@indigo-labs/dexter",
"version": "5.4.7",
"version": "5.4.8",
"license": "MIT",
"author": "Zachary Sluder",
"keywords": [
Expand Down
7 changes: 6 additions & 1 deletion src/dex/wingriders-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,13 @@ export class WingRidersV2 extends BaseDex {
}

priceImpactPercent(liquidityPool: LiquidityPool, swapInToken: Token, swapInAmount: bigint): number {
const swapOutTokenDecimals: number = tokensMatch(liquidityPool.assetA, swapInToken)
? (liquidityPool.assetB === 'lovelace' ? 6 : liquidityPool.assetB.decimals)
: (liquidityPool.assetA === 'lovelace' ? 6 : liquidityPool.assetA.decimals)

const estimatedReceive: bigint = this.estimatedReceive(liquidityPool, swapInToken, swapInAmount);
const swapPrice: number = Number(swapInAmount) / Number(estimatedReceive);
const swapPrice: number = (Number(swapInAmount) / 10**(swapInToken === 'lovelace' ? 6 : swapInToken.decimals))
/ (Number(estimatedReceive) / 10**swapOutTokenDecimals);
const poolPrice: number = tokensMatch(liquidityPool.assetA, swapInToken)
? liquidityPool.price
: (1 / liquidityPool.price);
Expand Down
7 changes: 6 additions & 1 deletion src/dex/wingriders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,13 @@ export class WingRiders extends BaseDex {
}

priceImpactPercent(liquidityPool: LiquidityPool, swapInToken: Token, swapInAmount: bigint): number {
const swapOutTokenDecimals: number = tokensMatch(liquidityPool.assetA, swapInToken)
? (liquidityPool.assetB === 'lovelace' ? 6 : liquidityPool.assetB.decimals)
: (liquidityPool.assetA === 'lovelace' ? 6 : liquidityPool.assetA.decimals)

const estimatedReceive: bigint = this.estimatedReceive(liquidityPool, swapInToken, swapInAmount);
const swapPrice: number = Number(swapInAmount) / Number(estimatedReceive);
const swapPrice: number = (Number(swapInAmount) / 10**(swapInToken === 'lovelace' ? 6 : swapInToken.decimals))
/ (Number(estimatedReceive) / 10**swapOutTokenDecimals);
const poolPrice: number = tokensMatch(liquidityPool.assetA, swapInToken)
? liquidityPool.price
: (1 / liquidityPool.price);
Expand Down

0 comments on commit b15444a

Please sign in to comment.