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