levr-sdk 0.0.1 → 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/README.md +109 -13
- 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/abis/StateView.js +149 -0
- package/dist/esm/abis/V3QuoterV2.js +26 -0
- package/dist/esm/abis/index.js +4 -0
- package/dist/esm/balance.js +48 -4
- 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 -30
- package/dist/esm/client/hook/use-fee-receivers.js.map +1 -1
- package/dist/esm/client/hook/use-governance.js +20 -274
- 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 +28 -16
- 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 -215
- package/dist/esm/client/hook/use-stake.js.map +1 -1
- package/dist/esm/client/hook/use-swap.js +23 -19
- 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 +73 -108
- package/dist/esm/client/levr-provider.js.map +1 -1
- package/dist/esm/client/query-keys.js +10 -22
- package/dist/esm/client/query-keys.js.map +1 -1
- package/dist/esm/constants.js +42 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/fee-receivers.js +28 -13
- package/dist/esm/fee-receivers.js.map +1 -1
- package/dist/esm/governance.js +35 -399
- package/dist/esm/governance.js.map +1 -1
- package/dist/esm/index.js +7 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/pool-key.js +152 -0
- package/dist/esm/pool-key.js.map +1 -0
- package/dist/esm/pool.js +70 -0
- package/dist/esm/pool.js.map +1 -0
- package/dist/esm/project.js +415 -118
- 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 +98 -0
- package/dist/esm/quote/index.js.map +1 -0
- package/dist/esm/quote/v3.js +62 -0
- package/dist/esm/quote/v3.js.map +1 -0
- package/dist/esm/quote/v4.js +228 -0
- package/dist/esm/quote/v4.js.map +1 -0
- package/dist/esm/stake.js +34 -237
- 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/usd-price.js +149 -0
- package/dist/esm/usd-price.js.map +1 -0
- package/dist/esm/user.js +153 -0
- package/dist/esm/user.js.map +1 -0
- package/dist/esm/util.js +45 -1
- package/dist/esm/util.js.map +1 -1
- 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/abis/StateView.d.ts +278 -0
- package/dist/types/abis/V3QuoterV2.d.ts +39 -0
- package/dist/types/abis/index.d.ts +2 -0
- package/dist/types/balance.d.ts +19 -6
- package/dist/types/balance.d.ts.map +1 -1
- package/dist/types/client/hook/index.d.ts +12 -4
- 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 -93
- 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 +8 -1
- 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 -168
- package/dist/types/client/hook/use-stake.d.ts.map +1 -1
- package/dist/types/client/hook/use-swap.d.ts +5 -9
- 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 +41 -68
- package/dist/types/client/levr-provider.d.ts.map +1 -1
- package/dist/types/client/query-keys.d.ts +14 -26
- package/dist/types/client/query-keys.d.ts.map +1 -1
- package/dist/types/constants.d.ts +18 -0
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/fee-receivers.d.ts +29 -2
- package/dist/types/fee-receivers.d.ts.map +1 -1
- package/dist/types/governance.d.ts +8 -108
- package/dist/types/governance.d.ts.map +1 -1
- package/dist/types/index.d.ts +7 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/pool-key.d.ts +121 -0
- package/dist/types/pool-key.d.ts.map +1 -0
- package/dist/types/pool.d.ts +590 -0
- package/dist/types/pool.d.ts.map +1 -0
- package/dist/types/project.d.ts +61 -11
- 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 +97 -0
- package/dist/types/quote/index.d.ts.map +1 -0
- package/dist/types/quote/v3.d.ts +78 -0
- package/dist/types/quote/v3.d.ts.map +1 -0
- package/dist/types/quote/v4.d.ts +95 -0
- package/dist/types/quote/v4.d.ts.map +1 -0
- package/dist/types/stake.d.ts +41 -87
- 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/types.d.ts +15 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/usd-price.d.ts +141 -0
- package/dist/types/usd-price.d.ts.map +1 -0
- package/dist/types/user.d.ts +188 -0
- package/dist/types/user.d.ts.map +1 -0
- package/dist/types/util.d.ts +17 -0
- package/dist/types/util.d.ts.map +1 -1
- package/package.json +5 -2
- package/dist/esm/client/hook/use-balance.js +0 -56
- 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 -31
- package/dist/esm/client/hook/use-proposals.js.map +0 -1
- package/dist/esm/projects.js +0 -212
- 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/esm/quote-v4.js +0 -169
- package/dist/esm/quote-v4.js.map +0 -1
- package/dist/types/client/hook/use-balance.d.ts +0 -18
- 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
- package/dist/types/quote-v4.d.ts +0 -54
- package/dist/types/quote-v4.d.ts.map +0 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { formatUnits, parseUnits } from "viem";
|
|
2
|
+
import { GET_USDC_ADDRESS, UNISWAP_V3_QUOTER_V2, WETH } from "./constants.js";
|
|
3
|
+
import { createPoolKey } from "./pool-key.js";
|
|
4
|
+
import { quote } from "./quote/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* @description Get the USD price of WETH from a WETH/USDC pool using Uniswap V3
|
|
7
|
+
*
|
|
8
|
+
* @param params Parameters for WETH/USD price oracle
|
|
9
|
+
* @returns WETH price in USD and raw quote data
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* This function queries Uniswap V3 WETH/USDC pools for accurate pricing.
|
|
13
|
+
* V3 is used instead of V4 because V3 has much deeper liquidity on most chains.
|
|
14
|
+
*
|
|
15
|
+
* The function:
|
|
16
|
+
* 1. Tries common V3 fee tiers (0.3%, 0.05%, 1%) in order of preference
|
|
17
|
+
* 2. Quotes 1 WETH to get USDC output
|
|
18
|
+
* 3. Returns the first successful quote
|
|
19
|
+
*
|
|
20
|
+
* This is commonly used as a price oracle for other token pricing calculations.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // Get current WETH price on Base mainnet
|
|
25
|
+
* const { priceUsd, fee } = await getWethUsdPrice({
|
|
26
|
+
* publicClient: baseMainnetClient,
|
|
27
|
+
* })
|
|
28
|
+
* console.log(`WETH price: $${priceUsd} (from ${fee/10000}% pool)`)
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export const getWethUsdPrice = async ({ publicClient, }) => {
|
|
32
|
+
// Get chain ID from client
|
|
33
|
+
const chainId = publicClient.chain?.id;
|
|
34
|
+
if (!chainId) {
|
|
35
|
+
throw new Error("Chain ID not found on public client");
|
|
36
|
+
}
|
|
37
|
+
// Get V3 Quoter address
|
|
38
|
+
const quoterAddress = UNISWAP_V3_QUOTER_V2(chainId);
|
|
39
|
+
if (!quoterAddress) {
|
|
40
|
+
throw new Error(`V3 Quoter address not found for chain ID ${chainId}`);
|
|
41
|
+
}
|
|
42
|
+
// Get WETH and USDC addresses
|
|
43
|
+
const wethData = WETH(chainId);
|
|
44
|
+
const usdcAddress = GET_USDC_ADDRESS(chainId);
|
|
45
|
+
if (!wethData) {
|
|
46
|
+
throw new Error(`WETH address not found for chain ID ${chainId}`);
|
|
47
|
+
}
|
|
48
|
+
if (!usdcAddress) {
|
|
49
|
+
throw new Error(`USDC address not found for chain ID ${chainId}`);
|
|
50
|
+
}
|
|
51
|
+
// V3 fee tiers (in order of preference for WETH/USDC)
|
|
52
|
+
const V3_FEE_TIERS = [3000, 500, 10000]; // 0.3%, 0.05%, 1%
|
|
53
|
+
// Try each V3 fee tier
|
|
54
|
+
for (const fee of V3_FEE_TIERS) {
|
|
55
|
+
try {
|
|
56
|
+
const oneWeth = parseUnits("1", wethData.decimals);
|
|
57
|
+
const quoteResult = await quote.v3.read({
|
|
58
|
+
publicClient,
|
|
59
|
+
quoterAddress,
|
|
60
|
+
tokenIn: wethData.address,
|
|
61
|
+
tokenOut: usdcAddress,
|
|
62
|
+
amountIn: oneWeth,
|
|
63
|
+
fee,
|
|
64
|
+
});
|
|
65
|
+
if (quoteResult.amountOut > 0n) {
|
|
66
|
+
const priceUsd = formatUnits(quoteResult.amountOut, 6);
|
|
67
|
+
return {
|
|
68
|
+
priceUsd,
|
|
69
|
+
wethPerUsdc: quoteResult.amountOut,
|
|
70
|
+
fee,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
// This fee tier doesn't work, try next
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
throw new Error("No liquid WETH/USDC V3 pool found");
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* @description Get the USD price of a token paired with WETH
|
|
83
|
+
*
|
|
84
|
+
* @param params Parameters including token addresses and chain config
|
|
85
|
+
* @returns USD price and intermediate price ratios
|
|
86
|
+
*
|
|
87
|
+
* @remarks
|
|
88
|
+
* This function calculates the USD price of a token by:
|
|
89
|
+
* 1. Auto-discovering and querying a liquid WETH/USDC pool (oracle chain)
|
|
90
|
+
* 2. Getting the price of the token in WETH (quote chain)
|
|
91
|
+
* 3. Multiplying them together to get token price in USD
|
|
92
|
+
*
|
|
93
|
+
* The paired token must be WETH, otherwise an error is thrown.
|
|
94
|
+
* USD pricing always uses USDC as the stable reference.
|
|
95
|
+
*
|
|
96
|
+
* This design allows you to:
|
|
97
|
+
* - Use mainnet for accurate WETH/USDC prices (oracle auto-discovers pool)
|
|
98
|
+
* - Quote tokens from any chain (testnet, L2, etc.)
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* // Get testnet token price using mainnet oracle
|
|
103
|
+
* const { priceUsd } = await getUsdPrice({
|
|
104
|
+
* oraclePublicClient: mainnetClient,
|
|
105
|
+
* quotePublicClient: testnetClient,
|
|
106
|
+
* tokenAddress: '0x123...',
|
|
107
|
+
* })
|
|
108
|
+
* console.log(`Token price: $${priceUsd}`)
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export const getUsdPrice = async ({ oraclePublicClient, quotePublicClient, tokenAddress, quoteFee, quoteTickSpacing, quoteHooks, }) => {
|
|
112
|
+
// Get chain ID from quote client
|
|
113
|
+
const quoteChainId = quotePublicClient.chain?.id;
|
|
114
|
+
if (!quoteChainId) {
|
|
115
|
+
throw new Error("Chain ID not found on quote public client");
|
|
116
|
+
}
|
|
117
|
+
// Get WETH address for quote chain (token is always paired with WETH)
|
|
118
|
+
const quoteWethData = WETH(quoteChainId);
|
|
119
|
+
if (!quoteWethData) {
|
|
120
|
+
throw new Error(`WETH address not found for quote chain ID ${quoteChainId}`);
|
|
121
|
+
}
|
|
122
|
+
// Get WETH/USD price from oracle (automatically discovers best pool)
|
|
123
|
+
const wethUsdPriceData = await getWethUsdPrice({
|
|
124
|
+
publicClient: oraclePublicClient,
|
|
125
|
+
});
|
|
126
|
+
// Create pool key for token/WETH
|
|
127
|
+
const tokenWethPoolKey = createPoolKey(tokenAddress, quoteWethData.address, quoteFee, quoteTickSpacing, quoteHooks);
|
|
128
|
+
// Determine trade direction based on sorted currencies
|
|
129
|
+
const tokenIsToken0InTokenWethPool = tokenAddress.toLowerCase() < quoteWethData.address.toLowerCase();
|
|
130
|
+
// Quote 1 token unit -> WETH to get token price in WETH (on quote chain)
|
|
131
|
+
// Using token decimals (assume 18 if not available)
|
|
132
|
+
const oneToken = parseUnits("1", 18);
|
|
133
|
+
const tokenWethQuote = await quote.v4.read({
|
|
134
|
+
publicClient: quotePublicClient,
|
|
135
|
+
poolKey: tokenWethPoolKey,
|
|
136
|
+
zeroForOne: tokenIsToken0InTokenWethPool,
|
|
137
|
+
amountIn: oneToken,
|
|
138
|
+
});
|
|
139
|
+
// WETH has 18 decimals
|
|
140
|
+
const tokenPriceInWeth = formatUnits(tokenWethQuote.amountOut, 18);
|
|
141
|
+
// Calculate USD price: (token/WETH) * (WETH/USD) = token/USD
|
|
142
|
+
const tokenPriceInUsd = parseFloat(tokenPriceInWeth) * parseFloat(wethUsdPriceData.priceUsd);
|
|
143
|
+
return {
|
|
144
|
+
priceUsd: tokenPriceInUsd.toFixed(6),
|
|
145
|
+
tokenPerWeth: tokenWethQuote.amountOut,
|
|
146
|
+
wethPerUsdc: wethUsdPriceData.wethPerUsdc,
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
//# sourceMappingURL=usd-price.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usd-price.js","sourceRoot":"","sources":["../../src/usd-price.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAE9C,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AA+B/B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,EACpC,YAAY,GACU,EAAsC,EAAE;IAC9D,2BAA2B;IAC3B,MAAM,OAAO,GAAG,YAA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AM,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;IACpC,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC;QACzC,YAAY,EAAE,iBAAiB;QAC/B,OAAO,EAAE,gBAAgB;QACzB,UAAU,EAAE,4BAA4B;QACxC,QAAQ,EAAE,QAAQ;KACnB,CAAC,CAAA;IAEF,uBAAuB;IACvB,MAAM,gBAAgB,GAAG,WAAW,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;IAElE,6DAA6D;IAC7D,MAAM,eAAe,GAAG,UAAU,CAAC,gBAAgB,CAAC,GAAG,UAAU,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IAE5F,OAAO;QACL,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;QACpC,YAAY,EAAE,cAAc,CAAC,SAAS;QACtC,WAAW,EAAE,gBAAgB,CAAC,WAAW;KAC1C,CAAA;AACH,CAAC,CAAA"}
|
package/dist/esm/user.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { erc20Abi } from "viem";
|
|
2
|
+
import { LevrStaking_v1 } from "./abis/index.js";
|
|
3
|
+
import { formatBalanceWithUsd } from "./balance.js";
|
|
4
|
+
import { WETH } from "./constants.js";
|
|
5
|
+
// ========================================
|
|
6
|
+
// HELPER UTILS (for composition in larger multicalls)
|
|
7
|
+
// ========================================
|
|
8
|
+
/**
|
|
9
|
+
* Helper: Get balance contracts for multicall composition
|
|
10
|
+
*/
|
|
11
|
+
export function balanceContracts(params) {
|
|
12
|
+
const contracts = [
|
|
13
|
+
{
|
|
14
|
+
address: params.clankerToken,
|
|
15
|
+
abi: erc20Abi,
|
|
16
|
+
functionName: "balanceOf",
|
|
17
|
+
args: [params.userAddress],
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
if (params.wethAddress) {
|
|
21
|
+
contracts.push({
|
|
22
|
+
address: params.wethAddress,
|
|
23
|
+
abi: erc20Abi,
|
|
24
|
+
functionName: "balanceOf",
|
|
25
|
+
args: [params.userAddress],
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return contracts;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Helper: Get user-specific staking contracts for multicall composition
|
|
32
|
+
* Pool-level stats (totalStaked, apr, outstandingRewards) now in project.ts
|
|
33
|
+
*/
|
|
34
|
+
export function stakingContracts(params) {
|
|
35
|
+
const contracts = [
|
|
36
|
+
{
|
|
37
|
+
address: params.stakingAddress,
|
|
38
|
+
abi: LevrStaking_v1,
|
|
39
|
+
functionName: "stakedBalanceOf",
|
|
40
|
+
args: [params.userAddress],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
address: params.clankerToken,
|
|
44
|
+
abi: erc20Abi,
|
|
45
|
+
functionName: "allowance",
|
|
46
|
+
args: [params.userAddress, params.stakingAddress],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
address: params.stakingAddress,
|
|
50
|
+
abi: LevrStaking_v1,
|
|
51
|
+
functionName: "claimableRewards",
|
|
52
|
+
args: [params.userAddress, params.clankerToken],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
address: params.stakingAddress,
|
|
56
|
+
abi: LevrStaking_v1,
|
|
57
|
+
functionName: "getVotingPower",
|
|
58
|
+
args: [params.userAddress],
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
if (params.wethAddress) {
|
|
62
|
+
contracts.push({
|
|
63
|
+
address: params.stakingAddress,
|
|
64
|
+
abi: LevrStaking_v1,
|
|
65
|
+
functionName: "claimableRewards",
|
|
66
|
+
args: [params.userAddress, params.wethAddress],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return contracts;
|
|
70
|
+
}
|
|
71
|
+
// ========================================
|
|
72
|
+
// MAIN USER DATA FUNCTION
|
|
73
|
+
// ========================================
|
|
74
|
+
/**
|
|
75
|
+
* Get all user-related data in a single efficient multicall
|
|
76
|
+
* Composes balances, staking, and governance data with USD values
|
|
77
|
+
*/
|
|
78
|
+
export async function getUser({ publicClient, userAddress, project }) {
|
|
79
|
+
if (Object.values({ publicClient, userAddress, project }).some((value) => !value)) {
|
|
80
|
+
throw new Error("Invalid user params");
|
|
81
|
+
}
|
|
82
|
+
const chainId = publicClient.chain?.id;
|
|
83
|
+
if (!chainId)
|
|
84
|
+
throw new Error("Chain ID not found on public client");
|
|
85
|
+
const wethAddress = WETH(chainId)?.address;
|
|
86
|
+
const { clankerToken, stakingAddress, tokenDecimals, pricing } = {
|
|
87
|
+
clankerToken: project.token.address,
|
|
88
|
+
stakingAddress: project.staking,
|
|
89
|
+
tokenDecimals: project.token.decimals,
|
|
90
|
+
pricing: project.pricing,
|
|
91
|
+
};
|
|
92
|
+
// Build single comprehensive multicall for ALL user data
|
|
93
|
+
const contracts = [
|
|
94
|
+
// Balances
|
|
95
|
+
{
|
|
96
|
+
address: clankerToken,
|
|
97
|
+
abi: erc20Abi,
|
|
98
|
+
functionName: "balanceOf",
|
|
99
|
+
args: [userAddress],
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
if (wethAddress) {
|
|
103
|
+
contracts.push({
|
|
104
|
+
address: wethAddress,
|
|
105
|
+
abi: erc20Abi,
|
|
106
|
+
functionName: "balanceOf",
|
|
107
|
+
args: [userAddress],
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
// Add staking contracts
|
|
111
|
+
contracts.push(...stakingContracts({ userAddress, stakingAddress, clankerToken, wethAddress }));
|
|
112
|
+
// Execute single multicall + native balance
|
|
113
|
+
const [nativeBalance, ...multicallResults] = await Promise.all([
|
|
114
|
+
publicClient.getBalance({ address: userAddress }),
|
|
115
|
+
publicClient.multicall({ contracts }),
|
|
116
|
+
]);
|
|
117
|
+
const results = multicallResults[0];
|
|
118
|
+
// Parse balance results
|
|
119
|
+
const stakingDataStartIndex = wethAddress ? 2 : 1;
|
|
120
|
+
const tokenBalanceRaw = results[0].result;
|
|
121
|
+
const wethBalanceRaw = wethAddress ? results[1].result : 0n;
|
|
122
|
+
// Parse user-specific staking results (pool stats now in project)
|
|
123
|
+
const stakedBalance = results[stakingDataStartIndex + 0].result;
|
|
124
|
+
const allowance = results[stakingDataStartIndex + 1].result;
|
|
125
|
+
const claimableRewardsToken = results[stakingDataStartIndex + 2].result;
|
|
126
|
+
const votingPower = results[stakingDataStartIndex + 3].result;
|
|
127
|
+
// Parse WETH claimable rewards if available
|
|
128
|
+
const claimableRewardsWeth = wethAddress
|
|
129
|
+
? results[stakingDataStartIndex + 4].result
|
|
130
|
+
: null;
|
|
131
|
+
// Calculate USD values
|
|
132
|
+
const tokenPrice = pricing ? parseFloat(pricing.tokenUsd) : null;
|
|
133
|
+
const wethPrice = pricing ? parseFloat(pricing.wethUsd) : null;
|
|
134
|
+
return {
|
|
135
|
+
balances: {
|
|
136
|
+
token: formatBalanceWithUsd(tokenBalanceRaw, tokenDecimals, tokenPrice),
|
|
137
|
+
weth: formatBalanceWithUsd(wethBalanceRaw, 18, wethPrice),
|
|
138
|
+
eth: formatBalanceWithUsd(nativeBalance, 18, wethPrice),
|
|
139
|
+
},
|
|
140
|
+
staking: {
|
|
141
|
+
stakedBalance: formatBalanceWithUsd(stakedBalance, tokenDecimals, tokenPrice),
|
|
142
|
+
allowance: formatBalanceWithUsd(allowance, tokenDecimals, tokenPrice),
|
|
143
|
+
claimableRewards: {
|
|
144
|
+
staking: formatBalanceWithUsd(claimableRewardsToken, tokenDecimals, tokenPrice),
|
|
145
|
+
weth: claimableRewardsWeth !== null && wethAddress
|
|
146
|
+
? formatBalanceWithUsd(claimableRewardsWeth, 18, wethPrice)
|
|
147
|
+
: null,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
votingPower: formatBalanceWithUsd(votingPower, tokenDecimals, tokenPrice),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=user.js.map
|
|
@@ -0,0 +1 @@
|
|
|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,oBAAoB,CAAC,qBAAqB,EAAE,aAAa,EAAE,UAAU,CAAC;gBAC/E,IAAI,EACF,oBAAoB,KAAK,IAAI,IAAI,WAAW;oBAC1C,CAAC,CAAC,oBAAoB,CAAC,oBAAoB,EAAE,EAAE,EAAE,SAAS,CAAC;oBAC3D,CAAC,CAAC,IAAI;aACX;SACF;QACD,WAAW,EAAE,oBAAoB,CAAC,WAAW,EAAE,aAAa,EAAE,UAAU,CAAC;KAC1E,CAAA;AACH,CAAC"}
|
package/dist/esm/util.js
CHANGED
|
@@ -1,4 +1,48 @@
|
|
|
1
|
-
import { parseUnits } from 'viem';
|
|
1
|
+
import { createPublicClient, http, parseUnits } from 'viem';
|
|
2
|
+
import { base, baseSepolia } from 'viem/chains';
|
|
3
|
+
/**
|
|
4
|
+
* Default public RPC URLs for common chains
|
|
5
|
+
*/
|
|
6
|
+
const DEFAULT_RPC_URLS = {
|
|
7
|
+
[base.id]: 'https://mainnet.base.org',
|
|
8
|
+
[baseSepolia.id]: 'https://sepolia.base.org',
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Get a configured public client for a given chain
|
|
12
|
+
* @param chainId - The chain ID to connect to
|
|
13
|
+
* @param rpcUrl - Optional custom RPC URL (falls back to public endpoints)
|
|
14
|
+
* @returns Configured public client
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Use default public RPC
|
|
19
|
+
* const client = getPublicClient(8453)
|
|
20
|
+
*
|
|
21
|
+
* // Use custom RPC
|
|
22
|
+
* const client = getPublicClient(8453, 'https://my-rpc.com')
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function getPublicClient(chainId, rpcUrl) {
|
|
26
|
+
const url = rpcUrl || DEFAULT_RPC_URLS[chainId];
|
|
27
|
+
if (!url) {
|
|
28
|
+
throw new Error(`No RPC URL available for chain ID ${chainId}. Please provide rpcUrl parameter.`);
|
|
29
|
+
}
|
|
30
|
+
// Get chain config
|
|
31
|
+
let chain;
|
|
32
|
+
if (chainId === base.id) {
|
|
33
|
+
chain = base;
|
|
34
|
+
}
|
|
35
|
+
else if (chainId === baseSepolia.id) {
|
|
36
|
+
chain = baseSepolia;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
throw new Error(`Unsupported chain ID ${chainId}`);
|
|
40
|
+
}
|
|
41
|
+
return createPublicClient({
|
|
42
|
+
chain,
|
|
43
|
+
transport: http(url),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
2
46
|
/**
|
|
3
47
|
* Check if approval is needed for a given amount
|
|
4
48
|
*/
|
package/dist/esm/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAC3D,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAI/C;;GAEG;AACH,MAAM,gBAAgB,GAA2B;IAC/C,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,0BAA0B;IACrC,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,0BAA0B;CAC7C,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,MAAe;IAC9D,MAAM,GAAG,GAAG,MAAM,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAC/C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,qCAAqC,OAAO,oCAAoC,CACjF,CAAA;IACH,CAAC;IAED,mBAAmB;IACnB,IAAI,KAAK,CAAA;IACT,IAAI,OAAO,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;QACxB,KAAK,GAAG,IAAI,CAAA;IACd,CAAC;SAAM,IAAI,OAAO,KAAK,WAAW,CAAC,EAAE,EAAE,CAAC;QACtC,KAAK,GAAG,WAAW,CAAA;IACrB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAA;IACpD,CAAC;IAED,OAAO,kBAAkB,CAAC;QACxB,KAAK;QACL,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC;KACrB,CAAoB,CAAA;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,gBAA0C,EAC1C,cAAwC,EACxC,QAAiB;IAEjB,IAAI,OAAO,gBAAgB,KAAK,QAAQ,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE,CAAC;QAC/E,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;QACjE,CAAC;IACH,CAAC;IAED,MAAM,sBAAsB,GAC1B,OAAO,gBAAgB,KAAK,QAAQ;QAClC,CAAC,CAAC,gBAAgB;QAClB,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,EAAE,EAAE,QAAS,CAAC,CAAA;IACxD,MAAM,oBAAoB,GACxB,OAAO,cAAc,KAAK,QAAQ;QAChC,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,QAAS,CAAC,CAAA;IAEtD,OAAO,sBAAsB,GAAG,oBAAoB,CAAA;AACtD,CAAC"}
|
|
@@ -141,6 +141,54 @@ declare const _default: readonly [{
|
|
|
141
141
|
}];
|
|
142
142
|
}];
|
|
143
143
|
readonly stateMutability: "view";
|
|
144
|
+
}, {
|
|
145
|
+
readonly type: "function";
|
|
146
|
+
readonly name: "getProjects";
|
|
147
|
+
readonly inputs: readonly [{
|
|
148
|
+
readonly name: "offset";
|
|
149
|
+
readonly type: "uint256";
|
|
150
|
+
readonly internalType: "uint256";
|
|
151
|
+
}, {
|
|
152
|
+
readonly name: "limit";
|
|
153
|
+
readonly type: "uint256";
|
|
154
|
+
readonly internalType: "uint256";
|
|
155
|
+
}];
|
|
156
|
+
readonly outputs: readonly [{
|
|
157
|
+
readonly name: "projects";
|
|
158
|
+
readonly type: "tuple[]";
|
|
159
|
+
readonly internalType: "struct ILevrFactory_v1.ProjectInfo[]";
|
|
160
|
+
readonly components: readonly [{
|
|
161
|
+
readonly name: "clankerToken";
|
|
162
|
+
readonly type: "address";
|
|
163
|
+
readonly internalType: "address";
|
|
164
|
+
}, {
|
|
165
|
+
readonly name: "project";
|
|
166
|
+
readonly type: "tuple";
|
|
167
|
+
readonly internalType: "struct ILevrFactory_v1.Project";
|
|
168
|
+
readonly components: readonly [{
|
|
169
|
+
readonly name: "treasury";
|
|
170
|
+
readonly type: "address";
|
|
171
|
+
readonly internalType: "address";
|
|
172
|
+
}, {
|
|
173
|
+
readonly name: "governor";
|
|
174
|
+
readonly type: "address";
|
|
175
|
+
readonly internalType: "address";
|
|
176
|
+
}, {
|
|
177
|
+
readonly name: "staking";
|
|
178
|
+
readonly type: "address";
|
|
179
|
+
readonly internalType: "address";
|
|
180
|
+
}, {
|
|
181
|
+
readonly name: "stakedToken";
|
|
182
|
+
readonly type: "address";
|
|
183
|
+
readonly internalType: "address";
|
|
184
|
+
}];
|
|
185
|
+
}];
|
|
186
|
+
}, {
|
|
187
|
+
readonly name: "total";
|
|
188
|
+
readonly type: "uint256";
|
|
189
|
+
readonly internalType: "uint256";
|
|
190
|
+
}];
|
|
191
|
+
readonly stateMutability: "view";
|
|
144
192
|
}, {
|
|
145
193
|
readonly type: "function";
|
|
146
194
|
readonly name: "isTrustedForwarder";
|
|
@@ -138,6 +138,18 @@ declare const _default: readonly [{
|
|
|
138
138
|
readonly name: "cycleId";
|
|
139
139
|
readonly type: "uint256";
|
|
140
140
|
readonly internalType: "uint256";
|
|
141
|
+
}, {
|
|
142
|
+
readonly name: "state";
|
|
143
|
+
readonly type: "uint8";
|
|
144
|
+
readonly internalType: "enum ILevrGovernor_v1.ProposalState";
|
|
145
|
+
}, {
|
|
146
|
+
readonly name: "meetsQuorum";
|
|
147
|
+
readonly type: "bool";
|
|
148
|
+
readonly internalType: "bool";
|
|
149
|
+
}, {
|
|
150
|
+
readonly name: "meetsApproval";
|
|
151
|
+
readonly type: "bool";
|
|
152
|
+
readonly internalType: "bool";
|
|
141
153
|
}];
|
|
142
154
|
}];
|
|
143
155
|
readonly stateMutability: "view";
|
|
@@ -186,24 +198,6 @@ declare const _default: readonly [{
|
|
|
186
198
|
}];
|
|
187
199
|
}];
|
|
188
200
|
readonly stateMutability: "view";
|
|
189
|
-
}, {
|
|
190
|
-
readonly type: "function";
|
|
191
|
-
readonly name: "getVotingPowerSnapshot";
|
|
192
|
-
readonly inputs: readonly [{
|
|
193
|
-
readonly name: "proposalId";
|
|
194
|
-
readonly type: "uint256";
|
|
195
|
-
readonly internalType: "uint256";
|
|
196
|
-
}, {
|
|
197
|
-
readonly name: "user";
|
|
198
|
-
readonly type: "address";
|
|
199
|
-
readonly internalType: "address";
|
|
200
|
-
}];
|
|
201
|
-
readonly outputs: readonly [{
|
|
202
|
-
readonly name: "";
|
|
203
|
-
readonly type: "uint256";
|
|
204
|
-
readonly internalType: "uint256";
|
|
205
|
-
}];
|
|
206
|
-
readonly stateMutability: "view";
|
|
207
201
|
}, {
|
|
208
202
|
readonly type: "function";
|
|
209
203
|
readonly name: "getWinner";
|
|
@@ -322,7 +322,11 @@ declare const _default: readonly [{
|
|
|
322
322
|
readonly type: "address";
|
|
323
323
|
readonly internalType: "address";
|
|
324
324
|
}];
|
|
325
|
-
readonly outputs: readonly [
|
|
325
|
+
readonly outputs: readonly [{
|
|
326
|
+
readonly name: "newVotingPower";
|
|
327
|
+
readonly type: "uint256";
|
|
328
|
+
readonly internalType: "uint256";
|
|
329
|
+
}];
|
|
326
330
|
readonly stateMutability: "nonpayable";
|
|
327
331
|
}, {
|
|
328
332
|
readonly type: "event";
|