@xchainjs/xchain-thorchain-amm 3.0.37 → 3.1.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.
- package/README.md +0 -10
- package/lib/index.esm.js +56 -11
- package/lib/index.js +56 -11
- package/lib/thorchain-action.d.ts +2 -0
- package/lib/thorchain-amm.d.ts +7 -3
- package/package.json +21 -21
package/README.md
CHANGED
|
@@ -113,13 +113,3 @@ If you plan on using the publicly accessible endpoints listed below, ensure that
|
|
|
113
113
|
- https://api.haskoin.com (BTC/BCH/LTC)
|
|
114
114
|
- https://gateway.liquify.com/chain/thorchain_api
|
|
115
115
|
|
|
116
|
-
Example
|
|
117
|
-
|
|
118
|
-
```typescript
|
|
119
|
-
import cosmosclient from '@cosmos-client/core'
|
|
120
|
-
import axios from 'axios'
|
|
121
|
-
import { register9Rheader } from '@xchainjs/xchain-util'
|
|
122
|
-
|
|
123
|
-
register9Rheader(axios)
|
|
124
|
-
register9Rheader(cosmosclient.config.globalAxios)
|
|
125
|
-
```
|
package/lib/index.esm.js
CHANGED
|
@@ -3100,12 +3100,13 @@ class ThorchainAction {
|
|
|
3100
3100
|
});
|
|
3101
3101
|
}
|
|
3102
3102
|
static makeProtocolAction(_a) {
|
|
3103
|
-
return __awaiter(this, arguments, void 0, function* ({ wallet, assetAmount, memo }) {
|
|
3103
|
+
return __awaiter(this, arguments, void 0, function* ({ wallet, assetAmount, memo, walletIndex, }) {
|
|
3104
3104
|
const hash = yield wallet.deposit({
|
|
3105
3105
|
chain: THORChain,
|
|
3106
3106
|
asset: assetAmount.asset,
|
|
3107
3107
|
amount: assetAmount.baseAmount,
|
|
3108
3108
|
memo,
|
|
3109
|
+
walletIndex,
|
|
3109
3110
|
});
|
|
3110
3111
|
return {
|
|
3111
3112
|
hash,
|
|
@@ -3114,7 +3115,7 @@ class ThorchainAction {
|
|
|
3114
3115
|
});
|
|
3115
3116
|
}
|
|
3116
3117
|
static makeNonProtocolAction(_a) {
|
|
3117
|
-
return __awaiter(this, arguments, void 0, function* ({ wallet, assetAmount, recipient, memo, }) {
|
|
3118
|
+
return __awaiter(this, arguments, void 0, function* ({ wallet, assetAmount, recipient, memo, walletIndex, }) {
|
|
3118
3119
|
// Non EVM actions
|
|
3119
3120
|
if (!isProtocolEVMChain(assetAmount.asset.chain)) {
|
|
3120
3121
|
if (isProtocolBFTChain(assetAmount.asset.chain)) {
|
|
@@ -3123,6 +3124,7 @@ class ThorchainAction {
|
|
|
3123
3124
|
amount: assetAmount.baseAmount,
|
|
3124
3125
|
recipient,
|
|
3125
3126
|
memo,
|
|
3127
|
+
walletIndex,
|
|
3126
3128
|
});
|
|
3127
3129
|
return {
|
|
3128
3130
|
hash,
|
|
@@ -3136,6 +3138,7 @@ class ThorchainAction {
|
|
|
3136
3138
|
recipient,
|
|
3137
3139
|
memo,
|
|
3138
3140
|
feeRate: feeRates.fast,
|
|
3141
|
+
walletIndex,
|
|
3139
3142
|
});
|
|
3140
3143
|
return {
|
|
3141
3144
|
hash,
|
|
@@ -3171,6 +3174,7 @@ class ThorchainAction {
|
|
|
3171
3174
|
gasPrice: gasPrices.fast,
|
|
3172
3175
|
isMemoEncoded: true,
|
|
3173
3176
|
gasLimit: new BigNumber(160000),
|
|
3177
|
+
walletIndex,
|
|
3174
3178
|
});
|
|
3175
3179
|
return {
|
|
3176
3180
|
hash,
|
|
@@ -3236,7 +3240,7 @@ class ThorchainAMM {
|
|
|
3236
3240
|
* @returns The estimated swap details.
|
|
3237
3241
|
*/
|
|
3238
3242
|
estimateSwap(_a) {
|
|
3239
|
-
return __awaiter(this, arguments, void 0, function* ({ fromAddress, fromAsset, amount, destinationAsset, destinationAddress, affiliateAddress = '', affiliateBps = 0, toleranceBps, liquidityToleranceBps, streamingInterval, streamingQuantity, }) {
|
|
3243
|
+
return __awaiter(this, arguments, void 0, function* ({ fromAddress, fromAsset, amount, destinationAsset, destinationAddress, affiliateAddress = '', affiliateBps = 0, affiliates, toleranceBps, liquidityToleranceBps, streamingInterval, streamingQuantity, }) {
|
|
3240
3244
|
const errors = yield this.validateSwap({
|
|
3241
3245
|
fromAddress,
|
|
3242
3246
|
fromAsset,
|
|
@@ -3251,6 +3255,7 @@ class ThorchainAMM {
|
|
|
3251
3255
|
destinationAddress,
|
|
3252
3256
|
affiliateAddress,
|
|
3253
3257
|
affiliateBps,
|
|
3258
|
+
affiliates,
|
|
3254
3259
|
toleranceBps,
|
|
3255
3260
|
liquidityToleranceBps,
|
|
3256
3261
|
streamingInterval,
|
|
@@ -3268,7 +3273,7 @@ class ThorchainAMM {
|
|
|
3268
3273
|
* @returns {string[]} the reasons the swap can not be done. If it is empty there are no reason to avoid the swap
|
|
3269
3274
|
*/
|
|
3270
3275
|
validateSwap(_a) {
|
|
3271
|
-
return __awaiter(this, arguments, void 0, function* ({ fromAsset, fromAddress, destinationAsset, destinationAddress, amount, affiliateAddress, affiliateBps, streamingInterval, streamingQuantity, }) {
|
|
3276
|
+
return __awaiter(this, arguments, void 0, function* ({ fromAsset, fromAddress, destinationAsset, destinationAddress, amount, affiliateAddress, affiliateBps, affiliates, streamingInterval, streamingQuantity, }) {
|
|
3272
3277
|
const errors = [];
|
|
3273
3278
|
if (destinationAddress &&
|
|
3274
3279
|
!validateAddress(this.thorchainQuery.thorchainCache.midgardQuery.midgardCache.midgard.network, isSynthAsset(destinationAsset) || isTradeAsset(destinationAsset) || isSecuredAsset(destinationAsset)
|
|
@@ -3282,14 +3287,36 @@ class ThorchainAMM {
|
|
|
3282
3287
|
if (isTradeAsset(fromAsset) && !isTradeAsset(destinationAsset) && !eqAsset(destinationAsset, AssetRuneNative)) {
|
|
3283
3288
|
errors.push('Can not make swap from trade asset to non trade asset or non Rune asset. Use withdrawFromTrade (TRADE-) operation');
|
|
3284
3289
|
}
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3290
|
+
// Reject mixing the singular form with the multi-affiliate array — the protocol's quote
|
|
3291
|
+
// endpoint reads them from the same query params, so passing both produces ambiguous wire output.
|
|
3292
|
+
if (affiliates && (affiliateAddress || affiliateBps !== undefined)) {
|
|
3293
|
+
errors.push('affiliates is mutually exclusive with affiliateAddress / affiliateBps; pass one form, not both');
|
|
3294
|
+
}
|
|
3295
|
+
if (affiliates) {
|
|
3296
|
+
if (affiliates.length === 0) {
|
|
3297
|
+
errors.push('affiliates array is empty; omit the field or include at least one entry');
|
|
3298
|
+
}
|
|
3299
|
+
// THORChain consensus caps the affiliate count at 5 per swap (MultipleAffiliatesMaxCount).
|
|
3300
|
+
if (affiliates.length > 5) {
|
|
3301
|
+
errors.push(`affiliates count ${affiliates.length} exceeds THORChain maximum of 5`);
|
|
3302
|
+
}
|
|
3303
|
+
for (const a of affiliates) {
|
|
3304
|
+
const valid = yield this.isThorAffiliateAddress(a.address);
|
|
3305
|
+
if (!valid)
|
|
3306
|
+
errors.push(`affiliate address ${a.address} is not a valid THOR address or THORName`);
|
|
3307
|
+
if (a.bps < 0 || a.bps > 1000) {
|
|
3308
|
+
errors.push(`affiliate bps ${a.bps} for ${a.address} out of range [0 - 1000]`);
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3311
|
+
}
|
|
3312
|
+
else if (affiliateAddress) {
|
|
3313
|
+
const valid = yield this.isThorAffiliateAddress(affiliateAddress);
|
|
3314
|
+
if (!valid)
|
|
3289
3315
|
errors.push(`affiliateAddress ${affiliateAddress} is not a valid THOR address`);
|
|
3290
3316
|
}
|
|
3291
|
-
|
|
3292
|
-
|
|
3317
|
+
// THORChain caps single-affiliate bps at 1000 (10%); previous limit of 10000 was wider than the protocol accepts.
|
|
3318
|
+
if (affiliateBps !== undefined && (affiliateBps < 0 || affiliateBps > 1000)) {
|
|
3319
|
+
errors.push(`affiliateBps ${affiliateBps} out of range [0 - 1000]`);
|
|
3293
3320
|
}
|
|
3294
3321
|
if (streamingInterval && streamingInterval < 0) {
|
|
3295
3322
|
errors.push(`streamingInterval ${streamingInterval} can not be lower than zero`);
|
|
@@ -3313,6 +3340,23 @@ class ThorchainAMM {
|
|
|
3313
3340
|
return errors;
|
|
3314
3341
|
});
|
|
3315
3342
|
}
|
|
3343
|
+
/**
|
|
3344
|
+
* Returns true if the given identifier is either a valid THOR bech32 address or a registered THORName.
|
|
3345
|
+
*/
|
|
3346
|
+
isThorAffiliateAddress(identifier) {
|
|
3347
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3348
|
+
const network = this.thorchainQuery.thorchainCache.midgardQuery.midgardCache.midgard.network;
|
|
3349
|
+
if (validateAddress(network, THORChain, identifier))
|
|
3350
|
+
return true;
|
|
3351
|
+
try {
|
|
3352
|
+
const thorname = yield this.thorchainQuery.thorchainCache.midgardQuery.midgardCache.midgard.getTHORNameDetails(identifier);
|
|
3353
|
+
return !!thorname;
|
|
3354
|
+
}
|
|
3355
|
+
catch (_a) {
|
|
3356
|
+
return false;
|
|
3357
|
+
}
|
|
3358
|
+
});
|
|
3359
|
+
}
|
|
3316
3360
|
/**
|
|
3317
3361
|
* Conducts a swap with the given inputs. This method should be called after estimateSwap() to ensure the swap is valid.
|
|
3318
3362
|
*
|
|
@@ -3321,7 +3365,7 @@ class ThorchainAMM {
|
|
|
3321
3365
|
* @returns {SwapSubmitted} - The transaction hash, URL of BlockExplorer, and expected wait time.
|
|
3322
3366
|
*/
|
|
3323
3367
|
doSwap(_a) {
|
|
3324
|
-
return __awaiter(this, arguments, void 0, function* ({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, streamingInterval, streamingQuantity, }) {
|
|
3368
|
+
return __awaiter(this, arguments, void 0, function* ({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, affiliates, toleranceBps, streamingInterval, streamingQuantity, }) {
|
|
3325
3369
|
// Retrieve swap details from ThorchainQuery to ensure validity
|
|
3326
3370
|
const txDetails = yield this.thorchainQuery.quoteSwap({
|
|
3327
3371
|
fromAsset,
|
|
@@ -3331,6 +3375,7 @@ class ThorchainAMM {
|
|
|
3331
3375
|
destinationAddress,
|
|
3332
3376
|
affiliateAddress,
|
|
3333
3377
|
affiliateBps,
|
|
3378
|
+
affiliates,
|
|
3334
3379
|
toleranceBps,
|
|
3335
3380
|
streamingInterval,
|
|
3336
3381
|
streamingQuantity,
|
package/lib/index.js
CHANGED
|
@@ -3102,12 +3102,13 @@ class ThorchainAction {
|
|
|
3102
3102
|
});
|
|
3103
3103
|
}
|
|
3104
3104
|
static makeProtocolAction(_a) {
|
|
3105
|
-
return __awaiter(this, arguments, void 0, function* ({ wallet, assetAmount, memo }) {
|
|
3105
|
+
return __awaiter(this, arguments, void 0, function* ({ wallet, assetAmount, memo, walletIndex, }) {
|
|
3106
3106
|
const hash = yield wallet.deposit({
|
|
3107
3107
|
chain: xchainThorchain.THORChain,
|
|
3108
3108
|
asset: assetAmount.asset,
|
|
3109
3109
|
amount: assetAmount.baseAmount,
|
|
3110
3110
|
memo,
|
|
3111
|
+
walletIndex,
|
|
3111
3112
|
});
|
|
3112
3113
|
return {
|
|
3113
3114
|
hash,
|
|
@@ -3116,7 +3117,7 @@ class ThorchainAction {
|
|
|
3116
3117
|
});
|
|
3117
3118
|
}
|
|
3118
3119
|
static makeNonProtocolAction(_a) {
|
|
3119
|
-
return __awaiter(this, arguments, void 0, function* ({ wallet, assetAmount, recipient, memo, }) {
|
|
3120
|
+
return __awaiter(this, arguments, void 0, function* ({ wallet, assetAmount, recipient, memo, walletIndex, }) {
|
|
3120
3121
|
// Non EVM actions
|
|
3121
3122
|
if (!isProtocolEVMChain(assetAmount.asset.chain)) {
|
|
3122
3123
|
if (isProtocolBFTChain(assetAmount.asset.chain)) {
|
|
@@ -3125,6 +3126,7 @@ class ThorchainAction {
|
|
|
3125
3126
|
amount: assetAmount.baseAmount,
|
|
3126
3127
|
recipient,
|
|
3127
3128
|
memo,
|
|
3129
|
+
walletIndex,
|
|
3128
3130
|
});
|
|
3129
3131
|
return {
|
|
3130
3132
|
hash,
|
|
@@ -3138,6 +3140,7 @@ class ThorchainAction {
|
|
|
3138
3140
|
recipient,
|
|
3139
3141
|
memo,
|
|
3140
3142
|
feeRate: feeRates.fast,
|
|
3143
|
+
walletIndex,
|
|
3141
3144
|
});
|
|
3142
3145
|
return {
|
|
3143
3146
|
hash,
|
|
@@ -3173,6 +3176,7 @@ class ThorchainAction {
|
|
|
3173
3176
|
gasPrice: gasPrices.fast,
|
|
3174
3177
|
isMemoEncoded: true,
|
|
3175
3178
|
gasLimit: new BigNumber(160000),
|
|
3179
|
+
walletIndex,
|
|
3176
3180
|
});
|
|
3177
3181
|
return {
|
|
3178
3182
|
hash,
|
|
@@ -3238,7 +3242,7 @@ class ThorchainAMM {
|
|
|
3238
3242
|
* @returns The estimated swap details.
|
|
3239
3243
|
*/
|
|
3240
3244
|
estimateSwap(_a) {
|
|
3241
|
-
return __awaiter(this, arguments, void 0, function* ({ fromAddress, fromAsset, amount, destinationAsset, destinationAddress, affiliateAddress = '', affiliateBps = 0, toleranceBps, liquidityToleranceBps, streamingInterval, streamingQuantity, }) {
|
|
3245
|
+
return __awaiter(this, arguments, void 0, function* ({ fromAddress, fromAsset, amount, destinationAsset, destinationAddress, affiliateAddress = '', affiliateBps = 0, affiliates, toleranceBps, liquidityToleranceBps, streamingInterval, streamingQuantity, }) {
|
|
3242
3246
|
const errors = yield this.validateSwap({
|
|
3243
3247
|
fromAddress,
|
|
3244
3248
|
fromAsset,
|
|
@@ -3253,6 +3257,7 @@ class ThorchainAMM {
|
|
|
3253
3257
|
destinationAddress,
|
|
3254
3258
|
affiliateAddress,
|
|
3255
3259
|
affiliateBps,
|
|
3260
|
+
affiliates,
|
|
3256
3261
|
toleranceBps,
|
|
3257
3262
|
liquidityToleranceBps,
|
|
3258
3263
|
streamingInterval,
|
|
@@ -3270,7 +3275,7 @@ class ThorchainAMM {
|
|
|
3270
3275
|
* @returns {string[]} the reasons the swap can not be done. If it is empty there are no reason to avoid the swap
|
|
3271
3276
|
*/
|
|
3272
3277
|
validateSwap(_a) {
|
|
3273
|
-
return __awaiter(this, arguments, void 0, function* ({ fromAsset, fromAddress, destinationAsset, destinationAddress, amount, affiliateAddress, affiliateBps, streamingInterval, streamingQuantity, }) {
|
|
3278
|
+
return __awaiter(this, arguments, void 0, function* ({ fromAsset, fromAddress, destinationAsset, destinationAddress, amount, affiliateAddress, affiliateBps, affiliates, streamingInterval, streamingQuantity, }) {
|
|
3274
3279
|
const errors = [];
|
|
3275
3280
|
if (destinationAddress &&
|
|
3276
3281
|
!validateAddress(this.thorchainQuery.thorchainCache.midgardQuery.midgardCache.midgard.network, xchainUtil.isSynthAsset(destinationAsset) || xchainUtil.isTradeAsset(destinationAsset) || xchainUtil.isSecuredAsset(destinationAsset)
|
|
@@ -3284,14 +3289,36 @@ class ThorchainAMM {
|
|
|
3284
3289
|
if (xchainUtil.isTradeAsset(fromAsset) && !xchainUtil.isTradeAsset(destinationAsset) && !xchainUtil.eqAsset(destinationAsset, xchainThorchain.AssetRuneNative)) {
|
|
3285
3290
|
errors.push('Can not make swap from trade asset to non trade asset or non Rune asset. Use withdrawFromTrade (TRADE-) operation');
|
|
3286
3291
|
}
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3292
|
+
// Reject mixing the singular form with the multi-affiliate array — the protocol's quote
|
|
3293
|
+
// endpoint reads them from the same query params, so passing both produces ambiguous wire output.
|
|
3294
|
+
if (affiliates && (affiliateAddress || affiliateBps !== undefined)) {
|
|
3295
|
+
errors.push('affiliates is mutually exclusive with affiliateAddress / affiliateBps; pass one form, not both');
|
|
3296
|
+
}
|
|
3297
|
+
if (affiliates) {
|
|
3298
|
+
if (affiliates.length === 0) {
|
|
3299
|
+
errors.push('affiliates array is empty; omit the field or include at least one entry');
|
|
3300
|
+
}
|
|
3301
|
+
// THORChain consensus caps the affiliate count at 5 per swap (MultipleAffiliatesMaxCount).
|
|
3302
|
+
if (affiliates.length > 5) {
|
|
3303
|
+
errors.push(`affiliates count ${affiliates.length} exceeds THORChain maximum of 5`);
|
|
3304
|
+
}
|
|
3305
|
+
for (const a of affiliates) {
|
|
3306
|
+
const valid = yield this.isThorAffiliateAddress(a.address);
|
|
3307
|
+
if (!valid)
|
|
3308
|
+
errors.push(`affiliate address ${a.address} is not a valid THOR address or THORName`);
|
|
3309
|
+
if (a.bps < 0 || a.bps > 1000) {
|
|
3310
|
+
errors.push(`affiliate bps ${a.bps} for ${a.address} out of range [0 - 1000]`);
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
else if (affiliateAddress) {
|
|
3315
|
+
const valid = yield this.isThorAffiliateAddress(affiliateAddress);
|
|
3316
|
+
if (!valid)
|
|
3291
3317
|
errors.push(`affiliateAddress ${affiliateAddress} is not a valid THOR address`);
|
|
3292
3318
|
}
|
|
3293
|
-
|
|
3294
|
-
|
|
3319
|
+
// THORChain caps single-affiliate bps at 1000 (10%); previous limit of 10000 was wider than the protocol accepts.
|
|
3320
|
+
if (affiliateBps !== undefined && (affiliateBps < 0 || affiliateBps > 1000)) {
|
|
3321
|
+
errors.push(`affiliateBps ${affiliateBps} out of range [0 - 1000]`);
|
|
3295
3322
|
}
|
|
3296
3323
|
if (streamingInterval && streamingInterval < 0) {
|
|
3297
3324
|
errors.push(`streamingInterval ${streamingInterval} can not be lower than zero`);
|
|
@@ -3315,6 +3342,23 @@ class ThorchainAMM {
|
|
|
3315
3342
|
return errors;
|
|
3316
3343
|
});
|
|
3317
3344
|
}
|
|
3345
|
+
/**
|
|
3346
|
+
* Returns true if the given identifier is either a valid THOR bech32 address or a registered THORName.
|
|
3347
|
+
*/
|
|
3348
|
+
isThorAffiliateAddress(identifier) {
|
|
3349
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3350
|
+
const network = this.thorchainQuery.thorchainCache.midgardQuery.midgardCache.midgard.network;
|
|
3351
|
+
if (validateAddress(network, xchainThorchain.THORChain, identifier))
|
|
3352
|
+
return true;
|
|
3353
|
+
try {
|
|
3354
|
+
const thorname = yield this.thorchainQuery.thorchainCache.midgardQuery.midgardCache.midgard.getTHORNameDetails(identifier);
|
|
3355
|
+
return !!thorname;
|
|
3356
|
+
}
|
|
3357
|
+
catch (_a) {
|
|
3358
|
+
return false;
|
|
3359
|
+
}
|
|
3360
|
+
});
|
|
3361
|
+
}
|
|
3318
3362
|
/**
|
|
3319
3363
|
* Conducts a swap with the given inputs. This method should be called after estimateSwap() to ensure the swap is valid.
|
|
3320
3364
|
*
|
|
@@ -3323,7 +3367,7 @@ class ThorchainAMM {
|
|
|
3323
3367
|
* @returns {SwapSubmitted} - The transaction hash, URL of BlockExplorer, and expected wait time.
|
|
3324
3368
|
*/
|
|
3325
3369
|
doSwap(_a) {
|
|
3326
|
-
return __awaiter(this, arguments, void 0, function* ({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, streamingInterval, streamingQuantity, }) {
|
|
3370
|
+
return __awaiter(this, arguments, void 0, function* ({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, affiliates, toleranceBps, streamingInterval, streamingQuantity, }) {
|
|
3327
3371
|
// Retrieve swap details from ThorchainQuery to ensure validity
|
|
3328
3372
|
const txDetails = yield this.thorchainQuery.quoteSwap({
|
|
3329
3373
|
fromAsset,
|
|
@@ -3333,6 +3377,7 @@ class ThorchainAMM {
|
|
|
3333
3377
|
destinationAddress,
|
|
3334
3378
|
affiliateAddress,
|
|
3335
3379
|
affiliateBps,
|
|
3380
|
+
affiliates,
|
|
3336
3381
|
toleranceBps,
|
|
3337
3382
|
streamingInterval,
|
|
3338
3383
|
streamingQuantity,
|
|
@@ -7,11 +7,13 @@ export type NonProtocolActionParams = {
|
|
|
7
7
|
assetAmount: CryptoAmount<Asset | TokenAsset>;
|
|
8
8
|
recipient: Address;
|
|
9
9
|
memo: string;
|
|
10
|
+
walletIndex?: number;
|
|
10
11
|
};
|
|
11
12
|
export type ProtocolActionParams = {
|
|
12
13
|
wallet: Wallet;
|
|
13
14
|
assetAmount: CryptoAmount<CompatibleAsset>;
|
|
14
15
|
memo: string;
|
|
16
|
+
walletIndex?: number;
|
|
15
17
|
};
|
|
16
18
|
export type ActionParams = ProtocolActionParams | NonProtocolActionParams;
|
|
17
19
|
export declare class ThorchainAction {
|
package/lib/thorchain-amm.d.ts
CHANGED
|
@@ -26,13 +26,17 @@ export declare class ThorchainAMM {
|
|
|
26
26
|
|
|
27
27
|
* @returns The estimated swap details.
|
|
28
28
|
*/
|
|
29
|
-
estimateSwap({ fromAddress, fromAsset, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, liquidityToleranceBps, streamingInterval, streamingQuantity, }: QuoteSwapParams): Promise<TxDetails>;
|
|
29
|
+
estimateSwap({ fromAddress, fromAsset, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, affiliates, toleranceBps, liquidityToleranceBps, streamingInterval, streamingQuantity, }: QuoteSwapParams): Promise<TxDetails>;
|
|
30
30
|
/**
|
|
31
31
|
* Validate swap params
|
|
32
32
|
* @param {QuoteSwapParams} quoteSwapParams Swap params
|
|
33
33
|
* @returns {string[]} the reasons the swap can not be done. If it is empty there are no reason to avoid the swap
|
|
34
34
|
*/
|
|
35
|
-
validateSwap({ fromAsset, fromAddress, destinationAsset, destinationAddress, amount, affiliateAddress, affiliateBps, streamingInterval, streamingQuantity, }: QuoteSwapParams): Promise<string[]>;
|
|
35
|
+
validateSwap({ fromAsset, fromAddress, destinationAsset, destinationAddress, amount, affiliateAddress, affiliateBps, affiliates, streamingInterval, streamingQuantity, }: QuoteSwapParams): Promise<string[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Returns true if the given identifier is either a valid THOR bech32 address or a registered THORName.
|
|
38
|
+
*/
|
|
39
|
+
private isThorAffiliateAddress;
|
|
36
40
|
/**
|
|
37
41
|
* Conducts a swap with the given inputs. This method should be called after estimateSwap() to ensure the swap is valid.
|
|
38
42
|
*
|
|
@@ -40,7 +44,7 @@ export declare class ThorchainAMM {
|
|
|
40
44
|
* @param params - The swap parameters.
|
|
41
45
|
* @returns {SwapSubmitted} - The transaction hash, URL of BlockExplorer, and expected wait time.
|
|
42
46
|
*/
|
|
43
|
-
doSwap({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, streamingInterval, streamingQuantity, }: QuoteSwapParams): Promise<TxSubmitted>;
|
|
47
|
+
doSwap({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, affiliates, toleranceBps, streamingInterval, streamingQuantity, }: QuoteSwapParams): Promise<TxSubmitted>;
|
|
44
48
|
/**
|
|
45
49
|
* Approve the Thorchain router to spend a certain amount in the asset chain.
|
|
46
50
|
* @param {ApproveParams} approveParams Parameters for approving the router to spend
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-thorchain-amm",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "module that exposes estimating & swappping cryptocurrency assets on thorchain",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"THORChain",
|
|
@@ -36,31 +36,31 @@
|
|
|
36
36
|
"url": "https://github.com/xchainjs/xchainjs-lib/issues"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@xchainjs/xchain-avax": "2.0.
|
|
40
|
-
"@xchainjs/xchain-base": "1.0.
|
|
41
|
-
"@xchainjs/xchain-bitcoin": "2.2.
|
|
42
|
-
"@xchainjs/xchain-bitcoincash": "2.2.
|
|
43
|
-
"@xchainjs/xchain-bsc": "2.0.
|
|
44
|
-
"@xchainjs/xchain-client": "2.0.
|
|
45
|
-
"@xchainjs/xchain-cosmos": "3.0.
|
|
46
|
-
"@xchainjs/xchain-doge": "2.2.
|
|
47
|
-
"@xchainjs/xchain-ethereum": "2.0.
|
|
48
|
-
"@xchainjs/xchain-evm": "2.0.
|
|
49
|
-
"@xchainjs/xchain-litecoin": "2.3.
|
|
50
|
-
"@xchainjs/xchain-ripple": "1.0.
|
|
51
|
-
"@xchainjs/xchain-solana": "1.1.
|
|
52
|
-
"@xchainjs/xchain-sui": "0.1.
|
|
53
|
-
"@xchainjs/xchain-thorchain": "3.0.
|
|
54
|
-
"@xchainjs/xchain-thorchain-query": "3.0
|
|
55
|
-
"@xchainjs/xchain-tron": "3.0.
|
|
39
|
+
"@xchainjs/xchain-avax": "2.0.18",
|
|
40
|
+
"@xchainjs/xchain-base": "1.0.18",
|
|
41
|
+
"@xchainjs/xchain-bitcoin": "2.2.6",
|
|
42
|
+
"@xchainjs/xchain-bitcoincash": "2.2.7",
|
|
43
|
+
"@xchainjs/xchain-bsc": "2.0.19",
|
|
44
|
+
"@xchainjs/xchain-client": "2.0.14",
|
|
45
|
+
"@xchainjs/xchain-cosmos": "3.0.14",
|
|
46
|
+
"@xchainjs/xchain-doge": "2.2.6",
|
|
47
|
+
"@xchainjs/xchain-ethereum": "2.0.19",
|
|
48
|
+
"@xchainjs/xchain-evm": "2.0.18",
|
|
49
|
+
"@xchainjs/xchain-litecoin": "2.3.3",
|
|
50
|
+
"@xchainjs/xchain-ripple": "1.0.16",
|
|
51
|
+
"@xchainjs/xchain-solana": "1.1.6",
|
|
52
|
+
"@xchainjs/xchain-sui": "0.1.3",
|
|
53
|
+
"@xchainjs/xchain-thorchain": "3.0.18",
|
|
54
|
+
"@xchainjs/xchain-thorchain-query": "3.1.0",
|
|
55
|
+
"@xchainjs/xchain-tron": "3.0.7",
|
|
56
56
|
"@xchainjs/xchain-util": "2.0.7",
|
|
57
|
-
"@xchainjs/xchain-wallet": "2.0.
|
|
58
|
-
"@xchainjs/xchain-zcash": "1.3.
|
|
57
|
+
"@xchainjs/xchain-wallet": "2.0.29",
|
|
58
|
+
"@xchainjs/xchain-zcash": "1.3.7",
|
|
59
59
|
"ethers": "^6.14.3"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@ledgerhq/hw-transport-node-hid": "^6.28.6",
|
|
63
|
-
"axios": "1.
|
|
63
|
+
"axios": "1.16.1",
|
|
64
64
|
"axios-mock-adapter": "^2.1.0"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|