tempo.ts 0.7.0 → 0.7.1
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/CHANGELOG.md +6 -0
- package/dist/viem/Actions/amm.d.ts +1213 -51
- package/dist/viem/Actions/amm.d.ts.map +1 -1
- package/dist/viem/Actions/amm.js +452 -0
- package/dist/viem/Actions/amm.js.map +1 -1
- package/dist/wagmi/Actions/amm.d.ts +225 -0
- package/dist/wagmi/Actions/amm.d.ts.map +1 -1
- package/dist/wagmi/Actions/amm.js +248 -0
- package/dist/wagmi/Actions/amm.js.map +1 -1
- package/dist/wagmi/Hooks/amm.d.ts +236 -0
- package/dist/wagmi/Hooks/amm.d.ts.map +1 -1
- package/dist/wagmi/Hooks/amm.js +285 -0
- package/dist/wagmi/Hooks/amm.js.map +1 -1
- package/package.json +1 -1
- package/src/viem/Actions/amm.ts +672 -0
- package/src/wagmi/Actions/amm.ts +346 -0
- package/src/wagmi/Hooks/amm.ts +443 -0
|
@@ -185,6 +185,1017 @@ export declare namespace getLiquidityBalance {
|
|
|
185
185
|
to: Address;
|
|
186
186
|
};
|
|
187
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Performs a rebalance swap from validator token to user token.
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* import { createClient, http } from 'viem'
|
|
194
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
195
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
196
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
197
|
+
*
|
|
198
|
+
* const client = createClient({
|
|
199
|
+
* account: privateKeyToAccount('0x...'),
|
|
200
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
201
|
+
* transport: http(),
|
|
202
|
+
* })
|
|
203
|
+
*
|
|
204
|
+
* const hash = await Actions.amm.rebalanceSwap(client, {
|
|
205
|
+
* userToken: '0x...',
|
|
206
|
+
* validatorToken: '0x...',
|
|
207
|
+
* amountOut: 100n,
|
|
208
|
+
* to: '0x...',
|
|
209
|
+
* })
|
|
210
|
+
* ```
|
|
211
|
+
*
|
|
212
|
+
* @param client - Client.
|
|
213
|
+
* @param parameters - Parameters.
|
|
214
|
+
* @returns The transaction hash.
|
|
215
|
+
*/
|
|
216
|
+
export declare function rebalanceSwap<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: rebalanceSwap.Parameters<chain, account>): Promise<rebalanceSwap.ReturnValue>;
|
|
217
|
+
export declare namespace rebalanceSwap {
|
|
218
|
+
type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = WriteParameters<chain, account> & Args;
|
|
219
|
+
type Args = {
|
|
220
|
+
/** Amount of user token to receive. */
|
|
221
|
+
amountOut: bigint;
|
|
222
|
+
/** Address to send the user token to. */
|
|
223
|
+
to: Address;
|
|
224
|
+
/** Address or ID of the user token. */
|
|
225
|
+
userToken: TokenId.TokenIdOrAddress;
|
|
226
|
+
/** Address or ID of the validator token. */
|
|
227
|
+
validatorToken: TokenId.TokenIdOrAddress;
|
|
228
|
+
};
|
|
229
|
+
type ReturnValue = WriteContractReturnType;
|
|
230
|
+
/** @internal */
|
|
231
|
+
function inner<action extends typeof writeContract | typeof writeContractSync, chain extends Chain | undefined, account extends Account | undefined>(action: action, client: Client<Transport, chain, account>, parameters: rebalanceSwap.Parameters<chain, account>): Promise<ReturnType<action>>;
|
|
232
|
+
/**
|
|
233
|
+
* Defines a call to the `rebalanceSwap` function.
|
|
234
|
+
*
|
|
235
|
+
* Can be passed as a parameter to:
|
|
236
|
+
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
|
|
237
|
+
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
|
|
238
|
+
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```ts
|
|
242
|
+
* import { createClient, http, walletActions } from 'viem'
|
|
243
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
244
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
245
|
+
*
|
|
246
|
+
* const client = createClient({
|
|
247
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
248
|
+
* transport: http(),
|
|
249
|
+
* }).extend(walletActions)
|
|
250
|
+
*
|
|
251
|
+
* const { result } = await client.sendCalls({
|
|
252
|
+
* calls: [
|
|
253
|
+
* actions.amm.rebalanceSwap.call({
|
|
254
|
+
* userToken: '0x20c0...beef',
|
|
255
|
+
* validatorToken: '0x20c0...babe',
|
|
256
|
+
* amountOut: 100n,
|
|
257
|
+
* to: '0xfeed...fede',
|
|
258
|
+
* }),
|
|
259
|
+
* actions.amm.rebalanceSwap.call({
|
|
260
|
+
* userToken: '0x20c0...babe',
|
|
261
|
+
* validatorToken: '0x20c0...babe',
|
|
262
|
+
* amountOut: 100n,
|
|
263
|
+
* to: '0xfeed...fede',
|
|
264
|
+
* }),
|
|
265
|
+
* ]
|
|
266
|
+
* })
|
|
267
|
+
* ```
|
|
268
|
+
*
|
|
269
|
+
* @param args - Arguments.
|
|
270
|
+
* @returns The call.
|
|
271
|
+
*/
|
|
272
|
+
function call(args: Args): {
|
|
273
|
+
abi: [{
|
|
274
|
+
readonly name: "rebalanceSwap";
|
|
275
|
+
readonly type: "function";
|
|
276
|
+
readonly stateMutability: "nonpayable";
|
|
277
|
+
readonly inputs: readonly [{
|
|
278
|
+
readonly type: "address";
|
|
279
|
+
readonly name: "userToken";
|
|
280
|
+
}, {
|
|
281
|
+
readonly type: "address";
|
|
282
|
+
readonly name: "validatorToken";
|
|
283
|
+
}, {
|
|
284
|
+
readonly type: "uint256";
|
|
285
|
+
readonly name: "amountOut";
|
|
286
|
+
}, {
|
|
287
|
+
readonly type: "address";
|
|
288
|
+
readonly name: "to";
|
|
289
|
+
}];
|
|
290
|
+
readonly outputs: readonly [{
|
|
291
|
+
readonly type: "uint256";
|
|
292
|
+
readonly name: "amountIn";
|
|
293
|
+
}];
|
|
294
|
+
}];
|
|
295
|
+
functionName: "rebalanceSwap";
|
|
296
|
+
args?: readonly [`0x${string}`, `0x${string}`, bigint, `0x${string}`] | undefined;
|
|
297
|
+
} & {
|
|
298
|
+
args: readonly [`0x${string}`, `0x${string}`, bigint, `0x${string}`];
|
|
299
|
+
} & {
|
|
300
|
+
address: Address;
|
|
301
|
+
} & {
|
|
302
|
+
data: Hex;
|
|
303
|
+
to: Address;
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Extracts the `RebalanceSwap` event from logs.
|
|
307
|
+
*
|
|
308
|
+
* @param logs - The logs.
|
|
309
|
+
* @returns The `RebalanceSwap` event.
|
|
310
|
+
*/
|
|
311
|
+
function extractEvent(logs: Log[]): Log<bigint, number, false, undefined, true, readonly [{
|
|
312
|
+
readonly name: "MIN_LIQUIDITY";
|
|
313
|
+
readonly type: "function";
|
|
314
|
+
readonly stateMutability: "view";
|
|
315
|
+
readonly inputs: readonly [];
|
|
316
|
+
readonly outputs: readonly [{
|
|
317
|
+
readonly type: "uint256";
|
|
318
|
+
}];
|
|
319
|
+
}, {
|
|
320
|
+
readonly name: "getPoolId";
|
|
321
|
+
readonly type: "function";
|
|
322
|
+
readonly stateMutability: "pure";
|
|
323
|
+
readonly inputs: readonly [{
|
|
324
|
+
readonly type: "address";
|
|
325
|
+
readonly name: "userToken";
|
|
326
|
+
}, {
|
|
327
|
+
readonly type: "address";
|
|
328
|
+
readonly name: "validatorToken";
|
|
329
|
+
}];
|
|
330
|
+
readonly outputs: readonly [{
|
|
331
|
+
readonly type: "bytes32";
|
|
332
|
+
}];
|
|
333
|
+
}, {
|
|
334
|
+
readonly name: "getPool";
|
|
335
|
+
readonly type: "function";
|
|
336
|
+
readonly stateMutability: "view";
|
|
337
|
+
readonly inputs: readonly [{
|
|
338
|
+
readonly type: "address";
|
|
339
|
+
readonly name: "userToken";
|
|
340
|
+
}, {
|
|
341
|
+
readonly type: "address";
|
|
342
|
+
readonly name: "validatorToken";
|
|
343
|
+
}];
|
|
344
|
+
readonly outputs: readonly [{
|
|
345
|
+
readonly type: "tuple";
|
|
346
|
+
readonly components: readonly [{
|
|
347
|
+
readonly type: "uint128";
|
|
348
|
+
readonly name: "reserveUserToken";
|
|
349
|
+
}, {
|
|
350
|
+
readonly type: "uint128";
|
|
351
|
+
readonly name: "reserveValidatorToken";
|
|
352
|
+
}];
|
|
353
|
+
}];
|
|
354
|
+
}, {
|
|
355
|
+
readonly name: "pools";
|
|
356
|
+
readonly type: "function";
|
|
357
|
+
readonly stateMutability: "view";
|
|
358
|
+
readonly inputs: readonly [{
|
|
359
|
+
readonly type: "bytes32";
|
|
360
|
+
readonly name: "poolId";
|
|
361
|
+
}];
|
|
362
|
+
readonly outputs: readonly [{
|
|
363
|
+
readonly type: "tuple";
|
|
364
|
+
readonly components: readonly [{
|
|
365
|
+
readonly type: "uint128";
|
|
366
|
+
readonly name: "reserveUserToken";
|
|
367
|
+
}, {
|
|
368
|
+
readonly type: "uint128";
|
|
369
|
+
readonly name: "reserveValidatorToken";
|
|
370
|
+
}];
|
|
371
|
+
}];
|
|
372
|
+
}, {
|
|
373
|
+
readonly name: "mint";
|
|
374
|
+
readonly type: "function";
|
|
375
|
+
readonly stateMutability: "nonpayable";
|
|
376
|
+
readonly inputs: readonly [{
|
|
377
|
+
readonly type: "address";
|
|
378
|
+
readonly name: "userToken";
|
|
379
|
+
}, {
|
|
380
|
+
readonly type: "address";
|
|
381
|
+
readonly name: "validatorToken";
|
|
382
|
+
}, {
|
|
383
|
+
readonly type: "uint256";
|
|
384
|
+
readonly name: "amountUserToken";
|
|
385
|
+
}, {
|
|
386
|
+
readonly type: "uint256";
|
|
387
|
+
readonly name: "amountValidatorToken";
|
|
388
|
+
}, {
|
|
389
|
+
readonly type: "address";
|
|
390
|
+
readonly name: "to";
|
|
391
|
+
}];
|
|
392
|
+
readonly outputs: readonly [{
|
|
393
|
+
readonly type: "uint256";
|
|
394
|
+
readonly name: "liquidity";
|
|
395
|
+
}];
|
|
396
|
+
}, {
|
|
397
|
+
readonly name: "mintWithValidatorToken";
|
|
398
|
+
readonly type: "function";
|
|
399
|
+
readonly stateMutability: "nonpayable";
|
|
400
|
+
readonly inputs: readonly [{
|
|
401
|
+
readonly type: "address";
|
|
402
|
+
readonly name: "userToken";
|
|
403
|
+
}, {
|
|
404
|
+
readonly type: "address";
|
|
405
|
+
readonly name: "validatorToken";
|
|
406
|
+
}, {
|
|
407
|
+
readonly type: "uint256";
|
|
408
|
+
readonly name: "amountValidatorToken";
|
|
409
|
+
}, {
|
|
410
|
+
readonly type: "address";
|
|
411
|
+
readonly name: "to";
|
|
412
|
+
}];
|
|
413
|
+
readonly outputs: readonly [{
|
|
414
|
+
readonly type: "uint256";
|
|
415
|
+
readonly name: "liquidity";
|
|
416
|
+
}];
|
|
417
|
+
}, {
|
|
418
|
+
readonly name: "burn";
|
|
419
|
+
readonly type: "function";
|
|
420
|
+
readonly stateMutability: "nonpayable";
|
|
421
|
+
readonly inputs: readonly [{
|
|
422
|
+
readonly type: "address";
|
|
423
|
+
readonly name: "userToken";
|
|
424
|
+
}, {
|
|
425
|
+
readonly type: "address";
|
|
426
|
+
readonly name: "validatorToken";
|
|
427
|
+
}, {
|
|
428
|
+
readonly type: "uint256";
|
|
429
|
+
readonly name: "liquidity";
|
|
430
|
+
}, {
|
|
431
|
+
readonly type: "address";
|
|
432
|
+
readonly name: "to";
|
|
433
|
+
}];
|
|
434
|
+
readonly outputs: readonly [{
|
|
435
|
+
readonly type: "uint256";
|
|
436
|
+
readonly name: "amountUserToken";
|
|
437
|
+
}, {
|
|
438
|
+
readonly type: "uint256";
|
|
439
|
+
readonly name: "amountValidatorToken";
|
|
440
|
+
}];
|
|
441
|
+
}, {
|
|
442
|
+
readonly name: "totalSupply";
|
|
443
|
+
readonly type: "function";
|
|
444
|
+
readonly stateMutability: "view";
|
|
445
|
+
readonly inputs: readonly [{
|
|
446
|
+
readonly type: "bytes32";
|
|
447
|
+
readonly name: "poolId";
|
|
448
|
+
}];
|
|
449
|
+
readonly outputs: readonly [{
|
|
450
|
+
readonly type: "uint256";
|
|
451
|
+
}];
|
|
452
|
+
}, {
|
|
453
|
+
readonly name: "liquidityBalances";
|
|
454
|
+
readonly type: "function";
|
|
455
|
+
readonly stateMutability: "view";
|
|
456
|
+
readonly inputs: readonly [{
|
|
457
|
+
readonly type: "bytes32";
|
|
458
|
+
readonly name: "poolId";
|
|
459
|
+
}, {
|
|
460
|
+
readonly type: "address";
|
|
461
|
+
readonly name: "user";
|
|
462
|
+
}];
|
|
463
|
+
readonly outputs: readonly [{
|
|
464
|
+
readonly type: "uint256";
|
|
465
|
+
}];
|
|
466
|
+
}, {
|
|
467
|
+
readonly name: "rebalanceSwap";
|
|
468
|
+
readonly type: "function";
|
|
469
|
+
readonly stateMutability: "nonpayable";
|
|
470
|
+
readonly inputs: readonly [{
|
|
471
|
+
readonly type: "address";
|
|
472
|
+
readonly name: "userToken";
|
|
473
|
+
}, {
|
|
474
|
+
readonly type: "address";
|
|
475
|
+
readonly name: "validatorToken";
|
|
476
|
+
}, {
|
|
477
|
+
readonly type: "uint256";
|
|
478
|
+
readonly name: "amountOut";
|
|
479
|
+
}, {
|
|
480
|
+
readonly type: "address";
|
|
481
|
+
readonly name: "to";
|
|
482
|
+
}];
|
|
483
|
+
readonly outputs: readonly [{
|
|
484
|
+
readonly type: "uint256";
|
|
485
|
+
readonly name: "amountIn";
|
|
486
|
+
}];
|
|
487
|
+
}, {
|
|
488
|
+
readonly name: "Mint";
|
|
489
|
+
readonly type: "event";
|
|
490
|
+
readonly inputs: readonly [{
|
|
491
|
+
readonly type: "address";
|
|
492
|
+
readonly name: "sender";
|
|
493
|
+
readonly indexed: true;
|
|
494
|
+
}, {
|
|
495
|
+
readonly type: "address";
|
|
496
|
+
readonly name: "userToken";
|
|
497
|
+
readonly indexed: true;
|
|
498
|
+
}, {
|
|
499
|
+
readonly type: "address";
|
|
500
|
+
readonly name: "validatorToken";
|
|
501
|
+
readonly indexed: true;
|
|
502
|
+
}, {
|
|
503
|
+
readonly type: "uint256";
|
|
504
|
+
readonly name: "amountUserToken";
|
|
505
|
+
}, {
|
|
506
|
+
readonly type: "uint256";
|
|
507
|
+
readonly name: "amountValidatorToken";
|
|
508
|
+
}, {
|
|
509
|
+
readonly type: "uint256";
|
|
510
|
+
readonly name: "liquidity";
|
|
511
|
+
}];
|
|
512
|
+
}, {
|
|
513
|
+
readonly name: "Burn";
|
|
514
|
+
readonly type: "event";
|
|
515
|
+
readonly inputs: readonly [{
|
|
516
|
+
readonly type: "address";
|
|
517
|
+
readonly name: "sender";
|
|
518
|
+
readonly indexed: true;
|
|
519
|
+
}, {
|
|
520
|
+
readonly type: "address";
|
|
521
|
+
readonly name: "userToken";
|
|
522
|
+
readonly indexed: true;
|
|
523
|
+
}, {
|
|
524
|
+
readonly type: "address";
|
|
525
|
+
readonly name: "validatorToken";
|
|
526
|
+
readonly indexed: true;
|
|
527
|
+
}, {
|
|
528
|
+
readonly type: "uint256";
|
|
529
|
+
readonly name: "amountUserToken";
|
|
530
|
+
}, {
|
|
531
|
+
readonly type: "uint256";
|
|
532
|
+
readonly name: "amountValidatorToken";
|
|
533
|
+
}, {
|
|
534
|
+
readonly type: "uint256";
|
|
535
|
+
readonly name: "liquidity";
|
|
536
|
+
}, {
|
|
537
|
+
readonly type: "address";
|
|
538
|
+
readonly name: "to";
|
|
539
|
+
}];
|
|
540
|
+
}, {
|
|
541
|
+
readonly name: "RebalanceSwap";
|
|
542
|
+
readonly type: "event";
|
|
543
|
+
readonly inputs: readonly [{
|
|
544
|
+
readonly type: "address";
|
|
545
|
+
readonly name: "userToken";
|
|
546
|
+
readonly indexed: true;
|
|
547
|
+
}, {
|
|
548
|
+
readonly type: "address";
|
|
549
|
+
readonly name: "validatorToken";
|
|
550
|
+
readonly indexed: true;
|
|
551
|
+
}, {
|
|
552
|
+
readonly type: "address";
|
|
553
|
+
readonly name: "swapper";
|
|
554
|
+
readonly indexed: true;
|
|
555
|
+
}, {
|
|
556
|
+
readonly type: "uint256";
|
|
557
|
+
readonly name: "amountIn";
|
|
558
|
+
}, {
|
|
559
|
+
readonly type: "uint256";
|
|
560
|
+
readonly name: "amountOut";
|
|
561
|
+
}];
|
|
562
|
+
}, {
|
|
563
|
+
readonly name: "FeeSwap";
|
|
564
|
+
readonly type: "event";
|
|
565
|
+
readonly inputs: readonly [{
|
|
566
|
+
readonly type: "address";
|
|
567
|
+
readonly name: "userToken";
|
|
568
|
+
readonly indexed: true;
|
|
569
|
+
}, {
|
|
570
|
+
readonly type: "address";
|
|
571
|
+
readonly name: "validatorToken";
|
|
572
|
+
readonly indexed: true;
|
|
573
|
+
}, {
|
|
574
|
+
readonly type: "uint256";
|
|
575
|
+
readonly name: "amountIn";
|
|
576
|
+
}, {
|
|
577
|
+
readonly type: "uint256";
|
|
578
|
+
readonly name: "amountOut";
|
|
579
|
+
}];
|
|
580
|
+
}, {
|
|
581
|
+
readonly name: "IdenticalAddresses";
|
|
582
|
+
readonly type: "error";
|
|
583
|
+
readonly inputs: readonly [];
|
|
584
|
+
}, {
|
|
585
|
+
readonly name: "ZeroAddress";
|
|
586
|
+
readonly type: "error";
|
|
587
|
+
readonly inputs: readonly [];
|
|
588
|
+
}, {
|
|
589
|
+
readonly name: "PoolExists";
|
|
590
|
+
readonly type: "error";
|
|
591
|
+
readonly inputs: readonly [];
|
|
592
|
+
}, {
|
|
593
|
+
readonly name: "PoolDoesNotExist";
|
|
594
|
+
readonly type: "error";
|
|
595
|
+
readonly inputs: readonly [];
|
|
596
|
+
}, {
|
|
597
|
+
readonly name: "InvalidToken";
|
|
598
|
+
readonly type: "error";
|
|
599
|
+
readonly inputs: readonly [];
|
|
600
|
+
}, {
|
|
601
|
+
readonly name: "InsufficientLiquidity";
|
|
602
|
+
readonly type: "error";
|
|
603
|
+
readonly inputs: readonly [];
|
|
604
|
+
}, {
|
|
605
|
+
readonly name: "OnlyProtocol";
|
|
606
|
+
readonly type: "error";
|
|
607
|
+
readonly inputs: readonly [];
|
|
608
|
+
}, {
|
|
609
|
+
readonly name: "InsufficientPoolBalance";
|
|
610
|
+
readonly type: "error";
|
|
611
|
+
readonly inputs: readonly [];
|
|
612
|
+
}, {
|
|
613
|
+
readonly name: "InsufficientReserves";
|
|
614
|
+
readonly type: "error";
|
|
615
|
+
readonly inputs: readonly [];
|
|
616
|
+
}, {
|
|
617
|
+
readonly name: "InsufficientLiquidityBalance";
|
|
618
|
+
readonly type: "error";
|
|
619
|
+
readonly inputs: readonly [];
|
|
620
|
+
}, {
|
|
621
|
+
readonly name: "MustDepositLowerBalanceToken";
|
|
622
|
+
readonly type: "error";
|
|
623
|
+
readonly inputs: readonly [];
|
|
624
|
+
}, {
|
|
625
|
+
readonly name: "InvalidAmount";
|
|
626
|
+
readonly type: "error";
|
|
627
|
+
readonly inputs: readonly [];
|
|
628
|
+
}, {
|
|
629
|
+
readonly name: "InvalidRebalanceState";
|
|
630
|
+
readonly type: "error";
|
|
631
|
+
readonly inputs: readonly [];
|
|
632
|
+
}, {
|
|
633
|
+
readonly name: "InvalidRebalanceDirection";
|
|
634
|
+
readonly type: "error";
|
|
635
|
+
readonly inputs: readonly [];
|
|
636
|
+
}, {
|
|
637
|
+
readonly name: "InvalidNewReserves";
|
|
638
|
+
readonly type: "error";
|
|
639
|
+
readonly inputs: readonly [];
|
|
640
|
+
}, {
|
|
641
|
+
readonly name: "CannotSupportPendingSwaps";
|
|
642
|
+
readonly type: "error";
|
|
643
|
+
readonly inputs: readonly [];
|
|
644
|
+
}, {
|
|
645
|
+
readonly name: "DivisionByZero";
|
|
646
|
+
readonly type: "error";
|
|
647
|
+
readonly inputs: readonly [];
|
|
648
|
+
}, {
|
|
649
|
+
readonly name: "InvalidSwapCalculation";
|
|
650
|
+
readonly type: "error";
|
|
651
|
+
readonly inputs: readonly [];
|
|
652
|
+
}, {
|
|
653
|
+
readonly name: "InsufficientLiquidityForPending";
|
|
654
|
+
readonly type: "error";
|
|
655
|
+
readonly inputs: readonly [];
|
|
656
|
+
}, {
|
|
657
|
+
readonly name: "TokenTransferFailed";
|
|
658
|
+
readonly type: "error";
|
|
659
|
+
readonly inputs: readonly [];
|
|
660
|
+
}, {
|
|
661
|
+
readonly name: "InternalError";
|
|
662
|
+
readonly type: "error";
|
|
663
|
+
readonly inputs: readonly [];
|
|
664
|
+
}], "RebalanceSwap">;
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Performs a rebalance swap from validator token to user token.
|
|
668
|
+
*
|
|
669
|
+
* @example
|
|
670
|
+
* ```ts
|
|
671
|
+
* import { createClient, http } from 'viem'
|
|
672
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
673
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
674
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
675
|
+
*
|
|
676
|
+
* const client = createClient({
|
|
677
|
+
* account: privateKeyToAccount('0x...'),
|
|
678
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
679
|
+
* transport: http(),
|
|
680
|
+
* })
|
|
681
|
+
*
|
|
682
|
+
* const result = await Actions.amm.rebalanceSwapSync(client, {
|
|
683
|
+
* userToken: '0x...',
|
|
684
|
+
* validatorToken: '0x...',
|
|
685
|
+
* amountOut: 100n,
|
|
686
|
+
* to: '0x...',
|
|
687
|
+
* })
|
|
688
|
+
* ```
|
|
689
|
+
*
|
|
690
|
+
* @param client - Client.
|
|
691
|
+
* @param parameters - Parameters.
|
|
692
|
+
* @returns The transaction receipt and event data.
|
|
693
|
+
*/
|
|
694
|
+
export declare function rebalanceSwapSync<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: rebalanceSwapSync.Parameters<chain, account>): Promise<rebalanceSwapSync.ReturnValue>;
|
|
695
|
+
export declare namespace rebalanceSwapSync {
|
|
696
|
+
type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = rebalanceSwap.Parameters<chain, account>;
|
|
697
|
+
type Args = rebalanceSwap.Args;
|
|
698
|
+
type ReturnValue = Compute<GetEventArgs<typeof Abis.feeAmm, 'RebalanceSwap', {
|
|
699
|
+
IndexedOnly: false;
|
|
700
|
+
Required: true;
|
|
701
|
+
}> & {
|
|
702
|
+
/** Transaction receipt. */
|
|
703
|
+
receipt: TransactionReceipt;
|
|
704
|
+
}>;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Adds liquidity to a pool.
|
|
708
|
+
*
|
|
709
|
+
* @example
|
|
710
|
+
* ```ts
|
|
711
|
+
* import { createClient, http } from 'viem'
|
|
712
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
713
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
714
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
715
|
+
*
|
|
716
|
+
* const client = createClient({
|
|
717
|
+
* account: privateKeyToAccount('0x...'),
|
|
718
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
719
|
+
* transport: http(),
|
|
720
|
+
* })
|
|
721
|
+
*
|
|
722
|
+
* const hash = await Actions.amm.mint(client, {
|
|
723
|
+
* userToken: {
|
|
724
|
+
* address: '0x20c0...beef',
|
|
725
|
+
* amount: 100n,
|
|
726
|
+
* },
|
|
727
|
+
* validatorToken: {
|
|
728
|
+
* address: '0x20c0...babe',
|
|
729
|
+
* amount: 100n,
|
|
730
|
+
* },
|
|
731
|
+
* to: '0xfeed...fede',
|
|
732
|
+
* })
|
|
733
|
+
* ```
|
|
734
|
+
*
|
|
735
|
+
* @param client - Client.
|
|
736
|
+
* @param parameters - Parameters.
|
|
737
|
+
* @returns The transaction hash.
|
|
738
|
+
*/
|
|
739
|
+
export declare function mint<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: mint.Parameters<chain, account>): Promise<mint.ReturnValue>;
|
|
740
|
+
export declare namespace mint {
|
|
741
|
+
type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = WriteParameters<chain, account> & Args;
|
|
742
|
+
type Args = {
|
|
743
|
+
/** Address to mint LP tokens to. */
|
|
744
|
+
to: Address;
|
|
745
|
+
/** User token address. */
|
|
746
|
+
userTokenAddress: TokenId.TokenIdOrAddress;
|
|
747
|
+
/** Validator token address. */
|
|
748
|
+
validatorTokenAddress: TokenId.TokenIdOrAddress;
|
|
749
|
+
/** Amount of validator token to add. */
|
|
750
|
+
validatorTokenAmount: bigint;
|
|
751
|
+
};
|
|
752
|
+
type ReturnValue = WriteContractReturnType;
|
|
753
|
+
/** @internal */
|
|
754
|
+
function inner<action extends typeof writeContract | typeof writeContractSync, chain extends Chain | undefined, account extends Account | undefined>(action: action, client: Client<Transport, chain, account>, parameters: mint.Parameters<chain, account>): Promise<ReturnType<action>>;
|
|
755
|
+
/**
|
|
756
|
+
* Defines a call to the `mint` function.
|
|
757
|
+
*
|
|
758
|
+
* Can be passed as a parameter to:
|
|
759
|
+
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
|
|
760
|
+
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
|
|
761
|
+
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
|
|
762
|
+
*
|
|
763
|
+
* @example
|
|
764
|
+
* ```ts
|
|
765
|
+
* import { createClient, http, walletActions } from 'viem'
|
|
766
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
767
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
768
|
+
*
|
|
769
|
+
* const client = createClient({
|
|
770
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
771
|
+
* transport: http(),
|
|
772
|
+
* }).extend(walletActions)
|
|
773
|
+
*
|
|
774
|
+
* const { result } = await client.sendCalls({
|
|
775
|
+
* calls: [
|
|
776
|
+
* actions.amm.mint.call({
|
|
777
|
+
* userToken: {
|
|
778
|
+
* address: '0x20c0...beef',
|
|
779
|
+
* amount: 100n,
|
|
780
|
+
* },
|
|
781
|
+
* validatorToken: {
|
|
782
|
+
* address: '0x20c0...babe',
|
|
783
|
+
* amount: 100n,
|
|
784
|
+
* },
|
|
785
|
+
* to: '0xfeed...fede',
|
|
786
|
+
* }),
|
|
787
|
+
* actions.amm.mint.call({
|
|
788
|
+
* userToken: {
|
|
789
|
+
* address: '0x20c0...babe',
|
|
790
|
+
* amount: 100n,
|
|
791
|
+
* },
|
|
792
|
+
* validatorToken: {
|
|
793
|
+
* address: '0x20c0...babe',
|
|
794
|
+
* amount: 100n,
|
|
795
|
+
* },
|
|
796
|
+
* to: '0xfeed...fede',
|
|
797
|
+
* }),
|
|
798
|
+
* ]
|
|
799
|
+
* })
|
|
800
|
+
* ```
|
|
801
|
+
*
|
|
802
|
+
* @param args - Arguments.
|
|
803
|
+
* @returns The call.
|
|
804
|
+
*/
|
|
805
|
+
function call(args: Args): {
|
|
806
|
+
abi: [{
|
|
807
|
+
readonly name: "mintWithValidatorToken";
|
|
808
|
+
readonly type: "function";
|
|
809
|
+
readonly stateMutability: "nonpayable";
|
|
810
|
+
readonly inputs: readonly [{
|
|
811
|
+
readonly type: "address";
|
|
812
|
+
readonly name: "userToken";
|
|
813
|
+
}, {
|
|
814
|
+
readonly type: "address";
|
|
815
|
+
readonly name: "validatorToken";
|
|
816
|
+
}, {
|
|
817
|
+
readonly type: "uint256";
|
|
818
|
+
readonly name: "amountValidatorToken";
|
|
819
|
+
}, {
|
|
820
|
+
readonly type: "address";
|
|
821
|
+
readonly name: "to";
|
|
822
|
+
}];
|
|
823
|
+
readonly outputs: readonly [{
|
|
824
|
+
readonly type: "uint256";
|
|
825
|
+
readonly name: "liquidity";
|
|
826
|
+
}];
|
|
827
|
+
}];
|
|
828
|
+
functionName: "mintWithValidatorToken";
|
|
829
|
+
args?: readonly [`0x${string}`, `0x${string}`, bigint, `0x${string}`] | undefined;
|
|
830
|
+
} & {
|
|
831
|
+
args: readonly [`0x${string}`, `0x${string}`, bigint, `0x${string}`];
|
|
832
|
+
} & {
|
|
833
|
+
address: Address;
|
|
834
|
+
} & {
|
|
835
|
+
data: Hex;
|
|
836
|
+
to: Address;
|
|
837
|
+
};
|
|
838
|
+
/**
|
|
839
|
+
* Extracts the `Mint` event from logs.
|
|
840
|
+
*
|
|
841
|
+
* @param logs - The logs.
|
|
842
|
+
* @returns The `Mint` event.
|
|
843
|
+
*/
|
|
844
|
+
function extractEvent(logs: Log[]): Log<bigint, number, false, undefined, true, readonly [{
|
|
845
|
+
readonly name: "MIN_LIQUIDITY";
|
|
846
|
+
readonly type: "function";
|
|
847
|
+
readonly stateMutability: "view";
|
|
848
|
+
readonly inputs: readonly [];
|
|
849
|
+
readonly outputs: readonly [{
|
|
850
|
+
readonly type: "uint256";
|
|
851
|
+
}];
|
|
852
|
+
}, {
|
|
853
|
+
readonly name: "getPoolId";
|
|
854
|
+
readonly type: "function";
|
|
855
|
+
readonly stateMutability: "pure";
|
|
856
|
+
readonly inputs: readonly [{
|
|
857
|
+
readonly type: "address";
|
|
858
|
+
readonly name: "userToken";
|
|
859
|
+
}, {
|
|
860
|
+
readonly type: "address";
|
|
861
|
+
readonly name: "validatorToken";
|
|
862
|
+
}];
|
|
863
|
+
readonly outputs: readonly [{
|
|
864
|
+
readonly type: "bytes32";
|
|
865
|
+
}];
|
|
866
|
+
}, {
|
|
867
|
+
readonly name: "getPool";
|
|
868
|
+
readonly type: "function";
|
|
869
|
+
readonly stateMutability: "view";
|
|
870
|
+
readonly inputs: readonly [{
|
|
871
|
+
readonly type: "address";
|
|
872
|
+
readonly name: "userToken";
|
|
873
|
+
}, {
|
|
874
|
+
readonly type: "address";
|
|
875
|
+
readonly name: "validatorToken";
|
|
876
|
+
}];
|
|
877
|
+
readonly outputs: readonly [{
|
|
878
|
+
readonly type: "tuple";
|
|
879
|
+
readonly components: readonly [{
|
|
880
|
+
readonly type: "uint128";
|
|
881
|
+
readonly name: "reserveUserToken";
|
|
882
|
+
}, {
|
|
883
|
+
readonly type: "uint128";
|
|
884
|
+
readonly name: "reserveValidatorToken";
|
|
885
|
+
}];
|
|
886
|
+
}];
|
|
887
|
+
}, {
|
|
888
|
+
readonly name: "pools";
|
|
889
|
+
readonly type: "function";
|
|
890
|
+
readonly stateMutability: "view";
|
|
891
|
+
readonly inputs: readonly [{
|
|
892
|
+
readonly type: "bytes32";
|
|
893
|
+
readonly name: "poolId";
|
|
894
|
+
}];
|
|
895
|
+
readonly outputs: readonly [{
|
|
896
|
+
readonly type: "tuple";
|
|
897
|
+
readonly components: readonly [{
|
|
898
|
+
readonly type: "uint128";
|
|
899
|
+
readonly name: "reserveUserToken";
|
|
900
|
+
}, {
|
|
901
|
+
readonly type: "uint128";
|
|
902
|
+
readonly name: "reserveValidatorToken";
|
|
903
|
+
}];
|
|
904
|
+
}];
|
|
905
|
+
}, {
|
|
906
|
+
readonly name: "mint";
|
|
907
|
+
readonly type: "function";
|
|
908
|
+
readonly stateMutability: "nonpayable";
|
|
909
|
+
readonly inputs: readonly [{
|
|
910
|
+
readonly type: "address";
|
|
911
|
+
readonly name: "userToken";
|
|
912
|
+
}, {
|
|
913
|
+
readonly type: "address";
|
|
914
|
+
readonly name: "validatorToken";
|
|
915
|
+
}, {
|
|
916
|
+
readonly type: "uint256";
|
|
917
|
+
readonly name: "amountUserToken";
|
|
918
|
+
}, {
|
|
919
|
+
readonly type: "uint256";
|
|
920
|
+
readonly name: "amountValidatorToken";
|
|
921
|
+
}, {
|
|
922
|
+
readonly type: "address";
|
|
923
|
+
readonly name: "to";
|
|
924
|
+
}];
|
|
925
|
+
readonly outputs: readonly [{
|
|
926
|
+
readonly type: "uint256";
|
|
927
|
+
readonly name: "liquidity";
|
|
928
|
+
}];
|
|
929
|
+
}, {
|
|
930
|
+
readonly name: "mintWithValidatorToken";
|
|
931
|
+
readonly type: "function";
|
|
932
|
+
readonly stateMutability: "nonpayable";
|
|
933
|
+
readonly inputs: readonly [{
|
|
934
|
+
readonly type: "address";
|
|
935
|
+
readonly name: "userToken";
|
|
936
|
+
}, {
|
|
937
|
+
readonly type: "address";
|
|
938
|
+
readonly name: "validatorToken";
|
|
939
|
+
}, {
|
|
940
|
+
readonly type: "uint256";
|
|
941
|
+
readonly name: "amountValidatorToken";
|
|
942
|
+
}, {
|
|
943
|
+
readonly type: "address";
|
|
944
|
+
readonly name: "to";
|
|
945
|
+
}];
|
|
946
|
+
readonly outputs: readonly [{
|
|
947
|
+
readonly type: "uint256";
|
|
948
|
+
readonly name: "liquidity";
|
|
949
|
+
}];
|
|
950
|
+
}, {
|
|
951
|
+
readonly name: "burn";
|
|
952
|
+
readonly type: "function";
|
|
953
|
+
readonly stateMutability: "nonpayable";
|
|
954
|
+
readonly inputs: readonly [{
|
|
955
|
+
readonly type: "address";
|
|
956
|
+
readonly name: "userToken";
|
|
957
|
+
}, {
|
|
958
|
+
readonly type: "address";
|
|
959
|
+
readonly name: "validatorToken";
|
|
960
|
+
}, {
|
|
961
|
+
readonly type: "uint256";
|
|
962
|
+
readonly name: "liquidity";
|
|
963
|
+
}, {
|
|
964
|
+
readonly type: "address";
|
|
965
|
+
readonly name: "to";
|
|
966
|
+
}];
|
|
967
|
+
readonly outputs: readonly [{
|
|
968
|
+
readonly type: "uint256";
|
|
969
|
+
readonly name: "amountUserToken";
|
|
970
|
+
}, {
|
|
971
|
+
readonly type: "uint256";
|
|
972
|
+
readonly name: "amountValidatorToken";
|
|
973
|
+
}];
|
|
974
|
+
}, {
|
|
975
|
+
readonly name: "totalSupply";
|
|
976
|
+
readonly type: "function";
|
|
977
|
+
readonly stateMutability: "view";
|
|
978
|
+
readonly inputs: readonly [{
|
|
979
|
+
readonly type: "bytes32";
|
|
980
|
+
readonly name: "poolId";
|
|
981
|
+
}];
|
|
982
|
+
readonly outputs: readonly [{
|
|
983
|
+
readonly type: "uint256";
|
|
984
|
+
}];
|
|
985
|
+
}, {
|
|
986
|
+
readonly name: "liquidityBalances";
|
|
987
|
+
readonly type: "function";
|
|
988
|
+
readonly stateMutability: "view";
|
|
989
|
+
readonly inputs: readonly [{
|
|
990
|
+
readonly type: "bytes32";
|
|
991
|
+
readonly name: "poolId";
|
|
992
|
+
}, {
|
|
993
|
+
readonly type: "address";
|
|
994
|
+
readonly name: "user";
|
|
995
|
+
}];
|
|
996
|
+
readonly outputs: readonly [{
|
|
997
|
+
readonly type: "uint256";
|
|
998
|
+
}];
|
|
999
|
+
}, {
|
|
1000
|
+
readonly name: "rebalanceSwap";
|
|
1001
|
+
readonly type: "function";
|
|
1002
|
+
readonly stateMutability: "nonpayable";
|
|
1003
|
+
readonly inputs: readonly [{
|
|
1004
|
+
readonly type: "address";
|
|
1005
|
+
readonly name: "userToken";
|
|
1006
|
+
}, {
|
|
1007
|
+
readonly type: "address";
|
|
1008
|
+
readonly name: "validatorToken";
|
|
1009
|
+
}, {
|
|
1010
|
+
readonly type: "uint256";
|
|
1011
|
+
readonly name: "amountOut";
|
|
1012
|
+
}, {
|
|
1013
|
+
readonly type: "address";
|
|
1014
|
+
readonly name: "to";
|
|
1015
|
+
}];
|
|
1016
|
+
readonly outputs: readonly [{
|
|
1017
|
+
readonly type: "uint256";
|
|
1018
|
+
readonly name: "amountIn";
|
|
1019
|
+
}];
|
|
1020
|
+
}, {
|
|
1021
|
+
readonly name: "Mint";
|
|
1022
|
+
readonly type: "event";
|
|
1023
|
+
readonly inputs: readonly [{
|
|
1024
|
+
readonly type: "address";
|
|
1025
|
+
readonly name: "sender";
|
|
1026
|
+
readonly indexed: true;
|
|
1027
|
+
}, {
|
|
1028
|
+
readonly type: "address";
|
|
1029
|
+
readonly name: "userToken";
|
|
1030
|
+
readonly indexed: true;
|
|
1031
|
+
}, {
|
|
1032
|
+
readonly type: "address";
|
|
1033
|
+
readonly name: "validatorToken";
|
|
1034
|
+
readonly indexed: true;
|
|
1035
|
+
}, {
|
|
1036
|
+
readonly type: "uint256";
|
|
1037
|
+
readonly name: "amountUserToken";
|
|
1038
|
+
}, {
|
|
1039
|
+
readonly type: "uint256";
|
|
1040
|
+
readonly name: "amountValidatorToken";
|
|
1041
|
+
}, {
|
|
1042
|
+
readonly type: "uint256";
|
|
1043
|
+
readonly name: "liquidity";
|
|
1044
|
+
}];
|
|
1045
|
+
}, {
|
|
1046
|
+
readonly name: "Burn";
|
|
1047
|
+
readonly type: "event";
|
|
1048
|
+
readonly inputs: readonly [{
|
|
1049
|
+
readonly type: "address";
|
|
1050
|
+
readonly name: "sender";
|
|
1051
|
+
readonly indexed: true;
|
|
1052
|
+
}, {
|
|
1053
|
+
readonly type: "address";
|
|
1054
|
+
readonly name: "userToken";
|
|
1055
|
+
readonly indexed: true;
|
|
1056
|
+
}, {
|
|
1057
|
+
readonly type: "address";
|
|
1058
|
+
readonly name: "validatorToken";
|
|
1059
|
+
readonly indexed: true;
|
|
1060
|
+
}, {
|
|
1061
|
+
readonly type: "uint256";
|
|
1062
|
+
readonly name: "amountUserToken";
|
|
1063
|
+
}, {
|
|
1064
|
+
readonly type: "uint256";
|
|
1065
|
+
readonly name: "amountValidatorToken";
|
|
1066
|
+
}, {
|
|
1067
|
+
readonly type: "uint256";
|
|
1068
|
+
readonly name: "liquidity";
|
|
1069
|
+
}, {
|
|
1070
|
+
readonly type: "address";
|
|
1071
|
+
readonly name: "to";
|
|
1072
|
+
}];
|
|
1073
|
+
}, {
|
|
1074
|
+
readonly name: "RebalanceSwap";
|
|
1075
|
+
readonly type: "event";
|
|
1076
|
+
readonly inputs: readonly [{
|
|
1077
|
+
readonly type: "address";
|
|
1078
|
+
readonly name: "userToken";
|
|
1079
|
+
readonly indexed: true;
|
|
1080
|
+
}, {
|
|
1081
|
+
readonly type: "address";
|
|
1082
|
+
readonly name: "validatorToken";
|
|
1083
|
+
readonly indexed: true;
|
|
1084
|
+
}, {
|
|
1085
|
+
readonly type: "address";
|
|
1086
|
+
readonly name: "swapper";
|
|
1087
|
+
readonly indexed: true;
|
|
1088
|
+
}, {
|
|
1089
|
+
readonly type: "uint256";
|
|
1090
|
+
readonly name: "amountIn";
|
|
1091
|
+
}, {
|
|
1092
|
+
readonly type: "uint256";
|
|
1093
|
+
readonly name: "amountOut";
|
|
1094
|
+
}];
|
|
1095
|
+
}, {
|
|
1096
|
+
readonly name: "FeeSwap";
|
|
1097
|
+
readonly type: "event";
|
|
1098
|
+
readonly inputs: readonly [{
|
|
1099
|
+
readonly type: "address";
|
|
1100
|
+
readonly name: "userToken";
|
|
1101
|
+
readonly indexed: true;
|
|
1102
|
+
}, {
|
|
1103
|
+
readonly type: "address";
|
|
1104
|
+
readonly name: "validatorToken";
|
|
1105
|
+
readonly indexed: true;
|
|
1106
|
+
}, {
|
|
1107
|
+
readonly type: "uint256";
|
|
1108
|
+
readonly name: "amountIn";
|
|
1109
|
+
}, {
|
|
1110
|
+
readonly type: "uint256";
|
|
1111
|
+
readonly name: "amountOut";
|
|
1112
|
+
}];
|
|
1113
|
+
}, {
|
|
1114
|
+
readonly name: "IdenticalAddresses";
|
|
1115
|
+
readonly type: "error";
|
|
1116
|
+
readonly inputs: readonly [];
|
|
1117
|
+
}, {
|
|
1118
|
+
readonly name: "ZeroAddress";
|
|
1119
|
+
readonly type: "error";
|
|
1120
|
+
readonly inputs: readonly [];
|
|
1121
|
+
}, {
|
|
1122
|
+
readonly name: "PoolExists";
|
|
1123
|
+
readonly type: "error";
|
|
1124
|
+
readonly inputs: readonly [];
|
|
1125
|
+
}, {
|
|
1126
|
+
readonly name: "PoolDoesNotExist";
|
|
1127
|
+
readonly type: "error";
|
|
1128
|
+
readonly inputs: readonly [];
|
|
1129
|
+
}, {
|
|
1130
|
+
readonly name: "InvalidToken";
|
|
1131
|
+
readonly type: "error";
|
|
1132
|
+
readonly inputs: readonly [];
|
|
1133
|
+
}, {
|
|
1134
|
+
readonly name: "InsufficientLiquidity";
|
|
1135
|
+
readonly type: "error";
|
|
1136
|
+
readonly inputs: readonly [];
|
|
1137
|
+
}, {
|
|
1138
|
+
readonly name: "OnlyProtocol";
|
|
1139
|
+
readonly type: "error";
|
|
1140
|
+
readonly inputs: readonly [];
|
|
1141
|
+
}, {
|
|
1142
|
+
readonly name: "InsufficientPoolBalance";
|
|
1143
|
+
readonly type: "error";
|
|
1144
|
+
readonly inputs: readonly [];
|
|
1145
|
+
}, {
|
|
1146
|
+
readonly name: "InsufficientReserves";
|
|
1147
|
+
readonly type: "error";
|
|
1148
|
+
readonly inputs: readonly [];
|
|
1149
|
+
}, {
|
|
1150
|
+
readonly name: "InsufficientLiquidityBalance";
|
|
1151
|
+
readonly type: "error";
|
|
1152
|
+
readonly inputs: readonly [];
|
|
1153
|
+
}, {
|
|
1154
|
+
readonly name: "MustDepositLowerBalanceToken";
|
|
1155
|
+
readonly type: "error";
|
|
1156
|
+
readonly inputs: readonly [];
|
|
1157
|
+
}, {
|
|
1158
|
+
readonly name: "InvalidAmount";
|
|
1159
|
+
readonly type: "error";
|
|
1160
|
+
readonly inputs: readonly [];
|
|
1161
|
+
}, {
|
|
1162
|
+
readonly name: "InvalidRebalanceState";
|
|
1163
|
+
readonly type: "error";
|
|
1164
|
+
readonly inputs: readonly [];
|
|
1165
|
+
}, {
|
|
1166
|
+
readonly name: "InvalidRebalanceDirection";
|
|
1167
|
+
readonly type: "error";
|
|
1168
|
+
readonly inputs: readonly [];
|
|
1169
|
+
}, {
|
|
1170
|
+
readonly name: "InvalidNewReserves";
|
|
1171
|
+
readonly type: "error";
|
|
1172
|
+
readonly inputs: readonly [];
|
|
1173
|
+
}, {
|
|
1174
|
+
readonly name: "CannotSupportPendingSwaps";
|
|
1175
|
+
readonly type: "error";
|
|
1176
|
+
readonly inputs: readonly [];
|
|
1177
|
+
}, {
|
|
1178
|
+
readonly name: "DivisionByZero";
|
|
1179
|
+
readonly type: "error";
|
|
1180
|
+
readonly inputs: readonly [];
|
|
1181
|
+
}, {
|
|
1182
|
+
readonly name: "InvalidSwapCalculation";
|
|
1183
|
+
readonly type: "error";
|
|
1184
|
+
readonly inputs: readonly [];
|
|
1185
|
+
}, {
|
|
1186
|
+
readonly name: "InsufficientLiquidityForPending";
|
|
1187
|
+
readonly type: "error";
|
|
1188
|
+
readonly inputs: readonly [];
|
|
1189
|
+
}, {
|
|
1190
|
+
readonly name: "TokenTransferFailed";
|
|
1191
|
+
readonly type: "error";
|
|
1192
|
+
readonly inputs: readonly [];
|
|
1193
|
+
}, {
|
|
1194
|
+
readonly name: "InternalError";
|
|
1195
|
+
readonly type: "error";
|
|
1196
|
+
readonly inputs: readonly [];
|
|
1197
|
+
}], "Mint">;
|
|
1198
|
+
}
|
|
188
1199
|
/**
|
|
189
1200
|
* Adds liquidity to a pool.
|
|
190
1201
|
*
|
|
@@ -216,26 +1227,66 @@ export declare namespace getLiquidityBalance {
|
|
|
216
1227
|
*
|
|
217
1228
|
* @param client - Client.
|
|
218
1229
|
* @param parameters - Parameters.
|
|
1230
|
+
* @returns The transaction receipt and event data.
|
|
1231
|
+
*/
|
|
1232
|
+
export declare function mintSync<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: mintSync.Parameters<chain, account>): Promise<mintSync.ReturnValue>;
|
|
1233
|
+
export declare namespace mintSync {
|
|
1234
|
+
type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = mint.Parameters<chain, account>;
|
|
1235
|
+
type Args = mint.Args;
|
|
1236
|
+
type ReturnValue = Compute<GetEventArgs<typeof Abis.feeAmm, 'Mint', {
|
|
1237
|
+
IndexedOnly: false;
|
|
1238
|
+
Required: true;
|
|
1239
|
+
}> & {
|
|
1240
|
+
/** Transaction receipt. */
|
|
1241
|
+
receipt: TransactionReceipt;
|
|
1242
|
+
}>;
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Removes liquidity from a pool.
|
|
1246
|
+
*
|
|
1247
|
+
* @example
|
|
1248
|
+
* ```ts
|
|
1249
|
+
* import { createClient, http } from 'viem'
|
|
1250
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
1251
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
1252
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
1253
|
+
*
|
|
1254
|
+
* const client = createClient({
|
|
1255
|
+
* account: privateKeyToAccount('0x...'),
|
|
1256
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1257
|
+
* transport: http(),
|
|
1258
|
+
* })
|
|
1259
|
+
*
|
|
1260
|
+
* const hash = await Actions.amm.burn(client, {
|
|
1261
|
+
* userToken: '0x20c0...beef',
|
|
1262
|
+
* validatorToken: '0x20c0...babe',
|
|
1263
|
+
* liquidity: 50n,
|
|
1264
|
+
* to: '0xfeed...fede',
|
|
1265
|
+
* })
|
|
1266
|
+
* ```
|
|
1267
|
+
*
|
|
1268
|
+
* @param client - Client.
|
|
1269
|
+
* @param parameters - Parameters.
|
|
219
1270
|
* @returns The transaction hash.
|
|
220
1271
|
*/
|
|
221
|
-
export declare function
|
|
222
|
-
export declare namespace
|
|
1272
|
+
export declare function burn<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: burn.Parameters<chain, account>): Promise<burn.ReturnValue>;
|
|
1273
|
+
export declare namespace burn {
|
|
223
1274
|
type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = WriteParameters<chain, account> & Args;
|
|
224
1275
|
type Args = {
|
|
225
|
-
/**
|
|
1276
|
+
/** Amount of LP tokens to burn. */
|
|
1277
|
+
liquidity: bigint;
|
|
1278
|
+
/** Address to send tokens to. */
|
|
226
1279
|
to: Address;
|
|
227
|
-
/**
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
|
|
231
|
-
/** Amount of validator token to add. */
|
|
232
|
-
validatorTokenAmount: bigint;
|
|
1280
|
+
/** Address or ID of the user token. */
|
|
1281
|
+
userToken: TokenId.TokenIdOrAddress;
|
|
1282
|
+
/** Address or ID of the validator token. */
|
|
1283
|
+
validatorToken: TokenId.TokenIdOrAddress;
|
|
233
1284
|
};
|
|
234
1285
|
type ReturnValue = WriteContractReturnType;
|
|
235
1286
|
/** @internal */
|
|
236
|
-
function inner<action extends typeof writeContract | typeof writeContractSync, chain extends Chain | undefined, account extends Account | undefined>(action: action, client: Client<Transport, chain, account>, parameters:
|
|
1287
|
+
function inner<action extends typeof writeContract | typeof writeContractSync, chain extends Chain | undefined, account extends Account | undefined>(action: action, client: Client<Transport, chain, account>, parameters: burn.Parameters<chain, account>): Promise<ReturnType<action>>;
|
|
237
1288
|
/**
|
|
238
|
-
* Defines a call to the `
|
|
1289
|
+
* Defines a call to the `burn` function.
|
|
239
1290
|
*
|
|
240
1291
|
* Can be passed as a parameter to:
|
|
241
1292
|
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
|
|
@@ -255,27 +1306,17 @@ export declare namespace mint {
|
|
|
255
1306
|
*
|
|
256
1307
|
* const { result } = await client.sendCalls({
|
|
257
1308
|
* calls: [
|
|
258
|
-
* actions.amm.
|
|
259
|
-
*
|
|
260
|
-
* address: '0x20c0...beef',
|
|
261
|
-
* amount: 100n,
|
|
262
|
-
* },
|
|
263
|
-
* validatorToken: {
|
|
264
|
-
* address: '0x20c0...babe',
|
|
265
|
-
* amount: 100n,
|
|
266
|
-
* },
|
|
1309
|
+
* actions.amm.burn.call({
|
|
1310
|
+
* liquidity: 100n,
|
|
267
1311
|
* to: '0xfeed...fede',
|
|
1312
|
+
* userToken: '0x20c0...beef',
|
|
1313
|
+
* validatorToken: '0x20c0...babe',
|
|
268
1314
|
* }),
|
|
269
|
-
* actions.amm.
|
|
270
|
-
*
|
|
271
|
-
* address: '0x20c0...babe',
|
|
272
|
-
* amount: 100n,
|
|
273
|
-
* },
|
|
274
|
-
* validatorToken: {
|
|
275
|
-
* address: '0x20c0...babe',
|
|
276
|
-
* amount: 100n,
|
|
277
|
-
* },
|
|
1315
|
+
* actions.amm.burn.call({
|
|
1316
|
+
* liquidity: 100n,
|
|
278
1317
|
* to: '0xfeed...fede',
|
|
1318
|
+
* userToken: '0x20c0...babe',
|
|
1319
|
+
* validatorToken: '0x20c0...babe',
|
|
279
1320
|
* }),
|
|
280
1321
|
* ]
|
|
281
1322
|
* })
|
|
@@ -286,7 +1327,7 @@ export declare namespace mint {
|
|
|
286
1327
|
*/
|
|
287
1328
|
function call(args: Args): {
|
|
288
1329
|
abi: [{
|
|
289
|
-
readonly name: "
|
|
1330
|
+
readonly name: "burn";
|
|
290
1331
|
readonly type: "function";
|
|
291
1332
|
readonly stateMutability: "nonpayable";
|
|
292
1333
|
readonly inputs: readonly [{
|
|
@@ -297,17 +1338,20 @@ export declare namespace mint {
|
|
|
297
1338
|
readonly name: "validatorToken";
|
|
298
1339
|
}, {
|
|
299
1340
|
readonly type: "uint256";
|
|
300
|
-
readonly name: "
|
|
1341
|
+
readonly name: "liquidity";
|
|
301
1342
|
}, {
|
|
302
1343
|
readonly type: "address";
|
|
303
1344
|
readonly name: "to";
|
|
304
1345
|
}];
|
|
305
1346
|
readonly outputs: readonly [{
|
|
306
1347
|
readonly type: "uint256";
|
|
307
|
-
readonly name: "
|
|
1348
|
+
readonly name: "amountUserToken";
|
|
1349
|
+
}, {
|
|
1350
|
+
readonly type: "uint256";
|
|
1351
|
+
readonly name: "amountValidatorToken";
|
|
308
1352
|
}];
|
|
309
1353
|
}];
|
|
310
|
-
functionName: "
|
|
1354
|
+
functionName: "burn";
|
|
311
1355
|
args?: readonly [`0x${string}`, `0x${string}`, bigint, `0x${string}`] | undefined;
|
|
312
1356
|
} & {
|
|
313
1357
|
args: readonly [`0x${string}`, `0x${string}`, bigint, `0x${string}`];
|
|
@@ -318,10 +1362,10 @@ export declare namespace mint {
|
|
|
318
1362
|
to: Address;
|
|
319
1363
|
};
|
|
320
1364
|
/**
|
|
321
|
-
* Extracts the `
|
|
1365
|
+
* Extracts the `Burn` event from logs.
|
|
322
1366
|
*
|
|
323
1367
|
* @param logs - The logs.
|
|
324
|
-
* @returns The `
|
|
1368
|
+
* @returns The `Burn` event.
|
|
325
1369
|
*/
|
|
326
1370
|
function extractEvent(logs: Log[]): Log<bigint, number, false, undefined, true, readonly [{
|
|
327
1371
|
readonly name: "MIN_LIQUIDITY";
|
|
@@ -676,10 +1720,10 @@ export declare namespace mint {
|
|
|
676
1720
|
readonly name: "InternalError";
|
|
677
1721
|
readonly type: "error";
|
|
678
1722
|
readonly inputs: readonly [];
|
|
679
|
-
}], "
|
|
1723
|
+
}], "Burn">;
|
|
680
1724
|
}
|
|
681
1725
|
/**
|
|
682
|
-
*
|
|
1726
|
+
* Removes liquidity from a pool.
|
|
683
1727
|
*
|
|
684
1728
|
* @example
|
|
685
1729
|
* ```ts
|
|
@@ -694,15 +1738,10 @@ export declare namespace mint {
|
|
|
694
1738
|
* transport: http(),
|
|
695
1739
|
* })
|
|
696
1740
|
*
|
|
697
|
-
* const
|
|
698
|
-
* userToken:
|
|
699
|
-
*
|
|
700
|
-
*
|
|
701
|
-
* },
|
|
702
|
-
* validatorToken: {
|
|
703
|
-
* address: '0x20c0...babe',
|
|
704
|
-
* amount: 100n,
|
|
705
|
-
* },
|
|
1741
|
+
* const result = await Actions.amm.burnSync(client, {
|
|
1742
|
+
* userToken: '0x20c0...beef',
|
|
1743
|
+
* validatorToken: '0x20c0...babe',
|
|
1744
|
+
* liquidity: 50n,
|
|
706
1745
|
* to: '0xfeed...fede',
|
|
707
1746
|
* })
|
|
708
1747
|
* ```
|
|
@@ -711,11 +1750,11 @@ export declare namespace mint {
|
|
|
711
1750
|
* @param parameters - Parameters.
|
|
712
1751
|
* @returns The transaction receipt and event data.
|
|
713
1752
|
*/
|
|
714
|
-
export declare function
|
|
715
|
-
export declare namespace
|
|
716
|
-
type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> =
|
|
717
|
-
type Args =
|
|
718
|
-
type ReturnValue = Compute<GetEventArgs<typeof Abis.feeAmm, '
|
|
1753
|
+
export declare function burnSync<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: burnSync.Parameters<chain, account>): Promise<burnSync.ReturnValue>;
|
|
1754
|
+
export declare namespace burnSync {
|
|
1755
|
+
type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = burn.Parameters<chain, account>;
|
|
1756
|
+
type Args = burn.Args;
|
|
1757
|
+
type ReturnValue = Compute<GetEventArgs<typeof Abis.feeAmm, 'Burn', {
|
|
719
1758
|
IndexedOnly: false;
|
|
720
1759
|
Required: true;
|
|
721
1760
|
}> & {
|
|
@@ -723,6 +1762,88 @@ export declare namespace mintSync {
|
|
|
723
1762
|
receipt: TransactionReceipt;
|
|
724
1763
|
}>;
|
|
725
1764
|
}
|
|
1765
|
+
/**
|
|
1766
|
+
* Watches for rebalance swap events.
|
|
1767
|
+
*
|
|
1768
|
+
* @example
|
|
1769
|
+
* ```ts
|
|
1770
|
+
* import { createClient, http } from 'viem'
|
|
1771
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
1772
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
1773
|
+
*
|
|
1774
|
+
* const client = createClient({
|
|
1775
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1776
|
+
* transport: http(),
|
|
1777
|
+
* })
|
|
1778
|
+
*
|
|
1779
|
+
* const unwatch = actions.amm.watchRebalanceSwap(client, {
|
|
1780
|
+
* onRebalanceSwap: (args, log) => {
|
|
1781
|
+
* console.log('Rebalance swap:', args)
|
|
1782
|
+
* },
|
|
1783
|
+
* })
|
|
1784
|
+
* ```
|
|
1785
|
+
*
|
|
1786
|
+
* @param client - Client.
|
|
1787
|
+
* @param parameters - Parameters.
|
|
1788
|
+
* @returns A function to unsubscribe from the event.
|
|
1789
|
+
*/
|
|
1790
|
+
export declare function watchRebalanceSwap<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: watchRebalanceSwap.Parameters): import("viem").WatchContractEventReturnType;
|
|
1791
|
+
export declare namespace watchRebalanceSwap {
|
|
1792
|
+
type Args = GetEventArgs<typeof Abis.feeAmm, 'RebalanceSwap', {
|
|
1793
|
+
IndexedOnly: false;
|
|
1794
|
+
Required: true;
|
|
1795
|
+
}>;
|
|
1796
|
+
type Log = viem_Log<bigint, number, false, ExtractAbiItem<typeof Abis.feeAmm, 'RebalanceSwap'>, true>;
|
|
1797
|
+
type Parameters = UnionOmit<WatchContractEventParameters<typeof Abis.feeAmm, 'RebalanceSwap', true>, 'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'> & {
|
|
1798
|
+
/** Callback to invoke when a rebalance swap occurs. */
|
|
1799
|
+
onRebalanceSwap: (args: Args, log: Log) => void;
|
|
1800
|
+
/** Address or ID of the user token to filter events. */
|
|
1801
|
+
userToken?: TokenId.TokenIdOrAddress | undefined;
|
|
1802
|
+
/** Address or ID of the validator token to filter events. */
|
|
1803
|
+
validatorToken?: TokenId.TokenIdOrAddress | undefined;
|
|
1804
|
+
};
|
|
1805
|
+
}
|
|
1806
|
+
/**
|
|
1807
|
+
* Watches for fee swap events.
|
|
1808
|
+
*
|
|
1809
|
+
* @example
|
|
1810
|
+
* ```ts
|
|
1811
|
+
* import { createClient, http } from 'viem'
|
|
1812
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
1813
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
1814
|
+
*
|
|
1815
|
+
* const client = createClient({
|
|
1816
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1817
|
+
* transport: http(),
|
|
1818
|
+
* })
|
|
1819
|
+
*
|
|
1820
|
+
* const unwatch = actions.amm.watchFeeSwap(client, {
|
|
1821
|
+
* onFeeSwap: (args, log) => {
|
|
1822
|
+
* console.log('Fee swap:', args)
|
|
1823
|
+
* },
|
|
1824
|
+
* })
|
|
1825
|
+
* ```
|
|
1826
|
+
*
|
|
1827
|
+
* @param client - Client.
|
|
1828
|
+
* @param parameters - Parameters.
|
|
1829
|
+
* @returns A function to unsubscribe from the event.
|
|
1830
|
+
*/
|
|
1831
|
+
export declare function watchFeeSwap<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: watchFeeSwap.Parameters): import("viem").WatchContractEventReturnType;
|
|
1832
|
+
export declare namespace watchFeeSwap {
|
|
1833
|
+
type Args = GetEventArgs<typeof Abis.feeAmm, 'FeeSwap', {
|
|
1834
|
+
IndexedOnly: false;
|
|
1835
|
+
Required: true;
|
|
1836
|
+
}>;
|
|
1837
|
+
type Log = viem_Log<bigint, number, false, ExtractAbiItem<typeof Abis.feeAmm, 'FeeSwap'>, true>;
|
|
1838
|
+
type Parameters = UnionOmit<WatchContractEventParameters<typeof Abis.feeAmm, 'FeeSwap', true>, 'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'> & {
|
|
1839
|
+
/** Callback to invoke when a fee swap occurs. */
|
|
1840
|
+
onFeeSwap: (args: Args, log: Log) => void;
|
|
1841
|
+
/** Address or ID of the user token to filter events. */
|
|
1842
|
+
userToken?: TokenId.TokenIdOrAddress | undefined;
|
|
1843
|
+
/** Address or ID of the validator token to filter events. */
|
|
1844
|
+
validatorToken?: TokenId.TokenIdOrAddress | undefined;
|
|
1845
|
+
};
|
|
1846
|
+
}
|
|
726
1847
|
/**
|
|
727
1848
|
* Watches for liquidity mint events.
|
|
728
1849
|
*
|
|
@@ -774,4 +1895,45 @@ export declare namespace watchMint {
|
|
|
774
1895
|
validatorToken?: TokenId.TokenIdOrAddress | undefined;
|
|
775
1896
|
};
|
|
776
1897
|
}
|
|
1898
|
+
/**
|
|
1899
|
+
* Watches for liquidity burn events.
|
|
1900
|
+
*
|
|
1901
|
+
* @example
|
|
1902
|
+
* ```ts
|
|
1903
|
+
* import { createClient, http } from 'viem'
|
|
1904
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
1905
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
1906
|
+
*
|
|
1907
|
+
* const client = createClient({
|
|
1908
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1909
|
+
* transport: http(),
|
|
1910
|
+
* })
|
|
1911
|
+
*
|
|
1912
|
+
* const unwatch = actions.amm.watchBurn(client, {
|
|
1913
|
+
* onBurn: (args, log) => {
|
|
1914
|
+
* console.log('Liquidity removed:', args)
|
|
1915
|
+
* },
|
|
1916
|
+
* })
|
|
1917
|
+
* ```
|
|
1918
|
+
*
|
|
1919
|
+
* @param client - Client.
|
|
1920
|
+
* @param parameters - Parameters.
|
|
1921
|
+
* @returns A function to unsubscribe from the event.
|
|
1922
|
+
*/
|
|
1923
|
+
export declare function watchBurn<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: watchBurn.Parameters): import("viem").WatchContractEventReturnType;
|
|
1924
|
+
export declare namespace watchBurn {
|
|
1925
|
+
type Args = GetEventArgs<typeof Abis.feeAmm, 'Burn', {
|
|
1926
|
+
IndexedOnly: false;
|
|
1927
|
+
Required: true;
|
|
1928
|
+
}>;
|
|
1929
|
+
type Log = viem_Log<bigint, number, false, ExtractAbiItem<typeof Abis.feeAmm, 'Burn'>, true>;
|
|
1930
|
+
type Parameters = UnionOmit<WatchContractEventParameters<typeof Abis.feeAmm, 'Burn', true>, 'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'> & {
|
|
1931
|
+
/** Callback to invoke when liquidity is removed. */
|
|
1932
|
+
onBurn: (args: Args, log: Log) => void;
|
|
1933
|
+
/** Address or ID of the user token to filter events. */
|
|
1934
|
+
userToken?: TokenId.TokenIdOrAddress | undefined;
|
|
1935
|
+
/** Address or ID of the validator token to filter events. */
|
|
1936
|
+
validatorToken?: TokenId.TokenIdOrAddress | undefined;
|
|
1937
|
+
};
|
|
1938
|
+
}
|
|
777
1939
|
//# sourceMappingURL=amm.d.ts.map
|