@net-protocol/score 0.1.5 → 0.1.7
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +147 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +147 -83
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js.map +1 -1
- package/dist/react.mjs.map +1 -1
- package/dist/{scoreKeyUtils-DuH70ypB.d.mts → scoreKeyUtils-D-ONTPej.d.mts} +2 -0
- package/dist/{scoreKeyUtils-DuH70ypB.d.ts → scoreKeyUtils-D-ONTPej.d.ts} +2 -0
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 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-
|
|
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-D-ONTPej.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-D-ONTPej.mjs';
|
|
3
3
|
import { Address, WalletClient, PublicClient, Abi } from 'viem';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 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-
|
|
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-D-ONTPej.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-D-ONTPej.js';
|
|
3
3
|
import { Address, WalletClient, PublicClient, Abi } from 'viem';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1807,7 +1807,59 @@ var multi_version_uniswap_pool_info_retriever_default = [
|
|
|
1807
1807
|
type: "function",
|
|
1808
1808
|
name: "V4_POOL_MANAGER",
|
|
1809
1809
|
inputs: [],
|
|
1810
|
-
outputs: [
|
|
1810
|
+
outputs: [
|
|
1811
|
+
{
|
|
1812
|
+
name: "",
|
|
1813
|
+
type: "address",
|
|
1814
|
+
internalType: "address"
|
|
1815
|
+
}
|
|
1816
|
+
],
|
|
1817
|
+
stateMutability: "view"
|
|
1818
|
+
},
|
|
1819
|
+
{
|
|
1820
|
+
type: "function",
|
|
1821
|
+
name: "_getV4Liquidity",
|
|
1822
|
+
inputs: [
|
|
1823
|
+
{
|
|
1824
|
+
name: "poolKey",
|
|
1825
|
+
type: "tuple",
|
|
1826
|
+
internalType: "struct PoolKey",
|
|
1827
|
+
components: [
|
|
1828
|
+
{
|
|
1829
|
+
name: "currency0",
|
|
1830
|
+
type: "address",
|
|
1831
|
+
internalType: "Currency"
|
|
1832
|
+
},
|
|
1833
|
+
{
|
|
1834
|
+
name: "currency1",
|
|
1835
|
+
type: "address",
|
|
1836
|
+
internalType: "Currency"
|
|
1837
|
+
},
|
|
1838
|
+
{
|
|
1839
|
+
name: "fee",
|
|
1840
|
+
type: "uint24",
|
|
1841
|
+
internalType: "uint24"
|
|
1842
|
+
},
|
|
1843
|
+
{
|
|
1844
|
+
name: "tickSpacing",
|
|
1845
|
+
type: "int24",
|
|
1846
|
+
internalType: "int24"
|
|
1847
|
+
},
|
|
1848
|
+
{
|
|
1849
|
+
name: "hooks",
|
|
1850
|
+
type: "address",
|
|
1851
|
+
internalType: "contract IHooks"
|
|
1852
|
+
}
|
|
1853
|
+
]
|
|
1854
|
+
}
|
|
1855
|
+
],
|
|
1856
|
+
outputs: [
|
|
1857
|
+
{
|
|
1858
|
+
name: "liquidity",
|
|
1859
|
+
type: "uint128",
|
|
1860
|
+
internalType: "uint128"
|
|
1861
|
+
}
|
|
1862
|
+
],
|
|
1811
1863
|
stateMutability: "view"
|
|
1812
1864
|
},
|
|
1813
1865
|
{
|
|
@@ -1829,8 +1881,16 @@ var multi_version_uniswap_pool_info_retriever_default = [
|
|
|
1829
1881
|
type: "address",
|
|
1830
1882
|
internalType: "Currency"
|
|
1831
1883
|
},
|
|
1832
|
-
{
|
|
1833
|
-
|
|
1884
|
+
{
|
|
1885
|
+
name: "fee",
|
|
1886
|
+
type: "uint24",
|
|
1887
|
+
internalType: "uint24"
|
|
1888
|
+
},
|
|
1889
|
+
{
|
|
1890
|
+
name: "tickSpacing",
|
|
1891
|
+
type: "int24",
|
|
1892
|
+
internalType: "int24"
|
|
1893
|
+
},
|
|
1834
1894
|
{
|
|
1835
1895
|
name: "hooks",
|
|
1836
1896
|
type: "address",
|
|
@@ -1840,7 +1900,11 @@ var multi_version_uniswap_pool_info_retriever_default = [
|
|
|
1840
1900
|
}
|
|
1841
1901
|
],
|
|
1842
1902
|
outputs: [
|
|
1843
|
-
{
|
|
1903
|
+
{
|
|
1904
|
+
name: "sqrtPriceX96",
|
|
1905
|
+
type: "uint160",
|
|
1906
|
+
internalType: "uint160"
|
|
1907
|
+
}
|
|
1844
1908
|
],
|
|
1845
1909
|
stateMutability: "view"
|
|
1846
1910
|
},
|
|
@@ -1873,8 +1937,16 @@ var multi_version_uniswap_pool_info_retriever_default = [
|
|
|
1873
1937
|
type: "address",
|
|
1874
1938
|
internalType: "Currency"
|
|
1875
1939
|
},
|
|
1876
|
-
{
|
|
1877
|
-
|
|
1940
|
+
{
|
|
1941
|
+
name: "fee",
|
|
1942
|
+
type: "uint24",
|
|
1943
|
+
internalType: "uint24"
|
|
1944
|
+
},
|
|
1945
|
+
{
|
|
1946
|
+
name: "tickSpacing",
|
|
1947
|
+
type: "int24",
|
|
1948
|
+
internalType: "int24"
|
|
1949
|
+
},
|
|
1878
1950
|
{
|
|
1879
1951
|
name: "hooks",
|
|
1880
1952
|
type: "address",
|
|
@@ -1882,7 +1954,11 @@ var multi_version_uniswap_pool_info_retriever_default = [
|
|
|
1882
1954
|
}
|
|
1883
1955
|
]
|
|
1884
1956
|
},
|
|
1885
|
-
{
|
|
1957
|
+
{
|
|
1958
|
+
name: "baseToken",
|
|
1959
|
+
type: "address",
|
|
1960
|
+
internalType: "address"
|
|
1961
|
+
}
|
|
1886
1962
|
],
|
|
1887
1963
|
outputs: [
|
|
1888
1964
|
{
|
|
@@ -1895,8 +1971,16 @@ var multi_version_uniswap_pool_info_retriever_default = [
|
|
|
1895
1971
|
type: "address",
|
|
1896
1972
|
internalType: "address"
|
|
1897
1973
|
},
|
|
1898
|
-
{
|
|
1899
|
-
|
|
1974
|
+
{
|
|
1975
|
+
name: "token0",
|
|
1976
|
+
type: "address",
|
|
1977
|
+
internalType: "address"
|
|
1978
|
+
},
|
|
1979
|
+
{
|
|
1980
|
+
name: "token1",
|
|
1981
|
+
type: "address",
|
|
1982
|
+
internalType: "address"
|
|
1983
|
+
},
|
|
1900
1984
|
{
|
|
1901
1985
|
name: "token0Decimals",
|
|
1902
1986
|
type: "uint8",
|
|
@@ -1926,6 +2010,11 @@ var multi_version_uniswap_pool_info_retriever_default = [
|
|
|
1926
2010
|
name: "token1Balance",
|
|
1927
2011
|
type: "uint256",
|
|
1928
2012
|
internalType: "uint256"
|
|
2013
|
+
},
|
|
2014
|
+
{
|
|
2015
|
+
name: "liquidity",
|
|
2016
|
+
type: "uint128",
|
|
2017
|
+
internalType: "uint128"
|
|
1929
2018
|
}
|
|
1930
2019
|
]
|
|
1931
2020
|
}
|
|
@@ -2433,7 +2522,7 @@ var MULTI_VERSION_UNISWAP_BULK_POOL_FINDER = {
|
|
|
2433
2522
|
abi: multi_version_uniswap_bulk_pool_finder_default
|
|
2434
2523
|
};
|
|
2435
2524
|
var MULTI_VERSION_UNISWAP_POOL_INFO_RETRIEVER = {
|
|
2436
|
-
address: "
|
|
2525
|
+
address: "0x00000002986Ca76897216a8A3A7Db10FcB0d29Cf",
|
|
2437
2526
|
abi: multi_version_uniswap_pool_info_retriever_default
|
|
2438
2527
|
};
|
|
2439
2528
|
var WETH_BY_CHAIN = {
|
|
@@ -3164,10 +3253,27 @@ var V4_HOOKS = [
|
|
|
3164
3253
|
"0xb429d62f8f3bFFb98CdB9569533eA23bF0Ba28CC",
|
|
3165
3254
|
"0xd60D6B218116cFd801E28F78d011a203D2b068Cc",
|
|
3166
3255
|
"0x3e342a06f9592459D75721d6956B570F02eF2Dc0",
|
|
3167
|
-
"0xbB7784A4d481184283Ed89619A3e3ed143e1Adc0"
|
|
3256
|
+
"0xbB7784A4d481184283Ed89619A3e3ed143e1Adc0",
|
|
3257
|
+
"0xBDF938149ac6a781F94FAa0ed45E6A0e984c6544"
|
|
3168
3258
|
];
|
|
3169
|
-
var
|
|
3170
|
-
var
|
|
3259
|
+
var Q96 = BigInt(2) ** BigInt(96);
|
|
3260
|
+
var ZERO_BI = BigInt(0);
|
|
3261
|
+
function deriveV4WethDepthWei(liquidity, sqrtPriceX96, wethIsCurrency1) {
|
|
3262
|
+
if (sqrtPriceX96 === ZERO_BI || liquidity === ZERO_BI) return ZERO_BI;
|
|
3263
|
+
if (wethIsCurrency1) {
|
|
3264
|
+
return liquidity * sqrtPriceX96 / Q96;
|
|
3265
|
+
}
|
|
3266
|
+
return liquidity * Q96 / sqrtPriceX96;
|
|
3267
|
+
}
|
|
3268
|
+
function deriveV2V3WethDepthWei(info, wethLower) {
|
|
3269
|
+
if ((info.token0 ?? "").toLowerCase() === wethLower) {
|
|
3270
|
+
return BigInt(info.token0Balance ?? 0);
|
|
3271
|
+
}
|
|
3272
|
+
if ((info.token1 ?? "").toLowerCase() === wethLower) {
|
|
3273
|
+
return BigInt(info.token1Balance ?? 0);
|
|
3274
|
+
}
|
|
3275
|
+
return BigInt(info.baseTokenBalance ?? 0);
|
|
3276
|
+
}
|
|
3171
3277
|
function normalizeTokenPairs(pairs, wethAddress) {
|
|
3172
3278
|
return pairs.map((pair) => {
|
|
3173
3279
|
const tokenA = pair.tokenAddress;
|
|
@@ -3374,42 +3480,7 @@ function constructPoolKey(info, pair, version, v4PoolKey) {
|
|
|
3374
3480
|
return void 0;
|
|
3375
3481
|
}
|
|
3376
3482
|
}
|
|
3377
|
-
function
|
|
3378
|
-
if (pool.token0?.toLowerCase() === wethAddress.toLowerCase()) {
|
|
3379
|
-
return Number(pool.token0Balance);
|
|
3380
|
-
} else if (pool.token1?.toLowerCase() === wethAddress.toLowerCase()) {
|
|
3381
|
-
return Number(pool.token1Balance);
|
|
3382
|
-
} else {
|
|
3383
|
-
return Number(pool.baseTokenBalance);
|
|
3384
|
-
}
|
|
3385
|
-
}
|
|
3386
|
-
function filterV2V3PoolsByLiquidity(pools, threshold, wethAddress) {
|
|
3387
|
-
return pools.filter((pool) => {
|
|
3388
|
-
if (!pool.poolAddress) return false;
|
|
3389
|
-
const wethBalanceWei = getWethBalanceWei(pool, wethAddress);
|
|
3390
|
-
return wethBalanceWei >= threshold;
|
|
3391
|
-
});
|
|
3392
|
-
}
|
|
3393
|
-
function selectBestV2V3Pool(pools) {
|
|
3394
|
-
return pools.reduce((a, b) => {
|
|
3395
|
-
const aIsV3 = a.fee > 0;
|
|
3396
|
-
const bIsV3 = b.fee > 0;
|
|
3397
|
-
if (aIsV3 && !bIsV3) return a;
|
|
3398
|
-
if (!aIsV3 && bIsV3) return b;
|
|
3399
|
-
return Number(a.baseTokenBalance) > Number(b.baseTokenBalance) ? a : b;
|
|
3400
|
-
});
|
|
3401
|
-
}
|
|
3402
|
-
function selectBestV4Pool(pools) {
|
|
3403
|
-
return pools.reduce((a, b) => {
|
|
3404
|
-
return a.fee < b.fee ? a : b;
|
|
3405
|
-
});
|
|
3406
|
-
}
|
|
3407
|
-
function selectBestV2V3PoolByFee(pools) {
|
|
3408
|
-
return pools.reduce((a, b) => {
|
|
3409
|
-
return a.fee < b.fee ? a : b;
|
|
3410
|
-
});
|
|
3411
|
-
}
|
|
3412
|
-
function selectBestPoolPerPair(allPools, wethAddress) {
|
|
3483
|
+
function selectBestPoolPerPair(allPools) {
|
|
3413
3484
|
const poolsByPair = {};
|
|
3414
3485
|
for (const pool of allPools) {
|
|
3415
3486
|
const key = pool.tokenAddress.toLowerCase() + "_" + pool.baseTokenAddress.toLowerCase();
|
|
@@ -3417,37 +3488,13 @@ function selectBestPoolPerPair(allPools, wethAddress) {
|
|
|
3417
3488
|
poolsByPair[key].push(pool);
|
|
3418
3489
|
}
|
|
3419
3490
|
const bestPools = [];
|
|
3420
|
-
for (const
|
|
3421
|
-
|
|
3422
|
-
if (
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
LIQUIDITY_THRESHOLD_TO_PREFER_V2_V3_POOLS,
|
|
3428
|
-
wethAddress
|
|
3429
|
-
);
|
|
3430
|
-
if (v2v3PoolsWithPreferredLiquidity.length > 0) {
|
|
3431
|
-
best = selectBestV2V3Pool(v2v3PoolsWithPreferredLiquidity);
|
|
3432
|
-
} else {
|
|
3433
|
-
const v4Pools = group.filter((pool) => !pool.poolAddress);
|
|
3434
|
-
if (v4Pools.length > 0) {
|
|
3435
|
-
best = selectBestV4Pool(v4Pools);
|
|
3436
|
-
} else {
|
|
3437
|
-
const v2v3PoolsWithAcceptableLiquidity = filterV2V3PoolsByLiquidity(
|
|
3438
|
-
group,
|
|
3439
|
-
LIQUIDITY_THRESHOLD_TO_CONSIDER_V2_V3_POOLS,
|
|
3440
|
-
wethAddress
|
|
3441
|
-
);
|
|
3442
|
-
if (v2v3PoolsWithAcceptableLiquidity.length > 0) {
|
|
3443
|
-
best = selectBestV2V3PoolByFee(v2v3PoolsWithAcceptableLiquidity);
|
|
3444
|
-
}
|
|
3445
|
-
}
|
|
3446
|
-
}
|
|
3447
|
-
}
|
|
3448
|
-
if (best) {
|
|
3449
|
-
bestPools.push(best);
|
|
3450
|
-
}
|
|
3491
|
+
for (const group of Object.values(poolsByPair)) {
|
|
3492
|
+
const withDepth = group.filter((p) => p.wethDepthWei > ZERO_BI);
|
|
3493
|
+
if (withDepth.length === 0) continue;
|
|
3494
|
+
const best = withDepth.reduce(
|
|
3495
|
+
(a, b) => a.wethDepthWei > b.wethDepthWei ? a : b
|
|
3496
|
+
);
|
|
3497
|
+
bestPools.push(best);
|
|
3451
3498
|
}
|
|
3452
3499
|
return bestPools;
|
|
3453
3500
|
}
|
|
@@ -3481,13 +3528,27 @@ async function discoverPools({
|
|
|
3481
3528
|
]
|
|
3482
3529
|
});
|
|
3483
3530
|
if (!Array.isArray(poolInfos) || poolInfos.length === 0) return [];
|
|
3531
|
+
const wethLower = wethAddress.toLowerCase();
|
|
3484
3532
|
const allPools = poolInfos.map((info, index) => {
|
|
3485
3533
|
const poolData = determinePoolVersion(discoveries, index);
|
|
3486
3534
|
if (!poolData || !poolData.pair) return null;
|
|
3535
|
+
const isV4 = poolData.version === 4;
|
|
3536
|
+
const liquidity = BigInt(info.liquidity ?? 0);
|
|
3537
|
+
let wethDepthWei;
|
|
3538
|
+
if (isV4) {
|
|
3539
|
+
const wethIsCurrency1 = poolData.v4PoolKey.currency1.toLowerCase() === wethLower;
|
|
3540
|
+
wethDepthWei = deriveV4WethDepthWei(
|
|
3541
|
+
liquidity,
|
|
3542
|
+
BigInt(info.sqrtPriceX96 ?? 0),
|
|
3543
|
+
wethIsCurrency1
|
|
3544
|
+
);
|
|
3545
|
+
} else {
|
|
3546
|
+
wethDepthWei = deriveV2V3WethDepthWei(info, wethLower);
|
|
3547
|
+
}
|
|
3487
3548
|
return {
|
|
3488
3549
|
tokenAddress: poolData.pair.tokenAddress,
|
|
3489
3550
|
baseTokenAddress: poolData.pair.baseTokenAddress || wethAddress,
|
|
3490
|
-
poolAddress:
|
|
3551
|
+
poolAddress: isV4 ? null : info.poolAddress,
|
|
3491
3552
|
price: calculatePoolPrice(info, poolData.pair, poolData.version),
|
|
3492
3553
|
baseTokenBalance: String(info.baseTokenBalance || 0),
|
|
3493
3554
|
token0: info.token0,
|
|
@@ -3500,10 +3561,12 @@ async function discoverPools({
|
|
|
3500
3561
|
poolData.pair,
|
|
3501
3562
|
poolData.version,
|
|
3502
3563
|
poolData.v4PoolKey
|
|
3503
|
-
)
|
|
3564
|
+
),
|
|
3565
|
+
liquidity: String(liquidity),
|
|
3566
|
+
wethDepthWei
|
|
3504
3567
|
};
|
|
3505
3568
|
}).filter((p) => p !== null);
|
|
3506
|
-
const bestPools = selectBestPoolPerPair(allPools
|
|
3569
|
+
const bestPools = selectBestPoolPerPair(allPools);
|
|
3507
3570
|
return bestPools.map(
|
|
3508
3571
|
(pool) => ({
|
|
3509
3572
|
tokenAddress: pool.tokenAddress,
|
|
@@ -3512,6 +3575,7 @@ async function discoverPools({
|
|
|
3512
3575
|
price: pool.price,
|
|
3513
3576
|
fee: pool.fee,
|
|
3514
3577
|
poolKey: pool.poolKey,
|
|
3578
|
+
liquidity: pool.liquidity,
|
|
3515
3579
|
balances: {
|
|
3516
3580
|
baseTokenBalance: pool.baseTokenBalance,
|
|
3517
3581
|
token0Balance: pool.token0Balance,
|