@avail-project/ca-common 2.3.0 → 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.
- package/dist/cjs/index.js +10593 -20
- package/dist/esm/index.mjs +10603 -0
- package/dist/types/index.d.ts +2608 -13
- package/package.json +41 -37
- package/dist/cjs/_polyfill.js +0 -147
- package/dist/cjs/balances/ub-api.js +0 -25
- package/dist/cjs/cosmos/index.js +0 -31
- package/dist/cjs/data/chaindata.js +0 -788
- package/dist/cjs/data/chainid.js +0 -93
- package/dist/cjs/data/currency.js +0 -78
- package/dist/cjs/data/index.js +0 -7
- package/dist/cjs/data/utils.js +0 -44
- package/dist/cjs/evmabi/erc20.abi.js +0 -349
- package/dist/cjs/evmabi/fibrousrouter.abi.js +0 -41
- package/dist/cjs/evmabi/index.js +0 -7
- package/dist/cjs/evmabi/vault.abi.js +0 -1021
- package/dist/cjs/evmabi/yakaggregator.abi.js +0 -275
- package/dist/cjs/permitutils/index.js +0 -186
- package/dist/cjs/proto/client.js +0 -48
- package/dist/cjs/proto/definition.js +0 -4131
- package/dist/cjs/proto/grpc.js +0 -298
- package/dist/cjs/rff/rff.js +0 -42
- package/dist/cjs/types/binarytypes.js +0 -2
- package/dist/cjs/types/index.js +0 -5
- package/dist/cjs/types/msgpack-axios.js +0 -22
- package/dist/cjs/vaultcontracts/index.js +0 -4
- package/dist/cjs/vaultcontracts/vaultcontracts.js +0 -222
- package/dist/cjs/xcs/autochoice.js +0 -575
- package/dist/cjs/xcs/bebop-agg.js +0 -156
- package/dist/cjs/xcs/fibrous-agg.js +0 -155
- package/dist/cjs/xcs/iface.js +0 -13
- package/dist/cjs/xcs/index.js +0 -9
- package/dist/cjs/xcs/lifi-agg.js +0 -177
- package/dist/cjs/xcs/selectsources.js +0 -255
- package/dist/esm/_polyfill.js +0 -143
- package/dist/esm/balances/ub-api.js +0 -21
- package/dist/esm/cosmos/index.js +0 -26
- package/dist/esm/data/chaindata.js +0 -785
- package/dist/esm/data/chainid.js +0 -87
- package/dist/esm/data/currency.js +0 -73
- package/dist/esm/data/index.js +0 -4
- package/dist/esm/data/utils.js +0 -34
- package/dist/esm/evmabi/erc20.abi.js +0 -346
- package/dist/esm/evmabi/fibrousrouter.abi.js +0 -38
- package/dist/esm/evmabi/index.js +0 -4
- package/dist/esm/evmabi/vault.abi.js +0 -1018
- package/dist/esm/evmabi/yakaggregator.abi.js +0 -272
- package/dist/esm/index.js +0 -13
- package/dist/esm/permitutils/index.js +0 -181
- package/dist/esm/proto/client.js +0 -11
- package/dist/esm/proto/definition.js +0 -4122
- package/dist/esm/proto/grpc.js +0 -292
- package/dist/esm/rff/rff.js +0 -38
- package/dist/esm/types/binarytypes.js +0 -1
- package/dist/esm/types/index.js +0 -2
- package/dist/esm/types/msgpack-axios.js +0 -18
- package/dist/esm/vaultcontracts/index.js +0 -1
- package/dist/esm/vaultcontracts/vaultcontracts.js +0 -218
- package/dist/esm/xcs/autochoice.js +0 -559
- package/dist/esm/xcs/bebop-agg.js +0 -151
- package/dist/esm/xcs/fibrous-agg.js +0 -150
- package/dist/esm/xcs/iface.js +0 -10
- package/dist/esm/xcs/index.js +0 -6
- package/dist/esm/xcs/lifi-agg.js +0 -172
- package/dist/esm/xcs/selectsources.js +0 -251
- package/dist/types/_polyfill.d.ts +0 -1
- package/dist/types/balances/ub-api.d.ts +0 -14
- package/dist/types/cosmos/index.d.ts +0 -6
- package/dist/types/data/chaindata.d.ts +0 -20
- package/dist/types/data/chainid.d.ts +0 -31
- package/dist/types/data/currency.d.ts +0 -30
- package/dist/types/data/index.d.ts +0 -4
- package/dist/types/data/utils.d.ts +0 -10
- package/dist/types/evmabi/erc20.abi.d.ts +0 -264
- package/dist/types/evmabi/fibrousrouter.abi.d.ts +0 -77
- package/dist/types/evmabi/index.d.ts +0 -4
- package/dist/types/evmabi/vault.abi.d.ts +0 -785
- package/dist/types/evmabi/yakaggregator.abi.d.ts +0 -298
- package/dist/types/permitutils/index.d.ts +0 -13
- package/dist/types/proto/client.d.ts +0 -2
- package/dist/types/proto/definition.d.ts +0 -382
- package/dist/types/proto/grpc.d.ts +0 -75
- package/dist/types/rff/rff.d.ts +0 -9
- package/dist/types/types/binarytypes.d.ts +0 -1
- package/dist/types/types/index.d.ts +0 -2
- package/dist/types/types/msgpack-axios.d.ts +0 -1
- package/dist/types/vaultcontracts/index.d.ts +0 -22
- package/dist/types/vaultcontracts/vaultcontracts.d.ts +0 -8
- package/dist/types/xcs/autochoice.d.ts +0 -104
- package/dist/types/xcs/bebop-agg.d.ts +0 -104
- package/dist/types/xcs/fibrous-agg.d.ts +0 -56
- package/dist/types/xcs/iface.d.ts +0 -69
- package/dist/types/xcs/index.d.ts +0 -6
- package/dist/types/xcs/lifi-agg.d.ts +0 -42
- package/dist/types/xcs/selectsources.d.ts +0 -27
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import Decimal from "decimal.js";
|
|
2
|
-
import { QuoteSeriousness, QuoteType, } from "./iface";
|
|
3
|
-
import { AggregateAggregatorsMode, aggregateAggregators, AutoSelectionError, } from "./autochoice";
|
|
4
|
-
import { ChaindataMap, convertDecimalToBigInt, CurrencyID, } from "../data";
|
|
5
|
-
const safetyMultiplier = new Decimal("1.025");
|
|
6
|
-
export async function selectSources(args) {
|
|
7
|
-
const { sources, outputRequired, aggregators, commonCurrencyID = CurrencyID.USDC, prefixHeadroom = new Decimal("1.25"), } = args;
|
|
8
|
-
console.debug("XCS | SS:", {
|
|
9
|
-
sources,
|
|
10
|
-
outputRequired: outputRequired.toFixed(),
|
|
11
|
-
prefixHeadroom: prefixHeadroom.toFixed(),
|
|
12
|
-
});
|
|
13
|
-
const cotList = [];
|
|
14
|
-
const nonCOTQuotes = [];
|
|
15
|
-
for (const [idx, src] of sources.entries()) {
|
|
16
|
-
const chain = ChaindataMap.get(src.chainID);
|
|
17
|
-
if (chain == null) {
|
|
18
|
-
throw new AutoSelectionError("Chain not found");
|
|
19
|
-
}
|
|
20
|
-
const cot = chain.Currencies.find((c) => c.currencyID === commonCurrencyID);
|
|
21
|
-
if (cot == null) {
|
|
22
|
-
console.debug("XCS | SS | Skipping source — no COT on chain", { chain });
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
const originalHolding = {
|
|
26
|
-
chainID: src.chainID,
|
|
27
|
-
tokenAddress: src.tokenAddress,
|
|
28
|
-
amountRaw: src.amountRaw,
|
|
29
|
-
};
|
|
30
|
-
if (Buffer.compare(src.tokenAddress, cot.tokenAddress) === 0) {
|
|
31
|
-
const normalizedAmount = new Decimal(src.amountRaw.toString()).div(Decimal.pow(10, cot.decimals));
|
|
32
|
-
cotList.push({
|
|
33
|
-
amount: normalizedAmount,
|
|
34
|
-
idx,
|
|
35
|
-
chainID: src.chainID,
|
|
36
|
-
currency: cot,
|
|
37
|
-
originalHolding,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
nonCOTQuotes.push({
|
|
42
|
-
req: {
|
|
43
|
-
userAddress: src.takerAddress,
|
|
44
|
-
receiverAddress: src.receiverAddress,
|
|
45
|
-
type: QuoteType.EXACT_IN,
|
|
46
|
-
chain: chain.ChainID,
|
|
47
|
-
inputToken: src.tokenAddress,
|
|
48
|
-
inputAmount: src.amountRaw,
|
|
49
|
-
outputToken: cot.tokenAddress,
|
|
50
|
-
seriousness: QuoteSeriousness.PRICE_SURVEY,
|
|
51
|
-
},
|
|
52
|
-
originalHolding,
|
|
53
|
-
cur: cot,
|
|
54
|
-
idx,
|
|
55
|
-
value: src.value,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
// Continuous-COT fast path — covers outputRequired without touching any aggregator.
|
|
60
|
-
if (cotList.length > 0 && cotList[0].idx === 0) {
|
|
61
|
-
let continuousAmount = new Decimal(0);
|
|
62
|
-
let continuousCount = 0;
|
|
63
|
-
for (const cot of cotList) {
|
|
64
|
-
if (cot.idx !== continuousCount)
|
|
65
|
-
break;
|
|
66
|
-
continuousAmount = continuousAmount.add(cot.amount);
|
|
67
|
-
continuousCount++;
|
|
68
|
-
if (continuousAmount.gte(outputRequired)) {
|
|
69
|
-
console.log("XCS | SS | Continuous COTs cover requirement, no quotes needed");
|
|
70
|
-
const usedCOTs = [];
|
|
71
|
-
let r = outputRequired;
|
|
72
|
-
for (let i = 0; i < continuousCount; i++) {
|
|
73
|
-
const c = cotList[i];
|
|
74
|
-
const amountToUse = Decimal.min(r, c.amount);
|
|
75
|
-
usedCOTs.push({
|
|
76
|
-
originalHolding: c.originalHolding,
|
|
77
|
-
amountUsed: amountToUse,
|
|
78
|
-
idx: c.idx,
|
|
79
|
-
cur: c.currency,
|
|
80
|
-
});
|
|
81
|
-
r = r.minus(amountToUse);
|
|
82
|
-
if (r.lte(0))
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
return { quoteResponses: [], usedCOTs };
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
const queue = [];
|
|
90
|
-
for (const c of cotList) {
|
|
91
|
-
queue.push({ idx: c.idx, isCOT: true, cotData: c });
|
|
92
|
-
}
|
|
93
|
-
for (const q of nonCOTQuotes) {
|
|
94
|
-
queue.push({ idx: q.idx, isCOT: false, quoteData: q });
|
|
95
|
-
}
|
|
96
|
-
queue.sort((a, b) => a.idx - b.idx);
|
|
97
|
-
// Smallest priority-ordered prefix whose cumulative value covers
|
|
98
|
-
// `outputRequired × prefixHeadroom`. Quote only that prefix initially; the batch
|
|
99
|
-
// is extended below if realised aggregator output under-delivers.
|
|
100
|
-
const target = outputRequired.mul(prefixHeadroom);
|
|
101
|
-
let cumulative = new Decimal(0);
|
|
102
|
-
let prefixCutoffIdx = null;
|
|
103
|
-
for (const item of queue) {
|
|
104
|
-
if (item.isCOT) {
|
|
105
|
-
cumulative = cumulative.add(item.cotData.amount);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
cumulative = cumulative.add(item.quoteData.value);
|
|
109
|
-
}
|
|
110
|
-
if (cumulative.gte(target)) {
|
|
111
|
-
prefixCutoffIdx = item.idx;
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
console.debug("XCS | SS | Prefix selected", {
|
|
116
|
-
prefixCutoffIdx,
|
|
117
|
-
cumulative: cumulative.toFixed(),
|
|
118
|
-
target: target.toFixed(),
|
|
119
|
-
});
|
|
120
|
-
const responseByIdx = new Map();
|
|
121
|
-
const quoteAndStore = async (batch) => {
|
|
122
|
-
if (batch.length === 0)
|
|
123
|
-
return;
|
|
124
|
-
const r = await aggregateAggregators(batch.map((b) => b.req), aggregators, AggregateAggregatorsMode.MaximizeOutput);
|
|
125
|
-
for (let i = 0; i < batch.length; i++) {
|
|
126
|
-
responseByIdx.set(batch[i].idx, r[i]);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
const initialBatch = prefixCutoffIdx == null
|
|
130
|
-
? nonCOTQuotes
|
|
131
|
-
: nonCOTQuotes.filter((q) => q.idx <= prefixCutoffIdx);
|
|
132
|
-
console.debug("XCS | SS | Initial quote batch", {
|
|
133
|
-
initialCount: initialBatch.length,
|
|
134
|
-
totalNonCOT: nonCOTQuotes.length,
|
|
135
|
-
});
|
|
136
|
-
await quoteAndStore(initialBatch);
|
|
137
|
-
const final = [];
|
|
138
|
-
const usedCOTs = [];
|
|
139
|
-
let remainder = outputRequired;
|
|
140
|
-
for (const item of queue) {
|
|
141
|
-
if (remainder.lte(0))
|
|
142
|
-
break;
|
|
143
|
-
if (item.isCOT) {
|
|
144
|
-
const { cotData } = item;
|
|
145
|
-
const amountToUse = Decimal.min(remainder, cotData.amount);
|
|
146
|
-
usedCOTs.push({
|
|
147
|
-
originalHolding: cotData.originalHolding,
|
|
148
|
-
amountUsed: amountToUse,
|
|
149
|
-
idx: cotData.idx,
|
|
150
|
-
cur: cotData.currency,
|
|
151
|
-
});
|
|
152
|
-
remainder = remainder.minus(amountToUse);
|
|
153
|
-
console.debug("XCS | SS | cot", {
|
|
154
|
-
idx: cotData.idx,
|
|
155
|
-
amountToUse: amountToUse.toFixed(),
|
|
156
|
-
remainder: remainder.toFixed(),
|
|
157
|
-
});
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
const { quoteData } = item;
|
|
161
|
-
let lookup = responseByIdx.get(quoteData.idx);
|
|
162
|
-
if (lookup == null) {
|
|
163
|
-
// Prefix under-delivered: quote every non-COT we haven't yet and continue.
|
|
164
|
-
const unquoted = nonCOTQuotes.filter((q) => !responseByIdx.has(q.idx));
|
|
165
|
-
console.log("XCS | SS | Prefix under-delivered, extending batch", {
|
|
166
|
-
remaining: unquoted.length,
|
|
167
|
-
});
|
|
168
|
-
await quoteAndStore(unquoted);
|
|
169
|
-
lookup = responseByIdx.get(quoteData.idx);
|
|
170
|
-
}
|
|
171
|
-
if (lookup == null)
|
|
172
|
-
continue;
|
|
173
|
-
const { quote: resp, aggregator } = lookup;
|
|
174
|
-
if (resp == null)
|
|
175
|
-
continue;
|
|
176
|
-
console.debug("XCS | SS | quote-eval", {
|
|
177
|
-
idx: quoteData.idx,
|
|
178
|
-
remainder: remainder.toFixed(),
|
|
179
|
-
input: resp.input,
|
|
180
|
-
output: resp.output,
|
|
181
|
-
});
|
|
182
|
-
const divisor = Decimal.pow(10, quoteData.cur.decimals);
|
|
183
|
-
const oamD = new Decimal(resp.output.amount);
|
|
184
|
-
if (oamD.gt(remainder)) {
|
|
185
|
-
const indicativePrice = Decimal.div(resp.input.amountRaw.toString(), resp.output.amountRaw.toString());
|
|
186
|
-
const userBal = new Decimal(quoteData.originalHolding.amountRaw.toString());
|
|
187
|
-
let expectedInput = Decimal.min(remainder.mul(divisor).mul(indicativePrice).mul(safetyMultiplier), userBal);
|
|
188
|
-
let attempts = 0;
|
|
189
|
-
while (true) {
|
|
190
|
-
if (++attempts > 10) {
|
|
191
|
-
throw new AutoSelectionError("Partial quote did not converge");
|
|
192
|
-
}
|
|
193
|
-
console.debug("XCS | SS | partial_quote_loop", {
|
|
194
|
-
indicativePrice: indicativePrice.toFixed(),
|
|
195
|
-
expectedInput: expectedInput.toFixed(),
|
|
196
|
-
userBal: userBal.toFixed(),
|
|
197
|
-
remainder: remainder.toFixed(),
|
|
198
|
-
});
|
|
199
|
-
const adequate = await aggregateAggregators([
|
|
200
|
-
{
|
|
201
|
-
...quoteData.req,
|
|
202
|
-
seriousness: QuoteSeriousness.SERIOUS,
|
|
203
|
-
inputAmount: convertDecimalToBigInt(expectedInput),
|
|
204
|
-
},
|
|
205
|
-
], aggregators, AggregateAggregatorsMode.MaximizeOutput);
|
|
206
|
-
if (adequate.length !== 1) {
|
|
207
|
-
throw new AutoSelectionError("Unexpected response length from aggregateAggregators");
|
|
208
|
-
}
|
|
209
|
-
const aq = adequate[0];
|
|
210
|
-
if (aq.quote == null) {
|
|
211
|
-
throw new AutoSelectionError("Couldn't get buy quote");
|
|
212
|
-
}
|
|
213
|
-
const oam2D = new Decimal(aq.quote.output.amount);
|
|
214
|
-
if (oam2D.gte(remainder)) {
|
|
215
|
-
final.push({
|
|
216
|
-
quote: aq.quote,
|
|
217
|
-
aggregator: aq.aggregator,
|
|
218
|
-
holding: quoteData.originalHolding,
|
|
219
|
-
chainID: Number(quoteData.req.chain.chainID),
|
|
220
|
-
});
|
|
221
|
-
remainder = remainder.minus(oam2D);
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
else if (expectedInput.eq(userBal)) {
|
|
225
|
-
throw new AutoSelectionError("Holding was supposedly enough to meet the full requirement but ceased to be so subsequently");
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
expectedInput = Decimal.min(expectedInput.mul(safetyMultiplier), userBal);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
final.push({
|
|
234
|
-
quote: resp,
|
|
235
|
-
holding: quoteData.originalHolding,
|
|
236
|
-
aggregator,
|
|
237
|
-
chainID: Number(quoteData.req.chain.chainID),
|
|
238
|
-
});
|
|
239
|
-
remainder = remainder.minus(resp.output.amount);
|
|
240
|
-
console.debug("XCS | SS | full_quote", {
|
|
241
|
-
idx: quoteData.idx,
|
|
242
|
-
remainder: remainder.toFixed(),
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
if (remainder.gt(0)) {
|
|
247
|
-
throw new AutoSelectionError("NOT_ENOUGH_SWAP_FOR_REQUIREMENT");
|
|
248
|
-
}
|
|
249
|
-
console.log("XCS | SS | final_quotes", { quotes: final, cots: usedCOTs });
|
|
250
|
-
return { quoteResponses: final, usedCOTs };
|
|
251
|
-
}
|
|
@@ -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,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;
|
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
export declare const ERC20ABI: readonly [{
|
|
2
|
-
readonly constant: true;
|
|
3
|
-
readonly inputs: readonly [];
|
|
4
|
-
readonly name: "name";
|
|
5
|
-
readonly outputs: readonly [{
|
|
6
|
-
readonly name: "";
|
|
7
|
-
readonly type: "string";
|
|
8
|
-
}];
|
|
9
|
-
readonly payable: false;
|
|
10
|
-
readonly stateMutability: "view";
|
|
11
|
-
readonly type: "function";
|
|
12
|
-
}, {
|
|
13
|
-
readonly constant: false;
|
|
14
|
-
readonly inputs: readonly [{
|
|
15
|
-
readonly name: "_spender";
|
|
16
|
-
readonly type: "address";
|
|
17
|
-
}, {
|
|
18
|
-
readonly name: "_value";
|
|
19
|
-
readonly type: "uint256";
|
|
20
|
-
}];
|
|
21
|
-
readonly name: "approve";
|
|
22
|
-
readonly outputs: readonly [{
|
|
23
|
-
readonly name: "";
|
|
24
|
-
readonly type: "bool";
|
|
25
|
-
}];
|
|
26
|
-
readonly payable: false;
|
|
27
|
-
readonly stateMutability: "nonpayable";
|
|
28
|
-
readonly type: "function";
|
|
29
|
-
}, {
|
|
30
|
-
readonly constant: true;
|
|
31
|
-
readonly inputs: readonly [];
|
|
32
|
-
readonly name: "totalSupply";
|
|
33
|
-
readonly outputs: readonly [{
|
|
34
|
-
readonly name: "";
|
|
35
|
-
readonly type: "uint256";
|
|
36
|
-
}];
|
|
37
|
-
readonly payable: false;
|
|
38
|
-
readonly stateMutability: "view";
|
|
39
|
-
readonly type: "function";
|
|
40
|
-
}, {
|
|
41
|
-
readonly constant: false;
|
|
42
|
-
readonly inputs: readonly [{
|
|
43
|
-
readonly name: "_from";
|
|
44
|
-
readonly type: "address";
|
|
45
|
-
}, {
|
|
46
|
-
readonly name: "_to";
|
|
47
|
-
readonly type: "address";
|
|
48
|
-
}, {
|
|
49
|
-
readonly name: "_value";
|
|
50
|
-
readonly type: "uint256";
|
|
51
|
-
}];
|
|
52
|
-
readonly name: "transferFrom";
|
|
53
|
-
readonly outputs: readonly [{
|
|
54
|
-
readonly name: "";
|
|
55
|
-
readonly type: "bool";
|
|
56
|
-
}];
|
|
57
|
-
readonly payable: false;
|
|
58
|
-
readonly stateMutability: "nonpayable";
|
|
59
|
-
readonly type: "function";
|
|
60
|
-
}, {
|
|
61
|
-
readonly constant: true;
|
|
62
|
-
readonly inputs: readonly [];
|
|
63
|
-
readonly name: "decimals";
|
|
64
|
-
readonly outputs: readonly [{
|
|
65
|
-
readonly name: "";
|
|
66
|
-
readonly type: "uint8";
|
|
67
|
-
}];
|
|
68
|
-
readonly payable: false;
|
|
69
|
-
readonly stateMutability: "view";
|
|
70
|
-
readonly type: "function";
|
|
71
|
-
}, {
|
|
72
|
-
readonly constant: true;
|
|
73
|
-
readonly inputs: readonly [{
|
|
74
|
-
readonly name: "_owner";
|
|
75
|
-
readonly type: "address";
|
|
76
|
-
}];
|
|
77
|
-
readonly name: "balanceOf";
|
|
78
|
-
readonly outputs: readonly [{
|
|
79
|
-
readonly name: "balance";
|
|
80
|
-
readonly type: "uint256";
|
|
81
|
-
}];
|
|
82
|
-
readonly payable: false;
|
|
83
|
-
readonly stateMutability: "view";
|
|
84
|
-
readonly type: "function";
|
|
85
|
-
}, {
|
|
86
|
-
readonly constant: true;
|
|
87
|
-
readonly inputs: readonly [];
|
|
88
|
-
readonly name: "symbol";
|
|
89
|
-
readonly outputs: readonly [{
|
|
90
|
-
readonly name: "";
|
|
91
|
-
readonly type: "string";
|
|
92
|
-
}];
|
|
93
|
-
readonly payable: false;
|
|
94
|
-
readonly stateMutability: "view";
|
|
95
|
-
readonly type: "function";
|
|
96
|
-
}, {
|
|
97
|
-
readonly constant: false;
|
|
98
|
-
readonly inputs: readonly [{
|
|
99
|
-
readonly name: "_to";
|
|
100
|
-
readonly type: "address";
|
|
101
|
-
}, {
|
|
102
|
-
readonly name: "_value";
|
|
103
|
-
readonly type: "uint256";
|
|
104
|
-
}];
|
|
105
|
-
readonly name: "transfer";
|
|
106
|
-
readonly outputs: readonly [{
|
|
107
|
-
readonly name: "";
|
|
108
|
-
readonly type: "bool";
|
|
109
|
-
}];
|
|
110
|
-
readonly payable: false;
|
|
111
|
-
readonly stateMutability: "nonpayable";
|
|
112
|
-
readonly type: "function";
|
|
113
|
-
}, {
|
|
114
|
-
readonly constant: true;
|
|
115
|
-
readonly inputs: readonly [{
|
|
116
|
-
readonly name: "_owner";
|
|
117
|
-
readonly type: "address";
|
|
118
|
-
}, {
|
|
119
|
-
readonly name: "_spender";
|
|
120
|
-
readonly type: "address";
|
|
121
|
-
}];
|
|
122
|
-
readonly name: "allowance";
|
|
123
|
-
readonly outputs: readonly [{
|
|
124
|
-
readonly name: "";
|
|
125
|
-
readonly type: "uint256";
|
|
126
|
-
}];
|
|
127
|
-
readonly payable: false;
|
|
128
|
-
readonly stateMutability: "view";
|
|
129
|
-
readonly type: "function";
|
|
130
|
-
}, {
|
|
131
|
-
readonly payable: true;
|
|
132
|
-
readonly stateMutability: "payable";
|
|
133
|
-
readonly type: "fallback";
|
|
134
|
-
}, {
|
|
135
|
-
readonly anonymous: false;
|
|
136
|
-
readonly inputs: readonly [{
|
|
137
|
-
readonly indexed: true;
|
|
138
|
-
readonly name: "owner";
|
|
139
|
-
readonly type: "address";
|
|
140
|
-
}, {
|
|
141
|
-
readonly indexed: true;
|
|
142
|
-
readonly name: "spender";
|
|
143
|
-
readonly type: "address";
|
|
144
|
-
}, {
|
|
145
|
-
readonly indexed: false;
|
|
146
|
-
readonly name: "value";
|
|
147
|
-
readonly type: "uint256";
|
|
148
|
-
}];
|
|
149
|
-
readonly name: "Approval";
|
|
150
|
-
readonly type: "event";
|
|
151
|
-
}, {
|
|
152
|
-
readonly anonymous: false;
|
|
153
|
-
readonly inputs: readonly [{
|
|
154
|
-
readonly indexed: true;
|
|
155
|
-
readonly name: "from";
|
|
156
|
-
readonly type: "address";
|
|
157
|
-
}, {
|
|
158
|
-
readonly indexed: true;
|
|
159
|
-
readonly name: "to";
|
|
160
|
-
readonly type: "address";
|
|
161
|
-
}, {
|
|
162
|
-
readonly indexed: false;
|
|
163
|
-
readonly name: "value";
|
|
164
|
-
readonly type: "uint256";
|
|
165
|
-
}];
|
|
166
|
-
readonly name: "Transfer";
|
|
167
|
-
readonly type: "event";
|
|
168
|
-
}, {
|
|
169
|
-
readonly comment: "From the EIP-2612 spec.";
|
|
170
|
-
readonly inputs: readonly [{
|
|
171
|
-
readonly internalType: "address";
|
|
172
|
-
readonly name: "owner";
|
|
173
|
-
readonly type: "address";
|
|
174
|
-
}];
|
|
175
|
-
readonly name: "nonces";
|
|
176
|
-
readonly outputs: readonly [{
|
|
177
|
-
readonly internalType: "uint256";
|
|
178
|
-
readonly name: "";
|
|
179
|
-
readonly type: "uint256";
|
|
180
|
-
}];
|
|
181
|
-
readonly stateMutability: "view";
|
|
182
|
-
readonly type: "function";
|
|
183
|
-
}, {
|
|
184
|
-
readonly comment: "From the EIP-2612 spec.";
|
|
185
|
-
readonly inputs: readonly [{
|
|
186
|
-
readonly internalType: "address";
|
|
187
|
-
readonly name: "owner";
|
|
188
|
-
readonly type: "address";
|
|
189
|
-
}, {
|
|
190
|
-
readonly internalType: "address";
|
|
191
|
-
readonly name: "spender";
|
|
192
|
-
readonly type: "address";
|
|
193
|
-
}, {
|
|
194
|
-
readonly internalType: "uint256";
|
|
195
|
-
readonly name: "value";
|
|
196
|
-
readonly type: "uint256";
|
|
197
|
-
}, {
|
|
198
|
-
readonly internalType: "uint256";
|
|
199
|
-
readonly name: "deadline";
|
|
200
|
-
readonly type: "uint256";
|
|
201
|
-
}, {
|
|
202
|
-
readonly internalType: "uint8";
|
|
203
|
-
readonly name: "v";
|
|
204
|
-
readonly type: "uint8";
|
|
205
|
-
}, {
|
|
206
|
-
readonly internalType: "bytes32";
|
|
207
|
-
readonly name: "r";
|
|
208
|
-
readonly type: "bytes32";
|
|
209
|
-
}, {
|
|
210
|
-
readonly internalType: "bytes32";
|
|
211
|
-
readonly name: "s";
|
|
212
|
-
readonly type: "bytes32";
|
|
213
|
-
}];
|
|
214
|
-
readonly name: "permit";
|
|
215
|
-
readonly outputs: readonly [];
|
|
216
|
-
readonly stateMutability: "nonpayable";
|
|
217
|
-
readonly type: "function";
|
|
218
|
-
}, {
|
|
219
|
-
readonly comment: "Available on bridged tokens on Polygon.";
|
|
220
|
-
readonly inputs: readonly [{
|
|
221
|
-
readonly internalType: "address";
|
|
222
|
-
readonly name: "userAddress";
|
|
223
|
-
readonly type: "address";
|
|
224
|
-
}, {
|
|
225
|
-
readonly internalType: "bytes";
|
|
226
|
-
readonly name: "functionSignature";
|
|
227
|
-
readonly type: "bytes";
|
|
228
|
-
}, {
|
|
229
|
-
readonly internalType: "bytes32";
|
|
230
|
-
readonly name: "sigR";
|
|
231
|
-
readonly type: "bytes32";
|
|
232
|
-
}, {
|
|
233
|
-
readonly internalType: "bytes32";
|
|
234
|
-
readonly name: "sigS";
|
|
235
|
-
readonly type: "bytes32";
|
|
236
|
-
}, {
|
|
237
|
-
readonly internalType: "uint8";
|
|
238
|
-
readonly name: "sigV";
|
|
239
|
-
readonly type: "uint8";
|
|
240
|
-
}];
|
|
241
|
-
readonly name: "executeMetaTransaction";
|
|
242
|
-
readonly outputs: readonly [{
|
|
243
|
-
readonly internalType: "bytes";
|
|
244
|
-
readonly name: "";
|
|
245
|
-
readonly type: "bytes";
|
|
246
|
-
}];
|
|
247
|
-
readonly stateMutability: "payable";
|
|
248
|
-
readonly type: "function";
|
|
249
|
-
}, {
|
|
250
|
-
readonly comment: "Available on bridged tokens on Polygon.";
|
|
251
|
-
readonly inputs: readonly [{
|
|
252
|
-
readonly internalType: "address";
|
|
253
|
-
readonly name: "user";
|
|
254
|
-
readonly type: "address";
|
|
255
|
-
}];
|
|
256
|
-
readonly name: "getNonce";
|
|
257
|
-
readonly outputs: readonly [{
|
|
258
|
-
readonly internalType: "uint256";
|
|
259
|
-
readonly name: "nonce";
|
|
260
|
-
readonly type: "uint256";
|
|
261
|
-
}];
|
|
262
|
-
readonly stateMutability: "view";
|
|
263
|
-
readonly type: "function";
|
|
264
|
-
}];
|