tempo.ts 0.2.1 → 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/README.md +24 -0
- package/dist/chains.d.ts +56 -1572
- package/dist/chains.d.ts.map +1 -1
- 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/fee.d.ts +1 -1
- package/dist/viem/Actions/fee.d.ts.map +1 -1
- package/dist/viem/Actions/fee.js +3 -1
- package/dist/viem/Actions/fee.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 +8 -5
- package/dist/viem/Chain.d.ts.map +1 -1
- package/dist/viem/Chain.js +38 -25
- 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 -54
- 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/Actions/fee.ts +3 -1
- package/src/viem/Chain.ts +59 -32
- 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/Chain.ts
CHANGED
|
@@ -23,42 +23,63 @@ export type Chain<
|
|
|
23
23
|
feeToken: feeToken
|
|
24
24
|
})
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
blockCreated: 0,
|
|
34
|
-
},
|
|
26
|
+
function config<const chain extends Chain>(chain: chain) {
|
|
27
|
+
return {
|
|
28
|
+
blockTime: 1_000,
|
|
29
|
+
contracts: {
|
|
30
|
+
multicall3: {
|
|
31
|
+
address: '0xca11bde05977b3631167028862be2a173976ca11',
|
|
32
|
+
blockCreated: 0,
|
|
35
33
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
34
|
+
},
|
|
35
|
+
formatters: {
|
|
36
|
+
transaction: defineTransaction({
|
|
37
|
+
format: Formatters.formatTransaction,
|
|
38
|
+
}),
|
|
39
|
+
transactionRequest: defineTransactionRequest({
|
|
40
|
+
format: (
|
|
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
|
+
),
|
|
57
|
+
}),
|
|
58
|
+
},
|
|
59
|
+
serializers: {
|
|
60
|
+
// TODO: casting to satisfy viem – viem v3 to have more flexible serializer type.
|
|
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,
|
|
71
|
+
},
|
|
72
|
+
...chain,
|
|
73
|
+
} as const
|
|
74
|
+
}
|
|
55
75
|
|
|
76
|
+
export function define<const chain extends viem_Chain>(
|
|
77
|
+
chain: chain,
|
|
78
|
+
): define.ReturnValue<chain> {
|
|
56
79
|
return Object.assign(
|
|
57
|
-
|
|
58
|
-
properties: properties = {} as properties,
|
|
59
|
-
) => inner({ ...chain, ...properties }),
|
|
80
|
+
(properties = {}) => config({ ...chain, ...properties }),
|
|
60
81
|
{ id: chain.id },
|
|
61
|
-
)
|
|
82
|
+
) as never
|
|
62
83
|
}
|
|
63
84
|
|
|
64
85
|
export declare namespace define {
|
|
@@ -74,4 +95,10 @@ export declare namespace define {
|
|
|
74
95
|
*/
|
|
75
96
|
feeToken?: TokenId.TokenIdOrAddress | null | undefined
|
|
76
97
|
}
|
|
98
|
+
|
|
99
|
+
type ReturnValue<chain extends viem_Chain> = (<
|
|
100
|
+
properties extends define.Properties | undefined,
|
|
101
|
+
>(
|
|
102
|
+
properties: properties,
|
|
103
|
+
) => ReturnType<typeof config<chain & properties>>) & { id: chain['id'] }
|
|
77
104
|
}
|
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
|
|