@net-protocol/score 0.1.2 → 0.1.4
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/index.d.mts +190 -7
- package/dist/index.d.ts +190 -7
- package/dist/index.js +792 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +783 -26
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +56 -3
- package/dist/react.d.ts +56 -3
- package/dist/react.js +596 -0
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +593 -3
- package/dist/react.mjs.map +1 -1
- package/dist/{scoreKeyUtils-DgHOtf44.d.mts → scoreKeyUtils-DuH70ypB.d.mts} +30 -1
- package/dist/{scoreKeyUtils-DgHOtf44.d.ts → scoreKeyUtils-DuH70ypB.d.ts} +30 -1
- package/package.json +6 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScoreClientOptions, G as GetUpvotesOptions, a as GetUpvotesForItemsOptions, b as GetStrategyKeyScoresOptions, c as GetAppKeyScoresOptions, D as DecodedStrategyMetadata, P as PoolKey, d as PoolDiscoveryResult } from './scoreKeyUtils-
|
|
2
|
-
export { e as DecodedUpvoteBlob, F as FeedMessage, f as PoolStrategyMetadata, g as PureAlphaMetadata, h as ScoreItem, U as UseTokenUpvotesOptions, i as
|
|
3
|
-
import { Address, PublicClient, Abi } from 'viem';
|
|
1
|
+
import { S as ScoreClientOptions, G as GetUpvotesOptions, a as GetUpvotesForItemsOptions, b as GetStrategyKeyScoresOptions, c as GetAppKeyScoresOptions, D as DecodedStrategyMetadata, P as PoolKey, d as PoolDiscoveryResult } from './scoreKeyUtils-DuH70ypB.mjs';
|
|
2
|
+
export { e as DecodedUpvoteBlob, F as FeedMessage, f as PoolStrategyMetadata, g as PureAlphaMetadata, h as ScoreItem, U as UseTokenUpvotesOptions, i as UseUpvotePriceOptions, j as UseUpvoteUserOptions, k as UseUpvotesBatchOptions, l as UseUpvotesOptions, m as UseUserUpvotesGivenOptions, n as UseUserUpvotesGivenPerTokenBatchOptions, o as UseUserUpvotesReceivedOptions, p as UseUserUpvotesReceivedPerTokenBatchOptions, q as extractTokenAddressFromScoreKey, r as getFeedContentKey, s as getScoreKey, t as getStorageScoreKey, u as getStorageUpvoteContext, v as getTokenScoreKey, w as isTokenScoreKey } from './scoreKeyUtils-DuH70ypB.mjs';
|
|
3
|
+
import { Address, WalletClient, PublicClient, Abi } from 'viem';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* ScoreClient - Client for interacting with Net protocol scoring/upvote system
|
|
@@ -37,6 +37,118 @@ declare class ScoreClient {
|
|
|
37
37
|
getAppKeyScores({ app, scoreKeys, }: GetAppKeyScoresOptions): Promise<number[]>;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
type ParsedUserUpvoteMessage = {
|
|
41
|
+
upvotedUserString: string;
|
|
42
|
+
actualToken: string;
|
|
43
|
+
numUpvotes: number;
|
|
44
|
+
tokenWethPrice: bigint;
|
|
45
|
+
wethUsdcPrice: bigint;
|
|
46
|
+
alphaWethPrice: bigint;
|
|
47
|
+
userTokenBalance?: bigint;
|
|
48
|
+
};
|
|
49
|
+
type TokenAddressExtraction = {
|
|
50
|
+
tokenAddresses: string[];
|
|
51
|
+
validMessages: ParsedUserUpvoteMessage[];
|
|
52
|
+
};
|
|
53
|
+
type UserUpvote = {
|
|
54
|
+
tokenAddress: string;
|
|
55
|
+
numUpvotes: number;
|
|
56
|
+
timestamp: number;
|
|
57
|
+
priceInUsdc?: number;
|
|
58
|
+
userTokenBalance: number;
|
|
59
|
+
userTokenBalanceUsdValue?: number;
|
|
60
|
+
upvotedUserAddress?: string;
|
|
61
|
+
tokenInfo?: {
|
|
62
|
+
name: string;
|
|
63
|
+
symbol: string;
|
|
64
|
+
decimals: number;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
type UserUpvoteReceived = {
|
|
68
|
+
upvoterAddress: string;
|
|
69
|
+
tokenAddress: string;
|
|
70
|
+
numUpvotes: number;
|
|
71
|
+
timestamp: number;
|
|
72
|
+
priceInUsdc?: number;
|
|
73
|
+
userTokenBalance: number;
|
|
74
|
+
userTokenBalanceUsdValue?: number;
|
|
75
|
+
tokenInfo?: {
|
|
76
|
+
name: string;
|
|
77
|
+
symbol: string;
|
|
78
|
+
decimals: number;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
type UserUpvoteClientOptions = {
|
|
82
|
+
chainId: number;
|
|
83
|
+
overrides?: {
|
|
84
|
+
contractAddress?: Address;
|
|
85
|
+
rpcUrls?: string[];
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
type UserUpvoteNetMessage = {
|
|
89
|
+
app: `0x${string}`;
|
|
90
|
+
sender: `0x${string}`;
|
|
91
|
+
timestamp: bigint;
|
|
92
|
+
data: `0x${string}`;
|
|
93
|
+
text: string;
|
|
94
|
+
topic: string;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* UserUpvoteClient - Client for reading user-to-user upvote data.
|
|
99
|
+
*
|
|
100
|
+
* This is a standalone upvote system separate from the token Score system.
|
|
101
|
+
* It reads directly from the UserUpvote contract on Base.
|
|
102
|
+
*/
|
|
103
|
+
declare class UserUpvoteClient {
|
|
104
|
+
private client;
|
|
105
|
+
private contractAddress;
|
|
106
|
+
private chainId;
|
|
107
|
+
constructor(params: UserUpvoteClientOptions);
|
|
108
|
+
getUserUpvotesGiven({ user }: {
|
|
109
|
+
user: Address;
|
|
110
|
+
}): Promise<bigint>;
|
|
111
|
+
getUserUpvotesReceived({ user }: {
|
|
112
|
+
user: Address;
|
|
113
|
+
}): Promise<bigint>;
|
|
114
|
+
getUserUpvotesGivenPerTokenBatch({ user, tokens, }: {
|
|
115
|
+
user: Address;
|
|
116
|
+
tokens: Address[];
|
|
117
|
+
}): Promise<bigint[]>;
|
|
118
|
+
getUserUpvotesReceivedPerTokenBatch({ user, tokens, }: {
|
|
119
|
+
user: Address;
|
|
120
|
+
tokens: Address[];
|
|
121
|
+
}): Promise<bigint[]>;
|
|
122
|
+
getTotalUpvotesPerToken({ token, }: {
|
|
123
|
+
token: Address;
|
|
124
|
+
}): Promise<bigint>;
|
|
125
|
+
getUserTokensInRange({ user, startIndex, endIndex, }: {
|
|
126
|
+
user: Address;
|
|
127
|
+
startIndex: number;
|
|
128
|
+
endIndex: number;
|
|
129
|
+
}): Promise<{
|
|
130
|
+
token: Address;
|
|
131
|
+
feeTier: number;
|
|
132
|
+
}[]>;
|
|
133
|
+
getUserTokenCount({ user }: {
|
|
134
|
+
user: Address;
|
|
135
|
+
}): Promise<number>;
|
|
136
|
+
isTokenInUserList({ user, token, }: {
|
|
137
|
+
user: Address;
|
|
138
|
+
token: Address;
|
|
139
|
+
}): Promise<boolean>;
|
|
140
|
+
getUpvotePrice(): Promise<bigint>;
|
|
141
|
+
upvoteUser({ walletClient, userToUpvote, token, numUpvotes, feeTier, value: providedValue, }: {
|
|
142
|
+
walletClient: WalletClient;
|
|
143
|
+
userToUpvote: Address;
|
|
144
|
+
token?: Address;
|
|
145
|
+
numUpvotes: number;
|
|
146
|
+
feeTier?: number;
|
|
147
|
+
/** Pre-computed ETH value. When omitted, fetches upvotePrice from chain. */
|
|
148
|
+
value?: bigint;
|
|
149
|
+
}): Promise<`0x${string}`>;
|
|
150
|
+
}
|
|
151
|
+
|
|
40
152
|
/**
|
|
41
153
|
* Convert token address to bytes32 upvote key.
|
|
42
154
|
*/
|
|
@@ -164,20 +276,24 @@ declare function calculatePriceFromSqrtPriceX96(sqrtPriceX96: bigint, token0Deci
|
|
|
164
276
|
* Discover the best Uniswap pools for multiple token pairs.
|
|
165
277
|
* Makes two on-chain calls: pool discovery + pool info retrieval.
|
|
166
278
|
*/
|
|
167
|
-
declare function discoverPools({ publicClient, pairs, }: {
|
|
279
|
+
declare function discoverPools({ publicClient, pairs, chainId, }: {
|
|
168
280
|
publicClient: PublicClient;
|
|
169
281
|
pairs: {
|
|
170
282
|
tokenAddress: string;
|
|
171
283
|
baseTokenAddress?: string;
|
|
172
284
|
}[];
|
|
285
|
+
/** Chain ID used to resolve the WETH address. Defaults to Base (8453). */
|
|
286
|
+
chainId?: number;
|
|
173
287
|
}): Promise<PoolDiscoveryResult[]>;
|
|
174
288
|
/**
|
|
175
289
|
* Discover the best WETH pool for a single token.
|
|
176
290
|
* Convenience wrapper around discoverPools.
|
|
177
291
|
*/
|
|
178
|
-
declare function discoverTokenPool({ publicClient, tokenAddress, }: {
|
|
292
|
+
declare function discoverTokenPool({ publicClient, tokenAddress, chainId, }: {
|
|
179
293
|
publicClient: PublicClient;
|
|
180
294
|
tokenAddress: string;
|
|
295
|
+
/** Chain ID used to resolve the WETH address. Defaults to Base (8453). */
|
|
296
|
+
chainId?: number;
|
|
181
297
|
}): Promise<PoolDiscoveryResult | null>;
|
|
182
298
|
|
|
183
299
|
declare const SCORE_CONTRACT: {
|
|
@@ -216,8 +332,75 @@ declare const MULTI_VERSION_UNISWAP_POOL_INFO_RETRIEVER: {
|
|
|
216
332
|
readonly address: Address;
|
|
217
333
|
readonly abi: Abi;
|
|
218
334
|
};
|
|
219
|
-
|
|
335
|
+
/**
|
|
336
|
+
* Get the WETH address for a given chain.
|
|
337
|
+
*/
|
|
338
|
+
declare function getWethAddress(chainId: number): Address;
|
|
220
339
|
declare const NULL_ADDRESS: Address;
|
|
221
340
|
declare const UPVOTE_PRICE_ETH = 0.000025;
|
|
341
|
+
declare const USER_UPVOTE_CONTRACT: {
|
|
342
|
+
readonly address: Address;
|
|
343
|
+
readonly abi: Abi;
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Parse a Net protocol message from the user upvote contract.
|
|
348
|
+
*
|
|
349
|
+
* Two formats based on topic:
|
|
350
|
+
* - Topic "ub-{address}" (received upvotes): 7 fields including userTokenBalance
|
|
351
|
+
* - Topic "g" (given upvotes): 6 fields without userTokenBalance
|
|
352
|
+
*/
|
|
353
|
+
declare function parseUserUpvoteMessage(message: UserUpvoteNetMessage, topic: string): ParsedUserUpvoteMessage | null;
|
|
354
|
+
/**
|
|
355
|
+
* Extract unique token addresses from an array of Net messages.
|
|
356
|
+
*/
|
|
357
|
+
declare function extractTokenAddressesFromMessages(messages: UserUpvoteNetMessage[], topic: string): TokenAddressExtraction;
|
|
358
|
+
/**
|
|
359
|
+
* Validate that a Net message can be parsed as a user upvote message.
|
|
360
|
+
*/
|
|
361
|
+
declare function validateUserUpvoteMessage(message: UserUpvoteNetMessage, topic: string): boolean;
|
|
362
|
+
/**
|
|
363
|
+
* Calculate the USDC price from a parsed user upvote message.
|
|
364
|
+
*
|
|
365
|
+
* The contract emits (halfWei * 1e18) / amountRaw for tokenWethPrice,
|
|
366
|
+
* so we divide by 10^(36 - tokenDecimals) to get the actual price.
|
|
367
|
+
*/
|
|
368
|
+
declare function calculatePriceInUsdc(parsedMessage: ParsedUserUpvoteMessage, tokenDecimals?: number): number | undefined;
|
|
369
|
+
/**
|
|
370
|
+
* Calculate the human-readable token balance from a raw bigint value.
|
|
371
|
+
*/
|
|
372
|
+
declare function calculateUserTokenBalance(rawBalance: bigint, tokenDecimals?: number): number;
|
|
373
|
+
/**
|
|
374
|
+
* Client-side validation for upvote parameters.
|
|
375
|
+
* Mirrors contract-side errors for better UX before sending a transaction.
|
|
376
|
+
*/
|
|
377
|
+
declare function validateUpvoteParams(params: {
|
|
378
|
+
sender: Address;
|
|
379
|
+
userToUpvote: Address;
|
|
380
|
+
numUpvotes: number;
|
|
381
|
+
}): {
|
|
382
|
+
valid: boolean;
|
|
383
|
+
error?: string;
|
|
384
|
+
};
|
|
385
|
+
/**
|
|
386
|
+
* Calculate the total ETH cost for a given number of upvotes.
|
|
387
|
+
*/
|
|
388
|
+
declare function calculateUpvoteCost(numUpvotes: number, upvotePrice: bigint): bigint;
|
|
389
|
+
/**
|
|
390
|
+
* Build an enriched UserUpvote from a parsed message and optional token info.
|
|
391
|
+
*/
|
|
392
|
+
declare function buildUserUpvote(parsed: ParsedUserUpvoteMessage, timestamp: number, tokenInfo?: {
|
|
393
|
+
name: string;
|
|
394
|
+
symbol: string;
|
|
395
|
+
decimals: number;
|
|
396
|
+
}): UserUpvote;
|
|
397
|
+
/**
|
|
398
|
+
* Build an enriched UserUpvoteReceived from a parsed message, upvoter address, and optional token info.
|
|
399
|
+
*/
|
|
400
|
+
declare function buildUserUpvoteReceived(parsed: ParsedUserUpvoteMessage, upvoterAddress: string, timestamp: number, tokenInfo?: {
|
|
401
|
+
name: string;
|
|
402
|
+
symbol: string;
|
|
403
|
+
decimals: number;
|
|
404
|
+
}): UserUpvoteReceived;
|
|
222
405
|
|
|
223
|
-
export { ALL_STRATEGY_ADDRESSES, DYNAMIC_SPLIT_STRATEGY, DecodedStrategyMetadata, GetAppKeyScoresOptions, GetStrategyKeyScoresOptions, GetUpvotesForItemsOptions, GetUpvotesOptions, LEGACY_UPVOTE_V1_ADDRESS, LEGACY_UPVOTE_V2_ADDRESS, MULTI_VERSION_UNISWAP_BULK_POOL_FINDER, MULTI_VERSION_UNISWAP_POOL_INFO_RETRIEVER, NULL_ADDRESS, PURE_ALPHA_STRATEGY, PoolDiscoveryResult, PoolKey, SCORE_CONTRACT, SUPPORTED_SCORE_CHAINS, ScoreClient, ScoreClientOptions, UNIV234_POOLS_STRATEGY, UPVOTE_APP, UPVOTE_PRICE_ETH, UPVOTE_STORAGE_APP,
|
|
406
|
+
export { ALL_STRATEGY_ADDRESSES, DYNAMIC_SPLIT_STRATEGY, DecodedStrategyMetadata, GetAppKeyScoresOptions, GetStrategyKeyScoresOptions, GetUpvotesForItemsOptions, GetUpvotesOptions, LEGACY_UPVOTE_V1_ADDRESS, LEGACY_UPVOTE_V2_ADDRESS, MULTI_VERSION_UNISWAP_BULK_POOL_FINDER, MULTI_VERSION_UNISWAP_POOL_INFO_RETRIEVER, NULL_ADDRESS, PURE_ALPHA_STRATEGY, type ParsedUserUpvoteMessage, PoolDiscoveryResult, PoolKey, SCORE_CONTRACT, SUPPORTED_SCORE_CHAINS, ScoreClient, ScoreClientOptions, type TokenAddressExtraction, UNIV234_POOLS_STRATEGY, UPVOTE_APP, UPVOTE_PRICE_ETH, UPVOTE_STORAGE_APP, USER_UPVOTE_CONTRACT, type UserUpvote, UserUpvoteClient, type UserUpvoteClientOptions, type UserUpvoteNetMessage, type UserUpvoteReceived, buildUserUpvote, buildUserUpvoteReceived, calculatePriceFromSqrtPriceX96, calculatePriceInUsdc, calculateUpvoteCost, calculateUserTokenBalance, decodeStrategyMetadata, decodeUpvoteMessage, decodeUpvoteStorageBlob, discoverPools, discoverTokenPool, encodePoolKey, encodeUpvoteKey, extractStrategyAddress, extractTokenAddressesFromMessages, getWethAddress, isDynamicSplitStrategy, isPureAlphaStrategy, isStrategyMessage, isUniv234PoolsStrategy, isUserUpvoteMessage, parseUserUpvoteMessage, selectStrategy, tokenAddressToUpvoteKeyString, validateUpvoteParams, validateUserUpvoteMessage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ScoreClientOptions, G as GetUpvotesOptions, a as GetUpvotesForItemsOptions, b as GetStrategyKeyScoresOptions, c as GetAppKeyScoresOptions, D as DecodedStrategyMetadata, P as PoolKey, d as PoolDiscoveryResult } from './scoreKeyUtils-
|
|
2
|
-
export { e as DecodedUpvoteBlob, F as FeedMessage, f as PoolStrategyMetadata, g as PureAlphaMetadata, h as ScoreItem, U as UseTokenUpvotesOptions, i as
|
|
3
|
-
import { Address, PublicClient, Abi } from 'viem';
|
|
1
|
+
import { S as ScoreClientOptions, G as GetUpvotesOptions, a as GetUpvotesForItemsOptions, b as GetStrategyKeyScoresOptions, c as GetAppKeyScoresOptions, D as DecodedStrategyMetadata, P as PoolKey, d as PoolDiscoveryResult } from './scoreKeyUtils-DuH70ypB.js';
|
|
2
|
+
export { e as DecodedUpvoteBlob, F as FeedMessage, f as PoolStrategyMetadata, g as PureAlphaMetadata, h as ScoreItem, U as UseTokenUpvotesOptions, i as UseUpvotePriceOptions, j as UseUpvoteUserOptions, k as UseUpvotesBatchOptions, l as UseUpvotesOptions, m as UseUserUpvotesGivenOptions, n as UseUserUpvotesGivenPerTokenBatchOptions, o as UseUserUpvotesReceivedOptions, p as UseUserUpvotesReceivedPerTokenBatchOptions, q as extractTokenAddressFromScoreKey, r as getFeedContentKey, s as getScoreKey, t as getStorageScoreKey, u as getStorageUpvoteContext, v as getTokenScoreKey, w as isTokenScoreKey } from './scoreKeyUtils-DuH70ypB.js';
|
|
3
|
+
import { Address, WalletClient, PublicClient, Abi } from 'viem';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* ScoreClient - Client for interacting with Net protocol scoring/upvote system
|
|
@@ -37,6 +37,118 @@ declare class ScoreClient {
|
|
|
37
37
|
getAppKeyScores({ app, scoreKeys, }: GetAppKeyScoresOptions): Promise<number[]>;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
type ParsedUserUpvoteMessage = {
|
|
41
|
+
upvotedUserString: string;
|
|
42
|
+
actualToken: string;
|
|
43
|
+
numUpvotes: number;
|
|
44
|
+
tokenWethPrice: bigint;
|
|
45
|
+
wethUsdcPrice: bigint;
|
|
46
|
+
alphaWethPrice: bigint;
|
|
47
|
+
userTokenBalance?: bigint;
|
|
48
|
+
};
|
|
49
|
+
type TokenAddressExtraction = {
|
|
50
|
+
tokenAddresses: string[];
|
|
51
|
+
validMessages: ParsedUserUpvoteMessage[];
|
|
52
|
+
};
|
|
53
|
+
type UserUpvote = {
|
|
54
|
+
tokenAddress: string;
|
|
55
|
+
numUpvotes: number;
|
|
56
|
+
timestamp: number;
|
|
57
|
+
priceInUsdc?: number;
|
|
58
|
+
userTokenBalance: number;
|
|
59
|
+
userTokenBalanceUsdValue?: number;
|
|
60
|
+
upvotedUserAddress?: string;
|
|
61
|
+
tokenInfo?: {
|
|
62
|
+
name: string;
|
|
63
|
+
symbol: string;
|
|
64
|
+
decimals: number;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
type UserUpvoteReceived = {
|
|
68
|
+
upvoterAddress: string;
|
|
69
|
+
tokenAddress: string;
|
|
70
|
+
numUpvotes: number;
|
|
71
|
+
timestamp: number;
|
|
72
|
+
priceInUsdc?: number;
|
|
73
|
+
userTokenBalance: number;
|
|
74
|
+
userTokenBalanceUsdValue?: number;
|
|
75
|
+
tokenInfo?: {
|
|
76
|
+
name: string;
|
|
77
|
+
symbol: string;
|
|
78
|
+
decimals: number;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
type UserUpvoteClientOptions = {
|
|
82
|
+
chainId: number;
|
|
83
|
+
overrides?: {
|
|
84
|
+
contractAddress?: Address;
|
|
85
|
+
rpcUrls?: string[];
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
type UserUpvoteNetMessage = {
|
|
89
|
+
app: `0x${string}`;
|
|
90
|
+
sender: `0x${string}`;
|
|
91
|
+
timestamp: bigint;
|
|
92
|
+
data: `0x${string}`;
|
|
93
|
+
text: string;
|
|
94
|
+
topic: string;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* UserUpvoteClient - Client for reading user-to-user upvote data.
|
|
99
|
+
*
|
|
100
|
+
* This is a standalone upvote system separate from the token Score system.
|
|
101
|
+
* It reads directly from the UserUpvote contract on Base.
|
|
102
|
+
*/
|
|
103
|
+
declare class UserUpvoteClient {
|
|
104
|
+
private client;
|
|
105
|
+
private contractAddress;
|
|
106
|
+
private chainId;
|
|
107
|
+
constructor(params: UserUpvoteClientOptions);
|
|
108
|
+
getUserUpvotesGiven({ user }: {
|
|
109
|
+
user: Address;
|
|
110
|
+
}): Promise<bigint>;
|
|
111
|
+
getUserUpvotesReceived({ user }: {
|
|
112
|
+
user: Address;
|
|
113
|
+
}): Promise<bigint>;
|
|
114
|
+
getUserUpvotesGivenPerTokenBatch({ user, tokens, }: {
|
|
115
|
+
user: Address;
|
|
116
|
+
tokens: Address[];
|
|
117
|
+
}): Promise<bigint[]>;
|
|
118
|
+
getUserUpvotesReceivedPerTokenBatch({ user, tokens, }: {
|
|
119
|
+
user: Address;
|
|
120
|
+
tokens: Address[];
|
|
121
|
+
}): Promise<bigint[]>;
|
|
122
|
+
getTotalUpvotesPerToken({ token, }: {
|
|
123
|
+
token: Address;
|
|
124
|
+
}): Promise<bigint>;
|
|
125
|
+
getUserTokensInRange({ user, startIndex, endIndex, }: {
|
|
126
|
+
user: Address;
|
|
127
|
+
startIndex: number;
|
|
128
|
+
endIndex: number;
|
|
129
|
+
}): Promise<{
|
|
130
|
+
token: Address;
|
|
131
|
+
feeTier: number;
|
|
132
|
+
}[]>;
|
|
133
|
+
getUserTokenCount({ user }: {
|
|
134
|
+
user: Address;
|
|
135
|
+
}): Promise<number>;
|
|
136
|
+
isTokenInUserList({ user, token, }: {
|
|
137
|
+
user: Address;
|
|
138
|
+
token: Address;
|
|
139
|
+
}): Promise<boolean>;
|
|
140
|
+
getUpvotePrice(): Promise<bigint>;
|
|
141
|
+
upvoteUser({ walletClient, userToUpvote, token, numUpvotes, feeTier, value: providedValue, }: {
|
|
142
|
+
walletClient: WalletClient;
|
|
143
|
+
userToUpvote: Address;
|
|
144
|
+
token?: Address;
|
|
145
|
+
numUpvotes: number;
|
|
146
|
+
feeTier?: number;
|
|
147
|
+
/** Pre-computed ETH value. When omitted, fetches upvotePrice from chain. */
|
|
148
|
+
value?: bigint;
|
|
149
|
+
}): Promise<`0x${string}`>;
|
|
150
|
+
}
|
|
151
|
+
|
|
40
152
|
/**
|
|
41
153
|
* Convert token address to bytes32 upvote key.
|
|
42
154
|
*/
|
|
@@ -164,20 +276,24 @@ declare function calculatePriceFromSqrtPriceX96(sqrtPriceX96: bigint, token0Deci
|
|
|
164
276
|
* Discover the best Uniswap pools for multiple token pairs.
|
|
165
277
|
* Makes two on-chain calls: pool discovery + pool info retrieval.
|
|
166
278
|
*/
|
|
167
|
-
declare function discoverPools({ publicClient, pairs, }: {
|
|
279
|
+
declare function discoverPools({ publicClient, pairs, chainId, }: {
|
|
168
280
|
publicClient: PublicClient;
|
|
169
281
|
pairs: {
|
|
170
282
|
tokenAddress: string;
|
|
171
283
|
baseTokenAddress?: string;
|
|
172
284
|
}[];
|
|
285
|
+
/** Chain ID used to resolve the WETH address. Defaults to Base (8453). */
|
|
286
|
+
chainId?: number;
|
|
173
287
|
}): Promise<PoolDiscoveryResult[]>;
|
|
174
288
|
/**
|
|
175
289
|
* Discover the best WETH pool for a single token.
|
|
176
290
|
* Convenience wrapper around discoverPools.
|
|
177
291
|
*/
|
|
178
|
-
declare function discoverTokenPool({ publicClient, tokenAddress, }: {
|
|
292
|
+
declare function discoverTokenPool({ publicClient, tokenAddress, chainId, }: {
|
|
179
293
|
publicClient: PublicClient;
|
|
180
294
|
tokenAddress: string;
|
|
295
|
+
/** Chain ID used to resolve the WETH address. Defaults to Base (8453). */
|
|
296
|
+
chainId?: number;
|
|
181
297
|
}): Promise<PoolDiscoveryResult | null>;
|
|
182
298
|
|
|
183
299
|
declare const SCORE_CONTRACT: {
|
|
@@ -216,8 +332,75 @@ declare const MULTI_VERSION_UNISWAP_POOL_INFO_RETRIEVER: {
|
|
|
216
332
|
readonly address: Address;
|
|
217
333
|
readonly abi: Abi;
|
|
218
334
|
};
|
|
219
|
-
|
|
335
|
+
/**
|
|
336
|
+
* Get the WETH address for a given chain.
|
|
337
|
+
*/
|
|
338
|
+
declare function getWethAddress(chainId: number): Address;
|
|
220
339
|
declare const NULL_ADDRESS: Address;
|
|
221
340
|
declare const UPVOTE_PRICE_ETH = 0.000025;
|
|
341
|
+
declare const USER_UPVOTE_CONTRACT: {
|
|
342
|
+
readonly address: Address;
|
|
343
|
+
readonly abi: Abi;
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Parse a Net protocol message from the user upvote contract.
|
|
348
|
+
*
|
|
349
|
+
* Two formats based on topic:
|
|
350
|
+
* - Topic "ub-{address}" (received upvotes): 7 fields including userTokenBalance
|
|
351
|
+
* - Topic "g" (given upvotes): 6 fields without userTokenBalance
|
|
352
|
+
*/
|
|
353
|
+
declare function parseUserUpvoteMessage(message: UserUpvoteNetMessage, topic: string): ParsedUserUpvoteMessage | null;
|
|
354
|
+
/**
|
|
355
|
+
* Extract unique token addresses from an array of Net messages.
|
|
356
|
+
*/
|
|
357
|
+
declare function extractTokenAddressesFromMessages(messages: UserUpvoteNetMessage[], topic: string): TokenAddressExtraction;
|
|
358
|
+
/**
|
|
359
|
+
* Validate that a Net message can be parsed as a user upvote message.
|
|
360
|
+
*/
|
|
361
|
+
declare function validateUserUpvoteMessage(message: UserUpvoteNetMessage, topic: string): boolean;
|
|
362
|
+
/**
|
|
363
|
+
* Calculate the USDC price from a parsed user upvote message.
|
|
364
|
+
*
|
|
365
|
+
* The contract emits (halfWei * 1e18) / amountRaw for tokenWethPrice,
|
|
366
|
+
* so we divide by 10^(36 - tokenDecimals) to get the actual price.
|
|
367
|
+
*/
|
|
368
|
+
declare function calculatePriceInUsdc(parsedMessage: ParsedUserUpvoteMessage, tokenDecimals?: number): number | undefined;
|
|
369
|
+
/**
|
|
370
|
+
* Calculate the human-readable token balance from a raw bigint value.
|
|
371
|
+
*/
|
|
372
|
+
declare function calculateUserTokenBalance(rawBalance: bigint, tokenDecimals?: number): number;
|
|
373
|
+
/**
|
|
374
|
+
* Client-side validation for upvote parameters.
|
|
375
|
+
* Mirrors contract-side errors for better UX before sending a transaction.
|
|
376
|
+
*/
|
|
377
|
+
declare function validateUpvoteParams(params: {
|
|
378
|
+
sender: Address;
|
|
379
|
+
userToUpvote: Address;
|
|
380
|
+
numUpvotes: number;
|
|
381
|
+
}): {
|
|
382
|
+
valid: boolean;
|
|
383
|
+
error?: string;
|
|
384
|
+
};
|
|
385
|
+
/**
|
|
386
|
+
* Calculate the total ETH cost for a given number of upvotes.
|
|
387
|
+
*/
|
|
388
|
+
declare function calculateUpvoteCost(numUpvotes: number, upvotePrice: bigint): bigint;
|
|
389
|
+
/**
|
|
390
|
+
* Build an enriched UserUpvote from a parsed message and optional token info.
|
|
391
|
+
*/
|
|
392
|
+
declare function buildUserUpvote(parsed: ParsedUserUpvoteMessage, timestamp: number, tokenInfo?: {
|
|
393
|
+
name: string;
|
|
394
|
+
symbol: string;
|
|
395
|
+
decimals: number;
|
|
396
|
+
}): UserUpvote;
|
|
397
|
+
/**
|
|
398
|
+
* Build an enriched UserUpvoteReceived from a parsed message, upvoter address, and optional token info.
|
|
399
|
+
*/
|
|
400
|
+
declare function buildUserUpvoteReceived(parsed: ParsedUserUpvoteMessage, upvoterAddress: string, timestamp: number, tokenInfo?: {
|
|
401
|
+
name: string;
|
|
402
|
+
symbol: string;
|
|
403
|
+
decimals: number;
|
|
404
|
+
}): UserUpvoteReceived;
|
|
222
405
|
|
|
223
|
-
export { ALL_STRATEGY_ADDRESSES, DYNAMIC_SPLIT_STRATEGY, DecodedStrategyMetadata, GetAppKeyScoresOptions, GetStrategyKeyScoresOptions, GetUpvotesForItemsOptions, GetUpvotesOptions, LEGACY_UPVOTE_V1_ADDRESS, LEGACY_UPVOTE_V2_ADDRESS, MULTI_VERSION_UNISWAP_BULK_POOL_FINDER, MULTI_VERSION_UNISWAP_POOL_INFO_RETRIEVER, NULL_ADDRESS, PURE_ALPHA_STRATEGY, PoolDiscoveryResult, PoolKey, SCORE_CONTRACT, SUPPORTED_SCORE_CHAINS, ScoreClient, ScoreClientOptions, UNIV234_POOLS_STRATEGY, UPVOTE_APP, UPVOTE_PRICE_ETH, UPVOTE_STORAGE_APP,
|
|
406
|
+
export { ALL_STRATEGY_ADDRESSES, DYNAMIC_SPLIT_STRATEGY, DecodedStrategyMetadata, GetAppKeyScoresOptions, GetStrategyKeyScoresOptions, GetUpvotesForItemsOptions, GetUpvotesOptions, LEGACY_UPVOTE_V1_ADDRESS, LEGACY_UPVOTE_V2_ADDRESS, MULTI_VERSION_UNISWAP_BULK_POOL_FINDER, MULTI_VERSION_UNISWAP_POOL_INFO_RETRIEVER, NULL_ADDRESS, PURE_ALPHA_STRATEGY, type ParsedUserUpvoteMessage, PoolDiscoveryResult, PoolKey, SCORE_CONTRACT, SUPPORTED_SCORE_CHAINS, ScoreClient, ScoreClientOptions, type TokenAddressExtraction, UNIV234_POOLS_STRATEGY, UPVOTE_APP, UPVOTE_PRICE_ETH, UPVOTE_STORAGE_APP, USER_UPVOTE_CONTRACT, type UserUpvote, UserUpvoteClient, type UserUpvoteClientOptions, type UserUpvoteNetMessage, type UserUpvoteReceived, buildUserUpvote, buildUserUpvoteReceived, calculatePriceFromSqrtPriceX96, calculatePriceInUsdc, calculateUpvoteCost, calculateUserTokenBalance, decodeStrategyMetadata, decodeUpvoteMessage, decodeUpvoteStorageBlob, discoverPools, discoverTokenPool, encodePoolKey, encodeUpvoteKey, extractStrategyAddress, extractTokenAddressesFromMessages, getWethAddress, isDynamicSplitStrategy, isPureAlphaStrategy, isStrategyMessage, isUniv234PoolsStrategy, isUserUpvoteMessage, parseUserUpvoteMessage, selectStrategy, tokenAddressToUpvoteKeyString, validateUpvoteParams, validateUserUpvoteMessage };
|