Skip to content

Commit e1f4dcf

Browse files
committed
chore: remove price collection code needed for sgb reward distribution
1 parent 24a08f4 commit e1f4dcf

File tree

3 files changed

+2
-93
lines changed

3 files changed

+2
-93
lines changed

packages/fasset-indexer-core/src/context/dal.ts

Lines changed: 0 additions & 56 deletions
This file was deleted.

packages/fasset-indexer-core/src/indexer/eventlib/event-parser.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,26 +58,6 @@ export class EventParser {
5858
} else if (await this.isCollateralPoolToken(em, log.address)) {
5959
return this.context.interfaces.erc20Interface.parseLog(log)
6060
}
61-
///////////// delete from /////////////
62-
if (this.context.config.indexPrices) {
63-
let parsed = null
64-
try {
65-
parsed = this.context.interfaces.erc20Interface.parseLog(log)
66-
} catch (e) {
67-
return null
68-
}
69-
const from = parsed?.args[0]
70-
const to = parsed?.args[1]
71-
if ((from != null && to != null) && (
72-
await this.isCollateralPool(em, from)
73-
|| await this.isAgentVault(em, from)
74-
|| await this.isCollateralPool(em, to)
75-
|| await this.isAgentVault(em, to)
76-
)) {
77-
return parsed
78-
}
79-
}
80-
///////////// delete to /////////////
8161
} else if (iface === 'COLLATERAL_POOL') {
8262
const em = this.context.orm.em.fork()
8363
if (await this.isCollateralPool(em, log.address)) {

packages/fasset-indexer-core/src/indexer/eventlib/state-updater.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ import { AgentManager, AgentOwner, AgentVault } from "../../orm/entities/agent"
33
import { AgentVaultSettings } from "../../orm/entities/state/agent"
44
import { AgentVaultCreated } from "../../orm/entities/events/agent"
55
import { UntrackedAgentVault } from "../../orm/entities/state/var"
6-
import { CollateralTypeAdded } from "../../orm/entities/events/token"
7-
import { PricePublished, PricesPublished } from "../../orm/entities/events/price"
6+
import { PricesPublished } from "../../orm/entities/events/price"
87
import { updateAgentVaultInfo, findOrCreateEvmAddress } from "../utils"
9-
import { getPriceFromDal } from "../../context/dal"
108
import { EventStorer } from "./event-storer"
119
import type { EntityManager } from "@mikro-orm/knex"
1210
import type { AgentVaultCreatedEvent } from "../../../chain/typechain/IAssetManager"
@@ -35,10 +33,7 @@ export class StateUpdater extends EventStorer {
3533
}
3634

3735
protected override async onPublishedPrices(em: EntityManager, evmLog: EvmLog, args: any): Promise<PricesPublished> {
38-
const pp = await super.onPublishedPrices(em, evmLog, args)
39-
if (this.context.config.indexPrices)
40-
await this.addPriceSnapshot(em, pp)
41-
return pp
36+
return await super.onPublishedPrices(em, evmLog, args)
4237
}
4338

4439
protected async ensureAgentManager(em: EntityManager, address: string): Promise<AgentManager> {
@@ -75,16 +70,6 @@ export class StateUpdater extends EventStorer {
7570
return agentManager
7671
}
7772

78-
private async addPriceSnapshot(em: EntityManager, pricesPublished: PricesPublished): Promise<void> {
79-
const collateralTypes = await em.findAll(CollateralTypeAdded)
80-
const symbols = new Set(collateralTypes.map((ct) => [ct.tokenFtsoSymbol, ct.assetFtsoSymbol]).flat())
81-
for (let symbol of symbols) {
82-
const [price, decimals] = await getPriceFromDal(symbol, pricesPublished.votingRoundId)
83-
const priceEntity = new PricePublished(pricesPublished, symbol, price, decimals)
84-
em.persist(priceEntity)
85-
}
86-
}
87-
8873
private async updateAgentVaultInfo(em: EntityManager, agentVault: AgentVault): Promise<void> {
8974
try {
9075
const assetManager = this.context.fAssetTypeToAssetManagerAddress(agentVault.fasset)

0 commit comments

Comments
 (0)