Skip to content

Commit 1289a08

Browse files
Remove tracking of pools (#492)
* Removing pool mapping * Removing pool utils * Removing pool transaction types * Removing TokenTransaction from schema * Removing pool functions from src/mappings/utils/globalUtils.ts * Removing pool functions from src/mappings/factoryRouter.ts * Removing pools from the schema * removing pool events from subgraph.template.yaml * Fixing TokenAdded in subgraph template Co-authored-by: mihaisc <[email protected]>
1 parent 61cfdba commit 1289a08

9 files changed

+28
-810
lines changed

schema.graphql

+6-190
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ type Token @entity {
4747
"dispensers using this token"
4848
dispensers: [Dispenser!] @derivedFrom(field:"token")
4949

50-
"pools, only available for datatokens"
51-
pools: [Pool!] @derivedFrom(field:"datatoken")
52-
5350
"block time datatoken was created"
5451
createdTimestamp: Int!
5552

@@ -76,7 +73,7 @@ type Nft @entity{
7673
id: ID!
7774
symbol: String!
7875
name: String!
79-
tokenUri: String!
76+
tokenUri: String
8077

8178
"address of the owner of the nft"
8279
owner: String!
@@ -115,134 +112,6 @@ type Nft @entity{
115112
orderCount: BigInt!
116113
}
117114

118-
type Pool @entity {
119-
"pool address"
120-
id: ID!
121-
122-
"owner address, pool controller"
123-
controller: String
124-
125-
"only finalized pools are relevant to us"
126-
isFinalized: Boolean!
127-
128-
"pool token symbol"
129-
symbol: String
130-
131-
"pool token name"
132-
name: String
133-
134-
"maximum supply if any, converted from wei"
135-
cap: BigDecimal
136-
137-
baseToken: Token!
138-
baseTokenLiquidity: BigDecimal!
139-
baseTokenWeight: BigDecimal!
140-
141-
datatoken: Token!
142-
datatokenLiquidity: BigDecimal!
143-
datatokenWeight: BigDecimal!
144-
145-
"publisher market fee value"
146-
publishMarketSwapFee: BigDecimal!
147-
"publisher market fee total amount"
148-
publishMarketSwapFeeAmount: BigDecimal
149-
150-
"Liquidty provider fee value"
151-
liquidityProviderSwapFee: BigDecimal
152-
"liquidity provider fee total amount"
153-
liquidityProviderSwapFeeAmount: BigDecimal!
154-
155-
"total pool token shares"
156-
totalShares: BigDecimal!
157-
158-
"total tokens that were swaped"
159-
totalSwapVolume: [TokenValuePair!]!
160-
161-
spotPrice: BigDecimal!
162-
163-
"count for when liquidity has been added"
164-
joinCount: BigInt!
165-
166-
"count for when liquidity has been removed"
167-
exitCount: BigInt!
168-
169-
"count for when tokens were swapped"
170-
swapCount: BigInt!
171-
172-
"number of transactions in this pool involving liquidity changes"
173-
transactionCount: BigInt!
174-
175-
"block time when pool was created"
176-
createdTimestamp: Int!
177-
"pool creation transaction id"
178-
tx: String!
179-
"block number when it was created"
180-
block: Int
181-
182-
shares: [PoolShare!] @derivedFrom(field: "pool")
183-
transactions: [PoolTransaction!] @derivedFrom(field: "pool")
184-
185-
"address of the market where the datatoken was created. This address collects market fees."
186-
publishMarketFeeAddress: String
187-
188-
189-
190-
191-
}
192-
193-
# we will need to track pool share tx between users - bpool transfer tx event
194-
type PoolShare @entity {
195-
"poolAddress + userAddress"
196-
id: ID!
197-
user: User!
198-
pool: Pool!
199-
shares: BigDecimal!
200-
}
201-
202-
enum PoolTransactionType {
203-
JOIN,
204-
EXIT,
205-
SWAP,
206-
SETUP
207-
}
208-
209-
type PoolTransaction @entity {
210-
"tx address + eventIndex"
211-
id: ID!
212-
"pool related to this tx"
213-
pool: Pool!
214-
"user that initiates the tx"
215-
user: User!
216-
type: PoolTransactionType!
217-
218-
"number of shares transfered"
219-
sharesTransferAmount: BigDecimal!
220-
221-
"block time when pool was created"
222-
timestamp: Int!
223-
"pool creation transaction id"
224-
tx: String!
225-
eventIndex: BigInt
226-
"block number when it was created"
227-
block: Int
228-
229-
gasLimit: BigDecimal!
230-
"price expressed in eth"
231-
gasPrice: BigDecimal!
232-
233-
"base tokens transfered"
234-
baseToken: Token
235-
236-
"number of base tokens transfered, for type SWAP if value is negative it means it was removed"
237-
baseTokenValue: BigDecimal
238-
239-
"datatokens transfered"
240-
datatoken: Token
241-
242-
"number of datatokens transfered, for type SWAP if value is negative it means it was removed"
243-
datatokenValue: BigDecimal
244-
}
245-
246115
type OrderReuse @entity {
247116
id: ID!
248117
order: Order!
@@ -253,6 +122,7 @@ type OrderReuse @entity {
253122
providerFee: String
254123
providerFeeValidUntil: BigInt
255124
}
125+
256126
type Order @entity {
257127
"transaction hash - token address - from address"
258128
id: ID!
@@ -286,25 +156,9 @@ type Order @entity {
286156
estimatedUSDValue: BigDecimal!
287157
}
288158

289-
# to be removed, mabye for pool shares only
290-
type TokenTransaction @entity {
291-
id: ID! # Log ID
292-
event: String
293-
token: Token
294-
user: User
295-
296-
block: Int!
297-
gasUsed: BigDecimal!
298-
gasPrice: BigDecimal!
299-
createdTimestamp: Int!
300-
tx: String!
301-
}
302-
303159
type User @entity {
304160
id: ID!
305-
sharesOwned: [PoolShare!] @derivedFrom(field: "user")
306161
tokenBalancesOwned: [TokenValuePair!]
307-
poolTransactions: [PoolTransaction!] @derivedFrom(field: "user")
308162
orders: [Order!] @derivedFrom(field: "payer")
309163
freSwaps: [FixedRateExchangeSwap!] @derivedFrom(field: "by")
310164

@@ -422,28 +276,6 @@ type DispenserTransaction @entity {
422276
tx: String!
423277
}
424278

425-
type PoolSnapshot @entity {
426-
id: ID!
427-
pool: Pool!
428-
"total pool shares at the end of the 24h interval"
429-
totalShares: BigDecimal!
430-
"swap value 24h"
431-
swapVolume: BigDecimal!
432-
"swap fee value 24h"
433-
swapFees: BigDecimal!
434-
"date without time"
435-
date: Int!
436-
"last spot price in the 24h interval"
437-
spotPrice: BigDecimal!
438-
439-
baseToken: Token!
440-
baseTokenLiquidity: BigDecimal!
441-
442-
datatoken: Token!
443-
datatokenLiquidity: BigDecimal!
444-
445-
}
446-
447279
"utility type"
448280
type GlobalTotalLiquidityPair @entity {
449281
"address of the token"
@@ -453,15 +285,6 @@ type GlobalTotalLiquidityPair @entity {
453285
value : BigDecimal!
454286
}
455287

456-
"utility type"
457-
type GlobalTotalPoolSwapPair @entity {
458-
"address of the token"
459-
id : ID!
460-
globalStatistic: GlobalStatistic!
461-
token : Token!
462-
value : BigDecimal!
463-
count: BigInt!
464-
}
465288
"utility type"
466289
type GlobalTotalFixedSwapPair @entity {
467290
"address of the token"
@@ -472,25 +295,18 @@ type GlobalTotalFixedSwapPair @entity {
472295
count: BigInt!
473296
}
474297
type GlobalStatistic @entity {
475-
id: ID!
476-
477-
"total liquidity for each base token in pools"
478-
totalLiquidity: [GlobalTotalLiquidityPair!]! @derivedFrom(field: "globalStatistic")
479-
"total swap volume for each base token in pools"
480-
totalPoolSwapVolume: [GlobalTotalPoolSwapPair!]! @derivedFrom(field: "globalStatistic")
298+
id: ID!
481299

482300
"total swap volume for each base token in fixed rate exchanges"
483301
totalFixedSwapVolume: [GlobalTotalFixedSwapPair!] @derivedFrom(field: "globalStatistic")
484302

485-
"number of total orders. pool orders + fixed rate exchange orders + dispenser orders"
303+
"number of total orders. fixed rate exchange orders + dispenser orders"
486304
orderCount: Int!
487305

488306
"total nfts(erc721) created"
489307
nftCount: Int!
490308
"total datatokens (tokens with isDatatoken = true) created"
491-
datatokenCount:Int!
492-
"number of pools"
493-
poolCount: Int!
309+
datatokenCount:Int!
494310

495311
"number of fixed rate exchanges"
496312
fixedCount: Int!
@@ -524,7 +340,7 @@ type OPC @entity {
524340

525341
type NftUpdate @entity {
526342
id: ID! # update tx + nft address
527-
tokenUri: String!
343+
tokenUri: String
528344
nft: Nft!
529345

530346
"provider url that can decrypt the ddo"

src/mappings/dispenser.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { weiToDecimal } from './utils/generic'
1717
import { addDispenser } from './utils/globalUtils'
1818
import { getToken } from './utils/tokenUtils'
1919
import { getUser } from './utils/userUtils'
20+
import { BigDecimal } from '@graphprotocol/graph-ts'
2021

2122
export function handleNewDispenser(event: DispenserCreated): void {
2223
const dispenserID = getDispenserGraphID(
@@ -38,7 +39,7 @@ export function handleNewDispenser(event: DispenserCreated): void {
3839
token.decimals
3940
)
4041
dispenser.active = true
41-
42+
dispenser.balance = BigDecimal.zero()
4243
dispenser.allowedSwapper = event.params.allowedSwapper.toHex()
4344
dispenser.createdTimestamp = event.block.timestamp.toI32()
4445
dispenser.tx = event.transaction.hash.toHex()

src/mappings/factoryRouter.ts

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
NewPool,
32
TokenAdded,
43
TokenRemoved,
54
OPCFeeChanged,
@@ -12,19 +11,11 @@ import {
1211
DispenserContractRemoved
1312
} from '../@types/FactoryRouter/FactoryRouter'
1413
import { BigInt } from '@graphprotocol/graph-ts'
15-
import { Pool } from '../@types/schema'
16-
import { BPool, FixedRateExchange, Dispenser } from '../@types/templates'
17-
import { addPool, getOPC, getTemplates } from './utils/globalUtils'
14+
import { FixedRateExchange, Dispenser } from '../@types/templates'
15+
import { getOPC, getTemplates } from './utils/globalUtils'
1816
import { weiToDecimal } from './utils/generic'
1917
import { getToken } from './utils/tokenUtils'
2018

21-
export function handleNewPool(event: NewPool): void {
22-
BPool.create(event.params.poolAddress)
23-
const pool = new Pool(event.params.poolAddress.toHexString())
24-
pool.save()
25-
addPool()
26-
}
27-
2819
export function handleOPCFeeChanged(event: OPCFeeChanged): void {
2920
const opc = getOPC()
3021
const decimals = BigInt.fromI32(18).toI32()

0 commit comments

Comments
 (0)