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 @@
|
|
|
1
|
+
{"version":3,"file":"proposal.d.ts","sourceRoot":"","sources":["../../src/proposal.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;A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EACP,QAAa,EACb,WAAW,GACZ,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAuE5C;AAED,wBAAsB,QAAQ,CAC5B,YAAY,EAAE,eAAe,EAC7B,eAAe,EAAE,KAAK,MAAM,EAAE,EAC9B,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,aAAa,EACvB,WAAW,CAAC,EAAE,KAAK,MAAM,EAAE,oCAU5B"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Unified quote API for Uniswap V3 and V4
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This module provides quote functionality for both Uniswap V3 and V4 pools.
|
|
6
|
+
* Each version offers two methods:
|
|
7
|
+
* - `read`: Performs an async call to get the quote immediately
|
|
8
|
+
* - `bytecode`: Returns encoded call data for use in multicalls or custom execution
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // V3 Read (immediate result)
|
|
13
|
+
* const v3Quote = await quote.v3.read({
|
|
14
|
+
* publicClient,
|
|
15
|
+
* quoterAddress: '0x...',
|
|
16
|
+
* tokenIn: '0x123...',
|
|
17
|
+
* tokenOut: '0x456...',
|
|
18
|
+
* amountIn: parseUnits('1', 18),
|
|
19
|
+
* fee: 3000,
|
|
20
|
+
* })
|
|
21
|
+
* console.log(`Output: ${formatUnits(v3Quote.amountOut, 6)}`)
|
|
22
|
+
*
|
|
23
|
+
* // V3 Bytecode (for multicall)
|
|
24
|
+
* const v3Bytecode = quote.v3.bytecode({
|
|
25
|
+
* quoterAddress: '0x...',
|
|
26
|
+
* tokenIn: '0x123...',
|
|
27
|
+
* tokenOut: '0x456...',
|
|
28
|
+
* amountIn: parseUnits('1', 18),
|
|
29
|
+
* fee: 3000,
|
|
30
|
+
* })
|
|
31
|
+
* // Use v3Bytecode.address and v3Bytecode.data in multicall
|
|
32
|
+
*
|
|
33
|
+
* // V4 Read (immediate result with hook fees and price impact)
|
|
34
|
+
* const v4Quote = await quote.v4.read({
|
|
35
|
+
* publicClient,
|
|
36
|
+
* poolKey,
|
|
37
|
+
* zeroForOne: true,
|
|
38
|
+
* amountIn: parseEther('1'),
|
|
39
|
+
* pricing,
|
|
40
|
+
* tokenAddress: '0x...',
|
|
41
|
+
* })
|
|
42
|
+
* console.log(`Output: ${formatEther(v4Quote.amountOut)}`)
|
|
43
|
+
* console.log(`Price Impact: ${v4Quote.priceImpactBps}%`)
|
|
44
|
+
* console.log(`Hook Fees:`, v4Quote.hookFees)
|
|
45
|
+
*
|
|
46
|
+
* // V4 Bytecode (for multicall)
|
|
47
|
+
* const v4Bytecode = quote.v4.bytecode({
|
|
48
|
+
* publicClient, // Needed for chain ID
|
|
49
|
+
* poolKey,
|
|
50
|
+
* zeroForOne: true,
|
|
51
|
+
* amountIn: parseEther('1'),
|
|
52
|
+
* })
|
|
53
|
+
* // Use v4Bytecode.address and v4Bytecode.data in multicall
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export type { QuoteV3BytecodeReturnType, QuoteV3Params, QuoteV3ReadReturnType } from './v3';
|
|
57
|
+
export type { QuoteV4BytecodeReturnType, QuoteV4Params, QuoteV4ReadReturnType } from './v4';
|
|
58
|
+
/**
|
|
59
|
+
* @description Unified quote API for Uniswap V3 and V4
|
|
60
|
+
*/
|
|
61
|
+
export declare const quote: {
|
|
62
|
+
/**
|
|
63
|
+
* Uniswap V3 quote methods
|
|
64
|
+
*/
|
|
65
|
+
v3: {
|
|
66
|
+
/**
|
|
67
|
+
* Get a V3 quote by reading from the quoter contract
|
|
68
|
+
* @param params Quote parameters
|
|
69
|
+
* @returns Quote result with output amount
|
|
70
|
+
*/
|
|
71
|
+
read: (params: import("./v3").QuoteV3Params) => Promise<import("./v3").QuoteV3ReadReturnType>;
|
|
72
|
+
/**
|
|
73
|
+
* Get encoded bytecode for a V3 quote (for multicalls)
|
|
74
|
+
* @param params Quote parameters
|
|
75
|
+
* @returns Contract address and encoded call data
|
|
76
|
+
*/
|
|
77
|
+
bytecode: (params: import("./v3").QuoteV3Params) => import("./v3").QuoteV3BytecodeReturnType;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Uniswap V4 quote methods
|
|
81
|
+
*/
|
|
82
|
+
v4: {
|
|
83
|
+
/**
|
|
84
|
+
* Get a V4 quote by reading from the quoter contract
|
|
85
|
+
* @param params Quote parameters
|
|
86
|
+
* @returns Quote result with output amount, gas estimate, price impact, and hook fees
|
|
87
|
+
*/
|
|
88
|
+
read: (params: import("./v4").QuoteV4Params) => Promise<import("./v4").QuoteV4ReadReturnType>;
|
|
89
|
+
/**
|
|
90
|
+
* Get encoded bytecode for a V4 quote (for multicalls)
|
|
91
|
+
* @param params Quote parameters
|
|
92
|
+
* @returns Contract address and encoded call data
|
|
93
|
+
*/
|
|
94
|
+
bytecode: (params: import("./v4").QuoteV4Params) => import("./v4").QuoteV4BytecodeReturnType;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/quote/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAGH,YAAY,EAAE,yBAAyB,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,MAAM,CAAA;AAC3F,YAAY,EAAE,yBAAyB,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,MAAM,CAAA;AAM3F;;GAEG;AACH,eAAO,MAAM,KAAK;IAChB;;OAEG;;QAED;;;;WAIG;;QAEH;;;;WAIG;;;IAGL;;OAEG;;QAED;;;;WAIG;;QAEH;;;;WAIG;;;CAGN,CAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { PublicClient } from 'viem';
|
|
2
|
+
import { V3QuoterV2 } from '../abis';
|
|
3
|
+
/**
|
|
4
|
+
* @description Parameters for quoting a V3 swap
|
|
5
|
+
*/
|
|
6
|
+
export type QuoteV3Params = {
|
|
7
|
+
/**
|
|
8
|
+
* Public client for V3 quoter queries (only required for read method)
|
|
9
|
+
*/
|
|
10
|
+
publicClient?: PublicClient;
|
|
11
|
+
/**
|
|
12
|
+
* V3 Quoter V2 address
|
|
13
|
+
*/
|
|
14
|
+
quoterAddress: `0x${string}`;
|
|
15
|
+
/**
|
|
16
|
+
* Input token address
|
|
17
|
+
*/
|
|
18
|
+
tokenIn: `0x${string}`;
|
|
19
|
+
/**
|
|
20
|
+
* Output token address
|
|
21
|
+
*/
|
|
22
|
+
tokenOut: `0x${string}`;
|
|
23
|
+
/**
|
|
24
|
+
* Amount of input token (in wei)
|
|
25
|
+
*/
|
|
26
|
+
amountIn: bigint;
|
|
27
|
+
/**
|
|
28
|
+
* Fee tier (500 = 0.05%, 3000 = 0.3%, 10000 = 1%)
|
|
29
|
+
*/
|
|
30
|
+
fee: number;
|
|
31
|
+
/**
|
|
32
|
+
* Optional sqrt price limit (0n = no limit)
|
|
33
|
+
*/
|
|
34
|
+
sqrtPriceLimitX96?: bigint;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* @description Return type for V3 quote read method
|
|
38
|
+
*/
|
|
39
|
+
export type QuoteV3ReadReturnType = {
|
|
40
|
+
/**
|
|
41
|
+
* Amount of output token (in wei)
|
|
42
|
+
*/
|
|
43
|
+
amountOut: bigint;
|
|
44
|
+
/**
|
|
45
|
+
* Fee tier used for the quote
|
|
46
|
+
*/
|
|
47
|
+
fee: number;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* @description Return type for V3 quote bytecode method
|
|
51
|
+
*/
|
|
52
|
+
export type QuoteV3BytecodeReturnType = {
|
|
53
|
+
/**
|
|
54
|
+
* Target contract address
|
|
55
|
+
*/
|
|
56
|
+
address: `0x${string}`;
|
|
57
|
+
/**
|
|
58
|
+
* Encoded function call data
|
|
59
|
+
*/
|
|
60
|
+
data: `0x${string}`;
|
|
61
|
+
/**
|
|
62
|
+
* Contract ABI for multicall
|
|
63
|
+
*/
|
|
64
|
+
abi: typeof V3QuoterV2;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* @description Quote a swap on Uniswap V3 by reading from the quoter contract
|
|
68
|
+
* @param params Parameters for V3 quote
|
|
69
|
+
* @returns Output amount and fee tier
|
|
70
|
+
*/
|
|
71
|
+
export declare const quoteV3Read: (params: QuoteV3Params) => Promise<QuoteV3ReadReturnType>;
|
|
72
|
+
/**
|
|
73
|
+
* @description Get bytecode for a V3 quote that can be used in multicalls
|
|
74
|
+
* @param params Parameters for V3 quote
|
|
75
|
+
* @returns Contract address, encoded call data, and ABI
|
|
76
|
+
*/
|
|
77
|
+
export declare const quoteV3Bytecode: (params: QuoteV3Params) => QuoteV3BytecodeReturnType;
|
|
78
|
+
//# sourceMappingURL=v3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v3.d.ts","sourceRoot":"","sources":["../../../src/quote/v3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAGxC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAMpC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B;;OAEG;IACH,aAAa,EAAE,KAAK,MAAM,EAAE,CAAA;IAC5B;;OAEG;IACH,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IACtB;;OAEG;IACH,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;IACvB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC;;OAEG;IACH,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IACtB;;OAEG;IACH,IAAI,EAAE,KAAK,MAAM,EAAE,CAAA;IACnB;;OAEG;IACH,GAAG,EAAE,OAAO,UAAU,CAAA;CACvB,CAAA;AAMD;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAU,QAAQ,aAAa,KAAG,OAAO,CAAC,qBAAqB,CAoCtF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,aAAa,KAAG,yBAsBvD,CAAA"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { PublicClient } from 'viem';
|
|
2
|
+
import { V4Quoter } from '../abis';
|
|
3
|
+
import type { PoolKey, PricingResult } from '../types';
|
|
4
|
+
export type QuoteV4Params = {
|
|
5
|
+
/**
|
|
6
|
+
* Public client for V4 quoter queries (only required for read method)
|
|
7
|
+
*/
|
|
8
|
+
publicClient?: PublicClient;
|
|
9
|
+
/**
|
|
10
|
+
* Pool key containing currency pair and fee info
|
|
11
|
+
*/
|
|
12
|
+
poolKey: PoolKey;
|
|
13
|
+
/**
|
|
14
|
+
* Swap direction (true = currency0 to currency1, false = currency1 to currency0)
|
|
15
|
+
*/
|
|
16
|
+
zeroForOne: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Amount of input token (in wei)
|
|
19
|
+
*/
|
|
20
|
+
amountIn: bigint;
|
|
21
|
+
/**
|
|
22
|
+
* Optional hook data
|
|
23
|
+
*/
|
|
24
|
+
hookData?: `0x${string}`;
|
|
25
|
+
/**
|
|
26
|
+
* Optional pricing data for price impact calculation
|
|
27
|
+
*/
|
|
28
|
+
pricing?: PricingResult;
|
|
29
|
+
/**
|
|
30
|
+
* Decimals for currency0 (default: 18)
|
|
31
|
+
*/
|
|
32
|
+
currency0Decimals?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Decimals for currency1 (default: 18)
|
|
35
|
+
*/
|
|
36
|
+
currency1Decimals?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Project token address to determine which currency is token vs WETH
|
|
39
|
+
*/
|
|
40
|
+
tokenAddress?: `0x${string}`;
|
|
41
|
+
};
|
|
42
|
+
export type QuoteV4ReadReturnType = {
|
|
43
|
+
/**
|
|
44
|
+
* Amount of output token (in wei)
|
|
45
|
+
*/
|
|
46
|
+
amountOut: bigint;
|
|
47
|
+
/**
|
|
48
|
+
* Estimated gas for the swap
|
|
49
|
+
*/
|
|
50
|
+
gasEstimate: bigint;
|
|
51
|
+
/**
|
|
52
|
+
* Price impact percentage (e.g., 0.5 for 0.5%)
|
|
53
|
+
* Only calculated if pricing data is provided
|
|
54
|
+
*/
|
|
55
|
+
priceImpactBps?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Fee information from Clanker hooks (if available)
|
|
58
|
+
* - Static fees: clankerFee and pairedFee in basis points
|
|
59
|
+
* - Dynamic fees: baseFee and maxLpFee in basis points
|
|
60
|
+
*/
|
|
61
|
+
hookFees?: {
|
|
62
|
+
type: 'static' | 'dynamic';
|
|
63
|
+
clankerFee?: number;
|
|
64
|
+
pairedFee?: number;
|
|
65
|
+
baseFee?: number;
|
|
66
|
+
maxLpFee?: number;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export type QuoteV4BytecodeReturnType = {
|
|
70
|
+
/**
|
|
71
|
+
* Target contract address
|
|
72
|
+
*/
|
|
73
|
+
address: `0x${string}`;
|
|
74
|
+
/**
|
|
75
|
+
* Encoded function call data
|
|
76
|
+
*/
|
|
77
|
+
data: `0x${string}`;
|
|
78
|
+
/**
|
|
79
|
+
* Contract ABI for multicall
|
|
80
|
+
*/
|
|
81
|
+
abi: typeof V4Quoter;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* @description Quote a swap on Uniswap V4 by reading from the quoter contract
|
|
85
|
+
* @param params Quote parameters including pool key and amount
|
|
86
|
+
* @returns Quote result with output amount, gas estimate, price impact, and hook fees
|
|
87
|
+
*/
|
|
88
|
+
export declare const quoteV4Read: (params: QuoteV4Params) => Promise<QuoteV4ReadReturnType>;
|
|
89
|
+
/**
|
|
90
|
+
* @description Get bytecode for a V4 quote that can be used in multicalls
|
|
91
|
+
* @param params Quote parameters including pool key and amount
|
|
92
|
+
* @returns Contract address, encoded call data, and ABI
|
|
93
|
+
*/
|
|
94
|
+
export declare const quoteV4Bytecode: (params: QuoteV4Params) => QuoteV4BytecodeReturnType;
|
|
95
|
+
//# sourceMappingURL=v4.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v4.d.ts","sourceRoot":"","sources":["../../../src/quote/v4.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAGxC,OAAO,EAAiD,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEjF,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAMtD,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,UAAU,EAAE,OAAO,CAAA;IACnB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,MAAM,EAAE,CAAA;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,MAAM,EAAE,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;OAIG;IACH,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAA;QAC1B,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CAAA;CACF,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC;;OAEG;IACH,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IACtB;;OAEG;IACH,IAAI,EAAE,KAAK,MAAM,EAAE,CAAA;IACnB;;OAEG;IACH,GAAG,EAAE,OAAO,QAAQ,CAAA;CACrB,CAAA;AAsLD;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAU,QAAQ,aAAa,KAAG,OAAO,CAAC,qBAAqB,CAwEtF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,aAAa,KAAG,yBAiCvD,CAAA"}
|
package/dist/types/stake.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { TransactionReceipt } from 'viem';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Project } from '.';
|
|
3
|
+
import type { BalanceResult, PopPublicClient, PopWalletClient } from './types';
|
|
3
4
|
export type StakeConfig = {
|
|
4
5
|
wallet: PopWalletClient;
|
|
5
6
|
publicClient: PopPublicClient;
|
|
6
|
-
|
|
7
|
-
tokenAddress: `0x${string}`;
|
|
8
|
-
tokenDecimals: number;
|
|
9
|
-
trustedForwarder?: `0x${string}`;
|
|
7
|
+
project: Project;
|
|
10
8
|
};
|
|
11
9
|
export type UnstakeParams = {
|
|
12
10
|
amount: number | string | bigint;
|
|
@@ -16,6 +14,35 @@ export type ClaimParams = {
|
|
|
16
14
|
tokens?: `0x${string}`[];
|
|
17
15
|
to?: `0x${string}`;
|
|
18
16
|
};
|
|
17
|
+
export type StakePoolData = {
|
|
18
|
+
totalStaked: BalanceResult;
|
|
19
|
+
escrowBalance: BalanceResult;
|
|
20
|
+
streamParams: {
|
|
21
|
+
windowSeconds: number;
|
|
22
|
+
streamStart: bigint;
|
|
23
|
+
streamEnd: bigint;
|
|
24
|
+
isActive: boolean;
|
|
25
|
+
};
|
|
26
|
+
rewardRatePerSecond: BalanceResult;
|
|
27
|
+
};
|
|
28
|
+
export type StakeUserData = {
|
|
29
|
+
stakedBalance: BalanceResult;
|
|
30
|
+
aprBps: {
|
|
31
|
+
raw: bigint;
|
|
32
|
+
percentage: number;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export type StakeOutstandingRewards = {
|
|
36
|
+
available: BalanceResult;
|
|
37
|
+
pending: BalanceResult;
|
|
38
|
+
};
|
|
39
|
+
export type StakeClaimableRewards = {
|
|
40
|
+
claimable: BalanceResult;
|
|
41
|
+
};
|
|
42
|
+
export type VotingPowerResult = {
|
|
43
|
+
tokenDays: bigint;
|
|
44
|
+
formatted: string;
|
|
45
|
+
};
|
|
19
46
|
export declare class Stake {
|
|
20
47
|
private wallet;
|
|
21
48
|
private publicClient;
|
|
@@ -36,84 +63,16 @@ export declare class Stake {
|
|
|
36
63
|
stake(amount: number | string | bigint): Promise<TransactionReceipt>;
|
|
37
64
|
/**
|
|
38
65
|
* Unstake tokens from the staking contract
|
|
66
|
+
* @returns Transaction receipt with the new voting power after unstake
|
|
39
67
|
*/
|
|
40
|
-
unstake({ amount, to }: UnstakeParams): Promise<
|
|
68
|
+
unstake({ amount, to }: UnstakeParams): Promise<{
|
|
69
|
+
receipt: TransactionReceipt;
|
|
70
|
+
newVotingPower: bigint;
|
|
71
|
+
}>;
|
|
41
72
|
/**
|
|
42
73
|
* Claim rewards from the staking contract
|
|
43
74
|
*/
|
|
44
75
|
claimRewards(params: ClaimParams | void): Promise<TransactionReceipt>;
|
|
45
|
-
/**
|
|
46
|
-
* Get allowance for a token and spender
|
|
47
|
-
*/
|
|
48
|
-
getAllowance(): Promise<{
|
|
49
|
-
raw: bigint;
|
|
50
|
-
formatted: string;
|
|
51
|
-
}>;
|
|
52
|
-
/**
|
|
53
|
-
* Get pool data from staking contract
|
|
54
|
-
*/
|
|
55
|
-
getPoolData(): Promise<{
|
|
56
|
-
totalStaked: {
|
|
57
|
-
raw: bigint;
|
|
58
|
-
formatted: string;
|
|
59
|
-
};
|
|
60
|
-
escrowBalance: {
|
|
61
|
-
raw: bigint;
|
|
62
|
-
formatted: string;
|
|
63
|
-
};
|
|
64
|
-
streamParams: {
|
|
65
|
-
windowSeconds: number;
|
|
66
|
-
streamStart: bigint;
|
|
67
|
-
streamEnd: bigint;
|
|
68
|
-
isActive: boolean;
|
|
69
|
-
};
|
|
70
|
-
rewardRatePerSecond: {
|
|
71
|
-
raw: bigint;
|
|
72
|
-
formatted: string;
|
|
73
|
-
};
|
|
74
|
-
}>;
|
|
75
|
-
/**
|
|
76
|
-
* Get user data from staking contract
|
|
77
|
-
*/
|
|
78
|
-
getUserData(): Promise<{
|
|
79
|
-
stakedBalance: {
|
|
80
|
-
raw: bigint;
|
|
81
|
-
formatted: string;
|
|
82
|
-
};
|
|
83
|
-
aprBps: {
|
|
84
|
-
raw: bigint;
|
|
85
|
-
percentage: number;
|
|
86
|
-
};
|
|
87
|
-
}>;
|
|
88
|
-
/**
|
|
89
|
-
* Get outstanding rewards for the token (for accrual purposes)
|
|
90
|
-
*/
|
|
91
|
-
getOutstandingRewards(tokenAddress?: `0x${string}`): Promise<{
|
|
92
|
-
available: {
|
|
93
|
-
raw: bigint;
|
|
94
|
-
formatted: string;
|
|
95
|
-
};
|
|
96
|
-
pending: {
|
|
97
|
-
raw: bigint;
|
|
98
|
-
formatted: string;
|
|
99
|
-
};
|
|
100
|
-
}>;
|
|
101
|
-
/**
|
|
102
|
-
* Get claimable rewards for the current user and token
|
|
103
|
-
*/
|
|
104
|
-
getClaimableRewards(tokenAddress?: `0x${string}`): Promise<{
|
|
105
|
-
claimable: {
|
|
106
|
-
raw: bigint;
|
|
107
|
-
formatted: string;
|
|
108
|
-
};
|
|
109
|
-
}>;
|
|
110
|
-
/**
|
|
111
|
-
* Get reward rate per second for a specific token
|
|
112
|
-
*/
|
|
113
|
-
getRewardRatePerSecond(tokenAddress?: `0x${string}`): Promise<{
|
|
114
|
-
raw: bigint;
|
|
115
|
-
formatted: string;
|
|
116
|
-
}>;
|
|
117
76
|
/**
|
|
118
77
|
* Accrue rewards by triggering automatic collection from LP locker and claiming from ClankerFeeLocker
|
|
119
78
|
*/
|
|
@@ -123,15 +82,10 @@ export declare class Stake {
|
|
|
123
82
|
*/
|
|
124
83
|
accrueAllRewards(tokenAddresses: `0x${string}`[]): Promise<TransactionReceipt>;
|
|
125
84
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* @param poolKey - The Uniswap V4 pool key for price discovery
|
|
130
|
-
* @returns WETH APR in basis points and percentage
|
|
85
|
+
* Simulate voting power after an unstake (without executing the transaction)
|
|
86
|
+
* @param amount Amount to unstake
|
|
87
|
+
* @returns Predicted voting power in token-days after the unstake
|
|
131
88
|
*/
|
|
132
|
-
|
|
133
|
-
raw: bigint;
|
|
134
|
-
percentage: number;
|
|
135
|
-
}>;
|
|
89
|
+
votingPowerOnUnstake(amount: number | string | bigint, userAddress?: `0x${string}`): Promise<VotingPowerResult>;
|
|
136
90
|
}
|
|
137
91
|
//# sourceMappingURL=stake.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stake.d.ts","sourceRoot":"","sources":["../../src/stake.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stake.d.ts","sourceRoot":"","sources":["../../src/stake.ts"],"names":[],"mappings":"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AAC,iBAAiB,CAAC;CAqB9B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BalanceResult, PopPublicClient } from './types';
|
|
2
|
+
export type AirdropStatus = {
|
|
3
|
+
availableAmount: BalanceResult;
|
|
4
|
+
allocatedAmount: BalanceResult;
|
|
5
|
+
isAvailable: boolean;
|
|
6
|
+
error?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Get treasury airdrop status
|
|
10
|
+
*/
|
|
11
|
+
export declare function getTreasuryAirdropStatus(publicClient: PopPublicClient, clankerToken: `0x${string}`, treasury: `0x${string}`, tokenDecimals: number, tokenUsdPrice: number | null): Promise<AirdropStatus | null>;
|
|
12
|
+
/**
|
|
13
|
+
* Get available airdrop amount for treasury
|
|
14
|
+
*/
|
|
15
|
+
export declare function getTreasuryAirdropAvailable(publicClient: PopPublicClient, clankerToken: `0x${string}`, treasury: `0x${string}`): Promise<bigint>;
|
|
16
|
+
//# sourceMappingURL=treasury.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treasury.d.ts","sourceRoot":"","sources":["../../src/treasury.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE7D,MAAM,MAAM,aAAa,GAAG;IAC1B,eAAe,EAAE,aAAa,CAAA;IAC9B,eAAe,EAAE,aAAa,CAAA;IAC9B,WAAW,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AA8JD;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,YAAY,EAAE,eAAe,EAC7B,YAAY,EAAE,KAAK,MAAM,EAAE,EAC3B,QAAQ,EAAE,KAAK,MAAM,EAAE,EACvB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,GAAG,IAAI,GAC3B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CA8B/B;AAED;;GAEG;AACH,wBAAsB,2BAA2B,CAC/C,YAAY,EAAE,eAAe,EAC7B,YAAY,EAAE,KAAK,MAAM,EAAE,EAC3B,QAAQ,EAAE,KAAK,MAAM,EAAE,GACtB,OAAO,CAAC,MAAM,CAAC,CAGjB"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -17,4 +17,19 @@ export type CallData = {
|
|
|
17
17
|
value: bigint;
|
|
18
18
|
callData: `0x${string}`;
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* @description Standard balance/amount result with optional USD value
|
|
22
|
+
*/
|
|
23
|
+
export type BalanceResult = {
|
|
24
|
+
raw: bigint;
|
|
25
|
+
formatted: string;
|
|
26
|
+
usd?: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* @description USD pricing result
|
|
30
|
+
*/
|
|
31
|
+
export type PricingResult = {
|
|
32
|
+
wethUsd: string;
|
|
33
|
+
tokenUsd: string;
|
|
34
|
+
};
|
|
20
35
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAEjF,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;AACrE,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;AAE5D;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,KAAK,MAAM,EAAE,CAAA;IACxB,SAAS,EAAE,KAAK,MAAM,EAAE,CAAA;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,KAAK,MAAM,EAAE,CAAA;CACrB,CAAA;AAED,MAAM,MAAM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|
+
import type { PublicClient } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* @description Parameters for getting WETH/USD price
|
|
4
|
+
*/
|
|
5
|
+
export type GetWethUsdPriceParams = {
|
|
6
|
+
/**
|
|
7
|
+
* Public client for WETH/USDC oracle queries
|
|
8
|
+
* This should connect to a chain with reliable USDC liquidity (e.g., Base mainnet)
|
|
9
|
+
*/
|
|
10
|
+
publicClient: PublicClient;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @description Return type for WETH/USD price function
|
|
14
|
+
*/
|
|
15
|
+
export type GetWethUsdPriceReturnType = {
|
|
16
|
+
/**
|
|
17
|
+
* WETH price in USD as a formatted string (e.g. "2543.21")
|
|
18
|
+
*/
|
|
19
|
+
priceUsd: string;
|
|
20
|
+
/**
|
|
21
|
+
* Raw amount of USDC received for 1 WETH (in USDC's 6 decimals)
|
|
22
|
+
*/
|
|
23
|
+
wethPerUsdc: bigint;
|
|
24
|
+
/**
|
|
25
|
+
* Fee tier of the V3 pool used (500 = 0.05%, 3000 = 0.3%, 10000 = 1%)
|
|
26
|
+
*/
|
|
27
|
+
fee: number;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* @description Get the USD price of WETH from a WETH/USDC pool using Uniswap V3
|
|
31
|
+
*
|
|
32
|
+
* @param params Parameters for WETH/USD price oracle
|
|
33
|
+
* @returns WETH price in USD and raw quote data
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* This function queries Uniswap V3 WETH/USDC pools for accurate pricing.
|
|
37
|
+
* V3 is used instead of V4 because V3 has much deeper liquidity on most chains.
|
|
38
|
+
*
|
|
39
|
+
* The function:
|
|
40
|
+
* 1. Tries common V3 fee tiers (0.3%, 0.05%, 1%) in order of preference
|
|
41
|
+
* 2. Quotes 1 WETH to get USDC output
|
|
42
|
+
* 3. Returns the first successful quote
|
|
43
|
+
*
|
|
44
|
+
* This is commonly used as a price oracle for other token pricing calculations.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // Get current WETH price on Base mainnet
|
|
49
|
+
* const { priceUsd, fee } = await getWethUsdPrice({
|
|
50
|
+
* publicClient: baseMainnetClient,
|
|
51
|
+
* })
|
|
52
|
+
* console.log(`WETH price: $${priceUsd} (from ${fee/10000}% pool)`)
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare const getWethUsdPrice: ({ publicClient, }: GetWethUsdPriceParams) => Promise<GetWethUsdPriceReturnType>;
|
|
56
|
+
/**
|
|
57
|
+
* @description Parameters for getting USD price of a token
|
|
58
|
+
*/
|
|
59
|
+
export type GetUsdPriceParams = {
|
|
60
|
+
/**
|
|
61
|
+
* Public client for price oracle queries (WETH/USDC)
|
|
62
|
+
* This should connect to a chain with reliable USDC liquidity (e.g., Base mainnet)
|
|
63
|
+
*/
|
|
64
|
+
oraclePublicClient: PublicClient;
|
|
65
|
+
/**
|
|
66
|
+
* Public client for token quote queries (Token/WETH)
|
|
67
|
+
* This should connect to the chain where the token is deployed
|
|
68
|
+
*/
|
|
69
|
+
quotePublicClient: PublicClient;
|
|
70
|
+
/**
|
|
71
|
+
* Token address to get price for
|
|
72
|
+
*/
|
|
73
|
+
tokenAddress: `0x${string}`;
|
|
74
|
+
/**
|
|
75
|
+
* Optional fee tier for the token/WETH pool (in hundredths of a bip, e.g. 3000 = 0.3%)
|
|
76
|
+
* If not provided, uses defaults from pool-key module (3000 = 0.3%)
|
|
77
|
+
* Note: WETH/USDC pool is automatically discovered
|
|
78
|
+
*/
|
|
79
|
+
quoteFee?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Optional tick spacing for the token/WETH pool
|
|
82
|
+
* If not provided, uses defaults from pool-key module (60 for 0.3% fee tier)
|
|
83
|
+
* Note: WETH/USDC pool is automatically discovered
|
|
84
|
+
*/
|
|
85
|
+
quoteTickSpacing?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Optional hooks address for the token/WETH pool
|
|
88
|
+
* If not provided, uses defaults from pool-key module (zero address = no hooks)
|
|
89
|
+
* Note: WETH/USDC pool is automatically discovered
|
|
90
|
+
*/
|
|
91
|
+
quoteHooks?: `0x${string}`;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* @description Return type for USD price function
|
|
95
|
+
*/
|
|
96
|
+
export type GetUsdPriceReturnType = {
|
|
97
|
+
/**
|
|
98
|
+
* USD price of the token as a formatted string (e.g. "1234.56")
|
|
99
|
+
*/
|
|
100
|
+
priceUsd: string;
|
|
101
|
+
/**
|
|
102
|
+
* Raw price ratio of token to WETH
|
|
103
|
+
*/
|
|
104
|
+
tokenPerWeth: bigint;
|
|
105
|
+
/**
|
|
106
|
+
* Raw price ratio of WETH to USDC
|
|
107
|
+
*/
|
|
108
|
+
wethPerUsdc: bigint;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* @description Get the USD price of a token paired with WETH
|
|
112
|
+
*
|
|
113
|
+
* @param params Parameters including token addresses and chain config
|
|
114
|
+
* @returns USD price and intermediate price ratios
|
|
115
|
+
*
|
|
116
|
+
* @remarks
|
|
117
|
+
* This function calculates the USD price of a token by:
|
|
118
|
+
* 1. Auto-discovering and querying a liquid WETH/USDC pool (oracle chain)
|
|
119
|
+
* 2. Getting the price of the token in WETH (quote chain)
|
|
120
|
+
* 3. Multiplying them together to get token price in USD
|
|
121
|
+
*
|
|
122
|
+
* The paired token must be WETH, otherwise an error is thrown.
|
|
123
|
+
* USD pricing always uses USDC as the stable reference.
|
|
124
|
+
*
|
|
125
|
+
* This design allows you to:
|
|
126
|
+
* - Use mainnet for accurate WETH/USDC prices (oracle auto-discovers pool)
|
|
127
|
+
* - Quote tokens from any chain (testnet, L2, etc.)
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* // Get testnet token price using mainnet oracle
|
|
132
|
+
* const { priceUsd } = await getUsdPrice({
|
|
133
|
+
* oraclePublicClient: mainnetClient,
|
|
134
|
+
* quotePublicClient: testnetClient,
|
|
135
|
+
* tokenAddress: '0x123...',
|
|
136
|
+
* })
|
|
137
|
+
* console.log(`Token price: $${priceUsd}`)
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export declare const getUsdPrice: ({ oraclePublicClient, quotePublicClient, tokenAddress, quoteFee, quoteTickSpacing, quoteHooks, }: GetUsdPriceParams) => Promise<GetUsdPriceReturnType>;
|
|
141
|
+
//# sourceMappingURL=usd-price.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usd-price.d.ts","sourceRoot":"","sources":["../../src/usd-price.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAOxC;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;OAGG;IACH,YAAY,EAAE,YAAY,CAAA;CAC3B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,eAAe,GAAU,mBAEnC,qBAAqB,KAAG,OAAO,CAAC,yBAAyB,CA0D3D,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,kBAAkB,EAAE,YAAY,CAAA;IAChC;;;OAGG;IACH,iBAAiB,EAAE,YAAY,CAAA;IAC/B;;OAEG;IACH,YAAY,EAAE,KAAK,MAAM,EAAE,CAAA;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;;;OAIG;IACH,UAAU,CAAC,EAAE,KAAK,MAAM,EAAE,CAAA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