Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

promote dev to prod #482

Merged
merged 24 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b91abbc
feat: add fxOracleDecimals prop to Token entity
schystz May 31, 2023
99b9da6
feat: replaced hardcoded decimals with fxOracleDecimals
schystz May 31, 2023
71a9151
feat: 8 as default FX oracle decimals instead of 0
schystz Jun 2, 2023
8e428a6
feat: hardcode fxOracleDecimals for now
schystz Jun 20, 2023
7cc78da
feat: reversal of unnecessary changes
schystz Jun 20, 2023
156f94c
Add gyroE factory for optimism
joshguha Jul 4, 2023
b9cdb42
Update GyroE Optimism factory address
joshguha Jul 4, 2023
031ca7b
improve protocol fee data
mendesfabio Jul 4, 2023
2444698
Merge pull request #472 from gyrostable/gyro-e-optimism
mendesfabio Jul 4, 2023
ae799fc
Merge pull request #462 from xave-finance/fxpool-oracle-decimals
mendesfabio Jul 4, 2023
102d2eb
Merge pull request #474 from balancer/improve-protocol-fee
mendesfabio Jul 4, 2023
c439a01
add last join exit amp
mendesfabio Jul 4, 2023
fb66870
Merge pull request #475 from balancer/add-last-join-exit-amp
mendesfabio Jul 4, 2023
14a0e4d
update arb and poly graft params
mendesfabio Jul 4, 2023
ec6169f
Merge pull request #473 from balancer/staging-dev
mendesfabio Jul 4, 2023
f182bc2
fix vault protocol fee
mendesfabio Jul 5, 2023
7861259
Merge pull request #476 from balancer/fix-vault-protocol-fee
mendesfabio Jul 5, 2023
0d887cf
fix fx oracle decimals
mendesfabio Jul 7, 2023
5702d69
Merge pull request #478 from balancer/fix-fx-oracle
mendesfabio Jul 7, 2023
d207251
support composable v5
mendesfabio Jul 7, 2023
cfb29a2
Merge pull request #477 from balancer/composable-v5
mendesfabio Jul 7, 2023
9383124
update arb and poly graft params
mendesfabio Jul 7, 2023
2615932
Merge pull request #479 from balancer/staging-dev
mendesfabio Jul 7, 2023
06ef2db
comment out polygon prod actions
mendesfabio Jul 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 46 additions & 46 deletions .github/workflows/graph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,52 +51,52 @@ jobs:
graph_subgraph_name: "balancer-v2"
graph_account: "balancer-labs"
graph_config_file: "subgraph.yaml"
deploy-polygon:
runs-on: ubuntu-latest
environment: graph
steps:
- uses: actions/checkout@v2
- name: Install node
uses: actions/setup-node@v1
with:
node-version: 16
- name: Install
run: yarn --frozen-lockfile
- name: Assets
run: yarn generate-assets polygon
- name: Codegen
run: yarn codegen
- name: Build
run: yarn build
- uses: balancer-labs/[email protected]
with:
graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}}
graph_subgraph_name: "balancer-polygon-v2"
graph_account: "balancer-labs"
graph_config_file: "subgraph.polygon.yaml"
deploy-polygon-pruned:
runs-on: ubuntu-latest
environment: graph
steps:
- uses: actions/checkout@v2
- name: Install node
uses: actions/setup-node@v1
with:
node-version: 16
- name: Install
run: yarn --frozen-lockfile
- name: Assets
run: yarn generate-assets polygon-prune
- name: Codegen
run: yarn codegen
- name: Build
run: yarn build
- uses: balancer-labs/[email protected]
with:
graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}}
graph_subgraph_name: "balancer-polygon-prune-v2"
graph_account: "balancer-labs"
graph_config_file: "subgraph.polygon.yaml"
# deploy-polygon:
# runs-on: ubuntu-latest
# environment: graph
# steps:
# - uses: actions/checkout@v2
# - name: Install node
# uses: actions/setup-node@v1
# with:
# node-version: 16
# - name: Install
# run: yarn --frozen-lockfile
# - name: Assets
# run: yarn generate-assets polygon
# - name: Codegen
# run: yarn codegen
# - name: Build
# run: yarn build
# - uses: balancer-labs/[email protected]
# with:
# graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}}
# graph_subgraph_name: "balancer-polygon-v2"
# graph_account: "balancer-labs"
# graph_config_file: "subgraph.polygon.yaml"
# deploy-polygon-pruned:
# runs-on: ubuntu-latest
# environment: graph
# steps:
# - uses: actions/checkout@v2
# - name: Install node
# uses: actions/setup-node@v1
# with:
# node-version: 16
# - name: Install
# run: yarn --frozen-lockfile
# - name: Assets
# run: yarn generate-assets polygon-prune
# - name: Codegen
# run: yarn codegen
# - name: Build
# run: yarn build
# - uses: balancer-labs/[email protected]
# with:
# graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}}
# graph_subgraph_name: "balancer-polygon-prune-v2"
# graph_account: "balancer-labs"
# graph_config_file: "subgraph.polygon.yaml"
deploy-arbitrum:
runs-on: ubuntu-latest
environment: graph
Expand Down
33 changes: 33 additions & 0 deletions manifest.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,39 @@ dataSources:
- event: PoolCreated(indexed address)
handler: handleNewComposableStablePoolV4
{{/if}}
{{#if ComposableStablePoolV5Factory}}
- kind: ethereum/contract
name: ComposableStablePoolV5Factory
network: {{network}}
source:
address: '{{ComposableStablePoolV5Factory.address}}'
abi: ComposableStablePoolV2Factory
startBlock: {{ComposableStablePoolV5Factory.startBlock}}
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
file: ./src/mappings/poolFactory.ts
entities:
- Balancer
- Pool
abis:
- name: Vault
file: ./abis/Vault.json
- name: ERC20
file: ./abis/ERC20.json
- name: WeightedPool
file: ./abis/WeightedPool.json
- name: ComposableStablePoolV2Factory
file: ./abis/ComposableStablePoolV2Factory.json
- name: ComposableStablePool
file: ./abis/ComposableStablePool.json
- name: StablePool
file: ./abis/StablePool.json
eventHandlers:
- event: PoolCreated(indexed address)
handler: handleNewComposableStablePoolV5
{{/if}}
{{#if HighAmpComposableStablePoolFactory}}
- kind: ethereum/contract
name: HighAmpComposableStablePoolFactory
Expand Down
42 changes: 36 additions & 6 deletions networks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ mainnet:
ComposableStablePoolV4Factory:
address: "0xfADa0f4547AB2de89D1304A668C39B3E09Aa7c76"
startBlock: 16878679
ComposableStablePoolV5Factory:
address: "0xDB8d758BCb971e482B2C45f7F8a7740283A1bd3A"
startBlock: 17643198
HighAmpComposableStablePoolFactory:
address: "0xBa1b4a90bAD57470a2cbA762A32955dC491f76e0"
startBlock: 15852258
Expand Down Expand Up @@ -161,6 +164,9 @@ goerli:
ComposableStablePoolV4Factory:
address: "0x1802953277FD955f9a254B80Aa0582f193cF1d77"
startBlock: 8695012
ComposableStablePoolV5Factory:
address: "0x4bdCc2fb18AEb9e2d281b0278D946445070EAda7"
startBlock: 9306452
HighAmpComposableStablePoolFactory:
address: "0x35802d6f8fe133215E1804EB70748fe39F10F318"
startBlock: 7842251
Expand Down Expand Up @@ -212,11 +218,11 @@ goerli:
polygon:
network: matic
graft:
# Apr 13 - block before a mock ManagedPool was created
block: 41501266
# Jul 7
block: 44780000
# always make sure the base subgraph has not been pruned
# it should be possible to run time travel queries on it going back to the vault's startBlock
base: QmPRLQvJ1qwoVZcpRHRbRgMzf5wq5gE5hrnyj8AtTbhYRU
base: QmegAtzM2Lv1tbJaaHrh3SgKDK9K3CcjtqbLsKUAHzdtdB
EventEmitter:
address: "0xcdcECFa416EE3022030E707dC3EA13a8997D74c8"
startBlock: 38152461
Expand Down Expand Up @@ -256,6 +262,9 @@ polygon:
ComposableStablePoolV4Factory:
address: "0x6Ab5549bBd766A43aFb687776ad8466F8b42f777"
startBlock: 40613553
ComposableStablePoolV5Factory:
address: "0xe2fa4e1d17725e72dcdAfe943Ecf45dF4B9E285b"
startBlock: 44798194
MetaStablePoolFactory:
address: "0xdAE7e32ADc5d490a43cCba1f0c736033F2b4eFca"
startBlock: 17913016
Expand Down Expand Up @@ -328,11 +337,11 @@ polygon:
arbitrum:
network: arbitrum-one
graft:
# Apr 13 - block before a mock ManagedPool was created
block: 80173696
# Jul 7
block: 108700000
# always make sure the base subgraph has not been pruned
# it should be possible to run time travel queries on it going back to the vault's startBlock
base: QmYrKwmsXkL65NxGQX6rj3c6XdJSVwN3YdhHw77F7ZTkGJ
base: QmSoXwL7Y9tfrALTRGjkfwPAbLraxr8WZL8TLNYUSHsLYp
EventEmitter:
address: "0x8f32D631093B5418d0546f77442c5fa66187E59D"
startBlock: 53475240
Expand Down Expand Up @@ -372,6 +381,9 @@ arbitrum:
ComposableStablePoolV4Factory:
address: "0x2498A2B0d6462d2260EAC50aE1C3e03F4829BA95"
startBlock: 72235860
ComposableStablePoolV5Factory:
address: "0xA8920455934Da4D853faac1f94Fe7bEf72943eF1"
startBlock: 108834057
MetaStablePoolFactory:
address: "0xEBFD5681977E38Af65A7487DC70B8221D089cCAD"
startBlock: 222868
Expand Down Expand Up @@ -484,6 +496,9 @@ gnosis:
ComposableStablePoolV4Factory:
address: "0xD87F44Df0159DC78029AB9CA7D7e57E7249F5ACD"
startBlock: 27056416
ComposableStablePoolV5Factory:
address: "0x4bdCc2fb18AEb9e2d281b0278D946445070EAda7"
startBlock: 28832248
AaveLinearPoolV3Factory:
address: "0x9dd5Db2d38b50bEF682cE532bCca5DfD203915E1"
startBlock: 25415464
Expand Down Expand Up @@ -537,6 +552,9 @@ optimism:
ComposableStablePoolV4Factory:
address: "0x1802953277FD955f9a254B80Aa0582f193cF1d77"
startBlock: 82748180
ComposableStablePoolV5Factory:
address: "0x043A2daD730d585C44FB79D2614F295D2d625412"
startBlock: 106574795
MetaStablePoolFactory:
address: "0xb08E16cFc07C684dAA2f93C70323BAdb2A6CBFd2"
startBlock: 7005662
Expand Down Expand Up @@ -585,6 +603,9 @@ optimism:
ProtocolIdRegistry:
address: "0x9805dcfD25e6De36bad8fe9D3Fe2c9b44B764102"
startBlock: 77557576
GyroEPoolFactory:
address: "0xefdE1c764Df6522a068b38106563DE166Ac97f58"
startBlock: 97252407
avalanche:
network: avalanche
Vault:
Expand All @@ -593,6 +614,9 @@ avalanche:
ComposableStablePoolV4Factory:
address: "0x3B1eb8EB7b43882b385aB30533D9A2BeF9052a98"
startBlock: 29221425
ComposableStablePoolV5Factory:
address: "0xE42FFA682A26EF8F25891db4882932711D42e467"
startBlock: 32301646
WeightedPoolV3Factory:
address: "0x94f68b54191F62f781Fe8298A8A5Fa3ed772d227"
startBlock: 26389236
Expand Down Expand Up @@ -633,6 +657,9 @@ sepolia:
ComposableStablePoolV4Factory:
address: "0xA3fd20E29358c056B727657E83DFd139abBC9924"
startBlock: 3425277
ComposableStablePoolV5Factory:
address: "0xa523f47A933D5020b23629dDf689695AA94612Dc"
startBlock: 3844648
AaveLinearPoolV5Factory:
address: "0xDF9B5B00Ef9bca66e9902Bd813dB14e4343Be025"
startBlock: 3421724
Expand Down Expand Up @@ -668,6 +695,9 @@ polygon-zkevm:
ComposableStablePoolV4Factory:
address: "0x8eA89804145c007e7D226001A96955ad53836087"
startBlock: 220016
ComposableStablePoolV5Factory:
address: "0x956CCab09898C0AF2aCa5e6C229c3aD4E93d9288"
startBlock: 2157318
AaveLinearPoolV5Factory:
address: "0x4b7b369989e613ff2C65768B7Cf930cC927F901E"
startBlock: 220075
Expand Down
6 changes: 5 additions & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ type Balancer @entity {
totalSwapCount: BigInt!
totalSwapVolume: BigDecimal!
totalSwapFee: BigDecimal!

totalProtocolFee: BigDecimal # TODO: make mandatory at next full sync

protocolFeesCollector: Bytes # TODO: make mandatory at next full sync
}

Expand Down Expand Up @@ -116,6 +117,7 @@ type Pool @entity {
totalProtocolFeePaidInBPT: BigDecimal

# Composable Stable Only
lastJoinExitAmp: BigInt
lastPostJoinExitInvariant: BigDecimal

# AaveLinearV3 Only
Expand Down Expand Up @@ -337,6 +339,7 @@ type Token @entity {
latestUSDPriceTimestamp: BigInt # timestamp at which the latestUSDPrice was updated
latestFXPrice: BigDecimal # latest "off-chain" price of token in USD, only available if token has an offchain price aggregator
pool: Pool # pool entity associated with the token, if it is a Balancer pool
fxOracleDecimals: Int # only available if token has an FX oracle
}

type TokenSnapshot @entity {
Expand Down Expand Up @@ -376,6 +379,7 @@ type BalancerSnapshot @entity {
totalSwapCount: BigInt!
totalSwapVolume: BigDecimal!
totalSwapFee: BigDecimal!
totalProtocolFee: BigDecimal # TODO: make mandatory at next full sync
}

type ProtocolIdData @entity {
Expand Down
9 changes: 8 additions & 1 deletion src/mappings/helpers/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { ERC20 } from '../../types/Vault/ERC20';
import { WeightedPool } from '../../types/Vault/WeightedPool';
import { Swap as SwapEvent, Vault } from '../../types/Vault/Vault';
import { ONE_BD, SWAP_IN, SWAP_OUT, VAULT_ADDRESS, ZERO, ZERO_ADDRESS, ZERO_BD } from './constants';
import { ONE_BD, SWAP_IN, SWAP_OUT, VAULT_ADDRESS, ZERO, ZERO_ADDRESS, ZERO_BD, FX_TOKEN_ADDRESSES } from './constants';
import { PoolType, getPoolAddress, isComposableStablePool } from './pools';
import { ComposableStablePool } from '../../types/ComposableStablePoolFactory/ComposableStablePool';
import { valueInUSD } from '../pricing';
Expand Down Expand Up @@ -299,6 +299,12 @@ export function createToken(tokenAddress: Address): Token {
token.pool = poolId.toHexString();
}

// assign oracle decimals for FX tokens
let tokenIndex = FX_TOKEN_ADDRESSES.indexOf(tokenAddress);
if (tokenIndex >= 0) {
token.fxOracleDecimals = 8; // @TODO: get decimals on-chain
}

token.name = name;
token.symbol = symbol;
token.decimals = decimals;
Expand Down Expand Up @@ -440,6 +446,7 @@ export function getBalancerSnapshot(vaultId: string, timestamp: i32): BalancerSn
snapshot.totalSwapFee = vault.totalSwapFee;
snapshot.totalSwapVolume = vault.totalSwapVolume;
snapshot.totalSwapCount = vault.totalSwapCount;
snapshot.totalProtocolFee = vault.totalProtocolFee;
snapshot.vault = vaultId;
snapshot.timestamp = dayStartTimestamp;
snapshot.save();
Expand Down
21 changes: 18 additions & 3 deletions src/mappings/poolController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
getProtocolFeeCollector,
createPoolSnapshot,
hexToBigInt,
getBalancerSnapshot,
} from './helpers/misc';
import { ONE_BD, ProtocolFeeType, ZERO_ADDRESS, ZERO_BD } from './helpers/constants';
import { updateAmpFactor } from './helpers/stable';
Expand Down Expand Up @@ -615,12 +616,26 @@ export function handleTransfer(event: Transfer): void {
}

if (protocolFeeCollector && poolShareTo.userAddress == protocolFeeCollector.toHex()) {
let protocolFeePaid = pool.totalProtocolFeePaidInBPT ? pool.totalProtocolFeePaidInBPT : ZERO_BD;
let protocolFeePaid = tokenToDecimal(event.params.value, BPT_DECIMALS);
let totalProtocolFee = pool.totalProtocolFeePaidInBPT ? pool.totalProtocolFeePaidInBPT : ZERO_BD;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
pool.totalProtocolFeePaidInBPT = protocolFeePaid!.plus(tokenToDecimal(event.params.value, BPT_DECIMALS));
pool.totalProtocolFeePaidInBPT = totalProtocolFee!.plus(protocolFeePaid);

let protocolFeeUSD = valueInUSD(protocolFeePaid, poolAddress);
let totalProtocolFeeUSD = pool.totalProtocolFee ? pool.totalProtocolFee : ZERO_BD;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
pool.totalProtocolFee = valueInUSD(pool.totalProtocolFeePaidInBPT!, poolAddress);
pool.totalProtocolFee = totalProtocolFeeUSD!.plus(protocolFeeUSD);

// create or update pool's snapshot
createPoolSnapshot(pool, event.block.timestamp.toI32());

let vault = Balancer.load('2') as Balancer;
let vaultProtocolFee = vault.totalProtocolFee ? vault.totalProtocolFee : ZERO_BD;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
vault.totalProtocolFee = vaultProtocolFee!.plus(protocolFeeUSD);
vault.save();
// create or update balancer's vault snapshot
getBalancerSnapshot(vault.id, event.block.timestamp.toI32());
}
} else if (isBurn) {
poolShareFrom.balance = poolShareFrom.balance.minus(tokenToDecimal(event.params.value, BPT_DECIMALS));
Expand Down
6 changes: 6 additions & 0 deletions src/mappings/poolFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ export function handleNewComposableStablePoolV4(event: PoolCreated): void {
StablePhantomPoolV2Template.create(event.params.pool);
}

export function handleNewComposableStablePoolV5(event: PoolCreated): void {
const pool = createStableLikePool(event, PoolType.ComposableStable, 5);
if (pool == null) return;
StablePhantomPoolV2Template.create(event.params.pool);
}

export function handleNewHighAmpComposableStablePool(event: PoolCreated): void {
const pool = createStableLikePool(event, PoolType.HighAmpComposableStable);
if (pool == null) return;
Expand Down
5 changes: 5 additions & 0 deletions src/mappings/pricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ export function handleAnswerUpdated(event: AnswerUpdated): void {
return;
}

// All tokens we track have oracles with 8 decimals
if (token.fxOracleDecimals == null) {
token.fxOracleDecimals = 8;
}

let rate = scaleDown(event.params.current, 8);
token.latestFXPrice = rate;
token.save();
Expand Down
Loading
Loading