@chainflip/sdk 1.6.7-rc.1 → 1.6.7-rc.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/swap.d.mts +7 -1
- package/dist/swap.d.ts +7 -1
- package/dist/swap.js +35 -3
- package/dist/swap.mjs +36 -4
- package/package.json +2 -2
package/dist/swap.d.mts
CHANGED
|
@@ -84,8 +84,8 @@ type BoostedQuoteDetails = {
|
|
|
84
84
|
interface BaseQuoteDetails {
|
|
85
85
|
srcAsset: AssetAndChain;
|
|
86
86
|
destAsset: AssetAndChain;
|
|
87
|
-
intermediateAmount?: string;
|
|
88
87
|
depositAmount: string;
|
|
88
|
+
intermediateAmount?: string;
|
|
89
89
|
egressAmount: string;
|
|
90
90
|
includedFees: SwapFee[];
|
|
91
91
|
poolInfo: PoolInfo[];
|
|
@@ -534,6 +534,12 @@ declare class SwapSDK {
|
|
|
534
534
|
signer?: Signer;
|
|
535
535
|
}): Promise<TransactionHash | null>;
|
|
536
536
|
private validateSwapAmount;
|
|
537
|
+
approveAndExecuteSwap(params: ExecuteSwapParams, txOpts?: Omit<TransactionOptions, 'nonce'> & {
|
|
538
|
+
signer?: Signer;
|
|
539
|
+
}): Promise<{
|
|
540
|
+
approveTxRef: TransactionHash | null;
|
|
541
|
+
swapTxRef: TransactionHash | null;
|
|
542
|
+
}>;
|
|
537
543
|
getSwapLimits(): Promise<{
|
|
538
544
|
minimumSwapAmounts: ChainAssetMap<bigint>;
|
|
539
545
|
maximumSwapAmounts: ChainAssetMap<bigint | null>;
|
package/dist/swap.d.ts
CHANGED
|
@@ -84,8 +84,8 @@ type BoostedQuoteDetails = {
|
|
|
84
84
|
interface BaseQuoteDetails {
|
|
85
85
|
srcAsset: AssetAndChain;
|
|
86
86
|
destAsset: AssetAndChain;
|
|
87
|
-
intermediateAmount?: string;
|
|
88
87
|
depositAmount: string;
|
|
88
|
+
intermediateAmount?: string;
|
|
89
89
|
egressAmount: string;
|
|
90
90
|
includedFees: SwapFee[];
|
|
91
91
|
poolInfo: PoolInfo[];
|
|
@@ -534,6 +534,12 @@ declare class SwapSDK {
|
|
|
534
534
|
signer?: Signer;
|
|
535
535
|
}): Promise<TransactionHash | null>;
|
|
536
536
|
private validateSwapAmount;
|
|
537
|
+
approveAndExecuteSwap(params: ExecuteSwapParams, txOpts?: Omit<TransactionOptions, 'nonce'> & {
|
|
538
|
+
signer?: Signer;
|
|
539
|
+
}): Promise<{
|
|
540
|
+
approveTxRef: TransactionHash | null;
|
|
541
|
+
swapTxRef: TransactionHash | null;
|
|
542
|
+
}>;
|
|
537
543
|
getSwapLimits(): Promise<{
|
|
538
544
|
minimumSwapAmounts: ChainAssetMap<bigint>;
|
|
539
545
|
maximumSwapAmounts: ChainAssetMap<bigint | null>;
|
package/dist/swap.js
CHANGED
|
@@ -12122,7 +12122,12 @@ z.object({
|
|
|
12122
12122
|
maxBoostFeeBps: z.number().optional(),
|
|
12123
12123
|
srcAddress: z.string().optional(),
|
|
12124
12124
|
fillOrKillParams: fillOrKillParams.optional(),
|
|
12125
|
-
dcaParams: dcaParams.optional()
|
|
12125
|
+
dcaParams: dcaParams.optional(),
|
|
12126
|
+
quote: z.object({
|
|
12127
|
+
intermediateAmount: z.string().optional(),
|
|
12128
|
+
egressAmount: z.string(),
|
|
12129
|
+
estimatedPrice: z.string()
|
|
12130
|
+
}).optional()
|
|
12126
12131
|
}).superRefine(ensureDcaWithFok).transform(({ amount, ...rest }) => ({
|
|
12127
12132
|
...rest,
|
|
12128
12133
|
expectedDepositAmount: amount
|
|
@@ -14043,7 +14048,7 @@ var getChainData = /* @__PURE__ */ __name((chain2, network, env) => ({
|
|
|
14043
14048
|
}), "getChainData");
|
|
14044
14049
|
|
|
14045
14050
|
// package.json
|
|
14046
|
-
var version = "1.6.7-rc.
|
|
14051
|
+
var version = "1.6.7-rc.2";
|
|
14047
14052
|
|
|
14048
14053
|
// src/swap/consts.ts
|
|
14049
14054
|
var CF_SDK_VERSION_HEADERS = {
|
|
@@ -14311,6 +14316,30 @@ var _SwapSDK = class _SwapSDK {
|
|
|
14311
14316
|
const result = validateSwapAmount(stateChainEnv, internalAsset, amount);
|
|
14312
14317
|
if (!result.success) throw new Error(result.reason);
|
|
14313
14318
|
}
|
|
14319
|
+
async approveAndExecuteSwap(params, txOpts = {}) {
|
|
14320
|
+
const { srcChain, srcAsset } = params;
|
|
14321
|
+
const signer = txOpts.signer ?? this.options.signer;
|
|
14322
|
+
assert2(signer, "No signer provided");
|
|
14323
|
+
const internalAsset = getInternalAsset({
|
|
14324
|
+
chain: srcChain,
|
|
14325
|
+
asset: srcAsset
|
|
14326
|
+
});
|
|
14327
|
+
let approveTxRef = null;
|
|
14328
|
+
if (!isGasAsset(internalAsset)) {
|
|
14329
|
+
approveTxRef = await this.approveVault(params, {
|
|
14330
|
+
...txOpts,
|
|
14331
|
+
nonce: void 0
|
|
14332
|
+
});
|
|
14333
|
+
}
|
|
14334
|
+
const swapTxRef = await this.executeSwap(params, {
|
|
14335
|
+
...txOpts,
|
|
14336
|
+
nonce: void 0
|
|
14337
|
+
});
|
|
14338
|
+
return {
|
|
14339
|
+
approveTxRef,
|
|
14340
|
+
swapTxRef
|
|
14341
|
+
};
|
|
14342
|
+
}
|
|
14314
14343
|
async getSwapLimits() {
|
|
14315
14344
|
const { swapping: { maximumSwapAmounts }, ingressEgress: { minimumDepositAmounts } } = await this.getStateChainEnvironment();
|
|
14316
14345
|
return {
|
|
@@ -14381,7 +14410,10 @@ var _SwapSDK = class _SwapSDK {
|
|
|
14381
14410
|
channelOpeningFee: result.channelOpeningFee
|
|
14382
14411
|
};
|
|
14383
14412
|
} else {
|
|
14384
|
-
response = await this.trpc.openSwapDepositChannel.mutate(
|
|
14413
|
+
response = await this.trpc.openSwapDepositChannel.mutate({
|
|
14414
|
+
...depositAddressRequest,
|
|
14415
|
+
quote
|
|
14416
|
+
});
|
|
14385
14417
|
}
|
|
14386
14418
|
return {
|
|
14387
14419
|
...depositAddressRequest,
|
package/dist/swap.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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, getTokenContractAddress, isTestnet, getEvmChainId,
|
|
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-G76RI3QK.mjs';
|
|
2
2
|
export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-G76RI3QK.mjs';
|
|
3
3
|
import { assert as assert$1 } from '@chainflip/utils/assertion';
|
|
4
4
|
import { hexToBytes, bytesToHex } from '@chainflip/utils/bytes';
|
|
@@ -11818,7 +11818,12 @@ z.object({
|
|
|
11818
11818
|
maxBoostFeeBps: z.number().optional(),
|
|
11819
11819
|
srcAddress: z.string().optional(),
|
|
11820
11820
|
fillOrKillParams: fillOrKillParams.optional(),
|
|
11821
|
-
dcaParams: dcaParams.optional()
|
|
11821
|
+
dcaParams: dcaParams.optional(),
|
|
11822
|
+
quote: z.object({
|
|
11823
|
+
intermediateAmount: z.string().optional(),
|
|
11824
|
+
egressAmount: z.string(),
|
|
11825
|
+
estimatedPrice: z.string()
|
|
11826
|
+
}).optional()
|
|
11822
11827
|
}).superRefine(ensureDcaWithFok).transform(({ amount, ...rest }) => ({
|
|
11823
11828
|
...rest,
|
|
11824
11829
|
expectedDepositAmount: amount
|
|
@@ -12289,7 +12294,7 @@ var getChainData = /* @__PURE__ */ __name((chain2, network, env) => ({
|
|
|
12289
12294
|
}), "getChainData");
|
|
12290
12295
|
|
|
12291
12296
|
// package.json
|
|
12292
|
-
var version = "1.6.7-rc.
|
|
12297
|
+
var version = "1.6.7-rc.2";
|
|
12293
12298
|
|
|
12294
12299
|
// src/swap/consts.ts
|
|
12295
12300
|
var CF_SDK_VERSION_HEADERS = {
|
|
@@ -12557,6 +12562,30 @@ var _SwapSDK = class _SwapSDK {
|
|
|
12557
12562
|
const result = validateSwapAmount(stateChainEnv, internalAsset, amount);
|
|
12558
12563
|
if (!result.success) throw new Error(result.reason);
|
|
12559
12564
|
}
|
|
12565
|
+
async approveAndExecuteSwap(params, txOpts = {}) {
|
|
12566
|
+
const { srcChain, srcAsset } = params;
|
|
12567
|
+
const signer = txOpts.signer ?? this.options.signer;
|
|
12568
|
+
assert(signer, "No signer provided");
|
|
12569
|
+
const internalAsset = getInternalAsset({
|
|
12570
|
+
chain: srcChain,
|
|
12571
|
+
asset: srcAsset
|
|
12572
|
+
});
|
|
12573
|
+
let approveTxRef = null;
|
|
12574
|
+
if (!isGasAsset(internalAsset)) {
|
|
12575
|
+
approveTxRef = await this.approveVault(params, {
|
|
12576
|
+
...txOpts,
|
|
12577
|
+
nonce: void 0
|
|
12578
|
+
});
|
|
12579
|
+
}
|
|
12580
|
+
const swapTxRef = await this.executeSwap(params, {
|
|
12581
|
+
...txOpts,
|
|
12582
|
+
nonce: void 0
|
|
12583
|
+
});
|
|
12584
|
+
return {
|
|
12585
|
+
approveTxRef,
|
|
12586
|
+
swapTxRef
|
|
12587
|
+
};
|
|
12588
|
+
}
|
|
12560
12589
|
async getSwapLimits() {
|
|
12561
12590
|
const { swapping: { maximumSwapAmounts }, ingressEgress: { minimumDepositAmounts } } = await this.getStateChainEnvironment();
|
|
12562
12591
|
return {
|
|
@@ -12627,7 +12656,10 @@ var _SwapSDK = class _SwapSDK {
|
|
|
12627
12656
|
channelOpeningFee: result.channelOpeningFee
|
|
12628
12657
|
};
|
|
12629
12658
|
} else {
|
|
12630
|
-
response = await this.trpc.openSwapDepositChannel.mutate(
|
|
12659
|
+
response = await this.trpc.openSwapDepositChannel.mutate({
|
|
12660
|
+
...depositAddressRequest,
|
|
12661
|
+
quote
|
|
12662
|
+
});
|
|
12631
12663
|
}
|
|
12632
12664
|
return {
|
|
12633
12665
|
...depositAddressRequest,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainflip/sdk",
|
|
3
|
-
"version": "1.6.7-rc.
|
|
3
|
+
"version": "1.6.7-rc.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./swap": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"ethers": "^6.13.3"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"tsup": "^8.
|
|
52
|
+
"tsup": "^8.3.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"test": "jest --forceExit",
|