@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.js
CHANGED
|
@@ -1934,6 +1934,467 @@ var multi_version_uniswap_pool_info_retriever_default = [
|
|
|
1934
1934
|
}
|
|
1935
1935
|
];
|
|
1936
1936
|
|
|
1937
|
+
// src/abis/user-upvote.json
|
|
1938
|
+
var user_upvote_default = [
|
|
1939
|
+
{
|
|
1940
|
+
type: "constructor",
|
|
1941
|
+
inputs: [
|
|
1942
|
+
{ name: "_alphaToken", type: "address", internalType: "address" },
|
|
1943
|
+
{ name: "_erc20TokenGatedChat", type: "address", internalType: "address" },
|
|
1944
|
+
{ name: "_net", type: "address", internalType: "address" },
|
|
1945
|
+
{ name: "_swapRouter", type: "address", internalType: "address" },
|
|
1946
|
+
{ name: "_weth", type: "address", internalType: "address" },
|
|
1947
|
+
{ name: "_upvotePrice", type: "uint256", internalType: "uint256" },
|
|
1948
|
+
{ name: "_feeBps", type: "uint256", internalType: "uint256" }
|
|
1949
|
+
],
|
|
1950
|
+
stateMutability: "nonpayable"
|
|
1951
|
+
},
|
|
1952
|
+
{
|
|
1953
|
+
type: "function",
|
|
1954
|
+
name: "ALPHA_TOKEN",
|
|
1955
|
+
inputs: [],
|
|
1956
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
1957
|
+
stateMutability: "view"
|
|
1958
|
+
},
|
|
1959
|
+
{
|
|
1960
|
+
type: "function",
|
|
1961
|
+
name: "ERC20_TOKEN_GATED_CHAT",
|
|
1962
|
+
inputs: [],
|
|
1963
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
1964
|
+
stateMutability: "view"
|
|
1965
|
+
},
|
|
1966
|
+
{
|
|
1967
|
+
type: "function",
|
|
1968
|
+
name: "ETH_USDC_POOL",
|
|
1969
|
+
inputs: [],
|
|
1970
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
1971
|
+
stateMutability: "view"
|
|
1972
|
+
},
|
|
1973
|
+
{
|
|
1974
|
+
type: "function",
|
|
1975
|
+
name: "MAX_TOKENS_PER_USER",
|
|
1976
|
+
inputs: [],
|
|
1977
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
1978
|
+
stateMutability: "view"
|
|
1979
|
+
},
|
|
1980
|
+
{
|
|
1981
|
+
type: "function",
|
|
1982
|
+
name: "NET",
|
|
1983
|
+
inputs: [],
|
|
1984
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
1985
|
+
stateMutability: "view"
|
|
1986
|
+
},
|
|
1987
|
+
{
|
|
1988
|
+
type: "function",
|
|
1989
|
+
name: "SWAP_ROUTER",
|
|
1990
|
+
inputs: [],
|
|
1991
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
1992
|
+
stateMutability: "view"
|
|
1993
|
+
},
|
|
1994
|
+
{
|
|
1995
|
+
type: "function",
|
|
1996
|
+
name: "UNISWAP_V3_FACTORY",
|
|
1997
|
+
inputs: [],
|
|
1998
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
1999
|
+
stateMutability: "view"
|
|
2000
|
+
},
|
|
2001
|
+
{
|
|
2002
|
+
type: "function",
|
|
2003
|
+
name: "WETH",
|
|
2004
|
+
inputs: [],
|
|
2005
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2006
|
+
stateMutability: "view"
|
|
2007
|
+
},
|
|
2008
|
+
{
|
|
2009
|
+
type: "function",
|
|
2010
|
+
name: "addTokenToList",
|
|
2011
|
+
inputs: [
|
|
2012
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
2013
|
+
{ name: "feeTier", type: "uint24", internalType: "uint24" }
|
|
2014
|
+
],
|
|
2015
|
+
outputs: [],
|
|
2016
|
+
stateMutability: "nonpayable"
|
|
2017
|
+
},
|
|
2018
|
+
{
|
|
2019
|
+
type: "function",
|
|
2020
|
+
name: "feeBps",
|
|
2021
|
+
inputs: [],
|
|
2022
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2023
|
+
stateMutability: "view"
|
|
2024
|
+
},
|
|
2025
|
+
{
|
|
2026
|
+
type: "function",
|
|
2027
|
+
name: "getTokenFeeTier",
|
|
2028
|
+
inputs: [
|
|
2029
|
+
{ name: "user", type: "address", internalType: "address" },
|
|
2030
|
+
{ name: "token", type: "address", internalType: "address" }
|
|
2031
|
+
],
|
|
2032
|
+
outputs: [{ name: "", type: "uint24", internalType: "uint24" }],
|
|
2033
|
+
stateMutability: "view"
|
|
2034
|
+
},
|
|
2035
|
+
{
|
|
2036
|
+
type: "function",
|
|
2037
|
+
name: "getTotalUpvotesPerToken",
|
|
2038
|
+
inputs: [
|
|
2039
|
+
{ name: "token", type: "address", internalType: "address" }
|
|
2040
|
+
],
|
|
2041
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2042
|
+
stateMutability: "view"
|
|
2043
|
+
},
|
|
2044
|
+
{
|
|
2045
|
+
type: "function",
|
|
2046
|
+
name: "getUserTokenCount",
|
|
2047
|
+
inputs: [
|
|
2048
|
+
{ name: "user", type: "address", internalType: "address" }
|
|
2049
|
+
],
|
|
2050
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2051
|
+
stateMutability: "view"
|
|
2052
|
+
},
|
|
2053
|
+
{
|
|
2054
|
+
type: "function",
|
|
2055
|
+
name: "getUserTokensInRange",
|
|
2056
|
+
inputs: [
|
|
2057
|
+
{ name: "user", type: "address", internalType: "address" },
|
|
2058
|
+
{ name: "startIndex", type: "uint256", internalType: "uint256" },
|
|
2059
|
+
{ name: "endIndex", type: "uint256", internalType: "uint256" }
|
|
2060
|
+
],
|
|
2061
|
+
outputs: [
|
|
2062
|
+
{
|
|
2063
|
+
name: "",
|
|
2064
|
+
type: "tuple[]",
|
|
2065
|
+
internalType: "struct UserUpvoteContract.TokenInfo[]",
|
|
2066
|
+
components: [
|
|
2067
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
2068
|
+
{ name: "feeTier", type: "uint24", internalType: "uint24" }
|
|
2069
|
+
]
|
|
2070
|
+
}
|
|
2071
|
+
],
|
|
2072
|
+
stateMutability: "view"
|
|
2073
|
+
},
|
|
2074
|
+
{
|
|
2075
|
+
type: "function",
|
|
2076
|
+
name: "getUserUpvotesGiven",
|
|
2077
|
+
inputs: [
|
|
2078
|
+
{ name: "user", type: "address", internalType: "address" }
|
|
2079
|
+
],
|
|
2080
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2081
|
+
stateMutability: "view"
|
|
2082
|
+
},
|
|
2083
|
+
{
|
|
2084
|
+
type: "function",
|
|
2085
|
+
name: "getUserUpvotesGivenPerToken",
|
|
2086
|
+
inputs: [
|
|
2087
|
+
{ name: "user", type: "address", internalType: "address" },
|
|
2088
|
+
{ name: "token", type: "address", internalType: "address" }
|
|
2089
|
+
],
|
|
2090
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2091
|
+
stateMutability: "view"
|
|
2092
|
+
},
|
|
2093
|
+
{
|
|
2094
|
+
type: "function",
|
|
2095
|
+
name: "getUserUpvotesGivenPerTokenBatch",
|
|
2096
|
+
inputs: [
|
|
2097
|
+
{ name: "user", type: "address", internalType: "address" },
|
|
2098
|
+
{ name: "tokens", type: "address[]", internalType: "address[]" }
|
|
2099
|
+
],
|
|
2100
|
+
outputs: [
|
|
2101
|
+
{ name: "", type: "uint256[]", internalType: "uint256[]" }
|
|
2102
|
+
],
|
|
2103
|
+
stateMutability: "view"
|
|
2104
|
+
},
|
|
2105
|
+
{
|
|
2106
|
+
type: "function",
|
|
2107
|
+
name: "getUserUpvotesReceived",
|
|
2108
|
+
inputs: [
|
|
2109
|
+
{ name: "user", type: "address", internalType: "address" }
|
|
2110
|
+
],
|
|
2111
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2112
|
+
stateMutability: "view"
|
|
2113
|
+
},
|
|
2114
|
+
{
|
|
2115
|
+
type: "function",
|
|
2116
|
+
name: "getUserUpvotesReceivedPerToken",
|
|
2117
|
+
inputs: [
|
|
2118
|
+
{ name: "user", type: "address", internalType: "address" },
|
|
2119
|
+
{ name: "token", type: "address", internalType: "address" }
|
|
2120
|
+
],
|
|
2121
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2122
|
+
stateMutability: "view"
|
|
2123
|
+
},
|
|
2124
|
+
{
|
|
2125
|
+
type: "function",
|
|
2126
|
+
name: "getUserUpvotesReceivedPerTokenBatch",
|
|
2127
|
+
inputs: [
|
|
2128
|
+
{ name: "user", type: "address", internalType: "address" },
|
|
2129
|
+
{ name: "tokens", type: "address[]", internalType: "address[]" }
|
|
2130
|
+
],
|
|
2131
|
+
outputs: [
|
|
2132
|
+
{ name: "", type: "uint256[]", internalType: "uint256[]" }
|
|
2133
|
+
],
|
|
2134
|
+
stateMutability: "view"
|
|
2135
|
+
},
|
|
2136
|
+
{
|
|
2137
|
+
type: "function",
|
|
2138
|
+
name: "isTokenInUserList",
|
|
2139
|
+
inputs: [
|
|
2140
|
+
{ name: "user", type: "address", internalType: "address" },
|
|
2141
|
+
{ name: "token", type: "address", internalType: "address" }
|
|
2142
|
+
],
|
|
2143
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
2144
|
+
stateMutability: "view"
|
|
2145
|
+
},
|
|
2146
|
+
{
|
|
2147
|
+
type: "function",
|
|
2148
|
+
name: "owner",
|
|
2149
|
+
inputs: [],
|
|
2150
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2151
|
+
stateMutability: "view"
|
|
2152
|
+
},
|
|
2153
|
+
{
|
|
2154
|
+
type: "function",
|
|
2155
|
+
name: "removeTokenFromList",
|
|
2156
|
+
inputs: [
|
|
2157
|
+
{ name: "token", type: "address", internalType: "address" }
|
|
2158
|
+
],
|
|
2159
|
+
outputs: [],
|
|
2160
|
+
stateMutability: "nonpayable"
|
|
2161
|
+
},
|
|
2162
|
+
{
|
|
2163
|
+
type: "function",
|
|
2164
|
+
name: "renounceOwnership",
|
|
2165
|
+
inputs: [],
|
|
2166
|
+
outputs: [],
|
|
2167
|
+
stateMutability: "nonpayable"
|
|
2168
|
+
},
|
|
2169
|
+
{
|
|
2170
|
+
type: "function",
|
|
2171
|
+
name: "setFeeBps",
|
|
2172
|
+
inputs: [
|
|
2173
|
+
{ name: "newFeeBps", type: "uint256", internalType: "uint256" }
|
|
2174
|
+
],
|
|
2175
|
+
outputs: [],
|
|
2176
|
+
stateMutability: "nonpayable"
|
|
2177
|
+
},
|
|
2178
|
+
{
|
|
2179
|
+
type: "function",
|
|
2180
|
+
name: "setUpvotePrice",
|
|
2181
|
+
inputs: [
|
|
2182
|
+
{ name: "newUpvotePrice", type: "uint256", internalType: "uint256" }
|
|
2183
|
+
],
|
|
2184
|
+
outputs: [],
|
|
2185
|
+
stateMutability: "nonpayable"
|
|
2186
|
+
},
|
|
2187
|
+
{
|
|
2188
|
+
type: "function",
|
|
2189
|
+
name: "totalUpvotesPerToken",
|
|
2190
|
+
inputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2191
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2192
|
+
stateMutability: "view"
|
|
2193
|
+
},
|
|
2194
|
+
{
|
|
2195
|
+
type: "function",
|
|
2196
|
+
name: "transferOwnership",
|
|
2197
|
+
inputs: [
|
|
2198
|
+
{ name: "newOwner", type: "address", internalType: "address" }
|
|
2199
|
+
],
|
|
2200
|
+
outputs: [],
|
|
2201
|
+
stateMutability: "nonpayable"
|
|
2202
|
+
},
|
|
2203
|
+
{
|
|
2204
|
+
type: "function",
|
|
2205
|
+
name: "upvotePrice",
|
|
2206
|
+
inputs: [],
|
|
2207
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2208
|
+
stateMutability: "view"
|
|
2209
|
+
},
|
|
2210
|
+
{
|
|
2211
|
+
type: "function",
|
|
2212
|
+
name: "upvoteUser",
|
|
2213
|
+
inputs: [
|
|
2214
|
+
{ name: "userToUpvote", type: "address", internalType: "address" },
|
|
2215
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
2216
|
+
{ name: "numUpvotes", type: "uint256", internalType: "uint256" },
|
|
2217
|
+
{ name: "feeTier", type: "uint24", internalType: "uint24" }
|
|
2218
|
+
],
|
|
2219
|
+
outputs: [],
|
|
2220
|
+
stateMutability: "payable"
|
|
2221
|
+
},
|
|
2222
|
+
{
|
|
2223
|
+
type: "function",
|
|
2224
|
+
name: "userTokenCount",
|
|
2225
|
+
inputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2226
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2227
|
+
stateMutability: "view"
|
|
2228
|
+
},
|
|
2229
|
+
{
|
|
2230
|
+
type: "function",
|
|
2231
|
+
name: "userTokenExists",
|
|
2232
|
+
inputs: [
|
|
2233
|
+
{ name: "", type: "address", internalType: "address" },
|
|
2234
|
+
{ name: "", type: "address", internalType: "address" }
|
|
2235
|
+
],
|
|
2236
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
2237
|
+
stateMutability: "view"
|
|
2238
|
+
},
|
|
2239
|
+
{
|
|
2240
|
+
type: "function",
|
|
2241
|
+
name: "userTokenFeeTiers",
|
|
2242
|
+
inputs: [
|
|
2243
|
+
{ name: "", type: "address", internalType: "address" },
|
|
2244
|
+
{ name: "", type: "address", internalType: "address" }
|
|
2245
|
+
],
|
|
2246
|
+
outputs: [{ name: "", type: "uint24", internalType: "uint24" }],
|
|
2247
|
+
stateMutability: "view"
|
|
2248
|
+
},
|
|
2249
|
+
{
|
|
2250
|
+
type: "function",
|
|
2251
|
+
name: "userTokenSeen",
|
|
2252
|
+
inputs: [
|
|
2253
|
+
{ name: "", type: "address", internalType: "address" },
|
|
2254
|
+
{ name: "", type: "address", internalType: "address" }
|
|
2255
|
+
],
|
|
2256
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
2257
|
+
stateMutability: "view"
|
|
2258
|
+
},
|
|
2259
|
+
{
|
|
2260
|
+
type: "function",
|
|
2261
|
+
name: "userTokens",
|
|
2262
|
+
inputs: [
|
|
2263
|
+
{ name: "", type: "address", internalType: "address" },
|
|
2264
|
+
{ name: "", type: "uint256", internalType: "uint256" }
|
|
2265
|
+
],
|
|
2266
|
+
outputs: [
|
|
2267
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
2268
|
+
{ name: "feeTier", type: "uint24", internalType: "uint24" }
|
|
2269
|
+
],
|
|
2270
|
+
stateMutability: "view"
|
|
2271
|
+
},
|
|
2272
|
+
{
|
|
2273
|
+
type: "function",
|
|
2274
|
+
name: "userUpvotesGiven",
|
|
2275
|
+
inputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2276
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2277
|
+
stateMutability: "view"
|
|
2278
|
+
},
|
|
2279
|
+
{
|
|
2280
|
+
type: "function",
|
|
2281
|
+
name: "userUpvotesGivenPerToken",
|
|
2282
|
+
inputs: [
|
|
2283
|
+
{ name: "", type: "address", internalType: "address" },
|
|
2284
|
+
{ name: "", type: "address", internalType: "address" }
|
|
2285
|
+
],
|
|
2286
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2287
|
+
stateMutability: "view"
|
|
2288
|
+
},
|
|
2289
|
+
{
|
|
2290
|
+
type: "function",
|
|
2291
|
+
name: "userUpvotesReceived",
|
|
2292
|
+
inputs: [{ name: "", type: "address", internalType: "address" }],
|
|
2293
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2294
|
+
stateMutability: "view"
|
|
2295
|
+
},
|
|
2296
|
+
{
|
|
2297
|
+
type: "function",
|
|
2298
|
+
name: "userUpvotesReceivedPerToken",
|
|
2299
|
+
inputs: [
|
|
2300
|
+
{ name: "", type: "address", internalType: "address" },
|
|
2301
|
+
{ name: "", type: "address", internalType: "address" }
|
|
2302
|
+
],
|
|
2303
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2304
|
+
stateMutability: "view"
|
|
2305
|
+
},
|
|
2306
|
+
{
|
|
2307
|
+
type: "function",
|
|
2308
|
+
name: "withdrawErc20",
|
|
2309
|
+
inputs: [
|
|
2310
|
+
{ name: "to", type: "address", internalType: "address" },
|
|
2311
|
+
{ name: "token", type: "address", internalType: "address" }
|
|
2312
|
+
],
|
|
2313
|
+
outputs: [],
|
|
2314
|
+
stateMutability: "nonpayable"
|
|
2315
|
+
},
|
|
2316
|
+
{
|
|
2317
|
+
type: "event",
|
|
2318
|
+
name: "OwnershipTransferred",
|
|
2319
|
+
inputs: [
|
|
2320
|
+
{ name: "previousOwner", type: "address", indexed: true, internalType: "address" },
|
|
2321
|
+
{ name: "newOwner", type: "address", indexed: true, internalType: "address" }
|
|
2322
|
+
],
|
|
2323
|
+
anonymous: false
|
|
2324
|
+
},
|
|
2325
|
+
{
|
|
2326
|
+
type: "event",
|
|
2327
|
+
name: "TokenAddedToList",
|
|
2328
|
+
inputs: [
|
|
2329
|
+
{ name: "user", type: "address", indexed: true, internalType: "address" },
|
|
2330
|
+
{ name: "token", type: "address", indexed: true, internalType: "address" },
|
|
2331
|
+
{ name: "feeTier", type: "uint24", indexed: false, internalType: "uint24" }
|
|
2332
|
+
],
|
|
2333
|
+
anonymous: false
|
|
2334
|
+
},
|
|
2335
|
+
{
|
|
2336
|
+
type: "event",
|
|
2337
|
+
name: "TokenRemovedFromList",
|
|
2338
|
+
inputs: [
|
|
2339
|
+
{ name: "user", type: "address", indexed: true, internalType: "address" },
|
|
2340
|
+
{ name: "token", type: "address", indexed: true, internalType: "address" }
|
|
2341
|
+
],
|
|
2342
|
+
anonymous: false
|
|
2343
|
+
},
|
|
2344
|
+
{
|
|
2345
|
+
type: "event",
|
|
2346
|
+
name: "UserUpvoted",
|
|
2347
|
+
inputs: [
|
|
2348
|
+
{ name: "upvoter", type: "address", indexed: true, internalType: "address" },
|
|
2349
|
+
{ name: "upvotedUser", type: "address", indexed: true, internalType: "address" },
|
|
2350
|
+
{ name: "token", type: "address", indexed: true, internalType: "address" },
|
|
2351
|
+
{ name: "numUpvotes", type: "uint256", indexed: false, internalType: "uint256" }
|
|
2352
|
+
],
|
|
2353
|
+
anonymous: false
|
|
2354
|
+
},
|
|
2355
|
+
{ type: "error", name: "IncorrectEthSent", inputs: [] },
|
|
2356
|
+
{ type: "error", name: "MaxTokensReached", inputs: [] },
|
|
2357
|
+
{ type: "error", name: "NoAlphaToWithdraw", inputs: [] },
|
|
2358
|
+
{
|
|
2359
|
+
type: "error",
|
|
2360
|
+
name: "OwnableInvalidOwner",
|
|
2361
|
+
inputs: [{ name: "owner", type: "address", internalType: "address" }]
|
|
2362
|
+
},
|
|
2363
|
+
{
|
|
2364
|
+
type: "error",
|
|
2365
|
+
name: "OwnableUnauthorizedAccount",
|
|
2366
|
+
inputs: [{ name: "account", type: "address", internalType: "address" }]
|
|
2367
|
+
},
|
|
2368
|
+
{
|
|
2369
|
+
type: "error",
|
|
2370
|
+
name: "PoolNotFound",
|
|
2371
|
+
inputs: [
|
|
2372
|
+
{ name: "tokenA", type: "address", internalType: "address" },
|
|
2373
|
+
{ name: "tokenB", type: "address", internalType: "address" },
|
|
2374
|
+
{ name: "feeTier", type: "uint24", internalType: "uint24" }
|
|
2375
|
+
]
|
|
2376
|
+
},
|
|
2377
|
+
{ type: "error", name: "ReentrancyGuardReentrantCall", inputs: [] },
|
|
2378
|
+
{
|
|
2379
|
+
type: "error",
|
|
2380
|
+
name: "Slot0ReadFailed",
|
|
2381
|
+
inputs: [{ name: "pool", type: "address", internalType: "address" }]
|
|
2382
|
+
},
|
|
2383
|
+
{
|
|
2384
|
+
type: "error",
|
|
2385
|
+
name: "StringsInsufficientHexLength",
|
|
2386
|
+
inputs: [
|
|
2387
|
+
{ name: "value", type: "uint256", internalType: "uint256" },
|
|
2388
|
+
{ name: "length", type: "uint256", internalType: "uint256" }
|
|
2389
|
+
]
|
|
2390
|
+
},
|
|
2391
|
+
{ type: "error", name: "TokenAlreadyInList", inputs: [] },
|
|
2392
|
+
{ type: "error", name: "TokenNotInUserList", inputs: [] },
|
|
2393
|
+
{ type: "error", name: "UserCannotUpvoteSelf", inputs: [] },
|
|
2394
|
+
{ type: "error", name: "WithdrawFailed", inputs: [] },
|
|
2395
|
+
{ type: "error", name: "ZeroUpvotes", inputs: [] }
|
|
2396
|
+
];
|
|
2397
|
+
|
|
1937
2398
|
// src/constants.ts
|
|
1938
2399
|
var SCORE_CONTRACT = {
|
|
1939
2400
|
address: "0x0000000fa09b022e5616e5a173b4b67fa2fbcf28",
|
|
@@ -1975,9 +2436,25 @@ var MULTI_VERSION_UNISWAP_POOL_INFO_RETRIEVER = {
|
|
|
1975
2436
|
address: "0x7A9EF0AC6F6a254cd570B05D62D094D3aa5067f1",
|
|
1976
2437
|
abi: multi_version_uniswap_pool_info_retriever_default
|
|
1977
2438
|
};
|
|
1978
|
-
var
|
|
2439
|
+
var WETH_BY_CHAIN = {
|
|
2440
|
+
8453: "0x4200000000000000000000000000000000000006",
|
|
2441
|
+
// Base (L2 predeploy)
|
|
2442
|
+
1: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
|
|
2443
|
+
// Ethereum mainnet
|
|
2444
|
+
};
|
|
2445
|
+
function getWethAddress(chainId) {
|
|
2446
|
+
const addr = WETH_BY_CHAIN[chainId];
|
|
2447
|
+
if (!addr) {
|
|
2448
|
+
throw new Error(`Score: No WETH address for chain ${chainId}`);
|
|
2449
|
+
}
|
|
2450
|
+
return addr;
|
|
2451
|
+
}
|
|
1979
2452
|
var NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
1980
2453
|
var UPVOTE_PRICE_ETH = 25e-6;
|
|
2454
|
+
var USER_UPVOTE_CONTRACT = {
|
|
2455
|
+
address: "0xa4bc2c63dd0157692fd5f409389e5032e37d8895",
|
|
2456
|
+
abi: user_upvote_default
|
|
2457
|
+
};
|
|
1981
2458
|
var encodeUpvoteKey = (tokenAddress) => {
|
|
1982
2459
|
return `0x${BigInt(`0x${tokenAddress.slice(2)}`).toString(16).padStart(64, "0")}`;
|
|
1983
2460
|
};
|
|
@@ -2369,6 +2846,280 @@ var ScoreClient = class {
|
|
|
2369
2846
|
return [];
|
|
2370
2847
|
}
|
|
2371
2848
|
};
|
|
2849
|
+
function parseUserUpvoteMessage(message, topic) {
|
|
2850
|
+
try {
|
|
2851
|
+
if (topic.startsWith("ub-")) {
|
|
2852
|
+
const [
|
|
2853
|
+
upvotedUserString,
|
|
2854
|
+
actualToken,
|
|
2855
|
+
numUpvotes,
|
|
2856
|
+
tokenWethPrice,
|
|
2857
|
+
wethUsdcPrice,
|
|
2858
|
+
alphaWethPrice,
|
|
2859
|
+
userTokenBalance
|
|
2860
|
+
] = viem.decodeAbiParameters(
|
|
2861
|
+
[
|
|
2862
|
+
{ type: "string" },
|
|
2863
|
+
{ type: "address" },
|
|
2864
|
+
{ type: "uint256" },
|
|
2865
|
+
{ type: "uint256" },
|
|
2866
|
+
{ type: "uint256" },
|
|
2867
|
+
{ type: "uint256" },
|
|
2868
|
+
{ type: "uint256" }
|
|
2869
|
+
],
|
|
2870
|
+
message.data
|
|
2871
|
+
);
|
|
2872
|
+
return {
|
|
2873
|
+
upvotedUserString,
|
|
2874
|
+
actualToken,
|
|
2875
|
+
numUpvotes: Number(numUpvotes),
|
|
2876
|
+
tokenWethPrice,
|
|
2877
|
+
wethUsdcPrice,
|
|
2878
|
+
alphaWethPrice,
|
|
2879
|
+
userTokenBalance
|
|
2880
|
+
};
|
|
2881
|
+
} else {
|
|
2882
|
+
const [
|
|
2883
|
+
upvotedUserString,
|
|
2884
|
+
actualToken,
|
|
2885
|
+
numUpvotes,
|
|
2886
|
+
tokenWethPrice,
|
|
2887
|
+
wethUsdcPrice,
|
|
2888
|
+
alphaWethPrice
|
|
2889
|
+
] = viem.decodeAbiParameters(
|
|
2890
|
+
[
|
|
2891
|
+
{ type: "string" },
|
|
2892
|
+
{ type: "address" },
|
|
2893
|
+
{ type: "uint256" },
|
|
2894
|
+
{ type: "uint256" },
|
|
2895
|
+
{ type: "uint256" },
|
|
2896
|
+
{ type: "uint256" }
|
|
2897
|
+
],
|
|
2898
|
+
message.data
|
|
2899
|
+
);
|
|
2900
|
+
return {
|
|
2901
|
+
upvotedUserString,
|
|
2902
|
+
actualToken,
|
|
2903
|
+
numUpvotes: Number(numUpvotes),
|
|
2904
|
+
tokenWethPrice,
|
|
2905
|
+
wethUsdcPrice,
|
|
2906
|
+
alphaWethPrice
|
|
2907
|
+
};
|
|
2908
|
+
}
|
|
2909
|
+
} catch {
|
|
2910
|
+
return null;
|
|
2911
|
+
}
|
|
2912
|
+
}
|
|
2913
|
+
function extractTokenAddressesFromMessages(messages, topic) {
|
|
2914
|
+
const tokenSet = /* @__PURE__ */ new Set();
|
|
2915
|
+
const validMessages = [];
|
|
2916
|
+
for (const message of messages) {
|
|
2917
|
+
const parsed = parseUserUpvoteMessage(message, topic);
|
|
2918
|
+
if (parsed) {
|
|
2919
|
+
tokenSet.add(parsed.actualToken.toLowerCase());
|
|
2920
|
+
validMessages.push(parsed);
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
return {
|
|
2924
|
+
tokenAddresses: Array.from(tokenSet),
|
|
2925
|
+
validMessages
|
|
2926
|
+
};
|
|
2927
|
+
}
|
|
2928
|
+
function validateUserUpvoteMessage(message, topic) {
|
|
2929
|
+
return parseUserUpvoteMessage(message, topic) !== null;
|
|
2930
|
+
}
|
|
2931
|
+
function calculatePriceInUsdc(parsedMessage, tokenDecimals = 18) {
|
|
2932
|
+
const { tokenWethPrice, wethUsdcPrice } = parsedMessage;
|
|
2933
|
+
if (tokenWethPrice > 0n && wethUsdcPrice > 0n) {
|
|
2934
|
+
const scale = 10 ** (36 - tokenDecimals);
|
|
2935
|
+
const tokenWethPriceNum = Number(tokenWethPrice) / scale;
|
|
2936
|
+
const wethUsdcPriceNum = Number(wethUsdcPrice) / 1e6;
|
|
2937
|
+
return tokenWethPriceNum * wethUsdcPriceNum;
|
|
2938
|
+
}
|
|
2939
|
+
return void 0;
|
|
2940
|
+
}
|
|
2941
|
+
function calculateUserTokenBalance(rawBalance, tokenDecimals = 18) {
|
|
2942
|
+
return Number(rawBalance) / Math.pow(10, tokenDecimals);
|
|
2943
|
+
}
|
|
2944
|
+
function validateUpvoteParams(params) {
|
|
2945
|
+
if (viem.isAddressEqual(params.sender, params.userToUpvote)) {
|
|
2946
|
+
return { valid: false, error: "Cannot upvote yourself" };
|
|
2947
|
+
}
|
|
2948
|
+
if (!Number.isInteger(params.numUpvotes)) {
|
|
2949
|
+
return { valid: false, error: "Number of upvotes must be a whole number" };
|
|
2950
|
+
}
|
|
2951
|
+
if (params.numUpvotes <= 0) {
|
|
2952
|
+
return { valid: false, error: "Number of upvotes must be greater than zero" };
|
|
2953
|
+
}
|
|
2954
|
+
return { valid: true };
|
|
2955
|
+
}
|
|
2956
|
+
function calculateUpvoteCost(numUpvotes, upvotePrice) {
|
|
2957
|
+
return BigInt(numUpvotes) * upvotePrice;
|
|
2958
|
+
}
|
|
2959
|
+
function computeEnrichedFields(parsed, tokenInfo) {
|
|
2960
|
+
const decimals = tokenInfo?.decimals ?? 18;
|
|
2961
|
+
const priceInUsdc = calculatePriceInUsdc(parsed, decimals);
|
|
2962
|
+
const userTokenBalance = parsed.userTokenBalance ? calculateUserTokenBalance(parsed.userTokenBalance, decimals) : 0;
|
|
2963
|
+
const userTokenBalanceUsdValue = priceInUsdc !== void 0 && userTokenBalance > 0 ? priceInUsdc * userTokenBalance : void 0;
|
|
2964
|
+
return { priceInUsdc, userTokenBalance, userTokenBalanceUsdValue };
|
|
2965
|
+
}
|
|
2966
|
+
function buildUserUpvote(parsed, timestamp, tokenInfo) {
|
|
2967
|
+
return {
|
|
2968
|
+
tokenAddress: parsed.actualToken,
|
|
2969
|
+
numUpvotes: parsed.numUpvotes,
|
|
2970
|
+
timestamp,
|
|
2971
|
+
...computeEnrichedFields(parsed, tokenInfo),
|
|
2972
|
+
upvotedUserAddress: parsed.upvotedUserString,
|
|
2973
|
+
tokenInfo
|
|
2974
|
+
};
|
|
2975
|
+
}
|
|
2976
|
+
function buildUserUpvoteReceived(parsed, upvoterAddress, timestamp, tokenInfo) {
|
|
2977
|
+
return {
|
|
2978
|
+
upvoterAddress,
|
|
2979
|
+
tokenAddress: parsed.actualToken,
|
|
2980
|
+
numUpvotes: parsed.numUpvotes,
|
|
2981
|
+
timestamp,
|
|
2982
|
+
...computeEnrichedFields(parsed, tokenInfo),
|
|
2983
|
+
tokenInfo
|
|
2984
|
+
};
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
// src/user-upvote/UserUpvoteClient.ts
|
|
2988
|
+
var UserUpvoteClient = class {
|
|
2989
|
+
constructor(params) {
|
|
2990
|
+
this.chainId = params.chainId;
|
|
2991
|
+
this.client = core.getPublicClient({
|
|
2992
|
+
chainId: params.chainId,
|
|
2993
|
+
rpcUrl: params.overrides?.rpcUrls
|
|
2994
|
+
});
|
|
2995
|
+
this.contractAddress = params.overrides?.contractAddress ?? USER_UPVOTE_CONTRACT.address;
|
|
2996
|
+
}
|
|
2997
|
+
async getUserUpvotesGiven({ user }) {
|
|
2998
|
+
const data = await actions.readContract(this.client, {
|
|
2999
|
+
address: this.contractAddress,
|
|
3000
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3001
|
+
functionName: "getUserUpvotesGiven",
|
|
3002
|
+
args: [user]
|
|
3003
|
+
});
|
|
3004
|
+
return data;
|
|
3005
|
+
}
|
|
3006
|
+
async getUserUpvotesReceived({ user }) {
|
|
3007
|
+
const data = await actions.readContract(this.client, {
|
|
3008
|
+
address: this.contractAddress,
|
|
3009
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3010
|
+
functionName: "getUserUpvotesReceived",
|
|
3011
|
+
args: [user]
|
|
3012
|
+
});
|
|
3013
|
+
return data;
|
|
3014
|
+
}
|
|
3015
|
+
async getUserUpvotesGivenPerTokenBatch({
|
|
3016
|
+
user,
|
|
3017
|
+
tokens
|
|
3018
|
+
}) {
|
|
3019
|
+
const data = await actions.readContract(this.client, {
|
|
3020
|
+
address: this.contractAddress,
|
|
3021
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3022
|
+
functionName: "getUserUpvotesGivenPerTokenBatch",
|
|
3023
|
+
args: [user, tokens]
|
|
3024
|
+
});
|
|
3025
|
+
return data;
|
|
3026
|
+
}
|
|
3027
|
+
async getUserUpvotesReceivedPerTokenBatch({
|
|
3028
|
+
user,
|
|
3029
|
+
tokens
|
|
3030
|
+
}) {
|
|
3031
|
+
const data = await actions.readContract(this.client, {
|
|
3032
|
+
address: this.contractAddress,
|
|
3033
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3034
|
+
functionName: "getUserUpvotesReceivedPerTokenBatch",
|
|
3035
|
+
args: [user, tokens]
|
|
3036
|
+
});
|
|
3037
|
+
return data;
|
|
3038
|
+
}
|
|
3039
|
+
async getTotalUpvotesPerToken({
|
|
3040
|
+
token
|
|
3041
|
+
}) {
|
|
3042
|
+
const data = await actions.readContract(this.client, {
|
|
3043
|
+
address: this.contractAddress,
|
|
3044
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3045
|
+
functionName: "getTotalUpvotesPerToken",
|
|
3046
|
+
args: [token]
|
|
3047
|
+
});
|
|
3048
|
+
return data;
|
|
3049
|
+
}
|
|
3050
|
+
async getUserTokensInRange({
|
|
3051
|
+
user,
|
|
3052
|
+
startIndex,
|
|
3053
|
+
endIndex
|
|
3054
|
+
}) {
|
|
3055
|
+
const data = await actions.readContract(this.client, {
|
|
3056
|
+
address: this.contractAddress,
|
|
3057
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3058
|
+
functionName: "getUserTokensInRange",
|
|
3059
|
+
args: [user, BigInt(startIndex), BigInt(endIndex)]
|
|
3060
|
+
});
|
|
3061
|
+
return data.map((item) => ({
|
|
3062
|
+
token: item.token,
|
|
3063
|
+
feeTier: Number(item.feeTier)
|
|
3064
|
+
}));
|
|
3065
|
+
}
|
|
3066
|
+
async getUserTokenCount({ user }) {
|
|
3067
|
+
const data = await actions.readContract(this.client, {
|
|
3068
|
+
address: this.contractAddress,
|
|
3069
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3070
|
+
functionName: "getUserTokenCount",
|
|
3071
|
+
args: [user]
|
|
3072
|
+
});
|
|
3073
|
+
return Number(data);
|
|
3074
|
+
}
|
|
3075
|
+
async isTokenInUserList({
|
|
3076
|
+
user,
|
|
3077
|
+
token
|
|
3078
|
+
}) {
|
|
3079
|
+
const data = await actions.readContract(this.client, {
|
|
3080
|
+
address: this.contractAddress,
|
|
3081
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3082
|
+
functionName: "isTokenInUserList",
|
|
3083
|
+
args: [user, token]
|
|
3084
|
+
});
|
|
3085
|
+
return data;
|
|
3086
|
+
}
|
|
3087
|
+
async getUpvotePrice() {
|
|
3088
|
+
const data = await actions.readContract(this.client, {
|
|
3089
|
+
address: this.contractAddress,
|
|
3090
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3091
|
+
functionName: "upvotePrice"
|
|
3092
|
+
});
|
|
3093
|
+
return data;
|
|
3094
|
+
}
|
|
3095
|
+
async upvoteUser({
|
|
3096
|
+
walletClient,
|
|
3097
|
+
userToUpvote,
|
|
3098
|
+
token = NULL_ADDRESS,
|
|
3099
|
+
numUpvotes,
|
|
3100
|
+
feeTier = 0,
|
|
3101
|
+
value: providedValue
|
|
3102
|
+
}) {
|
|
3103
|
+
const sender = walletClient.account?.address;
|
|
3104
|
+
if (sender) {
|
|
3105
|
+
const validation = validateUpvoteParams({ sender, userToUpvote, numUpvotes });
|
|
3106
|
+
if (!validation.valid) {
|
|
3107
|
+
throw new Error(validation.error);
|
|
3108
|
+
}
|
|
3109
|
+
}
|
|
3110
|
+
const value = providedValue ?? calculateUpvoteCost(numUpvotes, await this.getUpvotePrice());
|
|
3111
|
+
const hash = await walletClient.writeContract({
|
|
3112
|
+
address: this.contractAddress,
|
|
3113
|
+
abi: USER_UPVOTE_CONTRACT.abi,
|
|
3114
|
+
functionName: "upvoteUser",
|
|
3115
|
+
args: [userToUpvote, token, BigInt(numUpvotes), BigInt(feeTier)],
|
|
3116
|
+
value,
|
|
3117
|
+
chain: null,
|
|
3118
|
+
dataSuffix: core.getBaseDataSuffix(this.chainId)
|
|
3119
|
+
});
|
|
3120
|
+
return hash;
|
|
3121
|
+
}
|
|
3122
|
+
};
|
|
2372
3123
|
var encodePoolKey = (poolKey) => {
|
|
2373
3124
|
if (!poolKey || !isValidPoolKey2(poolKey)) {
|
|
2374
3125
|
return "0x";
|
|
@@ -2417,10 +3168,10 @@ var V4_HOOKS = [
|
|
|
2417
3168
|
];
|
|
2418
3169
|
var LIQUIDITY_THRESHOLD_TO_PREFER_V2_V3_POOLS = 0.1 * 1e18;
|
|
2419
3170
|
var LIQUIDITY_THRESHOLD_TO_CONSIDER_V2_V3_POOLS = 0.01 * 1e18;
|
|
2420
|
-
function normalizeTokenPairs(pairs) {
|
|
3171
|
+
function normalizeTokenPairs(pairs, wethAddress) {
|
|
2421
3172
|
return pairs.map((pair) => {
|
|
2422
3173
|
const tokenA = pair.tokenAddress;
|
|
2423
|
-
const tokenB = pair.baseTokenAddress ||
|
|
3174
|
+
const tokenB = pair.baseTokenAddress || wethAddress;
|
|
2424
3175
|
return {
|
|
2425
3176
|
originalPair: pair,
|
|
2426
3177
|
tokenA: tokenA.toLowerCase() < tokenB.toLowerCase() ? tokenA : tokenB,
|
|
@@ -2437,7 +3188,7 @@ function buildDiscoveryArgs(normalizedPairs) {
|
|
|
2437
3188
|
v4Hooks: V4_HOOKS
|
|
2438
3189
|
};
|
|
2439
3190
|
}
|
|
2440
|
-
function parsePoolDiscoveries(poolResults, pairs) {
|
|
3191
|
+
function parsePoolDiscoveries(poolResults, pairs, wethAddress) {
|
|
2441
3192
|
if (!poolResults) {
|
|
2442
3193
|
return {
|
|
2443
3194
|
v2PoolAddresses: [],
|
|
@@ -2474,7 +3225,7 @@ function parsePoolDiscoveries(poolResults, pairs) {
|
|
|
2474
3225
|
v2PoolAddresses.push(poolAddressValue);
|
|
2475
3226
|
v2PoolAddressToPair[poolAddress] = {
|
|
2476
3227
|
tokenAddress: pair.tokenAddress,
|
|
2477
|
-
baseTokenAddress: pair.baseTokenAddress ||
|
|
3228
|
+
baseTokenAddress: pair.baseTokenAddress || wethAddress,
|
|
2478
3229
|
fee: feeNum
|
|
2479
3230
|
};
|
|
2480
3231
|
}
|
|
@@ -2485,7 +3236,7 @@ function parsePoolDiscoveries(poolResults, pairs) {
|
|
|
2485
3236
|
v3PoolAddresses.push(poolAddressValue);
|
|
2486
3237
|
v3PoolAddressToPair[poolAddress] = {
|
|
2487
3238
|
tokenAddress: pair.tokenAddress,
|
|
2488
|
-
baseTokenAddress: pair.baseTokenAddress ||
|
|
3239
|
+
baseTokenAddress: pair.baseTokenAddress || wethAddress,
|
|
2489
3240
|
fee: feeNum
|
|
2490
3241
|
};
|
|
2491
3242
|
}
|
|
@@ -2496,7 +3247,7 @@ function parsePoolDiscoveries(poolResults, pairs) {
|
|
|
2496
3247
|
v4PoolKeys.push(poolKey);
|
|
2497
3248
|
v4PoolKeyToPair[poolKeyString] = {
|
|
2498
3249
|
tokenAddress: pair.tokenAddress,
|
|
2499
|
-
baseTokenAddress: pair.baseTokenAddress ||
|
|
3250
|
+
baseTokenAddress: pair.baseTokenAddress || wethAddress,
|
|
2500
3251
|
fee: feeNum
|
|
2501
3252
|
};
|
|
2502
3253
|
}
|
|
@@ -2623,19 +3374,19 @@ function constructPoolKey(info, pair, version, v4PoolKey) {
|
|
|
2623
3374
|
return void 0;
|
|
2624
3375
|
}
|
|
2625
3376
|
}
|
|
2626
|
-
function getWethBalanceWei(pool) {
|
|
2627
|
-
if (pool.token0?.toLowerCase() ===
|
|
3377
|
+
function getWethBalanceWei(pool, wethAddress) {
|
|
3378
|
+
if (pool.token0?.toLowerCase() === wethAddress.toLowerCase()) {
|
|
2628
3379
|
return Number(pool.token0Balance);
|
|
2629
|
-
} else if (pool.token1?.toLowerCase() ===
|
|
3380
|
+
} else if (pool.token1?.toLowerCase() === wethAddress.toLowerCase()) {
|
|
2630
3381
|
return Number(pool.token1Balance);
|
|
2631
3382
|
} else {
|
|
2632
3383
|
return Number(pool.baseTokenBalance);
|
|
2633
3384
|
}
|
|
2634
3385
|
}
|
|
2635
|
-
function filterV2V3PoolsByLiquidity(pools, threshold) {
|
|
3386
|
+
function filterV2V3PoolsByLiquidity(pools, threshold, wethAddress) {
|
|
2636
3387
|
return pools.filter((pool) => {
|
|
2637
3388
|
if (!pool.poolAddress) return false;
|
|
2638
|
-
const wethBalanceWei = getWethBalanceWei(pool);
|
|
3389
|
+
const wethBalanceWei = getWethBalanceWei(pool, wethAddress);
|
|
2639
3390
|
return wethBalanceWei >= threshold;
|
|
2640
3391
|
});
|
|
2641
3392
|
}
|
|
@@ -2658,7 +3409,7 @@ function selectBestV2V3PoolByFee(pools) {
|
|
|
2658
3409
|
return a.fee < b.fee ? a : b;
|
|
2659
3410
|
});
|
|
2660
3411
|
}
|
|
2661
|
-
function selectBestPoolPerPair(allPools) {
|
|
3412
|
+
function selectBestPoolPerPair(allPools, wethAddress) {
|
|
2662
3413
|
const poolsByPair = {};
|
|
2663
3414
|
for (const pool of allPools) {
|
|
2664
3415
|
const key = pool.tokenAddress.toLowerCase() + "_" + pool.baseTokenAddress.toLowerCase();
|
|
@@ -2673,7 +3424,8 @@ function selectBestPoolPerPair(allPools) {
|
|
|
2673
3424
|
} else {
|
|
2674
3425
|
const v2v3PoolsWithPreferredLiquidity = filterV2V3PoolsByLiquidity(
|
|
2675
3426
|
group,
|
|
2676
|
-
LIQUIDITY_THRESHOLD_TO_PREFER_V2_V3_POOLS
|
|
3427
|
+
LIQUIDITY_THRESHOLD_TO_PREFER_V2_V3_POOLS,
|
|
3428
|
+
wethAddress
|
|
2677
3429
|
);
|
|
2678
3430
|
if (v2v3PoolsWithPreferredLiquidity.length > 0) {
|
|
2679
3431
|
best = selectBestV2V3Pool(v2v3PoolsWithPreferredLiquidity);
|
|
@@ -2684,7 +3436,8 @@ function selectBestPoolPerPair(allPools) {
|
|
|
2684
3436
|
} else {
|
|
2685
3437
|
const v2v3PoolsWithAcceptableLiquidity = filterV2V3PoolsByLiquidity(
|
|
2686
3438
|
group,
|
|
2687
|
-
LIQUIDITY_THRESHOLD_TO_CONSIDER_V2_V3_POOLS
|
|
3439
|
+
LIQUIDITY_THRESHOLD_TO_CONSIDER_V2_V3_POOLS,
|
|
3440
|
+
wethAddress
|
|
2688
3441
|
);
|
|
2689
3442
|
if (v2v3PoolsWithAcceptableLiquidity.length > 0) {
|
|
2690
3443
|
best = selectBestV2V3PoolByFee(v2v3PoolsWithAcceptableLiquidity);
|
|
@@ -2700,10 +3453,12 @@ function selectBestPoolPerPair(allPools) {
|
|
|
2700
3453
|
}
|
|
2701
3454
|
async function discoverPools({
|
|
2702
3455
|
publicClient,
|
|
2703
|
-
pairs
|
|
3456
|
+
pairs,
|
|
3457
|
+
chainId = 8453
|
|
2704
3458
|
}) {
|
|
2705
3459
|
if (pairs.length === 0) return [];
|
|
2706
|
-
const
|
|
3460
|
+
const wethAddress = getWethAddress(chainId);
|
|
3461
|
+
const normalizedPairs = normalizeTokenPairs(pairs, wethAddress);
|
|
2707
3462
|
const discoveryArgs = buildDiscoveryArgs(normalizedPairs);
|
|
2708
3463
|
const poolResults = await actions.readContract(publicClient, {
|
|
2709
3464
|
address: MULTI_VERSION_UNISWAP_BULK_POOL_FINDER.address,
|
|
@@ -2711,7 +3466,7 @@ async function discoverPools({
|
|
|
2711
3466
|
functionName: "getPoolsMultiVersion",
|
|
2712
3467
|
args: [discoveryArgs]
|
|
2713
3468
|
});
|
|
2714
|
-
const discoveries = parsePoolDiscoveries(poolResults, pairs);
|
|
3469
|
+
const discoveries = parsePoolDiscoveries(poolResults, pairs, wethAddress);
|
|
2715
3470
|
const totalPools = discoveries.v2PoolAddresses.length + discoveries.v3PoolAddresses.length + discoveries.v4PoolKeys.length;
|
|
2716
3471
|
if (totalPools === 0) return [];
|
|
2717
3472
|
const poolInfos = await actions.readContract(publicClient, {
|
|
@@ -2722,7 +3477,7 @@ async function discoverPools({
|
|
|
2722
3477
|
discoveries.v2PoolAddresses,
|
|
2723
3478
|
discoveries.v3PoolAddresses,
|
|
2724
3479
|
discoveries.v4PoolKeys,
|
|
2725
|
-
|
|
3480
|
+
wethAddress
|
|
2726
3481
|
]
|
|
2727
3482
|
});
|
|
2728
3483
|
if (!Array.isArray(poolInfos) || poolInfos.length === 0) return [];
|
|
@@ -2731,7 +3486,7 @@ async function discoverPools({
|
|
|
2731
3486
|
if (!poolData || !poolData.pair) return null;
|
|
2732
3487
|
return {
|
|
2733
3488
|
tokenAddress: poolData.pair.tokenAddress,
|
|
2734
|
-
baseTokenAddress: poolData.pair.baseTokenAddress ||
|
|
3489
|
+
baseTokenAddress: poolData.pair.baseTokenAddress || wethAddress,
|
|
2735
3490
|
poolAddress: poolData.version === 4 ? null : info.poolAddress,
|
|
2736
3491
|
price: calculatePoolPrice(info, poolData.pair, poolData.version),
|
|
2737
3492
|
baseTokenBalance: String(info.baseTokenBalance || 0),
|
|
@@ -2748,7 +3503,7 @@ async function discoverPools({
|
|
|
2748
3503
|
)
|
|
2749
3504
|
};
|
|
2750
3505
|
}).filter((p) => p !== null);
|
|
2751
|
-
const bestPools = selectBestPoolPerPair(allPools);
|
|
3506
|
+
const bestPools = selectBestPoolPerPair(allPools, wethAddress);
|
|
2752
3507
|
return bestPools.map(
|
|
2753
3508
|
(pool) => ({
|
|
2754
3509
|
tokenAddress: pool.tokenAddress,
|
|
@@ -2767,11 +3522,13 @@ async function discoverPools({
|
|
|
2767
3522
|
}
|
|
2768
3523
|
async function discoverTokenPool({
|
|
2769
3524
|
publicClient,
|
|
2770
|
-
tokenAddress
|
|
3525
|
+
tokenAddress,
|
|
3526
|
+
chainId = 8453
|
|
2771
3527
|
}) {
|
|
2772
3528
|
const results = await discoverPools({
|
|
2773
3529
|
publicClient,
|
|
2774
|
-
pairs: [{ tokenAddress }]
|
|
3530
|
+
pairs: [{ tokenAddress }],
|
|
3531
|
+
chainId
|
|
2775
3532
|
});
|
|
2776
3533
|
return results[0] ?? null;
|
|
2777
3534
|
}
|
|
@@ -2791,8 +3548,14 @@ exports.UNIV234_POOLS_STRATEGY = UNIV234_POOLS_STRATEGY;
|
|
|
2791
3548
|
exports.UPVOTE_APP = UPVOTE_APP;
|
|
2792
3549
|
exports.UPVOTE_PRICE_ETH = UPVOTE_PRICE_ETH;
|
|
2793
3550
|
exports.UPVOTE_STORAGE_APP = UPVOTE_STORAGE_APP;
|
|
2794
|
-
exports.
|
|
3551
|
+
exports.USER_UPVOTE_CONTRACT = USER_UPVOTE_CONTRACT;
|
|
3552
|
+
exports.UserUpvoteClient = UserUpvoteClient;
|
|
3553
|
+
exports.buildUserUpvote = buildUserUpvote;
|
|
3554
|
+
exports.buildUserUpvoteReceived = buildUserUpvoteReceived;
|
|
2795
3555
|
exports.calculatePriceFromSqrtPriceX96 = calculatePriceFromSqrtPriceX96;
|
|
3556
|
+
exports.calculatePriceInUsdc = calculatePriceInUsdc;
|
|
3557
|
+
exports.calculateUpvoteCost = calculateUpvoteCost;
|
|
3558
|
+
exports.calculateUserTokenBalance = calculateUserTokenBalance;
|
|
2796
3559
|
exports.decodeStrategyMetadata = decodeStrategyMetadata;
|
|
2797
3560
|
exports.decodeUpvoteMessage = decodeUpvoteMessage;
|
|
2798
3561
|
exports.decodeUpvoteStorageBlob = decodeUpvoteStorageBlob;
|
|
@@ -2802,18 +3565,23 @@ exports.encodePoolKey = encodePoolKey;
|
|
|
2802
3565
|
exports.encodeUpvoteKey = encodeUpvoteKey;
|
|
2803
3566
|
exports.extractStrategyAddress = extractStrategyAddress;
|
|
2804
3567
|
exports.extractTokenAddressFromScoreKey = extractTokenAddressFromScoreKey;
|
|
3568
|
+
exports.extractTokenAddressesFromMessages = extractTokenAddressesFromMessages;
|
|
2805
3569
|
exports.getFeedContentKey = getFeedContentKey;
|
|
2806
3570
|
exports.getScoreKey = getScoreKey;
|
|
2807
3571
|
exports.getStorageScoreKey = getStorageScoreKey;
|
|
2808
3572
|
exports.getStorageUpvoteContext = getStorageUpvoteContext;
|
|
2809
3573
|
exports.getTokenScoreKey = getTokenScoreKey;
|
|
3574
|
+
exports.getWethAddress = getWethAddress;
|
|
2810
3575
|
exports.isDynamicSplitStrategy = isDynamicSplitStrategy;
|
|
2811
3576
|
exports.isPureAlphaStrategy = isPureAlphaStrategy;
|
|
2812
3577
|
exports.isStrategyMessage = isStrategyMessage;
|
|
2813
3578
|
exports.isTokenScoreKey = isTokenScoreKey;
|
|
2814
3579
|
exports.isUniv234PoolsStrategy = isUniv234PoolsStrategy;
|
|
2815
3580
|
exports.isUserUpvoteMessage = isUserUpvoteMessage;
|
|
3581
|
+
exports.parseUserUpvoteMessage = parseUserUpvoteMessage;
|
|
2816
3582
|
exports.selectStrategy = selectStrategy;
|
|
2817
3583
|
exports.tokenAddressToUpvoteKeyString = tokenAddressToUpvoteKeyString;
|
|
3584
|
+
exports.validateUpvoteParams = validateUpvoteParams;
|
|
3585
|
+
exports.validateUserUpvoteMessage = validateUserUpvoteMessage;
|
|
2818
3586
|
//# sourceMappingURL=index.js.map
|
|
2819
3587
|
//# sourceMappingURL=index.js.map
|