@chainflip/sdk 1.3.0-alpha.6 → 1.3.0-beta.2
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/{broker-7CH2KKIE.mjs → broker-AKUV2UWF.mjs} +7 -5
- package/dist/{chunk-NQ2JM5ZP.mjs → chunk-I6HKG4VF.mjs} +24 -20
- package/dist/{chunk-PYU5KZSK.mjs → chunk-IFMXL6VR.mjs} +3 -2
- package/dist/{chunk-VI7GMT56.mjs → chunk-KWYZ5QIZ.mjs} +2 -1
- package/dist/funding.js +22 -23
- package/dist/funding.mjs +7 -7
- package/dist/swap.d.mts +16 -12
- package/dist/swap.d.ts +16 -12
- package/dist/swap.js +116 -81
- package/dist/swap.mjs +87 -63
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ccmMetadataSchema } from './chunk-
|
|
2
|
-
import { z, __name, Chains, uncheckedAssetAndChain, numericString, hexString, btcAddress, hexStringFromNumber, dotAddress, unsignedInteger } from './chunk-
|
|
1
|
+
import { ccmMetadataSchema } from './chunk-IFMXL6VR.mjs';
|
|
2
|
+
import { z, __name, Chains, uncheckedAssetAndChain, numericString, hexString, btcAddress, hexStringFromNumber, dotAddress, unsignedInteger, u128 } from './chunk-KWYZ5QIZ.mjs';
|
|
3
3
|
import { u8aToHex } from '@polkadot/util';
|
|
4
4
|
import { decodeAddress } from '@polkadot/util-crypto';
|
|
5
5
|
import axios from 'axios';
|
|
@@ -74,12 +74,14 @@ var responseValidators = /* @__PURE__ */ __name((network) => ({
|
|
|
74
74
|
issued_block: z.number(),
|
|
75
75
|
channel_id: z.number(),
|
|
76
76
|
expiry_block: z.number().int().safe().positive().optional(),
|
|
77
|
-
source_chain_expiry_block: unsignedInteger.optional()
|
|
78
|
-
|
|
77
|
+
source_chain_expiry_block: unsignedInteger.optional(),
|
|
78
|
+
channel_opening_fee: u128.optional().default(0)
|
|
79
|
+
}).transform(({ address, issued_block, channel_id, source_chain_expiry_block, channel_opening_fee }) => ({
|
|
79
80
|
address,
|
|
80
81
|
issuedBlock: issued_block,
|
|
81
82
|
channelId: BigInt(channel_id),
|
|
82
|
-
sourceChainExpiryBlock: source_chain_expiry_block
|
|
83
|
+
sourceChainExpiryBlock: source_chain_expiry_block,
|
|
84
|
+
channelOpeningFee: channel_opening_fee
|
|
83
85
|
}))
|
|
84
86
|
}), "responseValidators");
|
|
85
87
|
var makeRpcRequest = /* @__PURE__ */ __name(async (network, url, method, ...params) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z, ChainflipNetworks, hexString, __name, __publicField, InternalAssets } from './chunk-
|
|
1
|
+
import { z, ChainflipNetworks, hexString, __name, __publicField, Chains, InternalAssets } from './chunk-KWYZ5QIZ.mjs';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { Interface, Contract } from 'ethers';
|
|
4
4
|
|
|
@@ -18,7 +18,7 @@ var camelCaseKeys = /* @__PURE__ */ __name((obj) => {
|
|
|
18
18
|
var RPC_URLS = {
|
|
19
19
|
[ChainflipNetworks.backspin]: "https://backspin-rpc.staging",
|
|
20
20
|
[ChainflipNetworks.sisyphos]: "https://archive.sisyphos.chainflip.io",
|
|
21
|
-
[ChainflipNetworks.perseverance]: "https://perseverance.chainflip.
|
|
21
|
+
[ChainflipNetworks.perseverance]: "https://archive.perseverance.chainflip.io",
|
|
22
22
|
[ChainflipNetworks.mainnet]: "https://mainnet-rpc.chainflip.io"
|
|
23
23
|
};
|
|
24
24
|
var createRequest = /* @__PURE__ */ __name((method, responseParser) => async (urlOrNetwork, ...params) => {
|
|
@@ -72,23 +72,15 @@ var rename = /* @__PURE__ */ __name((mapping) => (obj) => Object.fromEntries(Obj
|
|
|
72
72
|
])), "rename");
|
|
73
73
|
var ingressEgressEnvironment = z.object({
|
|
74
74
|
minimum_deposit_amounts: chainAssetMapFactory(numberOrHex, 0),
|
|
75
|
-
ingress_fees: chainAssetMapFactory(numberOrHex,
|
|
76
|
-
egress_fees: chainAssetMapFactory(numberOrHex,
|
|
75
|
+
ingress_fees: chainAssetMapFactory(numberOrHex.nullable(), null),
|
|
76
|
+
egress_fees: chainAssetMapFactory(numberOrHex.nullable(), null),
|
|
77
77
|
witness_safety_margins: chainNumberNullableMap,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
ETH: 1,
|
|
85
|
-
USDC: 1,
|
|
86
|
-
FLIP: 1,
|
|
87
|
-
USDT: 1
|
|
88
|
-
},
|
|
89
|
-
Polkadot: {
|
|
90
|
-
DOT: 1
|
|
91
|
-
}
|
|
78
|
+
egress_dust_limits: chainAssetMapFactory(numberOrHex, 1),
|
|
79
|
+
// TODO(1.3): remove optional and default value
|
|
80
|
+
channel_opening_fees: chainMap(numberOrHex).optional().default({
|
|
81
|
+
Bitcoin: 0,
|
|
82
|
+
Ethereum: 0,
|
|
83
|
+
Polkadot: 0
|
|
92
84
|
})
|
|
93
85
|
}).transform(rename({
|
|
94
86
|
egress_dust_limits: "minimum_egress_amounts"
|
|
@@ -2144,6 +2136,18 @@ var Vault__factory = _Vault__factory;
|
|
|
2144
2136
|
[ChainflipNetworks.perseverance]: 1e3,
|
|
2145
2137
|
[ChainflipNetworks.mainnet]: 1e3
|
|
2146
2138
|
});
|
|
2139
|
+
var ETHEREUM_EVM_CHAIN_ID = {
|
|
2140
|
+
[ChainflipNetworks.backspin]: 10997,
|
|
2141
|
+
[ChainflipNetworks.sisyphos]: 11155111,
|
|
2142
|
+
[ChainflipNetworks.perseverance]: 11155111,
|
|
2143
|
+
[ChainflipNetworks.mainnet]: 1
|
|
2144
|
+
};
|
|
2145
|
+
var getEvmChainId = /* @__PURE__ */ __name((chain, network) => {
|
|
2146
|
+
if (chain === Chains.Ethereum) {
|
|
2147
|
+
return ETHEREUM_EVM_CHAIN_ID[network];
|
|
2148
|
+
}
|
|
2149
|
+
return void 0;
|
|
2150
|
+
}, "getEvmChainId");
|
|
2147
2151
|
var SEPOLIA_USDC_CONTRACT_ADDRESS = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238";
|
|
2148
2152
|
var SEPOLIA_USDT_CONTRACT_ADDRESS = "0x7169D38820dfd117C3FA1f22a697dBA58d90BA06";
|
|
2149
2153
|
var ADDRESSES = {
|
|
@@ -2199,7 +2203,7 @@ var checkAllowance = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20
|
|
|
2199
2203
|
const allowance = await erc20.allowance(signerAddress, spenderAddress);
|
|
2200
2204
|
return {
|
|
2201
2205
|
allowance,
|
|
2202
|
-
|
|
2206
|
+
hasSufficientAllowance: allowance >= amount,
|
|
2203
2207
|
erc20
|
|
2204
2208
|
};
|
|
2205
2209
|
}, "checkAllowance");
|
|
@@ -2216,4 +2220,4 @@ var getFlipBalance = /* @__PURE__ */ __name(async (network, signer) => {
|
|
|
2216
2220
|
return flip.balanceOf(await signer.getAddress());
|
|
2217
2221
|
}, "getFlipBalance");
|
|
2218
2222
|
|
|
2219
|
-
export { StateChainGateway__factory, Vault__factory, approve, checkAllowance, extractOverrides, getEnvironment, getFlipBalance, getFundingEnvironment, getStateChainGatewayContractAddress, getTokenContractAddress, getVaultManagerContractAddress };
|
|
2223
|
+
export { StateChainGateway__factory, Vault__factory, approve, checkAllowance, extractOverrides, getEnvironment, getEvmChainId, getFlipBalance, getFundingEnvironment, getStateChainGatewayContractAddress, getTokenContractAddress, getVaultManagerContractAddress };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z, chain, asset, numericString, hexStringWithMaxByteSize } from './chunk-
|
|
1
|
+
import { z, chain, asset, numericString, numericOrEmptyString, hexStringWithMaxByteSize } from './chunk-KWYZ5QIZ.mjs';
|
|
2
2
|
|
|
3
3
|
// ../shared/src/schemas.ts
|
|
4
4
|
z.object({
|
|
@@ -7,7 +7,8 @@ z.object({
|
|
|
7
7
|
destChain: chain,
|
|
8
8
|
destAsset: asset,
|
|
9
9
|
amount: numericString,
|
|
10
|
-
brokerCommissionBps:
|
|
10
|
+
brokerCommissionBps: numericOrEmptyString.transform((v) => Number(v)).optional(),
|
|
11
|
+
boostFeeBps: numericOrEmptyString.transform((v) => Number(v)).optional()
|
|
11
12
|
});
|
|
12
13
|
var ccmMetadataSchema = z.object({
|
|
13
14
|
gasBudget: numericString,
|
|
@@ -4505,6 +4505,7 @@ var number = z.number({
|
|
|
4505
4505
|
errorMap: errorMap2
|
|
4506
4506
|
});
|
|
4507
4507
|
var numericString = string.regex(/^[0-9]+$/);
|
|
4508
|
+
var numericOrEmptyString = string.regex(/^[0-9]*$/);
|
|
4508
4509
|
var hexString = string.refine((v) => /^0x[0-9a-f]*$/i.test(v));
|
|
4509
4510
|
var hexStringWithMaxByteSize = /* @__PURE__ */ __name((maxByteSize) => hexString.refine((val) => val.length / 2 <= maxByteSize + 1, {
|
|
4510
4511
|
message: `String must be less than or equal to ${maxByteSize} bytes`
|
|
@@ -4580,4 +4581,4 @@ z.union([
|
|
|
4580
4581
|
}))
|
|
4581
4582
|
]);
|
|
4582
4583
|
|
|
4583
|
-
export { Assets, ChainflipNetworks, Chains, InternalAssets, __name, __publicField, assert, asset, assetConstants, btcAddress, chain, chainConstants, dotAddress, ethereumAddress, getInternalAsset, hexString, hexStringFromNumber, hexStringWithMaxByteSize, isNotNullish, isTestnet, isTokenCall, isTokenSwap, numericString, readChainAssetValue, uncheckedAssetAndChain, unsignedInteger, z };
|
|
4584
|
+
export { Assets, ChainflipNetworks, Chains, InternalAssets, __name, __publicField, assert, asset, assetConstants, btcAddress, chain, chainConstants, dotAddress, ethereumAddress, getInternalAsset, hexString, hexStringFromNumber, hexStringWithMaxByteSize, isNotNullish, isTestnet, isTokenCall, isTokenSwap, numericOrEmptyString, numericString, readChainAssetValue, u128, uncheckedAssetAndChain, unsignedInteger, z };
|
package/dist/funding.js
CHANGED
|
@@ -1349,6 +1349,12 @@ __name(isValidAssetAndChain, "isValidAssetAndChain");
|
|
|
1349
1349
|
[ChainflipNetworks.perseverance]: 1e3,
|
|
1350
1350
|
[ChainflipNetworks.mainnet]: 1e3
|
|
1351
1351
|
});
|
|
1352
|
+
({
|
|
1353
|
+
[ChainflipNetworks.backspin]: 10997,
|
|
1354
|
+
[ChainflipNetworks.sisyphos]: 11155111,
|
|
1355
|
+
[ChainflipNetworks.perseverance]: 11155111,
|
|
1356
|
+
[ChainflipNetworks.mainnet]: 1
|
|
1357
|
+
});
|
|
1352
1358
|
var SEPOLIA_USDC_CONTRACT_ADDRESS = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238";
|
|
1353
1359
|
var SEPOLIA_USDT_CONTRACT_ADDRESS = "0x7169D38820dfd117C3FA1f22a697dBA58d90BA06";
|
|
1354
1360
|
var ADDRESSES = {
|
|
@@ -1404,7 +1410,7 @@ var checkAllowance = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20
|
|
|
1404
1410
|
const allowance = await erc20.allowance(signerAddress, spenderAddress);
|
|
1405
1411
|
return {
|
|
1406
1412
|
allowance,
|
|
1407
|
-
|
|
1413
|
+
hasSufficientAllowance: allowance >= amount,
|
|
1408
1414
|
erc20
|
|
1409
1415
|
};
|
|
1410
1416
|
}, "checkAllowance");
|
|
@@ -5278,6 +5284,7 @@ var number = z.number({
|
|
|
5278
5284
|
errorMap: errorMap2
|
|
5279
5285
|
});
|
|
5280
5286
|
var numericString = string.regex(/^[0-9]+$/);
|
|
5287
|
+
string.regex(/^[0-9]*$/);
|
|
5281
5288
|
var hexString = string.refine((v) => /^0x[0-9a-f]*$/i.test(v));
|
|
5282
5289
|
numericString.transform((arg) => `0x${BigInt(arg).toString(16)}`);
|
|
5283
5290
|
var DOT_PREFIX = 0;
|
|
@@ -5358,7 +5365,7 @@ var camelCaseKeys = /* @__PURE__ */ __name((obj) => {
|
|
|
5358
5365
|
var RPC_URLS = {
|
|
5359
5366
|
[ChainflipNetworks.backspin]: "https://backspin-rpc.staging",
|
|
5360
5367
|
[ChainflipNetworks.sisyphos]: "https://archive.sisyphos.chainflip.io",
|
|
5361
|
-
[ChainflipNetworks.perseverance]: "https://perseverance.chainflip.
|
|
5368
|
+
[ChainflipNetworks.perseverance]: "https://archive.perseverance.chainflip.io",
|
|
5362
5369
|
[ChainflipNetworks.mainnet]: "https://mainnet-rpc.chainflip.io"
|
|
5363
5370
|
};
|
|
5364
5371
|
var createRequest = /* @__PURE__ */ __name((method, responseParser) => async (urlOrNetwork, ...params) => {
|
|
@@ -5412,23 +5419,15 @@ var rename = /* @__PURE__ */ __name((mapping) => (obj) => Object.fromEntries(Obj
|
|
|
5412
5419
|
])), "rename");
|
|
5413
5420
|
var ingressEgressEnvironment = z.object({
|
|
5414
5421
|
minimum_deposit_amounts: chainAssetMapFactory(numberOrHex, 0),
|
|
5415
|
-
ingress_fees: chainAssetMapFactory(numberOrHex,
|
|
5416
|
-
egress_fees: chainAssetMapFactory(numberOrHex,
|
|
5422
|
+
ingress_fees: chainAssetMapFactory(numberOrHex.nullable(), null),
|
|
5423
|
+
egress_fees: chainAssetMapFactory(numberOrHex.nullable(), null),
|
|
5417
5424
|
witness_safety_margins: chainNumberNullableMap,
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
ETH: 1,
|
|
5425
|
-
USDC: 1,
|
|
5426
|
-
FLIP: 1,
|
|
5427
|
-
USDT: 1
|
|
5428
|
-
},
|
|
5429
|
-
Polkadot: {
|
|
5430
|
-
DOT: 1
|
|
5431
|
-
}
|
|
5425
|
+
egress_dust_limits: chainAssetMapFactory(numberOrHex, 1),
|
|
5426
|
+
// TODO(1.3): remove optional and default value
|
|
5427
|
+
channel_opening_fees: chainMap(numberOrHex).optional().default({
|
|
5428
|
+
Bitcoin: 0,
|
|
5429
|
+
Ethereum: 0,
|
|
5430
|
+
Polkadot: 0
|
|
5432
5431
|
})
|
|
5433
5432
|
}).transform(rename({
|
|
5434
5433
|
egress_dust_limits: "minimum_egress_amounts"
|
|
@@ -5515,8 +5514,8 @@ var checkStateChainGatewayAllowance = /* @__PURE__ */ __name(async (amount, netw
|
|
|
5515
5514
|
return checkAllowance(amount, stateChainGatewayContractAddress, flipContractAddress, networkOpts.signer);
|
|
5516
5515
|
}, "checkStateChainGatewayAllowance");
|
|
5517
5516
|
var approveStateChainGateway = /* @__PURE__ */ __name(async (amount, networkOpts, txOpts) => {
|
|
5518
|
-
const { allowance, erc20,
|
|
5519
|
-
if (
|
|
5517
|
+
const { allowance, erc20, hasSufficientAllowance } = await checkStateChainGatewayAllowance(amount, networkOpts);
|
|
5518
|
+
if (hasSufficientAllowance)
|
|
5520
5519
|
return null;
|
|
5521
5520
|
const stateChainGatewayContractAddress = networkOpts.network === "localnet" ? networkOpts.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(networkOpts.network);
|
|
5522
5521
|
return approve(amount, stateChainGatewayContractAddress, erc20, allowance, txOpts);
|
|
@@ -5526,8 +5525,8 @@ var approveStateChainGateway = /* @__PURE__ */ __name(async (amount, networkOpts
|
|
|
5526
5525
|
var fundStateChainAccount = /* @__PURE__ */ __name(async (accountId, amount, networkOpts, txOpts) => {
|
|
5527
5526
|
const flipContractAddress = networkOpts.network === "localnet" ? networkOpts.flipContractAddress : getTokenContractAddress(InternalAssets.Flip, networkOpts.network);
|
|
5528
5527
|
const stateChainGateway = getStateChainGateway(networkOpts);
|
|
5529
|
-
const {
|
|
5530
|
-
assert(
|
|
5528
|
+
const { hasSufficientAllowance } = await checkAllowance(amount, await stateChainGateway.getAddress(), flipContractAddress, networkOpts.signer);
|
|
5529
|
+
assert(hasSufficientAllowance, "Insufficient allowance");
|
|
5531
5530
|
const transaction = await stateChainGateway.fundStateChainAccount(accountId, amount, extractOverrides(txOpts));
|
|
5532
5531
|
return transaction.wait(txOpts.wait);
|
|
5533
5532
|
}, "fundStateChainAccount");
|
|
@@ -5558,7 +5557,7 @@ var _FundingSDK = class _FundingSDK {
|
|
|
5558
5557
|
__publicField(this, "redemptionTax");
|
|
5559
5558
|
const network = options.network ?? ChainflipNetworks.perseverance;
|
|
5560
5559
|
this.options = {
|
|
5561
|
-
|
|
5560
|
+
...options,
|
|
5562
5561
|
network
|
|
5563
5562
|
};
|
|
5564
5563
|
this.rpcConfig = options.rpcUrl ? {
|
package/dist/funding.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getFlipBalance, getFundingEnvironment, getStateChainGatewayContractAddress, approve, getTokenContractAddress, checkAllowance, extractOverrides, StateChainGateway__factory } from './chunk-
|
|
2
|
-
import { __name, __publicField, ChainflipNetworks, InternalAssets, assert } from './chunk-
|
|
1
|
+
import { getFlipBalance, getFundingEnvironment, getStateChainGatewayContractAddress, approve, getTokenContractAddress, checkAllowance, extractOverrides, StateChainGateway__factory } from './chunk-I6HKG4VF.mjs';
|
|
2
|
+
import { __name, __publicField, ChainflipNetworks, InternalAssets, assert } from './chunk-KWYZ5QIZ.mjs';
|
|
3
3
|
|
|
4
4
|
// ../shared/src/stateChainGateway/utils.ts
|
|
5
5
|
var getStateChainGateway = /* @__PURE__ */ __name((networkOpts) => {
|
|
@@ -14,8 +14,8 @@ var checkStateChainGatewayAllowance = /* @__PURE__ */ __name(async (amount, netw
|
|
|
14
14
|
return checkAllowance(amount, stateChainGatewayContractAddress, flipContractAddress, networkOpts.signer);
|
|
15
15
|
}, "checkStateChainGatewayAllowance");
|
|
16
16
|
var approveStateChainGateway = /* @__PURE__ */ __name(async (amount, networkOpts, txOpts) => {
|
|
17
|
-
const { allowance, erc20,
|
|
18
|
-
if (
|
|
17
|
+
const { allowance, erc20, hasSufficientAllowance } = await checkStateChainGatewayAllowance(amount, networkOpts);
|
|
18
|
+
if (hasSufficientAllowance)
|
|
19
19
|
return null;
|
|
20
20
|
const stateChainGatewayContractAddress = networkOpts.network === "localnet" ? networkOpts.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(networkOpts.network);
|
|
21
21
|
return approve(amount, stateChainGatewayContractAddress, erc20, allowance, txOpts);
|
|
@@ -25,8 +25,8 @@ var approveStateChainGateway = /* @__PURE__ */ __name(async (amount, networkOpts
|
|
|
25
25
|
var fundStateChainAccount = /* @__PURE__ */ __name(async (accountId, amount, networkOpts, txOpts) => {
|
|
26
26
|
const flipContractAddress = networkOpts.network === "localnet" ? networkOpts.flipContractAddress : getTokenContractAddress(InternalAssets.Flip, networkOpts.network);
|
|
27
27
|
const stateChainGateway = getStateChainGateway(networkOpts);
|
|
28
|
-
const {
|
|
29
|
-
assert(
|
|
28
|
+
const { hasSufficientAllowance } = await checkAllowance(amount, await stateChainGateway.getAddress(), flipContractAddress, networkOpts.signer);
|
|
29
|
+
assert(hasSufficientAllowance, "Insufficient allowance");
|
|
30
30
|
const transaction = await stateChainGateway.fundStateChainAccount(accountId, amount, extractOverrides(txOpts));
|
|
31
31
|
return transaction.wait(txOpts.wait);
|
|
32
32
|
}, "fundStateChainAccount");
|
|
@@ -57,7 +57,7 @@ var _FundingSDK = class _FundingSDK {
|
|
|
57
57
|
__publicField(this, "redemptionTax");
|
|
58
58
|
const network = options.network ?? ChainflipNetworks.perseverance;
|
|
59
59
|
this.options = {
|
|
60
|
-
|
|
60
|
+
...options,
|
|
61
61
|
network
|
|
62
62
|
};
|
|
63
63
|
this.rpcConfig = options.rpcUrl ? {
|
package/dist/swap.d.mts
CHANGED
|
@@ -449,7 +449,7 @@ declare const ccmMetadataSchema: z.ZodObject<{
|
|
|
449
449
|
}>;
|
|
450
450
|
type CcmMetadata = z.infer<typeof ccmMetadataSchema>;
|
|
451
451
|
type SwapFee = {
|
|
452
|
-
type: 'LIQUIDITY' | 'NETWORK' | 'INGRESS' | 'EGRESS' | 'BROKER';
|
|
452
|
+
type: 'LIQUIDITY' | 'NETWORK' | 'INGRESS' | 'EGRESS' | 'BROKER' | 'BOOST';
|
|
453
453
|
chain: Chain;
|
|
454
454
|
asset: Asset;
|
|
455
455
|
amount: string;
|
|
@@ -465,6 +465,7 @@ type QuoteQueryResponse = {
|
|
|
465
465
|
interface ChainData {
|
|
466
466
|
chain: Chain;
|
|
467
467
|
name: string;
|
|
468
|
+
evmChainId: number | undefined;
|
|
468
469
|
isMainnet: boolean;
|
|
469
470
|
requiredBlockConfirmations: number | undefined;
|
|
470
471
|
}
|
|
@@ -491,14 +492,14 @@ interface ChainsAndAssets {
|
|
|
491
492
|
}
|
|
492
493
|
interface QuoteRequest extends ChainsAndAssets {
|
|
493
494
|
amount: string;
|
|
495
|
+
boostFeeBps?: number;
|
|
494
496
|
}
|
|
495
|
-
interface QuoteResponse extends QuoteRequest {
|
|
497
|
+
interface QuoteResponse extends Omit<QuoteRequest, 'boostFeeBps'> {
|
|
496
498
|
quote: QuoteQueryResponse;
|
|
497
499
|
}
|
|
498
500
|
interface DepositAddressRequest extends QuoteRequest {
|
|
499
501
|
destAddress: string;
|
|
500
502
|
ccmMetadata?: CcmMetadata;
|
|
501
|
-
boostFeeBps?: number;
|
|
502
503
|
}
|
|
503
504
|
interface DepositAddressResponse extends DepositAddressRequest {
|
|
504
505
|
depositChannelId: string;
|
|
@@ -506,6 +507,7 @@ interface DepositAddressResponse extends DepositAddressRequest {
|
|
|
506
507
|
brokerCommissionBps: number;
|
|
507
508
|
depositChannelExpiryBlock: bigint;
|
|
508
509
|
estimatedDepositChannelExpiryTime: number | undefined;
|
|
510
|
+
channelOpeningFee: bigint;
|
|
509
511
|
}
|
|
510
512
|
interface SwapStatusRequest {
|
|
511
513
|
id: string;
|
|
@@ -668,8 +670,8 @@ type RequestOptions = {
|
|
|
668
670
|
type TransactionHash = `0x${string}`;
|
|
669
671
|
type SwapSDKOptions = {
|
|
670
672
|
network?: ChainflipNetwork;
|
|
671
|
-
signer?: Signer;
|
|
672
673
|
backendUrl?: string;
|
|
674
|
+
signer?: Signer;
|
|
673
675
|
broker?: {
|
|
674
676
|
url: string;
|
|
675
677
|
commissionBps: number;
|
|
@@ -677,13 +679,10 @@ type SwapSDKOptions = {
|
|
|
677
679
|
rpcUrl?: string;
|
|
678
680
|
};
|
|
679
681
|
declare class SwapSDK {
|
|
680
|
-
private readonly
|
|
681
|
-
private readonly
|
|
682
|
-
private readonly signer?;
|
|
682
|
+
private readonly options;
|
|
683
|
+
private readonly rpcConfig;
|
|
683
684
|
private readonly trpc;
|
|
684
|
-
private readonly brokerConfig?;
|
|
685
685
|
private stateChainEnvironment?;
|
|
686
|
-
private readonly rpcConfig;
|
|
687
686
|
constructor(options?: SwapSDKOptions);
|
|
688
687
|
getChains(sourceChain?: Chain): Promise<ChainData[]>;
|
|
689
688
|
private getStateChainEnvironment;
|
|
@@ -691,14 +690,19 @@ declare class SwapSDK {
|
|
|
691
690
|
getQuote(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponse>;
|
|
692
691
|
requestDepositAddress(depositAddressRequest: DepositAddressRequest): Promise<DepositAddressResponse>;
|
|
693
692
|
getStatus(swapStatusRequest: SwapStatusRequest, options?: RequestOptions): Promise<SwapStatusResponse>;
|
|
694
|
-
executeSwap(params: ExecuteSwapParams, txOpts?: TransactionOptions
|
|
695
|
-
|
|
693
|
+
executeSwap(params: ExecuteSwapParams, txOpts?: TransactionOptions & {
|
|
694
|
+
signer?: Signer;
|
|
695
|
+
}): Promise<TransactionHash>;
|
|
696
|
+
approveVault(params: Pick<TokenSwapParams, 'srcChain' | 'srcAsset' | 'amount'>, txOpts?: TransactionOptions & {
|
|
697
|
+
signer?: Signer;
|
|
698
|
+
}): Promise<TransactionHash | null>;
|
|
696
699
|
private validateSwapAmount;
|
|
697
700
|
getSwapLimits(): Promise<{
|
|
698
701
|
minimumSwapAmounts: ChainAssetMap<bigint>;
|
|
699
702
|
maximumSwapAmounts: ChainAssetMap<bigint | null>;
|
|
700
703
|
}>;
|
|
701
|
-
getRequiredBlockConfirmations(): Promise<ChainMap<number |
|
|
704
|
+
getRequiredBlockConfirmations(): Promise<ChainMap<number | null>>;
|
|
705
|
+
getChannelOpeningFees(): Promise<ChainMap<bigint>>;
|
|
702
706
|
}
|
|
703
707
|
|
|
704
708
|
export { Asset, type AssetData, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type VaultSwapStatusResponse };
|
package/dist/swap.d.ts
CHANGED
|
@@ -449,7 +449,7 @@ declare const ccmMetadataSchema: z.ZodObject<{
|
|
|
449
449
|
}>;
|
|
450
450
|
type CcmMetadata = z.infer<typeof ccmMetadataSchema>;
|
|
451
451
|
type SwapFee = {
|
|
452
|
-
type: 'LIQUIDITY' | 'NETWORK' | 'INGRESS' | 'EGRESS' | 'BROKER';
|
|
452
|
+
type: 'LIQUIDITY' | 'NETWORK' | 'INGRESS' | 'EGRESS' | 'BROKER' | 'BOOST';
|
|
453
453
|
chain: Chain;
|
|
454
454
|
asset: Asset;
|
|
455
455
|
amount: string;
|
|
@@ -465,6 +465,7 @@ type QuoteQueryResponse = {
|
|
|
465
465
|
interface ChainData {
|
|
466
466
|
chain: Chain;
|
|
467
467
|
name: string;
|
|
468
|
+
evmChainId: number | undefined;
|
|
468
469
|
isMainnet: boolean;
|
|
469
470
|
requiredBlockConfirmations: number | undefined;
|
|
470
471
|
}
|
|
@@ -491,14 +492,14 @@ interface ChainsAndAssets {
|
|
|
491
492
|
}
|
|
492
493
|
interface QuoteRequest extends ChainsAndAssets {
|
|
493
494
|
amount: string;
|
|
495
|
+
boostFeeBps?: number;
|
|
494
496
|
}
|
|
495
|
-
interface QuoteResponse extends QuoteRequest {
|
|
497
|
+
interface QuoteResponse extends Omit<QuoteRequest, 'boostFeeBps'> {
|
|
496
498
|
quote: QuoteQueryResponse;
|
|
497
499
|
}
|
|
498
500
|
interface DepositAddressRequest extends QuoteRequest {
|
|
499
501
|
destAddress: string;
|
|
500
502
|
ccmMetadata?: CcmMetadata;
|
|
501
|
-
boostFeeBps?: number;
|
|
502
503
|
}
|
|
503
504
|
interface DepositAddressResponse extends DepositAddressRequest {
|
|
504
505
|
depositChannelId: string;
|
|
@@ -506,6 +507,7 @@ interface DepositAddressResponse extends DepositAddressRequest {
|
|
|
506
507
|
brokerCommissionBps: number;
|
|
507
508
|
depositChannelExpiryBlock: bigint;
|
|
508
509
|
estimatedDepositChannelExpiryTime: number | undefined;
|
|
510
|
+
channelOpeningFee: bigint;
|
|
509
511
|
}
|
|
510
512
|
interface SwapStatusRequest {
|
|
511
513
|
id: string;
|
|
@@ -668,8 +670,8 @@ type RequestOptions = {
|
|
|
668
670
|
type TransactionHash = `0x${string}`;
|
|
669
671
|
type SwapSDKOptions = {
|
|
670
672
|
network?: ChainflipNetwork;
|
|
671
|
-
signer?: Signer;
|
|
672
673
|
backendUrl?: string;
|
|
674
|
+
signer?: Signer;
|
|
673
675
|
broker?: {
|
|
674
676
|
url: string;
|
|
675
677
|
commissionBps: number;
|
|
@@ -677,13 +679,10 @@ type SwapSDKOptions = {
|
|
|
677
679
|
rpcUrl?: string;
|
|
678
680
|
};
|
|
679
681
|
declare class SwapSDK {
|
|
680
|
-
private readonly
|
|
681
|
-
private readonly
|
|
682
|
-
private readonly signer?;
|
|
682
|
+
private readonly options;
|
|
683
|
+
private readonly rpcConfig;
|
|
683
684
|
private readonly trpc;
|
|
684
|
-
private readonly brokerConfig?;
|
|
685
685
|
private stateChainEnvironment?;
|
|
686
|
-
private readonly rpcConfig;
|
|
687
686
|
constructor(options?: SwapSDKOptions);
|
|
688
687
|
getChains(sourceChain?: Chain): Promise<ChainData[]>;
|
|
689
688
|
private getStateChainEnvironment;
|
|
@@ -691,14 +690,19 @@ declare class SwapSDK {
|
|
|
691
690
|
getQuote(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponse>;
|
|
692
691
|
requestDepositAddress(depositAddressRequest: DepositAddressRequest): Promise<DepositAddressResponse>;
|
|
693
692
|
getStatus(swapStatusRequest: SwapStatusRequest, options?: RequestOptions): Promise<SwapStatusResponse>;
|
|
694
|
-
executeSwap(params: ExecuteSwapParams, txOpts?: TransactionOptions
|
|
695
|
-
|
|
693
|
+
executeSwap(params: ExecuteSwapParams, txOpts?: TransactionOptions & {
|
|
694
|
+
signer?: Signer;
|
|
695
|
+
}): Promise<TransactionHash>;
|
|
696
|
+
approveVault(params: Pick<TokenSwapParams, 'srcChain' | 'srcAsset' | 'amount'>, txOpts?: TransactionOptions & {
|
|
697
|
+
signer?: Signer;
|
|
698
|
+
}): Promise<TransactionHash | null>;
|
|
696
699
|
private validateSwapAmount;
|
|
697
700
|
getSwapLimits(): Promise<{
|
|
698
701
|
minimumSwapAmounts: ChainAssetMap<bigint>;
|
|
699
702
|
maximumSwapAmounts: ChainAssetMap<bigint | null>;
|
|
700
703
|
}>;
|
|
701
|
-
getRequiredBlockConfirmations(): Promise<ChainMap<number |
|
|
704
|
+
getRequiredBlockConfirmations(): Promise<ChainMap<number | null>>;
|
|
705
|
+
getChannelOpeningFees(): Promise<ChainMap<bigint>>;
|
|
702
706
|
}
|
|
703
707
|
|
|
704
708
|
export { Asset, type AssetData, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type VaultSwapStatusResponse };
|
package/dist/swap.js
CHANGED
|
@@ -4545,7 +4545,7 @@ var init_addressValidation = __esm({
|
|
|
4545
4545
|
validateBitcoinRegtestAddress = /* @__PURE__ */ __name((address) => validateBitcoinAddress(address, "regtest"), "validateBitcoinRegtestAddress");
|
|
4546
4546
|
}
|
|
4547
4547
|
});
|
|
4548
|
-
var enumValues, safeStringify, errorMap2, string, number, numericString, hexString, hexStringWithMaxByteSize, hexStringFromNumber, btcAddress, DOT_PREFIX, dotAddress, ethereumAddress, u128, unsignedInteger, rustEnum, chain, asset, uncheckedAssetAndChain;
|
|
4548
|
+
var enumValues, safeStringify, errorMap2, string, number, numericString, numericOrEmptyString, hexString, hexStringWithMaxByteSize, hexStringFromNumber, btcAddress, DOT_PREFIX, dotAddress, ethereumAddress, u128, unsignedInteger, rustEnum, chain, asset, uncheckedAssetAndChain;
|
|
4549
4549
|
var init_parsers = __esm({
|
|
4550
4550
|
"../shared/src/parsers.ts"() {
|
|
4551
4551
|
init_lib();
|
|
@@ -4564,6 +4564,7 @@ var init_parsers = __esm({
|
|
|
4564
4564
|
errorMap: errorMap2
|
|
4565
4565
|
});
|
|
4566
4566
|
numericString = string.regex(/^[0-9]+$/);
|
|
4567
|
+
numericOrEmptyString = string.regex(/^[0-9]*$/);
|
|
4567
4568
|
hexString = string.refine((v) => /^0x[0-9a-f]*$/i.test(v));
|
|
4568
4569
|
hexStringWithMaxByteSize = /* @__PURE__ */ __name((maxByteSize) => hexString.refine((val) => val.length / 2 <= maxByteSize + 1, {
|
|
4569
4570
|
message: `String must be less than or equal to ${maxByteSize} bytes`
|
|
@@ -4653,7 +4654,8 @@ var init_schemas = __esm({
|
|
|
4653
4654
|
destChain: chain,
|
|
4654
4655
|
destAsset: asset,
|
|
4655
4656
|
amount: numericString,
|
|
4656
|
-
brokerCommissionBps:
|
|
4657
|
+
brokerCommissionBps: numericOrEmptyString.transform((v) => Number(v)).optional(),
|
|
4658
|
+
boostFeeBps: numericOrEmptyString.transform((v) => Number(v)).optional()
|
|
4657
4659
|
});
|
|
4658
4660
|
ccmMetadataSchema = z.object({
|
|
4659
4661
|
gasBudget: numericString,
|
|
@@ -4775,12 +4777,14 @@ var init_broker = __esm({
|
|
|
4775
4777
|
issued_block: z.number(),
|
|
4776
4778
|
channel_id: z.number(),
|
|
4777
4779
|
expiry_block: z.number().int().safe().positive().optional(),
|
|
4778
|
-
source_chain_expiry_block: unsignedInteger.optional()
|
|
4779
|
-
|
|
4780
|
+
source_chain_expiry_block: unsignedInteger.optional(),
|
|
4781
|
+
channel_opening_fee: u128.optional().default(0)
|
|
4782
|
+
}).transform(({ address, issued_block, channel_id, source_chain_expiry_block, channel_opening_fee }) => ({
|
|
4780
4783
|
address,
|
|
4781
4784
|
issuedBlock: issued_block,
|
|
4782
4785
|
channelId: BigInt(channel_id),
|
|
4783
|
-
sourceChainExpiryBlock: source_chain_expiry_block
|
|
4786
|
+
sourceChainExpiryBlock: source_chain_expiry_block,
|
|
4787
|
+
channelOpeningFee: channel_opening_fee
|
|
4784
4788
|
}))
|
|
4785
4789
|
}), "responseValidators");
|
|
4786
4790
|
makeRpcRequest = /* @__PURE__ */ __name(async (network, url, method, ...params) => {
|
|
@@ -4800,7 +4804,7 @@ var init_broker = __esm({
|
|
|
4800
4804
|
}
|
|
4801
4805
|
});
|
|
4802
4806
|
|
|
4803
|
-
// ../../node_modules/.pnpm/@trpc+server@10.45.
|
|
4807
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/observable-ade1bad8.mjs
|
|
4804
4808
|
function identity(x) {
|
|
4805
4809
|
return x;
|
|
4806
4810
|
}
|
|
@@ -4879,7 +4883,7 @@ function observable(subscribe) {
|
|
|
4879
4883
|
}
|
|
4880
4884
|
__name(observable, "observable");
|
|
4881
4885
|
|
|
4882
|
-
// ../../node_modules/.pnpm/@trpc+server@10.45.
|
|
4886
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/observable/index.mjs
|
|
4883
4887
|
function share(_opts) {
|
|
4884
4888
|
return (originalObserver) => {
|
|
4885
4889
|
let refCount = 0;
|
|
@@ -4984,7 +4988,7 @@ function observableToPromise(observable2) {
|
|
|
4984
4988
|
}
|
|
4985
4989
|
__name(observableToPromise, "observableToPromise");
|
|
4986
4990
|
|
|
4987
|
-
// ../../node_modules/.pnpm/@trpc+client@10.45.
|
|
4991
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/splitLink-4c75f7be.mjs
|
|
4988
4992
|
function createChain(opts) {
|
|
4989
4993
|
return observable((observer) => {
|
|
4990
4994
|
function execute(index = 0, op = opts.op) {
|
|
@@ -5008,7 +5012,7 @@ function createChain(opts) {
|
|
|
5008
5012
|
}
|
|
5009
5013
|
__name(createChain, "createChain");
|
|
5010
5014
|
|
|
5011
|
-
// ../../node_modules/.pnpm/@trpc+server@10.45.
|
|
5015
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/codes-c924c3db.mjs
|
|
5012
5016
|
function invert(obj) {
|
|
5013
5017
|
const newObj = /* @__PURE__ */ Object.create(null);
|
|
5014
5018
|
for (const key in obj) {
|
|
@@ -5046,7 +5050,7 @@ var TRPC_ERROR_CODES_BY_KEY = {
|
|
|
5046
5050
|
};
|
|
5047
5051
|
invert(TRPC_ERROR_CODES_BY_KEY);
|
|
5048
5052
|
|
|
5049
|
-
// ../../node_modules/.pnpm/@trpc+server@10.45.
|
|
5053
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/index-f91d720c.mjs
|
|
5050
5054
|
invert(TRPC_ERROR_CODES_BY_KEY);
|
|
5051
5055
|
var noop = /* @__PURE__ */ __name(() => {
|
|
5052
5056
|
}, "noop");
|
|
@@ -5084,7 +5088,7 @@ var createFlatProxy = /* @__PURE__ */ __name((callback) => {
|
|
|
5084
5088
|
});
|
|
5085
5089
|
}, "createFlatProxy");
|
|
5086
5090
|
|
|
5087
|
-
// ../../node_modules/.pnpm/@trpc+server@10.45.
|
|
5091
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/getCauseFromUnknown-2d66414a.mjs
|
|
5088
5092
|
function isObject(value) {
|
|
5089
5093
|
return !!value && !Array.isArray(value) && typeof value === "object";
|
|
5090
5094
|
}
|
|
@@ -5115,7 +5119,7 @@ function getCauseFromUnknown(cause) {
|
|
|
5115
5119
|
}
|
|
5116
5120
|
__name(getCauseFromUnknown, "getCauseFromUnknown");
|
|
5117
5121
|
|
|
5118
|
-
// ../../node_modules/.pnpm/@trpc+client@10.45.
|
|
5122
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/transformResult-ace864b8.mjs
|
|
5119
5123
|
function isObject2(value) {
|
|
5120
5124
|
return !!value && !Array.isArray(value) && typeof value === "object";
|
|
5121
5125
|
}
|
|
@@ -5168,7 +5172,7 @@ function transformResult(response, runtime) {
|
|
|
5168
5172
|
}
|
|
5169
5173
|
__name(transformResult, "transformResult");
|
|
5170
5174
|
|
|
5171
|
-
// ../../node_modules/.pnpm/@trpc+client@10.45.
|
|
5175
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/TRPCClientError-38f9a32a.mjs
|
|
5172
5176
|
function isTRPCClientError(cause) {
|
|
5173
5177
|
return cause instanceof TRPCClientError || /**
|
|
5174
5178
|
* @deprecated
|
|
@@ -5226,7 +5230,7 @@ var _TRPCClientError = class _TRPCClientError extends Error {
|
|
|
5226
5230
|
__name(_TRPCClientError, "TRPCClientError");
|
|
5227
5231
|
var TRPCClientError = _TRPCClientError;
|
|
5228
5232
|
|
|
5229
|
-
// ../../node_modules/.pnpm/@trpc+client@10.45.
|
|
5233
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/httpUtils-b9d0cb48.mjs
|
|
5230
5234
|
var isFunction = /* @__PURE__ */ __name((fn) => typeof fn === "function", "isFunction");
|
|
5231
5235
|
function getFetch(customFetchImpl) {
|
|
5232
5236
|
if (customFetchImpl) {
|
|
@@ -5370,7 +5374,7 @@ function httpRequest(opts) {
|
|
|
5370
5374
|
}
|
|
5371
5375
|
__name(httpRequest, "httpRequest");
|
|
5372
5376
|
|
|
5373
|
-
// ../../node_modules/.pnpm/@trpc+client@10.45.
|
|
5377
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/httpBatchLink-d0f9eac9.mjs
|
|
5374
5378
|
var throwFatalError = /* @__PURE__ */ __name(() => {
|
|
5375
5379
|
throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new");
|
|
5376
5380
|
}, "throwFatalError");
|
|
@@ -5600,7 +5604,7 @@ var batchRequester = /* @__PURE__ */ __name((requesterOpts) => {
|
|
|
5600
5604
|
}, "batchRequester");
|
|
5601
5605
|
var httpBatchLink = createHTTPBatchLink(batchRequester);
|
|
5602
5606
|
|
|
5603
|
-
// ../../node_modules/.pnpm/@trpc+client@10.45.
|
|
5607
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/links/httpLink.mjs
|
|
5604
5608
|
function httpLinkFactory(factoryOpts) {
|
|
5605
5609
|
return (opts) => {
|
|
5606
5610
|
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
|
@@ -5652,7 +5656,7 @@ function httpLinkFactory(factoryOpts) {
|
|
|
5652
5656
|
}
|
|
5653
5657
|
__name(httpLinkFactory, "httpLinkFactory");
|
|
5654
5658
|
|
|
5655
|
-
// ../../node_modules/.pnpm/@trpc+client@10.45.
|
|
5659
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/index.mjs
|
|
5656
5660
|
var _TRPCUntypedClient = class _TRPCUntypedClient {
|
|
5657
5661
|
$request({ type, input, path, context = {} }) {
|
|
5658
5662
|
const chain$ = createChain({
|
|
@@ -7024,7 +7028,7 @@ var camelCaseKeys = /* @__PURE__ */ __name((obj) => {
|
|
|
7024
7028
|
var RPC_URLS = {
|
|
7025
7029
|
[exports.ChainflipNetworks.backspin]: "https://backspin-rpc.staging",
|
|
7026
7030
|
[exports.ChainflipNetworks.sisyphos]: "https://archive.sisyphos.chainflip.io",
|
|
7027
|
-
[exports.ChainflipNetworks.perseverance]: "https://perseverance.chainflip.
|
|
7031
|
+
[exports.ChainflipNetworks.perseverance]: "https://archive.perseverance.chainflip.io",
|
|
7028
7032
|
[exports.ChainflipNetworks.mainnet]: "https://mainnet-rpc.chainflip.io"
|
|
7029
7033
|
};
|
|
7030
7034
|
var createRequest = /* @__PURE__ */ __name((method, responseParser) => async (urlOrNetwork, ...params) => {
|
|
@@ -7078,23 +7082,15 @@ var rename = /* @__PURE__ */ __name((mapping) => (obj) => Object.fromEntries(Obj
|
|
|
7078
7082
|
])), "rename");
|
|
7079
7083
|
var ingressEgressEnvironment = z.object({
|
|
7080
7084
|
minimum_deposit_amounts: chainAssetMapFactory(numberOrHex, 0),
|
|
7081
|
-
ingress_fees: chainAssetMapFactory(numberOrHex,
|
|
7082
|
-
egress_fees: chainAssetMapFactory(numberOrHex,
|
|
7085
|
+
ingress_fees: chainAssetMapFactory(numberOrHex.nullable(), null),
|
|
7086
|
+
egress_fees: chainAssetMapFactory(numberOrHex.nullable(), null),
|
|
7083
7087
|
witness_safety_margins: chainNumberNullableMap,
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
ETH: 1,
|
|
7091
|
-
USDC: 1,
|
|
7092
|
-
FLIP: 1,
|
|
7093
|
-
USDT: 1
|
|
7094
|
-
},
|
|
7095
|
-
Polkadot: {
|
|
7096
|
-
DOT: 1
|
|
7097
|
-
}
|
|
7088
|
+
egress_dust_limits: chainAssetMapFactory(numberOrHex, 1),
|
|
7089
|
+
// TODO(1.3): remove optional and default value
|
|
7090
|
+
channel_opening_fees: chainMap(numberOrHex).optional().default({
|
|
7091
|
+
Bitcoin: 0,
|
|
7092
|
+
Ethereum: 0,
|
|
7093
|
+
Polkadot: 0
|
|
7098
7094
|
})
|
|
7099
7095
|
}).transform(rename({
|
|
7100
7096
|
egress_dust_limits: "minimum_egress_amounts"
|
|
@@ -8605,6 +8601,18 @@ init_enums();
|
|
|
8605
8601
|
[exports.ChainflipNetworks.perseverance]: 1e3,
|
|
8606
8602
|
[exports.ChainflipNetworks.mainnet]: 1e3
|
|
8607
8603
|
});
|
|
8604
|
+
var ETHEREUM_EVM_CHAIN_ID = {
|
|
8605
|
+
[exports.ChainflipNetworks.backspin]: 10997,
|
|
8606
|
+
[exports.ChainflipNetworks.sisyphos]: 11155111,
|
|
8607
|
+
[exports.ChainflipNetworks.perseverance]: 11155111,
|
|
8608
|
+
[exports.ChainflipNetworks.mainnet]: 1
|
|
8609
|
+
};
|
|
8610
|
+
var getEvmChainId = /* @__PURE__ */ __name((chain2, network) => {
|
|
8611
|
+
if (chain2 === exports.Chains.Ethereum) {
|
|
8612
|
+
return ETHEREUM_EVM_CHAIN_ID[network];
|
|
8613
|
+
}
|
|
8614
|
+
return void 0;
|
|
8615
|
+
}, "getEvmChainId");
|
|
8608
8616
|
var SEPOLIA_USDC_CONTRACT_ADDRESS = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238";
|
|
8609
8617
|
var SEPOLIA_USDT_CONTRACT_ADDRESS = "0x7169D38820dfd117C3FA1f22a697dBA58d90BA06";
|
|
8610
8618
|
var ADDRESSES = {
|
|
@@ -8660,7 +8668,7 @@ var checkAllowance = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20
|
|
|
8660
8668
|
const allowance = await erc20.allowance(signerAddress, spenderAddress);
|
|
8661
8669
|
return {
|
|
8662
8670
|
allowance,
|
|
8663
|
-
|
|
8671
|
+
hasSufficientAllowance: allowance >= amount,
|
|
8664
8672
|
erc20
|
|
8665
8673
|
};
|
|
8666
8674
|
}, "checkAllowance");
|
|
@@ -8675,6 +8683,20 @@ var getVaultManagerContractAddress = /* @__PURE__ */ __name((network) => ADDRESS
|
|
|
8675
8683
|
// ../shared/src/vault/executeSwap.ts
|
|
8676
8684
|
init_enums();
|
|
8677
8685
|
init_guards();
|
|
8686
|
+
|
|
8687
|
+
// ../shared/src/signer.ts
|
|
8688
|
+
init_guards();
|
|
8689
|
+
var assertSignerIsConnectedToChain = /* @__PURE__ */ __name(async (opts, chain2) => {
|
|
8690
|
+
if (opts.network === "localnet")
|
|
8691
|
+
return;
|
|
8692
|
+
assert(opts.signer.provider, "Signer has no provider");
|
|
8693
|
+
const sourceChainId = getEvmChainId(chain2, opts.network);
|
|
8694
|
+
assert(sourceChainId, `Chain ${chain2} has no evm chain id`);
|
|
8695
|
+
const { chainId: signerChainId } = await opts.signer.provider.getNetwork();
|
|
8696
|
+
assert(signerChainId === BigInt(sourceChainId), `Signer is connected to unexpected evm chain (expected: ${sourceChainId}, got: ${signerChainId})`);
|
|
8697
|
+
}, "assertSignerIsConnectedToChain");
|
|
8698
|
+
|
|
8699
|
+
// ../shared/src/vault/executeSwap.ts
|
|
8678
8700
|
var swapNative = /* @__PURE__ */ __name(async ({ destChain, destAsset, destAddress, amount }, networkOpts, txOpts) => {
|
|
8679
8701
|
const internalDestAsset = getInternalAsset({
|
|
8680
8702
|
chain: destChain,
|
|
@@ -8700,8 +8722,8 @@ var swapToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
8700
8722
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
8701
8723
|
const erc20Address = networkOpts.network === "localnet" ? networkOpts.srcTokenContractAddress : getTokenContractAddress(internalSrcAsset, networkOpts.network);
|
|
8702
8724
|
assert(erc20Address !== void 0, "Missing ERC20 contract address");
|
|
8703
|
-
const {
|
|
8704
|
-
assert(
|
|
8725
|
+
const { hasSufficientAllowance } = await checkAllowance(BigInt(params.amount), vaultContractAddress, erc20Address, networkOpts.signer);
|
|
8726
|
+
assert(hasSufficientAllowance, "Swap amount exceeds allowance");
|
|
8705
8727
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
8706
8728
|
const transaction = await vault.xSwapToken(chainConstants[params.destChain].contractId, params.destAddress, assetConstants[internalDestAsset].contractId, erc20Address, params.amount, "0x", extractOverrides(txOpts));
|
|
8707
8729
|
return transaction.wait(txOpts.wait);
|
|
@@ -8731,13 +8753,14 @@ var callToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
8731
8753
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
8732
8754
|
const erc20Address = networkOpts.network === "localnet" ? networkOpts.srcTokenContractAddress : getTokenContractAddress(internalSrcAsset, networkOpts.network);
|
|
8733
8755
|
assert(erc20Address !== void 0, "Missing ERC20 contract address");
|
|
8734
|
-
const {
|
|
8735
|
-
assert(
|
|
8756
|
+
const { hasSufficientAllowance } = await checkAllowance(BigInt(params.amount), vaultContractAddress, erc20Address, networkOpts.signer);
|
|
8757
|
+
assert(hasSufficientAllowance, "Swap amount exceeds allowance");
|
|
8736
8758
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
8737
8759
|
const transaction = await vault.xCallToken(chainConstants[params.destChain].contractId, params.destAddress, assetConstants[internalDestAsset].contractId, params.ccmMetadata.message, params.ccmMetadata.gasBudget, erc20Address, params.amount, "0x", extractOverrides(txOpts));
|
|
8738
8760
|
return transaction.wait(txOpts.wait);
|
|
8739
8761
|
}, "callToken");
|
|
8740
8762
|
var executeSwap = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
8763
|
+
await assertSignerIsConnectedToChain(networkOpts, params.srcChain);
|
|
8741
8764
|
const network = networkOpts.network === "localnet" ? "backspin" : networkOpts.network;
|
|
8742
8765
|
const parsedParams = executeSwapParamsSchema(network).parse(params);
|
|
8743
8766
|
if ("ccmMetadata" in parsedParams) {
|
|
@@ -8760,8 +8783,9 @@ var checkVaultAllowance = /* @__PURE__ */ __name((params, networkOpts) => {
|
|
|
8760
8783
|
return checkAllowance(BigInt(params.amount), vaultContractAddress, erc20Address, networkOpts.signer);
|
|
8761
8784
|
}, "checkVaultAllowance");
|
|
8762
8785
|
var approveVault = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
8763
|
-
|
|
8764
|
-
|
|
8786
|
+
await assertSignerIsConnectedToChain(networkOpts, params.srcChain);
|
|
8787
|
+
const { hasSufficientAllowance, erc20, allowance } = await checkVaultAllowance(params, networkOpts);
|
|
8788
|
+
if (hasSufficientAllowance)
|
|
8765
8789
|
return null;
|
|
8766
8790
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
8767
8791
|
return approve(BigInt(params.amount), vaultContractAddress, erc20, allowance, txOpts);
|
|
@@ -8810,9 +8834,10 @@ init_enums();
|
|
|
8810
8834
|
init_guards();
|
|
8811
8835
|
var chainFactory = /* @__PURE__ */ __name((chain2) => (network, env) => ({
|
|
8812
8836
|
chain: chain2,
|
|
8813
|
-
name:
|
|
8837
|
+
name: chain2,
|
|
8838
|
+
evmChainId: getEvmChainId(chain2, network),
|
|
8814
8839
|
isMainnet: !isTestnet(network),
|
|
8815
|
-
requiredBlockConfirmations: isNotNullish(env.ingressEgress.witnessSafetyMargins[
|
|
8840
|
+
requiredBlockConfirmations: isNotNullish(env.ingressEgress.witnessSafetyMargins[chain2]) ? Number(env.ingressEgress.witnessSafetyMargins[chain2]) + 1 : void 0
|
|
8816
8841
|
}), "chainFactory");
|
|
8817
8842
|
var ethereum = chainFactory(exports.Chains.Ethereum);
|
|
8818
8843
|
var polkadot = chainFactory(exports.Chains.Polkadot);
|
|
@@ -8872,7 +8897,7 @@ var getAssets = /* @__PURE__ */ __name(async (chain2, network, env) => {
|
|
|
8872
8897
|
throw new Error("received unexpected chain");
|
|
8873
8898
|
}, "getAssets");
|
|
8874
8899
|
var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal }) => {
|
|
8875
|
-
const { brokerCommissionBps, ...returnedRequestData } = quoteRequest;
|
|
8900
|
+
const { brokerCommissionBps, boostFeeBps, ...returnedRequestData } = quoteRequest;
|
|
8876
8901
|
const params = {
|
|
8877
8902
|
amount: returnedRequestData.amount,
|
|
8878
8903
|
srcChain: returnedRequestData.srcChain,
|
|
@@ -8881,6 +8906,9 @@ var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal })
|
|
|
8881
8906
|
destAsset: returnedRequestData.destAsset,
|
|
8882
8907
|
...brokerCommissionBps && {
|
|
8883
8908
|
brokerCommissionBps: String(brokerCommissionBps)
|
|
8909
|
+
},
|
|
8910
|
+
...boostFeeBps && {
|
|
8911
|
+
boostFeeBps: String(boostFeeBps)
|
|
8884
8912
|
}
|
|
8885
8913
|
};
|
|
8886
8914
|
const queryParams = new URLSearchParams(params);
|
|
@@ -8911,37 +8939,36 @@ var ApiService_default = {
|
|
|
8911
8939
|
// src/swap/sdk.ts
|
|
8912
8940
|
var _SwapSDK = class _SwapSDK {
|
|
8913
8941
|
constructor(options = {}) {
|
|
8914
|
-
__publicField(this, "
|
|
8915
|
-
__publicField(this, "
|
|
8916
|
-
__publicField(this, "signer");
|
|
8942
|
+
__publicField(this, "options");
|
|
8943
|
+
__publicField(this, "rpcConfig");
|
|
8917
8944
|
__publicField(this, "trpc");
|
|
8918
|
-
__publicField(this, "brokerConfig");
|
|
8919
8945
|
__publicField(this, "stateChainEnvironment");
|
|
8920
|
-
|
|
8921
|
-
this.
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
|
|
8946
|
+
const network = options.network ?? exports.ChainflipNetworks.perseverance;
|
|
8947
|
+
this.options = {
|
|
8948
|
+
...options,
|
|
8949
|
+
network,
|
|
8950
|
+
backendUrl: options.backendUrl ?? BACKEND_SERVICE_URLS[network]
|
|
8951
|
+
};
|
|
8952
|
+
this.rpcConfig = options.rpcUrl ? {
|
|
8953
|
+
rpcUrl: options.rpcUrl
|
|
8954
|
+
} : {
|
|
8955
|
+
network
|
|
8956
|
+
};
|
|
8925
8957
|
this.trpc = createTRPCProxyClient({
|
|
8926
8958
|
transformer: esm_default,
|
|
8927
8959
|
links: [
|
|
8928
8960
|
httpBatchLink({
|
|
8929
|
-
url: new URL("/trpc", this.
|
|
8961
|
+
url: new URL("/trpc", this.options.backendUrl)
|
|
8930
8962
|
})
|
|
8931
8963
|
]
|
|
8932
8964
|
});
|
|
8933
|
-
this.rpcConfig = options.rpcUrl ? {
|
|
8934
|
-
rpcUrl: options.rpcUrl
|
|
8935
|
-
} : {
|
|
8936
|
-
network: this.network
|
|
8937
|
-
};
|
|
8938
8965
|
}
|
|
8939
8966
|
async getChains(sourceChain) {
|
|
8940
8967
|
const env = await this.getStateChainEnvironment();
|
|
8941
8968
|
if (sourceChain !== void 0) {
|
|
8942
|
-
return ApiService_default.getPossibleDestinationChains(sourceChain, this.network, env);
|
|
8969
|
+
return ApiService_default.getPossibleDestinationChains(sourceChain, this.options.network, env);
|
|
8943
8970
|
}
|
|
8944
|
-
return ApiService_default.getChains(this.network, env);
|
|
8971
|
+
return ApiService_default.getChains(this.options.network, env);
|
|
8945
8972
|
}
|
|
8946
8973
|
async getStateChainEnvironment() {
|
|
8947
8974
|
this.stateChainEnvironment ?? (this.stateChainEnvironment = await getEnvironment(this.rpcConfig));
|
|
@@ -8949,12 +8976,12 @@ var _SwapSDK = class _SwapSDK {
|
|
|
8949
8976
|
}
|
|
8950
8977
|
async getAssets(chain2) {
|
|
8951
8978
|
const env = await this.getStateChainEnvironment();
|
|
8952
|
-
return ApiService_default.getAssets(chain2, this.network, env);
|
|
8979
|
+
return ApiService_default.getAssets(chain2, this.options.network, env);
|
|
8953
8980
|
}
|
|
8954
8981
|
getQuote(quoteRequest, options = {}) {
|
|
8955
|
-
return ApiService_default.getQuote(this.
|
|
8982
|
+
return ApiService_default.getQuote(this.options.backendUrl, {
|
|
8956
8983
|
...quoteRequest,
|
|
8957
|
-
brokerCommissionBps: this.
|
|
8984
|
+
brokerCommissionBps: this.options.broker?.commissionBps
|
|
8958
8985
|
}, options);
|
|
8959
8986
|
}
|
|
8960
8987
|
async requestDepositAddress(depositAddressRequest) {
|
|
@@ -8964,15 +8991,16 @@ var _SwapSDK = class _SwapSDK {
|
|
|
8964
8991
|
asset: srcAsset
|
|
8965
8992
|
}, BigInt(amount));
|
|
8966
8993
|
let response;
|
|
8967
|
-
if (this.
|
|
8994
|
+
if (this.options.broker !== void 0) {
|
|
8968
8995
|
const { requestSwapDepositAddress: requestSwapDepositAddress2 } = await Promise.resolve().then(() => (init_broker(), broker_exports));
|
|
8969
|
-
const result = await requestSwapDepositAddress2(depositAddressRequest, this.
|
|
8996
|
+
const result = await requestSwapDepositAddress2(depositAddressRequest, this.options.broker, this.options.network);
|
|
8970
8997
|
response = {
|
|
8971
8998
|
id: `${result.issuedBlock}-${depositAddressRequest.srcChain}-${result.channelId}`,
|
|
8972
8999
|
depositAddress: result.address,
|
|
8973
|
-
brokerCommissionBps: this.
|
|
9000
|
+
brokerCommissionBps: this.options.broker.commissionBps,
|
|
8974
9001
|
srcChainExpiryBlock: result.sourceChainExpiryBlock,
|
|
8975
|
-
boostFeeBps: depositAddressRequest.boostFeeBps
|
|
9002
|
+
boostFeeBps: depositAddressRequest.boostFeeBps,
|
|
9003
|
+
channelOpeningFee: result.channelOpeningFee
|
|
8976
9004
|
};
|
|
8977
9005
|
} else {
|
|
8978
9006
|
response = await this.trpc.openSwapDepositChannel.mutate(depositAddressRequest);
|
|
@@ -8984,33 +9012,36 @@ var _SwapSDK = class _SwapSDK {
|
|
|
8984
9012
|
brokerCommissionBps: response.brokerCommissionBps,
|
|
8985
9013
|
boostFeeBps: Number(response.boostFeeBps) || 0,
|
|
8986
9014
|
depositChannelExpiryBlock: response.srcChainExpiryBlock,
|
|
8987
|
-
estimatedDepositChannelExpiryTime: response.estimatedExpiryTime
|
|
9015
|
+
estimatedDepositChannelExpiryTime: response.estimatedExpiryTime,
|
|
9016
|
+
channelOpeningFee: response.channelOpeningFee
|
|
8988
9017
|
};
|
|
8989
9018
|
}
|
|
8990
9019
|
getStatus(swapStatusRequest, options = {}) {
|
|
8991
|
-
return ApiService_default.getStatus(this.
|
|
9020
|
+
return ApiService_default.getStatus(this.options.backendUrl, swapStatusRequest, options);
|
|
8992
9021
|
}
|
|
8993
9022
|
async executeSwap(params, txOpts = {}) {
|
|
8994
9023
|
const { srcChain, srcAsset, amount } = params;
|
|
9024
|
+
const { signer: optsSigner, ...remainingTxOpts } = txOpts;
|
|
9025
|
+
const signer = optsSigner ?? this.options.signer;
|
|
9026
|
+
assert(signer, "No signer provided");
|
|
8995
9027
|
await this.validateSwapAmount({
|
|
8996
9028
|
chain: srcChain,
|
|
8997
9029
|
asset: srcAsset
|
|
8998
9030
|
}, BigInt(amount));
|
|
8999
|
-
assert(this.signer, "No signer provided");
|
|
9000
9031
|
const receipt = await executeSwap_default(params, {
|
|
9001
|
-
network: this.network,
|
|
9002
|
-
signer
|
|
9003
|
-
},
|
|
9032
|
+
network: this.options.network,
|
|
9033
|
+
signer
|
|
9034
|
+
}, remainingTxOpts);
|
|
9004
9035
|
return receipt.hash;
|
|
9005
9036
|
}
|
|
9006
9037
|
async approveVault(params, txOpts = {}) {
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
assert(
|
|
9038
|
+
const { signer: optsSigner, ...remainingTxOpts } = txOpts;
|
|
9039
|
+
const signer = optsSigner ?? this.options.signer;
|
|
9040
|
+
assert(signer, "No signer provided");
|
|
9010
9041
|
const receipt = await approveVault(params, {
|
|
9011
|
-
signer
|
|
9012
|
-
network: this.network
|
|
9013
|
-
},
|
|
9042
|
+
signer,
|
|
9043
|
+
network: this.options.network
|
|
9044
|
+
}, remainingTxOpts);
|
|
9014
9045
|
return receipt ? receipt.hash : null;
|
|
9015
9046
|
}
|
|
9016
9047
|
async validateSwapAmount(asset2, amount) {
|
|
@@ -9029,10 +9060,14 @@ var _SwapSDK = class _SwapSDK {
|
|
|
9029
9060
|
async getRequiredBlockConfirmations() {
|
|
9030
9061
|
const { ingressEgress: { witnessSafetyMargins } } = await this.getStateChainEnvironment();
|
|
9031
9062
|
return Object.keys(exports.Chains).reduce((acc, chain2) => {
|
|
9032
|
-
acc[chain2] = witnessSafetyMargins[chain2] ? Number(witnessSafetyMargins[chain2]) + 1 :
|
|
9063
|
+
acc[chain2] = witnessSafetyMargins[chain2] ? Number(witnessSafetyMargins[chain2]) + 1 : null;
|
|
9033
9064
|
return acc;
|
|
9034
9065
|
}, {});
|
|
9035
9066
|
}
|
|
9067
|
+
async getChannelOpeningFees() {
|
|
9068
|
+
const { ingressEgress: { channelOpeningFees } } = await this.getStateChainEnvironment();
|
|
9069
|
+
return channelOpeningFees;
|
|
9070
|
+
}
|
|
9036
9071
|
};
|
|
9037
9072
|
__name(_SwapSDK, "SwapSDK");
|
|
9038
9073
|
var SwapSDK = _SwapSDK;
|
package/dist/swap.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getTokenContractAddress, getEnvironment, getVaultManagerContractAddress, approve, checkAllowance, Vault__factory, extractOverrides } from './chunk-
|
|
2
|
-
import { ccmMetadataSchema } from './chunk-
|
|
3
|
-
import { __name, z, numericString, Chains, Assets, ethereumAddress, dotAddress, ChainflipNetworks, assetConstants, isTestnet, readChainAssetValue, isNotNullish, __publicField, assert, chainConstants, isTokenCall, isTokenSwap, getInternalAsset, btcAddress } from './chunk-
|
|
4
|
-
export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-
|
|
1
|
+
import { getTokenContractAddress, getEvmChainId, getEnvironment, getVaultManagerContractAddress, approve, checkAllowance, Vault__factory, extractOverrides } from './chunk-I6HKG4VF.mjs';
|
|
2
|
+
import { ccmMetadataSchema } from './chunk-IFMXL6VR.mjs';
|
|
3
|
+
import { __name, z, numericString, Chains, Assets, ethereumAddress, dotAddress, ChainflipNetworks, assetConstants, isTestnet, readChainAssetValue, isNotNullish, __publicField, assert, chainConstants, isTokenCall, isTokenSwap, getInternalAsset, btcAddress } from './chunk-KWYZ5QIZ.mjs';
|
|
4
|
+
export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-KWYZ5QIZ.mjs';
|
|
5
5
|
import { decodeAddress } from '@polkadot/util-crypto';
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
|
|
8
|
-
// ../../node_modules/.pnpm/@trpc+server@10.45.
|
|
8
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/observable-ade1bad8.mjs
|
|
9
9
|
function identity(x) {
|
|
10
10
|
return x;
|
|
11
11
|
}
|
|
@@ -84,7 +84,7 @@ function observable(subscribe) {
|
|
|
84
84
|
}
|
|
85
85
|
__name(observable, "observable");
|
|
86
86
|
|
|
87
|
-
// ../../node_modules/.pnpm/@trpc+server@10.45.
|
|
87
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/observable/index.mjs
|
|
88
88
|
function share(_opts) {
|
|
89
89
|
return (originalObserver) => {
|
|
90
90
|
let refCount = 0;
|
|
@@ -189,7 +189,7 @@ function observableToPromise(observable2) {
|
|
|
189
189
|
}
|
|
190
190
|
__name(observableToPromise, "observableToPromise");
|
|
191
191
|
|
|
192
|
-
// ../../node_modules/.pnpm/@trpc+client@10.45.
|
|
192
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/splitLink-4c75f7be.mjs
|
|
193
193
|
function createChain(opts) {
|
|
194
194
|
return observable((observer) => {
|
|
195
195
|
function execute(index = 0, op = opts.op) {
|
|
@@ -213,7 +213,7 @@ function createChain(opts) {
|
|
|
213
213
|
}
|
|
214
214
|
__name(createChain, "createChain");
|
|
215
215
|
|
|
216
|
-
// ../../node_modules/.pnpm/@trpc+server@10.45.
|
|
216
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/codes-c924c3db.mjs
|
|
217
217
|
function invert(obj) {
|
|
218
218
|
const newObj = /* @__PURE__ */ Object.create(null);
|
|
219
219
|
for (const key in obj) {
|
|
@@ -251,7 +251,7 @@ var TRPC_ERROR_CODES_BY_KEY = {
|
|
|
251
251
|
};
|
|
252
252
|
invert(TRPC_ERROR_CODES_BY_KEY);
|
|
253
253
|
|
|
254
|
-
// ../../node_modules/.pnpm/@trpc+server@10.45.
|
|
254
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/index-f91d720c.mjs
|
|
255
255
|
invert(TRPC_ERROR_CODES_BY_KEY);
|
|
256
256
|
var noop = /* @__PURE__ */ __name(() => {
|
|
257
257
|
}, "noop");
|
|
@@ -289,7 +289,7 @@ var createFlatProxy = /* @__PURE__ */ __name((callback) => {
|
|
|
289
289
|
});
|
|
290
290
|
}, "createFlatProxy");
|
|
291
291
|
|
|
292
|
-
// ../../node_modules/.pnpm/@trpc+server@10.45.
|
|
292
|
+
// ../../node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/getCauseFromUnknown-2d66414a.mjs
|
|
293
293
|
function isObject(value) {
|
|
294
294
|
return !!value && !Array.isArray(value) && typeof value === "object";
|
|
295
295
|
}
|
|
@@ -320,7 +320,7 @@ function getCauseFromUnknown(cause) {
|
|
|
320
320
|
}
|
|
321
321
|
__name(getCauseFromUnknown, "getCauseFromUnknown");
|
|
322
322
|
|
|
323
|
-
// ../../node_modules/.pnpm/@trpc+client@10.45.
|
|
323
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/transformResult-ace864b8.mjs
|
|
324
324
|
function isObject2(value) {
|
|
325
325
|
return !!value && !Array.isArray(value) && typeof value === "object";
|
|
326
326
|
}
|
|
@@ -373,7 +373,7 @@ function transformResult(response, runtime) {
|
|
|
373
373
|
}
|
|
374
374
|
__name(transformResult, "transformResult");
|
|
375
375
|
|
|
376
|
-
// ../../node_modules/.pnpm/@trpc+client@10.45.
|
|
376
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/TRPCClientError-38f9a32a.mjs
|
|
377
377
|
function isTRPCClientError(cause) {
|
|
378
378
|
return cause instanceof TRPCClientError || /**
|
|
379
379
|
* @deprecated
|
|
@@ -431,7 +431,7 @@ var _TRPCClientError = class _TRPCClientError extends Error {
|
|
|
431
431
|
__name(_TRPCClientError, "TRPCClientError");
|
|
432
432
|
var TRPCClientError = _TRPCClientError;
|
|
433
433
|
|
|
434
|
-
// ../../node_modules/.pnpm/@trpc+client@10.45.
|
|
434
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/httpUtils-b9d0cb48.mjs
|
|
435
435
|
var isFunction = /* @__PURE__ */ __name((fn) => typeof fn === "function", "isFunction");
|
|
436
436
|
function getFetch(customFetchImpl) {
|
|
437
437
|
if (customFetchImpl) {
|
|
@@ -575,7 +575,7 @@ function httpRequest(opts) {
|
|
|
575
575
|
}
|
|
576
576
|
__name(httpRequest, "httpRequest");
|
|
577
577
|
|
|
578
|
-
// ../../node_modules/.pnpm/@trpc+client@10.45.
|
|
578
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/httpBatchLink-d0f9eac9.mjs
|
|
579
579
|
var throwFatalError = /* @__PURE__ */ __name(() => {
|
|
580
580
|
throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new");
|
|
581
581
|
}, "throwFatalError");
|
|
@@ -805,7 +805,7 @@ var batchRequester = /* @__PURE__ */ __name((requesterOpts) => {
|
|
|
805
805
|
}, "batchRequester");
|
|
806
806
|
var httpBatchLink = createHTTPBatchLink(batchRequester);
|
|
807
807
|
|
|
808
|
-
// ../../node_modules/.pnpm/@trpc+client@10.45.
|
|
808
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/links/httpLink.mjs
|
|
809
809
|
function httpLinkFactory(factoryOpts) {
|
|
810
810
|
return (opts) => {
|
|
811
811
|
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
|
@@ -857,7 +857,7 @@ function httpLinkFactory(factoryOpts) {
|
|
|
857
857
|
}
|
|
858
858
|
__name(httpLinkFactory, "httpLinkFactory");
|
|
859
859
|
|
|
860
|
-
// ../../node_modules/.pnpm/@trpc+client@10.45.
|
|
860
|
+
// ../../node_modules/.pnpm/@trpc+client@10.45.2_@trpc+server@10.45.2/node_modules/@trpc/client/dist/index.mjs
|
|
861
861
|
var _TRPCUntypedClient = class _TRPCUntypedClient {
|
|
862
862
|
$request({ type, input, path, context = {} }) {
|
|
863
863
|
const chain$ = createChain({
|
|
@@ -2323,6 +2323,17 @@ var executeSwapParamsSchema = /* @__PURE__ */ __name((network) => z.union([
|
|
|
2323
2323
|
tokenSwapParamsSchema(network)
|
|
2324
2324
|
]), "executeSwapParamsSchema");
|
|
2325
2325
|
|
|
2326
|
+
// ../shared/src/signer.ts
|
|
2327
|
+
var assertSignerIsConnectedToChain = /* @__PURE__ */ __name(async (opts, chain) => {
|
|
2328
|
+
if (opts.network === "localnet")
|
|
2329
|
+
return;
|
|
2330
|
+
assert(opts.signer.provider, "Signer has no provider");
|
|
2331
|
+
const sourceChainId = getEvmChainId(chain, opts.network);
|
|
2332
|
+
assert(sourceChainId, `Chain ${chain} has no evm chain id`);
|
|
2333
|
+
const { chainId: signerChainId } = await opts.signer.provider.getNetwork();
|
|
2334
|
+
assert(signerChainId === BigInt(sourceChainId), `Signer is connected to unexpected evm chain (expected: ${sourceChainId}, got: ${signerChainId})`);
|
|
2335
|
+
}, "assertSignerIsConnectedToChain");
|
|
2336
|
+
|
|
2326
2337
|
// ../shared/src/vault/executeSwap.ts
|
|
2327
2338
|
var swapNative = /* @__PURE__ */ __name(async ({ destChain, destAsset, destAddress, amount }, networkOpts, txOpts) => {
|
|
2328
2339
|
const internalDestAsset = getInternalAsset({
|
|
@@ -2349,8 +2360,8 @@ var swapToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
2349
2360
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
2350
2361
|
const erc20Address = networkOpts.network === "localnet" ? networkOpts.srcTokenContractAddress : getTokenContractAddress(internalSrcAsset, networkOpts.network);
|
|
2351
2362
|
assert(erc20Address !== void 0, "Missing ERC20 contract address");
|
|
2352
|
-
const {
|
|
2353
|
-
assert(
|
|
2363
|
+
const { hasSufficientAllowance } = await checkAllowance(BigInt(params.amount), vaultContractAddress, erc20Address, networkOpts.signer);
|
|
2364
|
+
assert(hasSufficientAllowance, "Swap amount exceeds allowance");
|
|
2354
2365
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
2355
2366
|
const transaction = await vault.xSwapToken(chainConstants[params.destChain].contractId, params.destAddress, assetConstants[internalDestAsset].contractId, erc20Address, params.amount, "0x", extractOverrides(txOpts));
|
|
2356
2367
|
return transaction.wait(txOpts.wait);
|
|
@@ -2380,13 +2391,14 @@ var callToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
2380
2391
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
2381
2392
|
const erc20Address = networkOpts.network === "localnet" ? networkOpts.srcTokenContractAddress : getTokenContractAddress(internalSrcAsset, networkOpts.network);
|
|
2382
2393
|
assert(erc20Address !== void 0, "Missing ERC20 contract address");
|
|
2383
|
-
const {
|
|
2384
|
-
assert(
|
|
2394
|
+
const { hasSufficientAllowance } = await checkAllowance(BigInt(params.amount), vaultContractAddress, erc20Address, networkOpts.signer);
|
|
2395
|
+
assert(hasSufficientAllowance, "Swap amount exceeds allowance");
|
|
2385
2396
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
2386
2397
|
const transaction = await vault.xCallToken(chainConstants[params.destChain].contractId, params.destAddress, assetConstants[internalDestAsset].contractId, params.ccmMetadata.message, params.ccmMetadata.gasBudget, erc20Address, params.amount, "0x", extractOverrides(txOpts));
|
|
2387
2398
|
return transaction.wait(txOpts.wait);
|
|
2388
2399
|
}, "callToken");
|
|
2389
2400
|
var executeSwap = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
2401
|
+
await assertSignerIsConnectedToChain(networkOpts, params.srcChain);
|
|
2390
2402
|
const network = networkOpts.network === "localnet" ? "backspin" : networkOpts.network;
|
|
2391
2403
|
const parsedParams = executeSwapParamsSchema(network).parse(params);
|
|
2392
2404
|
if ("ccmMetadata" in parsedParams) {
|
|
@@ -2407,8 +2419,9 @@ var checkVaultAllowance = /* @__PURE__ */ __name((params, networkOpts) => {
|
|
|
2407
2419
|
return checkAllowance(BigInt(params.amount), vaultContractAddress, erc20Address, networkOpts.signer);
|
|
2408
2420
|
}, "checkVaultAllowance");
|
|
2409
2421
|
var approveVault = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
2410
|
-
|
|
2411
|
-
|
|
2422
|
+
await assertSignerIsConnectedToChain(networkOpts, params.srcChain);
|
|
2423
|
+
const { hasSufficientAllowance, erc20, allowance } = await checkVaultAllowance(params, networkOpts);
|
|
2424
|
+
if (hasSufficientAllowance)
|
|
2412
2425
|
return null;
|
|
2413
2426
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
2414
2427
|
return approve(BigInt(params.amount), vaultContractAddress, erc20, allowance, txOpts);
|
|
@@ -2450,9 +2463,10 @@ var btc$ = assetFactory("Btc");
|
|
|
2450
2463
|
// src/swap/chains.ts
|
|
2451
2464
|
var chainFactory = /* @__PURE__ */ __name((chain) => (network, env) => ({
|
|
2452
2465
|
chain,
|
|
2453
|
-
name:
|
|
2466
|
+
name: chain,
|
|
2467
|
+
evmChainId: getEvmChainId(chain, network),
|
|
2454
2468
|
isMainnet: !isTestnet(network),
|
|
2455
|
-
requiredBlockConfirmations: isNotNullish(env.ingressEgress.witnessSafetyMargins[
|
|
2469
|
+
requiredBlockConfirmations: isNotNullish(env.ingressEgress.witnessSafetyMargins[chain]) ? Number(env.ingressEgress.witnessSafetyMargins[chain]) + 1 : void 0
|
|
2456
2470
|
}), "chainFactory");
|
|
2457
2471
|
var ethereum = chainFactory(Chains.Ethereum);
|
|
2458
2472
|
var polkadot = chainFactory(Chains.Polkadot);
|
|
@@ -2512,7 +2526,7 @@ var getAssets = /* @__PURE__ */ __name(async (chain, network, env) => {
|
|
|
2512
2526
|
throw new Error("received unexpected chain");
|
|
2513
2527
|
}, "getAssets");
|
|
2514
2528
|
var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal }) => {
|
|
2515
|
-
const { brokerCommissionBps, ...returnedRequestData } = quoteRequest;
|
|
2529
|
+
const { brokerCommissionBps, boostFeeBps, ...returnedRequestData } = quoteRequest;
|
|
2516
2530
|
const params = {
|
|
2517
2531
|
amount: returnedRequestData.amount,
|
|
2518
2532
|
srcChain: returnedRequestData.srcChain,
|
|
@@ -2521,6 +2535,9 @@ var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal })
|
|
|
2521
2535
|
destAsset: returnedRequestData.destAsset,
|
|
2522
2536
|
...brokerCommissionBps && {
|
|
2523
2537
|
brokerCommissionBps: String(brokerCommissionBps)
|
|
2538
|
+
},
|
|
2539
|
+
...boostFeeBps && {
|
|
2540
|
+
boostFeeBps: String(boostFeeBps)
|
|
2524
2541
|
}
|
|
2525
2542
|
};
|
|
2526
2543
|
const queryParams = new URLSearchParams(params);
|
|
@@ -2551,37 +2568,36 @@ var ApiService_default = {
|
|
|
2551
2568
|
// src/swap/sdk.ts
|
|
2552
2569
|
var _SwapSDK = class _SwapSDK {
|
|
2553
2570
|
constructor(options = {}) {
|
|
2554
|
-
__publicField(this, "
|
|
2555
|
-
__publicField(this, "
|
|
2556
|
-
__publicField(this, "signer");
|
|
2571
|
+
__publicField(this, "options");
|
|
2572
|
+
__publicField(this, "rpcConfig");
|
|
2557
2573
|
__publicField(this, "trpc");
|
|
2558
|
-
__publicField(this, "brokerConfig");
|
|
2559
2574
|
__publicField(this, "stateChainEnvironment");
|
|
2560
|
-
|
|
2561
|
-
this.
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2575
|
+
const network = options.network ?? ChainflipNetworks.perseverance;
|
|
2576
|
+
this.options = {
|
|
2577
|
+
...options,
|
|
2578
|
+
network,
|
|
2579
|
+
backendUrl: options.backendUrl ?? BACKEND_SERVICE_URLS[network]
|
|
2580
|
+
};
|
|
2581
|
+
this.rpcConfig = options.rpcUrl ? {
|
|
2582
|
+
rpcUrl: options.rpcUrl
|
|
2583
|
+
} : {
|
|
2584
|
+
network
|
|
2585
|
+
};
|
|
2565
2586
|
this.trpc = createTRPCProxyClient({
|
|
2566
2587
|
transformer: esm_default,
|
|
2567
2588
|
links: [
|
|
2568
2589
|
httpBatchLink({
|
|
2569
|
-
url: new URL("/trpc", this.
|
|
2590
|
+
url: new URL("/trpc", this.options.backendUrl)
|
|
2570
2591
|
})
|
|
2571
2592
|
]
|
|
2572
2593
|
});
|
|
2573
|
-
this.rpcConfig = options.rpcUrl ? {
|
|
2574
|
-
rpcUrl: options.rpcUrl
|
|
2575
|
-
} : {
|
|
2576
|
-
network: this.network
|
|
2577
|
-
};
|
|
2578
2594
|
}
|
|
2579
2595
|
async getChains(sourceChain) {
|
|
2580
2596
|
const env = await this.getStateChainEnvironment();
|
|
2581
2597
|
if (sourceChain !== void 0) {
|
|
2582
|
-
return ApiService_default.getPossibleDestinationChains(sourceChain, this.network, env);
|
|
2598
|
+
return ApiService_default.getPossibleDestinationChains(sourceChain, this.options.network, env);
|
|
2583
2599
|
}
|
|
2584
|
-
return ApiService_default.getChains(this.network, env);
|
|
2600
|
+
return ApiService_default.getChains(this.options.network, env);
|
|
2585
2601
|
}
|
|
2586
2602
|
async getStateChainEnvironment() {
|
|
2587
2603
|
this.stateChainEnvironment ?? (this.stateChainEnvironment = await getEnvironment(this.rpcConfig));
|
|
@@ -2589,12 +2605,12 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2589
2605
|
}
|
|
2590
2606
|
async getAssets(chain) {
|
|
2591
2607
|
const env = await this.getStateChainEnvironment();
|
|
2592
|
-
return ApiService_default.getAssets(chain, this.network, env);
|
|
2608
|
+
return ApiService_default.getAssets(chain, this.options.network, env);
|
|
2593
2609
|
}
|
|
2594
2610
|
getQuote(quoteRequest, options = {}) {
|
|
2595
|
-
return ApiService_default.getQuote(this.
|
|
2611
|
+
return ApiService_default.getQuote(this.options.backendUrl, {
|
|
2596
2612
|
...quoteRequest,
|
|
2597
|
-
brokerCommissionBps: this.
|
|
2613
|
+
brokerCommissionBps: this.options.broker?.commissionBps
|
|
2598
2614
|
}, options);
|
|
2599
2615
|
}
|
|
2600
2616
|
async requestDepositAddress(depositAddressRequest) {
|
|
@@ -2604,15 +2620,16 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2604
2620
|
asset: srcAsset
|
|
2605
2621
|
}, BigInt(amount));
|
|
2606
2622
|
let response;
|
|
2607
|
-
if (this.
|
|
2608
|
-
const { requestSwapDepositAddress } = await import('./broker-
|
|
2609
|
-
const result = await requestSwapDepositAddress(depositAddressRequest, this.
|
|
2623
|
+
if (this.options.broker !== void 0) {
|
|
2624
|
+
const { requestSwapDepositAddress } = await import('./broker-AKUV2UWF.mjs');
|
|
2625
|
+
const result = await requestSwapDepositAddress(depositAddressRequest, this.options.broker, this.options.network);
|
|
2610
2626
|
response = {
|
|
2611
2627
|
id: `${result.issuedBlock}-${depositAddressRequest.srcChain}-${result.channelId}`,
|
|
2612
2628
|
depositAddress: result.address,
|
|
2613
|
-
brokerCommissionBps: this.
|
|
2629
|
+
brokerCommissionBps: this.options.broker.commissionBps,
|
|
2614
2630
|
srcChainExpiryBlock: result.sourceChainExpiryBlock,
|
|
2615
|
-
boostFeeBps: depositAddressRequest.boostFeeBps
|
|
2631
|
+
boostFeeBps: depositAddressRequest.boostFeeBps,
|
|
2632
|
+
channelOpeningFee: result.channelOpeningFee
|
|
2616
2633
|
};
|
|
2617
2634
|
} else {
|
|
2618
2635
|
response = await this.trpc.openSwapDepositChannel.mutate(depositAddressRequest);
|
|
@@ -2624,33 +2641,36 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2624
2641
|
brokerCommissionBps: response.brokerCommissionBps,
|
|
2625
2642
|
boostFeeBps: Number(response.boostFeeBps) || 0,
|
|
2626
2643
|
depositChannelExpiryBlock: response.srcChainExpiryBlock,
|
|
2627
|
-
estimatedDepositChannelExpiryTime: response.estimatedExpiryTime
|
|
2644
|
+
estimatedDepositChannelExpiryTime: response.estimatedExpiryTime,
|
|
2645
|
+
channelOpeningFee: response.channelOpeningFee
|
|
2628
2646
|
};
|
|
2629
2647
|
}
|
|
2630
2648
|
getStatus(swapStatusRequest, options = {}) {
|
|
2631
|
-
return ApiService_default.getStatus(this.
|
|
2649
|
+
return ApiService_default.getStatus(this.options.backendUrl, swapStatusRequest, options);
|
|
2632
2650
|
}
|
|
2633
2651
|
async executeSwap(params, txOpts = {}) {
|
|
2634
2652
|
const { srcChain, srcAsset, amount } = params;
|
|
2653
|
+
const { signer: optsSigner, ...remainingTxOpts } = txOpts;
|
|
2654
|
+
const signer = optsSigner ?? this.options.signer;
|
|
2655
|
+
assert(signer, "No signer provided");
|
|
2635
2656
|
await this.validateSwapAmount({
|
|
2636
2657
|
chain: srcChain,
|
|
2637
2658
|
asset: srcAsset
|
|
2638
2659
|
}, BigInt(amount));
|
|
2639
|
-
assert(this.signer, "No signer provided");
|
|
2640
2660
|
const receipt = await executeSwap_default(params, {
|
|
2641
|
-
network: this.network,
|
|
2642
|
-
signer
|
|
2643
|
-
},
|
|
2661
|
+
network: this.options.network,
|
|
2662
|
+
signer
|
|
2663
|
+
}, remainingTxOpts);
|
|
2644
2664
|
return receipt.hash;
|
|
2645
2665
|
}
|
|
2646
2666
|
async approveVault(params, txOpts = {}) {
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
assert(
|
|
2667
|
+
const { signer: optsSigner, ...remainingTxOpts } = txOpts;
|
|
2668
|
+
const signer = optsSigner ?? this.options.signer;
|
|
2669
|
+
assert(signer, "No signer provided");
|
|
2650
2670
|
const receipt = await approveVault(params, {
|
|
2651
|
-
signer
|
|
2652
|
-
network: this.network
|
|
2653
|
-
},
|
|
2671
|
+
signer,
|
|
2672
|
+
network: this.options.network
|
|
2673
|
+
}, remainingTxOpts);
|
|
2654
2674
|
return receipt ? receipt.hash : null;
|
|
2655
2675
|
}
|
|
2656
2676
|
async validateSwapAmount(asset, amount) {
|
|
@@ -2669,10 +2689,14 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2669
2689
|
async getRequiredBlockConfirmations() {
|
|
2670
2690
|
const { ingressEgress: { witnessSafetyMargins } } = await this.getStateChainEnvironment();
|
|
2671
2691
|
return Object.keys(Chains).reduce((acc, chain) => {
|
|
2672
|
-
acc[chain] = witnessSafetyMargins[chain] ? Number(witnessSafetyMargins[chain]) + 1 :
|
|
2692
|
+
acc[chain] = witnessSafetyMargins[chain] ? Number(witnessSafetyMargins[chain]) + 1 : null;
|
|
2673
2693
|
return acc;
|
|
2674
2694
|
}, {});
|
|
2675
2695
|
}
|
|
2696
|
+
async getChannelOpeningFees() {
|
|
2697
|
+
const { ingressEgress: { channelOpeningFees } } = await this.getStateChainEnvironment();
|
|
2698
|
+
return channelOpeningFees;
|
|
2699
|
+
}
|
|
2676
2700
|
};
|
|
2677
2701
|
__name(_SwapSDK, "SwapSDK");
|
|
2678
2702
|
var SwapSDK = _SwapSDK;
|