@chainflip/sdk 2.1.0 → 2.2.0-alpha.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.
@@ -56,12 +56,24 @@ var ARBITRUM_EVM_CHAIN_ID = {
56
56
  mainnet: 42161
57
57
  // mainnet
58
58
  };
59
+ var TRON_CHAIN_ID = {
60
+ backspin: 4271970548,
61
+ // backspin tron
62
+ sisyphos: 3448148188,
63
+ // nile
64
+ perseverance: 3448148188,
65
+ // nile
66
+ mainnet: 728126428
67
+ // mainnet
68
+ };
59
69
  var getEvmChainId = (chain, network) => {
60
70
  switch (chain) {
61
71
  case "Ethereum":
62
72
  return ETHEREUM_EVM_CHAIN_ID[network];
63
73
  case "Arbitrum":
64
74
  return ARBITRUM_EVM_CHAIN_ID[network];
75
+ case "Tron":
76
+ return TRON_CHAIN_ID[network];
65
77
  default:
66
78
  return void 0;
67
79
  }
@@ -79,7 +91,9 @@ var ADDRESSES = {
79
91
  ARBUSDT_CONTRACT_ADDRESS: "0x9A676e781A523b5d0C0e43731313A708CB607508",
80
92
  STATE_CHAIN_GATEWAY_ADDRESS: "0xeEBe00Ac0756308ac4AaBfD76c05c4F3088B8883",
81
93
  SOLUSDC_CONTRACT_ADDRESS: "24PNhTaNtomHhoy3fTRaMhAFCRj4uHqhZEEoWrKDbR5p",
82
- SOLUSDT_CONTRACT_ADDRESS: "8D5DryH5hA6s7Wf5AHXX19pNBwaTmMmvj4UgQGW2S8dF"
94
+ SOLUSDT_CONTRACT_ADDRESS: "8D5DryH5hA6s7Wf5AHXX19pNBwaTmMmvj4UgQGW2S8dF",
95
+ TRXUSDT_CONTRACT_ADDRESS: "TQ6iqCJLAGYgVFccmARRLUBoAGM5FeMGqz"
96
+ // TRON USDT contract can change on backspin if the tron image is rebuilt
83
97
  },
84
98
  sisyphos: {
85
99
  FLIP_CONTRACT_ADDRESS: "0xcD079EAB6B5443b545788Fd210C8800FEADd87fa",
@@ -90,7 +104,8 @@ var ADDRESSES = {
90
104
  ARBUSDT_CONTRACT_ADDRESS: "0x3dd1A7A99CFa2554Da8b3483e6eD739120Fc35cB",
91
105
  STATE_CHAIN_GATEWAY_ADDRESS: "0x1F7fE41C798cc7b1D34BdC8de2dDDA4a4bE744D9",
92
106
  SOLUSDC_CONTRACT_ADDRESS: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
93
- SOLUSDT_CONTRACT_ADDRESS: "FvuqJYh8YeEmarW5qkSrYeEgzaTKktgL3vhgBy2Csy4o"
107
+ SOLUSDT_CONTRACT_ADDRESS: "FvuqJYh8YeEmarW5qkSrYeEgzaTKktgL3vhgBy2Csy4o",
108
+ TRXUSDT_CONTRACT_ADDRESS: "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf"
94
109
  },
95
110
  perseverance: {
96
111
  FLIP_CONTRACT_ADDRESS: "0xdC27c60956cB065D19F08bb69a707E37b36d8086",
@@ -101,7 +116,8 @@ var ADDRESSES = {
101
116
  ARBUSDT_CONTRACT_ADDRESS: "0x3dd1A7A99CFa2554Da8b3483e6eD739120Fc35cB",
102
117
  STATE_CHAIN_GATEWAY_ADDRESS: "0xA34a967197Ee90BB7fb28e928388a573c5CFd099",
103
118
  SOLUSDC_CONTRACT_ADDRESS: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
104
- SOLUSDT_CONTRACT_ADDRESS: "FvuqJYh8YeEmarW5qkSrYeEgzaTKktgL3vhgBy2Csy4o"
119
+ SOLUSDT_CONTRACT_ADDRESS: "FvuqJYh8YeEmarW5qkSrYeEgzaTKktgL3vhgBy2Csy4o",
120
+ TRXUSDT_CONTRACT_ADDRESS: "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf"
105
121
  },
106
122
  mainnet: {
107
123
  FLIP_CONTRACT_ADDRESS: "0x826180541412D574cf1336d22c0C0a287822678A",
@@ -112,7 +128,8 @@ var ADDRESSES = {
112
128
  ARBUSDT_CONTRACT_ADDRESS: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
113
129
  STATE_CHAIN_GATEWAY_ADDRESS: "0x6995Ab7c4D7F4B03f467Cf4c8E920427d9621DBd",
114
130
  SOLUSDC_CONTRACT_ADDRESS: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
115
- SOLUSDT_CONTRACT_ADDRESS: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"
131
+ SOLUSDT_CONTRACT_ADDRESS: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
132
+ TRXUSDT_CONTRACT_ADDRESS: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"
116
133
  }
117
134
  };
118
135
 
package/dist/funding.cjs CHANGED
@@ -766,7 +766,9 @@ var ADDRESSES = {
766
766
  ARBUSDT_CONTRACT_ADDRESS: "0x9A676e781A523b5d0C0e43731313A708CB607508",
767
767
  STATE_CHAIN_GATEWAY_ADDRESS: "0xeEBe00Ac0756308ac4AaBfD76c05c4F3088B8883",
768
768
  SOLUSDC_CONTRACT_ADDRESS: "24PNhTaNtomHhoy3fTRaMhAFCRj4uHqhZEEoWrKDbR5p",
769
- SOLUSDT_CONTRACT_ADDRESS: "8D5DryH5hA6s7Wf5AHXX19pNBwaTmMmvj4UgQGW2S8dF"
769
+ SOLUSDT_CONTRACT_ADDRESS: "8D5DryH5hA6s7Wf5AHXX19pNBwaTmMmvj4UgQGW2S8dF",
770
+ TRXUSDT_CONTRACT_ADDRESS: "TQ6iqCJLAGYgVFccmARRLUBoAGM5FeMGqz"
771
+ // TRON USDT contract can change on backspin if the tron image is rebuilt
770
772
  },
771
773
  sisyphos: {
772
774
  FLIP_CONTRACT_ADDRESS: "0xcD079EAB6B5443b545788Fd210C8800FEADd87fa",
@@ -777,7 +779,8 @@ var ADDRESSES = {
777
779
  ARBUSDT_CONTRACT_ADDRESS: "0x3dd1A7A99CFa2554Da8b3483e6eD739120Fc35cB",
778
780
  STATE_CHAIN_GATEWAY_ADDRESS: "0x1F7fE41C798cc7b1D34BdC8de2dDDA4a4bE744D9",
779
781
  SOLUSDC_CONTRACT_ADDRESS: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
780
- SOLUSDT_CONTRACT_ADDRESS: "FvuqJYh8YeEmarW5qkSrYeEgzaTKktgL3vhgBy2Csy4o"
782
+ SOLUSDT_CONTRACT_ADDRESS: "FvuqJYh8YeEmarW5qkSrYeEgzaTKktgL3vhgBy2Csy4o",
783
+ TRXUSDT_CONTRACT_ADDRESS: "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf"
781
784
  },
782
785
  perseverance: {
783
786
  FLIP_CONTRACT_ADDRESS: "0xdC27c60956cB065D19F08bb69a707E37b36d8086",
@@ -788,7 +791,8 @@ var ADDRESSES = {
788
791
  ARBUSDT_CONTRACT_ADDRESS: "0x3dd1A7A99CFa2554Da8b3483e6eD739120Fc35cB",
789
792
  STATE_CHAIN_GATEWAY_ADDRESS: "0xA34a967197Ee90BB7fb28e928388a573c5CFd099",
790
793
  SOLUSDC_CONTRACT_ADDRESS: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
791
- SOLUSDT_CONTRACT_ADDRESS: "FvuqJYh8YeEmarW5qkSrYeEgzaTKktgL3vhgBy2Csy4o"
794
+ SOLUSDT_CONTRACT_ADDRESS: "FvuqJYh8YeEmarW5qkSrYeEgzaTKktgL3vhgBy2Csy4o",
795
+ TRXUSDT_CONTRACT_ADDRESS: "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf"
792
796
  },
793
797
  mainnet: {
794
798
  FLIP_CONTRACT_ADDRESS: "0x826180541412D574cf1336d22c0C0a287822678A",
@@ -799,7 +803,8 @@ var ADDRESSES = {
799
803
  ARBUSDT_CONTRACT_ADDRESS: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
800
804
  STATE_CHAIN_GATEWAY_ADDRESS: "0x6995Ab7c4D7F4B03f467Cf4c8E920427d9621DBd",
801
805
  SOLUSDC_CONTRACT_ADDRESS: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
802
- SOLUSDT_CONTRACT_ADDRESS: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"
806
+ SOLUSDT_CONTRACT_ADDRESS: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
807
+ TRXUSDT_CONTRACT_ADDRESS: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"
803
808
  }
804
809
  };
805
810
 
package/dist/funding.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getFundingEnvironment, assert, ADDRESSES } from './chunk-S46ZA3IE.js';
1
+ import { getFundingEnvironment, assert, ADDRESSES } from './chunk-Y4JK5EIC.js';
2
2
  import { Interface, Contract } from 'ethers';
3
3
 
4
4
  var _abi = [
package/dist/swap.cjs CHANGED
@@ -8,6 +8,7 @@ var solana = require('@chainflip/solana');
8
8
  var ss58 = require('@chainflip/utils/ss58');
9
9
  var bitcoin = require('@chainflip/bitcoin');
10
10
  var string = require('@chainflip/utils/string');
11
+ var tron = require('@chainflip/utils/tron');
11
12
  var ethers = require('ethers');
12
13
  var number = require('@chainflip/utils/number');
13
14
  var rpc = require('@chainflip/rpc');
@@ -87,6 +88,14 @@ var EncodedVaultSwapData = z3.z.discriminatedUnion("chain", [
87
88
  calldata: hexString,
88
89
  sourceTokenAddress: hexString.optional()
89
90
  }),
91
+ z3.z.object({
92
+ chain: z3.z.literal("Tron"),
93
+ calldata: hexString,
94
+ value: z3.z.string(),
95
+ to: hexString,
96
+ note: hexString,
97
+ sourceTokenAddress: hexString.optional()
98
+ }),
90
99
  z3.z.object({
91
100
  chain: z3.z.literal("Solana"),
92
101
  programId: z3.z.string(),
@@ -141,41 +150,47 @@ var validateBitcoinMainnetAddress = (address) => bitcoin__namespace.isValidAddre
141
150
  var validateBitcoinTestnetAddress = (address) => bitcoin__namespace.isValidAddressForNetwork(address, "testnet");
142
151
  var validateBitcoinRegtestAddress = (address) => bitcoin__namespace.isValidAddressForNetwork(address, "regtest");
143
152
  var validateSolanaAddress = solana.isValidSolanaAddress;
153
+ var validateTronAddress = tron.isValidTronAddress;
144
154
  var validators = {
145
155
  mainnet: {
146
156
  Bitcoin: validateBitcoinMainnetAddress,
147
157
  Ethereum: validateEvmAddress,
148
158
  Arbitrum: validateEvmAddress,
149
159
  Solana: validateSolanaAddress,
150
- Assethub: validatePolkadotAddress
160
+ Assethub: validatePolkadotAddress,
161
+ Tron: validateTronAddress
151
162
  },
152
163
  perseverance: {
153
164
  Bitcoin: validateBitcoinTestnetAddress,
154
165
  Ethereum: validateEvmAddress,
155
166
  Arbitrum: validateEvmAddress,
156
167
  Solana: validateSolanaAddress,
157
- Assethub: validatePolkadotAddress
168
+ Assethub: validatePolkadotAddress,
169
+ Tron: validateTronAddress
158
170
  },
159
171
  sisyphos: {
160
172
  Bitcoin: validateBitcoinTestnetAddress,
161
173
  Ethereum: validateEvmAddress,
162
174
  Arbitrum: validateEvmAddress,
163
175
  Solana: validateSolanaAddress,
164
- Assethub: validatePolkadotAddress
176
+ Assethub: validatePolkadotAddress,
177
+ Tron: validateTronAddress
165
178
  },
166
179
  backspin: {
167
180
  Bitcoin: validateBitcoinRegtestAddress,
168
181
  Ethereum: validateEvmAddress,
169
182
  Arbitrum: validateEvmAddress,
170
183
  Solana: validateSolanaAddress,
171
- Assethub: validatePolkadotAddress
184
+ Assethub: validatePolkadotAddress,
185
+ Tron: validateTronAddress
172
186
  },
173
187
  localnet: {
174
188
  Bitcoin: validateBitcoinRegtestAddress,
175
189
  Ethereum: validateEvmAddress,
176
190
  Arbitrum: validateEvmAddress,
177
191
  Solana: validateSolanaAddress,
178
- Assethub: validatePolkadotAddress
192
+ Assethub: validatePolkadotAddress,
193
+ Tron: validateTronAddress
179
194
  }
180
195
  };
181
196
  var validateAddress = (chain2, address, network) => validators[network][chain2](address);
@@ -227,10 +242,10 @@ z3.z.object({
227
242
  z3.z.literal("undefined").transform(() => void 0)
228
243
  // sdk version 1.8.2 sends undefined string if not set
229
244
  ]).optional(),
230
- dcaEnabled: booleanString.default("false"),
231
245
  dcaV2Enabled: booleanString.default("false"),
232
246
  isVaultSwap: booleanString.optional(),
233
- isOnChain: booleanString.optional()
247
+ isOnChain: booleanString.optional(),
248
+ brokerIdSs58: chainflipAddress.optional()
234
249
  }).transform((args, ctx) => {
235
250
  const { srcAsset, destAsset } = chainflip.getInternalAssets(args, false);
236
251
  let hadError = false;
@@ -291,10 +306,10 @@ z3.z.object({
291
306
  amount: args.amount,
292
307
  brokerCommissionBps: args.brokerCommissionBps,
293
308
  ccmParams,
294
- dcaEnabled: args.dcaEnabled,
295
309
  dcaV2Enabled: args.dcaV2Enabled,
296
310
  isVaultSwap: args.isVaultSwap,
297
- isOnChain: args.isOnChain
311
+ isOnChain: args.isOnChain,
312
+ brokerIdSs58: args.brokerIdSs58
298
313
  };
299
314
  });
300
315
  var ccmParamsSchema = z3.z.object({
@@ -500,7 +515,7 @@ var getVaultSwapParameterEncodingRequestSchema = (network) => z3.z.object({
500
515
  retry_duration: data.fillOrKillParams.retry_duration,
501
516
  max_oracle_price_slippage: data.fillOrKillParams.max_oracle_price_slippage
502
517
  };
503
- } else if (data.srcAsset.chain === "Ethereum" || data.srcAsset.chain === "Arbitrum") {
518
+ } else if (data.srcAsset.chain === "Ethereum" || data.srcAsset.chain === "Arbitrum" || data.srcAsset.chain === "Tron") {
504
519
  extraParams = {
505
520
  chain: data.srcAsset.chain,
506
521
  input_amount: `0x${data.amount.toString(16)}`,
@@ -545,6 +560,7 @@ async function requestSwapDepositAddress(request, opts, chainflipNetwork) {
545
560
  case "Arbitrum":
546
561
  case "Bitcoin":
547
562
  case "Solana":
563
+ case "Tron":
548
564
  break;
549
565
  default:
550
566
  return assertion.unreachable(params.srcAsset, "unexpected chain");
@@ -694,30 +710,22 @@ var blocksPerMinute = 60 / consts.CHAINFLIP_BLOCK_TIME_SECONDS;
694
710
  function parseFoKParams(params, quote) {
695
711
  const srcAsset = chainflip.getInternalAsset(quote.srcAsset);
696
712
  const destAsset = chainflip.getInternalAsset(quote.destAsset);
697
- const livePriceProtectionDisabled = params.livePriceSlippageTolerancePercent === false;
698
- const livePriceProtectionEnabled = typeof params.livePriceSlippageTolerancePercent === "string" || typeof params.livePriceSlippageTolerancePercent === "number";
699
- const livePriceProtectionAvailable = isNotNullish(
700
- quote.recommendedLivePriceSlippageTolerancePercent
701
- );
702
- if (livePriceProtectionEnabled && !livePriceProtectionAvailable) {
703
- throw new Error("Live price protection is not available for this asset pair");
704
- }
713
+ const lppAvailable = isNotNullish(quote.recommendedLivePriceSlippageTolerancePercent);
705
714
  let minPrice;
706
- let livePriceSlippageTolerancePercent = null;
707
- if (!livePriceProtectionDisabled) {
708
- if (isNotNullish(params.livePriceSlippageTolerancePercent) && params.livePriceSlippageTolerancePercent !== false) {
709
- livePriceSlippageTolerancePercent = new BigNumber2__default.default(params.livePriceSlippageTolerancePercent);
710
- assert(!livePriceSlippageTolerancePercent.isNaN(), "Invalid live price slippage tolerance");
711
- assert(
712
- livePriceSlippageTolerancePercent.gte(0) && livePriceSlippageTolerancePercent.lte(100),
713
- "Live price slippage tolerance must be between 0 and 100 inclusive"
714
- );
715
- } else if (quote.recommendedLivePriceSlippageTolerancePercent) {
716
- livePriceSlippageTolerancePercent = new BigNumber2__default.default(
717
- quote.recommendedLivePriceSlippageTolerancePercent
718
- );
719
- assert(!livePriceSlippageTolerancePercent.isNaN(), "Invalid live price slippage tolerance");
715
+ let lpp = null;
716
+ if (isNotNullish(params.livePriceSlippageTolerancePercent)) {
717
+ if (!lppAvailable) {
718
+ throw new Error("Live price protection is not available for this asset pair");
720
719
  }
720
+ lpp = new BigNumber2__default.default(params.livePriceSlippageTolerancePercent);
721
+ assert(!lpp.isNaN(), "Invalid live price slippage tolerance");
722
+ assert(
723
+ lpp.gte(0) && lpp.lte(100),
724
+ "Live price slippage tolerance must be between 0 and 100 inclusive"
725
+ );
726
+ } else if (quote.recommendedLivePriceSlippageTolerancePercent) {
727
+ lpp = new BigNumber2__default.default(quote.recommendedLivePriceSlippageTolerancePercent);
728
+ assert(!lpp.isNaN(), "Invalid live price slippage tolerance");
721
729
  }
722
730
  if ("minPrice" in params) {
723
731
  assert(
@@ -740,7 +748,7 @@ function parseFoKParams(params, quote) {
740
748
  throw new Error("Either minPrice or slippageTolerancePercent must be provided");
741
749
  }
742
750
  const retryDurationBlocks = "retryDurationBlocks" in params ? params.retryDurationBlocks : Math.max(Math.ceil(params.retryDurationMinutes * blocksPerMinute), 0);
743
- const maxOraclePriceSlippage = livePriceSlippageTolerancePercent?.multipliedBy(100).toNumber() ?? null;
751
+ const maxOraclePriceSlippage = lpp?.multipliedBy(100).toNumber() ?? null;
744
752
  const parsed = {
745
753
  retryDurationBlocks,
746
754
  minPriceX128: getPriceX128FromPrice(minPrice, srcAsset, destAsset),
@@ -812,12 +820,24 @@ var ARBITRUM_EVM_CHAIN_ID = {
812
820
  mainnet: 42161
813
821
  // mainnet
814
822
  };
823
+ var TRON_CHAIN_ID = {
824
+ backspin: 4271970548,
825
+ // backspin tron
826
+ sisyphos: 3448148188,
827
+ // nile
828
+ perseverance: 3448148188,
829
+ // nile
830
+ mainnet: 728126428
831
+ // mainnet
832
+ };
815
833
  var getEvmChainId = (chain2, network) => {
816
834
  switch (chain2) {
817
835
  case "Ethereum":
818
836
  return ETHEREUM_EVM_CHAIN_ID[network];
819
837
  case "Arbitrum":
820
838
  return ARBITRUM_EVM_CHAIN_ID[network];
839
+ case "Tron":
840
+ return TRON_CHAIN_ID[network];
821
841
  default:
822
842
  return void 0;
823
843
  }
@@ -835,7 +855,9 @@ var ADDRESSES = {
835
855
  ARBUSDT_CONTRACT_ADDRESS: "0x9A676e781A523b5d0C0e43731313A708CB607508",
836
856
  STATE_CHAIN_GATEWAY_ADDRESS: "0xeEBe00Ac0756308ac4AaBfD76c05c4F3088B8883",
837
857
  SOLUSDC_CONTRACT_ADDRESS: "24PNhTaNtomHhoy3fTRaMhAFCRj4uHqhZEEoWrKDbR5p",
838
- SOLUSDT_CONTRACT_ADDRESS: "8D5DryH5hA6s7Wf5AHXX19pNBwaTmMmvj4UgQGW2S8dF"
858
+ SOLUSDT_CONTRACT_ADDRESS: "8D5DryH5hA6s7Wf5AHXX19pNBwaTmMmvj4UgQGW2S8dF",
859
+ TRXUSDT_CONTRACT_ADDRESS: "TQ6iqCJLAGYgVFccmARRLUBoAGM5FeMGqz"
860
+ // TRON USDT contract can change on backspin if the tron image is rebuilt
839
861
  },
840
862
  sisyphos: {
841
863
  FLIP_CONTRACT_ADDRESS: "0xcD079EAB6B5443b545788Fd210C8800FEADd87fa",
@@ -846,7 +868,8 @@ var ADDRESSES = {
846
868
  ARBUSDT_CONTRACT_ADDRESS: "0x3dd1A7A99CFa2554Da8b3483e6eD739120Fc35cB",
847
869
  STATE_CHAIN_GATEWAY_ADDRESS: "0x1F7fE41C798cc7b1D34BdC8de2dDDA4a4bE744D9",
848
870
  SOLUSDC_CONTRACT_ADDRESS: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
849
- SOLUSDT_CONTRACT_ADDRESS: "FvuqJYh8YeEmarW5qkSrYeEgzaTKktgL3vhgBy2Csy4o"
871
+ SOLUSDT_CONTRACT_ADDRESS: "FvuqJYh8YeEmarW5qkSrYeEgzaTKktgL3vhgBy2Csy4o",
872
+ TRXUSDT_CONTRACT_ADDRESS: "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf"
850
873
  },
851
874
  perseverance: {
852
875
  FLIP_CONTRACT_ADDRESS: "0xdC27c60956cB065D19F08bb69a707E37b36d8086",
@@ -857,7 +880,8 @@ var ADDRESSES = {
857
880
  ARBUSDT_CONTRACT_ADDRESS: "0x3dd1A7A99CFa2554Da8b3483e6eD739120Fc35cB",
858
881
  STATE_CHAIN_GATEWAY_ADDRESS: "0xA34a967197Ee90BB7fb28e928388a573c5CFd099",
859
882
  SOLUSDC_CONTRACT_ADDRESS: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
860
- SOLUSDT_CONTRACT_ADDRESS: "FvuqJYh8YeEmarW5qkSrYeEgzaTKktgL3vhgBy2Csy4o"
883
+ SOLUSDT_CONTRACT_ADDRESS: "FvuqJYh8YeEmarW5qkSrYeEgzaTKktgL3vhgBy2Csy4o",
884
+ TRXUSDT_CONTRACT_ADDRESS: "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf"
861
885
  },
862
886
  mainnet: {
863
887
  FLIP_CONTRACT_ADDRESS: "0x826180541412D574cf1336d22c0C0a287822678A",
@@ -868,7 +892,8 @@ var ADDRESSES = {
868
892
  ARBUSDT_CONTRACT_ADDRESS: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
869
893
  STATE_CHAIN_GATEWAY_ADDRESS: "0x6995Ab7c4D7F4B03f467Cf4c8E920427d9621DBd",
870
894
  SOLUSDC_CONTRACT_ADDRESS: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
871
- SOLUSDT_CONTRACT_ADDRESS: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"
895
+ SOLUSDT_CONTRACT_ADDRESS: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
896
+ TRXUSDT_CONTRACT_ADDRESS: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"
872
897
  }
873
898
  };
874
899
 
@@ -882,6 +907,7 @@ var getTokenContractAddress = (asset2, network) => {
882
907
  case "HubDot":
883
908
  case "HubUsdc":
884
909
  case "HubUsdt":
910
+ case "Trx":
885
911
  return void 0;
886
912
  default:
887
913
  return ADDRESSES[network][`${string.toUpperCase(asset2)}_CONTRACT_ADDRESS`];
@@ -902,7 +928,9 @@ var assetNames = {
902
928
  SolUsdt: "Solana USDT",
903
929
  HubDot: "Assethub DOT",
904
930
  HubUsdc: "Assethub USDC",
905
- HubUsdt: "Assethub USDT"
931
+ HubUsdt: "Assethub USDT",
932
+ Trx: "Tron",
933
+ TrxUsdt: "Tron USDT"
906
934
  };
907
935
  var getAssetData = (asset2, network, env) => {
908
936
  const assetConstant = chainflip.assetConstants[asset2];
@@ -933,7 +961,7 @@ var getChainData = (chain2, network, env) => ({
933
961
 
934
962
  // package.json
935
963
  var package_default = {
936
- version: "2.1.0"};
964
+ version: "2.2.0-alpha.2"};
937
965
 
938
966
  // src/swap/consts.ts
939
967
  var CF_SDK_VERSION_HEADERS = { "X-Chainflip-Sdk-Version": package_default.version };
@@ -961,8 +989,8 @@ var getQuoteV2 = async (baseUrl, quoteRequest, { signal }) => {
961
989
  ccmGasBudget: quoteRequest.ccmParams.gasBudget,
962
990
  ccmMessageLengthBytes: String(quoteRequest.ccmParams.messageLengthBytes)
963
991
  },
964
- dcaEnabled: String(Boolean(quoteRequest.dcaEnabled)),
965
- dcaV2Enabled: String(Boolean(quoteRequest.dcaV2Enabled))
992
+ dcaV2Enabled: String(Boolean(quoteRequest.dcaV2Enabled)),
993
+ ...quoteRequest.brokerAccount && { brokerIdSs58: quoteRequest.brokerAccount }
966
994
  };
967
995
  const { data } = await axios__default.default.get("/v2/quote", {
968
996
  baseURL: baseUrl,
@@ -998,7 +1026,6 @@ var SwapSDK = class {
998
1026
  rpcConfig;
999
1027
  apiClient;
1000
1028
  cache;
1001
- dcaEnabled = false;
1002
1029
  dcaV2Enabled = false;
1003
1030
  constructor(options = {}) {
1004
1031
  const network = options.network ?? "perseverance";
@@ -1015,7 +1042,6 @@ var SwapSDK = class {
1015
1042
  baseHeaders: CF_SDK_VERSION_HEADERS
1016
1043
  });
1017
1044
  this.dcaV2Enabled = options.enabledFeatures?.dcaV2 ?? false;
1018
- this.dcaEnabled = this.dcaV2Enabled || (options.enabledFeatures?.dca ?? false);
1019
1045
  this.cache = new MultiCache({
1020
1046
  environment: {
1021
1047
  fetch: () => getEnvironment(this.rpcConfig),
@@ -1095,8 +1121,8 @@ var SwapSDK = class {
1095
1121
  {
1096
1122
  ...quoteRequest,
1097
1123
  brokerCommissionBps: submitterBrokerCommissionBps,
1098
- dcaEnabled: this.dcaEnabled,
1099
- dcaV2Enabled: this.dcaV2Enabled
1124
+ dcaV2Enabled: this.dcaV2Enabled,
1125
+ brokerAccount: quoteRequest.brokerAccount ?? this.options.brokerAccount
1100
1126
  },
1101
1127
  options
1102
1128
  );
@@ -1181,7 +1207,6 @@ var SwapSDK = class {
1181
1207
  ccmParams,
1182
1208
  amount: quote.depositAmount
1183
1209
  };
1184
- await this.checkLivePriceProtectionRequirement(depositAddressRequest, quote);
1185
1210
  let response;
1186
1211
  if (this.options.broker) {
1187
1212
  const result = await requestSwapDepositAddress(
@@ -1272,7 +1297,6 @@ var SwapSDK = class {
1272
1297
  commissionBps: brokerCommissionBps,
1273
1298
  affiliates
1274
1299
  };
1275
- await this.checkLivePriceProtectionRequirement(vaultSwapRequest, quote);
1276
1300
  if (this.options.broker) {
1277
1301
  assert(
1278
1302
  !vaultSwapRequest.brokerAccount,
@@ -1299,6 +1323,7 @@ var SwapSDK = class {
1299
1323
  switch (res.body.chain) {
1300
1324
  case "Arbitrum":
1301
1325
  case "Ethereum":
1326
+ case "Tron":
1302
1327
  return { ...res.body, value: BigInt(res.body.value) };
1303
1328
  default:
1304
1329
  return res.body;
@@ -1334,7 +1359,6 @@ var SwapSDK = class {
1334
1359
  commissionBps: await this.getCommissionBps(brokerCommissionBps),
1335
1360
  affiliates
1336
1361
  };
1337
- await this.checkLivePriceProtectionRequirement(requestParams, quote);
1338
1362
  if (this.options.broker) {
1339
1363
  assert(
1340
1364
  !brokerAccount,
@@ -1381,21 +1405,6 @@ var SwapSDK = class {
1381
1405
  }
1382
1406
  return res.body;
1383
1407
  }
1384
- async checkLivePriceProtectionRequirement(request, quote) {
1385
- if (!this.dcaV2Enabled || quote.type !== "DCA") return;
1386
- const { assets: assets2 } = await this.cache.read("networkInfo");
1387
- const srcAsset = chainflip.getInternalAsset(request.srcAsset);
1388
- const destAsset = chainflip.getInternalAsset(request.destAsset);
1389
- if (![srcAsset, destAsset].every(
1390
- (asset2) => assets2.find((a) => a.asset === asset2)?.livePriceProtectionEnabled
1391
- )) {
1392
- return;
1393
- }
1394
- if (isNotNullish(request.fillOrKillParams.maxOraclePriceSlippage)) return;
1395
- throw new Error(
1396
- "Max oracle price slippage must be set in FillOrKillParams when live price protection is enabled for both assets in DCA V2"
1397
- );
1398
- }
1399
1408
  };
1400
1409
  var arrayToMap = (array) => Object.fromEntries(array.map((item) => [item, item]));
1401
1410
  var ChainflipNetworks = arrayToMap(chainflip.chainflipNetworks);
package/dist/swap.d.cts CHANGED
@@ -298,7 +298,7 @@ type DCABoostQuote = NonNullable<DCAQuote['boostQuote']>;
298
298
  type RegularBoostQuote = NonNullable<RegularQuote['boostQuote']>;
299
299
  type BoostQuote = RegularBoostQuote | DCABoostQuote;
300
300
  type FillOrKillParams = {
301
- livePriceSlippageTolerancePercent?: string | number | false;
301
+ livePriceSlippageTolerancePercent?: string | number;
302
302
  refundAddress: string;
303
303
  refundCcmMetadata?: CcmParams | null;
304
304
  } & ({
@@ -354,6 +354,11 @@ interface QuoteRequest extends ChainsAndAssets {
354
354
  gasBudget: string;
355
355
  messageLengthBytes: number;
356
356
  };
357
+ /**
358
+ * Chainflip broker SS58 address attributed to this quote.
359
+ * Overrides the SDK-level `brokerAccount` option for this request.
360
+ */
361
+ brokerAccount?: `cF${string}`;
357
362
  }
358
363
  interface QuoteResponseV2 extends QuoteRequest {
359
364
  quotes: Quote[];
@@ -598,6 +603,13 @@ type VaultSwapResponse = {
598
603
  value: bigint;
599
604
  to: string;
600
605
  sourceTokenAddress?: string | undefined;
606
+ } | {
607
+ chain: 'Tron';
608
+ calldata: string;
609
+ value: bigint;
610
+ to: string;
611
+ note: string;
612
+ sourceTokenAddress?: string;
601
613
  } | {
602
614
  chain: 'Solana';
603
615
  programId: string;
@@ -634,10 +646,13 @@ type SwapSDKOptions = {
634
646
  };
635
647
  rpcUrl?: string;
636
648
  enabledFeatures?: {
637
- /** @deprecated DEPRECATED(2.0): DCA will be enabled by default in version 2.2 */
638
- dca?: boolean;
639
649
  dcaV2?: boolean;
640
650
  };
651
+ /**
652
+ * Chainflip broker SS58 address attributed to quote requests.
653
+ * Sent on every /v2/quote request unless overridden per-call.
654
+ */
655
+ brokerAccount?: `cF${string}`;
641
656
  };
642
657
  type AssetState = 'all' | 'deposit' | 'destination' | 'depositChannel' | 'vaultSwap';
643
658
  declare class SwapSDK {
@@ -645,7 +660,6 @@ declare class SwapSDK {
645
660
  private readonly rpcConfig;
646
661
  private readonly apiClient;
647
662
  private cache;
648
- private dcaEnabled;
649
663
  private dcaV2Enabled;
650
664
  constructor(options?: SwapSDKOptions);
651
665
  getChains(sourceChain?: ChainflipChain, type?: AssetState): Promise<ChainData[]>;
@@ -683,7 +697,6 @@ declare class SwapSDK {
683
697
  channelOpeningFee: string;
684
698
  estimatedExpiryTime?: number | undefined;
685
699
  }>;
686
- private checkLivePriceProtectionRequirement;
687
700
  }
688
701
 
689
702
  /**
@@ -710,6 +723,8 @@ declare const InternalAssets: {
710
723
  Sol: "Sol";
711
724
  SolUsdc: "SolUsdc";
712
725
  SolUsdt: "SolUsdt";
726
+ Trx: "Trx";
727
+ TrxUsdt: "TrxUsdt";
713
728
  HubDot: "HubDot";
714
729
  HubUsdt: "HubUsdt";
715
730
  HubUsdc: "HubUsdc";
@@ -717,6 +732,7 @@ declare const InternalAssets: {
717
732
  declare const Chains: {
718
733
  Ethereum: "Ethereum";
719
734
  Arbitrum: "Arbitrum";
735
+ Tron: "Tron";
720
736
  Bitcoin: "Bitcoin";
721
737
  Solana: "Solana";
722
738
  Assethub: "Assethub";
@@ -730,6 +746,7 @@ declare const Assets: {
730
746
  USDC: "USDC";
731
747
  USDT: "USDT";
732
748
  WBTC: "WBTC";
749
+ TRX: "TRX";
733
750
  };
734
751
  type Chain = ChainflipChain;
735
752
  type InternalAsset = ChainflipAsset;
package/dist/swap.d.ts CHANGED
@@ -298,7 +298,7 @@ type DCABoostQuote = NonNullable<DCAQuote['boostQuote']>;
298
298
  type RegularBoostQuote = NonNullable<RegularQuote['boostQuote']>;
299
299
  type BoostQuote = RegularBoostQuote | DCABoostQuote;
300
300
  type FillOrKillParams = {
301
- livePriceSlippageTolerancePercent?: string | number | false;
301
+ livePriceSlippageTolerancePercent?: string | number;
302
302
  refundAddress: string;
303
303
  refundCcmMetadata?: CcmParams | null;
304
304
  } & ({
@@ -354,6 +354,11 @@ interface QuoteRequest extends ChainsAndAssets {
354
354
  gasBudget: string;
355
355
  messageLengthBytes: number;
356
356
  };
357
+ /**
358
+ * Chainflip broker SS58 address attributed to this quote.
359
+ * Overrides the SDK-level `brokerAccount` option for this request.
360
+ */
361
+ brokerAccount?: `cF${string}`;
357
362
  }
358
363
  interface QuoteResponseV2 extends QuoteRequest {
359
364
  quotes: Quote[];
@@ -598,6 +603,13 @@ type VaultSwapResponse = {
598
603
  value: bigint;
599
604
  to: string;
600
605
  sourceTokenAddress?: string | undefined;
606
+ } | {
607
+ chain: 'Tron';
608
+ calldata: string;
609
+ value: bigint;
610
+ to: string;
611
+ note: string;
612
+ sourceTokenAddress?: string;
601
613
  } | {
602
614
  chain: 'Solana';
603
615
  programId: string;
@@ -634,10 +646,13 @@ type SwapSDKOptions = {
634
646
  };
635
647
  rpcUrl?: string;
636
648
  enabledFeatures?: {
637
- /** @deprecated DEPRECATED(2.0): DCA will be enabled by default in version 2.2 */
638
- dca?: boolean;
639
649
  dcaV2?: boolean;
640
650
  };
651
+ /**
652
+ * Chainflip broker SS58 address attributed to quote requests.
653
+ * Sent on every /v2/quote request unless overridden per-call.
654
+ */
655
+ brokerAccount?: `cF${string}`;
641
656
  };
642
657
  type AssetState = 'all' | 'deposit' | 'destination' | 'depositChannel' | 'vaultSwap';
643
658
  declare class SwapSDK {
@@ -645,7 +660,6 @@ declare class SwapSDK {
645
660
  private readonly rpcConfig;
646
661
  private readonly apiClient;
647
662
  private cache;
648
- private dcaEnabled;
649
663
  private dcaV2Enabled;
650
664
  constructor(options?: SwapSDKOptions);
651
665
  getChains(sourceChain?: ChainflipChain, type?: AssetState): Promise<ChainData[]>;
@@ -683,7 +697,6 @@ declare class SwapSDK {
683
697
  channelOpeningFee: string;
684
698
  estimatedExpiryTime?: number | undefined;
685
699
  }>;
686
- private checkLivePriceProtectionRequirement;
687
700
  }
688
701
 
689
702
  /**
@@ -710,6 +723,8 @@ declare const InternalAssets: {
710
723
  Sol: "Sol";
711
724
  SolUsdc: "SolUsdc";
712
725
  SolUsdt: "SolUsdt";
726
+ Trx: "Trx";
727
+ TrxUsdt: "TrxUsdt";
713
728
  HubDot: "HubDot";
714
729
  HubUsdt: "HubUsdt";
715
730
  HubUsdc: "HubUsdc";
@@ -717,6 +732,7 @@ declare const InternalAssets: {
717
732
  declare const Chains: {
718
733
  Ethereum: "Ethereum";
719
734
  Arbitrum: "Arbitrum";
735
+ Tron: "Tron";
720
736
  Bitcoin: "Bitcoin";
721
737
  Solana: "Solana";
722
738
  Assethub: "Assethub";
@@ -730,6 +746,7 @@ declare const Assets: {
730
746
  USDC: "USDC";
731
747
  USDT: "USDT";
732
748
  WBTC: "WBTC";
749
+ TRX: "TRX";
733
750
  };
734
751
  type Chain = ChainflipChain;
735
752
  type InternalAsset = ChainflipAsset;
package/dist/swap.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getEnvironment, assert, getEvmChainId, getAllBoostPoolsDepth, isNotNullish, ADDRESSES } from './chunk-S46ZA3IE.js';
1
+ import { getEnvironment, assert, getEvmChainId, getAllBoostPoolsDepth, isNotNullish, ADDRESSES } from './chunk-Y4JK5EIC.js';
2
2
  import { unreachable } from '@chainflip/utils/assertion';
3
3
  import { chainflipChains, assetSymbols, isValidAssetAndChain, chainflipAssets, getInternalAssets, assetConstants, getInternalAsset, internalAssetToRpcAsset, chainflipNetworks, readAssetValue, anyAssetConstants } from '@chainflip/utils/chainflip';
4
4
  export { getInternalAsset as getChainflipId } from '@chainflip/utils/chainflip';
@@ -8,6 +8,7 @@ import { isValidSolanaAddress } from '@chainflip/solana';
8
8
  import * as ss58 from '@chainflip/utils/ss58';
9
9
  import * as bitcoin from '@chainflip/bitcoin';
10
10
  import { isHex, toUpperCase } from '@chainflip/utils/string';
11
+ import { isValidTronAddress } from '@chainflip/utils/tron';
11
12
  import * as ethers from 'ethers';
12
13
  import { hexEncodeNumber } from '@chainflip/utils/number';
13
14
  import { HttpClient } from '@chainflip/rpc';
@@ -59,6 +60,14 @@ var EncodedVaultSwapData = z.discriminatedUnion("chain", [
59
60
  calldata: hexString,
60
61
  sourceTokenAddress: hexString.optional()
61
62
  }),
63
+ z.object({
64
+ chain: z.literal("Tron"),
65
+ calldata: hexString,
66
+ value: z.string(),
67
+ to: hexString,
68
+ note: hexString,
69
+ sourceTokenAddress: hexString.optional()
70
+ }),
62
71
  z.object({
63
72
  chain: z.literal("Solana"),
64
73
  programId: z.string(),
@@ -100,41 +109,47 @@ var validateBitcoinMainnetAddress = (address) => bitcoin.isValidAddressForNetwor
100
109
  var validateBitcoinTestnetAddress = (address) => bitcoin.isValidAddressForNetwork(address, "testnet");
101
110
  var validateBitcoinRegtestAddress = (address) => bitcoin.isValidAddressForNetwork(address, "regtest");
102
111
  var validateSolanaAddress = isValidSolanaAddress;
112
+ var validateTronAddress = isValidTronAddress;
103
113
  var validators = {
104
114
  mainnet: {
105
115
  Bitcoin: validateBitcoinMainnetAddress,
106
116
  Ethereum: validateEvmAddress,
107
117
  Arbitrum: validateEvmAddress,
108
118
  Solana: validateSolanaAddress,
109
- Assethub: validatePolkadotAddress
119
+ Assethub: validatePolkadotAddress,
120
+ Tron: validateTronAddress
110
121
  },
111
122
  perseverance: {
112
123
  Bitcoin: validateBitcoinTestnetAddress,
113
124
  Ethereum: validateEvmAddress,
114
125
  Arbitrum: validateEvmAddress,
115
126
  Solana: validateSolanaAddress,
116
- Assethub: validatePolkadotAddress
127
+ Assethub: validatePolkadotAddress,
128
+ Tron: validateTronAddress
117
129
  },
118
130
  sisyphos: {
119
131
  Bitcoin: validateBitcoinTestnetAddress,
120
132
  Ethereum: validateEvmAddress,
121
133
  Arbitrum: validateEvmAddress,
122
134
  Solana: validateSolanaAddress,
123
- Assethub: validatePolkadotAddress
135
+ Assethub: validatePolkadotAddress,
136
+ Tron: validateTronAddress
124
137
  },
125
138
  backspin: {
126
139
  Bitcoin: validateBitcoinRegtestAddress,
127
140
  Ethereum: validateEvmAddress,
128
141
  Arbitrum: validateEvmAddress,
129
142
  Solana: validateSolanaAddress,
130
- Assethub: validatePolkadotAddress
143
+ Assethub: validatePolkadotAddress,
144
+ Tron: validateTronAddress
131
145
  },
132
146
  localnet: {
133
147
  Bitcoin: validateBitcoinRegtestAddress,
134
148
  Ethereum: validateEvmAddress,
135
149
  Arbitrum: validateEvmAddress,
136
150
  Solana: validateSolanaAddress,
137
- Assethub: validatePolkadotAddress
151
+ Assethub: validatePolkadotAddress,
152
+ Tron: validateTronAddress
138
153
  }
139
154
  };
140
155
  var validateAddress = (chain2, address, network) => validators[network][chain2](address);
@@ -186,10 +201,10 @@ z.object({
186
201
  z.literal("undefined").transform(() => void 0)
187
202
  // sdk version 1.8.2 sends undefined string if not set
188
203
  ]).optional(),
189
- dcaEnabled: booleanString.default("false"),
190
204
  dcaV2Enabled: booleanString.default("false"),
191
205
  isVaultSwap: booleanString.optional(),
192
- isOnChain: booleanString.optional()
206
+ isOnChain: booleanString.optional(),
207
+ brokerIdSs58: chainflipAddress.optional()
193
208
  }).transform((args, ctx) => {
194
209
  const { srcAsset, destAsset } = getInternalAssets(args, false);
195
210
  let hadError = false;
@@ -250,10 +265,10 @@ z.object({
250
265
  amount: args.amount,
251
266
  brokerCommissionBps: args.brokerCommissionBps,
252
267
  ccmParams,
253
- dcaEnabled: args.dcaEnabled,
254
268
  dcaV2Enabled: args.dcaV2Enabled,
255
269
  isVaultSwap: args.isVaultSwap,
256
- isOnChain: args.isOnChain
270
+ isOnChain: args.isOnChain,
271
+ brokerIdSs58: args.brokerIdSs58
257
272
  };
258
273
  });
259
274
  var ccmParamsSchema = z.object({
@@ -459,7 +474,7 @@ var getVaultSwapParameterEncodingRequestSchema = (network) => z.object({
459
474
  retry_duration: data.fillOrKillParams.retry_duration,
460
475
  max_oracle_price_slippage: data.fillOrKillParams.max_oracle_price_slippage
461
476
  };
462
- } else if (data.srcAsset.chain === "Ethereum" || data.srcAsset.chain === "Arbitrum") {
477
+ } else if (data.srcAsset.chain === "Ethereum" || data.srcAsset.chain === "Arbitrum" || data.srcAsset.chain === "Tron") {
463
478
  extraParams = {
464
479
  chain: data.srcAsset.chain,
465
480
  input_amount: `0x${data.amount.toString(16)}`,
@@ -504,6 +519,7 @@ async function requestSwapDepositAddress(request, opts, chainflipNetwork) {
504
519
  case "Arbitrum":
505
520
  case "Bitcoin":
506
521
  case "Solana":
522
+ case "Tron":
507
523
  break;
508
524
  default:
509
525
  return unreachable(params.srcAsset, "unexpected chain");
@@ -653,30 +669,22 @@ var blocksPerMinute = 60 / CHAINFLIP_BLOCK_TIME_SECONDS;
653
669
  function parseFoKParams(params, quote) {
654
670
  const srcAsset = getInternalAsset(quote.srcAsset);
655
671
  const destAsset = getInternalAsset(quote.destAsset);
656
- const livePriceProtectionDisabled = params.livePriceSlippageTolerancePercent === false;
657
- const livePriceProtectionEnabled = typeof params.livePriceSlippageTolerancePercent === "string" || typeof params.livePriceSlippageTolerancePercent === "number";
658
- const livePriceProtectionAvailable = isNotNullish(
659
- quote.recommendedLivePriceSlippageTolerancePercent
660
- );
661
- if (livePriceProtectionEnabled && !livePriceProtectionAvailable) {
662
- throw new Error("Live price protection is not available for this asset pair");
663
- }
672
+ const lppAvailable = isNotNullish(quote.recommendedLivePriceSlippageTolerancePercent);
664
673
  let minPrice;
665
- let livePriceSlippageTolerancePercent = null;
666
- if (!livePriceProtectionDisabled) {
667
- if (isNotNullish(params.livePriceSlippageTolerancePercent) && params.livePriceSlippageTolerancePercent !== false) {
668
- livePriceSlippageTolerancePercent = new BigNumber2(params.livePriceSlippageTolerancePercent);
669
- assert(!livePriceSlippageTolerancePercent.isNaN(), "Invalid live price slippage tolerance");
670
- assert(
671
- livePriceSlippageTolerancePercent.gte(0) && livePriceSlippageTolerancePercent.lte(100),
672
- "Live price slippage tolerance must be between 0 and 100 inclusive"
673
- );
674
- } else if (quote.recommendedLivePriceSlippageTolerancePercent) {
675
- livePriceSlippageTolerancePercent = new BigNumber2(
676
- quote.recommendedLivePriceSlippageTolerancePercent
677
- );
678
- assert(!livePriceSlippageTolerancePercent.isNaN(), "Invalid live price slippage tolerance");
674
+ let lpp = null;
675
+ if (isNotNullish(params.livePriceSlippageTolerancePercent)) {
676
+ if (!lppAvailable) {
677
+ throw new Error("Live price protection is not available for this asset pair");
679
678
  }
679
+ lpp = new BigNumber2(params.livePriceSlippageTolerancePercent);
680
+ assert(!lpp.isNaN(), "Invalid live price slippage tolerance");
681
+ assert(
682
+ lpp.gte(0) && lpp.lte(100),
683
+ "Live price slippage tolerance must be between 0 and 100 inclusive"
684
+ );
685
+ } else if (quote.recommendedLivePriceSlippageTolerancePercent) {
686
+ lpp = new BigNumber2(quote.recommendedLivePriceSlippageTolerancePercent);
687
+ assert(!lpp.isNaN(), "Invalid live price slippage tolerance");
680
688
  }
681
689
  if ("minPrice" in params) {
682
690
  assert(
@@ -699,7 +707,7 @@ function parseFoKParams(params, quote) {
699
707
  throw new Error("Either minPrice or slippageTolerancePercent must be provided");
700
708
  }
701
709
  const retryDurationBlocks = "retryDurationBlocks" in params ? params.retryDurationBlocks : Math.max(Math.ceil(params.retryDurationMinutes * blocksPerMinute), 0);
702
- const maxOraclePriceSlippage = livePriceSlippageTolerancePercent?.multipliedBy(100).toNumber() ?? null;
710
+ const maxOraclePriceSlippage = lpp?.multipliedBy(100).toNumber() ?? null;
703
711
  const parsed = {
704
712
  retryDurationBlocks,
705
713
  minPriceX128: getPriceX128FromPrice(minPrice, srcAsset, destAsset),
@@ -736,6 +744,7 @@ var getTokenContractAddress = (asset2, network) => {
736
744
  case "HubDot":
737
745
  case "HubUsdc":
738
746
  case "HubUsdt":
747
+ case "Trx":
739
748
  return void 0;
740
749
  default:
741
750
  return ADDRESSES[network][`${toUpperCase(asset2)}_CONTRACT_ADDRESS`];
@@ -756,7 +765,9 @@ var assetNames = {
756
765
  SolUsdt: "Solana USDT",
757
766
  HubDot: "Assethub DOT",
758
767
  HubUsdc: "Assethub USDC",
759
- HubUsdt: "Assethub USDT"
768
+ HubUsdt: "Assethub USDT",
769
+ Trx: "Tron",
770
+ TrxUsdt: "Tron USDT"
760
771
  };
761
772
  var getAssetData = (asset2, network, env) => {
762
773
  const assetConstant = assetConstants[asset2];
@@ -787,7 +798,7 @@ var getChainData = (chain2, network, env) => ({
787
798
 
788
799
  // package.json
789
800
  var package_default = {
790
- version: "2.1.0"};
801
+ version: "2.2.0-alpha.2"};
791
802
 
792
803
  // src/swap/consts.ts
793
804
  var CF_SDK_VERSION_HEADERS = { "X-Chainflip-Sdk-Version": package_default.version };
@@ -815,8 +826,8 @@ var getQuoteV2 = async (baseUrl, quoteRequest, { signal }) => {
815
826
  ccmGasBudget: quoteRequest.ccmParams.gasBudget,
816
827
  ccmMessageLengthBytes: String(quoteRequest.ccmParams.messageLengthBytes)
817
828
  },
818
- dcaEnabled: String(Boolean(quoteRequest.dcaEnabled)),
819
- dcaV2Enabled: String(Boolean(quoteRequest.dcaV2Enabled))
829
+ dcaV2Enabled: String(Boolean(quoteRequest.dcaV2Enabled)),
830
+ ...quoteRequest.brokerAccount && { brokerIdSs58: quoteRequest.brokerAccount }
820
831
  };
821
832
  const { data } = await axios.get("/v2/quote", {
822
833
  baseURL: baseUrl,
@@ -852,7 +863,6 @@ var SwapSDK = class {
852
863
  rpcConfig;
853
864
  apiClient;
854
865
  cache;
855
- dcaEnabled = false;
856
866
  dcaV2Enabled = false;
857
867
  constructor(options = {}) {
858
868
  const network = options.network ?? "perseverance";
@@ -869,7 +879,6 @@ var SwapSDK = class {
869
879
  baseHeaders: CF_SDK_VERSION_HEADERS
870
880
  });
871
881
  this.dcaV2Enabled = options.enabledFeatures?.dcaV2 ?? false;
872
- this.dcaEnabled = this.dcaV2Enabled || (options.enabledFeatures?.dca ?? false);
873
882
  this.cache = new MultiCache({
874
883
  environment: {
875
884
  fetch: () => getEnvironment(this.rpcConfig),
@@ -949,8 +958,8 @@ var SwapSDK = class {
949
958
  {
950
959
  ...quoteRequest,
951
960
  brokerCommissionBps: submitterBrokerCommissionBps,
952
- dcaEnabled: this.dcaEnabled,
953
- dcaV2Enabled: this.dcaV2Enabled
961
+ dcaV2Enabled: this.dcaV2Enabled,
962
+ brokerAccount: quoteRequest.brokerAccount ?? this.options.brokerAccount
954
963
  },
955
964
  options
956
965
  );
@@ -1035,7 +1044,6 @@ var SwapSDK = class {
1035
1044
  ccmParams,
1036
1045
  amount: quote.depositAmount
1037
1046
  };
1038
- await this.checkLivePriceProtectionRequirement(depositAddressRequest, quote);
1039
1047
  let response;
1040
1048
  if (this.options.broker) {
1041
1049
  const result = await requestSwapDepositAddress(
@@ -1126,7 +1134,6 @@ var SwapSDK = class {
1126
1134
  commissionBps: brokerCommissionBps,
1127
1135
  affiliates
1128
1136
  };
1129
- await this.checkLivePriceProtectionRequirement(vaultSwapRequest, quote);
1130
1137
  if (this.options.broker) {
1131
1138
  assert(
1132
1139
  !vaultSwapRequest.brokerAccount,
@@ -1153,6 +1160,7 @@ var SwapSDK = class {
1153
1160
  switch (res.body.chain) {
1154
1161
  case "Arbitrum":
1155
1162
  case "Ethereum":
1163
+ case "Tron":
1156
1164
  return { ...res.body, value: BigInt(res.body.value) };
1157
1165
  default:
1158
1166
  return res.body;
@@ -1188,7 +1196,6 @@ var SwapSDK = class {
1188
1196
  commissionBps: await this.getCommissionBps(brokerCommissionBps),
1189
1197
  affiliates
1190
1198
  };
1191
- await this.checkLivePriceProtectionRequirement(requestParams, quote);
1192
1199
  if (this.options.broker) {
1193
1200
  assert(
1194
1201
  !brokerAccount,
@@ -1235,21 +1242,6 @@ var SwapSDK = class {
1235
1242
  }
1236
1243
  return res.body;
1237
1244
  }
1238
- async checkLivePriceProtectionRequirement(request, quote) {
1239
- if (!this.dcaV2Enabled || quote.type !== "DCA") return;
1240
- const { assets: assets2 } = await this.cache.read("networkInfo");
1241
- const srcAsset = getInternalAsset(request.srcAsset);
1242
- const destAsset = getInternalAsset(request.destAsset);
1243
- if (![srcAsset, destAsset].every(
1244
- (asset2) => assets2.find((a) => a.asset === asset2)?.livePriceProtectionEnabled
1245
- )) {
1246
- return;
1247
- }
1248
- if (isNotNullish(request.fillOrKillParams.maxOraclePriceSlippage)) return;
1249
- throw new Error(
1250
- "Max oracle price slippage must be set in FillOrKillParams when live price protection is enabled for both assets in DCA V2"
1251
- );
1252
- }
1253
1245
  };
1254
1246
  var arrayToMap = (array) => Object.fromEntries(array.map((item) => [item, item]));
1255
1247
  var ChainflipNetworks = arrayToMap(chainflipNetworks);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/sdk",
3
- "version": "2.1.0",
3
+ "version": "2.2.0-alpha.2",
4
4
  "description": "",
5
5
  "exports": {
6
6
  "./swap": {
@@ -57,11 +57,11 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "@chainflip/bitcoin": "2.1.1",
60
- "@chainflip/rpc": "2.1.3",
61
- "@chainflip/solana": "2.2.2",
62
- "@chainflip/utils": "2.1.4",
60
+ "@chainflip/rpc": "2.2.0-alpha.4",
61
+ "@chainflip/solana": "2.2.3",
62
+ "@chainflip/utils": "2.2.0-alpha.2",
63
63
  "@ts-rest/core": "^3.52.1",
64
- "axios": "^1.10.0",
64
+ "axios": "^1.15.0",
65
65
  "bignumber.js": "^9.3.0",
66
66
  "ethers": "^6.14.4",
67
67
  "zod": "^3.25.76"