levr-sdk 0.0.2 → 0.1.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/esm/abis/LevrFactory_v1.js +63 -0
- package/dist/esm/abis/LevrGovernor_v1.js +15 -24
- package/dist/esm/abis/LevrStaking_v1.js +7 -1
- package/dist/esm/balance.js +19 -1
- package/dist/esm/balance.js.map +1 -1
- package/dist/esm/client/hook/index.js +14 -3
- package/dist/esm/client/hook/index.js.map +1 -1
- package/dist/esm/client/hook/use-fee-receivers.js +11 -29
- package/dist/esm/client/hook/use-fee-receivers.js.map +1 -1
- package/dist/esm/client/hook/use-governance.js +19 -254
- package/dist/esm/client/hook/use-governance.js.map +1 -1
- package/dist/esm/client/hook/use-pool.js +26 -0
- package/dist/esm/client/hook/use-pool.js.map +1 -0
- package/dist/esm/client/hook/use-prepare.js +6 -3
- package/dist/esm/client/hook/use-prepare.js.map +1 -1
- package/dist/esm/client/hook/use-project.js +24 -9
- package/dist/esm/client/hook/use-project.js.map +1 -1
- package/dist/esm/client/hook/use-proposal.js +48 -0
- package/dist/esm/client/hook/use-proposal.js.map +1 -0
- package/dist/esm/client/hook/use-stake.js +29 -195
- package/dist/esm/client/hook/use-stake.js.map +1 -1
- package/dist/esm/client/hook/use-swap.js +9 -13
- package/dist/esm/client/hook/use-swap.js.map +1 -1
- package/dist/esm/client/hook/use-user.js +25 -0
- package/dist/esm/client/hook/use-user.js.map +1 -0
- package/dist/esm/client/levr-provider.js +65 -107
- package/dist/esm/client/levr-provider.js.map +1 -1
- package/dist/esm/client/query-keys.js +9 -21
- package/dist/esm/client/query-keys.js.map +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/esm/fee-receivers.js +25 -13
- package/dist/esm/fee-receivers.js.map +1 -1
- package/dist/esm/governance.js +35 -414
- package/dist/esm/governance.js.map +1 -1
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/pool.js +70 -0
- package/dist/esm/pool.js.map +1 -0
- package/dist/esm/project.js +389 -135
- package/dist/esm/project.js.map +1 -1
- package/dist/esm/proposal.js +156 -0
- package/dist/esm/proposal.js.map +1 -0
- package/dist/esm/quote/index.js +2 -2
- package/dist/esm/quote/index.js.map +1 -1
- package/dist/esm/stake.js +34 -299
- package/dist/esm/stake.js.map +1 -1
- package/dist/esm/treasury.js +162 -0
- package/dist/esm/treasury.js.map +1 -0
- package/dist/esm/user.js +153 -0
- package/dist/esm/user.js.map +1 -0
- package/dist/types/abis/LevrFactory_v1.d.ts +48 -0
- package/dist/types/abis/LevrGovernor_v1.d.ts +12 -18
- package/dist/types/abis/LevrStaking_v1.d.ts +5 -1
- package/dist/types/balance.d.ts +15 -0
- package/dist/types/balance.d.ts.map +1 -1
- package/dist/types/client/hook/index.d.ts +11 -3
- package/dist/types/client/hook/index.d.ts.map +1 -1
- package/dist/types/client/hook/use-fee-receivers.d.ts +6 -16
- package/dist/types/client/hook/use-fee-receivers.d.ts.map +1 -1
- package/dist/types/client/hook/use-governance.d.ts +4 -98
- package/dist/types/client/hook/use-governance.d.ts.map +1 -1
- package/dist/types/client/hook/use-pool.d.ts +12 -0
- package/dist/types/client/hook/use-pool.d.ts.map +1 -0
- package/dist/types/client/hook/use-prepare.d.ts +1 -2
- package/dist/types/client/hook/use-prepare.d.ts.map +1 -1
- package/dist/types/client/hook/use-project.d.ts +5 -0
- package/dist/types/client/hook/use-project.d.ts.map +1 -1
- package/dist/types/client/hook/use-proposal.d.ts +18 -0
- package/dist/types/client/hook/use-proposal.d.ts.map +1 -0
- package/dist/types/client/hook/use-stake.d.ts +14 -73
- package/dist/types/client/hook/use-stake.d.ts.map +1 -1
- package/dist/types/client/hook/use-swap.d.ts +3 -8
- package/dist/types/client/hook/use-swap.d.ts.map +1 -1
- package/dist/types/client/hook/use-user.d.ts +13 -0
- package/dist/types/client/hook/use-user.d.ts.map +1 -0
- package/dist/types/client/levr-provider.d.ts +30 -50
- package/dist/types/client/levr-provider.d.ts.map +1 -1
- package/dist/types/client/query-keys.d.ts +13 -25
- package/dist/types/client/query-keys.d.ts.map +1 -1
- package/dist/types/fee-receivers.d.ts +28 -0
- package/dist/types/fee-receivers.d.ts.map +1 -1
- package/dist/types/governance.d.ts +5 -92
- package/dist/types/governance.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/pool.d.ts +590 -0
- package/dist/types/pool.d.ts.map +1 -0
- package/dist/types/project.d.ts +56 -1
- package/dist/types/project.d.ts.map +1 -1
- package/dist/types/proposal.d.ts +1161 -0
- package/dist/types/proposal.d.ts.map +1 -0
- package/dist/types/quote/index.d.ts +2 -2
- package/dist/types/quote/index.d.ts.map +1 -1
- package/dist/types/stake.d.ts +16 -41
- package/dist/types/stake.d.ts.map +1 -1
- package/dist/types/treasury.d.ts +16 -0
- package/dist/types/treasury.d.ts.map +1 -0
- package/dist/types/user.d.ts +188 -0
- package/dist/types/user.d.ts.map +1 -0
- package/package.json +5 -2
- package/dist/esm/client/hook/use-balance.js +0 -57
- package/dist/esm/client/hook/use-balance.js.map +0 -1
- package/dist/esm/client/hook/use-projects.js +0 -22
- package/dist/esm/client/hook/use-projects.js.map +0 -1
- package/dist/esm/client/hook/use-proposals.js +0 -29
- package/dist/esm/client/hook/use-proposals.js.map +0 -1
- package/dist/esm/projects.js +0 -184
- package/dist/esm/projects.js.map +0 -1
- package/dist/esm/proposals.js +0 -98
- package/dist/esm/proposals.js.map +0 -1
- package/dist/types/client/hook/use-balance.d.ts +0 -20
- package/dist/types/client/hook/use-balance.d.ts.map +0 -1
- package/dist/types/client/hook/use-projects.d.ts +0 -6
- package/dist/types/client/hook/use-projects.d.ts.map +0 -1
- package/dist/types/client/hook/use-proposals.d.ts +0 -16
- package/dist/types/client/hook/use-proposals.d.ts.map +0 -1
- package/dist/types/projects.d.ts +0 -20
- package/dist/types/projects.d.ts.map +0 -1
- package/dist/types/proposals.d.ts +0 -20
- package/dist/types/proposals.d.ts.map +0 -1
|
@@ -185,6 +185,69 @@ export default [
|
|
|
185
185
|
],
|
|
186
186
|
stateMutability: 'view',
|
|
187
187
|
},
|
|
188
|
+
{
|
|
189
|
+
type: 'function',
|
|
190
|
+
name: 'getProjects',
|
|
191
|
+
inputs: [
|
|
192
|
+
{
|
|
193
|
+
name: 'offset',
|
|
194
|
+
type: 'uint256',
|
|
195
|
+
internalType: 'uint256',
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: 'limit',
|
|
199
|
+
type: 'uint256',
|
|
200
|
+
internalType: 'uint256',
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
outputs: [
|
|
204
|
+
{
|
|
205
|
+
name: 'projects',
|
|
206
|
+
type: 'tuple[]',
|
|
207
|
+
internalType: 'struct ILevrFactory_v1.ProjectInfo[]',
|
|
208
|
+
components: [
|
|
209
|
+
{
|
|
210
|
+
name: 'clankerToken',
|
|
211
|
+
type: 'address',
|
|
212
|
+
internalType: 'address',
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: 'project',
|
|
216
|
+
type: 'tuple',
|
|
217
|
+
internalType: 'struct ILevrFactory_v1.Project',
|
|
218
|
+
components: [
|
|
219
|
+
{
|
|
220
|
+
name: 'treasury',
|
|
221
|
+
type: 'address',
|
|
222
|
+
internalType: 'address',
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: 'governor',
|
|
226
|
+
type: 'address',
|
|
227
|
+
internalType: 'address',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: 'staking',
|
|
231
|
+
type: 'address',
|
|
232
|
+
internalType: 'address',
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
name: 'stakedToken',
|
|
236
|
+
type: 'address',
|
|
237
|
+
internalType: 'address',
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: 'total',
|
|
245
|
+
type: 'uint256',
|
|
246
|
+
internalType: 'uint256',
|
|
247
|
+
},
|
|
248
|
+
],
|
|
249
|
+
stateMutability: 'view',
|
|
250
|
+
},
|
|
188
251
|
{
|
|
189
252
|
type: 'function',
|
|
190
253
|
name: 'isTrustedForwarder',
|
|
@@ -179,6 +179,21 @@ export default [
|
|
|
179
179
|
type: 'uint256',
|
|
180
180
|
internalType: 'uint256',
|
|
181
181
|
},
|
|
182
|
+
{
|
|
183
|
+
name: 'state',
|
|
184
|
+
type: 'uint8',
|
|
185
|
+
internalType: 'enum ILevrGovernor_v1.ProposalState',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: 'meetsQuorum',
|
|
189
|
+
type: 'bool',
|
|
190
|
+
internalType: 'bool',
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: 'meetsApproval',
|
|
194
|
+
type: 'bool',
|
|
195
|
+
internalType: 'bool',
|
|
196
|
+
},
|
|
182
197
|
],
|
|
183
198
|
},
|
|
184
199
|
],
|
|
@@ -244,30 +259,6 @@ export default [
|
|
|
244
259
|
],
|
|
245
260
|
stateMutability: 'view',
|
|
246
261
|
},
|
|
247
|
-
{
|
|
248
|
-
type: 'function',
|
|
249
|
-
name: 'getVotingPowerSnapshot',
|
|
250
|
-
inputs: [
|
|
251
|
-
{
|
|
252
|
-
name: 'proposalId',
|
|
253
|
-
type: 'uint256',
|
|
254
|
-
internalType: 'uint256',
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
name: 'user',
|
|
258
|
-
type: 'address',
|
|
259
|
-
internalType: 'address',
|
|
260
|
-
},
|
|
261
|
-
],
|
|
262
|
-
outputs: [
|
|
263
|
-
{
|
|
264
|
-
name: '',
|
|
265
|
-
type: 'uint256',
|
|
266
|
-
internalType: 'uint256',
|
|
267
|
-
},
|
|
268
|
-
],
|
|
269
|
-
stateMutability: 'view',
|
|
270
|
-
},
|
|
271
262
|
{
|
|
272
263
|
type: 'function',
|
|
273
264
|
name: 'getWinner',
|
package/dist/esm/balance.js
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
import { erc20Abi, formatUnits, zeroAddress } from 'viem';
|
|
2
2
|
/**
|
|
3
3
|
* Calculate USD value for a balance
|
|
4
|
+
* @param formatted - Formatted token amount as string
|
|
5
|
+
* @param usdPrice - USD price as string
|
|
6
|
+
* @returns USD value as string
|
|
4
7
|
*/
|
|
5
|
-
const calculateUsd = (formatted, usdPrice) => {
|
|
8
|
+
export const calculateUsd = (formatted, usdPrice) => {
|
|
6
9
|
const amount = parseFloat(formatted);
|
|
7
10
|
const price = parseFloat(usdPrice);
|
|
8
11
|
return (amount * price).toString();
|
|
9
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Format a balance with optional USD value
|
|
15
|
+
* @param amount - Raw balance amount
|
|
16
|
+
* @param decimals - Token decimals
|
|
17
|
+
* @param usdPrice - Optional USD price (null if not available)
|
|
18
|
+
* @returns BalanceResult with raw, formatted, and optional USD value
|
|
19
|
+
*/
|
|
20
|
+
export const formatBalanceWithUsd = (amount, decimals, usdPrice) => {
|
|
21
|
+
const formatted = formatUnits(amount, decimals);
|
|
22
|
+
return {
|
|
23
|
+
raw: amount,
|
|
24
|
+
formatted,
|
|
25
|
+
usd: usdPrice ? (parseFloat(formatted) * usdPrice).toString() : undefined,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
10
28
|
/**
|
|
11
29
|
* Get balances for multiple tokens including native currency
|
|
12
30
|
* @param publicClient - The public client to use for queries
|
package/dist/esm/balance.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/balance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,MAAM,CAAA;AAiBzD
|
|
1
|
+
{"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/balance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,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,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;iBAClC,CAAA;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
|
@@ -2,14 +2,18 @@ import { useLevrContext } from "../levr-provider.js";
|
|
|
2
2
|
// ========================================
|
|
3
3
|
// SIMPLE CONTEXT ACCESSORS (one-liner exports)
|
|
4
4
|
// ========================================
|
|
5
|
+
/**
|
|
6
|
+
* Hook to access user data from LevrProvider (hierarchical)
|
|
7
|
+
*/
|
|
8
|
+
export const useUser = () => useLevrContext().user;
|
|
5
9
|
/**
|
|
6
10
|
* Hook to access project data from LevrProvider
|
|
7
11
|
*/
|
|
8
12
|
export const useProject = () => useLevrContext().project;
|
|
9
13
|
/**
|
|
10
|
-
* Hook to access
|
|
14
|
+
* Hook to access pool data from LevrProvider
|
|
11
15
|
*/
|
|
12
|
-
export const
|
|
16
|
+
export const usePool = () => useLevrContext().pool;
|
|
13
17
|
/**
|
|
14
18
|
* Hook to access proposals from LevrProvider
|
|
15
19
|
*/
|
|
@@ -27,10 +31,17 @@ export * from "./use-governance.js";
|
|
|
27
31
|
export * from "./use-stake.js";
|
|
28
32
|
export * from "./use-swap.js";
|
|
29
33
|
// ========================================
|
|
34
|
+
// INTERNAL HOOKS (used by LevrProvider)
|
|
35
|
+
// ========================================
|
|
36
|
+
export { usePoolQuery } from "./use-pool.js";
|
|
37
|
+
export { useProposalsQuery } from "./use-proposal.js";
|
|
38
|
+
export { useUserQuery } from "./use-user.js";
|
|
39
|
+
// ========================================
|
|
30
40
|
// OTHER HOOKS (not part of Levr context)
|
|
31
41
|
// ========================================
|
|
32
42
|
export * from "./use-deploy.js";
|
|
33
43
|
export * from "./use-prepare.js";
|
|
34
|
-
export * from "./use-
|
|
44
|
+
export * from "./use-project.js";
|
|
45
|
+
export { useProposal } from "./use-proposal.js";
|
|
35
46
|
export * from "./use-register.js";
|
|
36
47
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/hook/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,2CAA2C;AAC3C,+CAA+C;AAC/C,2CAA2C;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,OAAO,CAAA;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/hook/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,2CAA2C;AAC3C,+CAA+C;AAC/C,2CAA2C;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,IAAI,CAAA;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,OAAO,CAAA;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,IAAI,CAAA;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,SAAS,CAAA;AAE5D;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,SAAS,CAAA;AAE/D,2CAA2C;AAC3C,2CAA2C;AAC3C,2CAA2C;AAE3C,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAE1B,2CAA2C;AAC3C,wCAAwC;AACxC,2CAA2C;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEzC,2CAA2C;AAC3C,yCAAyC;AACzC,2CAA2C;AAE3C,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,cAAc,gBAAgB,CAAA"}
|
|
@@ -1,34 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useMutation
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { usePublicClient, useWalletClient } from "wagmi";
|
|
4
|
+
import { updateFeeReceiver } from "../../fee-receivers.js";
|
|
5
5
|
import { useLevrContext } from "../levr-provider.js";
|
|
6
|
-
import { queryKeys } from "../query-keys.js";
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Hook to access fee receivers and update mutations
|
|
8
|
+
* Fee receivers come from project.feeReceivers (with areYouAnAdmin already calculated)
|
|
10
9
|
*/
|
|
11
|
-
export function
|
|
12
|
-
const
|
|
13
|
-
const chainId = useChainId();
|
|
14
|
-
const { address: userAddress } = useAccount();
|
|
15
|
-
return useQuery({
|
|
16
|
-
queryKey: queryKeys.feeReceivers(clankerToken, userAddress, chainId),
|
|
17
|
-
queryFn: () => feeReceivers({
|
|
18
|
-
publicClient: publicClient,
|
|
19
|
-
clankerToken: clankerToken,
|
|
20
|
-
userAddress,
|
|
21
|
-
}),
|
|
22
|
-
enabled: e && !!publicClient && !!chainId && !!clankerToken,
|
|
23
|
-
staleTime: 15000,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Hook to access fee receivers query and mutations
|
|
28
|
-
* Returns both query data and mutation function
|
|
29
|
-
*/
|
|
30
|
-
export function useFeeReceivers({ clankerToken: _clankerToken, enabled: _e = true, onSuccess, onError, } = {}) {
|
|
31
|
-
const { feeReceivers: query, refetch } = useLevrContext();
|
|
10
|
+
export function useFeeReceivers({ onSuccess, onError } = {}) {
|
|
11
|
+
const { project, refetch } = useLevrContext();
|
|
32
12
|
const publicClient = usePublicClient();
|
|
33
13
|
const wallet = useWalletClient();
|
|
34
14
|
const chainId = publicClient?.chain?.id;
|
|
@@ -41,13 +21,15 @@ export function useFeeReceivers({ clankerToken: _clankerToken, enabled: _e = tru
|
|
|
41
21
|
newRecipient: params.newRecipient,
|
|
42
22
|
}),
|
|
43
23
|
onSuccess: async (hash) => {
|
|
44
|
-
await refetch.
|
|
24
|
+
await refetch.project(); // Refetch project to update fee receivers
|
|
45
25
|
onSuccess?.(hash);
|
|
46
26
|
},
|
|
47
27
|
onError: onError,
|
|
48
28
|
});
|
|
49
29
|
return {
|
|
50
|
-
|
|
30
|
+
data: project.data?.feeReceivers, // Already has areYouAnAdmin calculated!
|
|
31
|
+
isLoading: project.isLoading,
|
|
32
|
+
error: project.error,
|
|
51
33
|
mutate,
|
|
52
34
|
};
|
|
53
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-fee-receivers.js","sourceRoot":"","sources":["../../../../src/client/hook/use-fee-receivers.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"use-fee-receivers.js","sourceRoot":"","sources":["../../../../src/client/hook/use-fee-receivers.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AAGxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAcjD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,EAAE,SAAS,EAAE,OAAO,KAA4B,EAAE;IAChF,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,CAAA;IAC7C,MAAM,YAAY,GAAG,eAAe,EAAE,CAAA;IACtC,MAAM,MAAM,GAAG,eAAe,EAAE,CAAA;IAChC,MAAM,OAAO,GAAG,YAAY,EAAE,KAAK,EAAE,EAAE,CAAA;IAEvC,MAAM,MAAM,GAAG,WAAW,CAAC;QACzB,UAAU,EAAE,CAAC,MAAiE,EAAE,EAAE,CAChF,iBAAiB,CAAC;YAChB,YAAY,EAAE,MAAM,CAAC,IAAK;YAC1B,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,OAAO,EAAE,OAAQ;YACjB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CAAC;QACJ,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YACxB,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA,CAAC,0CAA0C;YAClE,SAAS,EAAE,CAAC,IAAI,CAAC,CAAA;QACnB,CAAC;QACD,OAAO,EAAE,OAAO;KACjB,CAAC,CAAA;IAEF,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,wCAAwC;QAC1E,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM;KACP,CAAA;AACH,CAAC"}
|
|
@@ -1,183 +1,29 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useMutation
|
|
2
|
+
import { useMutation } from "@tanstack/react-query";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
4
|
import { parseUnits } from "viem";
|
|
5
5
|
import { usePublicClient, useWalletClient } from "wagmi";
|
|
6
6
|
import { Governance } from "../../governance.js";
|
|
7
7
|
import { useLevrContext } from "../levr-provider.js";
|
|
8
|
-
import { queryKeys } from "../query-keys.js";
|
|
9
|
-
/**
|
|
10
|
-
* Internal: Creates global governance queries with all logic
|
|
11
|
-
* Used by LevrProvider
|
|
12
|
-
*/
|
|
13
|
-
export function useGovernanceQueries({ clankerToken, projectData, enabled: e = true, }) {
|
|
14
|
-
const wallet = useWalletClient();
|
|
15
|
-
const publicClient = usePublicClient();
|
|
16
|
-
// Create Governance instance
|
|
17
|
-
const governance = useMemo(() => {
|
|
18
|
-
if (!wallet.data || !publicClient || !projectData || !clankerToken) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
return new Governance({
|
|
22
|
-
wallet: wallet.data,
|
|
23
|
-
publicClient,
|
|
24
|
-
governorAddress: projectData.governor,
|
|
25
|
-
tokenDecimals: projectData.token.decimals,
|
|
26
|
-
clankerToken,
|
|
27
|
-
pricing: projectData.pricing,
|
|
28
|
-
});
|
|
29
|
-
}, [wallet.data, publicClient, projectData, clankerToken]);
|
|
30
|
-
const currentCycleId = useQuery({
|
|
31
|
-
queryKey: queryKeys.governance.currentCycleId(projectData?.governor),
|
|
32
|
-
queryFn: async () => {
|
|
33
|
-
return await governance.getCurrentCycleId();
|
|
34
|
-
},
|
|
35
|
-
enabled: e && !!governance && !!projectData,
|
|
36
|
-
retry: 1,
|
|
37
|
-
});
|
|
38
|
-
const addresses = useQuery({
|
|
39
|
-
queryKey: queryKeys.governance.addresses(projectData?.governor),
|
|
40
|
-
queryFn: async () => {
|
|
41
|
-
const [treasury, factory, stakedToken] = await Promise.all([
|
|
42
|
-
governance.getTreasury(),
|
|
43
|
-
governance.getFactory(),
|
|
44
|
-
governance.getStakedToken(),
|
|
45
|
-
]);
|
|
46
|
-
return { treasury, factory, stakedToken };
|
|
47
|
-
},
|
|
48
|
-
enabled: e && !!governance && !!projectData,
|
|
49
|
-
retry: 1,
|
|
50
|
-
});
|
|
51
|
-
const airdropStatus = useQuery({
|
|
52
|
-
queryKey: queryKeys.governance.airdropStatus(projectData?.governor, clankerToken),
|
|
53
|
-
queryFn: async () => {
|
|
54
|
-
return await governance.getAirdropStatus();
|
|
55
|
-
},
|
|
56
|
-
enabled: e && !!governance && !!projectData && !!clankerToken,
|
|
57
|
-
retry: 1,
|
|
58
|
-
refetchInterval: 30000,
|
|
59
|
-
});
|
|
60
|
-
return {
|
|
61
|
-
currentCycleId,
|
|
62
|
-
addresses,
|
|
63
|
-
airdropStatus,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
8
|
/**
|
|
67
9
|
* Hook for managing governance operations
|
|
68
|
-
*
|
|
10
|
+
* All data comes from context (user, project)
|
|
69
11
|
*/
|
|
70
|
-
export function useGovernance({
|
|
71
|
-
const {
|
|
12
|
+
export function useGovernance({ proposalId, cycleId, userAddress, onProposeTransferSuccess, onProposeTransferError, onProposeBoostSuccess, onProposeBoostError, onVoteSuccess, onVoteError, onExecuteProposalSuccess, onExecuteProposalError, onClaimAirdropSuccess, onClaimAirdropError, } = {}) {
|
|
13
|
+
const { project, refetch } = useLevrContext();
|
|
72
14
|
const wallet = useWalletClient();
|
|
73
15
|
const publicClient = usePublicClient();
|
|
74
|
-
// Create Governance instance
|
|
16
|
+
// Create Governance instance (all params from project context)
|
|
75
17
|
const governance = useMemo(() => {
|
|
76
|
-
if (!wallet.data || !publicClient || !project.data
|
|
18
|
+
if (!wallet.data || !publicClient || !project.data) {
|
|
77
19
|
return null;
|
|
78
20
|
}
|
|
79
21
|
return new Governance({
|
|
80
22
|
wallet: wallet.data,
|
|
81
23
|
publicClient,
|
|
82
|
-
|
|
83
|
-
tokenDecimals: project.data.token.decimals,
|
|
84
|
-
clankerToken,
|
|
85
|
-
pricing: project.data.pricing,
|
|
24
|
+
project: project.data,
|
|
86
25
|
});
|
|
87
|
-
}, [wallet.data, publicClient, project.data
|
|
88
|
-
// Global queries from context
|
|
89
|
-
const currentCycleId = governanceQueries.currentCycleId;
|
|
90
|
-
const addresses = governanceQueries.addresses;
|
|
91
|
-
const airdropStatus = governanceQueries.airdropStatus;
|
|
92
|
-
// Dynamic queries (component-specific)
|
|
93
|
-
const proposal = useQuery({
|
|
94
|
-
queryKey: queryKeys.governance.proposal(governorAddress, proposalId?.toString()),
|
|
95
|
-
queryFn: async () => {
|
|
96
|
-
return await governance.getProposal(proposalId);
|
|
97
|
-
},
|
|
98
|
-
enabled: enabled && !!governance && proposalId !== undefined,
|
|
99
|
-
retry: 1,
|
|
100
|
-
});
|
|
101
|
-
const proposalsForCycle = useQuery({
|
|
102
|
-
queryKey: queryKeys.governance.proposalsForCycle(governorAddress, cycleId?.toString()),
|
|
103
|
-
queryFn: async () => {
|
|
104
|
-
return await governance.getProposalsForCycle(cycleId);
|
|
105
|
-
},
|
|
106
|
-
enabled: enabled && !!governance && cycleId !== undefined,
|
|
107
|
-
retry: 1,
|
|
108
|
-
});
|
|
109
|
-
const winner = useQuery({
|
|
110
|
-
queryKey: queryKeys.governance.winner(governorAddress, cycleId?.toString()),
|
|
111
|
-
queryFn: async () => {
|
|
112
|
-
return await governance.getWinner(cycleId);
|
|
113
|
-
},
|
|
114
|
-
enabled: enabled && !!governance && cycleId !== undefined,
|
|
115
|
-
retry: 1,
|
|
116
|
-
});
|
|
117
|
-
const voteReceipt = useQuery({
|
|
118
|
-
queryKey: [
|
|
119
|
-
"governance",
|
|
120
|
-
"voteReceipt",
|
|
121
|
-
governorAddress,
|
|
122
|
-
proposalId?.toString(),
|
|
123
|
-
userAddress || wallet.data?.account.address,
|
|
124
|
-
],
|
|
125
|
-
queryFn: async () => {
|
|
126
|
-
return await governance.getVoteReceipt(proposalId, userAddress);
|
|
127
|
-
},
|
|
128
|
-
enabled: enabled && !!governance && proposalId !== undefined,
|
|
129
|
-
retry: 1,
|
|
130
|
-
});
|
|
131
|
-
const votingPowerSnapshot = useQuery({
|
|
132
|
-
queryKey: [
|
|
133
|
-
"governance",
|
|
134
|
-
"votingPowerSnapshot",
|
|
135
|
-
governorAddress,
|
|
136
|
-
proposalId?.toString(),
|
|
137
|
-
userAddress || wallet.data?.account.address,
|
|
138
|
-
],
|
|
139
|
-
queryFn: async () => {
|
|
140
|
-
return await governance.getVotingPowerSnapshot(proposalId, userAddress);
|
|
141
|
-
},
|
|
142
|
-
enabled: enabled && !!governance && proposalId !== undefined,
|
|
143
|
-
retry: 1,
|
|
144
|
-
});
|
|
145
|
-
const meetsQuorum = useQuery({
|
|
146
|
-
queryKey: ["governance", "meetsQuorum", governorAddress, proposalId?.toString()],
|
|
147
|
-
queryFn: async () => {
|
|
148
|
-
return await governance.meetsQuorum(proposalId);
|
|
149
|
-
},
|
|
150
|
-
enabled: enabled && !!governance && proposalId !== undefined,
|
|
151
|
-
retry: 1,
|
|
152
|
-
});
|
|
153
|
-
const meetsApproval = useQuery({
|
|
154
|
-
queryKey: ["governance", "meetsApproval", governorAddress, proposalId?.toString()],
|
|
155
|
-
queryFn: async () => {
|
|
156
|
-
return await governance.meetsApproval(proposalId);
|
|
157
|
-
},
|
|
158
|
-
enabled: enabled && !!governance && proposalId !== undefined,
|
|
159
|
-
retry: 1,
|
|
160
|
-
});
|
|
161
|
-
const proposalState = useQuery({
|
|
162
|
-
queryKey: ["governance", "proposalState", governorAddress, proposalId?.toString()],
|
|
163
|
-
queryFn: async () => {
|
|
164
|
-
return await governance.getProposalState(proposalId);
|
|
165
|
-
},
|
|
166
|
-
enabled: enabled && !!governance && proposalId !== undefined,
|
|
167
|
-
retry: 1,
|
|
168
|
-
});
|
|
169
|
-
const activeProposalCount = useQuery({
|
|
170
|
-
queryKey: ["governance", "activeProposalCount", governorAddress],
|
|
171
|
-
queryFn: async () => {
|
|
172
|
-
const [boostCount, transferCount] = await Promise.all([
|
|
173
|
-
governance.getActiveProposalCount(0),
|
|
174
|
-
governance.getActiveProposalCount(1),
|
|
175
|
-
]);
|
|
176
|
-
return { boost: boostCount, transfer: transferCount };
|
|
177
|
-
},
|
|
178
|
-
enabled: enabled && !!governance,
|
|
179
|
-
retry: 1,
|
|
180
|
-
});
|
|
26
|
+
}, [wallet.data, publicClient, project.data]);
|
|
181
27
|
// Mutations
|
|
182
28
|
const vote = useMutation({
|
|
183
29
|
mutationFn: async ({ proposalId, support, }) => {
|
|
@@ -188,7 +34,7 @@ export function useGovernance({ governorAddress, clankerToken: _clankerToken, to
|
|
|
188
34
|
return await governance.vote(proposalId, support);
|
|
189
35
|
},
|
|
190
36
|
onSuccess: async (receipt) => {
|
|
191
|
-
await refetch.
|
|
37
|
+
await refetch.afterVote();
|
|
192
38
|
onVoteSuccess?.(receipt);
|
|
193
39
|
},
|
|
194
40
|
onError: onVoteError,
|
|
@@ -204,7 +50,7 @@ export function useGovernance({ governorAddress, clankerToken: _clankerToken, to
|
|
|
204
50
|
return result;
|
|
205
51
|
},
|
|
206
52
|
onSuccess: async (result) => {
|
|
207
|
-
await refetch.
|
|
53
|
+
await refetch.afterProposal();
|
|
208
54
|
onProposeTransferSuccess?.(result.receipt, result.proposalId);
|
|
209
55
|
},
|
|
210
56
|
onError: onProposeTransferError,
|
|
@@ -220,7 +66,7 @@ export function useGovernance({ governorAddress, clankerToken: _clankerToken, to
|
|
|
220
66
|
return result;
|
|
221
67
|
},
|
|
222
68
|
onSuccess: async (result) => {
|
|
223
|
-
await refetch.
|
|
69
|
+
await refetch.afterProposal();
|
|
224
70
|
onProposeBoostSuccess?.(result.receipt, result.proposalId);
|
|
225
71
|
},
|
|
226
72
|
onError: onProposeBoostError,
|
|
@@ -235,7 +81,7 @@ export function useGovernance({ governorAddress, clankerToken: _clankerToken, to
|
|
|
235
81
|
return receipt;
|
|
236
82
|
},
|
|
237
83
|
onSuccess: async (receipt) => {
|
|
238
|
-
await refetch.
|
|
84
|
+
await refetch.afterExecute();
|
|
239
85
|
onExecuteProposalSuccess?.(receipt);
|
|
240
86
|
},
|
|
241
87
|
onError: onExecuteProposalError,
|
|
@@ -249,119 +95,38 @@ export function useGovernance({ governorAddress, clankerToken: _clankerToken, to
|
|
|
249
95
|
return await governance.claimAirdrop();
|
|
250
96
|
},
|
|
251
97
|
onSuccess: async (receipt) => {
|
|
252
|
-
await refetch.
|
|
98
|
+
await refetch.afterAirdrop();
|
|
253
99
|
onClaimAirdropSuccess?.(receipt);
|
|
254
100
|
},
|
|
255
101
|
onError: onClaimAirdropError,
|
|
256
102
|
});
|
|
257
|
-
const proposeAndExecuteTransfer = useMutation({
|
|
258
|
-
mutationFn: async (config) => {
|
|
259
|
-
if (!governance)
|
|
260
|
-
throw new Error("Governance not initialized");
|
|
261
|
-
const amountBigInt = parseUnits(config.amount, config.amountDecimals);
|
|
262
|
-
const result = await governance.proposeAndExecuteTransfer(config.recipient, amountBigInt, config.description);
|
|
263
|
-
return result;
|
|
264
|
-
},
|
|
265
|
-
onSuccess: async () => {
|
|
266
|
-
await refetch.afterGovernance();
|
|
267
|
-
},
|
|
268
|
-
});
|
|
269
|
-
const proposeAndExecuteBoost = useMutation({
|
|
270
|
-
mutationFn: async (config) => {
|
|
271
|
-
if (!governance)
|
|
272
|
-
throw new Error("Governance not initialized");
|
|
273
|
-
const amountBigInt = parseUnits(config.amount, config.amountDecimals);
|
|
274
|
-
const result = await governance.proposeAndExecuteBoost(amountBigInt);
|
|
275
|
-
return result;
|
|
276
|
-
},
|
|
277
|
-
onSuccess: async () => {
|
|
278
|
-
await refetch.afterGovernance();
|
|
279
|
-
},
|
|
280
|
-
});
|
|
281
103
|
// Helpers
|
|
282
|
-
const buildProposeTransferConfig = ({ recipient, amount, amountDecimals
|
|
104
|
+
const buildProposeTransferConfig = ({ recipient, amount, amountDecimals, description, }) => ({
|
|
283
105
|
recipient,
|
|
284
106
|
amount: amount.toString(),
|
|
285
|
-
amountDecimals,
|
|
107
|
+
amountDecimals: amountDecimals ?? project.data?.token.decimals ?? 18,
|
|
286
108
|
description,
|
|
287
109
|
});
|
|
288
|
-
const buildProposeBoostConfig = ({ amount, amountDecimals
|
|
110
|
+
const buildProposeBoostConfig = ({ amount, amountDecimals, }) => ({
|
|
289
111
|
amount: amount.toString(),
|
|
290
|
-
amountDecimals,
|
|
112
|
+
amountDecimals: amountDecimals ?? project.data?.token.decimals ?? 18,
|
|
291
113
|
});
|
|
292
114
|
const buildExecuteProposalConfig = ({ proposalId, }) => ({
|
|
293
115
|
proposalId,
|
|
294
116
|
});
|
|
295
117
|
return {
|
|
296
|
-
//
|
|
118
|
+
// Mutations
|
|
297
119
|
proposeTransfer,
|
|
298
120
|
proposeBoost,
|
|
299
121
|
vote,
|
|
300
122
|
executeProposal,
|
|
301
123
|
claimAirdrop,
|
|
302
|
-
// Convenience mutations
|
|
303
|
-
proposeAndExecuteTransfer,
|
|
304
|
-
proposeAndExecuteBoost,
|
|
305
|
-
// Queries
|
|
306
|
-
proposal,
|
|
307
|
-
currentCycleId,
|
|
308
|
-
addresses,
|
|
309
|
-
airdropStatus,
|
|
310
|
-
proposalsForCycle,
|
|
311
|
-
winner,
|
|
312
|
-
voteReceipt,
|
|
313
|
-
votingPowerSnapshot,
|
|
314
|
-
meetsQuorum,
|
|
315
|
-
meetsApproval,
|
|
316
|
-
proposalState,
|
|
317
|
-
activeProposalCount,
|
|
318
|
-
// Convenience accessors - proposal data
|
|
319
|
-
proposalData: proposal.data,
|
|
320
|
-
proposalDescription: proposal.data?.description,
|
|
321
|
-
// Convenience accessors - cycle data
|
|
322
|
-
currentCycleIdValue: currentCycleId.data,
|
|
323
|
-
cycleProposals: proposalsForCycle.data,
|
|
324
|
-
winnerProposalId: winner.data,
|
|
325
|
-
// Convenience accessors - vote data
|
|
326
|
-
hasVoted: voteReceipt.data?.hasVoted ?? false,
|
|
327
|
-
voteSupport: voteReceipt.data?.support,
|
|
328
|
-
votesUsed: voteReceipt.data?.votes,
|
|
329
|
-
userVotingPower: votingPowerSnapshot.data,
|
|
330
|
-
// Convenience accessors - proposal status
|
|
331
|
-
proposalMeetsQuorum: meetsQuorum.data ?? false,
|
|
332
|
-
proposalMeetsApproval: meetsApproval.data ?? false,
|
|
333
|
-
proposalStateValue: proposalState.data,
|
|
334
|
-
// Convenience accessors - active counts
|
|
335
|
-
activeBoostProposals: activeProposalCount.data?.boost,
|
|
336
|
-
activeTransferProposals: activeProposalCount.data?.transfer,
|
|
337
|
-
// Convenience accessors - addresses
|
|
338
|
-
treasuryAddress: addresses.data?.treasury,
|
|
339
|
-
factoryAddress: addresses.data?.factory,
|
|
340
|
-
stakedTokenAddress: addresses.data?.stakedToken,
|
|
341
|
-
// Convenience accessors - airdrop
|
|
342
|
-
airdropStatusData: airdropStatus.data,
|
|
343
|
-
availableAirdropAmount: airdropStatus.data?.availableAmount,
|
|
344
|
-
airdropAllocatedAmount: airdropStatus.data?.allocatedAmount,
|
|
345
|
-
isAirdropAvailable: airdropStatus.data?.isAvailable ?? false,
|
|
346
|
-
airdropError: airdropStatus.data?.error,
|
|
347
124
|
// Helpers
|
|
348
125
|
buildProposeTransferConfig,
|
|
349
126
|
buildProposeBoostConfig,
|
|
350
127
|
buildExecuteProposalConfig,
|
|
351
|
-
//
|
|
128
|
+
// Loading states
|
|
352
129
|
isReady: !!governance && !!wallet.data,
|
|
353
|
-
isLoading: proposal.isLoading ||
|
|
354
|
-
currentCycleId.isLoading ||
|
|
355
|
-
addresses.isLoading ||
|
|
356
|
-
airdropStatus.isLoading ||
|
|
357
|
-
proposalsForCycle.isLoading ||
|
|
358
|
-
winner.isLoading ||
|
|
359
|
-
voteReceipt.isLoading ||
|
|
360
|
-
votingPowerSnapshot.isLoading ||
|
|
361
|
-
meetsQuorum.isLoading ||
|
|
362
|
-
meetsApproval.isLoading ||
|
|
363
|
-
proposalState.isLoading ||
|
|
364
|
-
activeProposalCount.isLoading,
|
|
365
130
|
isProposing: proposeTransfer.isPending || proposeBoost.isPending,
|
|
366
131
|
isVoting: vote.isPending,
|
|
367
132
|
isExecuting: executeProposal.isPending,
|