Skip to content

Commit

Permalink
update network to arbitrum-one
Browse files Browse the repository at this point in the history
  • Loading branch information
mzywang committed May 30, 2024
1 parent 8c3ff64 commit a902eb5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/mappings/pool/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
MINIMUM_ETH_LOCKED,
STABLE_COINS,
STABLECOIN_IS_TOKEN0,
USDC_WETH_05_POOL,
USDC_WETH_03_POOL,
WETH_ADDRESS,
} from '../../utils/pricing'

Expand All @@ -19,7 +19,7 @@ export function handleInitialize(event: Initialize): void {

export function handleInitializeHelper(
event: Initialize,
stablecoinWrappedNativePoolAddress: string = USDC_WETH_05_POOL,
stablecoinWrappedNativePoolAddress: string = USDC_WETH_03_POOL,
stablecoinIsToken0: boolean = STABLECOIN_IS_TOKEN0,
wrappedNativeAddress: string = WETH_ADDRESS,
stablecoinAddresses: string[] = STABLE_COINS,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '0x33128a8fC17869897dcE68Ed026d694621f6FDfD'
export const FACTORY_ADDRESS = '0x1F98431c8aD98523631AE4a59f267346ea31F984'

export const ZERO_BI = BigInt.fromI32(0)
export const ONE_BI = BigInt.fromI32(1)
Expand Down
21 changes: 13 additions & 8 deletions src/utils/pricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,37 @@ import { exponentToBigDecimal, safeDiv } from '../utils/index'
import { Bundle, Pool, Token } from './../types/schema'
import { ONE_BD, ZERO_BD, ZERO_BI } from './constants'

export const WETH_ADDRESS = '0x4200000000000000000000000000000000000006'
export const USDC_WETH_05_POOL = '0x4c36388be6f416a29c8d8eee81c771ce6be14b18'
export const WETH_ADDRESS = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1'
export const USDC_WETH_03_POOL = '0x17c14d2c404d167802b16c450d3c99f88f2c4f4d'
export const STABLECOIN_IS_TOKEN0 = false

const USDC_ADDRESS = '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913'
const USDC_ADDRESS = '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8'
const DAI_ADDRESS = '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1'
const USDT_ADDRESS = '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9'

// token where amounts should contribute to tracked volume and liquidity
// usually tokens that many tokens are paired with s
export const WHITELIST_TOKENS: string[] = [WETH_ADDRESS, USDC_ADDRESS]
export const WHITELIST_TOKENS: string[] = [WETH_ADDRESS, USDC_ADDRESS, DAI_ADDRESS, USDT_ADDRESS]

export const STABLE_COINS: string[] = [USDC_ADDRESS]
export const STABLE_COINS: string[] = [USDC_ADDRESS, DAI_ADDRESS, USDT_ADDRESS]

export const MINIMUM_ETH_LOCKED = BigDecimal.fromString('1')
export const MINIMUM_ETH_LOCKED = BigDecimal.fromString('60')

const Q192 = BigInt.fromI32(2).pow(192 as u8)
export function sqrtPriceX96ToTokenPrices(sqrtPriceX96: BigInt, token0: Token, token1: Token): BigDecimal[] {
const num = sqrtPriceX96.times(sqrtPriceX96).toBigDecimal()
const denom = BigDecimal.fromString(Q192.toString())
const price1 = num.div(denom).times(exponentToBigDecimal(token0.decimals)).div(exponentToBigDecimal(token1.decimals))
const price1 = num
.div(denom)
.times(exponentToBigDecimal(token0.decimals))
.div(exponentToBigDecimal(token1.decimals))

const price0 = safeDiv(BigDecimal.fromString('1'), price1)
return [price0, price1]
}

export function getEthPriceInUSD(
stablecoinWrappedNativePoolAddress: string = USDC_WETH_05_POOL,
stablecoinWrappedNativePoolAddress: string = USDC_WETH_03_POOL,
stablecoinIsToken0: boolean = STABLECOIN_IS_TOKEN0, // true is stablecoin is token0, false if stablecoin is token1
): BigDecimal {
const stablecoinWrappedNativePool = Pool.load(stablecoinWrappedNativePoolAddress)
Expand Down
15 changes: 14 additions & 1 deletion src/utils/staticTokenDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,17 @@ export const getStaticDefinition = (
return null
}

export const STATIC_TOKEN_DEFINITIONS: Array<StaticTokenDefinition> = []
export const STATIC_TOKEN_DEFINITIONS: Array<StaticTokenDefinition> = [
{
address: Address.fromString('0x82af49447d8a07e3bd95bd0d56f35241523fbab1'),
symbol: 'WETH',
name: 'Wrapped Ethereum',
decimals: BigInt.fromI32(18)
},
{
address: Address.fromString('0xff970a61a04b1ca14834a43f5de4533ebddb5cc8'),
symbol: 'USDC',
name: 'USD Coin',
decimals: BigInt.fromI32(6)
}
]
8 changes: 4 additions & 4 deletions subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ features:
dataSources:
- kind: ethereum/contract
name: Factory
network: base
network: arbitrum-one
source:
address: '0x33128a8fC17869897dcE68Ed026d694621f6FDfD'
address: '0x1F98431c8aD98523631AE4a59f267346ea31F984'
abi: Factory
startBlock: 2009445
startBlock: 165
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand All @@ -39,7 +39,7 @@ dataSources:
templates:
- kind: ethereum/contract
name: Pool
network: base
network: arbitrum-one
source:
abi: Pool
mapping:
Expand Down

0 comments on commit a902eb5

Please sign in to comment.