@chainflip/sdk 2.3.0-dev.1 → 2.3.1
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/funding.js +1 -1
- package/dist/swap.cjs +23 -21
- package/dist/swap.d.cts +1 -0
- package/dist/swap.d.ts +1 -0
- package/dist/swap.js +25 -23
- package/package.json +5 -5
- /package/dist/{chunk-BHQT2774.js → chunk-6KPGKVRC.js} +0 -0
package/dist/funding.js
CHANGED
package/dist/swap.cjs
CHANGED
|
@@ -254,6 +254,7 @@ z3.z.object({
|
|
|
254
254
|
dcaV2Enabled: booleanString.default("false"),
|
|
255
255
|
isVaultSwap: booleanString.optional(),
|
|
256
256
|
isOnChain: booleanString.optional(),
|
|
257
|
+
brokerAccount: chainflipAddress.optional(),
|
|
257
258
|
brokerIdSs58: chainflipAddress.optional(),
|
|
258
259
|
expectedResponseTimeMs: numericString.transform((v) => Number(v)).optional()
|
|
259
260
|
}).transform((args, ctx) => {
|
|
@@ -319,7 +320,7 @@ z3.z.object({
|
|
|
319
320
|
dcaV2Enabled: args.dcaV2Enabled,
|
|
320
321
|
isVaultSwap: args.isVaultSwap,
|
|
321
322
|
isOnChain: args.isOnChain,
|
|
322
|
-
brokerIdSs58: args.brokerIdSs58,
|
|
323
|
+
brokerIdSs58: args.brokerIdSs58 ?? args.brokerAccount,
|
|
323
324
|
expectedResponseTimeMs: args.expectedResponseTimeMs
|
|
324
325
|
};
|
|
325
326
|
});
|
|
@@ -546,6 +547,21 @@ var getVaultSwapParameterEncodingRequestSchema = (network) => z3.z.object({
|
|
|
546
547
|
}
|
|
547
548
|
return { ...data, extraParams };
|
|
548
549
|
});
|
|
550
|
+
var formatBrokerDepositAddress = (chain2, address) => {
|
|
551
|
+
switch (chain2) {
|
|
552
|
+
case "Assethub":
|
|
553
|
+
return string.isHex(address) ? ss58__namespace.encode({ data: address, ss58Format: DOT_PREFIX }) : address;
|
|
554
|
+
case "Ethereum":
|
|
555
|
+
case "Arbitrum":
|
|
556
|
+
case "Bitcoin":
|
|
557
|
+
case "Solana":
|
|
558
|
+
case "Tron":
|
|
559
|
+
case "Bsc":
|
|
560
|
+
return address;
|
|
561
|
+
default:
|
|
562
|
+
return assertion.unreachable(chain2, "unexpected chain");
|
|
563
|
+
}
|
|
564
|
+
};
|
|
549
565
|
async function requestSwapDepositAddress(request, opts, chainflipNetwork) {
|
|
550
566
|
const client = new rpc.HttpClient(opts.url);
|
|
551
567
|
const params = getDepositAddressRequestSchema(chainflipNetwork).parse(request);
|
|
@@ -561,22 +577,7 @@ async function requestSwapDepositAddress(request, opts, chainflipNetwork) {
|
|
|
561
577
|
params.fillOrKillParams,
|
|
562
578
|
params.dcaParams
|
|
563
579
|
);
|
|
564
|
-
|
|
565
|
-
case "Assethub":
|
|
566
|
-
if (string.isHex(response.address)) {
|
|
567
|
-
response.address = ss58__namespace.encode({ data: response.address, ss58Format: DOT_PREFIX });
|
|
568
|
-
}
|
|
569
|
-
break;
|
|
570
|
-
case "Ethereum":
|
|
571
|
-
case "Arbitrum":
|
|
572
|
-
case "Bitcoin":
|
|
573
|
-
case "Solana":
|
|
574
|
-
case "Tron":
|
|
575
|
-
case "Bsc":
|
|
576
|
-
break;
|
|
577
|
-
default:
|
|
578
|
-
return assertion.unreachable(params.srcAsset, "unexpected chain");
|
|
579
|
-
}
|
|
580
|
+
response.address = formatBrokerDepositAddress(params.srcAsset.chain, response.address);
|
|
580
581
|
return transformKeysToCamelCase(response);
|
|
581
582
|
}
|
|
582
583
|
async function requestSwapParameterEncoding(request, opts, chainflipNetwork) {
|
|
@@ -967,7 +968,7 @@ var assetNames = {
|
|
|
967
968
|
Trx: "Tron",
|
|
968
969
|
TrxUsdt: "Tron USDT",
|
|
969
970
|
Bnb: "BNB",
|
|
970
|
-
BscUsdt: "
|
|
971
|
+
BscUsdt: "BNB Chain USDT",
|
|
971
972
|
Cbbtc: "Coinbase Wrapped BTC"
|
|
972
973
|
};
|
|
973
974
|
var getAssetData = (asset2, network, env) => {
|
|
@@ -999,7 +1000,7 @@ var getChainData = (chain2, network, env) => ({
|
|
|
999
1000
|
|
|
1000
1001
|
// package.json
|
|
1001
1002
|
var package_default = {
|
|
1002
|
-
version: "2.3.
|
|
1003
|
+
version: "2.3.1"};
|
|
1003
1004
|
|
|
1004
1005
|
// src/swap/consts.ts
|
|
1005
1006
|
var CF_SDK_VERSION_HEADERS = { "X-Chainflip-Sdk-Version": package_default.version };
|
|
@@ -1030,13 +1031,14 @@ var getQuoteV2 = async (baseUrl, quoteRequest, { signal }) => {
|
|
|
1030
1031
|
dcaV2Enabled: String(Boolean(quoteRequest.dcaV2Enabled)),
|
|
1031
1032
|
...quoteRequest.brokerAccount && { brokerIdSs58: quoteRequest.brokerAccount }
|
|
1032
1033
|
};
|
|
1033
|
-
const { data } = await axios__default.default.get("/v2/quote", {
|
|
1034
|
+
const { data, headers } = await axios__default.default.get("/v2/quote", {
|
|
1034
1035
|
baseURL: baseUrl,
|
|
1035
1036
|
params,
|
|
1036
1037
|
signal,
|
|
1037
1038
|
headers: CF_SDK_VERSION_HEADERS
|
|
1038
1039
|
});
|
|
1039
|
-
|
|
1040
|
+
const requestId = headers?.["x-request-id"];
|
|
1041
|
+
return { ...quoteRequest, quotes: data, ...requestId && { requestId } };
|
|
1040
1042
|
};
|
|
1041
1043
|
var getStatusV2 = async (baseUrl, { id }, { signal }) => {
|
|
1042
1044
|
const { data } = await axios__default.default.get(`/v2/swaps/${id}`, {
|
package/dist/swap.d.cts
CHANGED
|
@@ -362,6 +362,7 @@ interface QuoteRequest extends ChainsAndAssets {
|
|
|
362
362
|
}
|
|
363
363
|
interface QuoteResponseV2 extends QuoteRequest {
|
|
364
364
|
quotes: Quote[];
|
|
365
|
+
requestId?: string;
|
|
365
366
|
}
|
|
366
367
|
type FillOrKillParamsWithSlippage = Omit<FillOrKillParamsWithMinPrice, 'minPrice'> & {
|
|
367
368
|
slippageTolerancePercent: string | number;
|
package/dist/swap.d.ts
CHANGED
|
@@ -362,6 +362,7 @@ interface QuoteRequest extends ChainsAndAssets {
|
|
|
362
362
|
}
|
|
363
363
|
interface QuoteResponseV2 extends QuoteRequest {
|
|
364
364
|
quotes: Quote[];
|
|
365
|
+
requestId?: string;
|
|
365
366
|
}
|
|
366
367
|
type FillOrKillParamsWithSlippage = Omit<FillOrKillParamsWithMinPrice, 'minPrice'> & {
|
|
367
368
|
slippageTolerancePercent: string | number;
|
package/dist/swap.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEnvironment, assert, getEvmChainId, getAllSupplyPoolsDepth, getAllBoostPoolsDepth, SUPPLY_POOL_BOOST_FEE_BPS, isNotNullish, ADDRESSES } from './chunk-
|
|
1
|
+
import { getEnvironment, assert, getEvmChainId, getAllSupplyPoolsDepth, getAllBoostPoolsDepth, SUPPLY_POOL_BOOST_FEE_BPS, isNotNullish, ADDRESSES } from './chunk-6KPGKVRC.js';
|
|
2
2
|
import { unreachable } from '@chainflip/utils/assertion';
|
|
3
3
|
import { chainflipChains, assetSymbols, isValidAssetAndChain, chainflipAssets, getInternalAssets, assetConstants, isChainflipAsset, internalAssetToRpcAsset, getInternalAsset, chainflipNetworks, readAssetValue, anyAssetConstants } from '@chainflip/utils/chainflip';
|
|
4
4
|
export { getInternalAsset as getChainflipId } from '@chainflip/utils/chainflip';
|
|
@@ -9,7 +9,7 @@ import { isValidSolanaAddress } from '@chainflip/solana';
|
|
|
9
9
|
import * as ss58 from '@chainflip/utils/ss58';
|
|
10
10
|
import { isValidTronAddress } from '@chainflip/utils/tron';
|
|
11
11
|
import * as bitcoin from '@chainflip/bitcoin';
|
|
12
|
-
import {
|
|
12
|
+
import { toUpperCase, isHex } from '@chainflip/utils/string';
|
|
13
13
|
import * as ethers from 'ethers';
|
|
14
14
|
import { hexEncodeNumber } from '@chainflip/utils/number';
|
|
15
15
|
import { HttpClient } from '@chainflip/rpc';
|
|
@@ -213,6 +213,7 @@ z.object({
|
|
|
213
213
|
dcaV2Enabled: booleanString.default("false"),
|
|
214
214
|
isVaultSwap: booleanString.optional(),
|
|
215
215
|
isOnChain: booleanString.optional(),
|
|
216
|
+
brokerAccount: chainflipAddress.optional(),
|
|
216
217
|
brokerIdSs58: chainflipAddress.optional(),
|
|
217
218
|
expectedResponseTimeMs: numericString.transform((v) => Number(v)).optional()
|
|
218
219
|
}).transform((args, ctx) => {
|
|
@@ -278,7 +279,7 @@ z.object({
|
|
|
278
279
|
dcaV2Enabled: args.dcaV2Enabled,
|
|
279
280
|
isVaultSwap: args.isVaultSwap,
|
|
280
281
|
isOnChain: args.isOnChain,
|
|
281
|
-
brokerIdSs58: args.brokerIdSs58,
|
|
282
|
+
brokerIdSs58: args.brokerIdSs58 ?? args.brokerAccount,
|
|
282
283
|
expectedResponseTimeMs: args.expectedResponseTimeMs
|
|
283
284
|
};
|
|
284
285
|
});
|
|
@@ -505,6 +506,21 @@ var getVaultSwapParameterEncodingRequestSchema = (network) => z.object({
|
|
|
505
506
|
}
|
|
506
507
|
return { ...data, extraParams };
|
|
507
508
|
});
|
|
509
|
+
var formatBrokerDepositAddress = (chain2, address) => {
|
|
510
|
+
switch (chain2) {
|
|
511
|
+
case "Assethub":
|
|
512
|
+
return isHex(address) ? ss58.encode({ data: address, ss58Format: DOT_PREFIX }) : address;
|
|
513
|
+
case "Ethereum":
|
|
514
|
+
case "Arbitrum":
|
|
515
|
+
case "Bitcoin":
|
|
516
|
+
case "Solana":
|
|
517
|
+
case "Tron":
|
|
518
|
+
case "Bsc":
|
|
519
|
+
return address;
|
|
520
|
+
default:
|
|
521
|
+
return unreachable(chain2, "unexpected chain");
|
|
522
|
+
}
|
|
523
|
+
};
|
|
508
524
|
async function requestSwapDepositAddress(request, opts, chainflipNetwork) {
|
|
509
525
|
const client = new HttpClient(opts.url);
|
|
510
526
|
const params = getDepositAddressRequestSchema(chainflipNetwork).parse(request);
|
|
@@ -520,22 +536,7 @@ async function requestSwapDepositAddress(request, opts, chainflipNetwork) {
|
|
|
520
536
|
params.fillOrKillParams,
|
|
521
537
|
params.dcaParams
|
|
522
538
|
);
|
|
523
|
-
|
|
524
|
-
case "Assethub":
|
|
525
|
-
if (isHex(response.address)) {
|
|
526
|
-
response.address = ss58.encode({ data: response.address, ss58Format: DOT_PREFIX });
|
|
527
|
-
}
|
|
528
|
-
break;
|
|
529
|
-
case "Ethereum":
|
|
530
|
-
case "Arbitrum":
|
|
531
|
-
case "Bitcoin":
|
|
532
|
-
case "Solana":
|
|
533
|
-
case "Tron":
|
|
534
|
-
case "Bsc":
|
|
535
|
-
break;
|
|
536
|
-
default:
|
|
537
|
-
return unreachable(params.srcAsset, "unexpected chain");
|
|
538
|
-
}
|
|
539
|
+
response.address = formatBrokerDepositAddress(params.srcAsset.chain, response.address);
|
|
539
540
|
return transformKeysToCamelCase(response);
|
|
540
541
|
}
|
|
541
542
|
async function requestSwapParameterEncoding(request, opts, chainflipNetwork) {
|
|
@@ -782,7 +783,7 @@ var assetNames = {
|
|
|
782
783
|
Trx: "Tron",
|
|
783
784
|
TrxUsdt: "Tron USDT",
|
|
784
785
|
Bnb: "BNB",
|
|
785
|
-
BscUsdt: "
|
|
786
|
+
BscUsdt: "BNB Chain USDT",
|
|
786
787
|
Cbbtc: "Coinbase Wrapped BTC"
|
|
787
788
|
};
|
|
788
789
|
var getAssetData = (asset2, network, env) => {
|
|
@@ -814,7 +815,7 @@ var getChainData = (chain2, network, env) => ({
|
|
|
814
815
|
|
|
815
816
|
// package.json
|
|
816
817
|
var package_default = {
|
|
817
|
-
version: "2.3.
|
|
818
|
+
version: "2.3.1"};
|
|
818
819
|
|
|
819
820
|
// src/swap/consts.ts
|
|
820
821
|
var CF_SDK_VERSION_HEADERS = { "X-Chainflip-Sdk-Version": package_default.version };
|
|
@@ -845,13 +846,14 @@ var getQuoteV2 = async (baseUrl, quoteRequest, { signal }) => {
|
|
|
845
846
|
dcaV2Enabled: String(Boolean(quoteRequest.dcaV2Enabled)),
|
|
846
847
|
...quoteRequest.brokerAccount && { brokerIdSs58: quoteRequest.brokerAccount }
|
|
847
848
|
};
|
|
848
|
-
const { data } = await axios.get("/v2/quote", {
|
|
849
|
+
const { data, headers } = await axios.get("/v2/quote", {
|
|
849
850
|
baseURL: baseUrl,
|
|
850
851
|
params,
|
|
851
852
|
signal,
|
|
852
853
|
headers: CF_SDK_VERSION_HEADERS
|
|
853
854
|
});
|
|
854
|
-
|
|
855
|
+
const requestId = headers?.["x-request-id"];
|
|
856
|
+
return { ...quoteRequest, quotes: data, ...requestId && { requestId } };
|
|
855
857
|
};
|
|
856
858
|
var getStatusV2 = async (baseUrl, { id }, { signal }) => {
|
|
857
859
|
const { data } = await axios.get(`/v2/swaps/${id}`, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainflip/sdk",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./swap": {
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@chainflip/bitcoin": "2.3.
|
|
60
|
-
"@chainflip/rpc": "2.3.
|
|
61
|
-
"@chainflip/solana": "2.3.
|
|
62
|
-
"@chainflip/utils": "2.3.
|
|
59
|
+
"@chainflip/bitcoin": "2.3.1",
|
|
60
|
+
"@chainflip/rpc": "2.3.3",
|
|
61
|
+
"@chainflip/solana": "2.3.1",
|
|
62
|
+
"@chainflip/utils": "2.3.3",
|
|
63
63
|
"@ts-rest/core": "^3.52.1",
|
|
64
64
|
"axios": "^1.15.0",
|
|
65
65
|
"bignumber.js": "^9.3.0",
|
|
File without changes
|