tempo.ts 0.1.5 → 0.2.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/README.md +33 -2
- package/dist/chains.d.ts +509 -115
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +20 -9
- package/dist/chains.js.map +1 -1
- package/dist/ox/Order.d.ts +92 -0
- package/dist/ox/Order.d.ts.map +1 -0
- package/dist/ox/Order.js +88 -0
- package/dist/ox/Order.js.map +1 -0
- package/dist/ox/OrdersFilters.d.ts +72 -0
- package/dist/ox/OrdersFilters.d.ts.map +1 -0
- package/dist/ox/OrdersFilters.js +100 -0
- package/dist/ox/OrdersFilters.js.map +1 -0
- package/dist/ox/Pagination.d.ts +128 -0
- package/dist/ox/Pagination.d.ts.map +1 -0
- package/dist/ox/Pagination.js +78 -0
- package/dist/ox/Pagination.js.map +1 -0
- package/dist/ox/PoolId.d.ts +18 -0
- package/dist/ox/PoolId.d.ts.map +1 -0
- package/dist/ox/PoolId.js +13 -0
- package/dist/ox/PoolId.js.map +1 -0
- package/dist/ox/RpcSchema.d.ts +32 -0
- package/dist/ox/RpcSchema.d.ts.map +1 -0
- package/dist/ox/RpcSchema.js +2 -0
- package/dist/ox/RpcSchema.js.map +1 -0
- package/dist/ox/SignatureEnvelope.d.ts +1 -1
- package/dist/ox/SignatureEnvelope.d.ts.map +1 -1
- package/dist/ox/SignatureEnvelope.js.map +1 -1
- package/dist/{viem → ox}/Tick.d.ts +4 -0
- package/dist/ox/Tick.d.ts.map +1 -0
- package/dist/ox/Tick.js.map +1 -0
- package/dist/ox/Transaction.d.ts.map +1 -1
- package/dist/ox/Transaction.js +2 -1
- package/dist/ox/Transaction.js.map +1 -1
- package/dist/ox/TransactionEnvelopeAA.d.ts +6 -6
- package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -1
- package/dist/ox/TransactionEnvelopeAA.js +4 -2
- package/dist/ox/TransactionEnvelopeAA.js.map +1 -1
- package/dist/ox/TransactionRequest.d.ts +4 -0
- package/dist/ox/TransactionRequest.d.ts.map +1 -1
- package/dist/ox/TransactionRequest.js.map +1 -1
- package/dist/ox/index.d.ts +6 -0
- package/dist/ox/index.d.ts.map +1 -1
- package/dist/ox/index.js +6 -0
- package/dist/ox/index.js.map +1 -1
- package/dist/prool/Instance.d.ts.map +1 -1
- package/dist/prool/Instance.js +20 -4
- package/dist/prool/Instance.js.map +1 -1
- package/dist/viem/Abis.d.ts +1469 -1082
- package/dist/viem/Abis.d.ts.map +1 -1
- package/dist/viem/Abis.js +932 -671
- package/dist/viem/Abis.js.map +1 -1
- package/dist/viem/Account.d.ts +150 -0
- package/dist/viem/Account.d.ts.map +1 -0
- package/dist/viem/Account.js +221 -0
- package/dist/viem/Account.js.map +1 -0
- package/dist/viem/Actions/amm.d.ts +144 -161
- package/dist/viem/Actions/amm.d.ts.map +1 -1
- package/dist/viem/Actions/amm.js +109 -163
- package/dist/viem/Actions/amm.js.map +1 -1
- package/dist/viem/Actions/dex.d.ts +920 -664
- package/dist/viem/Actions/dex.d.ts.map +1 -1
- package/dist/viem/Actions/dex.js +129 -30
- package/dist/viem/Actions/dex.js.map +1 -1
- package/dist/viem/Actions/faucet.d.ts +34 -0
- package/dist/viem/Actions/faucet.d.ts.map +1 -0
- package/dist/viem/Actions/faucet.js +33 -0
- package/dist/viem/Actions/faucet.js.map +1 -0
- package/dist/viem/Actions/fee.d.ts +16 -30
- package/dist/viem/Actions/fee.d.ts.map +1 -1
- package/dist/viem/Actions/fee.js +13 -13
- package/dist/viem/Actions/fee.js.map +1 -1
- package/dist/viem/Actions/index.d.ts +2 -0
- package/dist/viem/Actions/index.d.ts.map +1 -1
- package/dist/viem/Actions/index.js +2 -0
- package/dist/viem/Actions/index.js.map +1 -1
- package/dist/viem/Actions/policy.d.ts +46 -46
- package/dist/viem/Actions/policy.js +46 -46
- package/dist/viem/Actions/reward.d.ts +3236 -0
- package/dist/viem/Actions/reward.d.ts.map +1 -0
- package/dist/viem/Actions/reward.js +725 -0
- package/dist/viem/Actions/reward.js.map +1 -0
- package/dist/viem/Actions/token.d.ts +4399 -2750
- package/dist/viem/Actions/token.d.ts.map +1 -1
- package/dist/viem/Actions/token.js +361 -482
- package/dist/viem/Actions/token.js.map +1 -1
- package/dist/viem/Addresses.d.ts +1 -2
- package/dist/viem/Addresses.d.ts.map +1 -1
- package/dist/viem/Addresses.js +1 -2
- package/dist/viem/Addresses.js.map +1 -1
- package/dist/viem/Chain.d.ts +38 -12
- package/dist/viem/Chain.d.ts.map +1 -1
- package/dist/viem/Chain.js +27 -18
- package/dist/viem/Chain.js.map +1 -1
- package/dist/viem/Decorator.d.ts +1009 -428
- package/dist/viem/Decorator.d.ts.map +1 -1
- package/dist/viem/Decorator.js +17 -5
- package/dist/viem/Decorator.js.map +1 -1
- package/dist/viem/Formatters.d.ts +8 -1
- package/dist/viem/Formatters.d.ts.map +1 -1
- package/dist/viem/Formatters.js +17 -0
- package/dist/viem/Formatters.js.map +1 -1
- package/dist/viem/P256.d.ts +2 -0
- package/dist/viem/P256.d.ts.map +1 -0
- package/dist/viem/P256.js +2 -0
- package/dist/viem/P256.js.map +1 -0
- package/dist/viem/Secp256k1.d.ts +2 -0
- package/dist/viem/Secp256k1.d.ts.map +1 -0
- package/dist/viem/Secp256k1.js +2 -0
- package/dist/viem/Secp256k1.js.map +1 -0
- package/dist/viem/TokenIds.d.ts +1 -2
- package/dist/viem/TokenIds.d.ts.map +1 -1
- package/dist/viem/TokenIds.js +1 -2
- package/dist/viem/TokenIds.js.map +1 -1
- package/dist/viem/Transaction.d.ts +1 -1
- package/dist/viem/Transaction.d.ts.map +1 -1
- package/dist/viem/Transaction.js +46 -5
- package/dist/viem/Transaction.js.map +1 -1
- package/dist/viem/WebAuthnP256.d.ts +79 -0
- package/dist/viem/WebAuthnP256.d.ts.map +1 -0
- package/dist/viem/WebAuthnP256.js +95 -0
- package/dist/viem/WebAuthnP256.js.map +1 -0
- package/dist/viem/WebCryptoP256.d.ts +2 -0
- package/dist/viem/WebCryptoP256.d.ts.map +1 -0
- package/dist/viem/WebCryptoP256.js +2 -0
- package/dist/viem/WebCryptoP256.js.map +1 -0
- package/dist/viem/index.d.ts +6 -3
- package/dist/viem/index.d.ts.map +1 -1
- package/dist/viem/index.js +6 -3
- package/dist/viem/index.js.map +1 -1
- package/dist/viem/internal/account.d.ts +24 -0
- package/dist/viem/internal/account.d.ts.map +1 -0
- package/dist/viem/internal/account.js +68 -0
- package/dist/viem/internal/account.js.map +1 -0
- package/dist/viem/internal/types.d.ts +10 -0
- package/dist/viem/internal/types.d.ts.map +1 -1
- package/dist/wagmi/Actions/amm.d.ts +428 -0
- package/dist/wagmi/Actions/amm.d.ts.map +1 -0
- package/dist/wagmi/Actions/amm.js +472 -0
- package/dist/wagmi/Actions/amm.js.map +1 -0
- package/dist/wagmi/Actions/dex.d.ts +908 -0
- package/dist/wagmi/Actions/dex.d.ts.map +1 -0
- package/dist/wagmi/Actions/dex.js +1023 -0
- package/dist/wagmi/Actions/dex.js.map +1 -0
- package/dist/wagmi/Actions/faucet.d.ts +35 -0
- package/dist/wagmi/Actions/faucet.d.ts.map +1 -0
- package/dist/wagmi/Actions/faucet.js +33 -0
- package/dist/wagmi/Actions/faucet.js.map +1 -0
- package/dist/wagmi/Actions/fee.d.ts +111 -0
- package/dist/wagmi/Actions/fee.d.ts.map +1 -0
- package/dist/wagmi/Actions/fee.js +126 -0
- package/dist/wagmi/Actions/fee.js.map +1 -0
- package/dist/wagmi/Actions/index.d.ts +7 -0
- package/dist/wagmi/Actions/index.d.ts.map +1 -0
- package/dist/wagmi/Actions/index.js +7 -0
- package/dist/wagmi/Actions/index.js.map +1 -0
- package/dist/wagmi/Actions/reward.d.ts +348 -0
- package/dist/wagmi/Actions/reward.d.ts.map +1 -0
- package/dist/wagmi/Actions/reward.js +388 -0
- package/dist/wagmi/Actions/reward.js.map +1 -0
- package/dist/wagmi/Actions/token.d.ts +1546 -0
- package/dist/wagmi/Actions/token.d.ts.map +1 -0
- package/dist/wagmi/Actions/token.js +1712 -0
- package/dist/wagmi/Actions/token.js.map +1 -0
- package/dist/wagmi/Connector.d.ts +81 -0
- package/dist/wagmi/Connector.d.ts.map +1 -0
- package/dist/wagmi/Connector.js +261 -0
- package/dist/wagmi/Connector.js.map +1 -0
- package/dist/wagmi/Hooks/amm.d.ts +421 -0
- package/dist/wagmi/Hooks/amm.d.ts.map +1 -0
- package/dist/wagmi/Hooks/amm.js +504 -0
- package/dist/wagmi/Hooks/amm.js.map +1 -0
- package/dist/wagmi/Hooks/dex.d.ts +816 -0
- package/dist/wagmi/Hooks/dex.d.ts.map +1 -0
- package/dist/wagmi/Hooks/dex.js +973 -0
- package/dist/wagmi/Hooks/dex.js.map +1 -0
- package/dist/wagmi/Hooks/faucet.d.ts +39 -0
- package/dist/wagmi/Hooks/faucet.d.ts.map +1 -0
- package/dist/wagmi/Hooks/faucet.js +40 -0
- package/dist/wagmi/Hooks/faucet.js.map +1 -0
- package/dist/wagmi/Hooks/fee.d.ts +97 -0
- package/dist/wagmi/Hooks/fee.d.ts.map +1 -0
- package/dist/wagmi/Hooks/fee.js +109 -0
- package/dist/wagmi/Hooks/fee.js.map +1 -0
- package/dist/wagmi/Hooks/index.d.ts +7 -0
- package/dist/wagmi/Hooks/index.d.ts.map +1 -0
- package/dist/wagmi/Hooks/index.js +7 -0
- package/dist/wagmi/Hooks/index.js.map +1 -0
- package/dist/wagmi/Hooks/reward.d.ts +307 -0
- package/dist/wagmi/Hooks/reward.d.ts.map +1 -0
- package/dist/wagmi/Hooks/reward.js +349 -0
- package/dist/wagmi/Hooks/reward.js.map +1 -0
- package/dist/wagmi/Hooks/token.d.ts +1388 -0
- package/dist/wagmi/Hooks/token.d.ts.map +1 -0
- package/dist/wagmi/Hooks/token.js +1657 -0
- package/dist/wagmi/Hooks/token.js.map +1 -0
- package/dist/wagmi/index.d.ts +4 -0
- package/dist/wagmi/index.d.ts.map +1 -0
- package/dist/wagmi/index.js +4 -0
- package/dist/wagmi/index.js.map +1 -0
- package/package.json +54 -10
- package/src/chains.ts +21 -9
- package/src/ox/Order.test.ts +78 -0
- package/src/ox/Order.ts +125 -0
- package/src/ox/OrdersFilters.test.ts +182 -0
- package/src/ox/OrdersFilters.ts +125 -0
- package/src/ox/Pagination.test.ts +162 -0
- package/src/ox/Pagination.ts +164 -0
- package/src/ox/PoolId.test.ts +33 -0
- package/src/ox/PoolId.ts +27 -0
- package/src/ox/RpcSchema.ts +35 -0
- package/src/ox/SignatureEnvelope.ts +3 -1
- package/src/{viem → ox}/Tick.test.ts +1 -1
- package/src/{viem → ox}/Tick.ts +5 -0
- package/src/ox/Transaction.test.ts +1 -1
- package/src/ox/Transaction.ts +2 -1
- package/src/ox/TransactionEnvelopeAA.test.ts +239 -96
- package/src/ox/TransactionEnvelopeAA.ts +9 -7
- package/src/ox/TransactionRequest.ts +4 -0
- package/src/ox/index.ts +6 -0
- package/src/prool/Instance.ts +51 -37
- package/src/prool/internal/chain.json +104 -52
- package/src/tsconfig.json +9 -0
- package/src/viem/Abis.ts +972 -710
- package/src/viem/Account.ts +279 -0
- package/src/viem/Actions/__snapshots__/dex.test.ts.snap +850 -0
- package/src/viem/Actions/amm.test.ts +173 -169
- package/src/viem/Actions/amm.ts +131 -203
- package/src/viem/Actions/dex.test.ts +563 -484
- package/src/viem/Actions/dex.ts +203 -30
- package/src/viem/Actions/faucet.ts +50 -0
- package/src/viem/Actions/fee.test.ts +23 -34
- package/src/viem/Actions/fee.ts +20 -13
- package/src/viem/Actions/index.ts +2 -0
- package/src/viem/Actions/policy.test.ts +19 -33
- package/src/viem/Actions/policy.ts +46 -46
- package/src/viem/Actions/reward.test.ts +457 -0
- package/src/viem/Actions/reward.ts +999 -0
- package/src/viem/Actions/token.test.ts +453 -287
- package/src/viem/Actions/token.ts +605 -693
- package/src/viem/Addresses.ts +1 -2
- package/src/viem/Chain.bench-d.ts +12 -0
- package/src/viem/Chain.ts +70 -20
- package/src/viem/Decorator.bench-d.ts +1 -1
- package/src/viem/Decorator.test.ts +3 -1
- package/src/viem/Decorator.ts +1049 -442
- package/src/viem/Formatters.ts +31 -5
- package/src/viem/P256.ts +1 -0
- package/src/viem/Secp256k1.ts +1 -0
- package/src/viem/TokenIds.ts +1 -2
- package/src/viem/Transaction.ts +53 -7
- package/src/viem/WebAuthnP256.ts +140 -0
- package/src/viem/WebCryptoP256.ts +1 -0
- package/src/viem/e2e.test.ts +1126 -297
- package/src/viem/index.ts +6 -3
- package/src/viem/internal/account.ts +107 -0
- package/src/viem/internal/types.ts +9 -0
- package/src/wagmi/Actions/__snapshots__/dex.test.ts.snap +310 -0
- package/src/wagmi/Actions/amm.test.ts +198 -0
- package/src/wagmi/Actions/amm.ts +691 -0
- package/src/wagmi/Actions/dex.test.ts +1507 -0
- package/src/wagmi/Actions/dex.ts +1640 -0
- package/src/wagmi/Actions/faucet.ts +46 -0
- package/src/wagmi/Actions/fee.test.ts +63 -0
- package/src/wagmi/Actions/fee.ts +208 -0
- package/src/wagmi/Actions/index.ts +6 -0
- package/src/wagmi/Actions/reward.test.ts +210 -0
- package/src/wagmi/Actions/reward.ts +632 -0
- package/src/wagmi/Actions/token.test.ts +1308 -0
- package/src/wagmi/Actions/token.ts +2613 -0
- package/src/wagmi/Connector.test.ts +53 -0
- package/src/wagmi/Connector.ts +390 -0
- package/src/wagmi/Hooks/__snapshots__/dex.test.ts.snap +457 -0
- package/src/wagmi/Hooks/amm.test.ts +424 -0
- package/src/wagmi/Hooks/amm.ts +806 -0
- package/src/wagmi/Hooks/dex.test.ts +1017 -0
- package/src/wagmi/Hooks/dex.ts +1685 -0
- package/src/wagmi/Hooks/faucet.ts +76 -0
- package/src/wagmi/Hooks/fee.test.ts +166 -0
- package/src/wagmi/Hooks/fee.ts +206 -0
- package/src/wagmi/Hooks/index.ts +6 -0
- package/src/wagmi/Hooks/reward.test.ts +219 -0
- package/src/wagmi/Hooks/reward.ts +672 -0
- package/src/wagmi/Hooks/token.test.ts +1670 -0
- package/src/wagmi/Hooks/token.ts +2906 -0
- package/src/wagmi/index.ts +3 -0
- package/src/wagmi/internal/types.ts +16 -0
- package/dist/viem/Client.d.ts +0 -27
- package/dist/viem/Client.d.ts.map +0 -1
- package/dist/viem/Client.js +0 -28
- package/dist/viem/Client.js.map +0 -1
- package/dist/viem/Tick.d.ts.map +0 -1
- package/dist/viem/Tick.js.map +0 -1
- package/src/viem/Client.bench-d.ts +0 -8
- package/src/viem/Client.test.ts +0 -178
- package/src/viem/Client.ts +0 -91
- /package/dist/{viem → ox}/Tick.js +0 -0
package/src/viem/Actions/amm.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type GetEventArgs,
|
|
8
8
|
type Hex,
|
|
9
9
|
type Log,
|
|
10
|
+
type MulticallParameters,
|
|
10
11
|
parseEventLogs,
|
|
11
12
|
type ReadContractReturnType,
|
|
12
13
|
type TransactionReceipt,
|
|
@@ -16,86 +17,20 @@ import {
|
|
|
16
17
|
type WriteContractReturnType,
|
|
17
18
|
} from 'viem'
|
|
18
19
|
import {
|
|
20
|
+
multicall,
|
|
19
21
|
readContract,
|
|
20
22
|
watchContractEvent,
|
|
21
23
|
writeContract,
|
|
22
24
|
writeContractSync,
|
|
23
25
|
} from 'viem/actions'
|
|
24
|
-
import type { Compute, UnionOmit } from '../../internal/types.js'
|
|
26
|
+
import type { Compute, OneOf, UnionOmit } from '../../internal/types.js'
|
|
27
|
+
import * as PoolId from '../../ox/PoolId.js'
|
|
25
28
|
import * as TokenId from '../../ox/TokenId.js'
|
|
26
29
|
import * as Abis from '../Abis.js'
|
|
27
30
|
import * as Addresses from '../Addresses.js'
|
|
28
31
|
import type { ReadParameters, WriteParameters } from '../internal/types.js'
|
|
29
32
|
import { defineCall } from '../internal/utils.js'
|
|
30
33
|
|
|
31
|
-
/**
|
|
32
|
-
* Gets the pool ID for a token pair.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* import { createClient, http } from 'viem'
|
|
37
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
38
|
-
* import * as actions from 'tempo.ts/viem/actions'
|
|
39
|
-
*
|
|
40
|
-
* const client = createClient({
|
|
41
|
-
* chain: tempo,
|
|
42
|
-
* transport: http(),
|
|
43
|
-
* })
|
|
44
|
-
*
|
|
45
|
-
* const poolId = await actions.amm.getPoolId(client, {
|
|
46
|
-
* userToken: '0x...',
|
|
47
|
-
* validatorToken: '0x...',
|
|
48
|
-
* })
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* @param client - Client.
|
|
52
|
-
* @param parameters - Parameters.
|
|
53
|
-
* @returns The pool ID.
|
|
54
|
-
*/
|
|
55
|
-
export async function getPoolId<chain extends Chain | undefined>(
|
|
56
|
-
client: Client<Transport, chain>,
|
|
57
|
-
parameters: getPoolId.Parameters,
|
|
58
|
-
): Promise<getPoolId.ReturnValue> {
|
|
59
|
-
const { userToken, validatorToken, ...rest } = parameters
|
|
60
|
-
return readContract(client, {
|
|
61
|
-
...rest,
|
|
62
|
-
...getPoolId.call({ userToken, validatorToken }),
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export namespace getPoolId {
|
|
67
|
-
export type Parameters = ReadParameters & Args
|
|
68
|
-
|
|
69
|
-
export type Args = {
|
|
70
|
-
/** Address or ID of the user token. */
|
|
71
|
-
userToken: TokenId.TokenIdOrAddress
|
|
72
|
-
/** Address or ID of the validator token. */
|
|
73
|
-
validatorToken: TokenId.TokenIdOrAddress
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export type ReturnValue = ReadContractReturnType<
|
|
77
|
-
typeof Abis.feeAmm,
|
|
78
|
-
'getPoolId',
|
|
79
|
-
never
|
|
80
|
-
>
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Defines a call to the `getPoolId` function.
|
|
84
|
-
*
|
|
85
|
-
* @param args - Arguments.
|
|
86
|
-
* @returns The call.
|
|
87
|
-
*/
|
|
88
|
-
export function call(args: Args) {
|
|
89
|
-
const { userToken, validatorToken } = args
|
|
90
|
-
return defineCall({
|
|
91
|
-
address: Addresses.feeManager,
|
|
92
|
-
abi: Abis.feeAmm,
|
|
93
|
-
args: [TokenId.toAddress(userToken), TokenId.toAddress(validatorToken)],
|
|
94
|
-
functionName: 'getPoolId',
|
|
95
|
-
})
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
34
|
/**
|
|
100
35
|
* Gets the reserves for a liquidity pool.
|
|
101
36
|
*
|
|
@@ -103,14 +38,14 @@ export namespace getPoolId {
|
|
|
103
38
|
* ```ts
|
|
104
39
|
* import { createClient, http } from 'viem'
|
|
105
40
|
* import { tempo } from 'tempo.ts/chains'
|
|
106
|
-
* import
|
|
41
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
107
42
|
*
|
|
108
43
|
* const client = createClient({
|
|
109
|
-
* chain: tempo
|
|
44
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
110
45
|
* transport: http(),
|
|
111
46
|
* })
|
|
112
47
|
*
|
|
113
|
-
* const pool = await
|
|
48
|
+
* const pool = await Actions.amm.getPool(client, {
|
|
114
49
|
* userToken: '0x...',
|
|
115
50
|
* validatorToken: '0x...',
|
|
116
51
|
* })
|
|
@@ -125,14 +60,25 @@ export async function getPool<chain extends Chain | undefined>(
|
|
|
125
60
|
parameters: getPool.Parameters,
|
|
126
61
|
): Promise<getPool.ReturnValue> {
|
|
127
62
|
const { userToken, validatorToken, ...rest } = parameters
|
|
128
|
-
|
|
63
|
+
const [pool, totalSupply] = await multicall(client, {
|
|
129
64
|
...rest,
|
|
130
|
-
|
|
65
|
+
contracts: getPool.calls({ userToken, validatorToken }),
|
|
66
|
+
allowFailure: false,
|
|
67
|
+
deployless: true,
|
|
131
68
|
})
|
|
69
|
+
return {
|
|
70
|
+
reserveUserToken: pool.reserveUserToken,
|
|
71
|
+
reserveValidatorToken: pool.reserveValidatorToken,
|
|
72
|
+
totalSupply,
|
|
73
|
+
}
|
|
132
74
|
}
|
|
133
75
|
|
|
134
76
|
export namespace getPool {
|
|
135
|
-
export type Parameters =
|
|
77
|
+
export type Parameters = UnionOmit<
|
|
78
|
+
MulticallParameters,
|
|
79
|
+
'allowFailure' | 'contracts' | 'deployless'
|
|
80
|
+
> &
|
|
81
|
+
Args
|
|
136
82
|
|
|
137
83
|
export type Args = {
|
|
138
84
|
/** Address or ID of the user token. */
|
|
@@ -146,90 +92,32 @@ export namespace getPool {
|
|
|
146
92
|
reserveUserToken: bigint
|
|
147
93
|
/** Reserve of validator token. */
|
|
148
94
|
reserveValidatorToken: bigint
|
|
95
|
+
/** Total supply of LP tokens. */
|
|
96
|
+
totalSupply: bigint
|
|
149
97
|
}>
|
|
150
98
|
|
|
151
99
|
/**
|
|
152
|
-
* Defines
|
|
100
|
+
* Defines calls to the `getPool` and `totalSupply` functions.
|
|
153
101
|
*
|
|
154
102
|
* @param args - Arguments.
|
|
155
|
-
* @returns The
|
|
103
|
+
* @returns The calls.
|
|
156
104
|
*/
|
|
157
|
-
export function
|
|
105
|
+
export function calls(args: Args) {
|
|
158
106
|
const { userToken, validatorToken } = args
|
|
159
|
-
return
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
* import { createClient, http } from 'viem'
|
|
174
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
175
|
-
* import * as actions from 'tempo.ts/viem/actions'
|
|
176
|
-
*
|
|
177
|
-
* const client = createClient({
|
|
178
|
-
* chain: tempo,
|
|
179
|
-
* transport: http(),
|
|
180
|
-
* })
|
|
181
|
-
*
|
|
182
|
-
* const poolId = await actions.amm.getPoolId(client, {
|
|
183
|
-
* userToken: '0x...',
|
|
184
|
-
* validatorToken: '0x...',
|
|
185
|
-
* })
|
|
186
|
-
*
|
|
187
|
-
* const totalSupply = await actions.amm.getTotalSupply(client, { poolId })
|
|
188
|
-
* ```
|
|
189
|
-
*
|
|
190
|
-
* @param client - Client.
|
|
191
|
-
* @param parameters - Parameters.
|
|
192
|
-
* @returns The total supply of LP tokens.
|
|
193
|
-
*/
|
|
194
|
-
export async function getTotalSupply<chain extends Chain | undefined>(
|
|
195
|
-
client: Client<Transport, chain>,
|
|
196
|
-
parameters: getTotalSupply.Parameters,
|
|
197
|
-
): Promise<getTotalSupply.ReturnValue> {
|
|
198
|
-
const { poolId, ...rest } = parameters
|
|
199
|
-
return readContract(client, {
|
|
200
|
-
...rest,
|
|
201
|
-
...getTotalSupply.call({ poolId }),
|
|
202
|
-
})
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export namespace getTotalSupply {
|
|
206
|
-
export type Parameters = ReadParameters & Args
|
|
207
|
-
|
|
208
|
-
export type Args = {
|
|
209
|
-
/** Pool ID. */
|
|
210
|
-
poolId: Hex
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export type ReturnValue = ReadContractReturnType<
|
|
214
|
-
typeof Abis.feeAmm,
|
|
215
|
-
'totalSupply',
|
|
216
|
-
never
|
|
217
|
-
>
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Defines a call to the `totalSupply` function.
|
|
221
|
-
*
|
|
222
|
-
* @param args - Arguments.
|
|
223
|
-
* @returns The call.
|
|
224
|
-
*/
|
|
225
|
-
export function call(args: Args) {
|
|
226
|
-
const { poolId } = args
|
|
227
|
-
return defineCall({
|
|
228
|
-
address: Addresses.feeManager,
|
|
229
|
-
abi: Abis.feeAmm,
|
|
230
|
-
args: [poolId],
|
|
231
|
-
functionName: 'totalSupply',
|
|
232
|
-
})
|
|
107
|
+
return [
|
|
108
|
+
defineCall({
|
|
109
|
+
address: Addresses.feeManager,
|
|
110
|
+
abi: Abis.feeAmm,
|
|
111
|
+
args: [TokenId.toAddress(userToken), TokenId.toAddress(validatorToken)],
|
|
112
|
+
functionName: 'getPool',
|
|
113
|
+
}),
|
|
114
|
+
defineCall({
|
|
115
|
+
address: Addresses.feeManager,
|
|
116
|
+
abi: Abis.feeAmm,
|
|
117
|
+
args: [PoolId.from({ userToken, validatorToken })],
|
|
118
|
+
functionName: 'totalSupply',
|
|
119
|
+
}),
|
|
120
|
+
] as const
|
|
233
121
|
}
|
|
234
122
|
}
|
|
235
123
|
|
|
@@ -240,19 +128,19 @@ export namespace getTotalSupply {
|
|
|
240
128
|
* ```ts
|
|
241
129
|
* import { createClient, http } from 'viem'
|
|
242
130
|
* import { tempo } from 'tempo.ts/chains'
|
|
243
|
-
* import
|
|
131
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
244
132
|
*
|
|
245
133
|
* const client = createClient({
|
|
246
|
-
* chain: tempo
|
|
134
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
247
135
|
* transport: http(),
|
|
248
136
|
* })
|
|
249
137
|
*
|
|
250
|
-
* const poolId = await
|
|
138
|
+
* const poolId = await Actions.amm.getPoolId(client, {
|
|
251
139
|
* userToken: '0x...',
|
|
252
140
|
* validatorToken: '0x...',
|
|
253
141
|
* })
|
|
254
142
|
*
|
|
255
|
-
* const balance = await
|
|
143
|
+
* const balance = await Actions.amm.getLiquidityBalance(client, {
|
|
256
144
|
* poolId,
|
|
257
145
|
* address: '0x...',
|
|
258
146
|
* })
|
|
@@ -266,10 +154,15 @@ export async function getLiquidityBalance<chain extends Chain | undefined>(
|
|
|
266
154
|
client: Client<Transport, chain>,
|
|
267
155
|
parameters: getLiquidityBalance.Parameters,
|
|
268
156
|
): Promise<getLiquidityBalance.ReturnValue> {
|
|
269
|
-
const { address, poolId, ...rest } = parameters
|
|
157
|
+
const { address, poolId, userToken, validatorToken, ...rest } = parameters
|
|
270
158
|
return readContract(client, {
|
|
271
159
|
...rest,
|
|
272
|
-
...getLiquidityBalance.call({
|
|
160
|
+
...getLiquidityBalance.call({
|
|
161
|
+
address,
|
|
162
|
+
poolId,
|
|
163
|
+
userToken,
|
|
164
|
+
validatorToken,
|
|
165
|
+
} as never),
|
|
273
166
|
})
|
|
274
167
|
}
|
|
275
168
|
|
|
@@ -279,9 +172,18 @@ export namespace getLiquidityBalance {
|
|
|
279
172
|
export type Args = {
|
|
280
173
|
/** Address to check balance for. */
|
|
281
174
|
address: Address
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
175
|
+
} & OneOf<
|
|
176
|
+
| {
|
|
177
|
+
/** Pool ID. */
|
|
178
|
+
poolId: Hex
|
|
179
|
+
}
|
|
180
|
+
| {
|
|
181
|
+
/** User token. */
|
|
182
|
+
userToken: TokenId.TokenIdOrAddress
|
|
183
|
+
/** Validator token. */
|
|
184
|
+
validatorToken: TokenId.TokenIdOrAddress
|
|
185
|
+
}
|
|
186
|
+
>
|
|
285
187
|
|
|
286
188
|
export type ReturnValue = ReadContractReturnType<
|
|
287
189
|
typeof Abis.feeAmm,
|
|
@@ -296,7 +198,18 @@ export namespace getLiquidityBalance {
|
|
|
296
198
|
* @returns The call.
|
|
297
199
|
*/
|
|
298
200
|
export function call(args: Args) {
|
|
299
|
-
const { address
|
|
201
|
+
const { address } = args
|
|
202
|
+
const poolId = (() => {
|
|
203
|
+
if ('poolId' in args && args.poolId) return args.poolId!
|
|
204
|
+
if ('userToken' in args && 'validatorToken' in args)
|
|
205
|
+
return PoolId.from({
|
|
206
|
+
userToken: args.userToken,
|
|
207
|
+
validatorToken: args.validatorToken,
|
|
208
|
+
})
|
|
209
|
+
throw new Error(
|
|
210
|
+
'`poolId`, or `userToken` and `validatorToken` must be provided.',
|
|
211
|
+
)
|
|
212
|
+
})()
|
|
300
213
|
return defineCall({
|
|
301
214
|
address: Addresses.feeManager,
|
|
302
215
|
abi: Abis.feeAmm,
|
|
@@ -313,16 +226,16 @@ export namespace getLiquidityBalance {
|
|
|
313
226
|
* ```ts
|
|
314
227
|
* import { createClient, http } from 'viem'
|
|
315
228
|
* import { tempo } from 'tempo.ts/chains'
|
|
316
|
-
* import
|
|
229
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
317
230
|
* import { privateKeyToAccount } from 'viem/accounts'
|
|
318
231
|
*
|
|
319
232
|
* const client = createClient({
|
|
320
233
|
* account: privateKeyToAccount('0x...'),
|
|
321
|
-
* chain: tempo
|
|
234
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
322
235
|
* transport: http(),
|
|
323
236
|
* })
|
|
324
237
|
*
|
|
325
|
-
* const hash = await
|
|
238
|
+
* const hash = await Actions.amm.rebalanceSwap(client, {
|
|
326
239
|
* userToken: '0x...',
|
|
327
240
|
* validatorToken: '0x...',
|
|
328
241
|
* amountOut: 100n,
|
|
@@ -398,10 +311,10 @@ export namespace rebalanceSwap {
|
|
|
398
311
|
* ```ts
|
|
399
312
|
* import { createClient, http, walletActions } from 'viem'
|
|
400
313
|
* import { tempo } from 'tempo.ts/chains'
|
|
401
|
-
* import
|
|
314
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
402
315
|
*
|
|
403
316
|
* const client = createClient({
|
|
404
|
-
* chain: tempo
|
|
317
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
405
318
|
* transport: http(),
|
|
406
319
|
* }).extend(walletActions)
|
|
407
320
|
*
|
|
@@ -466,16 +379,16 @@ export namespace rebalanceSwap {
|
|
|
466
379
|
* ```ts
|
|
467
380
|
* import { createClient, http } from 'viem'
|
|
468
381
|
* import { tempo } from 'tempo.ts/chains'
|
|
469
|
-
* import
|
|
382
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
470
383
|
* import { privateKeyToAccount } from 'viem/accounts'
|
|
471
384
|
*
|
|
472
385
|
* const client = createClient({
|
|
473
386
|
* account: privateKeyToAccount('0x...'),
|
|
474
|
-
* chain: tempo
|
|
387
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
475
388
|
* transport: http(),
|
|
476
389
|
* })
|
|
477
390
|
*
|
|
478
|
-
* const result = await
|
|
391
|
+
* const result = await Actions.amm.rebalanceSwapSync(client, {
|
|
479
392
|
* userToken: '0x...',
|
|
480
393
|
* validatorToken: '0x...',
|
|
481
394
|
* amountOut: 100n,
|
|
@@ -533,16 +446,16 @@ export namespace rebalanceSwapSync {
|
|
|
533
446
|
* ```ts
|
|
534
447
|
* import { createClient, http } from 'viem'
|
|
535
448
|
* import { tempo } from 'tempo.ts/chains'
|
|
536
|
-
* import
|
|
449
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
537
450
|
* import { privateKeyToAccount } from 'viem/accounts'
|
|
538
451
|
*
|
|
539
452
|
* const client = createClient({
|
|
540
453
|
* account: privateKeyToAccount('0x...'),
|
|
541
|
-
* chain: tempo
|
|
454
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
542
455
|
* transport: http(),
|
|
543
456
|
* })
|
|
544
457
|
*
|
|
545
|
-
* const hash = await
|
|
458
|
+
* const hash = await Actions.amm.mint(client, {
|
|
546
459
|
* userToken: {
|
|
547
460
|
* address: '0x20c0...beef',
|
|
548
461
|
* amount: 100n,
|
|
@@ -583,7 +496,7 @@ export namespace mint {
|
|
|
583
496
|
/** Address or ID of the user token. */
|
|
584
497
|
address: TokenId.TokenIdOrAddress
|
|
585
498
|
/** Amount of user token to add. */
|
|
586
|
-
amount
|
|
499
|
+
amount?: bigint | undefined
|
|
587
500
|
}
|
|
588
501
|
/** Validator token address and amount. */
|
|
589
502
|
validatorToken: {
|
|
@@ -626,10 +539,10 @@ export namespace mint {
|
|
|
626
539
|
* ```ts
|
|
627
540
|
* import { createClient, http, walletActions } from 'viem'
|
|
628
541
|
* import { tempo } from 'tempo.ts/chains'
|
|
629
|
-
* import
|
|
542
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
630
543
|
*
|
|
631
544
|
* const client = createClient({
|
|
632
|
-
* chain: tempo
|
|
545
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
633
546
|
* transport: http(),
|
|
634
547
|
* }).extend(walletActions)
|
|
635
548
|
*
|
|
@@ -666,17 +579,32 @@ export namespace mint {
|
|
|
666
579
|
*/
|
|
667
580
|
export function call(args: Args) {
|
|
668
581
|
const { to, userToken, validatorToken } = args
|
|
582
|
+
const callArgs = (() => {
|
|
583
|
+
if (userToken.amount)
|
|
584
|
+
return {
|
|
585
|
+
functionName: 'mint',
|
|
586
|
+
args: [
|
|
587
|
+
TokenId.toAddress(userToken.address),
|
|
588
|
+
TokenId.toAddress(validatorToken.address),
|
|
589
|
+
userToken.amount,
|
|
590
|
+
validatorToken.amount,
|
|
591
|
+
to,
|
|
592
|
+
],
|
|
593
|
+
} as const
|
|
594
|
+
return {
|
|
595
|
+
functionName: 'mintWithValidatorToken',
|
|
596
|
+
args: [
|
|
597
|
+
TokenId.toAddress(userToken.address),
|
|
598
|
+
TokenId.toAddress(validatorToken.address),
|
|
599
|
+
validatorToken.amount,
|
|
600
|
+
to,
|
|
601
|
+
],
|
|
602
|
+
} as const
|
|
603
|
+
})()
|
|
669
604
|
return defineCall({
|
|
670
605
|
address: Addresses.feeManager,
|
|
671
606
|
abi: Abis.feeAmm,
|
|
672
|
-
|
|
673
|
-
args: [
|
|
674
|
-
TokenId.toAddress(userToken.address),
|
|
675
|
-
TokenId.toAddress(validatorToken.address),
|
|
676
|
-
userToken.amount,
|
|
677
|
-
validatorToken.amount,
|
|
678
|
-
to,
|
|
679
|
-
],
|
|
607
|
+
...callArgs,
|
|
680
608
|
})
|
|
681
609
|
}
|
|
682
610
|
|
|
@@ -705,16 +633,16 @@ export namespace mint {
|
|
|
705
633
|
* ```ts
|
|
706
634
|
* import { createClient, http } from 'viem'
|
|
707
635
|
* import { tempo } from 'tempo.ts/chains'
|
|
708
|
-
* import
|
|
636
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
709
637
|
* import { privateKeyToAccount } from 'viem/accounts'
|
|
710
638
|
*
|
|
711
639
|
* const client = createClient({
|
|
712
640
|
* account: privateKeyToAccount('0x...'),
|
|
713
|
-
* chain: tempo
|
|
641
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
714
642
|
* transport: http(),
|
|
715
643
|
* })
|
|
716
644
|
*
|
|
717
|
-
* const hash = await
|
|
645
|
+
* const hash = await Actions.amm.mint(client, {
|
|
718
646
|
* userToken: {
|
|
719
647
|
* address: '0x20c0...beef',
|
|
720
648
|
* amount: 100n,
|
|
@@ -777,16 +705,16 @@ export namespace mintSync {
|
|
|
777
705
|
* ```ts
|
|
778
706
|
* import { createClient, http } from 'viem'
|
|
779
707
|
* import { tempo } from 'tempo.ts/chains'
|
|
780
|
-
* import
|
|
708
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
781
709
|
* import { privateKeyToAccount } from 'viem/accounts'
|
|
782
710
|
*
|
|
783
711
|
* const client = createClient({
|
|
784
712
|
* account: privateKeyToAccount('0x...'),
|
|
785
|
-
* chain: tempo
|
|
713
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
786
714
|
* transport: http(),
|
|
787
715
|
* })
|
|
788
716
|
*
|
|
789
|
-
* const hash = await
|
|
717
|
+
* const hash = await Actions.amm.burn(client, {
|
|
790
718
|
* userToken: '0x20c0...beef',
|
|
791
719
|
* validatorToken: '0x20c0...babe',
|
|
792
720
|
* liquidity: 50n,
|
|
@@ -857,10 +785,10 @@ export namespace burn {
|
|
|
857
785
|
* ```ts
|
|
858
786
|
* import { createClient, http, walletActions } from 'viem'
|
|
859
787
|
* import { tempo } from 'tempo.ts/chains'
|
|
860
|
-
* import
|
|
788
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
861
789
|
*
|
|
862
790
|
* const client = createClient({
|
|
863
|
-
* chain: tempo
|
|
791
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
864
792
|
* transport: http(),
|
|
865
793
|
* }).extend(walletActions)
|
|
866
794
|
*
|
|
@@ -925,16 +853,16 @@ export namespace burn {
|
|
|
925
853
|
* ```ts
|
|
926
854
|
* import { createClient, http } from 'viem'
|
|
927
855
|
* import { tempo } from 'tempo.ts/chains'
|
|
928
|
-
* import
|
|
856
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
929
857
|
* import { privateKeyToAccount } from 'viem/accounts'
|
|
930
858
|
*
|
|
931
859
|
* const client = createClient({
|
|
932
860
|
* account: privateKeyToAccount('0x...'),
|
|
933
|
-
* chain: tempo
|
|
861
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
934
862
|
* transport: http(),
|
|
935
863
|
* })
|
|
936
864
|
*
|
|
937
|
-
* const result = await
|
|
865
|
+
* const result = await Actions.amm.burnSync(client, {
|
|
938
866
|
* userToken: '0x20c0...beef',
|
|
939
867
|
* validatorToken: '0x20c0...babe',
|
|
940
868
|
* liquidity: 50n,
|
|
@@ -992,10 +920,10 @@ export namespace burnSync {
|
|
|
992
920
|
* ```ts
|
|
993
921
|
* import { createClient, http } from 'viem'
|
|
994
922
|
* import { tempo } from 'tempo.ts/chains'
|
|
995
|
-
* import
|
|
923
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
996
924
|
*
|
|
997
925
|
* const client = createClient({
|
|
998
|
-
* chain: tempo
|
|
926
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
999
927
|
* transport: http(),
|
|
1000
928
|
* })
|
|
1001
929
|
*
|
|
@@ -1072,10 +1000,10 @@ export declare namespace watchRebalanceSwap {
|
|
|
1072
1000
|
* ```ts
|
|
1073
1001
|
* import { createClient, http } from 'viem'
|
|
1074
1002
|
* import { tempo } from 'tempo.ts/chains'
|
|
1075
|
-
* import
|
|
1003
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
1076
1004
|
*
|
|
1077
1005
|
* const client = createClient({
|
|
1078
|
-
* chain: tempo
|
|
1006
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1079
1007
|
* transport: http(),
|
|
1080
1008
|
* })
|
|
1081
1009
|
*
|
|
@@ -1152,10 +1080,10 @@ export declare namespace watchFeeSwap {
|
|
|
1152
1080
|
* ```ts
|
|
1153
1081
|
* import { createClient, http } from 'viem'
|
|
1154
1082
|
* import { tempo } from 'tempo.ts/chains'
|
|
1155
|
-
* import
|
|
1083
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
1156
1084
|
*
|
|
1157
1085
|
* const client = createClient({
|
|
1158
|
-
* chain: tempo
|
|
1086
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1159
1087
|
* transport: http(),
|
|
1160
1088
|
* })
|
|
1161
1089
|
*
|
|
@@ -1257,10 +1185,10 @@ export declare namespace watchMint {
|
|
|
1257
1185
|
* ```ts
|
|
1258
1186
|
* import { createClient, http } from 'viem'
|
|
1259
1187
|
* import { tempo } from 'tempo.ts/chains'
|
|
1260
|
-
* import
|
|
1188
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
1261
1189
|
*
|
|
1262
1190
|
* const client = createClient({
|
|
1263
|
-
* chain: tempo
|
|
1191
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1264
1192
|
* transport: http(),
|
|
1265
1193
|
* })
|
|
1266
1194
|
*
|