@chainflip/sdk 1.3.0-beta.1 → 1.3.0-beta.3
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-FDK3LRGL.mjs} +25 -21
- package/dist/{chunk-PYU5KZSK.mjs → chunk-IFMXL6VR.mjs} +3 -2
- package/dist/{chunk-VI7GMT56.mjs → chunk-KWYZ5QIZ.mjs} +2 -1
- package/dist/funding.js +23 -24
- package/dist/funding.mjs +7 -7
- package/dist/swap.d.mts +16 -12
- package/dist/swap.d.ts +16 -12
- package/dist/swap.js +117 -82
- 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,8 +2136,20 @@ 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
|
-
var SEPOLIA_USDT_CONTRACT_ADDRESS = "
|
|
2152
|
+
var SEPOLIA_USDT_CONTRACT_ADDRESS = "0x27CEA6Eb8a21Aae05Eb29C91c5CA10592892F584";
|
|
2149
2153
|
var ADDRESSES = {
|
|
2150
2154
|
[ChainflipNetworks.backspin]: {
|
|
2151
2155
|
FLIP_CONTRACT_ADDRESS: "0x10C6E9530F1C1AF873a391030a1D9E8ed0630D26",
|
|
@@ -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,8 +1349,14 @@ __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
|
-
var SEPOLIA_USDT_CONTRACT_ADDRESS = "
|
|
1359
|
+
var SEPOLIA_USDT_CONTRACT_ADDRESS = "0x27CEA6Eb8a21Aae05Eb29C91c5CA10592892F584";
|
|
1354
1360
|
var ADDRESSES = {
|
|
1355
1361
|
[ChainflipNetworks.backspin]: {
|
|
1356
1362
|
FLIP_CONTRACT_ADDRESS: "0x10C6E9530F1C1AF873a391030a1D9E8ed0630D26",
|
|
@@ -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-FDK3LRGL.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 };
|