@shapeshiftoss/swapper 9.14.0 → 9.16.0

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.
Files changed (78) hide show
  1. package/dist/api.d.ts +12 -2
  2. package/dist/api.js +1 -0
  3. package/dist/manager/SwapperManager.js +3 -3
  4. package/dist/swappercli.js +8 -8
  5. package/dist/swappers/cow/CowSwapper.d.ts +2 -1
  6. package/dist/swappers/cow/CowSwapper.js +5 -2
  7. package/dist/swappers/cow/cowApprovalNeeded/cowApprovalNeeded.js +4 -4
  8. package/dist/swappers/cow/{cowApproveInfinite/cowApproveInfinite.d.ts → cowApprove/cowApprove.d.ts} +2 -1
  9. package/dist/swappers/cow/cowApprove/cowApprove.js +56 -0
  10. package/dist/swappers/cow/cowBuildTrade/cowBuildTrade.js +11 -11
  11. package/dist/swappers/cow/cowExecuteTrade/cowExecuteTrade.js +7 -7
  12. package/dist/swappers/cow/cowGetTradeTxs/cowGetTradeTxs.js +4 -4
  13. package/dist/swappers/cow/getCowSwapMinMax/getCowSwapMinMax.js +1 -1
  14. package/dist/swappers/cow/getCowSwapTradeQuote/getCowSwapTradeQuote.js +12 -12
  15. package/dist/swappers/cow/utils/blacklist.js +1 -1
  16. package/dist/swappers/cow/utils/cowService.js +2 -2
  17. package/dist/swappers/cow/utils/helpers/helpers.js +7 -7
  18. package/dist/swappers/osmosis/OsmosisSwapper.d.ts +1 -0
  19. package/dist/swappers/osmosis/OsmosisSwapper.js +24 -19
  20. package/dist/swappers/osmosis/utils/helpers.d.ts +1 -1
  21. package/dist/swappers/osmosis/utils/helpers.js +35 -35
  22. package/dist/swappers/test/TestSwapper.d.ts +1 -0
  23. package/dist/swappers/test/TestSwapper.js +6 -1
  24. package/dist/swappers/thorchain/ThorchainSwapper.d.ts +1 -0
  25. package/dist/swappers/thorchain/ThorchainSwapper.js +17 -12
  26. package/dist/swappers/thorchain/buildThorTrade/buildThorTrade.d.ts +1 -1
  27. package/dist/swappers/thorchain/buildThorTrade/buildThorTrade.js +14 -14
  28. package/dist/swappers/thorchain/getThorTradeQuote/getTradeQuote.js +14 -14
  29. package/dist/swappers/thorchain/thorTradeApprovalNeeded/thorTradeApprovalNeeded.d.ts +1 -1
  30. package/dist/swappers/thorchain/thorTradeApprovalNeeded/thorTradeApprovalNeeded.js +7 -7
  31. package/dist/swappers/thorchain/thorTradeApproveInfinite/thorTradeApproveInfinite.d.ts +1 -1
  32. package/dist/swappers/thorchain/thorTradeApproveInfinite/thorTradeApproveInfinite.js +7 -7
  33. package/dist/swappers/thorchain/utils/bitcoin/utils/getThorTxData.js +5 -5
  34. package/dist/swappers/thorchain/utils/constants.js +1 -1
  35. package/dist/swappers/thorchain/utils/cosmos/cosmosTxData.js +6 -6
  36. package/dist/swappers/thorchain/utils/estimateTradeFee/estimateTradeFee.js +6 -6
  37. package/dist/swappers/thorchain/utils/ethereum/makeTradeTx.d.ts +1 -1
  38. package/dist/swappers/thorchain/utils/ethereum/makeTradeTx.js +6 -6
  39. package/dist/swappers/thorchain/utils/ethereum/utils/getThorTxData.js +5 -5
  40. package/dist/swappers/thorchain/utils/getLimit/getLimit.d.ts +1 -1
  41. package/dist/swappers/thorchain/utils/getLimit/getLimit.js +2 -2
  42. package/dist/swappers/thorchain/utils/getPriceRatio/getPriceRatio.js +3 -3
  43. package/dist/swappers/thorchain/utils/getTradeRate/getTradeRate.js +5 -5
  44. package/dist/swappers/thorchain/utils/getUsdRate/getUsdRate.d.ts +1 -1
  45. package/dist/swappers/thorchain/utils/getUsdRate/getUsdRate.js +4 -4
  46. package/dist/swappers/thorchain/utils/makeSwapMemo/makeSwapMemo.d.ts +1 -1
  47. package/dist/swappers/thorchain/utils/makeSwapMemo/makeSwapMemo.js +4 -4
  48. package/dist/swappers/thorchain/utils/test-data/midgardResponse.js +11 -11
  49. package/dist/swappers/thorchain/utils/test-data/setupThorswapDeps.js +9 -9
  50. package/dist/swappers/thorchain/utils/thorService.js +2 -2
  51. package/dist/swappers/thorchain/utils/txFeeHelpers/btcTxFees/getBtcTxFees.d.ts +1 -1
  52. package/dist/swappers/thorchain/utils/txFeeHelpers/btcTxFees/getBtcTxFees.js +4 -4
  53. package/dist/swappers/thorchain/utils/txFeeHelpers/ethTxFees/getEthTxFees.d.ts +1 -1
  54. package/dist/swappers/thorchain/utils/txFeeHelpers/ethTxFees/getEthTxFees.js +7 -7
  55. package/dist/swappers/utils/abi/erc20-abi.js +54 -54
  56. package/dist/swappers/utils/abi/erc20Allowance-abi.js +7 -7
  57. package/dist/swappers/utils/helpers/helpers.d.ts +4 -4
  58. package/dist/swappers/utils/helpers/helpers.js +13 -13
  59. package/dist/swappers/utils/test-data/assets.js +8 -8
  60. package/dist/swappers/utils/test-data/setupDeps.js +3 -3
  61. package/dist/swappers/utils/test-data/setupSwapQuote.js +3 -3
  62. package/dist/swappers/zrx/ZrxSwapper.d.ts +2 -1
  63. package/dist/swappers/zrx/ZrxSwapper.js +7 -4
  64. package/dist/swappers/zrx/getZrxMinMax/getZrxMinMax.js +1 -1
  65. package/dist/swappers/zrx/getZrxTradeQuote/getZrxTradeQuote.js +7 -7
  66. package/dist/swappers/zrx/utils/blacklist.js +1 -1
  67. package/dist/swappers/zrx/utils/helpers/helpers.js +6 -6
  68. package/dist/swappers/zrx/utils/test-data/setupZrxSwapQuote.js +2 -2
  69. package/dist/swappers/zrx/utils/zrxService.js +2 -2
  70. package/dist/swappers/zrx/zrxApprovalNeeded/zrxApprovalNeeded.js +6 -6
  71. package/dist/swappers/zrx/zrxApprove/zrxApprove.d.ts +4 -0
  72. package/dist/swappers/zrx/zrxApprove/zrxApprove.js +62 -0
  73. package/dist/swappers/zrx/zrxBuildTrade/zrxBuildTrade.js +13 -11
  74. package/dist/swappers/zrx/zrxExecuteTrade/zrxExecuteTrade.js +6 -6
  75. package/package.json +1 -1
  76. package/dist/swappers/cow/cowApproveInfinite/cowApproveInfinite.js +0 -31
  77. package/dist/swappers/zrx/zrxApproveInfinite/zrxApproveInfinite.d.ts +0 -3
  78. package/dist/swappers/zrx/zrxApproveInfinite/zrxApproveInfinite.js +0 -42
@@ -13,7 +13,7 @@ exports.btcMidgardPool = {
13
13
  synthSupply: '3281284823',
14
14
  synthUnits: '9838954536080',
15
15
  units: '545894929144923',
16
- volume24h: '15031085906495'
16
+ volume24h: '15031085906495',
17
17
  };
18
18
  exports.ethMidgardPool = {
19
19
  asset: 'ETH.ETH',
@@ -27,7 +27,7 @@ exports.ethMidgardPool = {
27
27
  synthSupply: '3572065751',
28
28
  synthUnits: '535301524652',
29
29
  units: '274245264962453',
30
- volume24h: '9890096673763'
30
+ volume24h: '9890096673763',
31
31
  };
32
32
  exports.foxMidgardPool = {
33
33
  asset: 'ETH.FOX-0XC770EEFAD204B5180DF6A14EE197D99D808EE52D',
@@ -41,7 +41,7 @@ exports.foxMidgardPool = {
41
41
  synthSupply: '17428372569375',
42
42
  synthUnits: '552604585625',
43
43
  units: '10568061707512',
44
- volume24h: '251596933033'
44
+ volume24h: '251596933033',
45
45
  };
46
46
  exports.mockInboundAdresses = [
47
47
  {
@@ -49,28 +49,28 @@ exports.mockInboundAdresses = [
49
49
  pub_key: 'thorpub1addwnpepqfyppkehky2hn2gy26y8jqyj9fz0rnvau2r7yueawzvc662w0x9s7n4ypra',
50
50
  address: 'qp5a6rn8zmamgmsyspqsl0p6ktk4hrheggdjdvntv0',
51
51
  halted: false,
52
- gas_rate: '3'
52
+ gas_rate: '3',
53
53
  },
54
54
  {
55
55
  chain: 'BNB',
56
56
  pub_key: 'thorpub1addwnpepqfyppkehky2hn2gy26y8jqyj9fz0rnvau2r7yueawzvc662w0x9s7n4ypra',
57
57
  address: 'bnb1d8wsuecklw6xupyqgy8mcw4ja4dca72z7nvqzw',
58
58
  halted: false,
59
- gas_rate: '11250'
59
+ gas_rate: '11250',
60
60
  },
61
61
  {
62
62
  chain: 'BTC',
63
63
  pub_key: 'thorpub1addwnpepqfyppkehky2hn2gy26y8jqyj9fz0rnvau2r7yueawzvc662w0x9s7n4ypra',
64
64
  address: 'bc1qd8wsuecklw6xupyqgy8mcw4ja4dca72z2dd88d',
65
65
  halted: false,
66
- gas_rate: '18'
66
+ gas_rate: '18',
67
67
  },
68
68
  {
69
69
  chain: 'DOGE',
70
70
  pub_key: 'thorpub1addwnpepqfyppkehky2hn2gy26y8jqyj9fz0rnvau2r7yueawzvc662w0x9s7n4ypra',
71
71
  address: 'DEnrJfAjC4KMsLsGtoTGSmYaFZLPunWw9q',
72
72
  halted: false,
73
- gas_rate: '550384'
73
+ gas_rate: '550384',
74
74
  },
75
75
  {
76
76
  chain: 'ETH',
@@ -78,21 +78,21 @@ exports.mockInboundAdresses = [
78
78
  address: '0x78e4e10dcacb0a8261eb3d5e57ffb98ae8d4dff1',
79
79
  router: '0x3624525075b88B24ecc29CE226b0CEc1fFcB6976',
80
80
  halted: false,
81
- gas_rate: '280'
81
+ gas_rate: '280',
82
82
  },
83
83
  {
84
84
  chain: 'LTC',
85
85
  pub_key: 'thorpub1addwnpepqfyppkehky2hn2gy26y8jqyj9fz0rnvau2r7yueawzvc662w0x9s7n4ypra',
86
86
  address: 'ltc1qd8wsuecklw6xupyqgy8mcw4ja4dca72zw3hrla',
87
87
  halted: false,
88
- gas_rate: '60'
88
+ gas_rate: '60',
89
89
  },
90
90
  {
91
91
  chain: 'TERRA',
92
92
  pub_key: 'thorpub1addwnpepqfyppkehky2hn2gy26y8jqyj9fz0rnvau2r7yueawzvc662w0x9s7n4ypra',
93
93
  address: 'terra1d8wsuecklw6xupyqgy8mcw4ja4dca72z6nfvpq',
94
94
  halted: true,
95
- gas_rate: '182523800'
96
- }
95
+ gas_rate: '182523800',
96
+ },
97
97
  ];
98
98
  exports.poolResponse = [exports.btcMidgardPool, exports.ethMidgardPool, exports.foxMidgardPool];
@@ -13,8 +13,8 @@ const setupThorswapDeps = () => {
13
13
  fast: {
14
14
  txFee: '1',
15
15
  chainSpecific: { approvalFee: '1', gasLimit: '1', gasPrice: '1' },
16
- tradeFee: '2'
17
- }
16
+ tradeFee: '2',
17
+ },
18
18
  };
19
19
  const adapterManager = new Map([
20
20
  [
@@ -28,21 +28,21 @@ const setupThorswapDeps = () => {
28
28
  [chain_adapters_1.FeeDataKey.Slow]: {
29
29
  gasPrice: '1',
30
30
  maxFeePerGas: '2',
31
- maxPriorityFeePerGas: '3'
31
+ maxPriorityFeePerGas: '3',
32
32
  },
33
33
  [chain_adapters_1.FeeDataKey.Average]: {
34
34
  gasPrice: '4',
35
35
  maxFeePerGas: '5',
36
- maxPriorityFeePerGas: '6'
36
+ maxPriorityFeePerGas: '6',
37
37
  },
38
38
  [chain_adapters_1.FeeDataKey.Fast]: {
39
39
  gasPrice: '7',
40
40
  maxFeePerGas: '8',
41
- maxPriorityFeePerGas: '9'
42
- }
43
- }))
44
- }
45
- ]
41
+ maxPriorityFeePerGas: '9',
42
+ },
43
+ })),
44
+ },
45
+ ],
46
46
  ]);
47
47
  const midgardUrl = 'localhost:3000';
48
48
  const ethNodeUrl = 'http://localhost:1000';
@@ -9,7 +9,7 @@ const axiosConfig = {
9
9
  timeout: 10000,
10
10
  headers: {
11
11
  Accept: 'application/json',
12
- 'Content-Type': 'application/json'
13
- }
12
+ 'Content-Type': 'application/json',
13
+ },
14
14
  };
15
15
  exports.thorService = axios_1.default.create(axiosConfig);
@@ -1,6 +1,6 @@
1
1
  import { UtxoBaseAdapter } from '@shapeshiftoss/chain-adapters';
2
2
  import { QuoteFeeData, UtxoSupportedChainIds } from '../../../../../api';
3
- export declare const getBtcTxFees: ({ opReturnData, vault, sellAmount, sellAdapter, pubkey, tradeFee }: {
3
+ export declare const getBtcTxFees: ({ opReturnData, vault, sellAmount, sellAdapter, pubkey, tradeFee, }: {
4
4
  opReturnData: string;
5
5
  vault: string;
6
6
  sellAmount: string;
@@ -4,12 +4,12 @@ exports.getBtcTxFees = void 0;
4
4
  const types_1 = require("@shapeshiftoss/types");
5
5
  const api_1 = require("../../../../../api");
6
6
  const bignumber_1 = require("../../../../utils/bignumber");
7
- const getBtcTxFees = async ({ opReturnData, vault, sellAmount, sellAdapter, pubkey, tradeFee }) => {
7
+ const getBtcTxFees = async ({ opReturnData, vault, sellAmount, sellAdapter, pubkey, tradeFee, }) => {
8
8
  try {
9
9
  const feeDataOptions = await sellAdapter.getFeeData({
10
10
  to: vault,
11
11
  value: sellAmount,
12
- chainSpecific: { pubkey, opReturnData }
12
+ chainSpecific: { pubkey, opReturnData },
13
13
  });
14
14
  const feeData = feeDataOptions['fast'];
15
15
  // BCH specific hack:
@@ -29,8 +29,8 @@ const getBtcTxFees = async ({ opReturnData, vault, sellAmount, sellAdapter, pubk
29
29
  byteCount: (0, bignumber_1.bn)(feeData.txFee)
30
30
  .dividedBy(feeData.chainSpecific.satoshiPerByte)
31
31
  .dp(0)
32
- .toString()
33
- }
32
+ .toString(),
33
+ },
34
34
  };
35
35
  }
36
36
  catch (e) {
@@ -2,7 +2,7 @@ import { AssetReference } from '@shapeshiftoss/caip';
2
2
  import { ChainAdapterManager } from '@shapeshiftoss/chain-adapters';
3
3
  import { KnownChainIds } from '@shapeshiftoss/types';
4
4
  import { QuoteFeeData } from '../../../../../api';
5
- export declare const getEthTxFees: ({ adapterManager, sellAssetReference, tradeFee }: {
5
+ export declare const getEthTxFees: ({ adapterManager, sellAssetReference, tradeFee, }: {
6
6
  adapterManager: ChainAdapterManager;
7
7
  sellAssetReference: AssetReference | string;
8
8
  tradeFee: string;
@@ -7,13 +7,13 @@ const api_1 = require("../../../../../api");
7
7
  const bignumber_1 = require("../../../../utils/bignumber");
8
8
  const constants_1 = require("../../../../utils/constants");
9
9
  const constants_2 = require("../../constants");
10
- const getEthTxFees = async ({ adapterManager, sellAssetReference, tradeFee }) => {
10
+ const getEthTxFees = async ({ adapterManager, sellAssetReference, tradeFee, }) => {
11
11
  try {
12
12
  const adapter = adapterManager.get(types_1.KnownChainIds.EthereumMainnet);
13
13
  if (!adapter) {
14
14
  throw new api_1.SwapError(`[getThorTxInfo] - No chain adapter found for ${types_1.KnownChainIds.EthereumMainnet}.`, {
15
15
  code: api_1.SwapErrorTypes.UNSUPPORTED_CHAIN,
16
- details: { chainId: types_1.KnownChainIds.EthereumMainnet }
16
+ details: { chainId: types_1.KnownChainIds.EthereumMainnet },
17
17
  });
18
18
  }
19
19
  const gasFeeData = await adapter.getGasFeeData();
@@ -25,9 +25,9 @@ const getEthTxFees = async ({ adapterManager, sellAssetReference, tradeFee }) =>
25
25
  txFee: (0, bignumber_1.bn)(gasLimit).times(gasFeeData[chain_adapters_1.FeeDataKey.Fast].gasPrice).toString(),
26
26
  chainSpecific: {
27
27
  gasPrice: gasFeeData[chain_adapters_1.FeeDataKey.Fast].gasPrice,
28
- gasLimit
29
- }
30
- }
28
+ gasLimit,
29
+ },
30
+ },
31
31
  };
32
32
  const feeData = feeDataOptions['fast'];
33
33
  return {
@@ -38,9 +38,9 @@ const getEthTxFees = async ({ adapterManager, sellAssetReference, tradeFee }) =>
38
38
  approvalFee: sellAssetReference &&
39
39
  (0, bignumber_1.bnOrZero)(constants_1.APPROVAL_GAS_LIMIT)
40
40
  .multipliedBy((0, bignumber_1.bnOrZero)(feeData.chainSpecific.gasPrice))
41
- .toString()
41
+ .toString(),
42
42
  },
43
- tradeFee
43
+ tradeFee,
44
44
  };
45
45
  }
46
46
  catch (e) {
@@ -9,35 +9,35 @@ exports.erc20Abi = [
9
9
  outputs: [
10
10
  {
11
11
  name: '',
12
- type: 'string'
13
- }
12
+ type: 'string',
13
+ },
14
14
  ],
15
15
  payable: false,
16
16
  stateMutability: 'view',
17
- type: 'function'
17
+ type: 'function',
18
18
  },
19
19
  {
20
20
  constant: false,
21
21
  inputs: [
22
22
  {
23
23
  name: '_spender',
24
- type: 'address'
24
+ type: 'address',
25
25
  },
26
26
  {
27
27
  name: '_value',
28
- type: 'uint256'
29
- }
28
+ type: 'uint256',
29
+ },
30
30
  ],
31
31
  name: 'approve',
32
32
  outputs: [
33
33
  {
34
34
  name: '',
35
- type: 'bool'
36
- }
35
+ type: 'bool',
36
+ },
37
37
  ],
38
38
  payable: false,
39
39
  stateMutability: 'nonpayable',
40
- type: 'function'
40
+ type: 'function',
41
41
  },
42
42
  {
43
43
  constant: true,
@@ -46,39 +46,39 @@ exports.erc20Abi = [
46
46
  outputs: [
47
47
  {
48
48
  name: '',
49
- type: 'uint256'
50
- }
49
+ type: 'uint256',
50
+ },
51
51
  ],
52
52
  payable: false,
53
53
  stateMutability: 'view',
54
- type: 'function'
54
+ type: 'function',
55
55
  },
56
56
  {
57
57
  constant: false,
58
58
  inputs: [
59
59
  {
60
60
  name: '_from',
61
- type: 'address'
61
+ type: 'address',
62
62
  },
63
63
  {
64
64
  name: '_to',
65
- type: 'address'
65
+ type: 'address',
66
66
  },
67
67
  {
68
68
  name: '_value',
69
- type: 'uint256'
70
- }
69
+ type: 'uint256',
70
+ },
71
71
  ],
72
72
  name: 'transferFrom',
73
73
  outputs: [
74
74
  {
75
75
  name: '',
76
- type: 'bool'
77
- }
76
+ type: 'bool',
77
+ },
78
78
  ],
79
79
  payable: false,
80
80
  stateMutability: 'nonpayable',
81
- type: 'function'
81
+ type: 'function',
82
82
  },
83
83
  {
84
84
  constant: true,
@@ -87,31 +87,31 @@ exports.erc20Abi = [
87
87
  outputs: [
88
88
  {
89
89
  name: '',
90
- type: 'uint8'
91
- }
90
+ type: 'uint8',
91
+ },
92
92
  ],
93
93
  payable: false,
94
94
  stateMutability: 'view',
95
- type: 'function'
95
+ type: 'function',
96
96
  },
97
97
  {
98
98
  constant: true,
99
99
  inputs: [
100
100
  {
101
101
  name: '_owner',
102
- type: 'address'
103
- }
102
+ type: 'address',
103
+ },
104
104
  ],
105
105
  name: 'balanceOf',
106
106
  outputs: [
107
107
  {
108
108
  name: 'balance',
109
- type: 'uint256'
110
- }
109
+ type: 'uint256',
110
+ },
111
111
  ],
112
112
  payable: false,
113
113
  stateMutability: 'view',
114
- type: 'function'
114
+ type: 'function',
115
115
  },
116
116
  {
117
117
  constant: true,
@@ -120,63 +120,63 @@ exports.erc20Abi = [
120
120
  outputs: [
121
121
  {
122
122
  name: '',
123
- type: 'string'
124
- }
123
+ type: 'string',
124
+ },
125
125
  ],
126
126
  payable: false,
127
127
  stateMutability: 'view',
128
- type: 'function'
128
+ type: 'function',
129
129
  },
130
130
  {
131
131
  constant: false,
132
132
  inputs: [
133
133
  {
134
134
  name: '_to',
135
- type: 'address'
135
+ type: 'address',
136
136
  },
137
137
  {
138
138
  name: '_value',
139
- type: 'uint256'
140
- }
139
+ type: 'uint256',
140
+ },
141
141
  ],
142
142
  name: 'transfer',
143
143
  outputs: [
144
144
  {
145
145
  name: '',
146
- type: 'bool'
147
- }
146
+ type: 'bool',
147
+ },
148
148
  ],
149
149
  payable: false,
150
150
  stateMutability: 'nonpayable',
151
- type: 'function'
151
+ type: 'function',
152
152
  },
153
153
  {
154
154
  constant: true,
155
155
  inputs: [
156
156
  {
157
157
  name: '_owner',
158
- type: 'address'
158
+ type: 'address',
159
159
  },
160
160
  {
161
161
  name: '_spender',
162
- type: 'address'
163
- }
162
+ type: 'address',
163
+ },
164
164
  ],
165
165
  name: 'allowance',
166
166
  outputs: [
167
167
  {
168
168
  name: '',
169
- type: 'uint256'
170
- }
169
+ type: 'uint256',
170
+ },
171
171
  ],
172
172
  payable: false,
173
173
  stateMutability: 'view',
174
- type: 'function'
174
+ type: 'function',
175
175
  },
176
176
  {
177
177
  payable: true,
178
178
  stateMutability: 'payable',
179
- type: 'fallback'
179
+ type: 'fallback',
180
180
  },
181
181
  {
182
182
  anonymous: false,
@@ -184,21 +184,21 @@ exports.erc20Abi = [
184
184
  {
185
185
  indexed: true,
186
186
  name: 'owner',
187
- type: 'address'
187
+ type: 'address',
188
188
  },
189
189
  {
190
190
  indexed: true,
191
191
  name: 'spender',
192
- type: 'address'
192
+ type: 'address',
193
193
  },
194
194
  {
195
195
  indexed: false,
196
196
  name: 'value',
197
- type: 'uint256'
198
- }
197
+ type: 'uint256',
198
+ },
199
199
  ],
200
200
  name: 'Approval',
201
- type: 'event'
201
+ type: 'event',
202
202
  },
203
203
  {
204
204
  anonymous: false,
@@ -206,20 +206,20 @@ exports.erc20Abi = [
206
206
  {
207
207
  indexed: true,
208
208
  name: 'from',
209
- type: 'address'
209
+ type: 'address',
210
210
  },
211
211
  {
212
212
  indexed: true,
213
213
  name: 'to',
214
- type: 'address'
214
+ type: 'address',
215
215
  },
216
216
  {
217
217
  indexed: false,
218
218
  name: 'value',
219
- type: 'uint256'
220
- }
219
+ type: 'uint256',
220
+ },
221
221
  ],
222
222
  name: 'Transfer',
223
- type: 'event'
224
- }
223
+ type: 'event',
224
+ },
225
225
  ];
@@ -7,22 +7,22 @@ exports.erc20AllowanceAbi = [
7
7
  inputs: [
8
8
  {
9
9
  name: '_owner',
10
- type: 'address'
10
+ type: 'address',
11
11
  },
12
12
  {
13
13
  name: '_spender',
14
- type: 'address'
15
- }
14
+ type: 'address',
15
+ },
16
16
  ],
17
17
  name: 'allowance',
18
18
  outputs: [
19
19
  {
20
20
  name: '',
21
- type: 'uint256'
22
- }
21
+ type: 'uint256',
22
+ },
23
23
  ],
24
24
  payable: false,
25
25
  stateMutability: 'view',
26
- type: 'function'
27
- }
26
+ type: 'function',
27
+ },
28
28
  ];
@@ -33,9 +33,9 @@ declare type GrantAllowanceArgs<T extends EvmSupportedChainIds> = {
33
33
  erc20Abi: AbiItem[];
34
34
  web3: Web3;
35
35
  };
36
- export declare const getERC20Allowance: ({ erc20AllowanceAbi, web3, sellAssetErc20Address, ownerAddress, spenderAddress }: GetERC20AllowanceArgs) => Promise<any>;
37
- export declare const getAllowanceRequired: ({ adapter, receiveAddress, allowanceContract, sellAsset, sellAmount, web3, erc20AllowanceAbi }: GetAllowanceRequiredArgs) => Promise<BigNumber>;
38
- export declare const grantAllowance: <T extends EvmSupportedChainIds>({ quote, wallet, adapter, erc20Abi, web3 }: GrantAllowanceArgs<T>) => Promise<string>;
36
+ export declare const getERC20Allowance: ({ erc20AllowanceAbi, web3, sellAssetErc20Address, ownerAddress, spenderAddress, }: GetERC20AllowanceArgs) => Promise<any>;
37
+ export declare const getAllowanceRequired: ({ adapter, receiveAddress, allowanceContract, sellAsset, sellAmount, web3, erc20AllowanceAbi, }: GetAllowanceRequiredArgs) => Promise<BigNumber>;
38
+ export declare const grantAllowance: <T extends EvmSupportedChainIds>({ quote, wallet, adapter, erc20Abi, web3, }: GrantAllowanceArgs<T>) => Promise<string>;
39
39
  /**
40
40
  * This function keeps 17 significant digits, so even if we try to trade 1 Billion of an
41
41
  * ETH or ERC20, we still keep 7 decimal places.
@@ -43,5 +43,5 @@ export declare const grantAllowance: <T extends EvmSupportedChainIds>({ quote, w
43
43
  */
44
44
  export declare const normalizeAmount: (amount: string | number | BN) => string;
45
45
  export declare const normalizeIntegerAmount: (amount: string | number | BN) => string;
46
- export declare const getApproveContractData: ({ web3, spenderAddress, contractAddress }: GetApproveContractDataArgs) => string;
46
+ export declare const getApproveContractData: ({ web3, spenderAddress, contractAddress, }: GetApproveContractDataArgs) => string;
47
47
  export {};
@@ -7,12 +7,12 @@ const api_1 = require("../../../api");
7
7
  const constants_1 = require("../../cow/utils/constants");
8
8
  const erc20_abi_1 = require("../abi/erc20-abi");
9
9
  const bignumber_1 = require("../bignumber");
10
- const getERC20Allowance = async ({ erc20AllowanceAbi, web3, sellAssetErc20Address, ownerAddress, spenderAddress }) => {
10
+ const getERC20Allowance = async ({ erc20AllowanceAbi, web3, sellAssetErc20Address, ownerAddress, spenderAddress, }) => {
11
11
  const erc20Contract = new web3.eth.Contract(erc20AllowanceAbi, sellAssetErc20Address);
12
12
  return erc20Contract.methods.allowance(ownerAddress, spenderAddress).call();
13
13
  };
14
14
  exports.getERC20Allowance = getERC20Allowance;
15
- const getAllowanceRequired = async ({ adapter, receiveAddress, allowanceContract, sellAsset, sellAmount, web3, erc20AllowanceAbi }) => {
15
+ const getAllowanceRequired = async ({ adapter, receiveAddress, allowanceContract, sellAsset, sellAmount, web3, erc20AllowanceAbi, }) => {
16
16
  try {
17
17
  if (sellAsset.assetId === adapter.getFeeAssetId()) {
18
18
  return (0, bignumber_1.bn)(0);
@@ -25,14 +25,14 @@ const getAllowanceRequired = async ({ adapter, receiveAddress, allowanceContract
25
25
  erc20AllowanceAbi,
26
26
  ownerAddress,
27
27
  spenderAddress,
28
- sellAssetErc20Address
28
+ sellAssetErc20Address,
29
29
  });
30
30
  if (allowanceOnChain === '0')
31
31
  return (0, bignumber_1.bnOrZero)(sellAmount);
32
32
  if (!allowanceOnChain) {
33
33
  throw new api_1.SwapError(`[getAllowanceRequired] - No allowance data`, {
34
34
  details: { allowanceContract, receiveAddress },
35
- code: api_1.SwapErrorTypes.RESPONSE_ERROR
35
+ code: api_1.SwapErrorTypes.RESPONSE_ERROR,
36
36
  });
37
37
  }
38
38
  const allowanceRequired = (0, bignumber_1.bnOrZero)(sellAmount).minus(allowanceOnChain);
@@ -43,12 +43,12 @@ const getAllowanceRequired = async ({ adapter, receiveAddress, allowanceContract
43
43
  throw e;
44
44
  throw new api_1.SwapError('[getAllowanceRequired]', {
45
45
  cause: e,
46
- code: api_1.SwapErrorTypes.ALLOWANCE_REQUIRED_FAILED
46
+ code: api_1.SwapErrorTypes.ALLOWANCE_REQUIRED_FAILED,
47
47
  });
48
48
  }
49
49
  };
50
50
  exports.getAllowanceRequired = getAllowanceRequired;
51
- const grantAllowance = async ({ quote, wallet, adapter, erc20Abi, web3 }) => {
51
+ const grantAllowance = async ({ quote, wallet, adapter, erc20Abi, web3, }) => {
52
52
  var _a, _b, _c, _d, _e;
53
53
  try {
54
54
  const { assetReference: sellAssetErc20Address } = (0, caip_1.fromAssetId)(quote.sellAsset.assetId);
@@ -66,12 +66,12 @@ const grantAllowance = async ({ quote, wallet, adapter, erc20Abi, web3 }) => {
66
66
  chainSpecific: {
67
67
  erc20ContractAddress: sellAssetErc20Address,
68
68
  gasPrice: (0, web3_utils_1.numberToHex)(((_b = (_a = quote.feeData) === null || _a === void 0 ? void 0 : _a.chainSpecific) === null || _b === void 0 ? void 0 : _b.gasPrice) || 0),
69
- gasLimit: (0, web3_utils_1.numberToHex)(((_d = (_c = quote.feeData) === null || _c === void 0 ? void 0 : _c.chainSpecific) === null || _d === void 0 ? void 0 : _d.estimatedGas) || 0)
70
- }
69
+ gasLimit: (0, web3_utils_1.numberToHex)(((_d = (_c = quote.feeData) === null || _c === void 0 ? void 0 : _c.chainSpecific) === null || _d === void 0 ? void 0 : _d.estimatedGas) || 0),
70
+ },
71
71
  });
72
72
  const grantAllowanceTxToSign = {
73
73
  ...txToSign,
74
- data: approveTx
74
+ data: approveTx,
75
75
  };
76
76
  if (wallet.supportsOfflineSigning()) {
77
77
  const signedTx = await adapter.signTransaction({ txToSign: grantAllowanceTxToSign, wallet });
@@ -81,13 +81,13 @@ const grantAllowance = async ({ quote, wallet, adapter, erc20Abi, web3 }) => {
81
81
  else if (wallet.supportsBroadcast() && adapter.signAndBroadcastTransaction) {
82
82
  const broadcastedTxId = await ((_e = adapter.signAndBroadcastTransaction) === null || _e === void 0 ? void 0 : _e.call(adapter, {
83
83
  txToSign: grantAllowanceTxToSign,
84
- wallet
84
+ wallet,
85
85
  }));
86
86
  return broadcastedTxId;
87
87
  }
88
88
  else {
89
89
  throw new api_1.SwapError('[grantAllowance] - invalid HDWallet config', {
90
- code: api_1.SwapErrorTypes.SIGN_AND_BROADCAST_FAILED
90
+ code: api_1.SwapErrorTypes.SIGN_AND_BROADCAST_FAILED,
91
91
  });
92
92
  }
93
93
  }
@@ -96,7 +96,7 @@ const grantAllowance = async ({ quote, wallet, adapter, erc20Abi, web3 }) => {
96
96
  throw e;
97
97
  throw new api_1.SwapError('[grantAllowance]', {
98
98
  cause: e,
99
- code: api_1.SwapErrorTypes.GRANT_ALLOWANCE_FAILED
99
+ code: api_1.SwapErrorTypes.GRANT_ALLOWANCE_FAILED,
100
100
  });
101
101
  }
102
102
  };
@@ -117,7 +117,7 @@ const normalizeIntegerAmount = (amount) => {
117
117
  .toLocaleString('fullwide', { useGrouping: false });
118
118
  };
119
119
  exports.normalizeIntegerAmount = normalizeIntegerAmount;
120
- const getApproveContractData = ({ web3, spenderAddress, contractAddress }) => {
120
+ const getApproveContractData = ({ web3, spenderAddress, contractAddress, }) => {
121
121
  const contract = new web3.eth.Contract(erc20_abi_1.erc20Abi, contractAddress);
122
122
  return contract.methods.approve(spenderAddress, constants_1.MAX_ALLOWANCE).encodeABI();
123
123
  };