Skip to content

Commit 536e728

Browse files
authored
Merge pull request #2 from enviodev/feat/stableswap-ng
Feat/stableswap ng
2 parents 1f8b2af + 372cdc4 commit 536e728

9 files changed

Lines changed: 1281 additions & 10 deletions

File tree

config.yaml

Lines changed: 155 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,69 @@ contracts:
7070
transaction_fields:
7171
- hash
7272

73+
# Stableswap-NG factory. Deploy events carry NO pool address, so the address
74+
# is resolved in contractRegister via pool_list(pool_count()-1).
75+
- name: StableswapFactoryNG
76+
events:
77+
- event: PlainPoolDeployed(address[] coins, uint256 A, uint256 fee, address deployer)
78+
field_selection:
79+
transaction_fields:
80+
- hash
81+
- event: MetaPoolDeployed(address coin, address base_pool, uint256 A, uint256 fee, address deployer)
82+
field_selection:
83+
transaction_fields:
84+
- hash
85+
86+
# Stableswap-NG pool, registered dynamically by the factory above. Pool
87+
# entity is initialized lazily on the first event we see for it.
88+
- name: StableswapPool
89+
events:
90+
- event: TokenExchange(address indexed buyer, int128 sold_id, uint256 tokens_sold, int128 bought_id, uint256 tokens_bought)
91+
field_selection:
92+
transaction_fields:
93+
- hash
94+
- event: TokenExchangeUnderlying(address indexed buyer, int128 sold_id, uint256 tokens_sold, int128 bought_id, uint256 tokens_bought)
95+
field_selection:
96+
transaction_fields:
97+
- hash
98+
- event: AddLiquidity(address indexed provider, uint256[] token_amounts, uint256[] fees, uint256 invariant, uint256 token_supply)
99+
field_selection:
100+
transaction_fields:
101+
- hash
102+
- event: RemoveLiquidity(address indexed provider, uint256[] token_amounts, uint256[] fees, uint256 token_supply)
103+
field_selection:
104+
transaction_fields:
105+
- hash
106+
- event: RemoveLiquidityOne(address indexed provider, int128 token_id, uint256 token_amount, uint256 coin_amount, uint256 token_supply)
107+
field_selection:
108+
transaction_fields:
109+
- hash
110+
- event: RemoveLiquidityImbalance(address indexed provider, uint256[] token_amounts, uint256[] fees, uint256 invariant, uint256 token_supply)
111+
field_selection:
112+
transaction_fields:
113+
- hash
114+
115+
# Legacy stableswap — pools are registered via the Main Registry's PoolAdded
116+
# (which, unlike the NG factory, carries the pool address). Metadata is read
117+
# from the registry; swaps share the int128 TokenExchange signature.
118+
- name: MainRegistry
119+
events:
120+
- event: PoolAdded(address indexed pool, bytes rate_method_id)
121+
field_selection:
122+
transaction_fields:
123+
- hash
124+
125+
- name: LegacyStablePool
126+
events:
127+
- event: TokenExchange(address indexed buyer, int128 sold_id, uint256 tokens_sold, int128 bought_id, uint256 tokens_bought)
128+
field_selection:
129+
transaction_fields:
130+
- hash
131+
73132
chains:
74133
# Ethereum Mainnet
75134
- id: 1
76-
start_block: 12500000
135+
start_block: 12195812
77136
contracts:
78137
- name: TricryptoFactoryNG
79138
address:
@@ -91,6 +150,15 @@ chains:
91150
address:
92151
- 0xd51a44d3fae010294c616388b506acda1bfaae46
93152
- name: CryptoPool
153+
- name: StableswapFactoryNG
154+
address:
155+
- 0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf
156+
start_block: 18433925
157+
- name: StableswapPool
158+
- name: MainRegistry
159+
address:
160+
- 0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5
161+
- name: LegacyStablePool
94162

95163
# Arbitrum
96164
- id: 42161
@@ -103,3 +171,89 @@ chains:
103171
address:
104172
- 0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F
105173
- name: CryptoPool
174+
- name: StableswapFactoryNG
175+
address:
176+
- 0x9AF14D26075f142eb3F292D5065EB3faa646167b
177+
start_block: 144181239
178+
- name: StableswapPool
179+
180+
# Optimism
181+
- id: 10
182+
start_block: 111362244
183+
contracts:
184+
- name: StableswapFactoryNG
185+
address:
186+
- 0x5eeE3091f747E60a045a2E715a4c71e600e31F6E
187+
- name: StableswapPool
188+
189+
# Base
190+
- id: 8453
191+
start_block: 7886150
192+
contracts:
193+
- name: StableswapFactoryNG
194+
address:
195+
- 0xd2002373543Ce3527023C75e7518C274A51ce712
196+
- name: StableswapPool
197+
198+
# Polygon
199+
- id: 137
200+
start_block: 50625140
201+
contracts:
202+
- name: StableswapFactoryNG
203+
address:
204+
- 0x1764ee18e8B3ccA4787249Ceb249356192594585
205+
- name: StableswapPool
206+
207+
# Gnosis (xDai)
208+
- id: 100
209+
start_block: 30507817
210+
contracts:
211+
- name: StableswapFactoryNG
212+
address:
213+
- 0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8
214+
- name: StableswapPool
215+
216+
# BSC
217+
- id: 56
218+
start_block: 34487718
219+
contracts:
220+
- name: StableswapFactoryNG
221+
address:
222+
- 0xd7E72f3615aa65b92A4DBdC211E296a35512988B
223+
- name: StableswapPool
224+
225+
# Fantom
226+
- id: 250
227+
start_block: 72534264
228+
contracts:
229+
- name: StableswapFactoryNG
230+
address:
231+
- 0xe61Fb97Ef6eBFBa12B36Ffd7be785c1F5A2DE66b
232+
- name: StableswapPool
233+
234+
# Fraxtal
235+
- id: 252
236+
start_block: 1911424
237+
contracts:
238+
- name: StableswapFactoryNG
239+
address:
240+
- 0xd2002373543Ce3527023C75e7518C274A51ce712
241+
- name: StableswapPool
242+
243+
# Sonic
244+
- id: 146
245+
start_block: 3231331
246+
contracts:
247+
- name: StableswapFactoryNG
248+
address:
249+
- 0x7C2085419BE6a04f4ad88ea91bC9F5C6E6C463D8
250+
- name: StableswapPool
251+
252+
# Avalanche
253+
- id: 43114
254+
start_block: 38813389
255+
contracts:
256+
- name: StableswapFactoryNG
257+
address:
258+
- 0x1764ee18e8B3ccA4787249Ceb249356192594585
259+
- name: StableswapPool

schema.graphql

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ enum PoolType {
1414
CRYPTO_V1
1515
TRICRYPTO_LEGACY
1616
TWOCRYPTO_STANDALONE
17+
STABLESWAP_NG
18+
STABLESWAP_NG_META
19+
STABLESWAP
1720
}
1821

1922
enum PriceSource {
@@ -61,6 +64,11 @@ type Pool {
6164
coinDecimals: [Int!]!
6265
lastPrices: [BigInt!]!
6366
priceScales: [BigInt!]!
67+
# Stableswap fields — null for crypto pools
68+
a: BigInt
69+
virtualPrice: BigInt
70+
isMetaPool: Boolean
71+
basePool: String
6472
balances: [BigInt!]!
6573
totalSwapCount: BigInt!
6674
totalVolumeUsd: BigDecimal!
@@ -75,6 +83,44 @@ type Pool {
7583
liquidityEvents: [LiquidityEvent!]! @derivedFrom(field: "pool")
7684
poolPairs: [PoolPair!]! @derivedFrom(field: "pool")
7785
poolPrices: [PoolPrice!]! @derivedFrom(field: "pool")
86+
swaps: [Swap!]! @derivedFrom(field: "pool")
87+
snapshots: [PoolSnapshot!]! @derivedFrom(field: "pool")
88+
}
89+
90+
# General per-swap record. Used by all pool classes (stableswap today; crypto
91+
# pools also write the richer PoolPrice entity for oracle-based pricing).
92+
type Swap {
93+
id: ID!
94+
chainId: Int!
95+
pool: Pool! @index
96+
buyer: String! @index
97+
soldId: Int!
98+
boughtId: Int!
99+
tokensSold: BigInt!
100+
tokensBought: BigInt!
101+
tokensSoldDecimal: BigDecimal!
102+
tokensBoughtDecimal: BigDecimal!
103+
volumeUsd: BigDecimal
104+
blockNumber: Int! @index
105+
timestamp: BigInt! @index
106+
txHash: String!
107+
logIndex: Int!
108+
}
109+
110+
# Daily per-pool time-series, upserted on each swap/liquidity event.
111+
# id = chainId_poolAddress_day (day = unix timestamp / 86400).
112+
type PoolSnapshot {
113+
id: ID!
114+
chainId: Int!
115+
pool: Pool! @index
116+
day: Int! @index
117+
timestamp: BigInt!
118+
blockNumber: Int!
119+
tvlUsd: BigDecimal
120+
virtualPrice: BigInt
121+
balances: [BigInt!]!
122+
volumeUsd: BigDecimal!
123+
swapCount: Int!
78124
}
79125

80126
type PoolPair {

0 commit comments

Comments
 (0)