@avail-project/ca-common 2.0.0 → 2.2.0

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.
@@ -98,7 +98,18 @@ cots = [(1 COT, 1), (1 COT, 4)]
98
98
  break
99
99
  5. return quotes and assets used.
100
100
  */
101
+ /**
102
+ * @deprecated Use {@link autoSelectSources} (object args; per-holding `takerAddress` and
103
+ * `receiverAddress` on each `HoldingWithSwapAddresses`).
104
+ */
101
105
  export async function autoSelectSourcesV2(userAddress, holdings, outputRequired, aggregators, commonCurrencyID = CurrencyID.USDC) {
106
+ return autoSelectSourcesV2ByRecipient(holdings.map((holding) => ({ ...holding, recipient: userAddress })), outputRequired, aggregators, commonCurrencyID);
107
+ }
108
+ /**
109
+ * @deprecated Use {@link autoSelectSources} (object args; per-holding `takerAddress` and
110
+ * `receiverAddress` on each `HoldingWithSwapAddresses`).
111
+ */
112
+ export async function autoSelectSourcesV2ByRecipient(holdings, outputRequired, aggregators, commonCurrencyID = CurrencyID.USDC) {
102
113
  // Assumption: Holding is already sorted in usage priority
103
114
  console.debug("XCS | SSV2:", {
104
115
  holdings,
@@ -132,7 +143,10 @@ export async function autoSelectSourcesV2(userAddress, holdings, outputRequired,
132
143
  else {
133
144
  fullLiquidationQuotes.push({
134
145
  req: {
135
- userAddress,
146
+ userAddress: holding.recipient,
147
+ // New wrappers thread per-holding receiver via this field. Falls back to taker
148
+ // (`recipient`) when absent — preserves legacy positional-call behavior.
149
+ receiverAddress: holding.receiverAddress,
136
150
  type: QuoteType.EXACT_IN,
137
151
  chain: chain.ChainID,
138
152
  inputToken: holding.tokenAddress,
@@ -316,7 +330,11 @@ export async function autoSelectSourcesV2(userAddress, holdings, outputRequired,
316
330
  console.log("final_quotes", { quotes: final, cots: usedCOTs });
317
331
  return { quoteResponses: final, usedCOTs };
318
332
  }
319
- export async function determineDestinationSwaps(userAddress, requirement, aggregators, commonCurrencyID = CurrencyID.USDC) {
333
+ /**
334
+ * @deprecated Use {@link getDestinationExactOutSwap} (object args; explicit `takerAddress` and
335
+ * `receiverAddress`, both required).
336
+ */
337
+ export async function determineDestinationSwaps(userAddress, requirement, aggregators, commonCurrencyID = CurrencyID.USDC, receiverAddress) {
320
338
  const chaindata = ChaindataMap.get(requirement.chainID);
321
339
  if (chaindata == null) {
322
340
  throw new AutoSelectionError("Chain not found");
@@ -331,6 +349,7 @@ export async function determineDestinationSwaps(userAddress, requirement, aggreg
331
349
  type: QuoteType.EXACT_IN,
332
350
  chain: requirement.chainID,
333
351
  userAddress,
352
+ receiverAddress,
334
353
  inputToken: requirement.tokenAddress,
335
354
  outputToken: COT.tokenAddress,
336
355
  inputAmount: requirement.amountRaw,
@@ -354,6 +373,7 @@ export async function determineDestinationSwaps(userAddress, requirement, aggreg
354
373
  {
355
374
  type: QuoteType.EXACT_IN,
356
375
  userAddress,
376
+ receiverAddress,
357
377
  chain: requirement.chainID,
358
378
  inputToken: COT.tokenAddress,
359
379
  outputToken: requirement.tokenAddress,
@@ -385,7 +405,18 @@ export async function determineDestinationSwaps(userAddress, requirement, aggreg
385
405
  }
386
406
  }
387
407
  }
388
- export async function liquidateInputHoldings(userAddress, holdings, aggregators, commonCurrencyID = CurrencyID.USDC) {
408
+ /**
409
+ * @deprecated Use {@link liquidateSourceHoldings} (object args; per-holding `takerAddress`
410
+ * and `receiverAddress` on each `HoldingWithSwapAddresses`).
411
+ */
412
+ export async function liquidateInputHoldings(userAddress, holdings, aggregators, commonCurrencyID = CurrencyID.USDC, receiverAddress) {
413
+ return liquidateInputHoldingsByRecipient(holdings.map((holding) => ({ ...holding, recipient: userAddress })), aggregators, commonCurrencyID, receiverAddress);
414
+ }
415
+ /**
416
+ * @deprecated Use {@link liquidateSourceHoldings} (object args; per-holding `takerAddress`
417
+ * and `receiverAddress` on each `HoldingWithSwapAddresses`).
418
+ */
419
+ export async function liquidateInputHoldingsByRecipient(holdings, aggregators, commonCurrencyID = CurrencyID.USDC, receiverAddress) {
389
420
  console.debug("XCS | LIH | Holdings:", holdings);
390
421
  const groupedByChainID = groupBy(holdings, (h) => bytesToHex(h.chainID.toBytes()));
391
422
  const fullLiquidationQuotes = [];
@@ -409,7 +440,10 @@ export async function liquidateInputHoldings(userAddress, holdings, aggregators,
409
440
  }
410
441
  fullLiquidationQuotes.push({
411
442
  req: {
412
- userAddress,
443
+ userAddress: holding.recipient,
444
+ // Per-holding receiver wins (set by the new wrappers); shared param is the legacy
445
+ // positional-call fallback.
446
+ receiverAddress: holding.receiverAddress ?? receiverAddress,
413
447
  type: QuoteType.EXACT_IN,
414
448
  chain: chain.ChainID,
415
449
  inputToken: holding.tokenAddress,
@@ -438,7 +472,11 @@ export async function liquidateInputHoldings(userAddress, holdings, aggregators,
438
472
  }
439
473
  return quotes;
440
474
  }
441
- export async function destinationSwapWithExactIn(userAddress, omniChainID, inputAmount, outputToken, aggregators, inputCurrency = CurrencyID.USDC) {
475
+ /**
476
+ * @deprecated Use {@link getDestinationExactInSwap} (object args; explicit `takerAddress`
477
+ * and `receiverAddress`, both required).
478
+ */
479
+ export async function destinationSwapWithExactIn(userAddress, omniChainID, inputAmount, outputToken, aggregators, inputCurrency = CurrencyID.USDC, receiverAddress) {
442
480
  const chaindata = ChaindataMap.get(omniChainID);
443
481
  if (chaindata == null) {
444
482
  throw new AutoSelectionError("Chain not found");
@@ -452,6 +490,7 @@ export async function destinationSwapWithExactIn(userAddress, omniChainID, input
452
490
  type: QuoteType.EXACT_IN,
453
491
  chain: omniChainID,
454
492
  userAddress,
493
+ receiverAddress,
455
494
  inputToken: COT.tokenAddress,
456
495
  outputToken: outputToken,
457
496
  inputAmount: inputAmount,
@@ -476,3 +515,40 @@ export async function destinationSwapWithExactIn(userAddress, omniChainID, input
476
515
  },
477
516
  };
478
517
  }
518
+ // =====================================================================================
519
+ // Object-arg wrappers around the legacy positional functions above.
520
+ //
521
+ // Aggregator vocabulary:
522
+ // takerAddress — on-chain executor of the swap (drives aggregator simulation /
523
+ // permit / approval routing). On 7702 chains this is the ephemeral; on
524
+ // non-Pectra chains it's the deployed Safe. Maps to the underlying
525
+ // QuoteRequest's `userAddress`.
526
+ // receiverAddress — recipient of the swap output. Maps to the underlying QuoteRequest's
527
+ // `receiverAddress`. Required on all 4 wrappers — the GS013-class bug we
528
+ // fixed came from forgetting this and silently defaulting to the wrong
529
+ // address. Even on source side (where it equals the taker today), require
530
+ // it explicitly so the type system forces every call site to acknowledge
531
+ // both roles.
532
+ //
533
+ // Wrap-only: each wrapper delegates to the deprecated positional fn. No business logic added.
534
+ // =====================================================================================
535
+ export async function getDestinationExactOutSwap(args) {
536
+ return determineDestinationSwaps(args.takerAddress, args.requirement, args.aggregators, args.commonCurrencyID, args.receiverAddress);
537
+ }
538
+ export async function getDestinationExactInSwap(args) {
539
+ return destinationSwapWithExactIn(args.takerAddress, args.chain, args.inputAmount, args.outputToken, args.aggregators, args.inputCurrency, args.receiverAddress);
540
+ }
541
+ export async function liquidateSourceHoldings(args) {
542
+ return liquidateInputHoldingsByRecipient(args.holdings.map((h) => ({
543
+ ...h,
544
+ recipient: h.takerAddress,
545
+ receiverAddress: h.receiverAddress,
546
+ })), args.aggregators, args.commonCurrencyID);
547
+ }
548
+ export async function autoSelectSources(args) {
549
+ return autoSelectSourcesV2ByRecipient(args.holdings.map((h) => ({
550
+ ...h,
551
+ recipient: h.takerAddress,
552
+ receiverAddress: h.receiverAddress,
553
+ })), args.outputRequired, args.aggregators, args.commonCurrencyID);
554
+ }
@@ -10,17 +10,11 @@ const ChainNameMapping = new Map(Object.entries({
10
10
  arbitrum: 42161,
11
11
  optimism: 10,
12
12
  base: 8453,
13
- taiko: 167000,
14
13
  bsc: 56,
15
- monadtestnet: 10143,
16
- megaethtestnet: 6342,
17
- berachain: 80094,
14
+ avalanche: 43114,
18
15
  polygon: 137,
19
- zksync: 324,
20
- blast: 81457,
21
- mode: 34443,
22
16
  scroll: 534352,
23
- superseed: 5330,
17
+ hyperevm: 999,
24
18
  }).map(([k, v]) => [bytesToHex(encodeChainID36(Universe.ETHEREUM, v)), k]));
25
19
  export class BebopAggregator {
26
20
  static BASE_URL = "https://api.bebop.xyz/router";
@@ -52,6 +46,9 @@ export class BebopAggregator {
52
46
  const inputTokenAddr = getAddress(bytesToHex(r.inputToken.subarray(12)));
53
47
  const outputTokenAddr = getAddress(bytesToHex(r.outputToken.subarray(12)));
54
48
  const userAddrHex = getAddress(bytesToHex(r.userAddress.subarray(12)));
49
+ const receiverAddrHex = r.receiverAddress != null
50
+ ? getAddress(bytesToHex(r.receiverAddress.subarray(12)))
51
+ : userAddrHex;
55
52
  switch (r.type) {
56
53
  case QuoteType.EXACT_IN: {
57
54
  respPromise = this.axios({
@@ -61,6 +58,7 @@ export class BebopAggregator {
61
58
  sell_tokens: inputTokenAddr,
62
59
  buy_tokens: outputTokenAddr,
63
60
  taker_address: userAddrHex,
61
+ receiver_address: receiverAddrHex,
64
62
  sell_amounts: r.inputAmount.toString(),
65
63
  ...BebopAggregator.COMMON_OPTIONS,
66
64
  },
@@ -75,6 +73,7 @@ export class BebopAggregator {
75
73
  sell_tokens: inputTokenAddr,
76
74
  buy_tokens: outputTokenAddr,
77
75
  taker_address: userAddrHex,
76
+ receiver_address: receiverAddrHex,
78
77
  buy_amounts: r.outputAmount.toString(),
79
78
  ...BebopAggregator.COMMON_OPTIONS,
80
79
  },
@@ -0,0 +1,147 @@
1
+ import axios, { AxiosError } from "axios";
2
+ import Decimal from "decimal.js";
3
+ import { bytesToHex, encodeFunctionData, getAddress, toHex, zeroAddress, } from "viem";
4
+ import { ChainIDKeyedMap, OmniversalChainID } from "../data";
5
+ import { FibrousRouterABI } from "../evmabi";
6
+ import { Universe } from "../proto/definition";
7
+ import { QuoteType, } from "./iface";
8
+ const ChainNameMapping = new ChainIDKeyedMap([
9
+ // [new OmniversalChainID(Universe.ETHEREUM, 8453), "base"], // Disabled because of few liquidity issues
10
+ [new OmniversalChainID(Universe.ETHEREUM, 999), "hyperevm"],
11
+ [new OmniversalChainID(Universe.ETHEREUM, 143), "monad"],
12
+ [new OmniversalChainID(Universe.ETHEREUM, 4114), "citrea"],
13
+ ]);
14
+ export class FibrousAggregator {
15
+ static BASE_URL = "https://api.fibrous.finance";
16
+ axios;
17
+ slippage;
18
+ constructor(options = {}) {
19
+ const { apiKey, slippage = 0.5 } = options;
20
+ this.slippage = slippage;
21
+ this.axios = axios.create({
22
+ baseURL: FibrousAggregator.BASE_URL,
23
+ headers: apiKey != null ? { "X-API-Key": apiKey } : undefined,
24
+ timeout: 10_000,
25
+ });
26
+ }
27
+ async getQuotes(requests) {
28
+ const list = await Promise.allSettled(requests.map(async (r) => {
29
+ if (r.type === QuoteType.EXACT_OUT) {
30
+ return null;
31
+ }
32
+ if (r.chain.universe !== Universe.ETHEREUM) {
33
+ return null;
34
+ }
35
+ const chainName = ChainNameMapping.get(r.chain);
36
+ if (chainName == null) {
37
+ return null;
38
+ }
39
+ const inputTokenAddr = getAddress(bytesToHex(r.inputToken.subarray(12)));
40
+ const outputTokenAddr = getAddress(bytesToHex(r.outputToken.subarray(12)));
41
+ const userAddrHex = getAddress(bytesToHex(r.userAddress.subarray(12)));
42
+ const receiverAddrHex = r.receiverAddress != null
43
+ ? getAddress(bytesToHex(r.receiverAddress.subarray(12)))
44
+ : userAddrHex;
45
+ let resp;
46
+ try {
47
+ resp = await this.axios({
48
+ method: "GET",
49
+ url: `/${chainName}/v2/routeAndCallData`,
50
+ params: {
51
+ amount: r.inputAmount.toString(),
52
+ tokenInAddress: inputTokenAddr,
53
+ tokenOutAddress: outputTokenAddr,
54
+ slippage: this.slippage,
55
+ destination: receiverAddrHex,
56
+ },
57
+ });
58
+ }
59
+ catch (e) {
60
+ if (e instanceof AxiosError && e.isAxiosError) {
61
+ return null;
62
+ }
63
+ throw e;
64
+ }
65
+ if (!resp.data.route.success) {
66
+ return null;
67
+ }
68
+ if (resp.data.calldata.swap_parameters.length === 0) {
69
+ return null;
70
+ }
71
+ const inputAmountInDecimal = new Decimal(resp.data.route.inputAmount)
72
+ .div(Decimal.pow(10, resp.data.route.inputToken.decimals))
73
+ .toFixed(resp.data.route.inputToken.decimals);
74
+ const outputAmountInDecimal = new Decimal(resp.data.calldata.route.min_received)
75
+ .div(Decimal.pow(10, resp.data.route.outputToken.decimals))
76
+ .toFixed(resp.data.route.outputToken.decimals);
77
+ const routerAddress = getAddress(resp.data.router_address);
78
+ const isNativeInput = resp.data.calldata.route.swap_type === 0;
79
+ const quote = {
80
+ originalResponse: resp.data,
81
+ input: {
82
+ amount: inputAmountInDecimal,
83
+ amountRaw: BigInt(resp.data.route.inputAmount),
84
+ contractAddress: inputTokenAddr,
85
+ decimals: resp.data.route.inputToken.decimals,
86
+ value: Decimal.mul(inputAmountInDecimal, resp.data.route.inputToken.price ?? 0).toNumber(),
87
+ symbol: resp.data.route.inputToken.symbol ??
88
+ resp.data.route.inputToken.name,
89
+ },
90
+ output: {
91
+ amount: outputAmountInDecimal,
92
+ amountRaw: BigInt(resp.data.calldata.route.min_received),
93
+ contractAddress: outputTokenAddr,
94
+ decimals: resp.data.route.outputToken.decimals,
95
+ value: Decimal.mul(outputAmountInDecimal, resp.data.route.outputToken.price ?? 0).toNumber(),
96
+ symbol: resp.data.route.outputToken.symbol ??
97
+ resp.data.route.outputToken.name,
98
+ },
99
+ txData: {
100
+ approvalAddress: isNativeInput ? zeroAddress : routerAddress,
101
+ tx: {
102
+ to: routerAddress,
103
+ value: isNativeInput
104
+ ? toHex(BigInt(resp.data.calldata.route.amount_in))
105
+ : toHex(0),
106
+ data: encodeFunctionData({
107
+ abi: FibrousRouterABI,
108
+ functionName: "swap",
109
+ args: [
110
+ {
111
+ token_in: getAddress(resp.data.calldata.route.token_in),
112
+ token_out: getAddress(resp.data.calldata.route.token_out),
113
+ amount_in: BigInt(resp.data.calldata.route.amount_in),
114
+ amount_out: BigInt(resp.data.calldata.route.amount_out),
115
+ min_received: BigInt(resp.data.calldata.route.min_received),
116
+ destination: getAddress(resp.data.calldata.route.destination),
117
+ swap_type: resp.data.calldata.route.swap_type,
118
+ },
119
+ resp.data.calldata.swap_parameters.map((swapParameter) => ({
120
+ token_in: getAddress(swapParameter.token_in),
121
+ token_out: getAddress(swapParameter.token_out),
122
+ rate: Number.parseInt(swapParameter.rate, 10),
123
+ protocol_id: Number.parseInt(swapParameter.protocol_id, 10),
124
+ pool_address: getAddress(swapParameter.pool_address),
125
+ swap_type: swapParameter.swap_type,
126
+ extra_data: swapParameter.extra_data,
127
+ })),
128
+ ],
129
+ }),
130
+ },
131
+ },
132
+ };
133
+ return quote;
134
+ }));
135
+ return list.map((item) => {
136
+ switch (item.status) {
137
+ case "fulfilled": {
138
+ return item.value;
139
+ }
140
+ case "rejected": {
141
+ console.error("Caught error in fetching Fibrous quotes:", item.reason);
142
+ return null;
143
+ }
144
+ }
145
+ });
146
+ }
147
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './iface';
2
2
  export * from './lifi-agg';
3
3
  export * from './bebop-agg';
4
+ export * from './fibrous-agg';
4
5
  export * from './autochoice';
@@ -3,6 +3,20 @@ import { bytesToHex, getAddress } from "viem";
3
3
  import { QuoteType, } from "./iface";
4
4
  import { Universe } from "../proto/definition";
5
5
  import Decimal from "decimal.js";
6
+ const ALLOWED_CHAINS = new Set([
7
+ 1, // Ethereum
8
+ 10, // Optimism
9
+ 56, // BSC
10
+ 137, // Polygon
11
+ 143, // Monad
12
+ 999, // HyperEVM
13
+ 4326, // MegaETH
14
+ 8453, // Base
15
+ 42161, // Arbitrum
16
+ 43114, // Avalanche
17
+ 8217, // Kaia
18
+ 534352, // Scroll
19
+ ]);
6
20
  export class LiFiAggregator {
7
21
  static BASE_URL_V1 = "https://li.quest/v1";
8
22
  static COMMON_OPTIONS = {
@@ -25,11 +39,17 @@ export class LiFiAggregator {
25
39
  if (r.chain.universe !== Universe.ETHEREUM) {
26
40
  return null;
27
41
  }
42
+ if (!ALLOWED_CHAINS.has(Number(r.chain.chainID))) {
43
+ return null;
44
+ }
28
45
  let respPromise;
29
46
  const chIDStr = r.chain.chainID.toString();
30
47
  const inputTokenAddr = getAddress(bytesToHex(r.inputToken.subarray(12)));
31
48
  const outputTokenAddr = getAddress(bytesToHex(r.outputToken.subarray(12)));
32
49
  const userAddrHex = getAddress(bytesToHex(r.userAddress.subarray(12)));
50
+ const receiverAddrHex = r.receiverAddress != null
51
+ ? getAddress(bytesToHex(r.receiverAddress.subarray(12)))
52
+ : userAddrHex;
33
53
  switch (r.type) {
34
54
  case QuoteType.EXACT_IN: {
35
55
  respPromise = this.axios({
@@ -41,6 +61,7 @@ export class LiFiAggregator {
41
61
  fromToken: inputTokenAddr,
42
62
  toToken: outputTokenAddr,
43
63
  fromAddress: userAddrHex,
64
+ toAddress: receiverAddrHex,
44
65
  fromAmount: r.inputAmount.toString(),
45
66
  ...LiFiAggregator.COMMON_OPTIONS,
46
67
  },
@@ -57,6 +78,7 @@ export class LiFiAggregator {
57
78
  fromToken: inputTokenAddr,
58
79
  toToken: outputTokenAddr,
59
80
  fromAddress: userAddrHex,
81
+ toAddress: receiverAddrHex,
60
82
  toAmount: r.outputAmount.toString(),
61
83
  ...LiFiAggregator.COMMON_OPTIONS,
62
84
  },
@@ -0,0 +1,77 @@
1
+ export declare const FibrousRouterABI: readonly [{
2
+ readonly inputs: readonly [{
3
+ readonly components: readonly [{
4
+ readonly internalType: "address";
5
+ readonly name: "token_in";
6
+ readonly type: "address";
7
+ }, {
8
+ readonly internalType: "address";
9
+ readonly name: "token_out";
10
+ readonly type: "address";
11
+ }, {
12
+ readonly internalType: "uint256";
13
+ readonly name: "amount_in";
14
+ readonly type: "uint256";
15
+ }, {
16
+ readonly internalType: "uint256";
17
+ readonly name: "amount_out";
18
+ readonly type: "uint256";
19
+ }, {
20
+ readonly internalType: "uint256";
21
+ readonly name: "min_received";
22
+ readonly type: "uint256";
23
+ }, {
24
+ readonly internalType: "address";
25
+ readonly name: "destination";
26
+ readonly type: "address";
27
+ }, {
28
+ readonly internalType: "uint8";
29
+ readonly name: "swap_type";
30
+ readonly type: "uint8";
31
+ }];
32
+ readonly internalType: "struct IFibrousRouter.RouteParam";
33
+ readonly name: "route";
34
+ readonly type: "tuple";
35
+ }, {
36
+ readonly components: readonly [{
37
+ readonly internalType: "address";
38
+ readonly name: "token_in";
39
+ readonly type: "address";
40
+ }, {
41
+ readonly internalType: "address";
42
+ readonly name: "token_out";
43
+ readonly type: "address";
44
+ }, {
45
+ readonly internalType: "uint32";
46
+ readonly name: "rate";
47
+ readonly type: "uint32";
48
+ }, {
49
+ readonly internalType: "int24";
50
+ readonly name: "protocol_id";
51
+ readonly type: "int24";
52
+ }, {
53
+ readonly internalType: "address";
54
+ readonly name: "pool_address";
55
+ readonly type: "address";
56
+ }, {
57
+ readonly internalType: "uint8";
58
+ readonly name: "swap_type";
59
+ readonly type: "uint8";
60
+ }, {
61
+ readonly internalType: "bytes";
62
+ readonly name: "extra_data";
63
+ readonly type: "bytes";
64
+ }];
65
+ readonly internalType: "struct IFibrousRouter.SwapParams[]";
66
+ readonly name: "swap_parameters";
67
+ readonly type: "tuple[]";
68
+ }];
69
+ readonly name: "swap";
70
+ readonly outputs: readonly [{
71
+ readonly internalType: "uint256";
72
+ readonly name: "";
73
+ readonly type: "uint256";
74
+ }];
75
+ readonly stateMutability: "payable";
76
+ readonly type: "function";
77
+ }];
@@ -1,3 +1,4 @@
1
1
  export * from './erc20.abi';
2
2
  export * from './vault.abi';
3
3
  export * from './yakaggregator.abi';
4
+ export * from './fibrousrouter.abi';
@@ -227,12 +227,18 @@ export interface AdminFeeRecipient {
227
227
  universe: Universe;
228
228
  address: Uint8Array;
229
229
  }
230
+ export interface PerChainFeeBP {
231
+ universe: Universe;
232
+ chainID: Uint8Array;
233
+ feeBP: Long;
234
+ }
230
235
  export interface ProtocolFees {
231
236
  feeBP: Long;
232
237
  collectionFees: FixedFeeTuple[];
233
238
  fulfilmentFees: FixedFeeTuple[];
234
239
  admin: string;
235
240
  feeRecipients: AdminFeeRecipient[];
241
+ perChainFeeBP: PerChainFeeBP[];
236
242
  }
237
243
  export interface QueryGetProtocolFeesRequest {
238
244
  }
@@ -245,6 +251,7 @@ export interface MsgCreateProtocolFees {
245
251
  collectionFees: FixedFeeTuple[];
246
252
  fulfilmentFees: FixedFeeTuple[];
247
253
  feeRecipients: AdminFeeRecipient[];
254
+ perChainFeeBP: PerChainFeeBP[];
248
255
  }
249
256
  export interface MsgCreateProtocolFeesResponse {
250
257
  }
@@ -254,6 +261,7 @@ export interface MsgUpdateProtocolFees {
254
261
  collectionFees: FixedFeeTuple[];
255
262
  fulfilmentFees: FixedFeeTuple[];
256
263
  feeRecipients: AdminFeeRecipient[];
264
+ perChainFeeBP: PerChainFeeBP[];
257
265
  }
258
266
  export interface MsgUpdateProtocolFeesResponse {
259
267
  }
@@ -330,6 +338,7 @@ export declare const QueryAllSettlementResponse: MessageFns<QueryAllSettlementRe
330
338
  export declare const QueryRequestForFundsByAddressRequest: MessageFns<QueryRequestForFundsByAddressRequest>;
331
339
  export declare const FixedFeeTuple: MessageFns<FixedFeeTuple>;
332
340
  export declare const AdminFeeRecipient: MessageFns<AdminFeeRecipient>;
341
+ export declare const PerChainFeeBP: MessageFns<PerChainFeeBP>;
333
342
  export declare const ProtocolFees: MessageFns<ProtocolFees>;
334
343
  export declare const QueryGetProtocolFeesRequest: MessageFns<QueryGetProtocolFeesRequest>;
335
344
  export declare const QueryGetProtocolFeesResponse: MessageFns<QueryGetProtocolFeesResponse>;
@@ -3,6 +3,14 @@ import { Aggregator, Quote, QuoteRequestExactInput, QuoteRequestExactOutput, Quo
3
3
  import { Currency, CurrencyID, OmniversalChainID } from "../data";
4
4
  import { Bytes } from "../types";
5
5
  import { Holding } from "./iface";
6
+ export type HoldingWithRecipient = Holding & {
7
+ recipient: Bytes;
8
+ receiverAddress?: Bytes;
9
+ };
10
+ export type HoldingWithSwapAddresses = Holding & {
11
+ takerAddress: Bytes;
12
+ receiverAddress: Bytes;
13
+ };
6
14
  export declare class AutoSelectionError extends Error {
7
15
  }
8
16
  declare const enum AggregateAggregatorsMode {
@@ -13,6 +21,10 @@ export declare function aggregateAggregators(requests: (QuoteRequestExactInput |
13
21
  quote: Quote | null;
14
22
  aggregator: Aggregator;
15
23
  }[]>;
24
+ /**
25
+ * @deprecated Use {@link autoSelectSources} (object args; per-holding `takerAddress` and
26
+ * `receiverAddress` on each `HoldingWithSwapAddresses`).
27
+ */
16
28
  export declare function autoSelectSourcesV2(userAddress: Bytes, holdings: Holding[], outputRequired: Decimal, aggregators: Aggregator[], commonCurrencyID?: CurrencyID): Promise<{
17
29
  quoteResponses: QuoteResponse[];
18
30
  usedCOTs: {
@@ -22,7 +34,72 @@ export declare function autoSelectSourcesV2(userAddress: Bytes, holdings: Holdin
22
34
  cur: Currency;
23
35
  }[];
24
36
  }>;
25
- export declare function determineDestinationSwaps(userAddress: Bytes, requirement: Holding, aggregators: Aggregator[], commonCurrencyID?: CurrencyID): Promise<QuoteResponse>;
26
- export declare function liquidateInputHoldings(userAddress: Bytes, holdings: Holding[], aggregators: Aggregator[], commonCurrencyID?: CurrencyID): Promise<QuoteResponse[]>;
27
- export declare function destinationSwapWithExactIn(userAddress: Bytes, omniChainID: OmniversalChainID, inputAmount: bigint, outputToken: Bytes, aggregators: Aggregator[], inputCurrency?: CurrencyID): Promise<QuoteResponse>;
37
+ /**
38
+ * @deprecated Use {@link autoSelectSources} (object args; per-holding `takerAddress` and
39
+ * `receiverAddress` on each `HoldingWithSwapAddresses`).
40
+ */
41
+ export declare function autoSelectSourcesV2ByRecipient(holdings: HoldingWithRecipient[], outputRequired: Decimal, aggregators: Aggregator[], commonCurrencyID?: CurrencyID): Promise<{
42
+ quoteResponses: QuoteResponse[];
43
+ usedCOTs: {
44
+ originalHolding: Holding;
45
+ amountUsed: Decimal;
46
+ idx: number;
47
+ cur: Currency;
48
+ }[];
49
+ }>;
50
+ /**
51
+ * @deprecated Use {@link getDestinationExactOutSwap} (object args; explicit `takerAddress` and
52
+ * `receiverAddress`, both required).
53
+ */
54
+ export declare function determineDestinationSwaps(userAddress: Bytes, requirement: Holding, aggregators: Aggregator[], commonCurrencyID?: CurrencyID, receiverAddress?: Bytes): Promise<QuoteResponse>;
55
+ /**
56
+ * @deprecated Use {@link liquidateSourceHoldings} (object args; per-holding `takerAddress`
57
+ * and `receiverAddress` on each `HoldingWithSwapAddresses`).
58
+ */
59
+ export declare function liquidateInputHoldings(userAddress: Bytes, holdings: Holding[], aggregators: Aggregator[], commonCurrencyID?: CurrencyID, receiverAddress?: Bytes): Promise<QuoteResponse[]>;
60
+ /**
61
+ * @deprecated Use {@link liquidateSourceHoldings} (object args; per-holding `takerAddress`
62
+ * and `receiverAddress` on each `HoldingWithSwapAddresses`).
63
+ */
64
+ export declare function liquidateInputHoldingsByRecipient(holdings: HoldingWithRecipient[], aggregators: Aggregator[], commonCurrencyID?: CurrencyID, receiverAddress?: Bytes): Promise<QuoteResponse[]>;
65
+ /**
66
+ * @deprecated Use {@link getDestinationExactInSwap} (object args; explicit `takerAddress`
67
+ * and `receiverAddress`, both required).
68
+ */
69
+ export declare function destinationSwapWithExactIn(userAddress: Bytes, omniChainID: OmniversalChainID, inputAmount: bigint, outputToken: Bytes, aggregators: Aggregator[], inputCurrency?: CurrencyID, receiverAddress?: Bytes): Promise<QuoteResponse>;
70
+ export declare function getDestinationExactOutSwap(args: {
71
+ takerAddress: Bytes;
72
+ receiverAddress: Bytes;
73
+ requirement: Holding;
74
+ aggregators: Aggregator[];
75
+ commonCurrencyID?: CurrencyID;
76
+ }): Promise<QuoteResponse>;
77
+ export declare function getDestinationExactInSwap(args: {
78
+ takerAddress: Bytes;
79
+ receiverAddress: Bytes;
80
+ chain: OmniversalChainID;
81
+ inputAmount: bigint;
82
+ outputToken: Bytes;
83
+ aggregators: Aggregator[];
84
+ inputCurrency?: CurrencyID;
85
+ }): Promise<QuoteResponse>;
86
+ export declare function liquidateSourceHoldings(args: {
87
+ holdings: HoldingWithSwapAddresses[];
88
+ aggregators: Aggregator[];
89
+ commonCurrencyID?: CurrencyID;
90
+ }): Promise<QuoteResponse[]>;
91
+ export declare function autoSelectSources(args: {
92
+ holdings: HoldingWithSwapAddresses[];
93
+ outputRequired: Decimal;
94
+ aggregators: Aggregator[];
95
+ commonCurrencyID?: CurrencyID;
96
+ }): Promise<{
97
+ quoteResponses: QuoteResponse[];
98
+ usedCOTs: {
99
+ originalHolding: Holding;
100
+ amountUsed: Decimal;
101
+ idx: number;
102
+ cur: Currency;
103
+ }[];
104
+ }>;
28
105
  export {};