@chainflip/sdk 1.6.0-alpha.5 → 1.6.0-alpha.7
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-EHDVKR7F.mjs → chunk-35BXEUA4.mjs} +3 -0
- package/dist/funding.js +3 -0
- package/dist/funding.mjs +1 -1
- package/dist/swap.d.mts +19 -5
- package/dist/swap.d.ts +19 -5
- package/dist/swap.js +37 -1
- package/dist/swap.mjs +36 -3
- package/package.json +2 -2
|
@@ -274,6 +274,9 @@ createRequest("state_getMetadata");
|
|
|
274
274
|
var getSupportedAssets = createRequest("cf_supported_assets");
|
|
275
275
|
createRequest("state_getRuntimeVersion");
|
|
276
276
|
createRequest("chain_getBlockHash");
|
|
277
|
+
createRequest("cf_pool_depth");
|
|
278
|
+
createRequest("cf_accounts");
|
|
279
|
+
createRequest("cf_account_info");
|
|
277
280
|
var getAllBoostPoolsDepth = transform(createRequest("cf_boost_pools_depth"), (result) => result.map(({ chain, asset, ...rest }) => ({
|
|
278
281
|
asset: getInternalAsset({
|
|
279
282
|
chain,
|
package/dist/funding.js
CHANGED
|
@@ -1083,6 +1083,9 @@ createRequest("state_getMetadata");
|
|
|
1083
1083
|
createRequest("cf_supported_assets");
|
|
1084
1084
|
createRequest("state_getRuntimeVersion");
|
|
1085
1085
|
createRequest("chain_getBlockHash");
|
|
1086
|
+
createRequest("cf_pool_depth");
|
|
1087
|
+
createRequest("cf_accounts");
|
|
1088
|
+
createRequest("cf_account_info");
|
|
1086
1089
|
transform(createRequest("cf_boost_pools_depth"), (result) => result.map(({ chain, asset, ...rest }) => ({
|
|
1087
1090
|
asset: getInternalAsset({
|
|
1088
1091
|
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-35BXEUA4.mjs';
|
|
2
2
|
|
|
3
3
|
// ../shared/src/stateChainGateway/utils.ts
|
|
4
4
|
var getStateChainGateway = /* @__PURE__ */ __name((networkOpts) => {
|
package/dist/swap.d.mts
CHANGED
|
@@ -64,6 +64,7 @@ type Fee<T> = {
|
|
|
64
64
|
};
|
|
65
65
|
type SwapFee = Fee<'NETWORK' | 'INGRESS' | 'EGRESS' | 'BROKER' | 'BOOST'>;
|
|
66
66
|
type PoolFee = Fee<'LIQUIDITY'>;
|
|
67
|
+
type PaidFee = SwapFee | PoolFee;
|
|
67
68
|
type PoolInfo = {
|
|
68
69
|
baseAsset: AssetAndChain;
|
|
69
70
|
quoteAsset: AssetAndChain;
|
|
@@ -83,6 +84,10 @@ type BoostedQuoteDetails = QuoteDetails & {
|
|
|
83
84
|
};
|
|
84
85
|
type QuoteQueryResponse = QuoteDetails & {
|
|
85
86
|
boostQuote?: BoostedQuoteDetails;
|
|
87
|
+
dcaParams?: {
|
|
88
|
+
numberOfChunks: number;
|
|
89
|
+
chunkInterval: number;
|
|
90
|
+
};
|
|
86
91
|
};
|
|
87
92
|
|
|
88
93
|
interface ExecuteSwapParams {
|
|
@@ -133,6 +138,9 @@ interface QuoteRequest extends ChainsAndAssets {
|
|
|
133
138
|
interface QuoteResponse extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affiliateBrokers'> {
|
|
134
139
|
quote: QuoteQueryResponse;
|
|
135
140
|
}
|
|
141
|
+
interface QuoteResponseV2 extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affiliateBrokers'> {
|
|
142
|
+
quotes: QuoteQueryResponse[];
|
|
143
|
+
}
|
|
136
144
|
interface DepositAddressRequest extends QuoteRequest {
|
|
137
145
|
destAddress: string;
|
|
138
146
|
ccmParams?: CcmParams;
|
|
@@ -354,6 +362,7 @@ interface Boost {
|
|
|
354
362
|
skippedBlockIndex: string | undefined;
|
|
355
363
|
}
|
|
356
364
|
interface DepositChannelFields {
|
|
365
|
+
id: string;
|
|
357
366
|
createdAt: number;
|
|
358
367
|
brokerCommissionBps: number;
|
|
359
368
|
depositAddress: string;
|
|
@@ -367,12 +376,14 @@ interface DepositChannelFields {
|
|
|
367
376
|
dcaParams: DcaParameters | undefined;
|
|
368
377
|
}
|
|
369
378
|
interface DepositFields {
|
|
370
|
-
amount: string
|
|
379
|
+
amount: string;
|
|
371
380
|
txRef: string | undefined;
|
|
372
381
|
txConfirmations: number | undefined;
|
|
373
382
|
receivedAt: number | undefined;
|
|
374
383
|
receivedBlockIndex: string | undefined;
|
|
375
384
|
failure: Failure | undefined;
|
|
385
|
+
failedAt: number | undefined;
|
|
386
|
+
failedBlockIndex: string | undefined;
|
|
376
387
|
}
|
|
377
388
|
interface SwapChunk {
|
|
378
389
|
swapInputAmount: string;
|
|
@@ -384,7 +395,7 @@ interface SwapChunk {
|
|
|
384
395
|
retryCount: number;
|
|
385
396
|
latestSwapRescheduledAt: number | undefined;
|
|
386
397
|
latestSwapRescheduledBlockIndex: number | undefined;
|
|
387
|
-
fees:
|
|
398
|
+
fees: PaidFee[];
|
|
388
399
|
isDca: false;
|
|
389
400
|
}
|
|
390
401
|
interface SwapFields {
|
|
@@ -395,7 +406,7 @@ interface SwapFields {
|
|
|
395
406
|
lastExecutedChunk: SwapChunk | undefined;
|
|
396
407
|
currentChunk: SwapChunk;
|
|
397
408
|
type: SwapType;
|
|
398
|
-
fees:
|
|
409
|
+
fees: PaidFee[];
|
|
399
410
|
}
|
|
400
411
|
interface EgressFields {
|
|
401
412
|
amount: string;
|
|
@@ -420,7 +431,7 @@ interface SwapStatusResponseCommonFields extends ChainsAndAssets {
|
|
|
420
431
|
interface VaultSwapCommonFields extends Exclude<SwapStatusResponseCommonFields, 'boost'> {
|
|
421
432
|
}
|
|
422
433
|
interface ReceivingVaultSwap extends VaultSwapCommonFields {
|
|
423
|
-
deposit:
|
|
434
|
+
deposit: DepositFields;
|
|
424
435
|
}
|
|
425
436
|
interface SwappingVaultSwap extends ReceivingVaultSwap {
|
|
426
437
|
swap: Exclude<SwapChunk, 'latestSwapRescheduledAt' | 'latestSwapRescheduledBlockIndex'> | undefined;
|
|
@@ -444,6 +455,8 @@ interface Sending extends Receiving {
|
|
|
444
455
|
refundEgress: EgressFields | undefined;
|
|
445
456
|
}
|
|
446
457
|
type SwapState = ({
|
|
458
|
+
state: 'WAITING';
|
|
459
|
+
} & DepositChannel) | ({
|
|
447
460
|
state: 'RECEIVING';
|
|
448
461
|
} & Receiving) | ({
|
|
449
462
|
state: 'SWAPPING';
|
|
@@ -488,6 +501,7 @@ declare class SwapSDK {
|
|
|
488
501
|
private getBoostPoolsDepth;
|
|
489
502
|
getAssets(chain?: Chain): Promise<AssetData[]>;
|
|
490
503
|
getQuote(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponse>;
|
|
504
|
+
getQuoteV2(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponseV2>;
|
|
491
505
|
requestDepositAddress(depositAddressRequest: DepositAddressRequest): Promise<DepositAddressResponse>;
|
|
492
506
|
getStatus(swapStatusRequest: SwapStatusRequest, options?: RequestOptions): Promise<SwapStatusResponse>;
|
|
493
507
|
getStatusV2(swapStatusRequest: SwapStatusRequest, options?: RequestOptions): Promise<SwapStatusResponseV2>;
|
|
@@ -513,4 +527,4 @@ declare class SwapSDK {
|
|
|
513
527
|
}): Promise<BoostPoolDepth[]>;
|
|
514
528
|
}
|
|
515
529
|
|
|
516
|
-
export { Asset, type AssetData, type BoostPoolDepth, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type ChainsAndAssets, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type DepositAddressStatusResponseV2, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type SwapStatusResponseV2, type VaultSwapStatusResponse, type VaultSwapStatusResponseV2 };
|
|
530
|
+
export { Asset, type AssetData, type BoostPoolDepth, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type ChainsAndAssets, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type DepositAddressStatusResponseV2, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, type QuoteResponseV2, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type SwapStatusResponseV2, type VaultSwapStatusResponse, type VaultSwapStatusResponseV2 };
|
package/dist/swap.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ type Fee<T> = {
|
|
|
64
64
|
};
|
|
65
65
|
type SwapFee = Fee<'NETWORK' | 'INGRESS' | 'EGRESS' | 'BROKER' | 'BOOST'>;
|
|
66
66
|
type PoolFee = Fee<'LIQUIDITY'>;
|
|
67
|
+
type PaidFee = SwapFee | PoolFee;
|
|
67
68
|
type PoolInfo = {
|
|
68
69
|
baseAsset: AssetAndChain;
|
|
69
70
|
quoteAsset: AssetAndChain;
|
|
@@ -83,6 +84,10 @@ type BoostedQuoteDetails = QuoteDetails & {
|
|
|
83
84
|
};
|
|
84
85
|
type QuoteQueryResponse = QuoteDetails & {
|
|
85
86
|
boostQuote?: BoostedQuoteDetails;
|
|
87
|
+
dcaParams?: {
|
|
88
|
+
numberOfChunks: number;
|
|
89
|
+
chunkInterval: number;
|
|
90
|
+
};
|
|
86
91
|
};
|
|
87
92
|
|
|
88
93
|
interface ExecuteSwapParams {
|
|
@@ -133,6 +138,9 @@ interface QuoteRequest extends ChainsAndAssets {
|
|
|
133
138
|
interface QuoteResponse extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affiliateBrokers'> {
|
|
134
139
|
quote: QuoteQueryResponse;
|
|
135
140
|
}
|
|
141
|
+
interface QuoteResponseV2 extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affiliateBrokers'> {
|
|
142
|
+
quotes: QuoteQueryResponse[];
|
|
143
|
+
}
|
|
136
144
|
interface DepositAddressRequest extends QuoteRequest {
|
|
137
145
|
destAddress: string;
|
|
138
146
|
ccmParams?: CcmParams;
|
|
@@ -354,6 +362,7 @@ interface Boost {
|
|
|
354
362
|
skippedBlockIndex: string | undefined;
|
|
355
363
|
}
|
|
356
364
|
interface DepositChannelFields {
|
|
365
|
+
id: string;
|
|
357
366
|
createdAt: number;
|
|
358
367
|
brokerCommissionBps: number;
|
|
359
368
|
depositAddress: string;
|
|
@@ -367,12 +376,14 @@ interface DepositChannelFields {
|
|
|
367
376
|
dcaParams: DcaParameters | undefined;
|
|
368
377
|
}
|
|
369
378
|
interface DepositFields {
|
|
370
|
-
amount: string
|
|
379
|
+
amount: string;
|
|
371
380
|
txRef: string | undefined;
|
|
372
381
|
txConfirmations: number | undefined;
|
|
373
382
|
receivedAt: number | undefined;
|
|
374
383
|
receivedBlockIndex: string | undefined;
|
|
375
384
|
failure: Failure | undefined;
|
|
385
|
+
failedAt: number | undefined;
|
|
386
|
+
failedBlockIndex: string | undefined;
|
|
376
387
|
}
|
|
377
388
|
interface SwapChunk {
|
|
378
389
|
swapInputAmount: string;
|
|
@@ -384,7 +395,7 @@ interface SwapChunk {
|
|
|
384
395
|
retryCount: number;
|
|
385
396
|
latestSwapRescheduledAt: number | undefined;
|
|
386
397
|
latestSwapRescheduledBlockIndex: number | undefined;
|
|
387
|
-
fees:
|
|
398
|
+
fees: PaidFee[];
|
|
388
399
|
isDca: false;
|
|
389
400
|
}
|
|
390
401
|
interface SwapFields {
|
|
@@ -395,7 +406,7 @@ interface SwapFields {
|
|
|
395
406
|
lastExecutedChunk: SwapChunk | undefined;
|
|
396
407
|
currentChunk: SwapChunk;
|
|
397
408
|
type: SwapType;
|
|
398
|
-
fees:
|
|
409
|
+
fees: PaidFee[];
|
|
399
410
|
}
|
|
400
411
|
interface EgressFields {
|
|
401
412
|
amount: string;
|
|
@@ -420,7 +431,7 @@ interface SwapStatusResponseCommonFields extends ChainsAndAssets {
|
|
|
420
431
|
interface VaultSwapCommonFields extends Exclude<SwapStatusResponseCommonFields, 'boost'> {
|
|
421
432
|
}
|
|
422
433
|
interface ReceivingVaultSwap extends VaultSwapCommonFields {
|
|
423
|
-
deposit:
|
|
434
|
+
deposit: DepositFields;
|
|
424
435
|
}
|
|
425
436
|
interface SwappingVaultSwap extends ReceivingVaultSwap {
|
|
426
437
|
swap: Exclude<SwapChunk, 'latestSwapRescheduledAt' | 'latestSwapRescheduledBlockIndex'> | undefined;
|
|
@@ -444,6 +455,8 @@ interface Sending extends Receiving {
|
|
|
444
455
|
refundEgress: EgressFields | undefined;
|
|
445
456
|
}
|
|
446
457
|
type SwapState = ({
|
|
458
|
+
state: 'WAITING';
|
|
459
|
+
} & DepositChannel) | ({
|
|
447
460
|
state: 'RECEIVING';
|
|
448
461
|
} & Receiving) | ({
|
|
449
462
|
state: 'SWAPPING';
|
|
@@ -488,6 +501,7 @@ declare class SwapSDK {
|
|
|
488
501
|
private getBoostPoolsDepth;
|
|
489
502
|
getAssets(chain?: Chain): Promise<AssetData[]>;
|
|
490
503
|
getQuote(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponse>;
|
|
504
|
+
getQuoteV2(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponseV2>;
|
|
491
505
|
requestDepositAddress(depositAddressRequest: DepositAddressRequest): Promise<DepositAddressResponse>;
|
|
492
506
|
getStatus(swapStatusRequest: SwapStatusRequest, options?: RequestOptions): Promise<SwapStatusResponse>;
|
|
493
507
|
getStatusV2(swapStatusRequest: SwapStatusRequest, options?: RequestOptions): Promise<SwapStatusResponseV2>;
|
|
@@ -513,4 +527,4 @@ declare class SwapSDK {
|
|
|
513
527
|
}): Promise<BoostPoolDepth[]>;
|
|
514
528
|
}
|
|
515
529
|
|
|
516
|
-
export { Asset, type AssetData, type BoostPoolDepth, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type ChainsAndAssets, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type DepositAddressStatusResponseV2, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type SwapStatusResponseV2, type VaultSwapStatusResponse, type VaultSwapStatusResponseV2 };
|
|
530
|
+
export { Asset, type AssetData, type BoostPoolDepth, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type ChainsAndAssets, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type DepositAddressStatusResponseV2, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, type QuoteResponseV2, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type SwapStatusResponseV2, type VaultSwapStatusResponse, type VaultSwapStatusResponseV2 };
|
package/dist/swap.js
CHANGED
|
@@ -8421,6 +8421,9 @@ createRequest("state_getMetadata");
|
|
|
8421
8421
|
var getSupportedAssets = createRequest("cf_supported_assets");
|
|
8422
8422
|
createRequest("state_getRuntimeVersion");
|
|
8423
8423
|
createRequest("chain_getBlockHash");
|
|
8424
|
+
createRequest("cf_pool_depth");
|
|
8425
|
+
createRequest("cf_accounts");
|
|
8426
|
+
createRequest("cf_account_info");
|
|
8424
8427
|
var getAllBoostPoolsDepth = transform(createRequest("cf_boost_pools_depth"), (result) => result.map(({ chain: chain2, asset: asset2, ...rest }) => ({
|
|
8425
8428
|
asset: getInternalAsset({
|
|
8426
8429
|
chain: chain2,
|
|
@@ -10029,7 +10032,7 @@ var getChainData = /* @__PURE__ */ __name((chain2, network, env) => ({
|
|
|
10029
10032
|
}), "getChainData");
|
|
10030
10033
|
|
|
10031
10034
|
// package.json
|
|
10032
|
-
var version = "1.6.0-alpha.
|
|
10035
|
+
var version = "1.6.0-alpha.7";
|
|
10033
10036
|
|
|
10034
10037
|
// src/swap/consts.ts
|
|
10035
10038
|
var CF_SDK_VERSION_HEADERS = {
|
|
@@ -10064,6 +10067,29 @@ var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal })
|
|
|
10064
10067
|
quote: data
|
|
10065
10068
|
};
|
|
10066
10069
|
}, "getQuote");
|
|
10070
|
+
var getQuoteV2 = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal }) => {
|
|
10071
|
+
const { brokerCommissionBps, ...returnedRequestData } = quoteRequest;
|
|
10072
|
+
const params = {
|
|
10073
|
+
amount: returnedRequestData.amount,
|
|
10074
|
+
srcChain: returnedRequestData.srcChain,
|
|
10075
|
+
srcAsset: returnedRequestData.srcAsset,
|
|
10076
|
+
destChain: returnedRequestData.destChain,
|
|
10077
|
+
destAsset: returnedRequestData.destAsset,
|
|
10078
|
+
...brokerCommissionBps && {
|
|
10079
|
+
brokerCommissionBps: String(brokerCommissionBps)
|
|
10080
|
+
}
|
|
10081
|
+
};
|
|
10082
|
+
const { data } = await axios__default.default.get("/v2/quote", {
|
|
10083
|
+
baseURL: baseUrl,
|
|
10084
|
+
params,
|
|
10085
|
+
signal,
|
|
10086
|
+
headers: CF_SDK_VERSION_HEADERS
|
|
10087
|
+
});
|
|
10088
|
+
return {
|
|
10089
|
+
...returnedRequestData,
|
|
10090
|
+
quotes: data
|
|
10091
|
+
};
|
|
10092
|
+
}, "getQuoteV2");
|
|
10067
10093
|
var getStatus = /* @__PURE__ */ __name(async (baseUrl, { id }, { signal }) => {
|
|
10068
10094
|
const { data } = await axios__default.default.get(`/swaps/${id}`, {
|
|
10069
10095
|
baseURL: baseUrl,
|
|
@@ -10140,6 +10166,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
10140
10166
|
]);
|
|
10141
10167
|
return supportedAssets.map((asset2) => getAssetData(asset2, this.options.network, env)).filter((asset2) => !chain2 || asset2.chain === chain2);
|
|
10142
10168
|
}
|
|
10169
|
+
/** @deprecated DEPRECATED(1.6) use getQuoteV2() */
|
|
10143
10170
|
getQuote(quoteRequest, options = {}) {
|
|
10144
10171
|
const { brokerCommissionBps, affiliateBrokers, ...remainingRequest } = quoteRequest;
|
|
10145
10172
|
const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
|
|
@@ -10149,6 +10176,15 @@ var _SwapSDK = class _SwapSDK {
|
|
|
10149
10176
|
brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps
|
|
10150
10177
|
}, options);
|
|
10151
10178
|
}
|
|
10179
|
+
getQuoteV2(quoteRequest, options = {}) {
|
|
10180
|
+
const { brokerCommissionBps, affiliateBrokers, ...remainingRequest } = quoteRequest;
|
|
10181
|
+
const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
|
|
10182
|
+
const affiliateBrokerCommissionBps = affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
|
|
10183
|
+
return getQuoteV2(this.options.backendUrl, {
|
|
10184
|
+
...remainingRequest,
|
|
10185
|
+
brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps
|
|
10186
|
+
}, options);
|
|
10187
|
+
}
|
|
10152
10188
|
async requestDepositAddress(depositAddressRequest) {
|
|
10153
10189
|
const { srcChain, srcAsset, amount, destChain, destAsset, brokerCommissionBps, affiliateBrokers } = depositAddressRequest;
|
|
10154
10190
|
await this.validateSwapAmount({
|
package/dist/swap.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __name, isString, InternalAssets, Chains, Assets, ChainflipNetworks, isValidAssetAndChain, getInternalAssets, __publicField, assetConstants, getEnvironment, getSupportedAssets, getInternalAsset, isNotNullish, getAllBoostPoolsDepth, assert, getAssetAndChain, readChainAssetValue, getVaultContractAddress, approve, getTokenContractAddress, isTestnet, getEvmChainId, chainConstants, checkAllowance, extractOverrides, Vault__factory } from './chunk-
|
|
2
|
-
export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-
|
|
1
|
+
import { __name, isString, InternalAssets, Chains, Assets, ChainflipNetworks, isValidAssetAndChain, getInternalAssets, __publicField, assetConstants, getEnvironment, getSupportedAssets, getInternalAsset, isNotNullish, getAllBoostPoolsDepth, assert, getAssetAndChain, readChainAssetValue, getVaultContractAddress, approve, getTokenContractAddress, isTestnet, getEvmChainId, chainConstants, checkAllowance, extractOverrides, Vault__factory } from './chunk-35BXEUA4.mjs';
|
|
2
|
+
export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-35BXEUA4.mjs';
|
|
3
3
|
import { HttpClient } from '@chainflip/rpc';
|
|
4
4
|
import * as ss582 from '@chainflip/utils/ss58';
|
|
5
5
|
import * as base58 from '@chainflip/utils/base58';
|
|
@@ -8307,7 +8307,7 @@ var getChainData = /* @__PURE__ */ __name((chain2, network, env) => ({
|
|
|
8307
8307
|
}), "getChainData");
|
|
8308
8308
|
|
|
8309
8309
|
// package.json
|
|
8310
|
-
var version = "1.6.0-alpha.
|
|
8310
|
+
var version = "1.6.0-alpha.7";
|
|
8311
8311
|
|
|
8312
8312
|
// src/swap/consts.ts
|
|
8313
8313
|
var CF_SDK_VERSION_HEADERS = {
|
|
@@ -8342,6 +8342,29 @@ var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal })
|
|
|
8342
8342
|
quote: data
|
|
8343
8343
|
};
|
|
8344
8344
|
}, "getQuote");
|
|
8345
|
+
var getQuoteV2 = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal }) => {
|
|
8346
|
+
const { brokerCommissionBps, ...returnedRequestData } = quoteRequest;
|
|
8347
|
+
const params = {
|
|
8348
|
+
amount: returnedRequestData.amount,
|
|
8349
|
+
srcChain: returnedRequestData.srcChain,
|
|
8350
|
+
srcAsset: returnedRequestData.srcAsset,
|
|
8351
|
+
destChain: returnedRequestData.destChain,
|
|
8352
|
+
destAsset: returnedRequestData.destAsset,
|
|
8353
|
+
...brokerCommissionBps && {
|
|
8354
|
+
brokerCommissionBps: String(brokerCommissionBps)
|
|
8355
|
+
}
|
|
8356
|
+
};
|
|
8357
|
+
const { data } = await axios.get("/v2/quote", {
|
|
8358
|
+
baseURL: baseUrl,
|
|
8359
|
+
params,
|
|
8360
|
+
signal,
|
|
8361
|
+
headers: CF_SDK_VERSION_HEADERS
|
|
8362
|
+
});
|
|
8363
|
+
return {
|
|
8364
|
+
...returnedRequestData,
|
|
8365
|
+
quotes: data
|
|
8366
|
+
};
|
|
8367
|
+
}, "getQuoteV2");
|
|
8345
8368
|
var getStatus = /* @__PURE__ */ __name(async (baseUrl, { id }, { signal }) => {
|
|
8346
8369
|
const { data } = await axios.get(`/swaps/${id}`, {
|
|
8347
8370
|
baseURL: baseUrl,
|
|
@@ -8418,6 +8441,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
8418
8441
|
]);
|
|
8419
8442
|
return supportedAssets.map((asset2) => getAssetData(asset2, this.options.network, env)).filter((asset2) => !chain2 || asset2.chain === chain2);
|
|
8420
8443
|
}
|
|
8444
|
+
/** @deprecated DEPRECATED(1.6) use getQuoteV2() */
|
|
8421
8445
|
getQuote(quoteRequest, options = {}) {
|
|
8422
8446
|
const { brokerCommissionBps, affiliateBrokers, ...remainingRequest } = quoteRequest;
|
|
8423
8447
|
const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
|
|
@@ -8427,6 +8451,15 @@ var _SwapSDK = class _SwapSDK {
|
|
|
8427
8451
|
brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps
|
|
8428
8452
|
}, options);
|
|
8429
8453
|
}
|
|
8454
|
+
getQuoteV2(quoteRequest, options = {}) {
|
|
8455
|
+
const { brokerCommissionBps, affiliateBrokers, ...remainingRequest } = quoteRequest;
|
|
8456
|
+
const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
|
|
8457
|
+
const affiliateBrokerCommissionBps = affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
|
|
8458
|
+
return getQuoteV2(this.options.backendUrl, {
|
|
8459
|
+
...remainingRequest,
|
|
8460
|
+
brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps
|
|
8461
|
+
}, options);
|
|
8462
|
+
}
|
|
8430
8463
|
async requestDepositAddress(depositAddressRequest) {
|
|
8431
8464
|
const { srcChain, srcAsset, amount, destChain, destAsset, brokerCommissionBps, affiliateBrokers } = depositAddressRequest;
|
|
8432
8465
|
await this.validateSwapAmount({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainflip/sdk",
|
|
3
|
-
"version": "1.6.0-alpha.
|
|
3
|
+
"version": "1.6.0-alpha.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./swap": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@chainflip/rpc": "^1.6.
|
|
44
|
+
"@chainflip/rpc": "^1.6.6",
|
|
45
45
|
"@chainflip/utils": "^0.4.0",
|
|
46
46
|
"axios": "^1.7.7",
|
|
47
47
|
"ethers": "^6.13.2"
|