@chainflip/sdk 1.6.7-rc.4 → 1.8.0-assethub.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/{chunk-G76RI3QK.mjs → chunk-5BNVUJZY.mjs} +50 -6
- package/dist/{contracts-Bgib7w_h.d.mts → contracts-BmyTFuGH.d.mts} +8 -2
- package/dist/{contracts-Bgib7w_h.d.ts → contracts-BmyTFuGH.d.ts} +8 -2
- package/dist/funding.d.mts +1 -1
- package/dist/funding.d.ts +1 -1
- package/dist/funding.js +50 -6
- package/dist/funding.mjs +1 -1
- package/dist/swap.d.mts +8 -5
- package/dist/swap.d.ts +8 -5
- package/dist/swap.js +79 -20
- package/dist/swap.mjs +31 -16
- package/package.json +3 -3
|
@@ -40,23 +40,31 @@ var arrayToMap = /* @__PURE__ */ __name((array) => Object.fromEntries(array.map(
|
|
|
40
40
|
key
|
|
41
41
|
])), "arrayToMap");
|
|
42
42
|
var InternalAssets = arrayToMap([
|
|
43
|
-
"
|
|
44
|
-
"Usdc",
|
|
43
|
+
"Btc",
|
|
45
44
|
"Dot",
|
|
45
|
+
// ethereum
|
|
46
46
|
"Eth",
|
|
47
|
-
"
|
|
47
|
+
"Usdc",
|
|
48
|
+
"Flip",
|
|
48
49
|
"Usdt",
|
|
50
|
+
// solana
|
|
51
|
+
"Sol",
|
|
52
|
+
"SolUsdc",
|
|
53
|
+
// arbitrum
|
|
49
54
|
"ArbUsdc",
|
|
50
55
|
"ArbEth",
|
|
51
|
-
|
|
52
|
-
"
|
|
56
|
+
// asset hub
|
|
57
|
+
"HubDot",
|
|
58
|
+
"HubUsdc",
|
|
59
|
+
"HubUsdt"
|
|
53
60
|
]);
|
|
54
61
|
var Chains = arrayToMap([
|
|
55
62
|
"Bitcoin",
|
|
56
63
|
"Ethereum",
|
|
57
64
|
"Polkadot",
|
|
58
65
|
"Arbitrum",
|
|
59
|
-
"Solana"
|
|
66
|
+
"Solana",
|
|
67
|
+
"Assethub"
|
|
60
68
|
]);
|
|
61
69
|
var Assets = arrayToMap([
|
|
62
70
|
"FLIP",
|
|
@@ -144,6 +152,27 @@ var assetConstants = {
|
|
|
144
152
|
name: "Solana USDC",
|
|
145
153
|
decimals: 6,
|
|
146
154
|
contractId: 10
|
|
155
|
+
},
|
|
156
|
+
[InternalAssets.HubDot]: {
|
|
157
|
+
chain: Chains.Assethub,
|
|
158
|
+
asset: Assets.DOT,
|
|
159
|
+
name: "AssetHub DOT",
|
|
160
|
+
decimals: 10,
|
|
161
|
+
contractId: 11
|
|
162
|
+
},
|
|
163
|
+
[InternalAssets.HubUsdc]: {
|
|
164
|
+
chain: Chains.Assethub,
|
|
165
|
+
asset: Assets.USDC,
|
|
166
|
+
name: "AssetHub USDC",
|
|
167
|
+
decimals: 6,
|
|
168
|
+
contractId: 12
|
|
169
|
+
},
|
|
170
|
+
[InternalAssets.HubUsdt]: {
|
|
171
|
+
chain: Chains.Assethub,
|
|
172
|
+
asset: Assets.USDT,
|
|
173
|
+
name: "AssetHub USDT",
|
|
174
|
+
decimals: 6,
|
|
175
|
+
contractId: 13
|
|
147
176
|
}
|
|
148
177
|
};
|
|
149
178
|
var chainConstants = {
|
|
@@ -191,6 +220,16 @@ var chainConstants = {
|
|
|
191
220
|
gasAsset: InternalAssets.Sol,
|
|
192
221
|
contractId: 5,
|
|
193
222
|
blockTimeSeconds: (400 + 800) / 2 / 1e3
|
|
223
|
+
},
|
|
224
|
+
[Chains.Assethub]: {
|
|
225
|
+
assets: [
|
|
226
|
+
Assets.DOT,
|
|
227
|
+
Assets.USDC,
|
|
228
|
+
Assets.USDT
|
|
229
|
+
],
|
|
230
|
+
gasAsset: InternalAssets.HubDot,
|
|
231
|
+
contractId: 6,
|
|
232
|
+
blockTimeSeconds: 12
|
|
194
233
|
}
|
|
195
234
|
};
|
|
196
235
|
function isValidAssetAndChain(assetAndChain) {
|
|
@@ -232,6 +271,11 @@ function getInternalAsset(asset, assert2 = true) {
|
|
|
232
271
|
[Chains.Solana]: {
|
|
233
272
|
[Assets.SOL]: InternalAssets.Sol,
|
|
234
273
|
[Assets.USDC]: InternalAssets.SolUsdc
|
|
274
|
+
},
|
|
275
|
+
[Chains.Assethub]: {
|
|
276
|
+
[Assets.DOT]: InternalAssets.HubDot,
|
|
277
|
+
[Assets.USDC]: InternalAssets.HubUsdc,
|
|
278
|
+
[Assets.USDT]: InternalAssets.HubUsdt
|
|
235
279
|
}
|
|
236
280
|
};
|
|
237
281
|
const chain = map[asset.chain];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
type ArrayToMap<T extends readonly string[]> = {
|
|
2
2
|
[K in T[number]]: K;
|
|
3
3
|
};
|
|
4
|
-
declare const InternalAssets: ArrayToMap<readonly ["
|
|
4
|
+
declare const InternalAssets: ArrayToMap<readonly ["Btc", "Dot", "Eth", "Usdc", "Flip", "Usdt", "Sol", "SolUsdc", "ArbUsdc", "ArbEth", "HubDot", "HubUsdc", "HubUsdt"]>;
|
|
5
5
|
type InternalAsset = (typeof InternalAssets)[keyof typeof InternalAssets];
|
|
6
|
-
declare const Chains: ArrayToMap<readonly ["Bitcoin", "Ethereum", "Polkadot", "Arbitrum", "Solana"]>;
|
|
6
|
+
declare const Chains: ArrayToMap<readonly ["Bitcoin", "Ethereum", "Polkadot", "Arbitrum", "Solana", "Assethub"]>;
|
|
7
7
|
type Chain = (typeof Chains)[keyof typeof Chains];
|
|
8
8
|
declare const Assets: ArrayToMap<readonly ["FLIP", "USDC", "DOT", "ETH", "BTC", "USDT", "SOL"]>;
|
|
9
9
|
type Asset = (typeof Assets)[keyof typeof Assets];
|
|
@@ -40,6 +40,12 @@ declare const chainConstants: {
|
|
|
40
40
|
readonly contractId: 5;
|
|
41
41
|
readonly blockTimeSeconds: number;
|
|
42
42
|
};
|
|
43
|
+
readonly Assethub: {
|
|
44
|
+
readonly assets: ["DOT", "USDC", "USDT"];
|
|
45
|
+
readonly gasAsset: "HubDot";
|
|
46
|
+
readonly contractId: 6;
|
|
47
|
+
readonly blockTimeSeconds: 12;
|
|
48
|
+
};
|
|
43
49
|
};
|
|
44
50
|
type AssetOfChain<C extends Chain> = (typeof chainConstants)[C]['assets'][number];
|
|
45
51
|
type UncheckedAssetAndChain = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
type ArrayToMap<T extends readonly string[]> = {
|
|
2
2
|
[K in T[number]]: K;
|
|
3
3
|
};
|
|
4
|
-
declare const InternalAssets: ArrayToMap<readonly ["
|
|
4
|
+
declare const InternalAssets: ArrayToMap<readonly ["Btc", "Dot", "Eth", "Usdc", "Flip", "Usdt", "Sol", "SolUsdc", "ArbUsdc", "ArbEth", "HubDot", "HubUsdc", "HubUsdt"]>;
|
|
5
5
|
type InternalAsset = (typeof InternalAssets)[keyof typeof InternalAssets];
|
|
6
|
-
declare const Chains: ArrayToMap<readonly ["Bitcoin", "Ethereum", "Polkadot", "Arbitrum", "Solana"]>;
|
|
6
|
+
declare const Chains: ArrayToMap<readonly ["Bitcoin", "Ethereum", "Polkadot", "Arbitrum", "Solana", "Assethub"]>;
|
|
7
7
|
type Chain = (typeof Chains)[keyof typeof Chains];
|
|
8
8
|
declare const Assets: ArrayToMap<readonly ["FLIP", "USDC", "DOT", "ETH", "BTC", "USDT", "SOL"]>;
|
|
9
9
|
type Asset = (typeof Assets)[keyof typeof Assets];
|
|
@@ -40,6 +40,12 @@ declare const chainConstants: {
|
|
|
40
40
|
readonly contractId: 5;
|
|
41
41
|
readonly blockTimeSeconds: number;
|
|
42
42
|
};
|
|
43
|
+
readonly Assethub: {
|
|
44
|
+
readonly assets: ["DOT", "USDC", "USDT"];
|
|
45
|
+
readonly gasAsset: "HubDot";
|
|
46
|
+
readonly contractId: 6;
|
|
47
|
+
readonly blockTimeSeconds: 12;
|
|
48
|
+
};
|
|
43
49
|
};
|
|
44
50
|
type AssetOfChain<C extends Chain> = (typeof chainConstants)[C]['assets'][number];
|
|
45
51
|
type UncheckedAssetAndChain = {
|
package/dist/funding.d.mts
CHANGED
package/dist/funding.d.ts
CHANGED
package/dist/funding.js
CHANGED
|
@@ -765,23 +765,31 @@ var arrayToMap = /* @__PURE__ */ __name((array) => Object.fromEntries(array.map(
|
|
|
765
765
|
key
|
|
766
766
|
])), "arrayToMap");
|
|
767
767
|
var InternalAssets = arrayToMap([
|
|
768
|
-
"
|
|
769
|
-
"Usdc",
|
|
768
|
+
"Btc",
|
|
770
769
|
"Dot",
|
|
770
|
+
// ethereum
|
|
771
771
|
"Eth",
|
|
772
|
-
"
|
|
772
|
+
"Usdc",
|
|
773
|
+
"Flip",
|
|
773
774
|
"Usdt",
|
|
775
|
+
// solana
|
|
776
|
+
"Sol",
|
|
777
|
+
"SolUsdc",
|
|
778
|
+
// arbitrum
|
|
774
779
|
"ArbUsdc",
|
|
775
780
|
"ArbEth",
|
|
776
|
-
|
|
777
|
-
"
|
|
781
|
+
// asset hub
|
|
782
|
+
"HubDot",
|
|
783
|
+
"HubUsdc",
|
|
784
|
+
"HubUsdt"
|
|
778
785
|
]);
|
|
779
786
|
var Chains = arrayToMap([
|
|
780
787
|
"Bitcoin",
|
|
781
788
|
"Ethereum",
|
|
782
789
|
"Polkadot",
|
|
783
790
|
"Arbitrum",
|
|
784
|
-
"Solana"
|
|
791
|
+
"Solana",
|
|
792
|
+
"Assethub"
|
|
785
793
|
]);
|
|
786
794
|
var Assets = arrayToMap([
|
|
787
795
|
"FLIP",
|
|
@@ -868,6 +876,27 @@ var ChainflipNetworks = arrayToMap([
|
|
|
868
876
|
name: "Solana USDC",
|
|
869
877
|
decimals: 6,
|
|
870
878
|
contractId: 10
|
|
879
|
+
},
|
|
880
|
+
[InternalAssets.HubDot]: {
|
|
881
|
+
chain: Chains.Assethub,
|
|
882
|
+
asset: Assets.DOT,
|
|
883
|
+
name: "AssetHub DOT",
|
|
884
|
+
decimals: 10,
|
|
885
|
+
contractId: 11
|
|
886
|
+
},
|
|
887
|
+
[InternalAssets.HubUsdc]: {
|
|
888
|
+
chain: Chains.Assethub,
|
|
889
|
+
asset: Assets.USDC,
|
|
890
|
+
name: "AssetHub USDC",
|
|
891
|
+
decimals: 6,
|
|
892
|
+
contractId: 12
|
|
893
|
+
},
|
|
894
|
+
[InternalAssets.HubUsdt]: {
|
|
895
|
+
chain: Chains.Assethub,
|
|
896
|
+
asset: Assets.USDT,
|
|
897
|
+
name: "AssetHub USDT",
|
|
898
|
+
decimals: 6,
|
|
899
|
+
contractId: 13
|
|
871
900
|
}
|
|
872
901
|
});
|
|
873
902
|
var chainConstants = {
|
|
@@ -915,6 +944,16 @@ var chainConstants = {
|
|
|
915
944
|
gasAsset: InternalAssets.Sol,
|
|
916
945
|
contractId: 5,
|
|
917
946
|
blockTimeSeconds: (400 + 800) / 2 / 1e3
|
|
947
|
+
},
|
|
948
|
+
[Chains.Assethub]: {
|
|
949
|
+
assets: [
|
|
950
|
+
Assets.DOT,
|
|
951
|
+
Assets.USDC,
|
|
952
|
+
Assets.USDT
|
|
953
|
+
],
|
|
954
|
+
gasAsset: InternalAssets.HubDot,
|
|
955
|
+
contractId: 6,
|
|
956
|
+
blockTimeSeconds: 12
|
|
918
957
|
}
|
|
919
958
|
};
|
|
920
959
|
function isValidAssetAndChain(assetAndChain) {
|
|
@@ -951,6 +990,11 @@ function getInternalAsset(asset, assert2 = true) {
|
|
|
951
990
|
[Chains.Solana]: {
|
|
952
991
|
[Assets.SOL]: InternalAssets.Sol,
|
|
953
992
|
[Assets.USDC]: InternalAssets.SolUsdc
|
|
993
|
+
},
|
|
994
|
+
[Chains.Assethub]: {
|
|
995
|
+
[Assets.DOT]: InternalAssets.HubDot,
|
|
996
|
+
[Assets.USDC]: InternalAssets.HubUsdc,
|
|
997
|
+
[Assets.USDT]: InternalAssets.HubUsdt
|
|
954
998
|
}
|
|
955
999
|
};
|
|
956
1000
|
const chain = map[asset.chain];
|
package/dist/funding.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name, __publicField, ChainflipNetworks, getFlipBalance, getFundingEnvironment, getStateChainGatewayContractAddress, approve, getTokenContractAddress, InternalAssets, checkAllowance, assert, extractOverrides, StateChainGateway__factory } from './chunk-
|
|
1
|
+
import { __name, __publicField, ChainflipNetworks, getFlipBalance, getFundingEnvironment, getStateChainGatewayContractAddress, approve, getTokenContractAddress, InternalAssets, checkAllowance, assert, extractOverrides, StateChainGateway__factory } from './chunk-5BNVUJZY.mjs';
|
|
2
2
|
|
|
3
3
|
// ../shared/src/stateChainGateway/utils.ts
|
|
4
4
|
var getStateChainGateway = /* @__PURE__ */ __name((networkOpts) => {
|
package/dist/swap.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AssetAndChain, C as Chain, a as Asset, I as InternalAsset, b as AssetOfChain, c as ChainflipNetwork, T as TransactionOptions, d as ChainAssetMap, e as ChainMap } from './contracts-
|
|
2
|
-
export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, U as UncheckedAssetAndChain, j as getChainflipId } from './contracts-
|
|
1
|
+
import { A as AssetAndChain, C as Chain, a as Asset, I as InternalAsset, b as AssetOfChain, c as ChainflipNetwork, T as TransactionOptions, d as ChainAssetMap, e as ChainMap } from './contracts-BmyTFuGH.mjs';
|
|
2
|
+
export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, U as UncheckedAssetAndChain, j as getChainflipId } from './contracts-BmyTFuGH.mjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { SwappingRequestSwapDepositAddressWithAffiliates } from '@chainflip/extrinsics/160/swapping/requestSwapDepositAddressWithAffiliates';
|
|
5
5
|
import { Signer } from 'ethers';
|
|
@@ -362,7 +362,8 @@ declare enum FailureMode {
|
|
|
362
362
|
IngressIgnored = "DEPOSIT_TOO_SMALL",
|
|
363
363
|
SwapEgressIgnored = "SWAP_OUTPUT_TOO_SMALL",
|
|
364
364
|
RefundEgressIgnored = "REFUND_OUTPUT_TOO_SMALL",
|
|
365
|
-
BroadcastAborted = "SENDING_FAILED"
|
|
365
|
+
BroadcastAborted = "SENDING_FAILED",
|
|
366
|
+
TransactionRejectedByBroker = "DEPOSIT_REJECTED"
|
|
366
367
|
}
|
|
367
368
|
|
|
368
369
|
interface Failure {
|
|
@@ -519,6 +520,7 @@ type SwapSDKOptions = {
|
|
|
519
520
|
rpcUrl?: string;
|
|
520
521
|
enabledFeatures?: {
|
|
521
522
|
dca?: boolean;
|
|
523
|
+
experimentalRecommendedSlippage?: boolean;
|
|
522
524
|
};
|
|
523
525
|
};
|
|
524
526
|
declare class SwapSDK {
|
|
@@ -528,6 +530,7 @@ declare class SwapSDK {
|
|
|
528
530
|
private stateChainEnvironmentCache;
|
|
529
531
|
private supportedAssets?;
|
|
530
532
|
private dcaEnabled;
|
|
533
|
+
private autoSlippageEnabled;
|
|
531
534
|
constructor(options?: SwapSDKOptions);
|
|
532
535
|
getChains(sourceChain?: Chain): Promise<ChainData[]>;
|
|
533
536
|
private getStateChainEnvironment;
|
|
@@ -579,9 +582,9 @@ declare class SwapSDK {
|
|
|
579
582
|
channelOpeningFee: bigint;
|
|
580
583
|
fillOrKillParams: FillOrKillParamsWithMinPrice | FillOrKillParamsWithSlippage$1 | undefined;
|
|
581
584
|
srcAsset: "FLIP" | "USDC" | "DOT" | "ETH" | "BTC" | "USDT" | "SOL";
|
|
582
|
-
srcChain: "Bitcoin" | "Ethereum" | "Polkadot" | "Arbitrum" | "Solana";
|
|
585
|
+
srcChain: "Bitcoin" | "Ethereum" | "Polkadot" | "Arbitrum" | "Solana" | "Assethub";
|
|
583
586
|
destAsset: "FLIP" | "USDC" | "DOT" | "ETH" | "BTC" | "USDT" | "SOL";
|
|
584
|
-
destChain: "Bitcoin" | "Ethereum" | "Polkadot" | "Arbitrum" | "Solana";
|
|
587
|
+
destChain: "Bitcoin" | "Ethereum" | "Polkadot" | "Arbitrum" | "Solana" | "Assethub";
|
|
585
588
|
srcAddress: string | undefined;
|
|
586
589
|
destAddress: string;
|
|
587
590
|
dcaParams: {
|
package/dist/swap.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AssetAndChain, C as Chain, a as Asset, I as InternalAsset, b as AssetOfChain, c as ChainflipNetwork, T as TransactionOptions, d as ChainAssetMap, e as ChainMap } from './contracts-
|
|
2
|
-
export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, U as UncheckedAssetAndChain, j as getChainflipId } from './contracts-
|
|
1
|
+
import { A as AssetAndChain, C as Chain, a as Asset, I as InternalAsset, b as AssetOfChain, c as ChainflipNetwork, T as TransactionOptions, d as ChainAssetMap, e as ChainMap } from './contracts-BmyTFuGH.js';
|
|
2
|
+
export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, U as UncheckedAssetAndChain, j as getChainflipId } from './contracts-BmyTFuGH.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { SwappingRequestSwapDepositAddressWithAffiliates } from '@chainflip/extrinsics/160/swapping/requestSwapDepositAddressWithAffiliates';
|
|
5
5
|
import { Signer } from 'ethers';
|
|
@@ -362,7 +362,8 @@ declare enum FailureMode {
|
|
|
362
362
|
IngressIgnored = "DEPOSIT_TOO_SMALL",
|
|
363
363
|
SwapEgressIgnored = "SWAP_OUTPUT_TOO_SMALL",
|
|
364
364
|
RefundEgressIgnored = "REFUND_OUTPUT_TOO_SMALL",
|
|
365
|
-
BroadcastAborted = "SENDING_FAILED"
|
|
365
|
+
BroadcastAborted = "SENDING_FAILED",
|
|
366
|
+
TransactionRejectedByBroker = "DEPOSIT_REJECTED"
|
|
366
367
|
}
|
|
367
368
|
|
|
368
369
|
interface Failure {
|
|
@@ -519,6 +520,7 @@ type SwapSDKOptions = {
|
|
|
519
520
|
rpcUrl?: string;
|
|
520
521
|
enabledFeatures?: {
|
|
521
522
|
dca?: boolean;
|
|
523
|
+
experimentalRecommendedSlippage?: boolean;
|
|
522
524
|
};
|
|
523
525
|
};
|
|
524
526
|
declare class SwapSDK {
|
|
@@ -528,6 +530,7 @@ declare class SwapSDK {
|
|
|
528
530
|
private stateChainEnvironmentCache;
|
|
529
531
|
private supportedAssets?;
|
|
530
532
|
private dcaEnabled;
|
|
533
|
+
private autoSlippageEnabled;
|
|
531
534
|
constructor(options?: SwapSDKOptions);
|
|
532
535
|
getChains(sourceChain?: Chain): Promise<ChainData[]>;
|
|
533
536
|
private getStateChainEnvironment;
|
|
@@ -579,9 +582,9 @@ declare class SwapSDK {
|
|
|
579
582
|
channelOpeningFee: bigint;
|
|
580
583
|
fillOrKillParams: FillOrKillParamsWithMinPrice | FillOrKillParamsWithSlippage$1 | undefined;
|
|
581
584
|
srcAsset: "FLIP" | "USDC" | "DOT" | "ETH" | "BTC" | "USDT" | "SOL";
|
|
582
|
-
srcChain: "Bitcoin" | "Ethereum" | "Polkadot" | "Arbitrum" | "Solana";
|
|
585
|
+
srcChain: "Bitcoin" | "Ethereum" | "Polkadot" | "Arbitrum" | "Solana" | "Assethub";
|
|
583
586
|
destAsset: "FLIP" | "USDC" | "DOT" | "ETH" | "BTC" | "USDT" | "SOL";
|
|
584
|
-
destChain: "Bitcoin" | "Ethereum" | "Polkadot" | "Arbitrum" | "Solana";
|
|
587
|
+
destChain: "Bitcoin" | "Ethereum" | "Polkadot" | "Arbitrum" | "Solana" | "Assethub";
|
|
585
588
|
srcAddress: string | undefined;
|
|
586
589
|
destAddress: string;
|
|
587
590
|
dcaParams: {
|
package/dist/swap.js
CHANGED
|
@@ -11597,23 +11597,31 @@ var arrayToMap = /* @__PURE__ */ __name((array2) => Object.fromEntries(array2.ma
|
|
|
11597
11597
|
key
|
|
11598
11598
|
])), "arrayToMap");
|
|
11599
11599
|
var InternalAssets = arrayToMap([
|
|
11600
|
-
"
|
|
11601
|
-
"Usdc",
|
|
11600
|
+
"Btc",
|
|
11602
11601
|
"Dot",
|
|
11602
|
+
// ethereum
|
|
11603
11603
|
"Eth",
|
|
11604
|
-
"
|
|
11604
|
+
"Usdc",
|
|
11605
|
+
"Flip",
|
|
11605
11606
|
"Usdt",
|
|
11607
|
+
// solana
|
|
11608
|
+
"Sol",
|
|
11609
|
+
"SolUsdc",
|
|
11610
|
+
// arbitrum
|
|
11606
11611
|
"ArbUsdc",
|
|
11607
11612
|
"ArbEth",
|
|
11608
|
-
|
|
11609
|
-
"
|
|
11613
|
+
// asset hub
|
|
11614
|
+
"HubDot",
|
|
11615
|
+
"HubUsdc",
|
|
11616
|
+
"HubUsdt"
|
|
11610
11617
|
]);
|
|
11611
11618
|
var Chains = arrayToMap([
|
|
11612
11619
|
"Bitcoin",
|
|
11613
11620
|
"Ethereum",
|
|
11614
11621
|
"Polkadot",
|
|
11615
11622
|
"Arbitrum",
|
|
11616
|
-
"Solana"
|
|
11623
|
+
"Solana",
|
|
11624
|
+
"Assethub"
|
|
11617
11625
|
]);
|
|
11618
11626
|
var Assets = arrayToMap([
|
|
11619
11627
|
"FLIP",
|
|
@@ -11701,6 +11709,27 @@ var assetConstants = {
|
|
|
11701
11709
|
name: "Solana USDC",
|
|
11702
11710
|
decimals: 6,
|
|
11703
11711
|
contractId: 10
|
|
11712
|
+
},
|
|
11713
|
+
[InternalAssets.HubDot]: {
|
|
11714
|
+
chain: Chains.Assethub,
|
|
11715
|
+
asset: Assets.DOT,
|
|
11716
|
+
name: "AssetHub DOT",
|
|
11717
|
+
decimals: 10,
|
|
11718
|
+
contractId: 11
|
|
11719
|
+
},
|
|
11720
|
+
[InternalAssets.HubUsdc]: {
|
|
11721
|
+
chain: Chains.Assethub,
|
|
11722
|
+
asset: Assets.USDC,
|
|
11723
|
+
name: "AssetHub USDC",
|
|
11724
|
+
decimals: 6,
|
|
11725
|
+
contractId: 12
|
|
11726
|
+
},
|
|
11727
|
+
[InternalAssets.HubUsdt]: {
|
|
11728
|
+
chain: Chains.Assethub,
|
|
11729
|
+
asset: Assets.USDT,
|
|
11730
|
+
name: "AssetHub USDT",
|
|
11731
|
+
decimals: 6,
|
|
11732
|
+
contractId: 13
|
|
11704
11733
|
}
|
|
11705
11734
|
};
|
|
11706
11735
|
var chainConstants = {
|
|
@@ -11748,6 +11777,16 @@ var chainConstants = {
|
|
|
11748
11777
|
gasAsset: InternalAssets.Sol,
|
|
11749
11778
|
contractId: 5,
|
|
11750
11779
|
blockTimeSeconds: (400 + 800) / 2 / 1e3
|
|
11780
|
+
},
|
|
11781
|
+
[Chains.Assethub]: {
|
|
11782
|
+
assets: [
|
|
11783
|
+
Assets.DOT,
|
|
11784
|
+
Assets.USDC,
|
|
11785
|
+
Assets.USDT
|
|
11786
|
+
],
|
|
11787
|
+
gasAsset: InternalAssets.HubDot,
|
|
11788
|
+
contractId: 6,
|
|
11789
|
+
blockTimeSeconds: 12
|
|
11751
11790
|
}
|
|
11752
11791
|
};
|
|
11753
11792
|
function isValidAssetAndChain(assetAndChain2) {
|
|
@@ -11789,6 +11828,11 @@ function getInternalAsset(asset2, assert3 = true) {
|
|
|
11789
11828
|
[Chains.Solana]: {
|
|
11790
11829
|
[Assets.SOL]: InternalAssets.Sol,
|
|
11791
11830
|
[Assets.USDC]: InternalAssets.SolUsdc
|
|
11831
|
+
},
|
|
11832
|
+
[Chains.Assethub]: {
|
|
11833
|
+
[Assets.DOT]: InternalAssets.HubDot,
|
|
11834
|
+
[Assets.USDC]: InternalAssets.HubUsdc,
|
|
11835
|
+
[Assets.USDT]: InternalAssets.HubUsdt
|
|
11792
11836
|
}
|
|
11793
11837
|
};
|
|
11794
11838
|
const chain2 = map[asset2.chain];
|
|
@@ -11862,35 +11906,40 @@ var validators = {
|
|
|
11862
11906
|
Ethereum: validateEvmAddress,
|
|
11863
11907
|
Polkadot: validatePolkadotAddress,
|
|
11864
11908
|
Arbitrum: validateEvmAddress,
|
|
11865
|
-
Solana: validateSolanaAddress
|
|
11909
|
+
Solana: validateSolanaAddress,
|
|
11910
|
+
Assethub: validatePolkadotAddress
|
|
11866
11911
|
},
|
|
11867
11912
|
perseverance: {
|
|
11868
11913
|
Bitcoin: validateBitcoinTestnetAddress,
|
|
11869
11914
|
Ethereum: validateEvmAddress,
|
|
11870
11915
|
Polkadot: validatePolkadotAddress,
|
|
11871
11916
|
Arbitrum: validateEvmAddress,
|
|
11872
|
-
Solana: validateSolanaAddress
|
|
11917
|
+
Solana: validateSolanaAddress,
|
|
11918
|
+
Assethub: validatePolkadotAddress
|
|
11873
11919
|
},
|
|
11874
11920
|
sisyphos: {
|
|
11875
11921
|
Bitcoin: validateBitcoinTestnetAddress,
|
|
11876
11922
|
Ethereum: validateEvmAddress,
|
|
11877
11923
|
Polkadot: validatePolkadotAddress,
|
|
11878
11924
|
Arbitrum: validateEvmAddress,
|
|
11879
|
-
Solana: validateSolanaAddress
|
|
11925
|
+
Solana: validateSolanaAddress,
|
|
11926
|
+
Assethub: validatePolkadotAddress
|
|
11880
11927
|
},
|
|
11881
11928
|
backspin: {
|
|
11882
11929
|
Bitcoin: validateBitcoinRegtestAddress,
|
|
11883
11930
|
Ethereum: validateEvmAddress,
|
|
11884
11931
|
Polkadot: validatePolkadotAddress,
|
|
11885
11932
|
Arbitrum: validateEvmAddress,
|
|
11886
|
-
Solana: validateSolanaAddress
|
|
11933
|
+
Solana: validateSolanaAddress,
|
|
11934
|
+
Assethub: validatePolkadotAddress
|
|
11887
11935
|
},
|
|
11888
11936
|
localnet: {
|
|
11889
11937
|
Bitcoin: validateBitcoinRegtestAddress,
|
|
11890
11938
|
Ethereum: validateEvmAddress,
|
|
11891
11939
|
Polkadot: validatePolkadotAddress,
|
|
11892
11940
|
Arbitrum: validateEvmAddress,
|
|
11893
|
-
Solana: validateSolanaAddress
|
|
11941
|
+
Solana: validateSolanaAddress,
|
|
11942
|
+
Assethub: validatePolkadotAddress
|
|
11894
11943
|
}
|
|
11895
11944
|
};
|
|
11896
11945
|
var assertValidAddress = /* @__PURE__ */ __name((chain2, address, network) => assert2(validators[network][chain2](address), `Address "${address}" is not a valid "${chain2}" address for "${network}"`), "assertValidAddress");
|
|
@@ -12045,7 +12094,8 @@ z.object({
|
|
|
12045
12094
|
destAsset: asset,
|
|
12046
12095
|
amount: numericString.transform((n) => BigInt(n)),
|
|
12047
12096
|
brokerCommissionBps: numericOrEmptyString.transform((v) => Number(v)).optional(),
|
|
12048
|
-
dcaEnabled: booleanString
|
|
12097
|
+
dcaEnabled: booleanString,
|
|
12098
|
+
autoSlippageEnabled: booleanString.optional()
|
|
12049
12099
|
}).transform((args, ctx) => {
|
|
12050
12100
|
const { srcAsset, destAsset } = getInternalAssets(args, false);
|
|
12051
12101
|
if (srcAsset === null) {
|
|
@@ -12073,7 +12123,8 @@ z.object({
|
|
|
12073
12123
|
destAsset,
|
|
12074
12124
|
amount: args.amount,
|
|
12075
12125
|
brokerCommissionBps: args.brokerCommissionBps,
|
|
12076
|
-
dcaEnabled: args.dcaEnabled
|
|
12126
|
+
dcaEnabled: args.dcaEnabled,
|
|
12127
|
+
autoSlippageEnabled: args.autoSlippageEnabled
|
|
12077
12128
|
};
|
|
12078
12129
|
});
|
|
12079
12130
|
var ccmParamsSchema = z.object({
|
|
@@ -12121,12 +12172,13 @@ z.object({
|
|
|
12121
12172
|
ccmParams: ccmParamsSchema.optional(),
|
|
12122
12173
|
maxBoostFeeBps: z.number().optional(),
|
|
12123
12174
|
srcAddress: z.string().optional(),
|
|
12124
|
-
fillOrKillParams
|
|
12175
|
+
fillOrKillParams,
|
|
12125
12176
|
dcaParams: dcaParams.optional(),
|
|
12126
12177
|
quote: z.object({
|
|
12127
12178
|
intermediateAmount: z.string().optional(),
|
|
12128
12179
|
egressAmount: z.string(),
|
|
12129
|
-
estimatedPrice: z.string()
|
|
12180
|
+
estimatedPrice: z.string(),
|
|
12181
|
+
recommendedSlippageTolerancePercent: z.number().optional()
|
|
12130
12182
|
}).optional()
|
|
12131
12183
|
}).superRefine(ensureDcaWithFok).transform(({ amount, ...rest }) => ({
|
|
12132
12184
|
...rest,
|
|
@@ -12167,7 +12219,7 @@ var validateAddressLength = /* @__PURE__ */ __name((chain2, address, type) => {
|
|
|
12167
12219
|
if ((chain2 === "Arbitrum" || chain2 === "Ethereum") && address.length !== 42) {
|
|
12168
12220
|
throw new Error(`Invalid ${type} address length`);
|
|
12169
12221
|
}
|
|
12170
|
-
if (chain2 === "Polkadot" && address.length !== 66) {
|
|
12222
|
+
if ((chain2 === "Polkadot" || chain2 === "Assethub") && address.length !== 66) {
|
|
12171
12223
|
throw new Error(`Invalid ${type} address length`);
|
|
12172
12224
|
}
|
|
12173
12225
|
}, "validateAddressLength");
|
|
@@ -13825,7 +13877,7 @@ var assertSignerIsConnectedToChain = /* @__PURE__ */ __name(async (opts, chain2)
|
|
|
13825
13877
|
|
|
13826
13878
|
// ../shared/src/vault/executeSwap.ts
|
|
13827
13879
|
var encodeAddress2 = /* @__PURE__ */ __name((chain2, address) => {
|
|
13828
|
-
if (chain2 === Chains.Polkadot) return bytes$1.bytesToHex(ss582__namespace.decode(dotAddress.parse(address)).data);
|
|
13880
|
+
if (chain2 === Chains.Polkadot || chain2 === Chains.Assethub) return bytes$1.bytesToHex(ss582__namespace.decode(dotAddress.parse(address)).data);
|
|
13829
13881
|
if (chain2 === Chains.Bitcoin) return `0x${Buffer.from(address).toString("hex")}`;
|
|
13830
13882
|
if (chain2 === Chains.Ethereum || chain2 === Chains.Arbitrum) return address;
|
|
13831
13883
|
if (chain2 === Chains.Solana) {
|
|
@@ -14048,7 +14100,7 @@ var getChainData = /* @__PURE__ */ __name((chain2, network, env) => ({
|
|
|
14048
14100
|
}), "getChainData");
|
|
14049
14101
|
|
|
14050
14102
|
// package.json
|
|
14051
|
-
var version = "1.
|
|
14103
|
+
var version = "1.8.0-assethub.2";
|
|
14052
14104
|
|
|
14053
14105
|
// src/swap/consts.ts
|
|
14054
14106
|
var CF_SDK_VERSION_HEADERS = {
|
|
@@ -14095,7 +14147,8 @@ var getQuoteV2 = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal }
|
|
|
14095
14147
|
...brokerCommissionBps && {
|
|
14096
14148
|
brokerCommissionBps: String(brokerCommissionBps)
|
|
14097
14149
|
},
|
|
14098
|
-
dcaEnabled: String(quoteRequest.dcaEnabled)
|
|
14150
|
+
dcaEnabled: String(quoteRequest.dcaEnabled),
|
|
14151
|
+
autoSlippageEnabled: String(quoteRequest.autoSlippageEnabled)
|
|
14099
14152
|
};
|
|
14100
14153
|
const { data } = await axios__default.default.get("/v2/quote", {
|
|
14101
14154
|
baseURL: baseUrl,
|
|
@@ -14145,6 +14198,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
14145
14198
|
__publicField(this, "stateChainEnvironmentCache");
|
|
14146
14199
|
__publicField(this, "supportedAssets");
|
|
14147
14200
|
__publicField(this, "dcaEnabled", false);
|
|
14201
|
+
__publicField(this, "autoSlippageEnabled", false);
|
|
14148
14202
|
const network = options.network ?? ChainflipNetworks.perseverance;
|
|
14149
14203
|
this.options = {
|
|
14150
14204
|
...options,
|
|
@@ -14166,6 +14220,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
14166
14220
|
]
|
|
14167
14221
|
});
|
|
14168
14222
|
this.dcaEnabled = options.enabledFeatures?.dca ?? false;
|
|
14223
|
+
this.autoSlippageEnabled = options.enabledFeatures?.experimentalRecommendedSlippage ?? false;
|
|
14169
14224
|
this.stateChainEnvironmentCache = new AsyncCacheMap({
|
|
14170
14225
|
fetch: /* @__PURE__ */ __name((_key) => getEnvironment(this.rpcConfig), "fetch"),
|
|
14171
14226
|
ttl: 6e4 * 10,
|
|
@@ -14218,7 +14273,8 @@ var _SwapSDK = class _SwapSDK {
|
|
|
14218
14273
|
return getQuoteV2(this.options.backendUrl, {
|
|
14219
14274
|
...remainingRequest,
|
|
14220
14275
|
brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps,
|
|
14221
|
-
dcaEnabled: this.dcaEnabled
|
|
14276
|
+
dcaEnabled: this.dcaEnabled,
|
|
14277
|
+
autoSlippageEnabled: this.autoSlippageEnabled
|
|
14222
14278
|
}, options);
|
|
14223
14279
|
}
|
|
14224
14280
|
/** @deprecated DEPRECATED(1.6) use requestDepositAddressV2() */
|
|
@@ -14260,6 +14316,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
14260
14316
|
} else {
|
|
14261
14317
|
assert2(!depositAddressRequest.brokerCommissionBps, "Broker commission is only supported only when initializing the SDK with a brokerUrl");
|
|
14262
14318
|
assert2(!depositAddressRequest.affiliateBrokers?.length, "Affiliate brokers are supported only when initializing the SDK with a brokerUrl");
|
|
14319
|
+
assert2(fillOrKillParams2, "Fill or kill parameters are required");
|
|
14263
14320
|
response = await this.trpc.openSwapDepositChannel.mutate({
|
|
14264
14321
|
...depositAddressRequest,
|
|
14265
14322
|
fillOrKillParams: fillOrKillParams2
|
|
@@ -14411,8 +14468,10 @@ var _SwapSDK = class _SwapSDK {
|
|
|
14411
14468
|
channelOpeningFee: result.channelOpeningFee
|
|
14412
14469
|
};
|
|
14413
14470
|
} else {
|
|
14471
|
+
assert2(depositAddressRequest.fillOrKillParams, "fill or kill params are required");
|
|
14414
14472
|
response = await this.trpc.openSwapDepositChannel.mutate({
|
|
14415
14473
|
...depositAddressRequest,
|
|
14474
|
+
fillOrKillParams: depositAddressRequest.fillOrKillParams,
|
|
14416
14475
|
quote
|
|
14417
14476
|
});
|
|
14418
14477
|
}
|
package/dist/swap.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __commonJS, __name, __export, __toESM, isString, InternalAssets, Chains, Assets, ChainflipNetworks, isValidAssetAndChain, getInternalAssets, __publicField, assert, getEnvironment, assetConstants, getSupportedAssets, getInternalAsset, isNotNullish, getAllBoostPoolsDepth, getAssetAndChain, readChainAssetValue, getVaultContractAddress, approve, chainConstants, getTokenContractAddress, isTestnet, getEvmChainId, checkAllowance, extractOverrides, Vault__factory } from './chunk-
|
|
2
|
-
export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-
|
|
1
|
+
import { __commonJS, __name, __export, __toESM, isString, InternalAssets, Chains, Assets, ChainflipNetworks, isValidAssetAndChain, getInternalAssets, __publicField, assert, getEnvironment, assetConstants, getSupportedAssets, getInternalAsset, isNotNullish, getAllBoostPoolsDepth, getAssetAndChain, readChainAssetValue, getVaultContractAddress, approve, chainConstants, getTokenContractAddress, isTestnet, getEvmChainId, checkAllowance, extractOverrides, Vault__factory } from './chunk-5BNVUJZY.mjs';
|
|
2
|
+
export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-5BNVUJZY.mjs';
|
|
3
3
|
import { assert as assert$1 } from '@chainflip/utils/assertion';
|
|
4
4
|
import { hexToBytes, bytesToHex } from '@chainflip/utils/bytes';
|
|
5
5
|
import { HttpClient } from '@chainflip/rpc';
|
|
@@ -11558,35 +11558,40 @@ var validators = {
|
|
|
11558
11558
|
Ethereum: validateEvmAddress,
|
|
11559
11559
|
Polkadot: validatePolkadotAddress,
|
|
11560
11560
|
Arbitrum: validateEvmAddress,
|
|
11561
|
-
Solana: validateSolanaAddress
|
|
11561
|
+
Solana: validateSolanaAddress,
|
|
11562
|
+
Assethub: validatePolkadotAddress
|
|
11562
11563
|
},
|
|
11563
11564
|
perseverance: {
|
|
11564
11565
|
Bitcoin: validateBitcoinTestnetAddress,
|
|
11565
11566
|
Ethereum: validateEvmAddress,
|
|
11566
11567
|
Polkadot: validatePolkadotAddress,
|
|
11567
11568
|
Arbitrum: validateEvmAddress,
|
|
11568
|
-
Solana: validateSolanaAddress
|
|
11569
|
+
Solana: validateSolanaAddress,
|
|
11570
|
+
Assethub: validatePolkadotAddress
|
|
11569
11571
|
},
|
|
11570
11572
|
sisyphos: {
|
|
11571
11573
|
Bitcoin: validateBitcoinTestnetAddress,
|
|
11572
11574
|
Ethereum: validateEvmAddress,
|
|
11573
11575
|
Polkadot: validatePolkadotAddress,
|
|
11574
11576
|
Arbitrum: validateEvmAddress,
|
|
11575
|
-
Solana: validateSolanaAddress
|
|
11577
|
+
Solana: validateSolanaAddress,
|
|
11578
|
+
Assethub: validatePolkadotAddress
|
|
11576
11579
|
},
|
|
11577
11580
|
backspin: {
|
|
11578
11581
|
Bitcoin: validateBitcoinRegtestAddress,
|
|
11579
11582
|
Ethereum: validateEvmAddress,
|
|
11580
11583
|
Polkadot: validatePolkadotAddress,
|
|
11581
11584
|
Arbitrum: validateEvmAddress,
|
|
11582
|
-
Solana: validateSolanaAddress
|
|
11585
|
+
Solana: validateSolanaAddress,
|
|
11586
|
+
Assethub: validatePolkadotAddress
|
|
11583
11587
|
},
|
|
11584
11588
|
localnet: {
|
|
11585
11589
|
Bitcoin: validateBitcoinRegtestAddress,
|
|
11586
11590
|
Ethereum: validateEvmAddress,
|
|
11587
11591
|
Polkadot: validatePolkadotAddress,
|
|
11588
11592
|
Arbitrum: validateEvmAddress,
|
|
11589
|
-
Solana: validateSolanaAddress
|
|
11593
|
+
Solana: validateSolanaAddress,
|
|
11594
|
+
Assethub: validatePolkadotAddress
|
|
11590
11595
|
}
|
|
11591
11596
|
};
|
|
11592
11597
|
var assertValidAddress = /* @__PURE__ */ __name((chain2, address, network) => assert(validators[network][chain2](address), `Address "${address}" is not a valid "${chain2}" address for "${network}"`), "assertValidAddress");
|
|
@@ -11741,7 +11746,8 @@ z.object({
|
|
|
11741
11746
|
destAsset: asset,
|
|
11742
11747
|
amount: numericString.transform((n) => BigInt(n)),
|
|
11743
11748
|
brokerCommissionBps: numericOrEmptyString.transform((v) => Number(v)).optional(),
|
|
11744
|
-
dcaEnabled: booleanString
|
|
11749
|
+
dcaEnabled: booleanString,
|
|
11750
|
+
autoSlippageEnabled: booleanString.optional()
|
|
11745
11751
|
}).transform((args, ctx) => {
|
|
11746
11752
|
const { srcAsset, destAsset } = getInternalAssets(args, false);
|
|
11747
11753
|
if (srcAsset === null) {
|
|
@@ -11769,7 +11775,8 @@ z.object({
|
|
|
11769
11775
|
destAsset,
|
|
11770
11776
|
amount: args.amount,
|
|
11771
11777
|
brokerCommissionBps: args.brokerCommissionBps,
|
|
11772
|
-
dcaEnabled: args.dcaEnabled
|
|
11778
|
+
dcaEnabled: args.dcaEnabled,
|
|
11779
|
+
autoSlippageEnabled: args.autoSlippageEnabled
|
|
11773
11780
|
};
|
|
11774
11781
|
});
|
|
11775
11782
|
var ccmParamsSchema = z.object({
|
|
@@ -11817,12 +11824,13 @@ z.object({
|
|
|
11817
11824
|
ccmParams: ccmParamsSchema.optional(),
|
|
11818
11825
|
maxBoostFeeBps: z.number().optional(),
|
|
11819
11826
|
srcAddress: z.string().optional(),
|
|
11820
|
-
fillOrKillParams
|
|
11827
|
+
fillOrKillParams,
|
|
11821
11828
|
dcaParams: dcaParams.optional(),
|
|
11822
11829
|
quote: z.object({
|
|
11823
11830
|
intermediateAmount: z.string().optional(),
|
|
11824
11831
|
egressAmount: z.string(),
|
|
11825
|
-
estimatedPrice: z.string()
|
|
11832
|
+
estimatedPrice: z.string(),
|
|
11833
|
+
recommendedSlippageTolerancePercent: z.number().optional()
|
|
11826
11834
|
}).optional()
|
|
11827
11835
|
}).superRefine(ensureDcaWithFok).transform(({ amount, ...rest }) => ({
|
|
11828
11836
|
...rest,
|
|
@@ -11863,7 +11871,7 @@ var validateAddressLength = /* @__PURE__ */ __name((chain2, address, type) => {
|
|
|
11863
11871
|
if ((chain2 === "Arbitrum" || chain2 === "Ethereum") && address.length !== 42) {
|
|
11864
11872
|
throw new Error(`Invalid ${type} address length`);
|
|
11865
11873
|
}
|
|
11866
|
-
if (chain2 === "Polkadot" && address.length !== 66) {
|
|
11874
|
+
if ((chain2 === "Polkadot" || chain2 === "Assethub") && address.length !== 66) {
|
|
11867
11875
|
throw new Error(`Invalid ${type} address length`);
|
|
11868
11876
|
}
|
|
11869
11877
|
}, "validateAddressLength");
|
|
@@ -12071,7 +12079,7 @@ var assertSignerIsConnectedToChain = /* @__PURE__ */ __name(async (opts, chain2)
|
|
|
12071
12079
|
|
|
12072
12080
|
// ../shared/src/vault/executeSwap.ts
|
|
12073
12081
|
var encodeAddress2 = /* @__PURE__ */ __name((chain2, address) => {
|
|
12074
|
-
if (chain2 === Chains.Polkadot) return bytesToHex(ss582.decode(dotAddress.parse(address)).data);
|
|
12082
|
+
if (chain2 === Chains.Polkadot || chain2 === Chains.Assethub) return bytesToHex(ss582.decode(dotAddress.parse(address)).data);
|
|
12075
12083
|
if (chain2 === Chains.Bitcoin) return `0x${Buffer.from(address).toString("hex")}`;
|
|
12076
12084
|
if (chain2 === Chains.Ethereum || chain2 === Chains.Arbitrum) return address;
|
|
12077
12085
|
if (chain2 === Chains.Solana) {
|
|
@@ -12294,7 +12302,7 @@ var getChainData = /* @__PURE__ */ __name((chain2, network, env) => ({
|
|
|
12294
12302
|
}), "getChainData");
|
|
12295
12303
|
|
|
12296
12304
|
// package.json
|
|
12297
|
-
var version = "1.
|
|
12305
|
+
var version = "1.8.0-assethub.2";
|
|
12298
12306
|
|
|
12299
12307
|
// src/swap/consts.ts
|
|
12300
12308
|
var CF_SDK_VERSION_HEADERS = {
|
|
@@ -12341,7 +12349,8 @@ var getQuoteV2 = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal }
|
|
|
12341
12349
|
...brokerCommissionBps && {
|
|
12342
12350
|
brokerCommissionBps: String(brokerCommissionBps)
|
|
12343
12351
|
},
|
|
12344
|
-
dcaEnabled: String(quoteRequest.dcaEnabled)
|
|
12352
|
+
dcaEnabled: String(quoteRequest.dcaEnabled),
|
|
12353
|
+
autoSlippageEnabled: String(quoteRequest.autoSlippageEnabled)
|
|
12345
12354
|
};
|
|
12346
12355
|
const { data } = await axios.get("/v2/quote", {
|
|
12347
12356
|
baseURL: baseUrl,
|
|
@@ -12391,6 +12400,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
12391
12400
|
__publicField(this, "stateChainEnvironmentCache");
|
|
12392
12401
|
__publicField(this, "supportedAssets");
|
|
12393
12402
|
__publicField(this, "dcaEnabled", false);
|
|
12403
|
+
__publicField(this, "autoSlippageEnabled", false);
|
|
12394
12404
|
const network = options.network ?? ChainflipNetworks.perseverance;
|
|
12395
12405
|
this.options = {
|
|
12396
12406
|
...options,
|
|
@@ -12412,6 +12422,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
12412
12422
|
]
|
|
12413
12423
|
});
|
|
12414
12424
|
this.dcaEnabled = options.enabledFeatures?.dca ?? false;
|
|
12425
|
+
this.autoSlippageEnabled = options.enabledFeatures?.experimentalRecommendedSlippage ?? false;
|
|
12415
12426
|
this.stateChainEnvironmentCache = new AsyncCacheMap({
|
|
12416
12427
|
fetch: /* @__PURE__ */ __name((_key) => getEnvironment(this.rpcConfig), "fetch"),
|
|
12417
12428
|
ttl: 6e4 * 10,
|
|
@@ -12464,7 +12475,8 @@ var _SwapSDK = class _SwapSDK {
|
|
|
12464
12475
|
return getQuoteV2(this.options.backendUrl, {
|
|
12465
12476
|
...remainingRequest,
|
|
12466
12477
|
brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps,
|
|
12467
|
-
dcaEnabled: this.dcaEnabled
|
|
12478
|
+
dcaEnabled: this.dcaEnabled,
|
|
12479
|
+
autoSlippageEnabled: this.autoSlippageEnabled
|
|
12468
12480
|
}, options);
|
|
12469
12481
|
}
|
|
12470
12482
|
/** @deprecated DEPRECATED(1.6) use requestDepositAddressV2() */
|
|
@@ -12506,6 +12518,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
12506
12518
|
} else {
|
|
12507
12519
|
assert(!depositAddressRequest.brokerCommissionBps, "Broker commission is only supported only when initializing the SDK with a brokerUrl");
|
|
12508
12520
|
assert(!depositAddressRequest.affiliateBrokers?.length, "Affiliate brokers are supported only when initializing the SDK with a brokerUrl");
|
|
12521
|
+
assert(fillOrKillParams2, "Fill or kill parameters are required");
|
|
12509
12522
|
response = await this.trpc.openSwapDepositChannel.mutate({
|
|
12510
12523
|
...depositAddressRequest,
|
|
12511
12524
|
fillOrKillParams: fillOrKillParams2
|
|
@@ -12657,8 +12670,10 @@ var _SwapSDK = class _SwapSDK {
|
|
|
12657
12670
|
channelOpeningFee: result.channelOpeningFee
|
|
12658
12671
|
};
|
|
12659
12672
|
} else {
|
|
12673
|
+
assert(depositAddressRequest.fillOrKillParams, "fill or kill params are required");
|
|
12660
12674
|
response = await this.trpc.openSwapDepositChannel.mutate({
|
|
12661
12675
|
...depositAddressRequest,
|
|
12676
|
+
fillOrKillParams: depositAddressRequest.fillOrKillParams,
|
|
12662
12677
|
quote
|
|
12663
12678
|
});
|
|
12664
12679
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainflip/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0-assethub.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./swap": {
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@chainflip/extrinsics": "^1.6.1",
|
|
45
|
-
"@chainflip/rpc": "^1.
|
|
46
|
-
"@chainflip/utils": "^
|
|
45
|
+
"@chainflip/rpc": "^1.8.0-assethub.1",
|
|
46
|
+
"@chainflip/utils": "^1.8.0-assethub.1",
|
|
47
47
|
"axios": "^1.7.7",
|
|
48
48
|
"bignumber.js": "^9.1.2",
|
|
49
49
|
"ethers": "^6.13.3"
|