@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.
Files changed (95) 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 -575
  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 -9
  33. package/dist/cjs/xcs/lifi-agg.js +0 -177
  34. package/dist/cjs/xcs/selectsources.js +0 -255
  35. package/dist/esm/_polyfill.js +0 -143
  36. package/dist/esm/balances/ub-api.js +0 -21
  37. package/dist/esm/cosmos/index.js +0 -26
  38. package/dist/esm/data/chaindata.js +0 -785
  39. package/dist/esm/data/chainid.js +0 -87
  40. package/dist/esm/data/currency.js +0 -73
  41. package/dist/esm/data/index.js +0 -4
  42. package/dist/esm/data/utils.js +0 -34
  43. package/dist/esm/evmabi/erc20.abi.js +0 -346
  44. package/dist/esm/evmabi/fibrousrouter.abi.js +0 -38
  45. package/dist/esm/evmabi/index.js +0 -4
  46. package/dist/esm/evmabi/vault.abi.js +0 -1018
  47. package/dist/esm/evmabi/yakaggregator.abi.js +0 -272
  48. package/dist/esm/index.js +0 -13
  49. package/dist/esm/permitutils/index.js +0 -181
  50. package/dist/esm/proto/client.js +0 -11
  51. package/dist/esm/proto/definition.js +0 -4122
  52. package/dist/esm/proto/grpc.js +0 -292
  53. package/dist/esm/rff/rff.js +0 -38
  54. package/dist/esm/types/binarytypes.js +0 -1
  55. package/dist/esm/types/index.js +0 -2
  56. package/dist/esm/types/msgpack-axios.js +0 -18
  57. package/dist/esm/vaultcontracts/index.js +0 -1
  58. package/dist/esm/vaultcontracts/vaultcontracts.js +0 -218
  59. package/dist/esm/xcs/autochoice.js +0 -559
  60. package/dist/esm/xcs/bebop-agg.js +0 -151
  61. package/dist/esm/xcs/fibrous-agg.js +0 -150
  62. package/dist/esm/xcs/iface.js +0 -10
  63. package/dist/esm/xcs/index.js +0 -6
  64. package/dist/esm/xcs/lifi-agg.js +0 -172
  65. package/dist/esm/xcs/selectsources.js +0 -251
  66. package/dist/types/_polyfill.d.ts +0 -1
  67. package/dist/types/balances/ub-api.d.ts +0 -14
  68. package/dist/types/cosmos/index.d.ts +0 -6
  69. package/dist/types/data/chaindata.d.ts +0 -20
  70. package/dist/types/data/chainid.d.ts +0 -31
  71. package/dist/types/data/currency.d.ts +0 -30
  72. package/dist/types/data/index.d.ts +0 -4
  73. package/dist/types/data/utils.d.ts +0 -10
  74. package/dist/types/evmabi/erc20.abi.d.ts +0 -264
  75. package/dist/types/evmabi/fibrousrouter.abi.d.ts +0 -77
  76. package/dist/types/evmabi/index.d.ts +0 -4
  77. package/dist/types/evmabi/vault.abi.d.ts +0 -785
  78. package/dist/types/evmabi/yakaggregator.abi.d.ts +0 -298
  79. package/dist/types/permitutils/index.d.ts +0 -13
  80. package/dist/types/proto/client.d.ts +0 -2
  81. package/dist/types/proto/definition.d.ts +0 -382
  82. package/dist/types/proto/grpc.d.ts +0 -75
  83. package/dist/types/rff/rff.d.ts +0 -9
  84. package/dist/types/types/binarytypes.d.ts +0 -1
  85. package/dist/types/types/index.d.ts +0 -2
  86. package/dist/types/types/msgpack-axios.d.ts +0 -1
  87. package/dist/types/vaultcontracts/index.d.ts +0 -22
  88. package/dist/types/vaultcontracts/vaultcontracts.d.ts +0 -8
  89. package/dist/types/xcs/autochoice.d.ts +0 -104
  90. package/dist/types/xcs/bebop-agg.d.ts +0 -104
  91. package/dist/types/xcs/fibrous-agg.d.ts +0 -56
  92. package/dist/types/xcs/iface.d.ts +0 -69
  93. package/dist/types/xcs/index.d.ts +0 -6
  94. package/dist/types/xcs/lifi-agg.d.ts +0 -42
  95. package/dist/types/xcs/selectsources.d.ts +0 -27
@@ -1,272 +0,0 @@
1
- export const YakAggregatorABI = [
2
- {
3
- inputs: [
4
- { internalType: "uint256", name: "_amountIn", type: "uint256" },
5
- {
6
- internalType: "address",
7
- name: "_tokenIn",
8
- type: "address",
9
- },
10
- { internalType: "address", name: "_tokenOut", type: "address" },
11
- {
12
- internalType: "uint256",
13
- name: "_maxSteps",
14
- type: "uint256",
15
- },
16
- ],
17
- name: "findBestPath",
18
- outputs: [
19
- {
20
- components: [
21
- {
22
- internalType: "uint256[]",
23
- name: "amounts",
24
- type: "uint256[]",
25
- },
26
- { internalType: "address[]", name: "adapters", type: "address[]" },
27
- {
28
- internalType: "address[]",
29
- name: "path",
30
- type: "address[]",
31
- },
32
- { internalType: "uint256", name: "gasEstimate", type: "uint256" },
33
- ],
34
- internalType: "struct YakRouter.FormattedOffer",
35
- name: "",
36
- type: "tuple",
37
- },
38
- ],
39
- stateMutability: "view",
40
- type: "function",
41
- },
42
- {
43
- inputs: [
44
- { internalType: "uint256", name: "_amountIn", type: "uint256" },
45
- {
46
- internalType: "address",
47
- name: "_tokenIn",
48
- type: "address",
49
- },
50
- { internalType: "address", name: "_tokenOut", type: "address" },
51
- {
52
- internalType: "uint256",
53
- name: "_maxSteps",
54
- type: "uint256",
55
- },
56
- { internalType: "uint256", name: "_gasPrice", type: "uint256" },
57
- ],
58
- name: "findBestPathWithGas",
59
- outputs: [
60
- {
61
- components: [
62
- {
63
- internalType: "uint256[]",
64
- name: "amounts",
65
- type: "uint256[]",
66
- },
67
- { internalType: "address[]", name: "adapters", type: "address[]" },
68
- {
69
- internalType: "address[]",
70
- name: "path",
71
- type: "address[]",
72
- },
73
- { internalType: "uint256", name: "gasEstimate", type: "uint256" },
74
- ],
75
- internalType: "struct YakRouter.FormattedOffer",
76
- name: "",
77
- type: "tuple",
78
- },
79
- ],
80
- stateMutability: "view",
81
- type: "function",
82
- },
83
- {
84
- inputs: [
85
- {
86
- components: [
87
- {
88
- internalType: "uint256",
89
- name: "amountIn",
90
- type: "uint256",
91
- },
92
- { internalType: "uint256", name: "amountOut", type: "uint256" },
93
- {
94
- internalType: "address[]",
95
- name: "path",
96
- type: "address[]",
97
- },
98
- { internalType: "address[]", name: "adapters", type: "address[]" },
99
- ],
100
- internalType: "struct YakRouter.Trade",
101
- name: "_trade",
102
- type: "tuple",
103
- },
104
- { internalType: "address", name: "_to", type: "address" },
105
- {
106
- internalType: "uint256",
107
- name: "_fee",
108
- type: "uint256",
109
- },
110
- ],
111
- name: "swapNoSplit",
112
- outputs: [],
113
- stateMutability: "nonpayable",
114
- type: "function",
115
- },
116
- {
117
- inputs: [
118
- {
119
- components: [
120
- {
121
- internalType: "uint256",
122
- name: "amountIn",
123
- type: "uint256",
124
- },
125
- { internalType: "uint256", name: "amountOut", type: "uint256" },
126
- {
127
- internalType: "address[]",
128
- name: "path",
129
- type: "address[]",
130
- },
131
- { internalType: "address[]", name: "adapters", type: "address[]" },
132
- ],
133
- internalType: "struct YakRouter.Trade",
134
- name: "_trade",
135
- type: "tuple",
136
- },
137
- { internalType: "address", name: "_to", type: "address" },
138
- {
139
- internalType: "uint256",
140
- name: "_fee",
141
- type: "uint256",
142
- },
143
- ],
144
- name: "swapNoSplitFromAVAX",
145
- outputs: [],
146
- stateMutability: "payable",
147
- type: "function",
148
- },
149
- {
150
- inputs: [
151
- {
152
- components: [
153
- {
154
- internalType: "uint256",
155
- name: "amountIn",
156
- type: "uint256",
157
- },
158
- { internalType: "uint256", name: "amountOut", type: "uint256" },
159
- {
160
- internalType: "address[]",
161
- name: "path",
162
- type: "address[]",
163
- },
164
- { internalType: "address[]", name: "adapters", type: "address[]" },
165
- ],
166
- internalType: "struct YakRouter.Trade",
167
- name: "_trade",
168
- type: "tuple",
169
- },
170
- { internalType: "address", name: "_to", type: "address" },
171
- {
172
- internalType: "uint256",
173
- name: "_fee",
174
- type: "uint256",
175
- },
176
- ],
177
- name: "swapNoSplitToAVAX",
178
- outputs: [],
179
- stateMutability: "nonpayable",
180
- type: "function",
181
- },
182
- {
183
- inputs: [
184
- {
185
- components: [
186
- {
187
- internalType: "uint256",
188
- name: "amountIn",
189
- type: "uint256",
190
- },
191
- { internalType: "uint256", name: "amountOut", type: "uint256" },
192
- {
193
- internalType: "address[]",
194
- name: "path",
195
- type: "address[]",
196
- },
197
- { internalType: "address[]", name: "adapters", type: "address[]" },
198
- ],
199
- internalType: "struct YakRouter.Trade",
200
- name: "_trade",
201
- type: "tuple",
202
- },
203
- { internalType: "address", name: "_to", type: "address" },
204
- {
205
- internalType: "uint256",
206
- name: "_fee",
207
- type: "uint256",
208
- },
209
- { internalType: "uint256", name: "_deadline", type: "uint256" },
210
- {
211
- internalType: "uint8",
212
- name: "_v",
213
- type: "uint8",
214
- },
215
- { internalType: "bytes32", name: "_r", type: "bytes32" },
216
- {
217
- internalType: "bytes32",
218
- name: "_s",
219
- type: "bytes32",
220
- },
221
- ],
222
- name: "swapNoSplitToAVAXWithPermit",
223
- outputs: [],
224
- stateMutability: "nonpayable",
225
- type: "function",
226
- },
227
- {
228
- inputs: [
229
- {
230
- components: [
231
- {
232
- internalType: "uint256",
233
- name: "amountIn",
234
- type: "uint256",
235
- },
236
- { internalType: "uint256", name: "amountOut", type: "uint256" },
237
- {
238
- internalType: "address[]",
239
- name: "path",
240
- type: "address[]",
241
- },
242
- { internalType: "address[]", name: "adapters", type: "address[]" },
243
- ],
244
- internalType: "struct YakRouter.Trade",
245
- name: "_trade",
246
- type: "tuple",
247
- },
248
- { internalType: "address", name: "_to", type: "address" },
249
- {
250
- internalType: "uint256",
251
- name: "_fee",
252
- type: "uint256",
253
- },
254
- { internalType: "uint256", name: "_deadline", type: "uint256" },
255
- {
256
- internalType: "uint8",
257
- name: "_v",
258
- type: "uint8",
259
- },
260
- { internalType: "bytes32", name: "_r", type: "bytes32" },
261
- {
262
- internalType: "bytes32",
263
- name: "_s",
264
- type: "bytes32",
265
- },
266
- ],
267
- name: "swapNoSplitWithPermit",
268
- outputs: [],
269
- stateMutability: "nonpayable",
270
- type: "function",
271
- },
272
- ];
package/dist/esm/index.js DELETED
@@ -1,13 +0,0 @@
1
- import "./_polyfill";
2
- export * from "./proto/definition";
3
- export { QueryClientImpl, GrpcWebError, GrpcWebImpl, } from "./proto/grpc";
4
- export { createGrpcWebImpl } from "./proto/client";
5
- export * from "./data";
6
- export * from "./vaultcontracts";
7
- export * from "./permitutils";
8
- export * from "./xcs";
9
- export * from "./cosmos";
10
- export * from "./rff/rff";
11
- export * from "./types";
12
- export * from "./balances/ub-api";
13
- export * from "./evmabi";
@@ -1,181 +0,0 @@
1
- import { bytesToHex, encodeFunctionData, getContract, hexToBigInt, pad, } from "viem";
2
- import { ERC20ABI } from "../evmabi";
3
- export var PermitVariant;
4
- (function (PermitVariant) {
5
- PermitVariant[PermitVariant["Unsupported"] = 0] = "Unsupported";
6
- PermitVariant[PermitVariant["EIP2612Canonical"] = 1] = "EIP2612Canonical";
7
- PermitVariant[PermitVariant["DAI"] = 2] = "DAI";
8
- PermitVariant[PermitVariant["Polygon2612"] = 3] = "Polygon2612";
9
- PermitVariant[PermitVariant["PolygonEMT"] = 4] = "PolygonEMT";
10
- })(PermitVariant || (PermitVariant = {}));
11
- export class PermitCreationError extends Error {
12
- }
13
- const EIP712Domain = [
14
- { name: "name", type: "string" },
15
- { name: "version", type: "string" },
16
- { name: "chainId", type: "uint256" },
17
- { name: "verifyingContract", type: "address" },
18
- ];
19
- const PolygonDomain = [
20
- { name: "name", type: "string" },
21
- { name: "version", type: "string" },
22
- { name: "verifyingContract", type: "address" },
23
- { name: "salt", type: "bytes32" },
24
- ];
25
- export async function signPermitForAddressAndValue(cur, client, account, spender, value, contract, deadline) {
26
- if (contract == null) {
27
- contract = getContract({
28
- address: bytesToHex(cur.tokenAddress.subarray(12)),
29
- abi: ERC20ABI,
30
- client,
31
- });
32
- }
33
- const walletAddress = account.address;
34
- deadline = deadline ?? 2n ** 256n - 1n;
35
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
- const requestsToBeMade = [
37
- contract.read.name(),
38
- client.request({ method: "eth_chainId" }, { dedupe: true }),
39
- ];
40
- switch (cur.permitVariant) {
41
- case PermitVariant.Unsupported:
42
- default: {
43
- throw new PermitCreationError("Permits are unsupported on this currency");
44
- }
45
- case PermitVariant.EIP2612Canonical:
46
- case PermitVariant.DAI:
47
- case PermitVariant.Polygon2612: {
48
- requestsToBeMade[2] = contract.read.nonces([walletAddress]);
49
- break;
50
- }
51
- case PermitVariant.PolygonEMT: {
52
- requestsToBeMade[2] = contract.read.getNonce([walletAddress]);
53
- }
54
- }
55
- const [name, chainID, nonce] = await Promise.all(requestsToBeMade);
56
- switch (cur.permitVariant) {
57
- case PermitVariant.EIP2612Canonical: {
58
- return client.signTypedData({
59
- types: {
60
- EIP712Domain,
61
- Permit: [
62
- { name: "owner", type: "address" },
63
- { name: "spender", type: "address" },
64
- { name: "value", type: "uint256" },
65
- { name: "nonce", type: "uint256" },
66
- { name: "deadline", type: "uint256" },
67
- ],
68
- },
69
- primaryType: "Permit",
70
- domain: {
71
- name,
72
- version: cur.permitContractVersion.toString(10),
73
- chainId: hexToBigInt(chainID),
74
- verifyingContract: contract.address,
75
- },
76
- message: {
77
- owner: walletAddress,
78
- spender,
79
- value,
80
- nonce,
81
- deadline,
82
- },
83
- account,
84
- });
85
- }
86
- case PermitVariant.DAI: {
87
- return client.signTypedData({
88
- types: {
89
- EIP712Domain,
90
- Permit: [
91
- { name: "holder", type: "address" },
92
- { name: "spender", type: "address" },
93
- { name: "nonce", type: "uint256" },
94
- { name: "expiry", type: "uint256" },
95
- { name: "allowed", type: "bool" },
96
- ],
97
- },
98
- primaryType: "Permit",
99
- domain: {
100
- name,
101
- version: cur.permitContractVersion.toString(10),
102
- chainId: hexToBigInt(chainID),
103
- verifyingContract: contract.address,
104
- },
105
- message: {
106
- holder: walletAddress,
107
- spender: spender,
108
- nonce,
109
- expiry: deadline,
110
- allowed: true,
111
- },
112
- account,
113
- });
114
- }
115
- case PermitVariant.Polygon2612: {
116
- return client.signTypedData({
117
- types: {
118
- EIP712Domain: PolygonDomain,
119
- Permit: [
120
- { name: "holder", type: "address" },
121
- { name: "spender", type: "address" },
122
- { name: "nonce", type: "uint256" },
123
- { name: "expiry", type: "uint256" },
124
- { name: "allowed", type: "bool" },
125
- ],
126
- },
127
- primaryType: "Permit",
128
- domain: {
129
- name,
130
- version: cur.permitContractVersion.toString(10),
131
- verifyingContract: contract.address,
132
- salt: pad(chainID, {
133
- dir: "left",
134
- size: 32,
135
- }),
136
- },
137
- message: {
138
- holder: walletAddress,
139
- spender: spender,
140
- nonce,
141
- expiry: deadline,
142
- allowed: true,
143
- },
144
- account,
145
- });
146
- }
147
- case PermitVariant.PolygonEMT: {
148
- const funcSig = encodeFunctionData({
149
- abi: ERC20ABI,
150
- functionName: "approve",
151
- args: [spender, value],
152
- });
153
- return client.signTypedData({
154
- types: {
155
- EIP712Domain: PolygonDomain,
156
- MetaTransaction: [
157
- { name: "nonce", type: "uint256" },
158
- { name: "from", type: "address" },
159
- { name: "functionSignature", type: "bytes" },
160
- ],
161
- },
162
- primaryType: "MetaTransaction",
163
- domain: {
164
- name,
165
- version: cur.permitContractVersion.toString(10),
166
- verifyingContract: contract.address,
167
- salt: pad(chainID, {
168
- dir: "left",
169
- size: 32,
170
- }),
171
- },
172
- message: {
173
- nonce,
174
- from: walletAddress,
175
- functionSignature: funcSig,
176
- },
177
- account,
178
- });
179
- }
180
- }
181
- }
@@ -1,11 +0,0 @@
1
- import { GrpcWebImpl } from "./grpc";
2
- export const createGrpcWebImpl = async (url) => {
3
- const options = {};
4
- // eslint-disable-next-line no-constant-binary-expression, valid-typeof
5
- if (typeof window == undefined) {
6
- const lib = await import("@improbable-eng/grpc-web-node-http-transport");
7
- options.transport = lib.NodeHttpTransport();
8
- }
9
- const impl = new GrpcWebImpl(url, options);
10
- return impl;
11
- };