@curvefi/api 2.68.30 → 2.68.32

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/README.md CHANGED
@@ -1380,6 +1380,98 @@ import curve from "@curvefi/api";
1380
1380
  })()
1381
1381
  ```
1382
1382
 
1383
+ ## FastBridge
1384
+
1385
+ FastBridge allows bridging crvUSD from L2 networks (Arbitrum, Optimism, Fraxtal) to Ethereum mainnet.
1386
+
1387
+ ```ts
1388
+ import curve from "@curvefi/api";
1389
+
1390
+ (async () => {
1391
+ // Initialize on L2 network (Arbitrum, Optimism, or Fraxtal)
1392
+ await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0, chainId: 42161 }); // Arbitrum
1393
+
1394
+ // Check if FastBridge is supported on current network
1395
+ curve.fastBridge.isSupported();
1396
+ // true (on Arbitrum, Optimism, Fraxtal)
1397
+ // false (on other networks)
1398
+
1399
+ // Assert that FastBridge is supported (throws error if not)
1400
+ curve.fastBridge.assertIsSupported();
1401
+ // No error on supported networks
1402
+ // Throws "FastBridge is not available on this network" on unsupported networks
1403
+
1404
+ // Get list of supported networks
1405
+ const supportedNetworks = curve.fastBridge.getSupportedNetworks();
1406
+ console.log(supportedNetworks);
1407
+ // [
1408
+ // {
1409
+ // chainId: 42161,
1410
+ // name: 'Arbitrum',
1411
+ // fastBridgeAddress: '0x1F2aF270029d028400265Ce1dd0919BA8780dAe1',
1412
+ // crvUsdAddress: '0x498Bf2B1e120FeD3ad3D42EA2165E9b73f99C1e5'
1413
+ // },
1414
+ // {
1415
+ // chainId: 10,
1416
+ // name: 'Optimism',
1417
+ // fastBridgeAddress: '0xD16d5eC345Dd86Fb63C6a9C43c517210F1027914',
1418
+ // crvUsdAddress: '0x417Ac0e078398C154EdFadD9Ef675d30Be60Af93'
1419
+ // },
1420
+ // {
1421
+ // chainId: 252,
1422
+ // name: 'Fraxtal',
1423
+ // fastBridgeAddress: '0x3fE593E651Cd0B383AD36b75F4159f30BB0631A6',
1424
+ // crvUsdAddress: '0x67bCae3700C0fd13FB1951C7801050349F8C5caa'
1425
+ // }
1426
+ // ]
1427
+
1428
+ // Check allowed bridge amounts (min/max)
1429
+ const { min, max } = await curve.fastBridge.allowedToBridge();
1430
+ console.log(min, max);
1431
+ // 10.0 49990.0
1432
+
1433
+ // Get bridge cost (must be called before bridging to cache the value)
1434
+ const cost = await curve.fastBridge.bridgeCost();
1435
+ console.log(cost);
1436
+ // 0.001234567890123456 (in ETH)
1437
+
1438
+ // Check if crvUSD is approved for the amount you want to bridge
1439
+ await curve.fastBridge.isApproved(1000);
1440
+ // false
1441
+
1442
+ // Approve crvUSD for bridging
1443
+ await curve.fastBridge.approve(1000);
1444
+ // [
1445
+ // '0xc111e471715ae6f5437e12d3b94868a5b6542cd7304efca18b5782d315760ae5'
1446
+ // ]
1447
+
1448
+ // Bridge crvUSD to Ethereum mainnet
1449
+ // Note: You must call bridgeCost() first to cache the cost value
1450
+ const bridgeTx = await curve.fastBridge.bridge(1000);
1451
+ // OR bridge to specific address:
1452
+ // const bridgeTx = await curve.fastBridge.bridge(1000, '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb');
1453
+ console.log(bridgeTx.hash);
1454
+ // 0xc7ba1d60871c0295ac5471bb602c37ec0f00a71543b3a041308ebd91833f26ba
1455
+
1456
+ // Estimate gas for approve
1457
+ await curve.fastBridge.estimateGas.approve(1000);
1458
+ // 46000
1459
+
1460
+ // Estimate gas for bridge
1461
+ await curve.fastBridge.estimateGas.bridge(1000);
1462
+ // 150000
1463
+ })()
1464
+ ```
1465
+
1466
+ **Important Notes:**
1467
+ 1. FastBridge is only available on L2 networks (Arbitrum, Optimism, Fraxtal)
1468
+ - Use `isSupported()` to check if current network supports FastBridge
1469
+ - Use `assertIsSupported()` to throw an error if not supported
1470
+ 2. You must call `bridgeCost()` before calling `bridge()` to cache the cost value
1471
+ 3. The bridge method is payable - it will send the cost amount in ETH/native currency
1472
+ 4. Bridge amount must be within the allowed range (min/max from `allowedToBridge()`)
1473
+ 5. `_min_amount` is automatically set equal to `_amount` for slippage protection
1474
+
1383
1475
  ## Boosting
1384
1476
 
1385
1477
  ### Lock
@@ -0,0 +1,21 @@
1
+ import { ethers } from "ethers";
2
+ import { type Curve } from "./curve.js";
3
+ export interface IFastBridgeNetwork {
4
+ chainId: number;
5
+ name: string;
6
+ fastBridgeAddress: string;
7
+ crvUsdAddress: string;
8
+ }
9
+ export declare function isSupported(this: Curve): boolean;
10
+ export declare function assertIsSupported(this: Curve): void;
11
+ export declare function allowedToBridge(this: Curve): Promise<{
12
+ min: number;
13
+ max: number;
14
+ }>;
15
+ export declare function bridgeCost(this: Curve): Promise<number>;
16
+ export declare function bridgeIsApproved(this: Curve, amount: number | string): Promise<boolean>;
17
+ export declare function bridgeApproveEstimateGas(this: Curve, amount: number | string): Promise<number | number[]>;
18
+ export declare function bridgeApprove(this: Curve, amount: number | string): Promise<string[]>;
19
+ export declare function bridgeEstimateGas(this: Curve, amount: number | string, address?: string): Promise<number | number[]>;
20
+ export declare function bridge(this: Curve, amount: number | string, address?: string): Promise<ethers.ContractTransactionResponse>;
21
+ export declare function getSupportedNetworks(): IFastBridgeNetwork[];
package/lib/bridge.js ADDED
@@ -0,0 +1,128 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { ensureAllowance, ensureAllowanceEstimateGas, hasAllowance, parseUnits, DIGas, smartNumber, } from "./utils.js";
11
+ import { NETWORK_CONSTANTS } from "./constants/network_constants.js";
12
+ const CRVUSD_DECIMALS = 18;
13
+ const _bridgeCostCache = {};
14
+ export function isSupported() {
15
+ return !!(this.constants.ALIASES.fast_bridge && this.constants.ALIASES.crvusd);
16
+ }
17
+ export function assertIsSupported() {
18
+ if (!this.constants.ALIASES.fast_bridge) {
19
+ throw new Error("FastBridge is not available on this network");
20
+ }
21
+ if (!this.constants.ALIASES.crvusd) {
22
+ throw new Error("crvUSD is not available on this network");
23
+ }
24
+ }
25
+ function _allowedToBridge() {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ assertIsSupported.call(this);
28
+ const contract = this.contracts[this.constants.ALIASES.fast_bridge].contract;
29
+ const result = yield contract.allowed_to_bridge(this.constantOptions);
30
+ return {
31
+ _min: result[0],
32
+ _max: result[1],
33
+ };
34
+ });
35
+ }
36
+ export function allowedToBridge() {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const { _min, _max } = yield _allowedToBridge.call(this);
39
+ return {
40
+ min: Number(this.formatUnits(_min, CRVUSD_DECIMALS)),
41
+ max: Number(this.formatUnits(_max, CRVUSD_DECIMALS)),
42
+ };
43
+ });
44
+ }
45
+ function _bridgeCost() {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ assertIsSupported.call(this);
48
+ const contract = this.contracts[this.constants.ALIASES.fast_bridge].contract;
49
+ return yield contract.cost(this.constantOptions);
50
+ });
51
+ }
52
+ export function bridgeCost() {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ const _cost = yield _bridgeCost.call(this);
55
+ const key = `${this.chainId}`;
56
+ _bridgeCostCache[key] = _cost;
57
+ return Number(this.formatUnits(_cost, 18));
58
+ });
59
+ }
60
+ export function bridgeIsApproved(amount) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ assertIsSupported.call(this);
63
+ return yield hasAllowance.call(this, [this.constants.ALIASES.crvusd], [amount], this.signerAddress, this.constants.ALIASES.fast_bridge);
64
+ });
65
+ }
66
+ export function bridgeApproveEstimateGas(amount) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ assertIsSupported.call(this);
69
+ return yield ensureAllowanceEstimateGas.call(this, [this.constants.ALIASES.crvusd], [amount], this.constants.ALIASES.fast_bridge);
70
+ });
71
+ }
72
+ export function bridgeApprove(amount) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ assertIsSupported.call(this);
75
+ return yield ensureAllowance.call(this, [this.constants.ALIASES.crvusd], [amount], this.constants.ALIASES.fast_bridge);
76
+ });
77
+ }
78
+ function _bridge(amount_1, address_1) {
79
+ return __awaiter(this, arguments, void 0, function* (amount, address, estimateGas = false) {
80
+ assertIsSupported.call(this);
81
+ const _amount = parseUnits(amount, CRVUSD_DECIMALS);
82
+ const { _min, _max } = yield _allowedToBridge.call(this);
83
+ if (_amount < _min || _amount > _max) {
84
+ throw new Error(`Amount must be between ${this.formatUnits(_min, CRVUSD_DECIMALS)} and ${this.formatUnits(_max, CRVUSD_DECIMALS)}`);
85
+ }
86
+ const key = `${this.chainId}`;
87
+ const _cost = _bridgeCostCache[key];
88
+ if (_cost === undefined) {
89
+ throw new Error("You must call bridgeCost() first to get the bridge cost");
90
+ }
91
+ const to = address || this.signerAddress;
92
+ const contract = this.contracts[this.constants.ALIASES.fast_bridge].contract;
93
+ if (!estimateGas)
94
+ yield bridgeApprove.call(this, amount);
95
+ const gas = yield contract.bridge.estimateGas(this.constants.ALIASES.crvusd, to, _amount, _amount, Object.assign(Object.assign({}, this.constantOptions), { value: _cost }));
96
+ if (estimateGas)
97
+ return smartNumber(gas);
98
+ yield this.updateFeeData();
99
+ const gasLimit = DIGas(gas) * this.parseUnits("160", 0) / this.parseUnits("100", 0);
100
+ return yield contract.bridge(this.constants.ALIASES.crvusd, to, _amount, _amount, Object.assign(Object.assign({}, this.options), { value: _cost, gasLimit }));
101
+ });
102
+ }
103
+ export function bridgeEstimateGas(amount, address) {
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ return yield _bridge.call(this, amount, address, true);
106
+ });
107
+ }
108
+ export function bridge(amount, address) {
109
+ return __awaiter(this, void 0, void 0, function* () {
110
+ return yield _bridge.call(this, amount, address, false);
111
+ });
112
+ }
113
+ export function getSupportedNetworks() {
114
+ var _a, _b;
115
+ const networks = [];
116
+ for (const [chainIdStr, config] of Object.entries(NETWORK_CONSTANTS)) {
117
+ const chainId = Number(chainIdStr);
118
+ if (((_a = config.ALIASES) === null || _a === void 0 ? void 0 : _a.fast_bridge) && ((_b = config.ALIASES) === null || _b === void 0 ? void 0 : _b.crvusd)) {
119
+ networks.push({
120
+ chainId,
121
+ name: config.NAME,
122
+ fastBridgeAddress: config.ALIASES.fast_bridge,
123
+ crvUsdAddress: config.ALIASES.crvusd,
124
+ });
125
+ }
126
+ }
127
+ return networks;
128
+ }
@@ -0,0 +1,400 @@
1
+ [
2
+ {
3
+ "anonymous": false,
4
+ "inputs": [
5
+ {
6
+ "indexed": false,
7
+ "name": "min_amount",
8
+ "type": "uint256"
9
+ }
10
+ ],
11
+ "name": "SetMinAmount",
12
+ "type": "event"
13
+ },
14
+ {
15
+ "anonymous": false,
16
+ "inputs": [
17
+ {
18
+ "indexed": false,
19
+ "name": "limit",
20
+ "type": "uint256"
21
+ }
22
+ ],
23
+ "name": "SetLimit",
24
+ "type": "event"
25
+ },
26
+ {
27
+ "anonymous": false,
28
+ "inputs": [
29
+ {
30
+ "indexed": false,
31
+ "name": "bridger",
32
+ "type": "address"
33
+ }
34
+ ],
35
+ "name": "SetBridger",
36
+ "type": "event"
37
+ },
38
+ {
39
+ "anonymous": false,
40
+ "inputs": [
41
+ {
42
+ "indexed": false,
43
+ "name": "messenger",
44
+ "type": "address"
45
+ }
46
+ ],
47
+ "name": "SetMessenger",
48
+ "type": "event"
49
+ },
50
+ {
51
+ "anonymous": false,
52
+ "inputs": [
53
+ {
54
+ "indexed": true,
55
+ "name": "previous_owner",
56
+ "type": "address"
57
+ },
58
+ {
59
+ "indexed": true,
60
+ "name": "new_owner",
61
+ "type": "address"
62
+ }
63
+ ],
64
+ "name": "OwnershipTransferred",
65
+ "type": "event"
66
+ },
67
+ {
68
+ "anonymous": false,
69
+ "inputs": [
70
+ {
71
+ "indexed": true,
72
+ "name": "token",
73
+ "type": "address"
74
+ },
75
+ {
76
+ "indexed": true,
77
+ "name": "sender",
78
+ "type": "address"
79
+ },
80
+ {
81
+ "indexed": true,
82
+ "name": "receiver",
83
+ "type": "address"
84
+ },
85
+ {
86
+ "indexed": false,
87
+ "name": "amount",
88
+ "type": "uint256"
89
+ }
90
+ ],
91
+ "name": "Bridge",
92
+ "type": "event"
93
+ },
94
+ {
95
+ "inputs": [],
96
+ "name": "owner",
97
+ "outputs": [
98
+ {
99
+ "name": "",
100
+ "type": "address"
101
+ }
102
+ ],
103
+ "stateMutability": "view",
104
+ "type": "function"
105
+ },
106
+ {
107
+ "inputs": [
108
+ {
109
+ "name": "new_owner",
110
+ "type": "address"
111
+ }
112
+ ],
113
+ "name": "transfer_ownership",
114
+ "outputs": [],
115
+ "stateMutability": "nonpayable",
116
+ "type": "function"
117
+ },
118
+ {
119
+ "inputs": [],
120
+ "name": "renounce_ownership",
121
+ "outputs": [],
122
+ "stateMutability": "nonpayable",
123
+ "type": "function"
124
+ },
125
+ {
126
+ "inputs": [],
127
+ "name": "cost",
128
+ "outputs": [
129
+ {
130
+ "name": "",
131
+ "type": "uint256"
132
+ }
133
+ ],
134
+ "stateMutability": "view",
135
+ "type": "function"
136
+ },
137
+ {
138
+ "inputs": [
139
+ {
140
+ "name": "_token",
141
+ "type": "address"
142
+ },
143
+ {
144
+ "name": "_to",
145
+ "type": "address"
146
+ },
147
+ {
148
+ "name": "_amount",
149
+ "type": "uint256"
150
+ }
151
+ ],
152
+ "name": "bridge",
153
+ "outputs": [
154
+ {
155
+ "name": "",
156
+ "type": "uint256"
157
+ }
158
+ ],
159
+ "stateMutability": "payable",
160
+ "type": "function"
161
+ },
162
+ {
163
+ "inputs": [
164
+ {
165
+ "name": "_token",
166
+ "type": "address"
167
+ },
168
+ {
169
+ "name": "_to",
170
+ "type": "address"
171
+ },
172
+ {
173
+ "name": "_amount",
174
+ "type": "uint256"
175
+ },
176
+ {
177
+ "name": "_min_amount",
178
+ "type": "uint256"
179
+ }
180
+ ],
181
+ "name": "bridge",
182
+ "outputs": [
183
+ {
184
+ "name": "",
185
+ "type": "uint256"
186
+ }
187
+ ],
188
+ "stateMutability": "payable",
189
+ "type": "function"
190
+ },
191
+ {
192
+ "inputs": [],
193
+ "name": "allowed_to_bridge",
194
+ "outputs": [
195
+ {
196
+ "name": "",
197
+ "type": "uint256"
198
+ },
199
+ {
200
+ "name": "",
201
+ "type": "uint256"
202
+ }
203
+ ],
204
+ "stateMutability": "view",
205
+ "type": "function"
206
+ },
207
+ {
208
+ "inputs": [
209
+ {
210
+ "name": "_ts",
211
+ "type": "uint256"
212
+ }
213
+ ],
214
+ "name": "allowed_to_bridge",
215
+ "outputs": [
216
+ {
217
+ "name": "",
218
+ "type": "uint256"
219
+ },
220
+ {
221
+ "name": "",
222
+ "type": "uint256"
223
+ }
224
+ ],
225
+ "stateMutability": "view",
226
+ "type": "function"
227
+ },
228
+ {
229
+ "inputs": [
230
+ {
231
+ "name": "_min_amount",
232
+ "type": "uint256"
233
+ }
234
+ ],
235
+ "name": "set_min_amount",
236
+ "outputs": [],
237
+ "stateMutability": "nonpayable",
238
+ "type": "function"
239
+ },
240
+ {
241
+ "inputs": [
242
+ {
243
+ "name": "_limit",
244
+ "type": "uint256"
245
+ }
246
+ ],
247
+ "name": "set_limit",
248
+ "outputs": [],
249
+ "stateMutability": "nonpayable",
250
+ "type": "function"
251
+ },
252
+ {
253
+ "inputs": [
254
+ {
255
+ "name": "_bridger",
256
+ "type": "address"
257
+ }
258
+ ],
259
+ "name": "set_bridger",
260
+ "outputs": [],
261
+ "stateMutability": "nonpayable",
262
+ "type": "function"
263
+ },
264
+ {
265
+ "inputs": [
266
+ {
267
+ "name": "_messenger",
268
+ "type": "address"
269
+ }
270
+ ],
271
+ "name": "set_messenger",
272
+ "outputs": [],
273
+ "stateMutability": "nonpayable",
274
+ "type": "function"
275
+ },
276
+ {
277
+ "inputs": [],
278
+ "name": "version",
279
+ "outputs": [
280
+ {
281
+ "name": "",
282
+ "type": "string"
283
+ }
284
+ ],
285
+ "stateMutability": "view",
286
+ "type": "function"
287
+ },
288
+ {
289
+ "inputs": [],
290
+ "name": "CRVUSD",
291
+ "outputs": [
292
+ {
293
+ "name": "",
294
+ "type": "address"
295
+ }
296
+ ],
297
+ "stateMutability": "view",
298
+ "type": "function"
299
+ },
300
+ {
301
+ "inputs": [],
302
+ "name": "VAULT",
303
+ "outputs": [
304
+ {
305
+ "name": "",
306
+ "type": "address"
307
+ }
308
+ ],
309
+ "stateMutability": "view",
310
+ "type": "function"
311
+ },
312
+ {
313
+ "inputs": [],
314
+ "name": "min_amount",
315
+ "outputs": [
316
+ {
317
+ "name": "",
318
+ "type": "uint256"
319
+ }
320
+ ],
321
+ "stateMutability": "view",
322
+ "type": "function"
323
+ },
324
+ {
325
+ "inputs": [],
326
+ "name": "limit",
327
+ "outputs": [
328
+ {
329
+ "name": "",
330
+ "type": "uint256"
331
+ }
332
+ ],
333
+ "stateMutability": "view",
334
+ "type": "function"
335
+ },
336
+ {
337
+ "inputs": [
338
+ {
339
+ "name": "arg0",
340
+ "type": "uint256"
341
+ }
342
+ ],
343
+ "name": "bridged",
344
+ "outputs": [
345
+ {
346
+ "name": "",
347
+ "type": "uint256"
348
+ }
349
+ ],
350
+ "stateMutability": "view",
351
+ "type": "function"
352
+ },
353
+ {
354
+ "inputs": [],
355
+ "name": "bridger",
356
+ "outputs": [
357
+ {
358
+ "name": "",
359
+ "type": "address"
360
+ }
361
+ ],
362
+ "stateMutability": "view",
363
+ "type": "function"
364
+ },
365
+ {
366
+ "inputs": [],
367
+ "name": "messenger",
368
+ "outputs": [
369
+ {
370
+ "name": "",
371
+ "type": "address"
372
+ }
373
+ ],
374
+ "stateMutability": "view",
375
+ "type": "function"
376
+ },
377
+ {
378
+ "inputs": [
379
+ {
380
+ "name": "_crvusd",
381
+ "type": "address"
382
+ },
383
+ {
384
+ "name": "_vault",
385
+ "type": "address"
386
+ },
387
+ {
388
+ "name": "_bridger",
389
+ "type": "address"
390
+ },
391
+ {
392
+ "name": "_messenger",
393
+ "type": "address"
394
+ }
395
+ ],
396
+ "outputs": [],
397
+ "stateMutability": "nonpayable",
398
+ "type": "constructor"
399
+ }
400
+ ]
@@ -100,6 +100,8 @@ const ALIASES_ARBITRUM = lowerCaseValues({
100
100
  "twocrypto_factory": '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F',
101
101
  "tricrypto_factory": '0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8',
102
102
  "factory_admin": "",
103
+ "fast_bridge": "0x1F2aF270029d028400265Ce1dd0919BA8780dAe1",
104
+ "crvusd": "0x498Bf2B1e120FeD3ad3D42EA2165E9b73f99C1e5",
103
105
  });
104
106
  const ALIASES_OPTIMISM = lowerCaseValues({
105
107
  "crv": "0x0994206dfE8De6Ec6920FF4D779B0d950605Fb53",
@@ -120,6 +122,8 @@ const ALIASES_OPTIMISM = lowerCaseValues({
120
122
  "factory_admin": "",
121
123
  "gas_oracle": '0xc0d3C0d3C0d3c0D3C0D3C0d3C0d3C0D3C0D3000f',
122
124
  "gas_oracle_blob": '0x420000000000000000000000000000000000000f',
125
+ "fast_bridge": "0xD16d5eC345Dd86Fb63C6a9C43c517210F1027914",
126
+ "crvusd": "0xC52D7F23a2e460248Db6eE192Cb23dD12bDDCbf6",
123
127
  });
124
128
  const ALIASES_XDAI = lowerCaseValues({
125
129
  "crv": "0x712b3d230f3c1c19db860d80619288b1f0bdd0bd",
@@ -274,6 +278,8 @@ const ALIASES_FRAXTAL = lowerCaseValues({
274
278
  "twocrypto_factory": '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F',
275
279
  "tricrypto_factory": '0xc9Fe0C63Af9A39402e8a5514f9c43Af0322b665F',
276
280
  "factory_admin": '0x0000000000000000000000000000000000000000',
281
+ "fast_bridge": "0x3fE593E651Cd0B383AD36b75F4159f30BB0631A6",
282
+ "crvusd": "0xB102f7Efa0d5dE071A8D37B3548e1C7CB148Caf3",
277
283
  });
278
284
  const ALIASES_XLAYER = lowerCaseValues({
279
285
  "crv": "0x0000000000000000000000000000000000000000",
package/lib/curve.js CHANGED
@@ -48,6 +48,7 @@ import gasOracleBlobABI from './constants/abis/gas_oracle_optimism_blob.json' wi
48
48
  import votingProposalABI from './constants/abis/voting_proposal.json' with { type: 'json' };
49
49
  import circulatingSupplyABI from './constants/abis/circulating_supply.json' with { type: 'json' };
50
50
  import rootGaugeFactoryABI from "./constants/abis/gauge_factory/root_gauge_factory.json" with { type: "json" };
51
+ import fastBridgeABI from './constants/abis/fastBridge.json' with { type: 'json' };
51
52
  import { extractDecimals, extractGauges, formatUnits, lowerCasePoolDataAddresses, parseUnits, } from "./constants/utils.js";
52
53
  import { _getHiddenPools } from "./external-api.js";
53
54
  import { L2Networks } from "./constants/L2Networks.js";
@@ -561,6 +562,13 @@ export class Curve {
561
562
  this.constants.DECIMALS[this.constants.ALIASES.crv] = 18;
562
563
  this.setContract(this.constants.COINS.scrvusd, ERC20Abi);
563
564
  this.constants.DECIMALS[this.constants.COINS.scrvusd] = 18;
565
+ if (this.constants.ALIASES.fast_bridge) {
566
+ this.setContract(this.constants.ALIASES.fast_bridge, fastBridgeABI);
567
+ }
568
+ if (this.constants.ALIASES.crvusd) {
569
+ this.setContract(this.constants.ALIASES.crvusd, ERC20Abi);
570
+ this.constants.DECIMALS[this.constants.ALIASES.crvusd] = 18;
571
+ }
564
572
  if (this.chainId === 1) {
565
573
  this.setContract(this.constants.ALIASES.minter, minterMainnetABI);
566
574
  this.setContract(this.constants.ALIASES.fee_distributor_crvusd, feeDistributorCrvUSDABI);
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ethers } from "ethers";
2
2
  import { PoolTemplate } from "./pools/index.js";
3
+ import { getSupportedNetworks } from "./bridge.js";
3
4
  import { deployCryptoPoolEstimateGas, deployTwocryptoPoolEstimateGas } from './factory/deploy.js';
4
5
  import { getTwoCryptoImplementations } from './constants/twoCryptoImplementations.js';
5
6
  export declare const createCurve: () => {
@@ -268,6 +269,23 @@ export declare const createCurve: () => {
268
269
  swapFromCalldata: (tx: ethers.TransactionRequest) => Promise<number | number[]>;
269
270
  };
270
271
  };
272
+ fastBridge: {
273
+ assertIsSupported: () => void;
274
+ isSupported: () => boolean;
275
+ getSupportedNetworks: typeof getSupportedNetworks;
276
+ allowedToBridge: () => Promise<{
277
+ min: number;
278
+ max: number;
279
+ }>;
280
+ bridgeCost: () => Promise<number>;
281
+ isApproved: (amount: string | number) => Promise<boolean>;
282
+ approve: (amount: string | number) => Promise<string[]>;
283
+ bridge: (amount: string | number, address?: string | undefined) => Promise<ethers.ContractTransactionResponse>;
284
+ estimateGas: {
285
+ approve: (amount: string | number) => Promise<number | number[]>;
286
+ bridge: (amount: string | number, address?: string | undefined) => Promise<number | number[]>;
287
+ };
288
+ };
271
289
  dao: {
272
290
  crvSupplyStats: () => Promise<{
273
291
  circulating: string;
@@ -585,6 +603,23 @@ declare const _default: {
585
603
  swapFromCalldata: (tx: ethers.TransactionRequest) => Promise<number | number[]>;
586
604
  };
587
605
  };
606
+ fastBridge: {
607
+ assertIsSupported: () => void;
608
+ isSupported: () => boolean;
609
+ getSupportedNetworks: typeof getSupportedNetworks;
610
+ allowedToBridge: () => Promise<{
611
+ min: number;
612
+ max: number;
613
+ }>;
614
+ bridgeCost: () => Promise<number>;
615
+ isApproved: (amount: string | number) => Promise<boolean>;
616
+ approve: (amount: string | number) => Promise<string[]>;
617
+ bridge: (amount: string | number, address?: string | undefined) => Promise<ethers.ContractTransactionResponse>;
618
+ estimateGas: {
619
+ approve: (amount: string | number) => Promise<number | number[]>;
620
+ bridge: (amount: string | number, address?: string | undefined) => Promise<number | number[]>;
621
+ };
622
+ };
588
623
  dao: {
589
624
  crvSupplyStats: () => Promise<{
590
625
  circulating: string;
package/lib/index.js CHANGED
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { PoolTemplate, getPool } from "./pools/index.js";
11
11
  import { getUserPoolListByLiquidity, getUserPoolListByClaimable, getUserPoolList, getUserLiquidityUSD, getUserClaimable, } from "./pools/utils.js";
12
12
  import { getBestRouteAndOutput, getArgs, swapExpected, swapRequired, swapPriceImpact, swapIsApproved, swapApproveEstimateGas, swapApprove, swapPopulateApprove, swapEstimateGas, swap, populateSwap, getSwappedAmount, approveFromCalldata, approveFromCalldataEstimateGas, swapFromCalldata, swapFromCalldataEstimateGas, } from "./router.js";
13
+ import { isSupported, assertIsSupported, allowedToBridge, bridgeCost, bridgeIsApproved, bridgeApproveEstimateGas, bridgeApprove, bridgeEstimateGas, bridge, getSupportedNetworks, } from "./bridge.js";
13
14
  import { Curve } from "./curve.js";
14
15
  import { getCrv, getLockedAmountAndUnlockTime, getVeCrv, getVeCrvPct, calcUnlockTime, createLockEstimateGas, createLock, isApproved, approveEstimateGas, approve, increaseAmountEstimateGas, increaseAmount, increaseUnlockTimeEstimateGas, increaseUnlockTime, withdrawLockedCrvEstimateGas, withdrawLockedCrv, claimableFees, claimFeesEstimateGas, claimFees, lastEthBlock, getAnycallBalance, topUpAnycall, topUpAnycallEstimateGas, lastBlockSent, blockToSend, sendBlockhash, sendBlockhashEstimateGas, submitProof, submitProofEstimateGas, claimFeesCrvUSDEstimateGas, claimableFeesCrvUSD, claimFeesCrvUSD, calculateVeCrv, } from "./boosting.js";
15
16
  import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, populateApprove, getUsdRate, getGasPriceFromL1, getGasPriceFromL2, getGasInfoForL2, getTVL, getCoinsData, getVolume, hasDepositAndStake, hasRouter, getBasePools, getGasPrice, getCurveLiteNetworks, } from "./utils.js";
@@ -242,6 +243,20 @@ export const createCurve = () => {
242
243
  swapFromCalldata: swapFromCalldataEstimateGas.bind(_curve),
243
244
  },
244
245
  },
246
+ fastBridge: {
247
+ assertIsSupported: assertIsSupported.bind(_curve),
248
+ isSupported: isSupported.bind(_curve),
249
+ getSupportedNetworks: getSupportedNetworks.bind(_curve),
250
+ allowedToBridge: allowedToBridge.bind(_curve),
251
+ bridgeCost: bridgeCost.bind(_curve),
252
+ isApproved: bridgeIsApproved.bind(_curve),
253
+ approve: bridgeApprove.bind(_curve),
254
+ bridge: bridge.bind(_curve),
255
+ estimateGas: {
256
+ approve: bridgeApproveEstimateGas.bind(_curve),
257
+ bridge: bridgeEstimateGas.bind(_curve),
258
+ },
259
+ },
245
260
  dao: {
246
261
  // --- CRV lock ---
247
262
  // View methods
@@ -184,6 +184,7 @@ export declare class PoolTemplate extends CorePool {
184
184
  getSwapInfo(): Promise<ISwapMethodInfo>;
185
185
  _swapWrappedExpected(i: number, j: number, _amount: bigint): Promise<bigint>;
186
186
  swapWrappedExpected(inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<string>;
187
+ swapWrappedExpectedBigInt(inputCoin: string | number, outputCoin: string | number, amount: bigint): Promise<bigint>;
187
188
  swapWrappedPriceImpact(inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<number>;
188
189
  swapWrappedIsApproved(inputCoin: string | number, amount: number | string): Promise<boolean>;
189
190
  private swapWrappedApproveEstimateGas;
@@ -1832,6 +1832,12 @@ export class PoolTemplate extends CorePool {
1832
1832
  throw Error(`swapWrappedExpected method doesn't exist for pool ${this.name} (id: ${this.name})`);
1833
1833
  });
1834
1834
  }
1835
+ // OVERRIDE
1836
+ swapWrappedExpectedBigInt(inputCoin, outputCoin, amount) {
1837
+ return __awaiter(this, void 0, void 0, function* () {
1838
+ throw Error(`swapWrappedExpectedBigInt method doesn't exist for pool ${this.name} (id: ${this.name})`);
1839
+ });
1840
+ }
1835
1841
  swapWrappedPriceImpact(inputCoin, outputCoin, amount) {
1836
1842
  return __awaiter(this, void 0, void 0, function* () {
1837
1843
  if (this.isPlain || this.isFake) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.68.30",
3
+ "version": "2.68.32",
4
4
  "description": "JavaScript library for curve.finance",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",