@avail-project/ca-common 2.2.1 → 3.0.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.
Files changed (92) hide show
  1. package/dist/cjs/index.js +10593 -20
  2. package/dist/esm/index.mjs +10603 -0
  3. package/dist/types/index.d.ts +2608 -13
  4. package/package.json +41 -37
  5. package/dist/cjs/_polyfill.js +0 -147
  6. package/dist/cjs/balances/ub-api.js +0 -25
  7. package/dist/cjs/cosmos/index.js +0 -31
  8. package/dist/cjs/data/chaindata.js +0 -788
  9. package/dist/cjs/data/chainid.js +0 -93
  10. package/dist/cjs/data/currency.js +0 -78
  11. package/dist/cjs/data/index.js +0 -7
  12. package/dist/cjs/data/utils.js +0 -44
  13. package/dist/cjs/evmabi/erc20.abi.js +0 -349
  14. package/dist/cjs/evmabi/fibrousrouter.abi.js +0 -41
  15. package/dist/cjs/evmabi/index.js +0 -7
  16. package/dist/cjs/evmabi/vault.abi.js +0 -1021
  17. package/dist/cjs/evmabi/yakaggregator.abi.js +0 -275
  18. package/dist/cjs/permitutils/index.js +0 -186
  19. package/dist/cjs/proto/client.js +0 -48
  20. package/dist/cjs/proto/definition.js +0 -4131
  21. package/dist/cjs/proto/grpc.js +0 -298
  22. package/dist/cjs/rff/rff.js +0 -42
  23. package/dist/cjs/types/binarytypes.js +0 -2
  24. package/dist/cjs/types/index.js +0 -5
  25. package/dist/cjs/types/msgpack-axios.js +0 -22
  26. package/dist/cjs/vaultcontracts/index.js +0 -4
  27. package/dist/cjs/vaultcontracts/vaultcontracts.js +0 -222
  28. package/dist/cjs/xcs/autochoice.js +0 -570
  29. package/dist/cjs/xcs/bebop-agg.js +0 -156
  30. package/dist/cjs/xcs/fibrous-agg.js +0 -155
  31. package/dist/cjs/xcs/iface.js +0 -13
  32. package/dist/cjs/xcs/index.js +0 -8
  33. package/dist/cjs/xcs/lifi-agg.js +0 -155
  34. package/dist/esm/_polyfill.js +0 -143
  35. package/dist/esm/balances/ub-api.js +0 -21
  36. package/dist/esm/cosmos/index.js +0 -26
  37. package/dist/esm/data/chaindata.js +0 -785
  38. package/dist/esm/data/chainid.js +0 -87
  39. package/dist/esm/data/currency.js +0 -73
  40. package/dist/esm/data/index.js +0 -4
  41. package/dist/esm/data/utils.js +0 -34
  42. package/dist/esm/evmabi/erc20.abi.js +0 -346
  43. package/dist/esm/evmabi/fibrousrouter.abi.js +0 -38
  44. package/dist/esm/evmabi/index.js +0 -4
  45. package/dist/esm/evmabi/vault.abi.js +0 -1018
  46. package/dist/esm/evmabi/yakaggregator.abi.js +0 -272
  47. package/dist/esm/index.js +0 -13
  48. package/dist/esm/permitutils/index.js +0 -181
  49. package/dist/esm/proto/client.js +0 -11
  50. package/dist/esm/proto/definition.js +0 -4122
  51. package/dist/esm/proto/grpc.js +0 -292
  52. package/dist/esm/rff/rff.js +0 -38
  53. package/dist/esm/types/binarytypes.js +0 -1
  54. package/dist/esm/types/index.js +0 -2
  55. package/dist/esm/types/msgpack-axios.js +0 -18
  56. package/dist/esm/vaultcontracts/index.js +0 -1
  57. package/dist/esm/vaultcontracts/vaultcontracts.js +0 -218
  58. package/dist/esm/xcs/autochoice.js +0 -554
  59. package/dist/esm/xcs/bebop-agg.js +0 -151
  60. package/dist/esm/xcs/fibrous-agg.js +0 -150
  61. package/dist/esm/xcs/iface.js +0 -10
  62. package/dist/esm/xcs/index.js +0 -5
  63. package/dist/esm/xcs/lifi-agg.js +0 -150
  64. package/dist/types/_polyfill.d.ts +0 -1
  65. package/dist/types/balances/ub-api.d.ts +0 -14
  66. package/dist/types/cosmos/index.d.ts +0 -6
  67. package/dist/types/data/chaindata.d.ts +0 -20
  68. package/dist/types/data/chainid.d.ts +0 -31
  69. package/dist/types/data/currency.d.ts +0 -30
  70. package/dist/types/data/index.d.ts +0 -4
  71. package/dist/types/data/utils.d.ts +0 -10
  72. package/dist/types/evmabi/erc20.abi.d.ts +0 -264
  73. package/dist/types/evmabi/fibrousrouter.abi.d.ts +0 -77
  74. package/dist/types/evmabi/index.d.ts +0 -4
  75. package/dist/types/evmabi/vault.abi.d.ts +0 -785
  76. package/dist/types/evmabi/yakaggregator.abi.d.ts +0 -298
  77. package/dist/types/permitutils/index.d.ts +0 -13
  78. package/dist/types/proto/client.d.ts +0 -2
  79. package/dist/types/proto/definition.d.ts +0 -382
  80. package/dist/types/proto/grpc.d.ts +0 -75
  81. package/dist/types/rff/rff.d.ts +0 -9
  82. package/dist/types/types/binarytypes.d.ts +0 -1
  83. package/dist/types/types/index.d.ts +0 -2
  84. package/dist/types/types/msgpack-axios.d.ts +0 -1
  85. package/dist/types/vaultcontracts/index.d.ts +0 -22
  86. package/dist/types/vaultcontracts/vaultcontracts.d.ts +0 -8
  87. package/dist/types/xcs/autochoice.d.ts +0 -105
  88. package/dist/types/xcs/bebop-agg.d.ts +0 -104
  89. package/dist/types/xcs/fibrous-agg.d.ts +0 -56
  90. package/dist/types/xcs/iface.d.ts +0 -69
  91. package/dist/types/xcs/index.d.ts +0 -5
  92. package/dist/types/xcs/lifi-agg.d.ts +0 -39
@@ -1,151 +0,0 @@
1
- import axios, { AxiosError } from "axios";
2
- import { bytesToHex, getAddress } from "viem";
3
- import { QuoteType, } from "./iface";
4
- import { Universe } from "../proto/definition";
5
- import { encodeChainID36 } from "../data";
6
- import Decimal from "decimal.js";
7
- // https://api.bebop.xyz/{jam|pmm}/chains
8
- const ChainNameMapping = new Map(Object.entries({
9
- ethereum: 1,
10
- arbitrum: 42161,
11
- optimism: 10,
12
- base: 8453,
13
- bsc: 56,
14
- avalanche: 43114,
15
- polygon: 137,
16
- scroll: 534352,
17
- hyperevm: 999,
18
- }).map(([k, v]) => [bytesToHex(encodeChainID36(Universe.ETHEREUM, v)), k]));
19
- export class BebopAggregator {
20
- static BASE_URL = "https://api.bebop.xyz/router";
21
- static COMMON_OPTIONS = {
22
- approval_type: "Standard",
23
- skip_validation: "true",
24
- gasless: false,
25
- };
26
- axios;
27
- constructor(apiKey) {
28
- this.axios = axios.create({
29
- baseURL: BebopAggregator.BASE_URL,
30
- headers: {
31
- "Source-Auth": apiKey,
32
- },
33
- params: {
34
- source: "arcana",
35
- },
36
- timeout: 10_000,
37
- });
38
- }
39
- async getQuotes(requests) {
40
- const list = await Promise.allSettled(requests.map(async (r) => {
41
- const chainName = ChainNameMapping.get(bytesToHex(r.chain.toBytes()));
42
- if (chainName == null) {
43
- return null;
44
- }
45
- let respPromise;
46
- const inputTokenAddr = getAddress(bytesToHex(r.inputToken.subarray(12)));
47
- const outputTokenAddr = getAddress(bytesToHex(r.outputToken.subarray(12)));
48
- const userAddrHex = getAddress(bytesToHex(r.userAddress.subarray(12)));
49
- const receiverAddrHex = r.receiverAddress != null
50
- ? getAddress(bytesToHex(r.receiverAddress.subarray(12)))
51
- : userAddrHex;
52
- switch (r.type) {
53
- case QuoteType.EXACT_IN: {
54
- respPromise = this.axios({
55
- method: "GET",
56
- url: `/${chainName}/v1/quote`,
57
- params: {
58
- sell_tokens: inputTokenAddr,
59
- buy_tokens: outputTokenAddr,
60
- taker_address: userAddrHex,
61
- receiver_address: receiverAddrHex,
62
- sell_amounts: r.inputAmount.toString(),
63
- ...BebopAggregator.COMMON_OPTIONS,
64
- },
65
- });
66
- break;
67
- }
68
- case QuoteType.EXACT_OUT: {
69
- respPromise = this.axios({
70
- method: "GET",
71
- url: `/${chainName}/v1/quote`,
72
- params: {
73
- sell_tokens: inputTokenAddr,
74
- buy_tokens: outputTokenAddr,
75
- taker_address: userAddrHex,
76
- receiver_address: receiverAddrHex,
77
- buy_amounts: r.outputAmount.toString(),
78
- ...BebopAggregator.COMMON_OPTIONS,
79
- },
80
- });
81
- break;
82
- }
83
- }
84
- let resp;
85
- try {
86
- resp = await respPromise;
87
- }
88
- catch (e) {
89
- if (e instanceof AxiosError && e.isAxiosError) {
90
- if (e.response?.status === 404 &&
91
- e.response.data.code === 1002 &&
92
- e.response.data.message ===
93
- "No available quotes for the requested transfer") {
94
- return null;
95
- }
96
- }
97
- throw e;
98
- }
99
- const bestRoute = resp.data.routes?.at(0);
100
- if (bestRoute == null) {
101
- return null;
102
- }
103
- const buyT = bestRoute.quote.buyTokens[outputTokenAddr];
104
- const sellT = bestRoute.quote.sellTokens[inputTokenAddr];
105
- const outputAmountInDecimal = new Decimal(buyT.minimumAmount)
106
- .div(Decimal.pow(10, buyT.decimals))
107
- .toFixed(buyT.decimals);
108
- const inputAmountInDecimal = new Decimal(sellT.amount)
109
- .div(Decimal.pow(10, sellT.decimals))
110
- .toFixed(sellT.decimals);
111
- return {
112
- expiry: bestRoute.quote.expiry,
113
- input: {
114
- amount: inputAmountInDecimal,
115
- amountRaw: BigInt(sellT.amount),
116
- contractAddress: inputTokenAddr,
117
- decimals: sellT.decimals,
118
- value: Decimal.mul(inputAmountInDecimal, sellT.priceUsd).toNumber(),
119
- symbol: sellT.symbol,
120
- },
121
- output: {
122
- amount: outputAmountInDecimal,
123
- amountRaw: BigInt(buyT.minimumAmount),
124
- contractAddress: outputTokenAddr,
125
- decimals: buyT.decimals,
126
- value: Decimal.mul(buyT.priceUsd, outputAmountInDecimal).toNumber(),
127
- symbol: buyT.symbol,
128
- },
129
- txData: {
130
- approvalAddress: bestRoute.quote.approvalTarget,
131
- tx: {
132
- to: bestRoute.quote.tx.to,
133
- value: bestRoute.quote.tx.value,
134
- data: bestRoute.quote.tx.data,
135
- },
136
- },
137
- };
138
- }));
139
- return list.map((item) => {
140
- switch (item.status) {
141
- case "fulfilled": {
142
- return item.value;
143
- }
144
- case "rejected": {
145
- console.error("Caught error in fetching Bebop quotes:", item.reason);
146
- return null;
147
- }
148
- }
149
- });
150
- }
151
- }
@@ -1,150 +0,0 @@
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
- excludeProtocols;
19
- constructor(options = {}) {
20
- const { apiKey, slippage = 0.5, excludeProtocols = "3" } = options;
21
- this.slippage = slippage;
22
- this.excludeProtocols = excludeProtocols;
23
- this.axios = axios.create({
24
- baseURL: FibrousAggregator.BASE_URL,
25
- headers: apiKey != null ? { "X-API-Key": apiKey } : undefined,
26
- timeout: 10_000,
27
- });
28
- }
29
- async getQuotes(requests) {
30
- const list = await Promise.allSettled(requests.map(async (r) => {
31
- if (r.type === QuoteType.EXACT_OUT) {
32
- return null;
33
- }
34
- if (r.chain.universe !== Universe.ETHEREUM) {
35
- return null;
36
- }
37
- const chainName = ChainNameMapping.get(r.chain);
38
- if (chainName == null) {
39
- return null;
40
- }
41
- const inputTokenAddr = getAddress(bytesToHex(r.inputToken.subarray(12)));
42
- const outputTokenAddr = getAddress(bytesToHex(r.outputToken.subarray(12)));
43
- const userAddrHex = getAddress(bytesToHex(r.userAddress.subarray(12)));
44
- const receiverAddrHex = r.receiverAddress != null
45
- ? getAddress(bytesToHex(r.receiverAddress.subarray(12)))
46
- : userAddrHex;
47
- let resp;
48
- try {
49
- resp = await this.axios({
50
- method: "GET",
51
- url: `/${chainName}/v2/routeAndCallData`,
52
- params: {
53
- amount: r.inputAmount.toString(),
54
- tokenInAddress: inputTokenAddr,
55
- tokenOutAddress: outputTokenAddr,
56
- slippage: this.slippage,
57
- destination: receiverAddrHex,
58
- excludeProtocols: this.excludeProtocols,
59
- },
60
- });
61
- }
62
- catch (e) {
63
- if (e instanceof AxiosError && e.isAxiosError) {
64
- return null;
65
- }
66
- throw e;
67
- }
68
- if (!resp.data.route.success) {
69
- return null;
70
- }
71
- if (resp.data.calldata.swap_parameters.length === 0) {
72
- return null;
73
- }
74
- const inputAmountInDecimal = new Decimal(resp.data.route.inputAmount)
75
- .div(Decimal.pow(10, resp.data.route.inputToken.decimals))
76
- .toFixed(resp.data.route.inputToken.decimals);
77
- const outputAmountInDecimal = new Decimal(resp.data.calldata.route.min_received)
78
- .div(Decimal.pow(10, resp.data.route.outputToken.decimals))
79
- .toFixed(resp.data.route.outputToken.decimals);
80
- const routerAddress = getAddress(resp.data.router_address);
81
- const isNativeInput = resp.data.calldata.route.swap_type === 0;
82
- const quote = {
83
- originalResponse: resp.data,
84
- input: {
85
- amount: inputAmountInDecimal,
86
- amountRaw: BigInt(resp.data.route.inputAmount),
87
- contractAddress: inputTokenAddr,
88
- decimals: resp.data.route.inputToken.decimals,
89
- value: Decimal.mul(inputAmountInDecimal, resp.data.route.inputToken.price ?? 0).toNumber(),
90
- symbol: resp.data.route.inputToken.symbol ??
91
- resp.data.route.inputToken.name,
92
- },
93
- output: {
94
- amount: outputAmountInDecimal,
95
- amountRaw: BigInt(resp.data.calldata.route.min_received),
96
- contractAddress: outputTokenAddr,
97
- decimals: resp.data.route.outputToken.decimals,
98
- value: Decimal.mul(outputAmountInDecimal, resp.data.route.outputToken.price ?? 0).toNumber(),
99
- symbol: resp.data.route.outputToken.symbol ??
100
- resp.data.route.outputToken.name,
101
- },
102
- txData: {
103
- approvalAddress: isNativeInput ? zeroAddress : routerAddress,
104
- tx: {
105
- to: routerAddress,
106
- value: isNativeInput
107
- ? toHex(BigInt(resp.data.calldata.route.amount_in))
108
- : toHex(0),
109
- data: encodeFunctionData({
110
- abi: FibrousRouterABI,
111
- functionName: "swap",
112
- args: [
113
- {
114
- token_in: getAddress(resp.data.calldata.route.token_in),
115
- token_out: getAddress(resp.data.calldata.route.token_out),
116
- amount_in: BigInt(resp.data.calldata.route.amount_in),
117
- amount_out: BigInt(resp.data.calldata.route.amount_out),
118
- min_received: BigInt(resp.data.calldata.route.min_received),
119
- destination: getAddress(resp.data.calldata.route.destination),
120
- swap_type: resp.data.calldata.route.swap_type,
121
- },
122
- resp.data.calldata.swap_parameters.map((swapParameter) => ({
123
- token_in: getAddress(swapParameter.token_in),
124
- token_out: getAddress(swapParameter.token_out),
125
- rate: Number.parseInt(swapParameter.rate, 10),
126
- protocol_id: Number.parseInt(swapParameter.protocol_id, 10),
127
- pool_address: getAddress(swapParameter.pool_address),
128
- swap_type: swapParameter.swap_type,
129
- extra_data: swapParameter.extra_data,
130
- })),
131
- ],
132
- }),
133
- },
134
- },
135
- };
136
- return quote;
137
- }));
138
- return list.map((item) => {
139
- switch (item.status) {
140
- case "fulfilled": {
141
- return item.value;
142
- }
143
- case "rejected": {
144
- console.error("Caught error in fetching Fibrous quotes:", item.reason);
145
- return null;
146
- }
147
- }
148
- });
149
- }
150
- }
@@ -1,10 +0,0 @@
1
- export var QuoteType;
2
- (function (QuoteType) {
3
- QuoteType[QuoteType["EXACT_IN"] = 0] = "EXACT_IN";
4
- QuoteType[QuoteType["EXACT_OUT"] = 1] = "EXACT_OUT";
5
- })(QuoteType || (QuoteType = {}));
6
- export var QuoteSeriousness;
7
- (function (QuoteSeriousness) {
8
- QuoteSeriousness[QuoteSeriousness["PRICE_SURVEY"] = 0] = "PRICE_SURVEY";
9
- QuoteSeriousness[QuoteSeriousness["SERIOUS"] = 1] = "SERIOUS";
10
- })(QuoteSeriousness || (QuoteSeriousness = {}));
@@ -1,5 +0,0 @@
1
- export * from './iface';
2
- export * from './lifi-agg';
3
- export * from './bebop-agg';
4
- export * from './fibrous-agg';
5
- export * from './autochoice';
@@ -1,150 +0,0 @@
1
- import axios, { AxiosError } from "axios";
2
- import { bytesToHex, getAddress } from "viem";
3
- import { QuoteType, } from "./iface";
4
- import { Universe } from "../proto/definition";
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
- ]);
20
- export class LiFiAggregator {
21
- static BASE_URL_V1 = "https://li.quest/v1";
22
- static COMMON_OPTIONS = {
23
- denyExchanges: "openocean",
24
- slippage: "0.01",
25
- skipSimulation: true,
26
- };
27
- axios;
28
- constructor(apiKey) {
29
- this.axios = axios.create({
30
- baseURL: LiFiAggregator.BASE_URL_V1,
31
- headers: {
32
- "x-lifi-api-key": apiKey,
33
- },
34
- timeout: 10_000,
35
- });
36
- }
37
- async getQuotes(requests) {
38
- const list = await Promise.allSettled(requests.map(async (r) => {
39
- if (r.chain.universe !== Universe.ETHEREUM) {
40
- return null;
41
- }
42
- if (!ALLOWED_CHAINS.has(Number(r.chain.chainID))) {
43
- return null;
44
- }
45
- let respPromise;
46
- const chIDStr = r.chain.chainID.toString();
47
- const inputTokenAddr = getAddress(bytesToHex(r.inputToken.subarray(12)));
48
- const outputTokenAddr = getAddress(bytesToHex(r.outputToken.subarray(12)));
49
- const userAddrHex = getAddress(bytesToHex(r.userAddress.subarray(12)));
50
- const receiverAddrHex = r.receiverAddress != null
51
- ? getAddress(bytesToHex(r.receiverAddress.subarray(12)))
52
- : userAddrHex;
53
- switch (r.type) {
54
- case QuoteType.EXACT_IN: {
55
- respPromise = this.axios({
56
- method: "GET",
57
- url: "/quote",
58
- params: {
59
- fromChain: chIDStr,
60
- toChain: chIDStr,
61
- fromToken: inputTokenAddr,
62
- toToken: outputTokenAddr,
63
- fromAddress: userAddrHex,
64
- toAddress: receiverAddrHex,
65
- fromAmount: r.inputAmount.toString(),
66
- ...LiFiAggregator.COMMON_OPTIONS,
67
- },
68
- });
69
- break;
70
- }
71
- case QuoteType.EXACT_OUT: {
72
- respPromise = this.axios({
73
- method: "GET",
74
- url: "/quote/toAmount",
75
- params: {
76
- fromChain: chIDStr,
77
- toChain: chIDStr,
78
- fromToken: inputTokenAddr,
79
- toToken: outputTokenAddr,
80
- fromAddress: userAddrHex,
81
- toAddress: receiverAddrHex,
82
- toAmount: r.outputAmount.toString(),
83
- ...LiFiAggregator.COMMON_OPTIONS,
84
- },
85
- });
86
- break;
87
- }
88
- }
89
- let resp;
90
- try {
91
- resp = await respPromise;
92
- }
93
- catch (e) {
94
- if (e instanceof AxiosError && e.isAxiosError) {
95
- if (e.response?.status === 404 &&
96
- e.response.data.code === 1002 &&
97
- e.response.data.message ===
98
- "No available quotes for the requested transfer") {
99
- return null;
100
- }
101
- }
102
- throw e;
103
- }
104
- const { estimate, transactionRequest: { to, value, data }, action: { fromToken, toToken }, } = resp.data;
105
- const inputAmountInDecimal = new Decimal(estimate.fromAmount)
106
- .div(Decimal.pow(10, fromToken.decimals))
107
- .toFixed(fromToken.decimals);
108
- const outputAmountInDecimal = new Decimal(estimate.toAmountMin)
109
- .div(Decimal.pow(10, toToken.decimals))
110
- .toFixed(toToken.decimals);
111
- return {
112
- input: {
113
- amount: inputAmountInDecimal,
114
- amountRaw: BigInt(estimate.fromAmount),
115
- contractAddress: inputTokenAddr,
116
- decimals: fromToken.decimals,
117
- value: Decimal.mul(inputAmountInDecimal, fromToken.priceUSD).toNumber(),
118
- symbol: fromToken.symbol,
119
- },
120
- output: {
121
- amount: outputAmountInDecimal,
122
- amountRaw: BigInt(estimate.toAmountMin),
123
- contractAddress: outputTokenAddr,
124
- decimals: toToken.decimals,
125
- value: Decimal.mul(outputAmountInDecimal, toToken.priceUSD).toNumber(),
126
- symbol: toToken.symbol,
127
- },
128
- txData: {
129
- approvalAddress: estimate.approvalAddress,
130
- tx: {
131
- to,
132
- value,
133
- data,
134
- },
135
- },
136
- };
137
- }));
138
- return list.map((item) => {
139
- switch (item.status) {
140
- case "fulfilled": {
141
- return item.value;
142
- }
143
- case "rejected": {
144
- console.error("Caught error in fetching LiFi quotes:", item.reason);
145
- return null;
146
- }
147
- }
148
- });
149
- }
150
- }
@@ -1 +0,0 @@
1
- export declare function ensureBufferPolyfill(): void;
@@ -1,14 +0,0 @@
1
- import Decimal from "decimal.js";
2
- import { Universe } from "../proto/definition";
3
- import { Bytes } from "../types";
4
- import { OmniversalChainID } from "../data";
5
- export type BalanceOnChain = {
6
- chainID: OmniversalChainID;
7
- totalValue: Decimal;
8
- currencywise: {
9
- tokenAddress: Buffer;
10
- amount: Decimal;
11
- value: Decimal;
12
- }[];
13
- };
14
- export declare function getBalances(vscURL: string, universe: Universe, address: Bytes): Promise<BalanceOnChain[]>;
@@ -1,6 +0,0 @@
1
- import { Registry as CosmosRegistry, OfflineDirectSigner, DirectSecp256k1Wallet } from "@cosmjs/proto-signing";
2
- import { HttpEndpoint, SigningStargateClient, SigningStargateClientOptions } from "@cosmjs/stargate";
3
- import { Bytes } from "../types";
4
- export declare const Registry: CosmosRegistry;
5
- export declare function createCosmosWallet(privateKey: string | Bytes): Promise<DirectSecp256k1Wallet>;
6
- export declare function createCosmosClient(signer: OfflineDirectSigner, endpoint: string | HttpEndpoint, options?: SigningStargateClientOptions): Promise<SigningStargateClient>;
@@ -1,20 +0,0 @@
1
- import { Universe } from "../proto/definition";
2
- import { ChainIDKeyedMap, OmniversalChainID } from "./chainid";
3
- import { Currency } from "./currency";
4
- import { ezPadTo32Hex } from "./utils";
5
- declare class CurrencyMap {
6
- private readonly map;
7
- constructor(currencies: Currency[]);
8
- get(input: Parameters<typeof ezPadTo32Hex>[0]): Currency | undefined;
9
- }
10
- export type ChainDatum = {
11
- ChainID: OmniversalChainID;
12
- Universe: Universe;
13
- ChainID32: Buffer;
14
- Currencies: Currency[];
15
- CurrencyMap: CurrencyMap;
16
- };
17
- export declare const Chaindata: ChainDatum[];
18
- export declare const ChaindataMap: ChainIDKeyedMap<ChainDatum>;
19
- export declare const RPCURLMap: ChainIDKeyedMap<string>;
20
- export {};
@@ -1,31 +0,0 @@
1
- import { type Hex } from "viem";
2
- import { Universe } from "../proto/definition";
3
- import { Bytes } from "../types";
4
- export declare function encodeChainID36(universe: Universe, chainID: Bytes | bigint | number): Buffer;
5
- export declare class OmniversalChainID {
6
- readonly universe: Universe;
7
- readonly chainID: bigint;
8
- private readonly binaryForm;
9
- constructor(universe: Universe, chainID: bigint | number | string | Bytes);
10
- toString(): string;
11
- toJSON(): {
12
- universe: string;
13
- chainID: `0x${string}`;
14
- };
15
- static fromJSON(input: {
16
- universe: string;
17
- chainID: Hex;
18
- }): OmniversalChainID;
19
- static fromChainID36(_input: Bytes): OmniversalChainID;
20
- toBytes(): Buffer;
21
- equals(rhs: OmniversalChainID): boolean;
22
- static equals(lhs: OmniversalChainID, rhs: OmniversalChainID): boolean;
23
- }
24
- export declare class ChainIDKeyedMap<V> {
25
- private readonly map;
26
- constructor(entries?: readonly [OmniversalChainID, V][] | null);
27
- get(key: OmniversalChainID): V | undefined;
28
- set(key: OmniversalChainID, value: V): this;
29
- getFromChainID36(key: Bytes): V | undefined;
30
- entries(): Generator<[OmniversalChainID, V]>;
31
- }
@@ -1,30 +0,0 @@
1
- import { Hex } from "viem";
2
- import Decimal from "decimal.js";
3
- import { Bytes } from "../types";
4
- import { PermitVariant } from "../permitutils";
5
- export declare enum CurrencyID {
6
- USDC = 1,
7
- USDT = 2,
8
- ETH = 3,
9
- POL = 4,
10
- AVAX = 5,
11
- BNB = 6,
12
- HYPE = 16,
13
- KAIA = 17,
14
- SOPH = 18,
15
- TRX = 19,
16
- MON = 20,
17
- CBTC = 21
18
- }
19
- export declare class Currency {
20
- readonly currencyID: CurrencyID;
21
- readonly decimals: number;
22
- readonly permitVariant: PermitVariant;
23
- readonly permitContractVersion: number;
24
- readonly isGasToken: boolean;
25
- readonly tokenAddress: Buffer;
26
- private readonly oneUnitToAtomicUnitRatio;
27
- constructor(currencyID: CurrencyID, tokenAddress: string | Bytes | number[], decimals: number, permitVariant: PermitVariant, permitContractVersion: number | undefined, isGasToken: boolean);
28
- convertUnitsToAmountDecimal(input: bigint | number | Hex | Bytes): Decimal;
29
- convertAmountToUnitsInBinary(input: Decimal): Buffer;
30
- }
@@ -1,4 +0,0 @@
1
- export * from './chaindata';
2
- export * from './chainid';
3
- export * from './currency';
4
- export * from './utils';
@@ -1,10 +0,0 @@
1
- import { Hex, toHex } from "viem";
2
- import Decimal from "decimal.js";
3
- import { Bytes } from "../types";
4
- export declare function convertToBufferIfNecessary(buf: Bytes): Buffer<ArrayBufferLike>;
5
- export declare function zeroExtendBufToGivenSize(buf: Bytes, size?: number): Buffer;
6
- export declare function ezPadTo32Hex(input: Hex | Parameters<typeof toHex>[0]): Hex;
7
- export declare function convertDecimalToBigInt(dec: Decimal): bigint;
8
- export declare function convertBigIntToDecimal(big: bigint): Decimal;
9
- export declare function maxByBigInt<T>(items: readonly T[], getValue: (element: T) => bigint): T;
10
- export declare function minByBigInt<T>(items: readonly T[], getValue: (element: T) => bigint): T;