From d87fbed5b509031bafe4ff21dea1b6cec5f6d1ce Mon Sep 17 00:00:00 2001 From: mihaisc Date: Thu, 23 Jun 2022 04:51:14 -0700 Subject: [PATCH] create token (#467) --- src/mappings/factoryRouter.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mappings/factoryRouter.ts b/src/mappings/factoryRouter.ts index 9259619..3704129 100644 --- a/src/mappings/factoryRouter.ts +++ b/src/mappings/factoryRouter.ts @@ -16,6 +16,7 @@ import { Pool } from '../@types/schema' import { BPool, FixedRateExchange, Dispenser } from '../@types/templates' import { addPool, getOPC, getTemplates } from './utils/globalUtils' import { weiToDecimal } from './utils/generic' +import { getToken } from './utils/tokenUtils' export function handleNewPool(event: NewPool): void { BPool.create(event.params.poolAddress) @@ -74,8 +75,11 @@ export function handleTokenAdded(event: TokenAdded): void { let existingTokens: string[] if (!opc.approvedTokens) existingTokens = [] else existingTokens = opc.approvedTokens as string[] - if (!existingTokens.includes(event.params.token.toHexString())) - existingTokens.push(event.params.token.toHexString()) + if (!existingTokens.includes(event.params.token.toHexString())) { + const newToken = getToken(event.params.token, false) + existingTokens.push(newToken.id) + } + opc.approvedTokens = existingTokens opc.save()