@net-protocol/score 0.1.10 → 0.1.11

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 CHANGED
@@ -409,6 +409,15 @@ declare const MULTI_VERSION_UNISWAP_POOL_INFO_RETRIEVER: {
409
409
  */
410
410
  declare function getWethAddress(chainId: number): Address;
411
411
  declare const NULL_ADDRESS: Address;
412
+ type UniswapFactories = {
413
+ v2Factory: Address;
414
+ v3Factory: Address;
415
+ v4PoolManager: Address;
416
+ };
417
+ /**
418
+ * Get the Uniswap factory / pool-manager addresses for a given chain.
419
+ */
420
+ declare function getUniswapFactories(chainId: number): UniswapFactories;
412
421
  declare const UPVOTE_PRICE_ETH = 0.000025;
413
422
  declare const USER_UPVOTE_CONTRACT: {
414
423
  readonly address: Address;
@@ -479,4 +488,4 @@ declare function buildUserUpvoteReceived(parsed: ParsedUserUpvoteMessage, upvote
479
488
  decimals: number;
480
489
  }): UserUpvoteReceived;
481
490
 
482
- export { ALL_STRATEGY_ADDRESSES, DYNAMIC_SPLIT_STRATEGY, DecodedStrategyMetadata, ERC20_BULK_INFO_HELPER_CONTRACT, GetAppKeyScoresOptions, GetStrategyKeyScoresOptions, type GetTokenRankingsOptions, 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, PoolDiscoveryPair, PoolDiscoveryResult, PoolKey, type RankedToken, type RankingSort, 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, getTokenRankings, getWethAddress, isDynamicSplitStrategy, isPureAlphaStrategy, isStrategyMessage, isUniv234PoolsStrategy, isUserUpvoteMessage, parseUserUpvoteMessage, selectStrategy, tokenAddressToUpvoteKeyString, validateUpvoteParams, validateUserUpvoteMessage };
491
+ export { ALL_STRATEGY_ADDRESSES, DYNAMIC_SPLIT_STRATEGY, DecodedStrategyMetadata, ERC20_BULK_INFO_HELPER_CONTRACT, GetAppKeyScoresOptions, GetStrategyKeyScoresOptions, type GetTokenRankingsOptions, 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, PoolDiscoveryPair, PoolDiscoveryResult, PoolKey, type RankedToken, type RankingSort, 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, getTokenRankings, getUniswapFactories, getWethAddress, isDynamicSplitStrategy, isPureAlphaStrategy, isStrategyMessage, isUniv234PoolsStrategy, isUserUpvoteMessage, parseUserUpvoteMessage, selectStrategy, tokenAddressToUpvoteKeyString, validateUpvoteParams, validateUserUpvoteMessage };
package/dist/index.d.ts CHANGED
@@ -409,6 +409,15 @@ declare const MULTI_VERSION_UNISWAP_POOL_INFO_RETRIEVER: {
409
409
  */
410
410
  declare function getWethAddress(chainId: number): Address;
411
411
  declare const NULL_ADDRESS: Address;
412
+ type UniswapFactories = {
413
+ v2Factory: Address;
414
+ v3Factory: Address;
415
+ v4PoolManager: Address;
416
+ };
417
+ /**
418
+ * Get the Uniswap factory / pool-manager addresses for a given chain.
419
+ */
420
+ declare function getUniswapFactories(chainId: number): UniswapFactories;
412
421
  declare const UPVOTE_PRICE_ETH = 0.000025;
413
422
  declare const USER_UPVOTE_CONTRACT: {
414
423
  readonly address: Address;
@@ -479,4 +488,4 @@ declare function buildUserUpvoteReceived(parsed: ParsedUserUpvoteMessage, upvote
479
488
  decimals: number;
480
489
  }): UserUpvoteReceived;
481
490
 
482
- export { ALL_STRATEGY_ADDRESSES, DYNAMIC_SPLIT_STRATEGY, DecodedStrategyMetadata, ERC20_BULK_INFO_HELPER_CONTRACT, GetAppKeyScoresOptions, GetStrategyKeyScoresOptions, type GetTokenRankingsOptions, 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, PoolDiscoveryPair, PoolDiscoveryResult, PoolKey, type RankedToken, type RankingSort, 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, getTokenRankings, getWethAddress, isDynamicSplitStrategy, isPureAlphaStrategy, isStrategyMessage, isUniv234PoolsStrategy, isUserUpvoteMessage, parseUserUpvoteMessage, selectStrategy, tokenAddressToUpvoteKeyString, validateUpvoteParams, validateUserUpvoteMessage };
491
+ export { ALL_STRATEGY_ADDRESSES, DYNAMIC_SPLIT_STRATEGY, DecodedStrategyMetadata, ERC20_BULK_INFO_HELPER_CONTRACT, GetAppKeyScoresOptions, GetStrategyKeyScoresOptions, type GetTokenRankingsOptions, 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, PoolDiscoveryPair, PoolDiscoveryResult, PoolKey, type RankedToken, type RankingSort, 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, getTokenRankings, getUniswapFactories, getWethAddress, isDynamicSplitStrategy, isPureAlphaStrategy, isStrategyMessage, isUniv234PoolsStrategy, isUserUpvoteMessage, parseUserUpvoteMessage, selectStrategy, tokenAddressToUpvoteKeyString, validateUpvoteParams, validateUserUpvoteMessage };
package/dist/index.js CHANGED
@@ -1659,27 +1659,6 @@ var dynamic_split_strategy_default = [
1659
1659
 
1660
1660
  // src/abis/multi-version-uniswap-bulk-pool-finder.json
1661
1661
  var multi_version_uniswap_bulk_pool_finder_default = [
1662
- {
1663
- type: "function",
1664
- name: "V2_FACTORY",
1665
- inputs: [],
1666
- outputs: [{ name: "", type: "address", internalType: "address" }],
1667
- stateMutability: "view"
1668
- },
1669
- {
1670
- type: "function",
1671
- name: "V3_FACTORY",
1672
- inputs: [],
1673
- outputs: [{ name: "", type: "address", internalType: "address" }],
1674
- stateMutability: "view"
1675
- },
1676
- {
1677
- type: "function",
1678
- name: "V4_POOL_MANAGER",
1679
- inputs: [],
1680
- outputs: [{ name: "", type: "address", internalType: "address" }],
1681
- stateMutability: "view"
1682
- },
1683
1662
  {
1684
1663
  type: "function",
1685
1664
  name: "_checkV4PoolExternal",
@@ -1699,17 +1678,36 @@ var multi_version_uniswap_bulk_pool_finder_default = [
1699
1678
  type: "address",
1700
1679
  internalType: "Currency"
1701
1680
  },
1702
- { name: "fee", type: "uint24", internalType: "uint24" },
1703
- { name: "tickSpacing", type: "int24", internalType: "int24" },
1681
+ {
1682
+ name: "fee",
1683
+ type: "uint24",
1684
+ internalType: "uint24"
1685
+ },
1686
+ {
1687
+ name: "tickSpacing",
1688
+ type: "int24",
1689
+ internalType: "int24"
1690
+ },
1704
1691
  {
1705
1692
  name: "hooks",
1706
1693
  type: "address",
1707
1694
  internalType: "contract IHooks"
1708
1695
  }
1709
1696
  ]
1697
+ },
1698
+ {
1699
+ name: "poolManager",
1700
+ type: "address",
1701
+ internalType: "address"
1702
+ }
1703
+ ],
1704
+ outputs: [
1705
+ {
1706
+ name: "exists",
1707
+ type: "bool",
1708
+ internalType: "bool"
1710
1709
  }
1711
1710
  ],
1712
- outputs: [{ name: "exists", type: "bool", internalType: "bool" }],
1713
1711
  stateMutability: "view"
1714
1712
  },
1715
1713
  {
@@ -1731,7 +1729,11 @@ var multi_version_uniswap_bulk_pool_finder_default = [
1731
1729
  type: "address[]",
1732
1730
  internalType: "address[]"
1733
1731
  },
1734
- { name: "fees", type: "uint24[]", internalType: "uint24[]" },
1732
+ {
1733
+ name: "fees",
1734
+ type: "uint24[]",
1735
+ internalType: "uint24[]"
1736
+ },
1735
1737
  {
1736
1738
  name: "v4TickSpacings",
1737
1739
  type: "int24[]",
@@ -1741,6 +1743,21 @@ var multi_version_uniswap_bulk_pool_finder_default = [
1741
1743
  name: "v4Hooks",
1742
1744
  type: "address[]",
1743
1745
  internalType: "address[]"
1746
+ },
1747
+ {
1748
+ name: "v2Factory",
1749
+ type: "address",
1750
+ internalType: "address"
1751
+ },
1752
+ {
1753
+ name: "v3Factory",
1754
+ type: "address",
1755
+ internalType: "address"
1756
+ },
1757
+ {
1758
+ name: "v4PoolManager",
1759
+ type: "address",
1760
+ internalType: "address"
1744
1761
  }
1745
1762
  ]
1746
1763
  }
@@ -1756,7 +1773,11 @@ var multi_version_uniswap_bulk_pool_finder_default = [
1756
1773
  type: "uint256",
1757
1774
  internalType: "uint256"
1758
1775
  },
1759
- { name: "version", type: "uint8", internalType: "uint8" },
1776
+ {
1777
+ name: "version",
1778
+ type: "uint8",
1779
+ internalType: "uint8"
1780
+ },
1760
1781
  {
1761
1782
  name: "poolAddress",
1762
1783
  type: "address",
@@ -1777,7 +1798,11 @@ var multi_version_uniswap_bulk_pool_finder_default = [
1777
1798
  type: "address",
1778
1799
  internalType: "Currency"
1779
1800
  },
1780
- { name: "fee", type: "uint24", internalType: "uint24" },
1801
+ {
1802
+ name: "fee",
1803
+ type: "uint24",
1804
+ internalType: "uint24"
1805
+ },
1781
1806
  {
1782
1807
  name: "tickSpacing",
1783
1808
  type: "int24",
@@ -1790,12 +1815,28 @@ var multi_version_uniswap_bulk_pool_finder_default = [
1790
1815
  }
1791
1816
  ]
1792
1817
  },
1793
- { name: "fee", type: "uint24", internalType: "uint24" },
1794
- { name: "tickSpacing", type: "int24", internalType: "int24" },
1795
- { name: "hooks", type: "address", internalType: "address" }
1818
+ {
1819
+ name: "fee",
1820
+ type: "uint24",
1821
+ internalType: "uint24"
1822
+ },
1823
+ {
1824
+ name: "tickSpacing",
1825
+ type: "int24",
1826
+ internalType: "int24"
1827
+ },
1828
+ {
1829
+ name: "hooks",
1830
+ type: "address",
1831
+ internalType: "address"
1832
+ }
1796
1833
  ]
1797
1834
  },
1798
- { name: "count", type: "uint256", internalType: "uint256" }
1835
+ {
1836
+ name: "count",
1837
+ type: "uint256",
1838
+ internalType: "uint256"
1839
+ }
1799
1840
  ],
1800
1841
  stateMutability: "view"
1801
1842
  }
@@ -2556,7 +2597,7 @@ var LEGACY_UPVOTE_V1_ADDRESS = "0x0ada882dbbdc12388a1f9ca85d2d847088f747df";
2556
2597
  var LEGACY_UPVOTE_V2_ADDRESS = "0x9027dcad0a3dca5835895e14fbc022a1e5ea909b";
2557
2598
  var SUPPORTED_SCORE_CHAINS = [8453];
2558
2599
  var MULTI_VERSION_UNISWAP_BULK_POOL_FINDER = {
2559
- address: "0xbc237dac4c74c170780fc12f353a258bdd31a8cf",
2600
+ address: "0x88A51f8d3B1f222394075E086e33108BC9ceDfB6",
2560
2601
  abi: multi_version_uniswap_bulk_pool_finder_default
2561
2602
  };
2562
2603
  var MULTI_VERSION_UNISWAP_POOL_INFO_RETRIEVER = {
@@ -2579,6 +2620,33 @@ function getWethAddress(chainId) {
2579
2620
  return addr;
2580
2621
  }
2581
2622
  var NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
2623
+ var UNISWAP_FACTORIES_BY_CHAIN = {
2624
+ 8453: {
2625
+ // Base
2626
+ v2Factory: "0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6",
2627
+ v3Factory: "0x33128a8fC17869897dcE68Ed026d694621f6FDfD",
2628
+ v4PoolManager: "0x498581fF718922c3f8e6A244956aF099B2652b2b"
2629
+ },
2630
+ 1: {
2631
+ // Ethereum mainnet
2632
+ v2Factory: "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
2633
+ v3Factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984",
2634
+ v4PoolManager: "0x000000000004444c5dc75cB358380D2e3dE08A90"
2635
+ },
2636
+ 4663: {
2637
+ // Robinhood Chain — Uniswap V3 only, at a non-canonical factory address.
2638
+ v2Factory: NULL_ADDRESS,
2639
+ v3Factory: "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA",
2640
+ v4PoolManager: NULL_ADDRESS
2641
+ }
2642
+ };
2643
+ function getUniswapFactories(chainId) {
2644
+ const factories = UNISWAP_FACTORIES_BY_CHAIN[chainId];
2645
+ if (!factories) {
2646
+ throw new Error(`Score: No Uniswap factories for chain ${chainId}`);
2647
+ }
2648
+ return factories;
2649
+ }
2582
2650
  var UPVOTE_PRICE_ETH = 25e-6;
2583
2651
  var USER_UPVOTE_CONTRACT = {
2584
2652
  address: "0xa4bc2c63dd0157692fd5f409389e5032e37d8895",
@@ -3294,13 +3362,16 @@ function normalizeTokenPairs(pairs, wethAddress) {
3294
3362
  };
3295
3363
  });
3296
3364
  }
3297
- function buildDiscoveryArgs(normalizedPairs) {
3365
+ function buildDiscoveryArgs(normalizedPairs, factories) {
3298
3366
  return {
3299
3367
  tokenAs: normalizedPairs.map((p) => p.tokenA),
3300
3368
  tokenBs: normalizedPairs.map((p) => p.tokenB),
3301
3369
  fees: V3_V4_FEE_TIERS,
3302
3370
  v4TickSpacings: V4_TICK_SPACINGS,
3303
- v4Hooks: V4_HOOKS
3371
+ v4Hooks: V4_HOOKS,
3372
+ v2Factory: factories.v2Factory,
3373
+ v3Factory: factories.v3Factory,
3374
+ v4PoolManager: factories.v4PoolManager
3304
3375
  };
3305
3376
  }
3306
3377
  function parsePoolDiscoveries(poolResults, pairs, wethAddress) {
@@ -3514,8 +3585,9 @@ async function discoverPools({
3514
3585
  }) {
3515
3586
  if (pairs.length === 0) return [];
3516
3587
  const wethAddress = getWethAddress(chainId);
3588
+ const factories = getUniswapFactories(chainId);
3517
3589
  const normalizedPairs = normalizeTokenPairs(pairs, wethAddress);
3518
- const discoveryArgs = buildDiscoveryArgs(normalizedPairs);
3590
+ const discoveryArgs = buildDiscoveryArgs(normalizedPairs, factories);
3519
3591
  const poolResults = await actions.readContract(publicClient, {
3520
3592
  address: MULTI_VERSION_UNISWAP_BULK_POOL_FINDER.address,
3521
3593
  abi: MULTI_VERSION_UNISWAP_BULK_POOL_FINDER.abi,
@@ -4073,6 +4145,7 @@ exports.getStorageScoreKey = getStorageScoreKey;
4073
4145
  exports.getStorageUpvoteContext = getStorageUpvoteContext;
4074
4146
  exports.getTokenRankings = getTokenRankings;
4075
4147
  exports.getTokenScoreKey = getTokenScoreKey;
4148
+ exports.getUniswapFactories = getUniswapFactories;
4076
4149
  exports.getWethAddress = getWethAddress;
4077
4150
  exports.isDynamicSplitStrategy = isDynamicSplitStrategy;
4078
4151
  exports.isPureAlphaStrategy = isPureAlphaStrategy;