@shapeshiftoss/swapper 14.4.1 → 14.5.1

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/dist/api.d.ts CHANGED
@@ -118,7 +118,8 @@ export interface TradeQuote<C extends ChainId> extends TradeBase<C> {
118
118
  allowanceContract: string;
119
119
  minimumCryptoHuman: string;
120
120
  maximum: string;
121
- /** @deprecated Use sellAmountCryptoHuman instead */
121
+ recommendedSlippage?: string;
122
+ /** @deprecated Use minimumCryptoHuman instead */
122
123
  minimum?: string;
123
124
  }
124
125
  export interface Trade<C extends ChainId> extends TradeBase<C> {
@@ -144,7 +145,7 @@ export declare type ApprovalNeededInput<C extends ChainId> = {
144
145
  wallet: HDWallet;
145
146
  };
146
147
  export declare type SwapSource = {
147
- name: string;
148
+ name: SwapperName;
148
149
  proportion: string;
149
150
  };
150
151
  export interface MinMaxOutput {
@@ -202,7 +203,7 @@ export declare enum SwapErrorTypes {
202
203
  }
203
204
  export interface Swapper<T extends ChainId> {
204
205
  /** Human-readable swapper name */
205
- readonly name: string;
206
+ readonly name: SwapperName;
206
207
  /** perform any necessary async initialization */
207
208
  initialize?(): Promise<void>;
208
209
  /** Returns the swapper type */
@@ -244,6 +245,9 @@ export interface Swapper<T extends ChainId> {
244
245
  * Get supported sell assetIds
245
246
  */
246
247
  filterAssetIdsBySellable(assetIds: AssetId[]): AssetId[];
248
+ /**
249
+ * Get transactions related to a trade
250
+ */
247
251
  getTradeTxs(tradeResult: TradeResult): Promise<TradeTxs>;
248
252
  }
249
253
  export {};
@@ -1,8 +1,9 @@
1
+ import { SwapperName } from '../../../api';
1
2
  export declare const MAX_ALLOWANCE = "100000000000000000000000000";
2
3
  export declare const MAX_COWSWAP_TRADE = "100000000000000000000000000";
3
4
  export declare const MIN_COWSWAP_VALUE_USD = 20;
4
5
  export declare const DEFAULT_SOURCE: {
5
- name: string;
6
+ name: SwapperName;
6
7
  proportion: string;
7
8
  }[];
8
9
  export declare const DEFAULT_ADDRESS = "0x0000000000000000000000000000000000000000";
@@ -2,10 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.COW_SWAP_ETH_MARKER_ADDRESS = exports.ORDER_STATUS_FULFILLED = exports.ERC20_TOKEN_BALANCE = exports.SIGNING_SCHEME = exports.ORDER_KIND_BUY = exports.ORDER_KIND_SELL = exports.WETH_ASSET_ID = exports.COW_SWAP_SETTLEMENT_ADDRESS = exports.COW_SWAP_VAULT_RELAYER_ADDRESS = exports.DEFAULT_APP_DATA = exports.DEFAULT_ADDRESS = exports.DEFAULT_SOURCE = exports.MIN_COWSWAP_VALUE_USD = exports.MAX_COWSWAP_TRADE = exports.MAX_ALLOWANCE = void 0;
4
4
  const constants_1 = require("@ethersproject/constants");
5
+ const api_1 = require("../../../api");
5
6
  exports.MAX_ALLOWANCE = '100000000000000000000000000';
6
7
  exports.MAX_COWSWAP_TRADE = '100000000000000000000000000';
7
8
  exports.MIN_COWSWAP_VALUE_USD = 20;
8
- exports.DEFAULT_SOURCE = [{ name: 'CowSwap', proportion: '1' }];
9
+ exports.DEFAULT_SOURCE = [{ name: api_1.SwapperName.CowSwap, proportion: '1' }];
9
10
  exports.DEFAULT_ADDRESS = constants_1.AddressZero;
10
11
  exports.DEFAULT_APP_DATA = '0x68a7b5781dfe48bd5d7aeb11261c17517f5c587da682e4fade9b6a00a59b8970';
11
12
  exports.COW_SWAP_VAULT_RELAYER_ADDRESS = '0xc92e8bdf79f0507f65a392b0ab4667716bfe0110';
@@ -116,7 +116,7 @@ class OsmosisSwapper {
116
116
  sellAmountCryptoPrecision: sellAmountCryptoBase,
117
117
  sellAsset,
118
118
  bip44Params,
119
- sources: [{ name: 'Osmosis', proportion: '100' }],
119
+ sources: [{ name: api_1.SwapperName.Osmosis, proportion: '100' }],
120
120
  };
121
121
  }
122
122
  async getTradeQuote(input) {
@@ -1,5 +1,6 @@
1
+ import { SwapperName } from '../../../api';
1
2
  export declare const DEFAULT_SOURCE: {
2
- name: string;
3
+ name: SwapperName;
3
4
  proportion: string;
4
5
  }[];
5
6
  export declare const MAX_SWAPPER_SELL = "100000000000000000000000000";
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OSMO_COSMO_CHANNEL = exports.COSMO_OSMO_CHANNEL = exports.OSMOSIS_PRECISION = exports.MAX_SWAPPER_SELL = exports.DEFAULT_SOURCE = void 0;
4
- exports.DEFAULT_SOURCE = [{ name: 'Osmosis', proportion: '1' }];
4
+ const api_1 = require("../../../api");
5
+ exports.DEFAULT_SOURCE = [{ name: api_1.SwapperName.Osmosis, proportion: '1' }];
5
6
  exports.MAX_SWAPPER_SELL = '100000000000000000000000000';
6
7
  exports.OSMOSIS_PRECISION = 6;
7
8
  exports.COSMO_OSMO_CHANNEL = 'channel-141';
@@ -0,0 +1,23 @@
1
+ import { AssetId } from '@shapeshiftoss/caip';
2
+ import { BN } from '../../utils/bignumber';
3
+ import { ThornodePoolResponse } from '../types';
4
+ declare type GetSingleSwapSlippageArgs = {
5
+ inputAmountThorPrecision: BN;
6
+ pool: ThornodePoolResponse;
7
+ toRune: boolean;
8
+ };
9
+ export declare const getSingleSwapSlippage: ({ inputAmountThorPrecision, pool, toRune, }: GetSingleSwapSlippageArgs) => BN;
10
+ declare type GetDoubleSwapSlippageArgs = {
11
+ inputAmountThorPrecision: BN;
12
+ sellPool: ThornodePoolResponse;
13
+ buyPool: ThornodePoolResponse;
14
+ };
15
+ export declare const getDoubleSwapSlippage: ({ inputAmountThorPrecision, sellPool, buyPool, }: GetDoubleSwapSlippageArgs) => BN;
16
+ declare type GetSlippageArgs = {
17
+ inputAmountThorPrecision: BN;
18
+ daemonUrl: string;
19
+ buyAssetId: AssetId;
20
+ sellAssetId: AssetId;
21
+ };
22
+ export declare const getSlippage: ({ inputAmountThorPrecision, daemonUrl, buyAssetId, sellAssetId, }: GetSlippageArgs) => Promise<BN>;
23
+ export {};
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSlippage = exports.getDoubleSwapSlippage = exports.getSingleSwapSlippage = void 0;
4
+ const caip_1 = require("@shapeshiftoss/caip");
5
+ const utils_1 = require("../../../utils");
6
+ const getTradeRate_1 = require("../utils/getTradeRate/getTradeRate");
7
+ const isRune_1 = require("../utils/isRune/isRune");
8
+ const thorService_1 = require("../utils/thorService");
9
+ const getSingleSwapSlippage = ({ inputAmountThorPrecision, pool, toRune, }) => {
10
+ // formula: (inputAmount) / (inputAmount + inputBalance)
11
+ const inputBalance = toRune ? pool.balance_asset : pool.balance_rune; // input is asset if toRune
12
+ const denominator = inputAmountThorPrecision.plus(inputBalance);
13
+ return inputAmountThorPrecision.div(denominator);
14
+ };
15
+ exports.getSingleSwapSlippage = getSingleSwapSlippage;
16
+ const getDoubleSwapSlippage = ({ inputAmountThorPrecision, sellPool, buyPool, }) => {
17
+ // formula: getSwapOutput(input1) + getSingleSwapSlippage(getSwapOutput(input1) => input2)
18
+ const firstSwapSlippage = (0, exports.getSingleSwapSlippage)({
19
+ inputAmountThorPrecision,
20
+ pool: sellPool,
21
+ toRune: true,
22
+ });
23
+ const firstSwapOutput = (0, getTradeRate_1.getSwapOutput)(inputAmountThorPrecision, sellPool, true);
24
+ const secondSwapSlippage = (0, exports.getSingleSwapSlippage)({
25
+ inputAmountThorPrecision: firstSwapOutput,
26
+ pool: buyPool,
27
+ toRune: false,
28
+ });
29
+ return firstSwapSlippage.plus(secondSwapSlippage);
30
+ };
31
+ exports.getDoubleSwapSlippage = getDoubleSwapSlippage;
32
+ const getSlippage = async ({ inputAmountThorPrecision, daemonUrl, buyAssetId, sellAssetId, }) => {
33
+ try {
34
+ const { data: poolData } = await thorService_1.thorService.get(`${daemonUrl}/lcd/thorchain/pools`);
35
+ const buyPoolId = caip_1.adapters.assetIdToPoolAssetId({ assetId: buyAssetId });
36
+ const sellPoolId = caip_1.adapters.assetIdToPoolAssetId({ assetId: sellAssetId });
37
+ const buyPool = buyPoolId ? poolData.find((response) => response.asset === buyPoolId) : null;
38
+ const sellPool = sellPoolId ? poolData.find((response) => response.asset === sellPoolId) : null;
39
+ const toRune = (0, isRune_1.isRune)(buyAssetId);
40
+ const fromRune = (0, isRune_1.isRune)(sellAssetId);
41
+ switch (true) {
42
+ case toRune: {
43
+ (0, utils_1.assertIsDefined)(sellPool);
44
+ return (0, exports.getSingleSwapSlippage)({
45
+ inputAmountThorPrecision,
46
+ pool: sellPool,
47
+ toRune,
48
+ });
49
+ }
50
+ case fromRune: {
51
+ (0, utils_1.assertIsDefined)(buyPool);
52
+ return (0, exports.getSingleSwapSlippage)({
53
+ inputAmountThorPrecision,
54
+ pool: buyPool,
55
+ toRune,
56
+ });
57
+ }
58
+ default: {
59
+ (0, utils_1.assertIsDefined)(sellPool);
60
+ (0, utils_1.assertIsDefined)(buyPool);
61
+ return (0, exports.getDoubleSwapSlippage)({ inputAmountThorPrecision, sellPool, buyPool });
62
+ }
63
+ }
64
+ }
65
+ catch (e) {
66
+ throw new Error(`Failed to get pool data: ${e}`);
67
+ }
68
+ };
69
+ exports.getSlippage = getSlippage;
@@ -14,6 +14,7 @@ const getUsdRate_1 = require("../utils/getUsdRate/getUsdRate");
14
14
  const isRune_1 = require("../utils/isRune/isRune");
15
15
  const getEvmTxFees_1 = require("../utils/txFeeHelpers/evmTxFees/getEvmTxFees");
16
16
  const getUtxoTxFees_1 = require("../utils/txFeeHelpers/utxoTxFees/getUtxoTxFees");
17
+ const getSlippage_1 = require("./getSlippage");
17
18
  const getThorTradeQuote = async ({ deps, input }) => {
18
19
  const { sellAsset, buyAsset, sellAmountCryptoPrecision, bip44Params, chainId, receiveAddress, sendMax, } = input;
19
20
  if (!bip44Params) {
@@ -32,6 +33,13 @@ const getThorTradeQuote = async ({ deps, input }) => {
32
33
  const rate = await (0, getTradeRate_1.getTradeRate)(sellAsset, buyAsset.assetId, sellAmountCryptoPrecision, deps);
33
34
  const buyAmountCryptoPrecision = (0, bignumber_1.toBaseUnit)((0, bignumber_1.bnOrZero)((0, bignumber_1.fromBaseUnit)(sellAmountCryptoPrecision, sellAsset.precision)).times(rate), buyAsset.precision);
34
35
  const buyAssetAddressData = await (0, getInboundAddressDataForChain_1.getInboundAddressDataForChain)(deps.daemonUrl, buyAsset.assetId);
36
+ const sellAmountThorPrecision = (0, bignumber_1.toBaseUnit)((0, bignumber_1.fromBaseUnit)(sellAmountCryptoPrecision, sellAsset.precision), constants_3.THORCHAIN_FIXED_PRECISION);
37
+ const recommendedSlippage = await (0, getSlippage_1.getSlippage)({
38
+ inputAmountThorPrecision: (0, bignumber_1.bn)(sellAmountThorPrecision),
39
+ daemonUrl: deps.daemonUrl,
40
+ buyAssetId: buyAsset.assetId,
41
+ sellAssetId: sellAsset.assetId,
42
+ });
35
43
  const estimatedBuyAssetTradeFeeFeeAssetCryptoHuman = (0, isRune_1.isRune)(buyAsset.assetId)
36
44
  ? constants_2.RUNE_OUTBOUND_TRANSACTION_FEE_CRYPTO_HUMAN.toString()
37
45
  : (0, bignumber_1.fromBaseUnit)((0, bignumber_1.bnOrZero)(buyAssetAddressData === null || buyAssetAddressData === void 0 ? void 0 : buyAssetAddressData.outbound_fee), constants_3.THORCHAIN_FIXED_PRECISION);
@@ -54,11 +62,12 @@ const getThorTradeQuote = async ({ deps, input }) => {
54
62
  maximum: constants_3.MAX_THORCHAIN_TRADE,
55
63
  sellAmountCryptoPrecision,
56
64
  buyAmountCryptoPrecision,
57
- sources: [{ name: 'thorchain', proportion: '1' }],
65
+ sources: [{ name: api_1.SwapperName.Thorchain, proportion: '1' }],
58
66
  buyAsset,
59
67
  sellAsset,
60
68
  bip44Params,
61
69
  minimumCryptoHuman: minimumSellAssetAmountPaddedCryptoHuman,
70
+ recommendedSlippage: recommendedSlippage.toPrecision(),
62
71
  };
63
72
  const { chainNamespace } = (0, caip_1.fromAssetId)(sellAsset.assetId);
64
73
  switch (chainNamespace) {
@@ -8,8 +8,9 @@ const caip_1 = require("@shapeshiftoss/caip");
8
8
  const max_1 = __importDefault(require("lodash/max"));
9
9
  const api_1 = require("../../../../api");
10
10
  const bignumber_1 = require("../../../utils/bignumber");
11
- const constants_1 = require("../../constants");
12
- const constants_2 = require("../constants");
11
+ const constants_1 = require("../../../utils/constants");
12
+ const constants_2 = require("../../constants");
13
+ const constants_3 = require("../constants");
13
14
  const getInboundAddressDataForChain_1 = require("../getInboundAddressDataForChain");
14
15
  const getTradeRate_1 = require("../getTradeRate/getTradeRate");
15
16
  const getUsdRate_1 = require("../getUsdRate/getUsdRate");
@@ -28,27 +29,27 @@ const getLimit = async ({ sellAsset, buyAssetId, sellAmountCryptoPrecision, deps
28
29
  }
29
30
  const sellFeeAssetUsdRate = await (0, getUsdRate_1.getUsdRate)(deps.daemonUrl, sellAssetChainFeeAssetId);
30
31
  const buyAssetUsdRate = await (0, getUsdRate_1.getUsdRate)(deps.daemonUrl, buyAssetId);
31
- const expectedBuyAmountCryptoPrecision8 = (0, bignumber_1.toBaseUnit)((0, bignumber_1.fromBaseUnit)((0, bignumber_1.bnOrZero)(sellAmountCryptoPrecision).times(tradeRate), sellAsset.precision), constants_2.THORCHAIN_FIXED_PRECISION);
32
+ const expectedBuyAmountCryptoPrecision8 = (0, bignumber_1.toBaseUnit)((0, bignumber_1.fromBaseUnit)((0, bignumber_1.bnOrZero)(sellAmountCryptoPrecision).times(tradeRate), sellAsset.precision), constants_3.THORCHAIN_FIXED_PRECISION);
32
33
  const isValidSlippageRange = (0, bignumber_1.bnOrZero)(slippageTolerance).gte(0) && (0, bignumber_1.bnOrZero)(slippageTolerance).lte(1);
33
34
  if ((0, bignumber_1.bnOrZero)(expectedBuyAmountCryptoPrecision8).lt(0) || !isValidSlippageRange)
34
35
  throw new api_1.SwapError('[getLimit]: bad expected buy amount or bad slippage tolerance', {
35
36
  code: api_1.SwapErrorTypes.BUILD_TRADE_FAILED,
36
37
  details: { expectedBuyAmountCryptoPrecision8, slippageTolerance },
37
38
  });
38
- const buyAssetTradeFeeCryptoPrecision8 = (0, bignumber_1.toBaseUnit)((0, bignumber_1.bnOrZero)(buyAssetTradeFeeUsd).div(buyAssetUsdRate), constants_2.THORCHAIN_FIXED_PRECISION);
39
+ const buyAssetTradeFeeCryptoPrecision8 = (0, bignumber_1.toBaseUnit)((0, bignumber_1.bnOrZero)(buyAssetTradeFeeUsd).div(buyAssetUsdRate), constants_3.THORCHAIN_FIXED_PRECISION);
39
40
  const sellAssetAddressData = await (0, getInboundAddressDataForChain_1.getInboundAddressDataForChain)(deps.daemonUrl, sellAsset.assetId);
40
41
  const refundFeeBuyAssetCryptoPrecision8 = (() => {
41
42
  switch (true) {
42
43
  // If the sell asset is on THOR the return fee is fixed at 0.02 RUNE
43
44
  case (0, isRune_1.isRune)(sellAsset.assetId): {
44
- const runeFeeUsd = constants_1.RUNE_OUTBOUND_TRANSACTION_FEE_CRYPTO_HUMAN.times(sellFeeAssetUsdRate);
45
- return (0, bignumber_1.toBaseUnit)((0, bignumber_1.bnOrZero)(runeFeeUsd).div(buyAssetUsdRate), constants_2.THORCHAIN_FIXED_PRECISION);
45
+ const runeFeeUsd = constants_2.RUNE_OUTBOUND_TRANSACTION_FEE_CRYPTO_HUMAN.times(sellFeeAssetUsdRate);
46
+ return (0, bignumber_1.toBaseUnit)((0, bignumber_1.bnOrZero)(runeFeeUsd).div(buyAssetUsdRate), constants_3.THORCHAIN_FIXED_PRECISION);
46
47
  }
47
48
  // Else the return fee is the outbound fee of the sell asset's chain
48
49
  default: {
49
- const sellAssetTradeFeeCryptoHuman = (0, bignumber_1.fromBaseUnit)((0, bignumber_1.bnOrZero)(sellAssetAddressData === null || sellAssetAddressData === void 0 ? void 0 : sellAssetAddressData.outbound_fee), constants_2.THORCHAIN_FIXED_PRECISION);
50
+ const sellAssetTradeFeeCryptoHuman = (0, bignumber_1.fromBaseUnit)((0, bignumber_1.bnOrZero)(sellAssetAddressData === null || sellAssetAddressData === void 0 ? void 0 : sellAssetAddressData.outbound_fee), constants_3.THORCHAIN_FIXED_PRECISION);
50
51
  const sellAssetTradeFeeUsd = (0, bignumber_1.bnOrZero)(sellAssetTradeFeeCryptoHuman).times(sellFeeAssetUsdRate);
51
- return (0, bignumber_1.toBaseUnit)((0, bignumber_1.bnOrZero)(sellAssetTradeFeeUsd).div(buyAssetUsdRate), constants_2.THORCHAIN_FIXED_PRECISION);
52
+ return (0, bignumber_1.toBaseUnit)((0, bignumber_1.bnOrZero)(sellAssetTradeFeeUsd).div(buyAssetUsdRate), constants_3.THORCHAIN_FIXED_PRECISION);
52
53
  }
53
54
  }
54
55
  })();
@@ -59,6 +60,7 @@ const getLimit = async ({ sellAsset, buyAssetId, sellAmountCryptoPrecision, deps
59
60
  ]);
60
61
  const expectedBuyAmountAfterHighestFeeCryptoPrecision8 = (0, bignumber_1.bnOrZero)(expectedBuyAmountCryptoPrecision8)
61
62
  .times((0, bignumber_1.bn)(1).minus(slippageTolerance))
63
+ .times((0, bignumber_1.bn)(1).minus(constants_1.ALLOWABLE_MARKET_MOVEMENT))
62
64
  .minus(highestPossibleFeeCryptoPrecision8 !== null && highestPossibleFeeCryptoPrecision8 !== void 0 ? highestPossibleFeeCryptoPrecision8 : 0)
63
65
  .decimalPlaces(0);
64
66
  // expectedBuyAmountAfterHighestFeeCryptoPrecision8 can be negative if the sell asset has a higher inbound_fee
@@ -1,4 +1,6 @@
1
1
  import { Asset } from '@shapeshiftoss/asset-service';
2
2
  import { AssetId } from '@shapeshiftoss/caip';
3
- import { ThorchainSwapperDeps } from '../../types';
3
+ import { BN } from '../../../utils/bignumber';
4
+ import { ThorchainSwapperDeps, ThornodePoolResponse } from '../../types';
5
+ export declare const getSwapOutput: (inputAmount: BN, pool: ThornodePoolResponse, toRune: boolean) => BN;
4
6
  export declare const getTradeRate: (sellAsset: Asset, buyAssetId: AssetId, sellAmountCryptoPrecision: string, deps: ThorchainSwapperDeps) => Promise<string>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTradeRate = void 0;
3
+ exports.getTradeRate = exports.getSwapOutput = void 0;
4
4
  const caip_1 = require("@shapeshiftoss/caip");
5
5
  const api_1 = require("../../../../api");
6
6
  const bignumber_1 = require("../../../utils/bignumber");
@@ -9,23 +9,23 @@ const isRune_1 = require("../isRune/isRune");
9
9
  const thorService_1 = require("../thorService");
10
10
  const THOR_PRECISION = 8;
11
11
  const getSwapOutput = (inputAmount, pool, toRune) => {
12
- const x = inputAmount;
13
- const X = toRune ? pool.balance_asset : pool.balance_rune;
14
- const Y = toRune ? pool.balance_rune : pool.balance_asset;
15
- const numerator = (0, bignumber_1.bn)(x).times(X).times(Y);
16
- const denominator = (0, bignumber_1.bn)(x).plus(X).pow(2);
12
+ const inputBalance = toRune ? pool.balance_asset : pool.balance_rune;
13
+ const outputBalance = toRune ? pool.balance_rune : pool.balance_asset;
14
+ const numerator = inputAmount.times(inputBalance).times(outputBalance);
15
+ const denominator = inputAmount.plus(inputBalance).pow(2);
17
16
  return numerator.div(denominator);
18
17
  };
18
+ exports.getSwapOutput = getSwapOutput;
19
19
  const getDoubleSwapOutput = (input, inputPool, outputPool) => {
20
20
  if (inputPool && outputPool) {
21
- const runeToOutput = getSwapOutput(input, inputPool, true);
22
- return getSwapOutput(runeToOutput, outputPool, false);
21
+ const runeToOutput = (0, exports.getSwapOutput)(input, inputPool, true);
22
+ return (0, exports.getSwapOutput)(runeToOutput, outputPool, false);
23
23
  }
24
24
  if (inputPool && !outputPool) {
25
- return getSwapOutput(input, inputPool, true);
25
+ return (0, exports.getSwapOutput)(input, inputPool, true);
26
26
  }
27
27
  if (!inputPool && outputPool) {
28
- return getSwapOutput(input, outputPool, false);
28
+ return (0, exports.getSwapOutput)(input, outputPool, false);
29
29
  }
30
30
  return (0, bignumber_1.bn)(0); // We should never reach this, but this makes tsc happy
31
31
  };
@@ -3,4 +3,5 @@ export declare const btcThornodePool: ThornodePoolResponse;
3
3
  export declare const ethThornodePool: ThornodePoolResponse;
4
4
  export declare const foxThornodePool: ThornodePoolResponse;
5
5
  export declare const usdcThornodePool: ThornodePoolResponse;
6
+ export declare const thornodePools: ThornodePoolResponse[];
6
7
  export declare const mockInboundAddresses: InboundAddressResponse[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mockInboundAddresses = exports.usdcThornodePool = exports.foxThornodePool = exports.ethThornodePool = exports.btcThornodePool = void 0;
3
+ exports.mockInboundAddresses = exports.thornodePools = exports.usdcThornodePool = exports.foxThornodePool = exports.ethThornodePool = exports.btcThornodePool = void 0;
4
4
  exports.btcThornodePool = {
5
5
  LP_units: '536055974608843',
6
6
  asset: 'BTC.BTC',
@@ -49,6 +49,12 @@ exports.usdcThornodePool = {
49
49
  synth_supply: '25598723155460',
50
50
  synth_units: '1936419947970',
51
51
  };
52
+ exports.thornodePools = [
53
+ exports.btcThornodePool,
54
+ exports.ethThornodePool,
55
+ exports.foxThornodePool,
56
+ exports.usdcThornodePool,
57
+ ];
52
58
  exports.mockInboundAddresses = [
53
59
  {
54
60
  chain: 'BCH',
@@ -1,2 +1,3 @@
1
1
  export declare const APPROVAL_GAS_LIMIT = "100000";
2
2
  export declare const DEFAULT_SLIPPAGE = "0.03";
3
+ export declare const ALLOWABLE_MARKET_MOVEMENT = "0.005";
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_SLIPPAGE = exports.APPROVAL_GAS_LIMIT = void 0;
3
+ exports.ALLOWABLE_MARKET_MOVEMENT = exports.DEFAULT_SLIPPAGE = exports.APPROVAL_GAS_LIMIT = void 0;
4
4
  exports.APPROVAL_GAS_LIMIT = '100000'; // Most approvals are around 40k, we've seen 72k in the wild, so 100000 for safety.
5
5
  exports.DEFAULT_SLIPPAGE = '0.03'; // 3%
6
+ exports.ALLOWABLE_MARKET_MOVEMENT = '0.005'; // 0.5% is what https://app.thorswap.finance/ uses
@@ -0,0 +1 @@
1
+ export declare function assertIsDefined<T>(val: T): asserts val is NonNullable<T>;
package/dist/utils.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertIsDefined = void 0;
4
+ const assert_1 = require("assert");
5
+ // asserts x is type doesn't work when using arrow functions
6
+ function assertIsDefined(val) {
7
+ if (val === undefined || val === null) {
8
+ throw new assert_1.AssertionError({ message: `Expected 'val' to be defined, but received ${val}` });
9
+ }
10
+ }
11
+ exports.assertIsDefined = assertIsDefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "14.4.1",
3
+ "version": "14.5.1",
4
4
  "description": "An interface and implementations to trade coins via various protocols",
5
5
  "repository": "https://github.com/shapeshift/lib",
6
6
  "license": "MIT",