@codex-data/sdk 1.0.25 → 1.0.28

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.
Files changed (34) hide show
  1. package/dist/resources/graphql.d.ts +242 -14
  2. package/dist/resources/graphql.d.ts.map +1 -1
  3. package/dist/resources/graphql.js +14 -2
  4. package/dist/resources/graphql.js.map +1 -1
  5. package/dist/scripts/generateNetworkConfigs.d.ts +2 -0
  6. package/dist/scripts/generateNetworkConfigs.d.ts.map +1 -0
  7. package/dist/scripts/generateNetworkConfigs.js +235 -0
  8. package/dist/scripts/generateNetworkConfigs.js.map +1 -0
  9. package/dist/sdk/Mutation.d.ts +3 -3
  10. package/dist/sdk/Mutation.d.ts.map +1 -1
  11. package/dist/sdk/Mutation.js +3 -3
  12. package/dist/sdk/Mutation.js.map +1 -1
  13. package/dist/sdk/Query.d.ts +51 -51
  14. package/dist/sdk/Query.d.ts.map +1 -1
  15. package/dist/sdk/Query.js +51 -51
  16. package/dist/sdk/Query.js.map +1 -1
  17. package/dist/sdk/Subscribe.d.ts +14 -14
  18. package/dist/sdk/Subscribe.d.ts.map +1 -1
  19. package/dist/sdk/Subscribe.js +65 -65
  20. package/dist/sdk/Subscribe.js.map +1 -1
  21. package/dist/sdk/generated/graphql.d.ts +244 -16
  22. package/dist/sdk/generated/graphql.d.ts.map +1 -1
  23. package/dist/sdk/generated/graphql.js +16 -4
  24. package/dist/sdk/generated/graphql.js.map +1 -1
  25. package/package.json +3 -1
  26. package/src/resources/graphql.schema.json +2698 -29
  27. package/src/resources/graphql.ts +260 -14
  28. package/src/resources/networkConfigs.json +3695 -0
  29. package/src/resources/schema.graphql +241 -12
  30. package/src/scripts/generateNetworkConfigs.ts +243 -0
  31. package/src/sdk/Mutation.ts +7 -7
  32. package/src/sdk/Query.ts +107 -107
  33. package/src/sdk/Subscribe.ts +156 -156
  34. package/src/sdk/generated/graphql.ts +261 -15
@@ -5,6 +5,10 @@ type Query {
5
5
  apiToken(
6
6
  token: String!
7
7
  ): ApiToken!
8
+ """Returns block data for the input blockNumbers or timestamps, maximum 25 inputs."""
9
+ blocks(
10
+ input: BlocksInput!
11
+ ): [Block!]!
8
12
  """Returns a list of all networks supported on Codex."""
9
13
  getNetworks: [Network!]!
10
14
  """Returns the status of a list of networks supported on Codex."""
@@ -25,6 +29,9 @@ type Query {
25
29
  """limit: The maximum number of webhooks to return."""
26
30
  limit: Int
27
31
  ): GetWebhooksResponse
32
+ getNetworkConfigs(
33
+ networkIds: [Int!]
34
+ ): [NetworkConfig!]!
28
35
  """Returns an NFT pool."""
29
36
  getNftPool(
30
37
  """The contract address of the NFT pool."""
@@ -452,6 +459,27 @@ type Query {
452
459
  inputs: [GetPriceInput]
453
460
  ): [Price]
454
461
  """Returns bar chart data to track price changes over time."""
462
+ getTokenBars(
463
+ """The ID of the pair or token (`pairAddress:networkId` or `tokenAddress:networkId`). If a token contract address is provided, the token's top pair is used. For example, `0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2:1` returns WETH's top pair on Ethereum."""
464
+ symbol: String!
465
+ """The unix timestamp for the start of the requested range."""
466
+ from: Int!
467
+ """The unix timestamp for the end of the requested range."""
468
+ to: Int!
469
+ """The time frame for each candle. Available options are `1S`, `5S`, `15S`, `30S`, `1`, `5`, `15`, `30`, `60`, `240`, `720`, `1D`, `7D`. Resolutions lower than 1 minute are only updated for the last 24 hours due to the volume of data produced."""
470
+ resolution: String!
471
+ """The currency to use for the response. Can be `USD` or `TOKEN`. Default is `USD`. Use `currencyCode: TOKEN` for native token pricing."""
472
+ currencyCode: QuoteCurrency
473
+ """Whether to remove leading null values from the response. Default is `false`. To fetch a token's entire history, set resolution to `1D`, `from` value to `0` and `removeLeadingNullValues` to `true`."""
474
+ removeLeadingNullValues: Boolean
475
+ """Whether to remove empty bars from the response. This is useful for eliminating gaps in low-activity tokens. Default is `false`."""
476
+ removeEmptyBars: Boolean
477
+ """The token of interest within the token's top pair. Can be `token0` or `token1`. If omitted, the base token is inferred automatically. You can invert the pair by quoting the other token."""
478
+ statsType: TokenPairStatisticsType
479
+ """Guarantees number of bars returned is at most this number. Use `countback: 1500` with `from: 0` for maximum results."""
480
+ countback: Int
481
+ ): TokenBarsResponse
482
+ """Returns bar chart data to track price changes over time."""
455
483
  getBars(
456
484
  """The ID of the pair or token (`pairAddress:networkId` or `tokenAddress:networkId`). If a token contract address is provided, the token's top pair is used. For example, `0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2:1` returns WETH's top pair on Ethereum."""
457
485
  symbol: String!
@@ -936,6 +964,27 @@ type ApiToken {
936
964
  remaining: String
937
965
  }
938
966
 
967
+ type AptosNetworkConfig {
968
+ id: ID!
969
+ networkId: Int!
970
+ baseTokenAddress: String!
971
+ baseTokenSymbol: String!
972
+ color: String
973
+ defaultPairAddress: String!
974
+ defaultPairQuoteToken: QuoteToken!
975
+ enabled: Boolean!
976
+ newTokensEnabled: Boolean
977
+ explorer: ExplorerConfig!
978
+ mainnet: Boolean!
979
+ name: String!
980
+ networkIconUrl: String!
981
+ networkName: String!
982
+ networkShortName: String!
983
+ networkType: NetworkConfigType!
984
+ stableCoinAddresses: [String!]
985
+ wrappedBaseTokenSymbol: String!
986
+ }
987
+
939
988
  type ArenaTradeData {
940
989
  """Protocol specific token ID"""
941
990
  tokenId: String
@@ -1038,6 +1087,18 @@ type BarsResponse {
1038
1087
  pair: Pair!
1039
1088
  }
1040
1089
 
1090
+ type Block {
1091
+ blockNumber: Int!
1092
+ timestamp: Int!
1093
+ hash: String!
1094
+ }
1095
+
1096
+ input BlocksInput {
1097
+ networkId: Int!
1098
+ blockNumbers: [Int!]
1099
+ timestamps: [Int!]
1100
+ }
1101
+
1041
1102
  """The mathematical formula that defines how the prices of NFTs change after each buy or sell within a pool."""
1042
1103
  enum BondingCurveType {
1043
1104
  EXPONENTIAL
@@ -1949,6 +2010,27 @@ enum EventType {
1949
2010
  PoolBalanceChanged
1950
2011
  }
1951
2012
 
2013
+ type EvmNetworkConfig {
2014
+ id: ID!
2015
+ networkId: Int!
2016
+ baseTokenAddress: String!
2017
+ baseTokenSymbol: String!
2018
+ color: String
2019
+ defaultPairAddress: String!
2020
+ defaultPairQuoteToken: QuoteToken!
2021
+ enabled: Boolean!
2022
+ newTokensEnabled: Boolean
2023
+ explorer: ExplorerConfig!
2024
+ mainnet: Boolean!
2025
+ name: String!
2026
+ networkIconUrl: String!
2027
+ networkName: String!
2028
+ networkShortName: String!
2029
+ networkType: NetworkConfigType!
2030
+ stableCoinAddresses: [String!]
2031
+ wrappedBaseTokenSymbol: String!
2032
+ }
2033
+
1952
2034
  """Metadata for a decentralized exchange."""
1953
2035
  type Exchange {
1954
2036
  """The contract address of the exchange."""
@@ -2077,6 +2159,13 @@ enum ExchangeRankingAttribute {
2077
2159
  monthlyActiveUsers
2078
2160
  }
2079
2161
 
2162
+ type ExplorerConfig {
2163
+ checksummed: Boolean!
2164
+ icon: String!
2165
+ name: String!
2166
+ url: String!
2167
+ }
2168
+
2080
2169
  """Third party token data sourced from off chain."""
2081
2170
  type ExplorerTokenData {
2082
2171
  """The ID of the token (`address:networkId`)."""
@@ -2683,6 +2772,10 @@ enum LaunchpadTokenProtocol {
2683
2772
  Clanker
2684
2773
  """Protocol name for Heaven."""
2685
2774
  HeavenAMM
2775
+ """Protocol name for TokenMill V2."""
2776
+ TokenMillV2
2777
+ """Protocol name for Clanker V4."""
2778
+ ClankerV4
2686
2779
  }
2687
2780
 
2688
2781
  scalar link__Import
@@ -2968,6 +3061,37 @@ type NetworkBreakdown {
2968
3061
  statsYear1: WindowedWalletStats
2969
3062
  }
2970
3063
 
3064
+ union NetworkConfig = EvmNetworkConfig | SolanaNetworkConfig | SuiNetworkConfig | AptosNetworkConfig | StarknetNetworkConfig
3065
+
3066
+ interface NetworkConfigBase {
3067
+ id: ID!
3068
+ networkId: Int!
3069
+ baseTokenAddress: String!
3070
+ baseTokenSymbol: String!
3071
+ color: String
3072
+ defaultPairAddress: String!
3073
+ defaultPairQuoteToken: QuoteToken!
3074
+ enabled: Boolean!
3075
+ newTokensEnabled: Boolean
3076
+ explorer: ExplorerConfig!
3077
+ mainnet: Boolean!
3078
+ name: String!
3079
+ networkIconUrl: String!
3080
+ networkName: String!
3081
+ networkShortName: String!
3082
+ networkType: NetworkConfigType!
3083
+ wrappedBaseTokenSymbol: String!
3084
+ stableCoinAddresses: [String!]
3085
+ }
3086
+
3087
+ enum NetworkConfigType {
3088
+ SOLANA
3089
+ EVM
3090
+ SUI
3091
+ APTOS
3092
+ STARKNET
3093
+ }
3094
+
2971
3095
  """A connection of wallets matching a filter on a specific network."""
2972
3096
  type NetworkWalletFilterConnection {
2973
3097
  """The list of wallets matching the filter parameters."""
@@ -5601,9 +5725,9 @@ input OnLaunchpadTokenEventBatchInput {
5601
5725
  protocols: [LaunchpadTokenProtocol!]
5602
5726
  """The network ID that the token is deployed on."""
5603
5727
  networkId: Int
5604
- """The name of the launchpad. One of the following: Pump.fun, Bonk, Baseapp, Zora, Zora Creator, Four.meme, Believe, Moonshot, Jupiter Studio, boop, Heaven, Virtuals, Clanker, ArenaTrade, Moonit, LaunchLab, MeteoraDBC, Vertigo, Cooking.City, time.fun, BAGS, Circus, Dealr, OhFuckFun, PrintFun, Trend, shout.fun, xApple, Sendshot, DubDub, cults."""
5728
+ """The name of the launchpad. One of the following: Pump.fun, Bonk, Baseapp, Zora, Zora Creator, Four.meme, Believe, Moonshot, Jupiter Studio, boop, Heaven, TokenMill V2, Virtuals, Clanker, Clanker V4, ArenaTrade, Moonit, LaunchLab, MeteoraDBC, Vertigo, Cooking.City, time.fun, BAGS, Circus, Dealr, OhFuckFun, PrintFun, Trend, shout.fun, xApple, Sendshot, DubDub, cults."""
5605
5729
  launchpadName: String
5606
- """A list of launchpad names. Any of the following: Pump.fun, Bonk, Baseapp, Zora, Zora Creator, Four.meme, Believe, Moonshot, Jupiter Studio, boop, Heaven, Virtuals, Clanker, ArenaTrade, Moonit, LaunchLab, MeteoraDBC, Vertigo, Cooking.City, time.fun, BAGS, Circus, Dealr, OhFuckFun, PrintFun, Trend, shout.fun, xApple, Sendshot, DubDub, cults."""
5730
+ """A list of launchpad names. Any of the following: Pump.fun, Bonk, Baseapp, Zora, Zora Creator, Four.meme, Believe, Moonshot, Jupiter Studio, boop, Heaven, TokenMill V2, Virtuals, Clanker, Clanker V4, ArenaTrade, Moonit, LaunchLab, MeteoraDBC, Vertigo, Cooking.City, time.fun, BAGS, Circus, Dealr, OhFuckFun, PrintFun, Trend, shout.fun, xApple, Sendshot, DubDub, cults."""
5607
5731
  launchpadNames: [String!]
5608
5732
  """The type of event."""
5609
5733
  eventType: LaunchpadTokenEventType
@@ -5615,9 +5739,9 @@ input OnLaunchpadTokenEventInput {
5615
5739
  protocol: LaunchpadTokenProtocol
5616
5740
  """A list of launchpad protocols."""
5617
5741
  protocols: [LaunchpadTokenProtocol!]
5618
- """The name of the launchpad. One of the following: Pump.fun, Bonk, Baseapp, Zora, Zora Creator, Four.meme, Believe, Moonshot, Jupiter Studio, boop, Heaven, Virtuals, Clanker, ArenaTrade, Moonit, LaunchLab, MeteoraDBC, Vertigo, Cooking.City, time.fun, BAGS, Circus, Dealr, OhFuckFun, PrintFun, Trend, shout.fun, xApple, Sendshot, DubDub, cults."""
5742
+ """The name of the launchpad. One of the following: Pump.fun, Bonk, Baseapp, Zora, Zora Creator, Four.meme, Believe, Moonshot, Jupiter Studio, boop, Heaven, TokenMill V2, Virtuals, Clanker, Clanker V4, ArenaTrade, Moonit, LaunchLab, MeteoraDBC, Vertigo, Cooking.City, time.fun, BAGS, Circus, Dealr, OhFuckFun, PrintFun, Trend, shout.fun, xApple, Sendshot, DubDub, cults."""
5619
5743
  launchpadName: String
5620
- """A list of launchpad names. Any of the following: Pump.fun, Bonk, Baseapp, Zora, Zora Creator, Four.meme, Believe, Moonshot, Jupiter Studio, boop, Heaven, Virtuals, Clanker, ArenaTrade, Moonit, LaunchLab, MeteoraDBC, Vertigo, Cooking.City, time.fun, BAGS, Circus, Dealr, OhFuckFun, PrintFun, Trend, shout.fun, xApple, Sendshot, DubDub, cults."""
5744
+ """A list of launchpad names. Any of the following: Pump.fun, Bonk, Baseapp, Zora, Zora Creator, Four.meme, Believe, Moonshot, Jupiter Studio, boop, Heaven, TokenMill V2, Virtuals, Clanker, Clanker V4, ArenaTrade, Moonit, LaunchLab, MeteoraDBC, Vertigo, Cooking.City, time.fun, BAGS, Circus, Dealr, OhFuckFun, PrintFun, Trend, shout.fun, xApple, Sendshot, DubDub, cults."""
5621
5745
  launchpadNames: [String!]
5622
5746
  """The type of event."""
5623
5747
  eventType: LaunchpadTokenEventType
@@ -5636,11 +5760,11 @@ input OnPricesUpdatedInput {
5636
5760
  """Response returned by `onBarsUpdated`."""
5637
5761
  type OnTokenBarsUpdatedResponse {
5638
5762
  """The contract address for the pair."""
5639
- pairAddress: String!
5763
+ pairAddress: String @deprecated(reason: "pairs are no longer used for pricing")
5640
5764
  """The network ID the pair is deployed on."""
5641
5765
  networkId: Int!
5642
5766
  """The ID for the pair (`pairAddress`:`networkId`)."""
5643
- pairId: String!
5767
+ pairId: String @deprecated(reason: "pairs are no longer used for pricing")
5644
5768
  """The unix timestamp for the new bar."""
5645
5769
  timestamp: Int!
5646
5770
  """The type of statistics used. Can be `Filtered` or `Unfiltered`."""
@@ -5650,7 +5774,7 @@ type OnTokenBarsUpdatedResponse {
5650
5774
  """Price data broken down by resolution."""
5651
5775
  aggregates: ResolutionBarData!
5652
5776
  """The quote token within the pair."""
5653
- quoteToken: QuoteToken
5777
+ quoteToken: QuoteToken @deprecated(reason: "pairs are no longer used for pricing")
5654
5778
  """The address of the token being quoted"""
5655
5779
  tokenAddress: String!
5656
5780
  """The address of the token being quoted"""
@@ -6538,6 +6662,8 @@ type Price {
6538
6662
  poolAddress: String!
6539
6663
  """Ratio of how confident we are in the price"""
6540
6664
  confidence: Float
6665
+ """The internal pool address for the price"""
6666
+ internalPoolAddress: String
6541
6667
  }
6542
6668
 
6543
6669
  """Webhook conditions for a price event."""
@@ -7222,6 +7348,27 @@ type SocialLinks {
7222
7348
  youtube: String
7223
7349
  }
7224
7350
 
7351
+ type SolanaNetworkConfig {
7352
+ id: ID!
7353
+ networkId: Int!
7354
+ baseTokenAddress: String!
7355
+ baseTokenSymbol: String!
7356
+ color: String
7357
+ defaultPairAddress: String!
7358
+ defaultPairQuoteToken: QuoteToken!
7359
+ enabled: Boolean!
7360
+ newTokensEnabled: Boolean
7361
+ explorer: ExplorerConfig!
7362
+ mainnet: Boolean!
7363
+ name: String!
7364
+ networkIconUrl: String!
7365
+ networkName: String!
7366
+ networkShortName: String!
7367
+ networkType: NetworkConfigType!
7368
+ stableCoinAddresses: [String!]
7369
+ wrappedBaseTokenSymbol: String!
7370
+ }
7371
+
7225
7372
  enum SparklineAttribute {
7226
7373
  PRICE
7227
7374
  }
@@ -7232,6 +7379,27 @@ type SparklineValue {
7232
7379
  value: Float!
7233
7380
  }
7234
7381
 
7382
+ type StarknetNetworkConfig {
7383
+ id: ID!
7384
+ networkId: Int!
7385
+ baseTokenAddress: String!
7386
+ baseTokenSymbol: String!
7387
+ color: String
7388
+ defaultPairAddress: String!
7389
+ defaultPairQuoteToken: QuoteToken!
7390
+ enabled: Boolean!
7391
+ newTokensEnabled: Boolean
7392
+ explorer: ExplorerConfig!
7393
+ mainnet: Boolean!
7394
+ name: String!
7395
+ networkIconUrl: String!
7396
+ networkName: String!
7397
+ networkShortName: String!
7398
+ networkType: NetworkConfigType!
7399
+ stableCoinAddresses: [String!]
7400
+ wrappedBaseTokenSymbol: String!
7401
+ }
7402
+
7235
7403
  """Currency stats."""
7236
7404
  input statsCurrency {
7237
7405
  """The volume over the time frame."""
@@ -7322,6 +7490,27 @@ input StringFilter {
7322
7490
  lt: String
7323
7491
  }
7324
7492
 
7493
+ type SuiNetworkConfig {
7494
+ id: ID!
7495
+ networkId: Int!
7496
+ baseTokenAddress: String!
7497
+ baseTokenSymbol: String!
7498
+ color: String
7499
+ defaultPairAddress: String!
7500
+ defaultPairQuoteToken: QuoteToken!
7501
+ enabled: Boolean!
7502
+ newTokensEnabled: Boolean
7503
+ explorer: ExplorerConfig!
7504
+ mainnet: Boolean!
7505
+ name: String!
7506
+ networkIconUrl: String!
7507
+ networkName: String!
7508
+ networkShortName: String!
7509
+ networkType: NetworkConfigType!
7510
+ stableCoinAddresses: [String!]
7511
+ wrappedBaseTokenSymbol: String!
7512
+ }
7513
+
7325
7514
  """Event data for a token swap event."""
7326
7515
  type SwapEventData {
7327
7516
  """The amount of `token0` involved in the swap. Only applicable for UniswapV3 events."""
@@ -7503,6 +7692,46 @@ enum SymbolType {
7503
7692
  POOL
7504
7693
  }
7505
7694
 
7695
+ """Bar chart data to track price changes over time."""
7696
+ type TokenBarsResponse {
7697
+ """The opening price."""
7698
+ o: [Float]!
7699
+ """The high price."""
7700
+ h: [Float]!
7701
+ """The low price."""
7702
+ l: [Float]!
7703
+ """The closing price."""
7704
+ c: [Float]!
7705
+ """The timestamp for the bar."""
7706
+ t: [Int!]!
7707
+ """The status code for the batch: `ok` for successful data retrieval and `no_data` for empty responses signaling the end of server data."""
7708
+ s: String!
7709
+ """The volume with higher precision."""
7710
+ volume: [String]
7711
+ """The volume in the native token for the network"""
7712
+ volumeNativeToken: [String]
7713
+ """The number of unique buyers"""
7714
+ buyers: [Int]!
7715
+ """The number of buys"""
7716
+ buys: [Int]!
7717
+ """The buy volume in USD"""
7718
+ buyVolume: [String]!
7719
+ """The number of unique sellers"""
7720
+ sellers: [Int]!
7721
+ """The number of sells"""
7722
+ sells: [Int]!
7723
+ """The sell volume in USD"""
7724
+ sellVolume: [String]!
7725
+ """Liquidity in USD"""
7726
+ liquidity: [String]!
7727
+ """The number of traders"""
7728
+ traders: [Int]!
7729
+ """The number of transactions"""
7730
+ transactions: [Int]!
7731
+ """The token that is being returned"""
7732
+ token: EnhancedToken!
7733
+ }
7734
+
7506
7735
  """Token burn event data."""
7507
7736
  type TokenBurnEventData {
7508
7737
  """The amount of tokens burned."""
@@ -7865,15 +8094,15 @@ input TokenFilters {
7865
8094
  creatorAddress: String
7866
8095
  """A list of launchpad protocols."""
7867
8096
  launchpadProtocol: [String!]
7868
- """A list of launchpad names. Any of the following: Pump.fun, Bonk, Baseapp, Zora, Zora Creator, Four.meme, Believe, Moonshot, Jupiter Studio, boop, Heaven, Virtuals, Clanker, ArenaTrade, Moonit, LaunchLab, MeteoraDBC, Vertigo, Cooking.City, time.fun, BAGS, Circus, Dealr, OhFuckFun, PrintFun, Trend, shout.fun, xApple, Sendshot, DubDub, cults."""
8097
+ """A list of launchpad names. Any of the following: Pump.fun, Bonk, Baseapp, Zora, Zora Creator, Four.meme, Believe, Moonshot, Jupiter Studio, boop, Heaven, TokenMill V2, Virtuals, Clanker, Clanker V4, ArenaTrade, Moonit, LaunchLab, MeteoraDBC, Vertigo, Cooking.City, time.fun, BAGS, Circus, Dealr, OhFuckFun, PrintFun, Trend, shout.fun, xApple, Sendshot, DubDub, cults."""
7869
8098
  launchpadName: [String!]
7870
- """Indicates if the launchpad is completed"""
8099
+ """Indicates if the launchpad is completed."""
7871
8100
  launchpadCompleted: Boolean
7872
- """Indicates if the launchpad has migrated"""
8101
+ """Indicates if the launchpad has migrated."""
7873
8102
  launchpadMigrated: Boolean
7874
- """The graduation percentage"""
8103
+ """The graduation percentage."""
7875
8104
  launchpadGraduationPercent: NumberFilter
7876
- """The timestamp when the launchpad was completed"""
8105
+ """The timestamp when the launchpad was completed."""
7877
8106
  launchpadCompletedAt: NumberFilter
7878
8107
  """The timestamp when the launchpad was migrated"""
7879
8108
  launchpadMigratedAt: NumberFilter
@@ -0,0 +1,243 @@
1
+ import "dotenv/config";
2
+
3
+ import * as fs from "fs";
4
+ import { gql } from "graphql-tag";
5
+ import * as path from "path";
6
+
7
+ import { Codex } from "../sdk";
8
+
9
+ const apiKey = process.env.CODEX_API_KEY;
10
+
11
+ if (!apiKey) throw new Error("CODEX_API_KEY env variable not found");
12
+
13
+ const sdk = new Codex(apiKey);
14
+
15
+ const getNetworkConfigsQuery = gql`
16
+ query networkConfigs {
17
+ getNetworkConfigs {
18
+ ... on EvmNetworkConfig {
19
+ __typename
20
+ id
21
+ networkType
22
+ networkId
23
+ name
24
+ enabled
25
+ newTokensEnabled
26
+ mainnet
27
+ wrappedBaseTokenSymbol
28
+ baseTokenSymbol
29
+ baseTokenAddress
30
+ defaultPairAddress
31
+ defaultPairQuoteToken
32
+ stableCoinAddresses
33
+ networkIconUrl
34
+ color
35
+ networkShortName
36
+ networkName
37
+ explorer {
38
+ name
39
+ url
40
+ checksummed
41
+ icon
42
+ }
43
+ }
44
+ ... on SolanaNetworkConfig {
45
+ __typename
46
+ # --- Common fields
47
+ id
48
+ networkType
49
+ networkId
50
+ name
51
+ enabled
52
+ newTokensEnabled
53
+ mainnet
54
+ wrappedBaseTokenSymbol
55
+ baseTokenSymbol
56
+ baseTokenAddress
57
+ defaultPairAddress
58
+ defaultPairQuoteToken
59
+ stableCoinAddresses
60
+ networkIconUrl
61
+ color
62
+ networkShortName
63
+ networkName
64
+ explorer {
65
+ name
66
+ url
67
+ checksummed
68
+ icon
69
+ }
70
+ }
71
+ ... on SuiNetworkConfig {
72
+ __typename
73
+ # --- Common fields
74
+ id
75
+ networkType
76
+ networkId
77
+ name
78
+ enabled
79
+ newTokensEnabled
80
+ mainnet
81
+ wrappedBaseTokenSymbol
82
+ baseTokenSymbol
83
+ baseTokenAddress
84
+ defaultPairAddress
85
+ defaultPairQuoteToken
86
+ stableCoinAddresses
87
+ networkIconUrl
88
+ color
89
+ networkShortName
90
+ networkName
91
+ explorer {
92
+ name
93
+ url
94
+ checksummed
95
+ icon
96
+ }
97
+ }
98
+ ... on AptosNetworkConfig {
99
+ __typename
100
+ # --- Common fields
101
+ id
102
+ networkType
103
+ networkId
104
+ name
105
+ enabled
106
+ newTokensEnabled
107
+ mainnet
108
+ wrappedBaseTokenSymbol
109
+ baseTokenSymbol
110
+ baseTokenAddress
111
+ defaultPairAddress
112
+ defaultPairQuoteToken
113
+ stableCoinAddresses
114
+ networkIconUrl
115
+ color
116
+ networkShortName
117
+ networkName
118
+ explorer {
119
+ name
120
+ url
121
+ checksummed
122
+ icon
123
+ }
124
+ }
125
+ ... on StarknetNetworkConfig {
126
+ __typename
127
+ # --- Common fields
128
+ id
129
+ networkType
130
+ networkId
131
+ name
132
+ enabled
133
+ newTokensEnabled
134
+ mainnet
135
+ wrappedBaseTokenSymbol
136
+ baseTokenSymbol
137
+ baseTokenAddress
138
+ defaultPairAddress
139
+ defaultPairQuoteToken
140
+ stableCoinAddresses
141
+ networkIconUrl
142
+ color
143
+ networkShortName
144
+ networkName
145
+ explorer {
146
+ name
147
+ url
148
+ checksummed
149
+ icon
150
+ }
151
+ }
152
+ }
153
+ }
154
+ `;
155
+
156
+ const getTokensQuery = gql`
157
+ query getTokens($tokens: [String!]!) {
158
+ filterTokens(tokens: $tokens) {
159
+ results {
160
+ token {
161
+ name
162
+ id
163
+ decimals
164
+ }
165
+ }
166
+ }
167
+ }
168
+ `;
169
+
170
+ async function main() {
171
+ // eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any
172
+ const data = await sdk.query<{ getNetworkConfigs: any }, {}>(
173
+ getNetworkConfigsQuery,
174
+ );
175
+ const networkConfigs = data.getNetworkConfigs;
176
+
177
+ // Get all base token addresses with their network IDs
178
+ const tokenIds: string[] = networkConfigs.map(
179
+ (config: { baseTokenAddress: string; networkId: number }) =>
180
+ `${config.baseTokenAddress}:${config.networkId}`,
181
+ );
182
+
183
+ // Fetch base token names
184
+ const tokenData = await sdk.query<
185
+ {
186
+ filterTokens: {
187
+ results: {
188
+ token: { id: string; name: string; decimals: number };
189
+ }[];
190
+ };
191
+ },
192
+ { tokens: string[] }
193
+ >(getTokensQuery, {
194
+ tokens: tokenIds,
195
+ });
196
+
197
+ // Create a map of address:networkId -> name
198
+ const tokenNameMap = new Map(
199
+ tokenData.filterTokens.results.map((result) => [
200
+ result.token.id,
201
+ result.token.name,
202
+ ]),
203
+ );
204
+ // Create a map of address:networkId -> decimals
205
+ const tokenDecimalsMap = new Map(
206
+ tokenData.filterTokens.results.map((result) => [
207
+ result.token.id,
208
+ result.token.decimals,
209
+ ]),
210
+ );
211
+
212
+ // Add baseTokenName to each network config
213
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
214
+ const enrichedConfigs = networkConfigs
215
+ .map((config: any) => ({
216
+ ...config,
217
+ baseTokenName:
218
+ tokenNameMap.get(`${config.baseTokenAddress}:${config.networkId}`) ||
219
+ config.baseTokenSymbol,
220
+ baseTokenDecimals:
221
+ tokenDecimalsMap.get(
222
+ `${config.baseTokenAddress}:${config.networkId}`,
223
+ ) || config.baseTokenDecimals,
224
+ }))
225
+ .sort((a: { name: string }, b: { name: string }) =>
226
+ a.name.localeCompare(b.name),
227
+ );
228
+ console.log(
229
+ `Fetched ${networkConfigs.length} network configs, writing them to generated files`,
230
+ );
231
+
232
+ const filePath = path.resolve(__dirname, "../resources/networkConfigs.json");
233
+
234
+ // Ensure the directory exists
235
+ const dirPath = path.dirname(filePath);
236
+ if (!fs.existsSync(dirPath)) {
237
+ fs.mkdirSync(dirPath, { recursive: true });
238
+ }
239
+
240
+ fs.writeFileSync(filePath, JSON.stringify(enrichedConfigs, null, 2));
241
+ }
242
+
243
+ main().catch(console.error);
@@ -15,15 +15,15 @@ import { Codex } from "./index";
15
15
 
16
16
  export class Mutation {
17
17
  constructor(private sdk: Codex) {}
18
- backfillWalletAggregates = async (
19
- vars: BackfillWalletAggregatesMutationVariables,
20
- ) => this.sdk.mutation(BackfillWalletAggregatesDocument, vars);
21
18
  createWebhooks = async (vars: CreateWebhooksMutationVariables) =>
22
19
  this.sdk.mutation(CreateWebhooksDocument, vars);
23
- deleteApiToken = async (vars: DeleteApiTokenMutationVariables) =>
24
- this.sdk.mutation(DeleteApiTokenDocument, vars);
25
- createApiTokens = async (vars: CreateApiTokensMutationVariables) =>
26
- this.sdk.mutation(CreateApiTokensDocument, vars);
27
20
  deleteWebhooks = async (vars: DeleteWebhooksMutationVariables) =>
28
21
  this.sdk.mutation(DeleteWebhooksDocument, vars);
22
+ createApiTokens = async (vars: CreateApiTokensMutationVariables) =>
23
+ this.sdk.mutation(CreateApiTokensDocument, vars);
24
+ deleteApiToken = async (vars: DeleteApiTokenMutationVariables) =>
25
+ this.sdk.mutation(DeleteApiTokenDocument, vars);
26
+ backfillWalletAggregates = async (
27
+ vars: BackfillWalletAggregatesMutationVariables,
28
+ ) => this.sdk.mutation(BackfillWalletAggregatesDocument, vars);
29
29
  }