@xchainjs/xchain-mayachain-amm 4.0.7 → 4.0.9
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/lib/index.esm.js +30 -26
- package/lib/index.js +8 -4
- package/package.json +18 -17
package/lib/index.esm.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { AssetAETH, ARBChain, Client, defaultArbParams } from '@xchainjs/xchain-arbitrum';
|
|
2
|
-
import {
|
|
2
|
+
import { ZECChain, Client as Client$1, defaultZECParams } from '@xchainjs/xchain-zcash';
|
|
3
|
+
import { BTCChain, Client as Client$8, defaultBTCParams } from '@xchainjs/xchain-bitcoin';
|
|
3
4
|
import { Network } from '@xchainjs/xchain-client';
|
|
4
|
-
import { DASHChain, Client as Client$
|
|
5
|
-
import { AssetETH, ETHChain, Client as Client$
|
|
5
|
+
import { DASHChain, Client as Client$6, defaultDashParams } from '@xchainjs/xchain-dash';
|
|
6
|
+
import { AssetETH, ETHChain, Client as Client$7, defaultEthParams } from '@xchainjs/xchain-ethereum';
|
|
6
7
|
import { abi, MAX_APPROVAL } from '@xchainjs/xchain-evm';
|
|
7
|
-
import { AssetKUJI, KUJIChain, Client as Client$
|
|
8
|
-
import { MAYAChain, Client as Client$
|
|
8
|
+
import { AssetKUJI, KUJIChain, Client as Client$5, defaultKujiParams } from '@xchainjs/xchain-kujira';
|
|
9
|
+
import { MAYAChain, Client as Client$3, CACAO_DECIMAL, AssetCacao } from '@xchainjs/xchain-mayachain';
|
|
9
10
|
import { MayachainQuery } from '@xchainjs/xchain-mayachain-query';
|
|
10
|
-
import { RadixChain, Client as Client$
|
|
11
|
-
import { AssetRuneNative, THORChain, Client as Client$
|
|
11
|
+
import { RadixChain, Client as Client$2, AssetXRD, generateAddressParam, generateBucketParam, generateStringParam } from '@xchainjs/xchain-radix';
|
|
12
|
+
import { AssetRuneNative, THORChain, Client as Client$4 } from '@xchainjs/xchain-thorchain';
|
|
12
13
|
import { eqAsset, isSynthAsset, getContractAddressFromAsset, baseAmount, CryptoAmount, assetToString, AssetCryptoAmount } from '@xchainjs/xchain-util';
|
|
13
14
|
import { Wallet } from '@xchainjs/xchain-wallet';
|
|
14
|
-
import {
|
|
15
|
+
import { getAddress, ZeroAddress, Contract } from 'ethers';
|
|
15
16
|
|
|
16
17
|
/******************************************************************************
|
|
17
18
|
Copyright (c) Microsoft Corporation.
|
|
@@ -93,19 +94,21 @@ const isRadixChain = (chain) => {
|
|
|
93
94
|
const validateAddress = (network, chain, address) => {
|
|
94
95
|
switch (chain) {
|
|
95
96
|
case BTCChain:
|
|
96
|
-
return new Client$
|
|
97
|
+
return new Client$8(Object.assign(Object.assign({}, defaultBTCParams), { network })).validateAddress(address);
|
|
97
98
|
case ETHChain:
|
|
98
|
-
return new Client$
|
|
99
|
+
return new Client$7(Object.assign(Object.assign({}, defaultEthParams), { network })).validateAddress(address);
|
|
99
100
|
case DASHChain:
|
|
100
|
-
return new Client$
|
|
101
|
+
return new Client$6(Object.assign(Object.assign({}, defaultDashParams), { network })).validateAddress(address);
|
|
101
102
|
case KUJIChain:
|
|
102
|
-
return new Client$
|
|
103
|
+
return new Client$5(Object.assign(Object.assign({}, defaultKujiParams), { network })).validateAddress(address);
|
|
103
104
|
case THORChain:
|
|
104
|
-
return new Client$
|
|
105
|
+
return new Client$4({ network }).validateAddress(address);
|
|
105
106
|
case MAYAChain:
|
|
106
|
-
return new Client$
|
|
107
|
+
return new Client$3({ network }).validateAddress(address);
|
|
107
108
|
case RadixChain:
|
|
108
|
-
return new Client$
|
|
109
|
+
return new Client$2({ network }).validateAddress(address);
|
|
110
|
+
case ZECChain:
|
|
111
|
+
return new Client$1(Object.assign(Object.assign({}, defaultZECParams), { network })).validateAddress(address);
|
|
109
112
|
case ARBChain:
|
|
110
113
|
return new Client(Object.assign(Object.assign({}, defaultArbParams), { network: Network.Mainnet })).validateAddress(address);
|
|
111
114
|
default:
|
|
@@ -199,8 +202,8 @@ class MayachainAction {
|
|
|
199
202
|
// Evm
|
|
200
203
|
const isERC20 = isProtocolERC20Asset(assetAmount.asset);
|
|
201
204
|
const checkSummedContractAddress = isERC20
|
|
202
|
-
?
|
|
203
|
-
:
|
|
205
|
+
? getAddress(getContractAddressFromAsset(assetAmount.asset))
|
|
206
|
+
: ZeroAddress;
|
|
204
207
|
const expiration = Math.floor(new Date(new Date().getTime() + 15 * 60000).getTime() / 1000);
|
|
205
208
|
const depositParams = [
|
|
206
209
|
recipient,
|
|
@@ -209,9 +212,9 @@ class MayachainAction {
|
|
|
209
212
|
memo,
|
|
210
213
|
expiration,
|
|
211
214
|
];
|
|
212
|
-
const routerContract = new
|
|
215
|
+
const routerContract = new Contract(inboundDetails.router, abi.router);
|
|
213
216
|
const gasPrices = yield wallet.getFeeRates(assetAmount.asset.chain);
|
|
214
|
-
const unsignedTx = yield routerContract.populateTransaction
|
|
217
|
+
const unsignedTx = yield routerContract.getFunction('depositWithExpiry').populateTransaction(...depositParams);
|
|
215
218
|
const nativeAsset = wallet.getAssetInfo(assetAmount.asset.chain);
|
|
216
219
|
const tx = {
|
|
217
220
|
asset: nativeAsset.asset,
|
|
@@ -254,14 +257,15 @@ class MayachainAMM {
|
|
|
254
257
|
* @returns {MayachainAMM} Returns the MayachainAMM instance.
|
|
255
258
|
*/
|
|
256
259
|
constructor(mayachainQuery = new MayachainQuery(), wallet = new Wallet({
|
|
257
|
-
BTC: new Client$
|
|
258
|
-
ETH: new Client$
|
|
259
|
-
DASH: new Client$
|
|
260
|
-
KUJI: new Client$
|
|
260
|
+
BTC: new Client$8(Object.assign(Object.assign({}, defaultBTCParams), { network: Network.Mainnet })),
|
|
261
|
+
ETH: new Client$7(Object.assign(Object.assign({}, defaultEthParams), { network: Network.Mainnet })),
|
|
262
|
+
DASH: new Client$6(Object.assign(Object.assign({}, defaultDashParams), { network: Network.Mainnet })),
|
|
263
|
+
KUJI: new Client$5(Object.assign(Object.assign({}, defaultKujiParams), { network: Network.Mainnet })),
|
|
261
264
|
ARB: new Client(Object.assign(Object.assign({}, defaultArbParams), { network: Network.Mainnet })),
|
|
262
|
-
THOR: new Client$
|
|
263
|
-
MAYA: new Client$
|
|
264
|
-
XRD: new Client$
|
|
265
|
+
THOR: new Client$4({ network: Network.Mainnet }),
|
|
266
|
+
MAYA: new Client$3({ network: Network.Mainnet }),
|
|
267
|
+
XRD: new Client$2({ network: Network.Mainnet }),
|
|
268
|
+
ZEC: new Client$1(Object.assign(Object.assign({}, defaultZECParams), { network: Network.Mainnet })),
|
|
265
269
|
})) {
|
|
266
270
|
this.mayachainQuery = mayachainQuery;
|
|
267
271
|
this.wallet = wallet;
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var xchainArbitrum = require('@xchainjs/xchain-arbitrum');
|
|
4
|
+
var xchainZcash = require('@xchainjs/xchain-zcash');
|
|
4
5
|
var xchainBitcoin = require('@xchainjs/xchain-bitcoin');
|
|
5
6
|
var xchainClient = require('@xchainjs/xchain-client');
|
|
6
7
|
var xchainDash = require('@xchainjs/xchain-dash');
|
|
@@ -108,6 +109,8 @@ const validateAddress = (network, chain, address) => {
|
|
|
108
109
|
return new xchainMayachain.Client({ network }).validateAddress(address);
|
|
109
110
|
case xchainRadix.RadixChain:
|
|
110
111
|
return new xchainRadix.Client({ network }).validateAddress(address);
|
|
112
|
+
case xchainZcash.ZECChain:
|
|
113
|
+
return new xchainZcash.Client(Object.assign(Object.assign({}, xchainZcash.defaultZECParams), { network })).validateAddress(address);
|
|
111
114
|
case xchainArbitrum.ARBChain:
|
|
112
115
|
return new xchainArbitrum.Client(Object.assign(Object.assign({}, xchainArbitrum.defaultArbParams), { network: xchainClient.Network.Mainnet })).validateAddress(address);
|
|
113
116
|
default:
|
|
@@ -201,8 +204,8 @@ class MayachainAction {
|
|
|
201
204
|
// Evm
|
|
202
205
|
const isERC20 = isProtocolERC20Asset(assetAmount.asset);
|
|
203
206
|
const checkSummedContractAddress = isERC20
|
|
204
|
-
? ethers.
|
|
205
|
-
: ethers.
|
|
207
|
+
? ethers.getAddress(xchainUtil.getContractAddressFromAsset(assetAmount.asset))
|
|
208
|
+
: ethers.ZeroAddress;
|
|
206
209
|
const expiration = Math.floor(new Date(new Date().getTime() + 15 * 60000).getTime() / 1000);
|
|
207
210
|
const depositParams = [
|
|
208
211
|
recipient,
|
|
@@ -211,9 +214,9 @@ class MayachainAction {
|
|
|
211
214
|
memo,
|
|
212
215
|
expiration,
|
|
213
216
|
];
|
|
214
|
-
const routerContract = new ethers.
|
|
217
|
+
const routerContract = new ethers.Contract(inboundDetails.router, xchainEvm.abi.router);
|
|
215
218
|
const gasPrices = yield wallet.getFeeRates(assetAmount.asset.chain);
|
|
216
|
-
const unsignedTx = yield routerContract.populateTransaction
|
|
219
|
+
const unsignedTx = yield routerContract.getFunction('depositWithExpiry').populateTransaction(...depositParams);
|
|
217
220
|
const nativeAsset = wallet.getAssetInfo(assetAmount.asset.chain);
|
|
218
221
|
const tx = {
|
|
219
222
|
asset: nativeAsset.asset,
|
|
@@ -264,6 +267,7 @@ class MayachainAMM {
|
|
|
264
267
|
THOR: new xchainThorchain.Client({ network: xchainClient.Network.Mainnet }),
|
|
265
268
|
MAYA: new xchainMayachain.Client({ network: xchainClient.Network.Mainnet }),
|
|
266
269
|
XRD: new xchainRadix.Client({ network: xchainClient.Network.Mainnet }),
|
|
270
|
+
ZEC: new xchainZcash.Client(Object.assign(Object.assign({}, xchainZcash.defaultZECParams), { network: xchainClient.Network.Mainnet })),
|
|
267
271
|
})) {
|
|
268
272
|
this.mayachainQuery = mayachainQuery;
|
|
269
273
|
this.wallet = wallet;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-mayachain-amm",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.9",
|
|
4
4
|
"description": "module that exposes estimating & swapping cryptocurrency assets on mayachain",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MAYAChain",
|
|
@@ -36,26 +36,27 @@
|
|
|
36
36
|
"url": "https://github.com/xchainjs/xchainjs-lib/issues"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@xchainjs/xchain-arbitrum": "2.0.
|
|
40
|
-
"@xchainjs/xchain-bitcoin": "2.0.
|
|
41
|
-
"@xchainjs/xchain-client": "2.0.
|
|
42
|
-
"@xchainjs/xchain-crypto": "1.0.
|
|
43
|
-
"@xchainjs/xchain-dash": "2.0.
|
|
44
|
-
"@xchainjs/xchain-ethereum": "2.0.
|
|
45
|
-
"@xchainjs/xchain-evm": "2.0.
|
|
46
|
-
"@xchainjs/xchain-kujira": "2.0.
|
|
47
|
-
"@xchainjs/xchain-mayachain": "3.0.
|
|
48
|
-
"@xchainjs/xchain-mayachain-query": "2.0.
|
|
49
|
-
"@xchainjs/xchain-radix": "2.0.
|
|
50
|
-
"@xchainjs/xchain-thorchain": "3.0.
|
|
51
|
-
"@xchainjs/xchain-util": "2.0.
|
|
52
|
-
"@xchainjs/xchain-wallet": "2.0.
|
|
53
|
-
"
|
|
39
|
+
"@xchainjs/xchain-arbitrum": "2.0.3",
|
|
40
|
+
"@xchainjs/xchain-bitcoin": "2.0.2",
|
|
41
|
+
"@xchainjs/xchain-client": "2.0.2",
|
|
42
|
+
"@xchainjs/xchain-crypto": "1.0.1",
|
|
43
|
+
"@xchainjs/xchain-dash": "2.0.2",
|
|
44
|
+
"@xchainjs/xchain-ethereum": "2.0.4",
|
|
45
|
+
"@xchainjs/xchain-evm": "2.0.3",
|
|
46
|
+
"@xchainjs/xchain-kujira": "2.0.2",
|
|
47
|
+
"@xchainjs/xchain-mayachain": "3.0.2",
|
|
48
|
+
"@xchainjs/xchain-mayachain-query": "2.0.4",
|
|
49
|
+
"@xchainjs/xchain-radix": "2.0.2",
|
|
50
|
+
"@xchainjs/xchain-thorchain": "3.0.6",
|
|
51
|
+
"@xchainjs/xchain-util": "2.0.1",
|
|
52
|
+
"@xchainjs/xchain-wallet": "2.0.7",
|
|
53
|
+
"@xchainjs/xchain-zcash": "1.0.3",
|
|
54
|
+
"ethers": "^6.14.3"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@ledgerhq/hw-transport-node-hid": "6.28.6",
|
|
57
58
|
"axios": "1.8.4",
|
|
58
|
-
"axios-mock-adapter": "1.
|
|
59
|
+
"axios-mock-adapter": "2.1.0"
|
|
59
60
|
},
|
|
60
61
|
"publishConfig": {
|
|
61
62
|
"access": "public",
|