From aaa3b82c4754390389f3909e85054ed42dedb67f Mon Sep 17 00:00:00 2001 From: Michael Wang <44713145+mzywang@users.noreply.github.com> Date: Wed, 24 Apr 2024 18:23:17 -0400 Subject: [PATCH] update network to celo --- schema.graphql | 4 +-- src/mappings/pool/initialize.ts | 8 +++--- src/utils/constants.ts | 2 +- src/utils/pricing.ts | 48 ++++++++++++++------------------- subgraph.yaml | 8 +++--- 5 files changed, 31 insertions(+), 39 deletions(-) diff --git a/schema.graphql b/schema.graphql index b28ec770..ff906b15 100644 --- a/schema.graphql +++ b/schema.graphql @@ -31,7 +31,7 @@ type Factory @entity { # stores for USD calculations type Bundle @entity { id: ID! - # todo: update this to nativePriceUSD because avax is native asset + # todo: update this to nativePriceUSD because celo is native asset # price of ETH in usd ethPriceUSD: BigDecimal! } @@ -66,7 +66,7 @@ type Token @entity { # TVL derived in USD untracked totalValueLockedUSDUntracked: BigDecimal! # derived price in ETH - # todo: update this to derivedNative because avax is native asset + # todo: update this to derivedNative because celo is native asset derivedETH: BigDecimal! # pools token is in that are white listed for USD pricing whitelistPools: [Pool!]! diff --git a/src/mappings/pool/initialize.ts b/src/mappings/pool/initialize.ts index 2fe24065..3a56aa8f 100644 --- a/src/mappings/pool/initialize.ts +++ b/src/mappings/pool/initialize.ts @@ -4,13 +4,13 @@ import { Bundle, Pool, Token } from '../../types/schema' import { Initialize } from '../../types/templates/Pool/Pool' import { updatePoolDayData, updatePoolHourData } from '../../utils/intervalUpdates' import { + CELO_NATIVE_ADDRESS, + CUSD_CELO_POOL_ADDRESS, findEthPerToken, getEthPriceInUSD, MINIMUM_ETH_LOCKED, STABLE_COINS, STABLECOIN_IS_TOKEN0, - WAVAX_ADDRESS, - WAVAX_USDC_05_POOL, } from '../../utils/pricing' export function handleInitialize(event: Initialize): void { @@ -19,9 +19,9 @@ export function handleInitialize(event: Initialize): void { export function handleInitializeHelper( event: Initialize, - stablecoinWrappedNativePoolAddress: string = WAVAX_USDC_05_POOL, + stablecoinWrappedNativePoolAddress: string = CUSD_CELO_POOL_ADDRESS, stablecoinIsToken0: boolean = STABLECOIN_IS_TOKEN0, - wrappedNativeAddress: string = WAVAX_ADDRESS, + wrappedNativeAddress: string = CELO_NATIVE_ADDRESS, stablecoinAddresses: string[] = STABLE_COINS, minimumEthLocked: BigDecimal = MINIMUM_ETH_LOCKED, ): void { diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 1b830e49..57e3b602 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -3,7 +3,7 @@ import { Address, BigDecimal, BigInt } from '@graphprotocol/graph-ts' import { Factory as FactoryContract } from '../types/templates/Pool/Factory' export const ADDRESS_ZERO = '0x0000000000000000000000000000000000000000' -export const FACTORY_ADDRESS = '0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD' +export const FACTORY_ADDRESS = '0xAfE208a311B21f13EF87E33A90049fC17A7acDEc' export const ZERO_BI = BigInt.fromI32(0) export const ONE_BI = BigInt.fromI32(1) diff --git a/src/utils/pricing.ts b/src/utils/pricing.ts index a48081d2..1fbc9cc8 100644 --- a/src/utils/pricing.ts +++ b/src/utils/pricing.ts @@ -4,40 +4,32 @@ import { exponentToBigDecimal, safeDiv } from '../utils/index' import { Bundle, Pool, Token } from './../types/schema' import { ONE_BD, ZERO_BD, ZERO_BI } from './constants' -export const WAVAX_ADDRESS = '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7' -export const WAVAX_USDC_05_POOL = '0xfae3f424a0a47706811521e3ee268f00cfb5c45e' +export const CELO_NATIVE_ADDRESS = '0x471ece3750da237f93b8e339c536989b8978a438' +export const CUSD_CELO_POOL_ADDRESS = '0x2d70cbabf4d8e61d5317b62cbe912935fd94e0fe' export const STABLECOIN_IS_TOKEN0 = false -const DAI_E_ADDRESS = '0xd586e7f844cea2f87f50152665bcbc2c279d8d70' -const DAI_ADDRESS = '0xba7deebbfc5fa1100fb055a87773e1e99cd3507a' -const USDC_E_ADDRESS = '0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664' -const USDC_ADDRESS = '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e' -const USDT_E_ADDRESS = '0xc7198437980c041c805a1edcba50c1ce5db95118' -const USDT_ADDRESS = '0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7' +const CUSD_ADDRESS = '0x765de816845861e75a25fca122bb6898b8b1282a' +const BRIDGED_USDC_ADDRESS = '0xef4229c8c3250c675f21bcefa42f58efbff6002a' +const NATIVE_USDC_ADDRESS = '0xceba9300f2b948710d2653dd7b07f33a8b32118c' // token where amounts should contribute to tracked volume and liquidity -// usually tokens that many tokens are paired with s +// usually tokens that many tokens are paired with export const WHITELIST_TOKENS: string[] = [ - WAVAX_ADDRESS, - DAI_E_ADDRESS, - DAI_ADDRESS, - USDC_E_ADDRESS, - USDC_ADDRESS, - USDT_E_ADDRESS, - USDT_ADDRESS, - '0x130966628846bfd36ff31a822705796e8cb8c18d', // mim + CELO_NATIVE_ADDRESS, + CUSD_ADDRESS, + BRIDGED_USDC_ADDRESS, + NATIVE_USDC_ADDRESS, + '0xd8763cba276a3738e6de85b4b3bf5fded6d6ca73', // CEUR + '0xe8537a3d056da446677b9e9d6c5db704eaab4787', // CREAL + '0x46c9757c5497c5b1f2eb73ae79b6b67d119b0b58', // PACT + '0x17700282592d6917f6a73d0bf8accf4d578c131e', // MOO + '0x66803fb87abd4aac3cbb3fad7c3aa01f6f3fb207', // Portal Eth + '0xbaab46e28388d2779e6e31fd00cf0e5ad95e327b', // WBTC ] -export const STABLE_COINS: string[] = [ - DAI_E_ADDRESS, - DAI_ADDRESS, - USDC_E_ADDRESS, - USDC_ADDRESS, - USDT_E_ADDRESS, - USDT_ADDRESS, -] +export const STABLE_COINS: string[] = [CUSD_ADDRESS, BRIDGED_USDC_ADDRESS, NATIVE_USDC_ADDRESS] -export const MINIMUM_ETH_LOCKED = BigDecimal.fromString('1000') +export const MINIMUM_ETH_LOCKED = BigDecimal.fromString('3600') const Q192 = BigInt.fromI32(2).pow(192 as u8) export function sqrtPriceX96ToTokenPrices(sqrtPriceX96: BigInt, token0: Token, token1: Token): BigDecimal[] { @@ -53,7 +45,7 @@ export function sqrtPriceX96ToTokenPrices(sqrtPriceX96: BigInt, token0: Token, t } export function getEthPriceInUSD( - stablecoinWrappedNativePoolAddress: string = WAVAX_USDC_05_POOL, + stablecoinWrappedNativePoolAddress: string = CUSD_CELO_POOL_ADDRESS, stablecoinIsToken0: boolean = STABLECOIN_IS_TOKEN0, // true is stablecoin is token0, false if stablecoin is token1 ): BigDecimal { const stablecoinWrappedNativePool = Pool.load(stablecoinWrappedNativePoolAddress) @@ -70,7 +62,7 @@ export function getEthPriceInUSD( **/ export function findEthPerToken( token: Token, - wrappedNativeAddress: string = WAVAX_ADDRESS, + wrappedNativeAddress: string = CELO_NATIVE_ADDRESS, stablecoinAddresses: string[] = STABLE_COINS, minimumEthLocked: BigDecimal = MINIMUM_ETH_LOCKED, ): BigDecimal { diff --git a/subgraph.yaml b/subgraph.yaml index f0817b74..740dd4c4 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -9,11 +9,11 @@ features: dataSources: - kind: ethereum/contract name: Factory - network: avalanche + network: celo source: - address: '0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD' + address: '0xAfE208a311B21f13EF87E33A90049fC17A7acDEc' abi: Factory - startBlock: 27832971 + startBlock: 13916355 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -39,7 +39,7 @@ dataSources: templates: - kind: ethereum/contract name: Pool - network: avalanche + network: celo source: abi: Pool mapping: