@shapeshiftoss/swapper 14.2.0 → 14.2.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.
|
@@ -114,8 +114,8 @@ const findPool = async (sellAssetSymbol, buyAssetSymbol, osmoUrl) => {
|
|
|
114
114
|
}
|
|
115
115
|
})();
|
|
116
116
|
const foundPool = (0, lodash_1.find)(poolsResponse.data.pools, (pool) => {
|
|
117
|
-
const token0Denom = pool.
|
|
118
|
-
const token1Denom = pool.
|
|
117
|
+
const token0Denom = pool.pool_assets[0].token.denom;
|
|
118
|
+
const token1Denom = pool.pool_assets[1].token.denom;
|
|
119
119
|
return ((token0Denom === sellAssetDenom && token1Denom === buyAssetDenom) ||
|
|
120
120
|
(token0Denom === buyAssetDenom && token1Denom === sellAssetDenom));
|
|
121
121
|
});
|
|
@@ -124,7 +124,7 @@ const findPool = async (sellAssetSymbol, buyAssetSymbol, osmoUrl) => {
|
|
|
124
124
|
code: index_1.SwapErrorTypes.POOL_NOT_FOUND,
|
|
125
125
|
});
|
|
126
126
|
const { sellAssetIndex, buyAssetIndex } = (() => {
|
|
127
|
-
if (foundPool.
|
|
127
|
+
if (foundPool.pool_assets[0].token.denom === sellAssetDenom) {
|
|
128
128
|
return { sellAssetIndex: 0, buyAssetIndex: 1 };
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
@@ -134,9 +134,9 @@ const findPool = async (sellAssetSymbol, buyAssetSymbol, osmoUrl) => {
|
|
|
134
134
|
return { pool: foundPool, sellAssetIndex, buyAssetIndex };
|
|
135
135
|
};
|
|
136
136
|
const getInfoFromPool = (sellAmount, pool, sellAssetIndex, buyAssetIndex) => {
|
|
137
|
-
const constantProduct = (0, bignumber_1.bnOrZero)(pool.
|
|
138
|
-
const sellAssetInitialPoolSize = (0, bignumber_1.bnOrZero)(pool.
|
|
139
|
-
const buyAssetInitialPoolSize = (0, bignumber_1.bnOrZero)(pool.
|
|
137
|
+
const constantProduct = (0, bignumber_1.bnOrZero)(pool.pool_assets[0].token.amount).times(pool.pool_assets[1].token.amount);
|
|
138
|
+
const sellAssetInitialPoolSize = (0, bignumber_1.bnOrZero)(pool.pool_assets[sellAssetIndex].token.amount);
|
|
139
|
+
const buyAssetInitialPoolSize = (0, bignumber_1.bnOrZero)(pool.pool_assets[buyAssetIndex].token.amount);
|
|
140
140
|
const initialMarketPrice = sellAssetInitialPoolSize.dividedBy(buyAssetInitialPoolSize);
|
|
141
141
|
const sellAssetFinalPoolSize = sellAssetInitialPoolSize.plus(sellAmount);
|
|
142
142
|
const buyAssetFinalPoolSize = constantProduct.dividedBy(sellAssetFinalPoolSize);
|
|
@@ -144,7 +144,7 @@ const getInfoFromPool = (sellAmount, pool, sellAssetIndex, buyAssetIndex) => {
|
|
|
144
144
|
const buyAmount = buyAssetInitialPoolSize.minus(buyAssetFinalPoolSize).toString();
|
|
145
145
|
const rate = (0, bignumber_1.bnOrZero)(buyAmount).dividedBy(sellAmount).toString();
|
|
146
146
|
const priceImpact = (0, bignumber_1.bn)(1).minus(initialMarketPrice.dividedBy(finalMarketPrice)).abs().toString();
|
|
147
|
-
const tradeFeeBase = (0, bignumber_1.bnOrZero)(buyAmount).times((0, bignumber_1.bnOrZero)(pool.
|
|
147
|
+
const tradeFeeBase = (0, bignumber_1.bnOrZero)(buyAmount).times((0, bignumber_1.bnOrZero)(pool.pool_params.swap_fee));
|
|
148
148
|
const buyAssetTradeFeeUsd = tradeFeeBase
|
|
149
149
|
.dividedBy((0, bignumber_1.bn)(10).exponentiatedBy(constants_1.OSMOSIS_PRECISION))
|
|
150
150
|
.toString();
|
|
@@ -210,7 +210,7 @@ const performIbcTransfer = async (input, adapter, wallet, blockBaseUrl, denom, s
|
|
|
210
210
|
txToSign: {
|
|
211
211
|
tx,
|
|
212
212
|
addressNList: (0, chain_adapters_1.toAddressNList)(adapter.buildBIP44Params({ accountNumber: 0 })),
|
|
213
|
-
chain_id: caip_1.
|
|
213
|
+
chain_id: (0, caip_1.fromChainId)(adapter.getChainId()).chainReference,
|
|
214
214
|
account_number: accountNumber,
|
|
215
215
|
sequence,
|
|
216
216
|
},
|
|
@@ -11,9 +11,9 @@ export declare type IbcTransferInput = {
|
|
|
11
11
|
amount: string;
|
|
12
12
|
};
|
|
13
13
|
export declare type PoolInfo = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
pool_assets: PoolAssetInfo[];
|
|
15
|
+
pool_params: {
|
|
16
|
+
swap_fee: string;
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
export declare type PoolAssetInfo = {
|
package/package.json
CHANGED