From c34c7c3012368d2d351ced5fdb59ba116e8d1833 Mon Sep 17 00:00:00 2001 From: Sluder Date: Tue, 15 Aug 2023 08:03:24 -0400 Subject: [PATCH] v4.0.2 --- CHANGELOG.md | 3 +++ package.json | 2 +- src/dex/minswap.ts | 21 ++++++++------------- src/dex/wingriders.ts | 4 ++-- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 012d1cd..68485b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to Dexter will be documented in this file. +## [v4.0.2] +- Fix pool identifiers & LP token for Minswap. + ## [v4.0.1] - Remove total LP tokens from fetched data. This data is not needed for swapping, and wastes a lot of network requests. - Add `setProviderForDex()` to use different data providers for each DEX. diff --git a/package.json b/package.json index 5236b18..9a203eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@indigo-labs/dexter", - "version": "4.0.1", + "version": "4.0.2", "license": "MIT", "author": "Zachary Sluder", "keywords": [ diff --git a/src/dex/minswap.ts b/src/dex/minswap.ts index 22cb6ea..c0e0cd0 100644 --- a/src/dex/minswap.ts +++ b/src/dex/minswap.ts @@ -6,8 +6,6 @@ import { AssetAddress, AssetBalance, DatumParameters, - DefinitionConstr, - DefinitionField, PayToAddress, RequestConfig, SwapFee, @@ -16,7 +14,6 @@ import { import { DefinitionBuilder } from '@app/definition-builder'; import { correspondingReserves } from '@app/utils'; import { AddressType, DatumParameterKey } from '@app/constants'; -import pool from '@dex/definitions/minswap/pool'; import order from '@dex/definitions/minswap/order'; import { BaseApi } from '@dex/api/base-api'; import { MinswapApi } from '@dex/api/minswap-api'; @@ -106,16 +103,14 @@ export class Minswap extends BaseDex { ); // Load additional pool information - const possibleLpTokens: Asset[] = utxo.assetBalances.filter((assetBalance: AssetBalance) => { - return assetBalance.asset !== 'lovelace' && assetBalance.asset.policyId === this.lpTokenPolicyId; - }).map((assetBalance: AssetBalance) => assetBalance.asset as Asset); - - if (possibleLpTokens.length > 1) { - return undefined; - } else if (possibleLpTokens.length === 1) { - liquidityPool.lpToken = possibleLpTokens[0]; - liquidityPool.identifier = possibleLpTokens[0].policyId; - } + const poolNft: Asset | undefined = utxo.assetBalances.find((assetBalance: AssetBalance) => { + return assetBalance.asset !== 'lovelace' && assetBalance.asset.policyId === this.poolNftPolicyId; + })?.asset as Asset; + + if (! poolNft) return undefined; + + liquidityPool.lpToken = new Asset(this.lpTokenPolicyId, poolNft.nameHex); + liquidityPool.identifier = poolNft.nameHex; liquidityPool.poolFeePercent = 0.3; diff --git a/src/dex/wingriders.ts b/src/dex/wingriders.ts index aa6ef11..2273192 100644 --- a/src/dex/wingriders.ts +++ b/src/dex/wingriders.ts @@ -107,12 +107,12 @@ export class WingRiders extends BaseDex { relevantAssets[assetAIndex].asset, relevantAssets[assetBIndex].asset, relevantAssets[assetAIndex].asset === 'lovelace' - ? (assetAQuantity - MIN_POOL_ADA < 1_000_000) + ? (assetAQuantity - MIN_POOL_ADA < 1_000_000n) ? assetAQuantity - MIN_POOL_ADA : assetAQuantity : assetAQuantity, relevantAssets[assetBIndex].asset === 'lovelace' - ? (assetBQuantity - MIN_POOL_ADA < 1_000_000) + ? (assetBQuantity - MIN_POOL_ADA < 1_000_000n) ? assetBQuantity - MIN_POOL_ADA : assetBQuantity : assetBQuantity,