Skip to content

Commit

Permalink
add contractNames to kana
Browse files Browse the repository at this point in the history
  • Loading branch information
ye-sentio committed Feb 19, 2024
1 parent b089408 commit cb62b10
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
17 changes: 9 additions & 8 deletions projects/kana/src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const vol = Gauge.register("vol")
const routes = Gauge.register("routes")
const routesCounter = Counter.register("routes_counter")

// here starts the previous contract
// v1
kana_aggregatorv1.bind()
.onEventSwapStepEvent(async (event, ctx) => {
ctx.meter.Counter('swap_step_event_emit').add(1)
Expand Down Expand Up @@ -65,6 +65,7 @@ kana_aggregatorv1.bind()
symbolY: symbolY,
pair: displayPair,
tag: "kana",
contractName: "kana aggregator v1",
message: `Legacy Kana contract swap ${volume} ${symbolX} to ${symbolY} through dex ${getDex(dexType, KANA_DEX_MAP)}`
})

Expand All @@ -73,7 +74,7 @@ kana_aggregatorv1.bind()
})


// here starts the new contract
// v2
KanalabsAggregatorV1.bind()
.onEventSwapStepEvent(async (event, ctx) => {
ctx.meter.Counter('swap_step_event_emit').add(1)
Expand Down Expand Up @@ -116,6 +117,7 @@ KanalabsAggregatorV1.bind()
symbolY: symbolY,
pair: displayPair,
tag: "kana",
contractName: "kana aggregator v2",
message: `New Kana contract swap ${volume} ${symbolX} to ${symbolY} through dex ${getDex(dexType, KANA_DEX_MAP)}`
})
ctx.eventLogger.emit("any", {
Expand All @@ -133,12 +135,14 @@ KanalabsRouterV1.bind()

ctx.eventLogger.emit("route", {
distinctId: ctx.transaction.sender,
tag: "kana"
tag: "kana",
contractName: "kana router v2",
})


}))

//v3
Aggregator.bind()
.onEventSwapStepEvent(async (event, ctx) => {
ctx.meter.Counter('swap_step_event_emit').add(1)
Expand Down Expand Up @@ -179,6 +183,7 @@ Aggregator.bind()
symbolY: symbolY,
pair: displayPair,
tag: "kana",
contractName: "kana aggregator v3",
message: `KanaAggregator swap ${volume} ${symbolX} to ${symbolY} through dex ${getDex(dexType, KANA_DEX_MAP)}`
})
ctx.eventLogger.emit("any", {
Expand All @@ -197,7 +202,6 @@ aggregator.bind({ address: "0x89576037b3cc0b89645ea393a47787bb348272c76d6941c574
const dexType = evt.data_decoded.dex_type
const xType = extractTypeName(evt.data_decoded.x_type_info)
const yType = extractTypeName(evt.data_decoded.y_type_info)

const coinXInfo = getCoinInfo(xType)
const coinYInfo = getCoinInfo(yType)
const poolType = evt.data_decoded.pool_type
Expand All @@ -208,9 +212,7 @@ aggregator.bind({ address: "0x89576037b3cc0b89645ea393a47787bb348272c76d6941c574
const symbolX = coinXInfo.symbol
const symbolY = coinYInfo.symbol
const displayPair = constructDisplay(symbolX, symbolY)

totalTx.add(ctx, 1, { tag: "hippo" })

if (whiteListed(xType)) {
vol.record(ctx, volume, { dex: getDex(dexType, HIPPO_DEX_MAP), poolType: poolType.toString(), xType: xType, yType: yType, symbolX: symbolX, symbolY: symbolY, pair: displayPair })
volCounter.add(ctx, volume, { dex: getDex(dexType, HIPPO_DEX_MAP), poolType: poolType.toString(), xType: xType, yType: yType, symbolX: symbolX, symbolY: symbolY, pair: displayPair, tag: "hippo" })
Expand All @@ -225,6 +227,7 @@ aggregator.bind({ address: "0x89576037b3cc0b89645ea393a47787bb348272c76d6941c574
symbolY: symbolY,
pair: displayPair,
tag: "hippo",
contractName: "hippo aggregator",
message: `Hippo swap ${volume} ${symbolX} to ${symbolY} through dex ${getDex(dexType, HIPPO_DEX_MAP)}`
})
ctx.eventLogger.emit("any", {
Expand All @@ -233,8 +236,6 @@ aggregator.bind({ address: "0x89576037b3cc0b89645ea393a47787bb348272c76d6941c574
}
})



function constructPair(xType: String, yType: String) {
if (xType > yType) {
return xType + "-" + yType
Expand Down
7 changes: 5 additions & 2 deletions projects/kana/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
"rootDir": "./src",
"skipLibCheck": true
},
"exclude": ["dist", "jest.config.ts"]
}
"exclude": [
"dist",
"jest.config.ts"
]
}

0 comments on commit cb62b10

Please sign in to comment.