@chainflip/sdk 2.2.0-alpha.2 → 2.2.0-alpha.4

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.
@@ -34,6 +34,7 @@ var getAllBoostPoolsDepth = transform(
34
34
  ...rest
35
35
  }))
36
36
  );
37
+ var getSupplyPoolsDepth = createRequest(`cf_lending_pools`);
37
38
 
38
39
  // ../shared/src/consts.ts
39
40
  var ETHEREUM_EVM_CHAIN_ID = {
@@ -133,4 +134,4 @@ var ADDRESSES = {
133
134
  }
134
135
  };
135
136
 
136
- export { ADDRESSES, assert, getAllBoostPoolsDepth, getEnvironment, getEvmChainId, getFundingEnvironment, isNotNullish };
137
+ export { ADDRESSES, assert, getAllBoostPoolsDepth, getEnvironment, getEvmChainId, getFundingEnvironment, getSupplyPoolsDepth, isNotNullish };
package/dist/funding.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getFundingEnvironment, assert, ADDRESSES } from './chunk-Y4JK5EIC.js';
1
+ import { getFundingEnvironment, assert, ADDRESSES } from './chunk-7JDRGJ3P.js';
2
2
  import { Interface, Contract } from 'ethers';
3
3
 
4
4
  var _abi = [
package/dist/swap.cjs CHANGED
@@ -6,9 +6,9 @@ var core = require('@ts-rest/core');
6
6
  var z3 = require('zod');
7
7
  var solana = require('@chainflip/solana');
8
8
  var ss58 = require('@chainflip/utils/ss58');
9
+ var tron = require('@chainflip/utils/tron');
9
10
  var bitcoin = require('@chainflip/bitcoin');
10
11
  var string = require('@chainflip/utils/string');
11
- var tron = require('@chainflip/utils/tron');
12
12
  var ethers = require('ethers');
13
13
  var number = require('@chainflip/utils/number');
14
14
  var rpc = require('@chainflip/rpc');
@@ -62,6 +62,9 @@ var chainflipAddress = z3.z.string().refine(
62
62
  z3.z.string().refine(solana.isValidSolanaAddress, (address) => ({
63
63
  message: `${address} is not a valid Solana address`
64
64
  }));
65
+ var tronAddress = z3.z.string().refine(tron.isValidTronAddress, (address) => ({
66
+ message: `${address} is not a valid Tron address`
67
+ }));
65
68
  var u128 = z3.z.union([z3.z.number(), numericString, hexString]).transform((arg) => BigInt(arg));
66
69
  var unsignedInteger = z3.z.union([u128, z3.z.number().transform((n) => BigInt(n))]);
67
70
  var chain = z3.z.enum(chainflip.chainflipChains);
@@ -92,9 +95,9 @@ var EncodedVaultSwapData = z3.z.discriminatedUnion("chain", [
92
95
  chain: z3.z.literal("Tron"),
93
96
  calldata: hexString,
94
97
  value: z3.z.string(),
95
- to: hexString,
98
+ to: tronAddress,
96
99
  note: hexString,
97
- sourceTokenAddress: hexString.optional()
100
+ sourceTokenAddress: tronAddress.optional()
98
101
  }),
99
102
  z3.z.object({
100
103
  chain: z3.z.literal("Solana"),
@@ -780,6 +783,7 @@ var getAllBoostPoolsDepth = transform(
780
783
  ...rest
781
784
  }))
782
785
  );
786
+ var getSupplyPoolsDepth = createRequest(`cf_lending_pools`);
783
787
  var MAX_SWAP_AMOUNT = 2n ** 128n - 1n;
784
788
  var validateSwapAmount = (env, asset2, amount) => {
785
789
  const minimumAmount = chainflip.readAssetValue(env.ingressEgress.minimumDepositAmounts, asset2);
@@ -961,7 +965,7 @@ var getChainData = (chain2, network, env) => ({
961
965
 
962
966
  // package.json
963
967
  var package_default = {
964
- version: "2.2.0-alpha.2"};
968
+ version: "2.2.0-alpha.4"};
965
969
 
966
970
  // src/swap/consts.ts
967
971
  var CF_SDK_VERSION_HEADERS = { "X-Chainflip-Sdk-Version": package_default.version };
@@ -1091,6 +1095,9 @@ var SwapSDK = class {
1091
1095
  }
1092
1096
  }).map((a) => a.asset);
1093
1097
  }
1098
+ async getBtcSupplyPoolDepth() {
1099
+ return getSupplyPoolsDepth(this.rpcConfig, chainflip.internalAssetToRpcAsset.Btc);
1100
+ }
1094
1101
  async getBoostPoolsDepth() {
1095
1102
  return getAllBoostPoolsDepth(this.rpcConfig);
1096
1103
  }
@@ -1162,20 +1169,33 @@ var SwapSDK = class {
1162
1169
  return channelOpeningFees;
1163
1170
  }
1164
1171
  async getBoostLiquidity(params = {}) {
1165
- let poolsDepth = await this.getBoostPoolsDepth();
1166
- if ("chain" in params && "asset" in params) {
1167
- const { chain: chain2, asset: asset2 } = params;
1168
- const internalAsset = chainflip.getInternalAsset({ chain: chain2, asset: asset2 });
1169
- poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.asset === internalAsset).sort((a, b) => b.tier - a.tier);
1172
+ if (params.feeTierBps && params.feeTierBps !== 5) {
1173
+ throw new Error("Unsupported fee tier. Only 5 bps is supported starting from version 2.2.");
1170
1174
  }
1171
- if ("feeTierBps" in params && params.feeTierBps !== void 0) {
1172
- poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.tier === params.feeTierBps);
1175
+ const internalAsset = "chain" in params && "asset" in params ? chainflip.getInternalAsset(params) : null;
1176
+ const fetchBtcSupplyPool = !internalAsset || internalAsset === "Btc";
1177
+ let [poolsDepth, btcSupplyPoolDepth] = await Promise.all([
1178
+ this.getBoostPoolsDepth(),
1179
+ fetchBtcSupplyPool ? this.getBtcSupplyPoolDepth() : Promise.resolve([])
1180
+ ]);
1181
+ if (internalAsset) {
1182
+ poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.asset === internalAsset).sort((a, b) => b.tier - a.tier);
1173
1183
  }
1174
- return poolsDepth.map((depth) => ({
1175
- availableAmount: depth.availableAmount,
1176
- feeTierBps: depth.tier,
1177
- ...chainflip.internalAssetToRpcAsset[depth.asset]
1178
- }));
1184
+ return [
1185
+ ...poolsDepth.map((depth) => ({
1186
+ availableAmount: depth.availableAmount,
1187
+ feeTierBps: depth.tier,
1188
+ poolType: "LEGACY_BOOST",
1189
+ ...chainflip.internalAssetToRpcAsset[depth.asset]
1190
+ })),
1191
+ ...btcSupplyPoolDepth.map((pool) => ({
1192
+ availableAmount: pool.availableAmount,
1193
+ feeTierBps: 5,
1194
+ // supply pools boosts cost 5bps fixed
1195
+ poolType: "SUPPLY",
1196
+ ...pool.asset
1197
+ }))
1198
+ ];
1179
1199
  }
1180
1200
  async requestDepositAddressV2({
1181
1201
  quote,
package/dist/swap.d.cts CHANGED
@@ -374,6 +374,7 @@ type BoostPoolDepth = {
374
374
  availableAmount: bigint;
375
375
  asset: AssetSymbol;
376
376
  chain: ChainflipChain;
377
+ poolType: 'LEGACY_BOOST' | 'SUPPLY';
377
378
  };
378
379
 
379
380
  type ChunkFailureReason = 'PriceImpactLimit' | 'MinPriceViolation' | 'OraclePriceSlippageExceeded' | 'OraclePriceStale' | 'PredecessorSwapFailure' | 'SafeModeActive';
@@ -665,6 +666,7 @@ declare class SwapSDK {
665
666
  getChains(sourceChain?: ChainflipChain, type?: AssetState): Promise<ChainData[]>;
666
667
  private getStateChainEnvironment;
667
668
  private getSupportedAssets;
669
+ private getBtcSupplyPoolDepth;
668
670
  private getBoostPoolsDepth;
669
671
  getAssets(chain?: ChainflipChain, type?: AssetState): Promise<AssetData[]>;
670
672
  protected shouldTakeCommission(): boolean;
@@ -679,8 +681,10 @@ declare class SwapSDK {
679
681
  getRequiredBlockConfirmations(): Promise<ChainMap<number | null>>;
680
682
  getChannelOpeningFees(): Promise<ChainMap<bigint>>;
681
683
  getBoostLiquidity(params?: {
684
+ /** @deprecated DEPRECATED(2.2): Only value supported moving forward is 5 bps */
682
685
  feeTierBps?: number;
683
686
  } | ({
687
+ /** @deprecated DEPRECATED(2.2): Only value supported moving forward is 5 bps */
684
688
  feeTierBps?: number;
685
689
  } & UncheckedAssetAndChain)): Promise<BoostPoolDepth[]>;
686
690
  requestDepositAddressV2({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps: brokerCommissionBpsParam, }: DepositAddressRequestV2): Promise<DepositAddressResponseV2>;
package/dist/swap.d.ts CHANGED
@@ -374,6 +374,7 @@ type BoostPoolDepth = {
374
374
  availableAmount: bigint;
375
375
  asset: AssetSymbol;
376
376
  chain: ChainflipChain;
377
+ poolType: 'LEGACY_BOOST' | 'SUPPLY';
377
378
  };
378
379
 
379
380
  type ChunkFailureReason = 'PriceImpactLimit' | 'MinPriceViolation' | 'OraclePriceSlippageExceeded' | 'OraclePriceStale' | 'PredecessorSwapFailure' | 'SafeModeActive';
@@ -665,6 +666,7 @@ declare class SwapSDK {
665
666
  getChains(sourceChain?: ChainflipChain, type?: AssetState): Promise<ChainData[]>;
666
667
  private getStateChainEnvironment;
667
668
  private getSupportedAssets;
669
+ private getBtcSupplyPoolDepth;
668
670
  private getBoostPoolsDepth;
669
671
  getAssets(chain?: ChainflipChain, type?: AssetState): Promise<AssetData[]>;
670
672
  protected shouldTakeCommission(): boolean;
@@ -679,8 +681,10 @@ declare class SwapSDK {
679
681
  getRequiredBlockConfirmations(): Promise<ChainMap<number | null>>;
680
682
  getChannelOpeningFees(): Promise<ChainMap<bigint>>;
681
683
  getBoostLiquidity(params?: {
684
+ /** @deprecated DEPRECATED(2.2): Only value supported moving forward is 5 bps */
682
685
  feeTierBps?: number;
683
686
  } | ({
687
+ /** @deprecated DEPRECATED(2.2): Only value supported moving forward is 5 bps */
684
688
  feeTierBps?: number;
685
689
  } & UncheckedAssetAndChain)): Promise<BoostPoolDepth[]>;
686
690
  requestDepositAddressV2({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps: brokerCommissionBpsParam, }: DepositAddressRequestV2): Promise<DepositAddressResponseV2>;
package/dist/swap.js CHANGED
@@ -1,14 +1,14 @@
1
- import { getEnvironment, assert, getEvmChainId, getAllBoostPoolsDepth, isNotNullish, ADDRESSES } from './chunk-Y4JK5EIC.js';
1
+ import { getEnvironment, assert, getEvmChainId, getSupplyPoolsDepth, getAllBoostPoolsDepth, isNotNullish, ADDRESSES } from './chunk-7JDRGJ3P.js';
2
2
  import { unreachable } from '@chainflip/utils/assertion';
3
- import { chainflipChains, assetSymbols, isValidAssetAndChain, chainflipAssets, getInternalAssets, assetConstants, getInternalAsset, internalAssetToRpcAsset, chainflipNetworks, readAssetValue, anyAssetConstants } from '@chainflip/utils/chainflip';
3
+ import { chainflipChains, assetSymbols, isValidAssetAndChain, chainflipAssets, getInternalAssets, assetConstants, internalAssetToRpcAsset, getInternalAsset, chainflipNetworks, readAssetValue, anyAssetConstants } from '@chainflip/utils/chainflip';
4
4
  export { getInternalAsset as getChainflipId } from '@chainflip/utils/chainflip';
5
5
  import { initContract, initClient } from '@ts-rest/core';
6
6
  import z3, { z } from 'zod';
7
7
  import { isValidSolanaAddress } from '@chainflip/solana';
8
8
  import * as ss58 from '@chainflip/utils/ss58';
9
+ import { isValidTronAddress } from '@chainflip/utils/tron';
9
10
  import * as bitcoin from '@chainflip/bitcoin';
10
11
  import { isHex, toUpperCase } from '@chainflip/utils/string';
11
- import { isValidTronAddress } from '@chainflip/utils/tron';
12
12
  import * as ethers from 'ethers';
13
13
  import { hexEncodeNumber } from '@chainflip/utils/number';
14
14
  import { HttpClient } from '@chainflip/rpc';
@@ -34,6 +34,9 @@ var chainflipAddress = z.string().refine(
34
34
  z.string().refine(isValidSolanaAddress, (address) => ({
35
35
  message: `${address} is not a valid Solana address`
36
36
  }));
37
+ var tronAddress = z.string().refine(isValidTronAddress, (address) => ({
38
+ message: `${address} is not a valid Tron address`
39
+ }));
37
40
  var u128 = z.union([z.number(), numericString, hexString]).transform((arg) => BigInt(arg));
38
41
  var unsignedInteger = z.union([u128, z.number().transform((n) => BigInt(n))]);
39
42
  var chain = z.enum(chainflipChains);
@@ -64,9 +67,9 @@ var EncodedVaultSwapData = z.discriminatedUnion("chain", [
64
67
  chain: z.literal("Tron"),
65
68
  calldata: hexString,
66
69
  value: z.string(),
67
- to: hexString,
70
+ to: tronAddress,
68
71
  note: hexString,
69
- sourceTokenAddress: hexString.optional()
72
+ sourceTokenAddress: tronAddress.optional()
70
73
  }),
71
74
  z.object({
72
75
  chain: z.literal("Solana"),
@@ -798,7 +801,7 @@ var getChainData = (chain2, network, env) => ({
798
801
 
799
802
  // package.json
800
803
  var package_default = {
801
- version: "2.2.0-alpha.2"};
804
+ version: "2.2.0-alpha.4"};
802
805
 
803
806
  // src/swap/consts.ts
804
807
  var CF_SDK_VERSION_HEADERS = { "X-Chainflip-Sdk-Version": package_default.version };
@@ -928,6 +931,9 @@ var SwapSDK = class {
928
931
  }
929
932
  }).map((a) => a.asset);
930
933
  }
934
+ async getBtcSupplyPoolDepth() {
935
+ return getSupplyPoolsDepth(this.rpcConfig, internalAssetToRpcAsset.Btc);
936
+ }
931
937
  async getBoostPoolsDepth() {
932
938
  return getAllBoostPoolsDepth(this.rpcConfig);
933
939
  }
@@ -999,20 +1005,33 @@ var SwapSDK = class {
999
1005
  return channelOpeningFees;
1000
1006
  }
1001
1007
  async getBoostLiquidity(params = {}) {
1002
- let poolsDepth = await this.getBoostPoolsDepth();
1003
- if ("chain" in params && "asset" in params) {
1004
- const { chain: chain2, asset: asset2 } = params;
1005
- const internalAsset = getInternalAsset({ chain: chain2, asset: asset2 });
1006
- poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.asset === internalAsset).sort((a, b) => b.tier - a.tier);
1008
+ if (params.feeTierBps && params.feeTierBps !== 5) {
1009
+ throw new Error("Unsupported fee tier. Only 5 bps is supported starting from version 2.2.");
1007
1010
  }
1008
- if ("feeTierBps" in params && params.feeTierBps !== void 0) {
1009
- poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.tier === params.feeTierBps);
1011
+ const internalAsset = "chain" in params && "asset" in params ? getInternalAsset(params) : null;
1012
+ const fetchBtcSupplyPool = !internalAsset || internalAsset === "Btc";
1013
+ let [poolsDepth, btcSupplyPoolDepth] = await Promise.all([
1014
+ this.getBoostPoolsDepth(),
1015
+ fetchBtcSupplyPool ? this.getBtcSupplyPoolDepth() : Promise.resolve([])
1016
+ ]);
1017
+ if (internalAsset) {
1018
+ poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.asset === internalAsset).sort((a, b) => b.tier - a.tier);
1010
1019
  }
1011
- return poolsDepth.map((depth) => ({
1012
- availableAmount: depth.availableAmount,
1013
- feeTierBps: depth.tier,
1014
- ...internalAssetToRpcAsset[depth.asset]
1015
- }));
1020
+ return [
1021
+ ...poolsDepth.map((depth) => ({
1022
+ availableAmount: depth.availableAmount,
1023
+ feeTierBps: depth.tier,
1024
+ poolType: "LEGACY_BOOST",
1025
+ ...internalAssetToRpcAsset[depth.asset]
1026
+ })),
1027
+ ...btcSupplyPoolDepth.map((pool) => ({
1028
+ availableAmount: pool.availableAmount,
1029
+ feeTierBps: 5,
1030
+ // supply pools boosts cost 5bps fixed
1031
+ poolType: "SUPPLY",
1032
+ ...pool.asset
1033
+ }))
1034
+ ];
1016
1035
  }
1017
1036
  async requestDepositAddressV2({
1018
1037
  quote,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/sdk",
3
- "version": "2.2.0-alpha.2",
3
+ "version": "2.2.0-alpha.4",
4
4
  "description": "",
5
5
  "exports": {
6
6
  "./swap": {
@@ -57,9 +57,9 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "@chainflip/bitcoin": "2.1.1",
60
- "@chainflip/rpc": "2.2.0-alpha.4",
60
+ "@chainflip/rpc": "2.2.0-alpha.8",
61
61
  "@chainflip/solana": "2.2.3",
62
- "@chainflip/utils": "2.2.0-alpha.2",
62
+ "@chainflip/utils": "2.2.0-alpha.3",
63
63
  "@ts-rest/core": "^3.52.1",
64
64
  "axios": "^1.15.0",
65
65
  "bignumber.js": "^9.3.0",