@net-protocol/score 0.1.6 → 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 +145 -82
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +145 -82
- 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 +1 -1
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 = {
|
|
@@ -3167,8 +3256,24 @@ var V4_HOOKS = [
|
|
|
3167
3256
|
"0xbB7784A4d481184283Ed89619A3e3ed143e1Adc0",
|
|
3168
3257
|
"0xBDF938149ac6a781F94FAa0ed45E6A0e984c6544"
|
|
3169
3258
|
];
|
|
3170
|
-
var
|
|
3171
|
-
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
|
+
}
|
|
3172
3277
|
function normalizeTokenPairs(pairs, wethAddress) {
|
|
3173
3278
|
return pairs.map((pair) => {
|
|
3174
3279
|
const tokenA = pair.tokenAddress;
|
|
@@ -3375,42 +3480,7 @@ function constructPoolKey(info, pair, version, v4PoolKey) {
|
|
|
3375
3480
|
return void 0;
|
|
3376
3481
|
}
|
|
3377
3482
|
}
|
|
3378
|
-
function
|
|
3379
|
-
if (pool.token0?.toLowerCase() === wethAddress.toLowerCase()) {
|
|
3380
|
-
return Number(pool.token0Balance);
|
|
3381
|
-
} else if (pool.token1?.toLowerCase() === wethAddress.toLowerCase()) {
|
|
3382
|
-
return Number(pool.token1Balance);
|
|
3383
|
-
} else {
|
|
3384
|
-
return Number(pool.baseTokenBalance);
|
|
3385
|
-
}
|
|
3386
|
-
}
|
|
3387
|
-
function filterV2V3PoolsByLiquidity(pools, threshold, wethAddress) {
|
|
3388
|
-
return pools.filter((pool) => {
|
|
3389
|
-
if (!pool.poolAddress) return false;
|
|
3390
|
-
const wethBalanceWei = getWethBalanceWei(pool, wethAddress);
|
|
3391
|
-
return wethBalanceWei >= threshold;
|
|
3392
|
-
});
|
|
3393
|
-
}
|
|
3394
|
-
function selectBestV2V3Pool(pools) {
|
|
3395
|
-
return pools.reduce((a, b) => {
|
|
3396
|
-
const aIsV3 = a.fee > 0;
|
|
3397
|
-
const bIsV3 = b.fee > 0;
|
|
3398
|
-
if (aIsV3 && !bIsV3) return a;
|
|
3399
|
-
if (!aIsV3 && bIsV3) return b;
|
|
3400
|
-
return Number(a.baseTokenBalance) > Number(b.baseTokenBalance) ? a : b;
|
|
3401
|
-
});
|
|
3402
|
-
}
|
|
3403
|
-
function selectBestV4Pool(pools) {
|
|
3404
|
-
return pools.reduce((a, b) => {
|
|
3405
|
-
return a.fee < b.fee ? a : b;
|
|
3406
|
-
});
|
|
3407
|
-
}
|
|
3408
|
-
function selectBestV2V3PoolByFee(pools) {
|
|
3409
|
-
return pools.reduce((a, b) => {
|
|
3410
|
-
return a.fee < b.fee ? a : b;
|
|
3411
|
-
});
|
|
3412
|
-
}
|
|
3413
|
-
function selectBestPoolPerPair(allPools, wethAddress) {
|
|
3483
|
+
function selectBestPoolPerPair(allPools) {
|
|
3414
3484
|
const poolsByPair = {};
|
|
3415
3485
|
for (const pool of allPools) {
|
|
3416
3486
|
const key = pool.tokenAddress.toLowerCase() + "_" + pool.baseTokenAddress.toLowerCase();
|
|
@@ -3418,37 +3488,13 @@ function selectBestPoolPerPair(allPools, wethAddress) {
|
|
|
3418
3488
|
poolsByPair[key].push(pool);
|
|
3419
3489
|
}
|
|
3420
3490
|
const bestPools = [];
|
|
3421
|
-
for (const
|
|
3422
|
-
|
|
3423
|
-
if (
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
LIQUIDITY_THRESHOLD_TO_PREFER_V2_V3_POOLS,
|
|
3429
|
-
wethAddress
|
|
3430
|
-
);
|
|
3431
|
-
if (v2v3PoolsWithPreferredLiquidity.length > 0) {
|
|
3432
|
-
best = selectBestV2V3Pool(v2v3PoolsWithPreferredLiquidity);
|
|
3433
|
-
} else {
|
|
3434
|
-
const v4Pools = group.filter((pool) => !pool.poolAddress);
|
|
3435
|
-
if (v4Pools.length > 0) {
|
|
3436
|
-
best = selectBestV4Pool(v4Pools);
|
|
3437
|
-
} else {
|
|
3438
|
-
const v2v3PoolsWithAcceptableLiquidity = filterV2V3PoolsByLiquidity(
|
|
3439
|
-
group,
|
|
3440
|
-
LIQUIDITY_THRESHOLD_TO_CONSIDER_V2_V3_POOLS,
|
|
3441
|
-
wethAddress
|
|
3442
|
-
);
|
|
3443
|
-
if (v2v3PoolsWithAcceptableLiquidity.length > 0) {
|
|
3444
|
-
best = selectBestV2V3PoolByFee(v2v3PoolsWithAcceptableLiquidity);
|
|
3445
|
-
}
|
|
3446
|
-
}
|
|
3447
|
-
}
|
|
3448
|
-
}
|
|
3449
|
-
if (best) {
|
|
3450
|
-
bestPools.push(best);
|
|
3451
|
-
}
|
|
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);
|
|
3452
3498
|
}
|
|
3453
3499
|
return bestPools;
|
|
3454
3500
|
}
|
|
@@ -3482,13 +3528,27 @@ async function discoverPools({
|
|
|
3482
3528
|
]
|
|
3483
3529
|
});
|
|
3484
3530
|
if (!Array.isArray(poolInfos) || poolInfos.length === 0) return [];
|
|
3531
|
+
const wethLower = wethAddress.toLowerCase();
|
|
3485
3532
|
const allPools = poolInfos.map((info, index) => {
|
|
3486
3533
|
const poolData = determinePoolVersion(discoveries, index);
|
|
3487
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
|
+
}
|
|
3488
3548
|
return {
|
|
3489
3549
|
tokenAddress: poolData.pair.tokenAddress,
|
|
3490
3550
|
baseTokenAddress: poolData.pair.baseTokenAddress || wethAddress,
|
|
3491
|
-
poolAddress:
|
|
3551
|
+
poolAddress: isV4 ? null : info.poolAddress,
|
|
3492
3552
|
price: calculatePoolPrice(info, poolData.pair, poolData.version),
|
|
3493
3553
|
baseTokenBalance: String(info.baseTokenBalance || 0),
|
|
3494
3554
|
token0: info.token0,
|
|
@@ -3501,10 +3561,12 @@ async function discoverPools({
|
|
|
3501
3561
|
poolData.pair,
|
|
3502
3562
|
poolData.version,
|
|
3503
3563
|
poolData.v4PoolKey
|
|
3504
|
-
)
|
|
3564
|
+
),
|
|
3565
|
+
liquidity: String(liquidity),
|
|
3566
|
+
wethDepthWei
|
|
3505
3567
|
};
|
|
3506
3568
|
}).filter((p) => p !== null);
|
|
3507
|
-
const bestPools = selectBestPoolPerPair(allPools
|
|
3569
|
+
const bestPools = selectBestPoolPerPair(allPools);
|
|
3508
3570
|
return bestPools.map(
|
|
3509
3571
|
(pool) => ({
|
|
3510
3572
|
tokenAddress: pool.tokenAddress,
|
|
@@ -3513,6 +3575,7 @@ async function discoverPools({
|
|
|
3513
3575
|
price: pool.price,
|
|
3514
3576
|
fee: pool.fee,
|
|
3515
3577
|
poolKey: pool.poolKey,
|
|
3578
|
+
liquidity: pool.liquidity,
|
|
3516
3579
|
balances: {
|
|
3517
3580
|
baseTokenBalance: pool.baseTokenBalance,
|
|
3518
3581
|
token0Balance: pool.token0Balance,
|