tempo.ts 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/viem/Abis.d.ts +103 -35
- package/dist/viem/Abis.d.ts.map +1 -1
- package/dist/viem/Abis.js +78 -27
- package/dist/viem/Abis.js.map +1 -1
- package/dist/viem/Actions/amm.d.ts +24 -42
- package/dist/viem/Actions/amm.d.ts.map +1 -1
- package/dist/viem/Actions/dex.d.ts +314 -66
- package/dist/viem/Actions/dex.d.ts.map +1 -1
- package/dist/viem/Actions/dex.js +10 -9
- package/dist/viem/Actions/dex.js.map +1 -1
- package/dist/viem/Actions/reward.d.ts +15 -3
- package/dist/viem/Actions/reward.d.ts.map +1 -1
- package/dist/viem/Actions/token.d.ts +75 -15
- package/dist/viem/Actions/token.d.ts.map +1 -1
- package/dist/viem/Chain.d.ts.map +1 -1
- package/dist/viem/Chain.js +15 -2
- package/dist/viem/Chain.js.map +1 -1
- package/dist/viem/Decorator.d.ts +2 -2
- package/dist/viem/Decorator.d.ts.map +1 -1
- package/dist/viem/Decorator.js +1 -1
- package/dist/viem/Decorator.js.map +1 -1
- package/dist/wagmi/Actions/dex.d.ts +8 -8
- package/dist/wagmi/Actions/dex.d.ts.map +1 -1
- package/dist/wagmi/Actions/dex.js +9 -9
- package/dist/wagmi/Actions/dex.js.map +1 -1
- package/dist/wagmi/Hooks/dex.d.ts +4 -4
- package/dist/wagmi/Hooks/dex.d.ts.map +1 -1
- package/dist/wagmi/Hooks/dex.js +2 -2
- package/dist/wagmi/Hooks/dex.js.map +1 -1
- package/package.json +1 -1
- package/src/ox/TransactionEnvelopeAA.test.ts +42 -50
- package/src/prool/internal/chain.json +84 -80
- package/src/viem/Abis.ts +79 -27
- package/src/viem/Actions/dex.test.ts +12 -12
- package/src/viem/Actions/dex.ts +18 -14
- package/src/viem/Chain.ts +26 -3
- package/src/viem/Decorator.ts +6 -6
- package/src/viem/e2e.test.ts +6 -6
- package/src/wagmi/Actions/dex.test.ts +12 -12
- package/src/wagmi/Actions/dex.ts +15 -15
- package/src/wagmi/Hooks/dex.ts +8 -8
package/src/viem/Abis.ts
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
// Generated with `pnpm gen:abis`. Do not modify manually.
|
|
2
2
|
|
|
3
|
+
export const linkingUsd = [
|
|
4
|
+
{
|
|
5
|
+
name: 'TRANSFER_ROLE',
|
|
6
|
+
type: 'function',
|
|
7
|
+
stateMutability: 'view',
|
|
8
|
+
inputs: [],
|
|
9
|
+
outputs: [{ type: 'bytes32' }],
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: 'RECEIVE_WITH_MEMO_ROLE',
|
|
13
|
+
type: 'function',
|
|
14
|
+
stateMutability: 'view',
|
|
15
|
+
inputs: [],
|
|
16
|
+
outputs: [{ type: 'bytes32' }],
|
|
17
|
+
},
|
|
18
|
+
] as const
|
|
19
|
+
|
|
3
20
|
export const nonce = [
|
|
4
21
|
{
|
|
5
22
|
name: 'getNonce',
|
|
@@ -178,7 +195,7 @@ export const stablecoinExchange = [
|
|
|
178
195
|
],
|
|
179
196
|
},
|
|
180
197
|
{
|
|
181
|
-
name: '
|
|
198
|
+
name: 'getTickLevel',
|
|
182
199
|
type: 'function',
|
|
183
200
|
stateMutability: 'view',
|
|
184
201
|
inputs: [
|
|
@@ -187,14 +204,9 @@ export const stablecoinExchange = [
|
|
|
187
204
|
{ type: 'bool', name: 'isBid' },
|
|
188
205
|
],
|
|
189
206
|
outputs: [
|
|
190
|
-
{
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
{ type: 'uint128', name: 'head' },
|
|
194
|
-
{ type: 'uint128', name: 'tail' },
|
|
195
|
-
{ type: 'uint128', name: 'totalLiquidity' },
|
|
196
|
-
],
|
|
197
|
-
},
|
|
207
|
+
{ type: 'uint128', name: 'head' },
|
|
208
|
+
{ type: 'uint128', name: 'tail' },
|
|
209
|
+
{ type: 'uint128', name: 'totalLiquidity' },
|
|
198
210
|
],
|
|
199
211
|
},
|
|
200
212
|
{
|
|
@@ -238,6 +250,55 @@ export const stablecoinExchange = [
|
|
|
238
250
|
},
|
|
239
251
|
],
|
|
240
252
|
},
|
|
253
|
+
{
|
|
254
|
+
name: 'MIN_TICK',
|
|
255
|
+
type: 'function',
|
|
256
|
+
stateMutability: 'pure',
|
|
257
|
+
inputs: [],
|
|
258
|
+
outputs: [{ type: 'int16' }],
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: 'MAX_TICK',
|
|
262
|
+
type: 'function',
|
|
263
|
+
stateMutability: 'pure',
|
|
264
|
+
inputs: [],
|
|
265
|
+
outputs: [{ type: 'int16' }],
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: 'PRICE_SCALE',
|
|
269
|
+
type: 'function',
|
|
270
|
+
stateMutability: 'pure',
|
|
271
|
+
inputs: [],
|
|
272
|
+
outputs: [{ type: 'uint32' }],
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
name: 'MIN_PRICE',
|
|
276
|
+
type: 'function',
|
|
277
|
+
stateMutability: 'pure',
|
|
278
|
+
inputs: [],
|
|
279
|
+
outputs: [{ type: 'uint32' }],
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
name: 'MAX_PRICE',
|
|
283
|
+
type: 'function',
|
|
284
|
+
stateMutability: 'pure',
|
|
285
|
+
inputs: [],
|
|
286
|
+
outputs: [{ type: 'uint32' }],
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
name: 'tickToPrice',
|
|
290
|
+
type: 'function',
|
|
291
|
+
stateMutability: 'pure',
|
|
292
|
+
inputs: [{ type: 'int16', name: 'tick' }],
|
|
293
|
+
outputs: [{ type: 'uint32', name: 'price' }],
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
name: 'priceToTick',
|
|
297
|
+
type: 'function',
|
|
298
|
+
stateMutability: 'pure',
|
|
299
|
+
inputs: [{ type: 'uint32', name: 'price' }],
|
|
300
|
+
outputs: [{ type: 'int16', name: 'tick' }],
|
|
301
|
+
},
|
|
241
302
|
{
|
|
242
303
|
name: 'PairCreated',
|
|
243
304
|
type: 'event',
|
|
@@ -656,7 +717,7 @@ export const tip20 = [
|
|
|
656
717
|
{
|
|
657
718
|
type: 'tuple',
|
|
658
719
|
components: [
|
|
659
|
-
{ type: 'address', name: '
|
|
720
|
+
{ type: 'address', name: 'rewardRecipient' },
|
|
660
721
|
{ type: 'uint256', name: 'rewardPerToken' },
|
|
661
722
|
{ type: 'uint256', name: 'rewardBalance' },
|
|
662
723
|
],
|
|
@@ -807,6 +868,7 @@ export const tip20 = [
|
|
|
807
868
|
{ name: 'StreamInactive', type: 'error', inputs: [] },
|
|
808
869
|
{ name: 'NoOptedInSupply', type: 'error', inputs: [] },
|
|
809
870
|
{ name: 'Unauthorized', type: 'error', inputs: [] },
|
|
871
|
+
{ name: 'RewardsDisabled', type: 'error', inputs: [] },
|
|
810
872
|
{
|
|
811
873
|
name: 'hasRole',
|
|
812
874
|
type: 'function',
|
|
@@ -1073,13 +1135,6 @@ export const tipAccountRegistrar = [
|
|
|
1073
1135
|
],
|
|
1074
1136
|
outputs: [{ type: 'address', name: 'authority' }],
|
|
1075
1137
|
},
|
|
1076
|
-
{
|
|
1077
|
-
name: 'getDelegationMessage',
|
|
1078
|
-
type: 'function',
|
|
1079
|
-
stateMutability: 'pure',
|
|
1080
|
-
inputs: [],
|
|
1081
|
-
outputs: [{ type: 'string' }],
|
|
1082
|
-
},
|
|
1083
1138
|
{ name: 'InvalidSignature', type: 'error', inputs: [] },
|
|
1084
1139
|
{ name: 'CodeNotEmpty', type: 'error', inputs: [] },
|
|
1085
1140
|
{ name: 'NonceNotZero', type: 'error', inputs: [] },
|
|
@@ -1159,6 +1214,13 @@ export const feeManager = [
|
|
|
1159
1214
|
] as const
|
|
1160
1215
|
|
|
1161
1216
|
export const feeAmm = [
|
|
1217
|
+
{
|
|
1218
|
+
name: 'MIN_LIQUIDITY',
|
|
1219
|
+
type: 'function',
|
|
1220
|
+
stateMutability: 'view',
|
|
1221
|
+
inputs: [],
|
|
1222
|
+
outputs: [{ type: 'uint256' }],
|
|
1223
|
+
},
|
|
1162
1224
|
{
|
|
1163
1225
|
name: 'getPoolId',
|
|
1164
1226
|
type: 'function',
|
|
@@ -1271,16 +1333,6 @@ export const feeAmm = [
|
|
|
1271
1333
|
],
|
|
1272
1334
|
outputs: [{ type: 'uint256', name: 'amountIn' }],
|
|
1273
1335
|
},
|
|
1274
|
-
{
|
|
1275
|
-
name: 'calculateLiquidity',
|
|
1276
|
-
type: 'function',
|
|
1277
|
-
stateMutability: 'pure',
|
|
1278
|
-
inputs: [
|
|
1279
|
-
{ type: 'uint256', name: 'x' },
|
|
1280
|
-
{ type: 'uint256', name: 'y' },
|
|
1281
|
-
],
|
|
1282
|
-
outputs: [{ type: 'uint256' }],
|
|
1283
|
-
},
|
|
1284
1336
|
{
|
|
1285
1337
|
name: 'Mint',
|
|
1286
1338
|
type: 'event',
|
|
@@ -785,7 +785,7 @@ describe('getOrderbook', () => {
|
|
|
785
785
|
})
|
|
786
786
|
})
|
|
787
787
|
|
|
788
|
-
describe('
|
|
788
|
+
describe('getTickLevel', () => {
|
|
789
789
|
test('default', async () => {
|
|
790
790
|
const { base } = await setupTokenPair(client)
|
|
791
791
|
|
|
@@ -800,7 +800,7 @@ describe('getPriceLevel', () => {
|
|
|
800
800
|
})
|
|
801
801
|
|
|
802
802
|
// Get the price level
|
|
803
|
-
const level = await Actions.dex.
|
|
803
|
+
const level = await Actions.dex.getTickLevel(client, {
|
|
804
804
|
base,
|
|
805
805
|
tick,
|
|
806
806
|
isBid: true,
|
|
@@ -818,7 +818,7 @@ describe('getPriceLevel', () => {
|
|
|
818
818
|
const tick = Tick.fromPrice('1.001')
|
|
819
819
|
|
|
820
820
|
// Query a tick with no orders
|
|
821
|
-
const level = await Actions.dex.
|
|
821
|
+
const level = await Actions.dex.getTickLevel(client, {
|
|
822
822
|
base,
|
|
823
823
|
tick,
|
|
824
824
|
isBid: true,
|
|
@@ -852,7 +852,7 @@ describe('getPriceLevel', () => {
|
|
|
852
852
|
})
|
|
853
853
|
|
|
854
854
|
// Get the price level
|
|
855
|
-
const level = await Actions.dex.
|
|
855
|
+
const level = await Actions.dex.getTickLevel(client, {
|
|
856
856
|
base,
|
|
857
857
|
tick,
|
|
858
858
|
isBid: true,
|
|
@@ -886,14 +886,14 @@ describe('getPriceLevel', () => {
|
|
|
886
886
|
})
|
|
887
887
|
|
|
888
888
|
// Get bid side
|
|
889
|
-
const bidLevel = await Actions.dex.
|
|
889
|
+
const bidLevel = await Actions.dex.getTickLevel(client, {
|
|
890
890
|
base,
|
|
891
891
|
tick,
|
|
892
892
|
isBid: true,
|
|
893
893
|
})
|
|
894
894
|
|
|
895
895
|
// Get ask side
|
|
896
|
-
const askLevel = await Actions.dex.
|
|
896
|
+
const askLevel = await Actions.dex.getTickLevel(client, {
|
|
897
897
|
base,
|
|
898
898
|
tick,
|
|
899
899
|
isBid: false,
|
|
@@ -926,7 +926,7 @@ describe('getPriceLevel', () => {
|
|
|
926
926
|
})
|
|
927
927
|
|
|
928
928
|
// Get level before cancellation
|
|
929
|
-
const levelBefore = await Actions.dex.
|
|
929
|
+
const levelBefore = await Actions.dex.getTickLevel(client, {
|
|
930
930
|
base,
|
|
931
931
|
tick,
|
|
932
932
|
isBid: true,
|
|
@@ -938,7 +938,7 @@ describe('getPriceLevel', () => {
|
|
|
938
938
|
})
|
|
939
939
|
|
|
940
940
|
// Get level after cancellation
|
|
941
|
-
const levelAfter = await Actions.dex.
|
|
941
|
+
const levelAfter = await Actions.dex.getTickLevel(client, {
|
|
942
942
|
base,
|
|
943
943
|
tick,
|
|
944
944
|
isBid: true,
|
|
@@ -962,7 +962,7 @@ describe('getPriceLevel', () => {
|
|
|
962
962
|
})
|
|
963
963
|
|
|
964
964
|
// Get level before fill
|
|
965
|
-
const levelBefore = await Actions.dex.
|
|
965
|
+
const levelBefore = await Actions.dex.getTickLevel(client, {
|
|
966
966
|
base,
|
|
967
967
|
tick,
|
|
968
968
|
isBid: false,
|
|
@@ -977,7 +977,7 @@ describe('getPriceLevel', () => {
|
|
|
977
977
|
})
|
|
978
978
|
|
|
979
979
|
// Get level after fill
|
|
980
|
-
const levelAfter = await Actions.dex.
|
|
980
|
+
const levelAfter = await Actions.dex.getTickLevel(client, {
|
|
981
981
|
base,
|
|
982
982
|
tick,
|
|
983
983
|
isBid: false,
|
|
@@ -999,7 +999,7 @@ describe('getPriceLevel', () => {
|
|
|
999
999
|
})
|
|
1000
1000
|
|
|
1001
1001
|
// Query min tick
|
|
1002
|
-
const minLevel = await Actions.dex.
|
|
1002
|
+
const minLevel = await Actions.dex.getTickLevel(client, {
|
|
1003
1003
|
base,
|
|
1004
1004
|
tick: Tick.minTick,
|
|
1005
1005
|
isBid: false,
|
|
@@ -1015,7 +1015,7 @@ describe('getPriceLevel', () => {
|
|
|
1015
1015
|
})
|
|
1016
1016
|
|
|
1017
1017
|
// Query max tick
|
|
1018
|
-
const maxLevel = await Actions.dex.
|
|
1018
|
+
const maxLevel = await Actions.dex.getTickLevel(client, {
|
|
1019
1019
|
base,
|
|
1020
1020
|
tick: Tick.maxTick,
|
|
1021
1021
|
isBid: true,
|
package/src/viem/Actions/dex.ts
CHANGED
|
@@ -959,7 +959,7 @@ export namespace getOrderbook {
|
|
|
959
959
|
* transport: http(),
|
|
960
960
|
* })
|
|
961
961
|
*
|
|
962
|
-
* const level = await Actions.dex.
|
|
962
|
+
* const level = await Actions.dex.getTickLevel(client, {
|
|
963
963
|
* base: '0x20c...11',
|
|
964
964
|
* tick: Tick.fromPrice('1.001'),
|
|
965
965
|
* isBid: true,
|
|
@@ -970,18 +970,19 @@ export namespace getOrderbook {
|
|
|
970
970
|
* @param parameters - Parameters.
|
|
971
971
|
* @returns The price level information.
|
|
972
972
|
*/
|
|
973
|
-
export async function
|
|
973
|
+
export async function getTickLevel<chain extends Chain | undefined>(
|
|
974
974
|
client: Client<Transport, chain>,
|
|
975
|
-
parameters:
|
|
976
|
-
): Promise<
|
|
975
|
+
parameters: getTickLevel.Parameters,
|
|
976
|
+
): Promise<getTickLevel.ReturnValue> {
|
|
977
977
|
const { base, tick, isBid, ...rest } = parameters
|
|
978
|
-
|
|
978
|
+
const [head, tail, totalLiquidity] = await readContract(client, {
|
|
979
979
|
...rest,
|
|
980
|
-
...
|
|
980
|
+
...getTickLevel.call({ base, tick, isBid }),
|
|
981
981
|
})
|
|
982
|
+
return { head, tail, totalLiquidity }
|
|
982
983
|
}
|
|
983
984
|
|
|
984
|
-
export namespace
|
|
985
|
+
export namespace getTickLevel {
|
|
985
986
|
export type Parameters = ReadParameters & Args
|
|
986
987
|
|
|
987
988
|
export type Args = {
|
|
@@ -993,14 +994,17 @@ export namespace getPriceLevel {
|
|
|
993
994
|
tick: number
|
|
994
995
|
}
|
|
995
996
|
|
|
996
|
-
export type ReturnValue =
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
997
|
+
export type ReturnValue = {
|
|
998
|
+
/** Order ID of the first order at this tick (0 if empty) */
|
|
999
|
+
head: bigint
|
|
1000
|
+
/** Order ID of the last order at this tick (0 if empty) */
|
|
1001
|
+
tail: bigint
|
|
1002
|
+
/** Total liquidity available at this tick level */
|
|
1003
|
+
totalLiquidity: bigint
|
|
1004
|
+
}
|
|
1001
1005
|
|
|
1002
1006
|
/**
|
|
1003
|
-
* Defines a call to the `
|
|
1007
|
+
* Defines a call to the `getTickLevel` function.
|
|
1004
1008
|
*
|
|
1005
1009
|
* @param args - Arguments.
|
|
1006
1010
|
* @returns The call.
|
|
@@ -1011,7 +1015,7 @@ export namespace getPriceLevel {
|
|
|
1011
1015
|
address: Addresses.stablecoinExchange,
|
|
1012
1016
|
abi: Abis.stablecoinExchange,
|
|
1013
1017
|
args: [base, tick, isBid],
|
|
1014
|
-
functionName: '
|
|
1018
|
+
functionName: 'getTickLevel',
|
|
1015
1019
|
})
|
|
1016
1020
|
}
|
|
1017
1021
|
}
|
package/src/viem/Chain.ts
CHANGED
|
@@ -38,13 +38,36 @@ function config<const chain extends Chain>(chain: chain) {
|
|
|
38
38
|
}),
|
|
39
39
|
transactionRequest: defineTransactionRequest({
|
|
40
40
|
format: (
|
|
41
|
-
...
|
|
42
|
-
|
|
41
|
+
...[request, action]: Parameters<
|
|
42
|
+
typeof Formatters.formatTransactionRequest<chain>
|
|
43
|
+
>
|
|
44
|
+
) =>
|
|
45
|
+
Formatters.formatTransactionRequest<chain>(
|
|
46
|
+
{
|
|
47
|
+
...request,
|
|
48
|
+
...(!request.feePayer &&
|
|
49
|
+
(action === 'estimateGas' || action === 'sendTransaction')
|
|
50
|
+
? {
|
|
51
|
+
feeToken: request.feeToken ?? chain.feeToken,
|
|
52
|
+
}
|
|
53
|
+
: {}),
|
|
54
|
+
},
|
|
55
|
+
action,
|
|
56
|
+
),
|
|
43
57
|
}),
|
|
44
58
|
},
|
|
45
59
|
serializers: {
|
|
46
60
|
// TODO: casting to satisfy viem – viem v3 to have more flexible serializer type.
|
|
47
|
-
transaction:
|
|
61
|
+
transaction: ((transaction, signature) =>
|
|
62
|
+
Transaction.serialize(
|
|
63
|
+
{
|
|
64
|
+
...transaction,
|
|
65
|
+
...(!(transaction as { feePayer?: unknown }).feePayer
|
|
66
|
+
? { feeToken: chain.feeToken ?? undefined }
|
|
67
|
+
: {}),
|
|
68
|
+
} as never,
|
|
69
|
+
signature,
|
|
70
|
+
)) as SerializeTransactionFn,
|
|
48
71
|
},
|
|
49
72
|
...chain,
|
|
50
73
|
} as const
|
package/src/viem/Decorator.ts
CHANGED
|
@@ -652,7 +652,7 @@ export type Decorator<
|
|
|
652
652
|
* transport: http(),
|
|
653
653
|
* }).extend(tempoActions())
|
|
654
654
|
*
|
|
655
|
-
* const level = await client.dex.
|
|
655
|
+
* const level = await client.dex.getTickLevel({
|
|
656
656
|
* base: '0x20c...11',
|
|
657
657
|
* tick: Tick.fromPrice('1.001'),
|
|
658
658
|
* isBid: true,
|
|
@@ -662,9 +662,9 @@ export type Decorator<
|
|
|
662
662
|
* @param parameters - Parameters.
|
|
663
663
|
* @returns The price level information.
|
|
664
664
|
*/
|
|
665
|
-
|
|
666
|
-
parameters: dexActions.
|
|
667
|
-
) => Promise<dexActions.
|
|
665
|
+
getTickLevel: (
|
|
666
|
+
parameters: dexActions.getTickLevel.Parameters,
|
|
667
|
+
) => Promise<dexActions.getTickLevel.ReturnValue>
|
|
668
668
|
/**
|
|
669
669
|
* Gets the quote for selling a specific amount of tokens.
|
|
670
670
|
*
|
|
@@ -2980,8 +2980,8 @@ export function decorator() {
|
|
|
2980
2980
|
getBuyQuote: (parameters) => dexActions.getBuyQuote(client, parameters),
|
|
2981
2981
|
getOrder: (parameters) => dexActions.getOrder(client, parameters),
|
|
2982
2982
|
getOrders: (parameters) => dexActions.getOrders(client, parameters),
|
|
2983
|
-
|
|
2984
|
-
dexActions.
|
|
2983
|
+
getTickLevel: (parameters) =>
|
|
2984
|
+
dexActions.getTickLevel(client, parameters),
|
|
2985
2985
|
getSellQuote: (parameters) =>
|
|
2986
2986
|
dexActions.getSellQuote(client, parameters),
|
|
2987
2987
|
place: (parameters) => dexActions.place(client, parameters),
|
package/src/viem/e2e.test.ts
CHANGED
|
@@ -130,11 +130,11 @@ describe('sendTransaction', () => {
|
|
|
130
130
|
"chainId": 1337,
|
|
131
131
|
"data": undefined,
|
|
132
132
|
"feePayerSignature": undefined,
|
|
133
|
-
"feeToken":
|
|
133
|
+
"feeToken": "0x20c0000000000000000000000000000000000001",
|
|
134
134
|
"from": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
|
|
135
|
-
"gas":
|
|
135
|
+
"gas": 217317n,
|
|
136
136
|
"gasPrice": 10000000000n,
|
|
137
|
-
"hash": "
|
|
137
|
+
"hash": "0x5644cb4aca7b42c7f4d28c324b9cbc4d0ba4ff3aeddbe41fa418a5966923ab36",
|
|
138
138
|
"maxFeePerBlobGas": undefined,
|
|
139
139
|
"maxFeePerGas": 12000000000n,
|
|
140
140
|
"maxPriorityFeePerGas": 0n,
|
|
@@ -142,9 +142,9 @@ describe('sendTransaction', () => {
|
|
|
142
142
|
"nonceKey": 0n,
|
|
143
143
|
"signature": {
|
|
144
144
|
"signature": {
|
|
145
|
-
"r":
|
|
146
|
-
"s":
|
|
147
|
-
"yParity":
|
|
145
|
+
"r": 1770799250379385769866461071353582741695856909786638355195145760341199788761n,
|
|
146
|
+
"s": 52417275998342468381261131517961079083566057345688940928298921493890348732163n,
|
|
147
|
+
"yParity": 1,
|
|
148
148
|
},
|
|
149
149
|
"type": "secp256k1",
|
|
150
150
|
},
|
|
@@ -599,7 +599,7 @@ describe('getOrderbook', () => {
|
|
|
599
599
|
})
|
|
600
600
|
})
|
|
601
601
|
|
|
602
|
-
describe('
|
|
602
|
+
describe('getTickLevel', () => {
|
|
603
603
|
test('default', async () => {
|
|
604
604
|
const { base } = await setupTokenPair()
|
|
605
605
|
|
|
@@ -614,7 +614,7 @@ describe('getPriceLevel', () => {
|
|
|
614
614
|
})
|
|
615
615
|
|
|
616
616
|
// Get the price level
|
|
617
|
-
const level = await Actions.dex.
|
|
617
|
+
const level = await Actions.dex.getTickLevel(config, {
|
|
618
618
|
base,
|
|
619
619
|
tick,
|
|
620
620
|
isBid: true,
|
|
@@ -632,7 +632,7 @@ describe('getPriceLevel', () => {
|
|
|
632
632
|
const tick = Tick.fromPrice('1.001')
|
|
633
633
|
|
|
634
634
|
// Query a tick with no orders
|
|
635
|
-
const level = await Actions.dex.
|
|
635
|
+
const level = await Actions.dex.getTickLevel(config, {
|
|
636
636
|
base,
|
|
637
637
|
tick,
|
|
638
638
|
isBid: true,
|
|
@@ -666,7 +666,7 @@ describe('getPriceLevel', () => {
|
|
|
666
666
|
})
|
|
667
667
|
|
|
668
668
|
// Get the price level
|
|
669
|
-
const level = await Actions.dex.
|
|
669
|
+
const level = await Actions.dex.getTickLevel(config, {
|
|
670
670
|
base,
|
|
671
671
|
tick,
|
|
672
672
|
isBid: true,
|
|
@@ -700,14 +700,14 @@ describe('getPriceLevel', () => {
|
|
|
700
700
|
})
|
|
701
701
|
|
|
702
702
|
// Get bid side
|
|
703
|
-
const bidLevel = await Actions.dex.
|
|
703
|
+
const bidLevel = await Actions.dex.getTickLevel(config, {
|
|
704
704
|
base,
|
|
705
705
|
tick,
|
|
706
706
|
isBid: true,
|
|
707
707
|
})
|
|
708
708
|
|
|
709
709
|
// Get ask side
|
|
710
|
-
const askLevel = await Actions.dex.
|
|
710
|
+
const askLevel = await Actions.dex.getTickLevel(config, {
|
|
711
711
|
base,
|
|
712
712
|
tick,
|
|
713
713
|
isBid: false,
|
|
@@ -740,7 +740,7 @@ describe('getPriceLevel', () => {
|
|
|
740
740
|
})
|
|
741
741
|
|
|
742
742
|
// Get level before cancellation
|
|
743
|
-
const levelBefore = await Actions.dex.
|
|
743
|
+
const levelBefore = await Actions.dex.getTickLevel(config, {
|
|
744
744
|
base,
|
|
745
745
|
tick,
|
|
746
746
|
isBid: true,
|
|
@@ -752,7 +752,7 @@ describe('getPriceLevel', () => {
|
|
|
752
752
|
})
|
|
753
753
|
|
|
754
754
|
// Get level after cancellation
|
|
755
|
-
const levelAfter = await Actions.dex.
|
|
755
|
+
const levelAfter = await Actions.dex.getTickLevel(config, {
|
|
756
756
|
base,
|
|
757
757
|
tick,
|
|
758
758
|
isBid: true,
|
|
@@ -776,7 +776,7 @@ describe('getPriceLevel', () => {
|
|
|
776
776
|
})
|
|
777
777
|
|
|
778
778
|
// Get level before fill
|
|
779
|
-
const levelBefore = await Actions.dex.
|
|
779
|
+
const levelBefore = await Actions.dex.getTickLevel(config, {
|
|
780
780
|
base,
|
|
781
781
|
tick,
|
|
782
782
|
isBid: false,
|
|
@@ -791,7 +791,7 @@ describe('getPriceLevel', () => {
|
|
|
791
791
|
})
|
|
792
792
|
|
|
793
793
|
// Get level after fill
|
|
794
|
-
const levelAfter = await Actions.dex.
|
|
794
|
+
const levelAfter = await Actions.dex.getTickLevel(config, {
|
|
795
795
|
base,
|
|
796
796
|
tick,
|
|
797
797
|
isBid: false,
|
|
@@ -813,7 +813,7 @@ describe('getPriceLevel', () => {
|
|
|
813
813
|
})
|
|
814
814
|
|
|
815
815
|
// Query min tick
|
|
816
|
-
const minLevel = await Actions.dex.
|
|
816
|
+
const minLevel = await Actions.dex.getTickLevel(config, {
|
|
817
817
|
base,
|
|
818
818
|
tick: Tick.minTick,
|
|
819
819
|
isBid: false,
|
|
@@ -829,7 +829,7 @@ describe('getPriceLevel', () => {
|
|
|
829
829
|
})
|
|
830
830
|
|
|
831
831
|
// Query max tick
|
|
832
|
-
const maxLevel = await Actions.dex.
|
|
832
|
+
const maxLevel = await Actions.dex.getTickLevel(config, {
|
|
833
833
|
base,
|
|
834
834
|
tick: Tick.maxTick,
|
|
835
835
|
isBid: true,
|
package/src/wagmi/Actions/dex.ts
CHANGED
|
@@ -831,7 +831,7 @@ export namespace getOrderbook {
|
|
|
831
831
|
* },
|
|
832
832
|
* })
|
|
833
833
|
*
|
|
834
|
-
* const level = await Actions.dex.
|
|
834
|
+
* const level = await Actions.dex.getTickLevel(config, {
|
|
835
835
|
* base: '0x20c...11',
|
|
836
836
|
* tick: Tick.fromPrice('1.001'),
|
|
837
837
|
* isBid: true,
|
|
@@ -842,25 +842,25 @@ export namespace getOrderbook {
|
|
|
842
842
|
* @param parameters - Parameters.
|
|
843
843
|
* @returns The price level information.
|
|
844
844
|
*/
|
|
845
|
-
export function
|
|
845
|
+
export function getTickLevel<config extends Config>(
|
|
846
846
|
config: config,
|
|
847
|
-
parameters:
|
|
848
|
-
): Promise<
|
|
847
|
+
parameters: getTickLevel.Parameters<config>,
|
|
848
|
+
): Promise<getTickLevel.ReturnValue> {
|
|
849
849
|
const { chainId, ...rest } = parameters
|
|
850
850
|
const client = config.getClient({ chainId })
|
|
851
|
-
return viem_Actions.
|
|
851
|
+
return viem_Actions.getTickLevel(client, rest)
|
|
852
852
|
}
|
|
853
853
|
|
|
854
|
-
export namespace
|
|
854
|
+
export namespace getTickLevel {
|
|
855
855
|
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
856
|
-
viem_Actions.
|
|
856
|
+
viem_Actions.getTickLevel.Parameters
|
|
857
857
|
|
|
858
|
-
export type ReturnValue = viem_Actions.
|
|
858
|
+
export type ReturnValue = viem_Actions.getTickLevel.ReturnValue
|
|
859
859
|
|
|
860
860
|
export function queryKey<config extends Config>(
|
|
861
861
|
parameters: Parameters<config>,
|
|
862
862
|
) {
|
|
863
|
-
return ['
|
|
863
|
+
return ['getTickLevel', parameters] as const
|
|
864
864
|
}
|
|
865
865
|
|
|
866
866
|
export type QueryKey<config extends Config> = ReturnType<
|
|
@@ -877,7 +877,7 @@ export namespace getPriceLevel {
|
|
|
877
877
|
queryKey: queryKey(rest),
|
|
878
878
|
async queryFn({ queryKey }) {
|
|
879
879
|
const [, parameters] = queryKey
|
|
880
|
-
return await
|
|
880
|
+
return await getTickLevel(config, parameters)
|
|
881
881
|
},
|
|
882
882
|
}
|
|
883
883
|
}
|
|
@@ -885,8 +885,8 @@ export namespace getPriceLevel {
|
|
|
885
885
|
export declare namespace queryOptions {
|
|
886
886
|
export type Parameters<
|
|
887
887
|
config extends Config,
|
|
888
|
-
selectData =
|
|
889
|
-
> =
|
|
888
|
+
selectData = getTickLevel.ReturnValue,
|
|
889
|
+
> = getTickLevel.Parameters<config> & {
|
|
890
890
|
query?:
|
|
891
891
|
| Omit<ReturnValue<config, selectData>, 'queryKey' | 'queryFn'>
|
|
892
892
|
| undefined
|
|
@@ -894,13 +894,13 @@ export namespace getPriceLevel {
|
|
|
894
894
|
|
|
895
895
|
export type ReturnValue<
|
|
896
896
|
config extends Config,
|
|
897
|
-
selectData =
|
|
897
|
+
selectData = getTickLevel.ReturnValue,
|
|
898
898
|
> = RequiredBy<
|
|
899
899
|
Query.QueryOptions<
|
|
900
|
-
|
|
900
|
+
getTickLevel.ReturnValue,
|
|
901
901
|
Query.DefaultError,
|
|
902
902
|
selectData,
|
|
903
|
-
|
|
903
|
+
getTickLevel.QueryKey<config>
|
|
904
904
|
>,
|
|
905
905
|
'queryKey' | 'queryFn'
|
|
906
906
|
>
|
package/src/wagmi/Hooks/dex.ts
CHANGED
|
@@ -26,8 +26,8 @@ import {
|
|
|
26
26
|
getOrder,
|
|
27
27
|
getOrderbook,
|
|
28
28
|
getOrders,
|
|
29
|
-
getPriceLevel,
|
|
30
29
|
getSellQuote,
|
|
30
|
+
getTickLevel,
|
|
31
31
|
place,
|
|
32
32
|
placeFlip,
|
|
33
33
|
placeFlipSync,
|
|
@@ -808,14 +808,14 @@ export declare namespace useOrderbook {
|
|
|
808
808
|
*/
|
|
809
809
|
export function usePriceLevel<
|
|
810
810
|
config extends Config = ResolvedRegister['config'],
|
|
811
|
-
selectData =
|
|
811
|
+
selectData = getTickLevel.ReturnValue,
|
|
812
812
|
>(parameters: usePriceLevel.Parameters<config, selectData>) {
|
|
813
813
|
const { query = {} } = parameters
|
|
814
814
|
|
|
815
815
|
const config = useConfig(parameters)
|
|
816
816
|
const chainId = useChainId({ config })
|
|
817
817
|
|
|
818
|
-
const options =
|
|
818
|
+
const options = getTickLevel.queryOptions(config, {
|
|
819
819
|
...parameters,
|
|
820
820
|
chainId: parameters.chainId ?? chainId,
|
|
821
821
|
query: undefined,
|
|
@@ -833,17 +833,17 @@ export function usePriceLevel<
|
|
|
833
833
|
export declare namespace usePriceLevel {
|
|
834
834
|
export type Parameters<
|
|
835
835
|
config extends Config = ResolvedRegister['config'],
|
|
836
|
-
selectData =
|
|
836
|
+
selectData = getTickLevel.ReturnValue,
|
|
837
837
|
> = ConfigParameter<config> &
|
|
838
838
|
QueryParameter<
|
|
839
|
-
|
|
839
|
+
getTickLevel.ReturnValue,
|
|
840
840
|
DefaultError,
|
|
841
841
|
selectData,
|
|
842
|
-
|
|
842
|
+
getTickLevel.QueryKey<config>
|
|
843
843
|
> &
|
|
844
|
-
Omit<
|
|
844
|
+
Omit<getTickLevel.queryOptions.Parameters<config, selectData>, 'query'>
|
|
845
845
|
|
|
846
|
-
export type ReturnValue<selectData =
|
|
846
|
+
export type ReturnValue<selectData = getTickLevel.ReturnValue> =
|
|
847
847
|
UseQueryReturnType<selectData, Error>
|
|
848
848
|
}
|
|
849
849
|
|