@dhedge/v2-sdk 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/v2-sdk",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "license": "MIT",
5
5
  "description": "🛠 An SDK for building applications on top of dHEDGE V2",
6
6
  "main": "dist/index.js",
@@ -8,10 +8,16 @@ import { isPool, loadPool } from "./pool";
8
8
 
9
9
  export async function getPoolDepositAsset(
10
10
  pool: Pool,
11
- poolAddress: string
11
+ poolAddress: string,
12
+ investAsset: string
12
13
  ): Promise<string | undefined> {
13
14
  const torosPool = await loadPool(pool, poolAddress);
14
15
  const composition = await torosPool.getComposition();
16
+ if (
17
+ composition.find(e => e.asset.toLowerCase() === investAsset.toLowerCase())
18
+ ?.isDeposit
19
+ )
20
+ return investAsset;
15
21
  return composition.find(e => e.isDeposit)?.asset;
16
22
  }
17
23
 
@@ -90,7 +96,11 @@ export async function getEasySwapperTxData(
90
96
  minAmountOut.mul(10000 - slippage * 100).div(10000)
91
97
  ]);
92
98
  } else {
93
- const depositAsset = await getPoolDepositAsset(pool, torosAsset);
99
+ const depositAsset = await getPoolDepositAsset(
100
+ pool,
101
+ torosAsset,
102
+ investAsset
103
+ );
94
104
  if (!depositAsset) throw new Error("no deposit assets");
95
105
  const minAmountOut = await getEasySwapperDepositQuote(
96
106
  pool,