@shapeshiftoss/swapper 9.11.0 → 9.11.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.
@@ -76,7 +76,7 @@ class OsmosisSwapper {
76
76
  code: api_1.SwapErrorTypes.BUILD_TRADE_FAILED
77
77
  });
78
78
  const feeData = await osmosisAdapter.getFeeData({});
79
- const fee = feeData.average.txFee;
79
+ const fee = feeData.fast.txFee;
80
80
  return {
81
81
  buyAmount,
82
82
  buyAsset,
@@ -104,7 +104,7 @@ class OsmosisSwapper {
104
104
  code: api_1.SwapErrorTypes.TRADE_QUOTE_FAILED
105
105
  });
106
106
  const feeData = await osmosisAdapter.getFeeData({});
107
- const fee = feeData.average.txFee;
107
+ const fee = feeData.fast.txFee;
108
108
  return {
109
109
  buyAsset,
110
110
  feeData: { fee, tradeFee },
@@ -134,7 +134,7 @@ class OsmosisSwapper {
134
134
  }
135
135
  let sellAddress;
136
136
  const feeData = await osmosisAdapter.getFeeData({});
137
- const gas = feeData.average.chainSpecific.gasLimit;
137
+ const gas = feeData.fast.chainSpecific.gasLimit;
138
138
  if (!isFromOsmo) {
139
139
  const sellBip44Params = cosmosAdapter.buildBIP44Params({
140
140
  accountNumber: Number(sellAssetAccountNumber)
@@ -160,6 +160,9 @@ class OsmosisSwapper {
160
160
  code: api_1.SwapErrorTypes.EXECUTE_TRADE_FAILED
161
161
  });
162
162
  ibcSellAmount = await (0, helpers_1.pollForAtomChannelBalance)(receiveAddress, this.deps.osmoUrl);
163
+ // delay to ensure all nodes we interact with are up to date at this point
164
+ // seeing intermittent bugs that suggest the balances and sequence numbers were sometimes off
165
+ await new Promise((resolve) => setTimeout(resolve, 3000));
163
166
  }
164
167
  else {
165
168
  const sellBip44Params = osmosisAdapter.buildBIP44Params({
@@ -199,6 +202,9 @@ class OsmosisSwapper {
199
202
  const ibcResponseAccount = await osmosisAdapter.getAccount(sellAddress);
200
203
  const ibcAccountNumber = ibcResponseAccount.chainSpecific.accountNumber || '0';
201
204
  const ibcSequence = ibcResponseAccount.chainSpecific.sequence || '0';
205
+ // delay to ensure all nodes we interact with are up to date at this point
206
+ // seeing intermittent bugs that suggest the balances and sequence numbers were sometimes off
207
+ await new Promise((resolve) => setTimeout(resolve, 3000));
202
208
  await (0, helpers_1.performIbcTransfer)(transfer, osmosisAdapter, wallet, this.deps.cosmosUrl, buyAssetDenom, constants_1.OSMO_COSMO_CHANNEL, trade.feeData.fee, ibcAccountNumber, ibcSequence, gas);
203
209
  }
204
210
  return { tradeId: tradeId || 'error' };
@@ -27,14 +27,14 @@ const txStatus = async (txid, baseUrl) => {
27
27
  return 'failed';
28
28
  }
29
29
  catch (e) {
30
- console.error('Failed to get status');
30
+ console.warn('Retrying to retrieve status');
31
31
  }
32
32
  return 'not found';
33
33
  };
34
34
  // TODO: leverage chain-adapters websockets
35
35
  const pollForComplete = async (txid, baseUrl) => {
36
36
  return new Promise((resolve, reject) => {
37
- const timeout = 120000; // 2 mins
37
+ const timeout = 300000; // 5 mins
38
38
  const startTime = Date.now();
39
39
  const interval = 5000; // 5 seconds
40
40
  const poll = async function () {
@@ -72,14 +72,14 @@ const getAtomChannelBalance = async (address, osmoUrl) => {
72
72
  toAtomChannelBalance = Number(amount);
73
73
  }
74
74
  catch (e) {
75
- console.error('no channel balance');
75
+ console.warn('Retrying to get ibc balance');
76
76
  }
77
77
  return toAtomChannelBalance;
78
78
  };
79
79
  exports.getAtomChannelBalance = getAtomChannelBalance;
80
80
  const pollForAtomChannelBalance = async (address, osmoUrl) => {
81
81
  return new Promise((resolve, reject) => {
82
- const timeout = 120000; // 2 mins
82
+ const timeout = 300000; // 5 mins
83
83
  const startTime = Date.now();
84
84
  const interval = 5000; // 5 seconds
85
85
  const poll = async function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "9.11.0",
3
+ "version": "9.11.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",