Skip to content

Commit

Permalink
pricing
Browse files Browse the repository at this point in the history
  • Loading branch information
mzywang committed Dec 9, 2024
1 parent 802e1f8 commit 556b730
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/mappings/pair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export function handleMint(event: Mint): void {
mint.amount1 = token1Amount as BigDecimal
mint.save()

pair.reserve0 = pair.reserve0.plus(token0Amount)
pair.reserve1 = pair.reserve1.plus(token1Amount)
pair.save()

token0.totalLiquidity = token0.totalLiquidity.plus(token0Amount)
token1.totalLiquidity = token1.totalLiquidity.plus(token1Amount)
token0.save()
Expand Down Expand Up @@ -66,6 +70,10 @@ export function handleBurn(event: Burn): void {
burn.to = event.params.to
burn.save()

pair.reserve0 = pair.reserve0.minus(token0Amount)
pair.reserve1 = pair.reserve1.minus(token1Amount)
pair.save()

token0.totalLiquidity = token0.totalLiquidity.minus(token0Amount)
token1.totalLiquidity = token1.totalLiquidity.minus(token1Amount)
token0.save()
Expand Down Expand Up @@ -100,6 +108,10 @@ export function handleSwap(event: Swap): void {
swap.to = event.params.to
swap.save()

pair.reserve0 = pair.reserve0.minus(token0AmountOut).plus(token0AmountIn)
pair.reserve1 = pair.reserve1.minus(token1AmountOut).plus(token1AmountIn)
pair.save()

token0.totalLiquidity = token0.totalLiquidity.minus(token0AmountOut).plus(token0AmountIn)
token1.totalLiquidity = token1.totalLiquidity.minus(token1AmountOut).plus(token1AmountIn)
token0.save()
Expand Down
5 changes: 5 additions & 0 deletions src/mappings/pricing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const STABLECOINS: string[] = [
'0x6b175474e89094c44da98b954eedeac495271d0f', // DAI
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', // USDC
'0xdac17f958d2ee523a2206206994597c13d831ec7', // USDT
]

0 comments on commit 556b730

Please sign in to comment.