Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/curve-finance' into feat/cu…
Browse files Browse the repository at this point in the history
…rve-finance
  • Loading branch information
fishTsai20 committed Jul 1, 2024
2 parents 5914d91 + 574d382 commit dcc4354
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion deployment/deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@
"status": "prod",
"versions": {
"schema": "1.3.0",
"subgraph": "1.1.4",
"subgraph": "1.2.0",
"methodology": "1.0.0"
},
"files": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ dataSources:
handler: handleNewGauge
- event: RewardsOnlyGaugeCreated(indexed address,indexed address,address)
handler: handleRewardsOnlyGaugeCreated
file: ./src/mappings/GaugeControllerMappings.ts
file: ./src/mappings/gaugeControllerMappings.ts
{{#usesBalancerTokenAdmin}}
- kind: ethereum/contract
name: BalancerTokenAdmin
Expand Down
2 changes: 1 addition & 1 deletion subgraphs/balancer-forks/src/common/initializers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ export function getOrCreateLiquidityPool(
);
pool._poolId = poolId.toHexString();

const inputTokensInfo = utils.getPoolTokensInfo(poolId);
const inputTokensInfo = utils.getPoolTokensInfo(poolAddress, poolId);
pool.inputTokens = inputTokensInfo.getInputTokens;
pool.inputTokenBalances = inputTokensInfo.getBalances;
pool.inputTokenWeights = utils.getPoolTokenWeights(
Expand Down
12 changes: 11 additions & 1 deletion subgraphs/balancer-forks/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,16 @@ export class PoolFeesType {
}

export class PoolTokensType {
private _poolAddress: Address;
private _tokens: Address[];
private _balances: BigInt[];

constructor(tokens: Address[] = [], balances: BigInt[] = []) {
constructor(
poolAddress: Address = constants.NULL.TYPE_ADDRESS,
tokens: Address[] = [],
balances: BigInt[] = []
) {
this._poolAddress = poolAddress;
this._tokens = tokens;
this._balances = balances;
}
Expand All @@ -78,6 +84,10 @@ export class PoolTokensType {
const inputTokens: string[] = [];

for (let idx = 0; idx < this._tokens.length; idx++) {
if (this._tokens.at(idx) == this._poolAddress) {
continue;
}

inputTokens.push(this._tokens.at(idx).toHexString());
}

Expand Down
12 changes: 10 additions & 2 deletions subgraphs/balancer-forks/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@ export function getTokenDecimals(tokenAddr: Address): BigDecimal {
return constants.BIGINT_TEN.pow(decimals.toI32() as u8).toBigDecimal();
}

export function getPoolTokensInfo(poolId: Bytes): PoolTokensType {
export function getPoolTokensInfo(
poolAddress: Address,
poolId: Bytes
): PoolTokensType {
const vaultContract = VaultContract.bind(constants.VAULT_ADDRESS);

const poolTokens = vaultContract.try_getPoolTokens(poolId);
if (poolTokens.reverted) return new PoolTokensType();

return new PoolTokensType(
poolAddress,
poolTokens.value.getTokens(),
poolTokens.value.getBalances()
);
Expand Down Expand Up @@ -99,7 +103,7 @@ export function getPoolInputTokenBalances(
poolId: Bytes
): BigInt[] {
const poolContract = WeightedPoolContract.bind(poolAddress);
const poolTokensInfo = getPoolTokensInfo(poolId);
const poolTokensInfo = getPoolTokensInfo(poolAddress, poolId);

const poolBalances = poolTokensInfo.getBalances;

Expand Down Expand Up @@ -229,6 +233,10 @@ export function getPoolTVL(
): BigDecimal {
let totalValueLockedUSD = constants.BIGDECIMAL_ZERO;

if (inputTokens.length != inputTokenBalances.length) {
return totalValueLockedUSD;
}

for (let idx = 0; idx < inputTokens.length; idx++) {
const inputTokenBalance = inputTokenBalances[idx];

Expand Down
2 changes: 1 addition & 1 deletion subgraphs/balancer-forks/src/modules/Rewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as constants from "../common/constants";
import { RewardsInfoType } from "../common/types";
import { getRewardsPerDay } from "../common/rewards";
import { log, BigInt, Address, ethereum } from "@graphprotocol/graph-ts";
import { Gauge as LiquidityGaugeContract } from "../../generated/templates/gauge/Gauge";
import { Gauge as LiquidityGaugeContract } from "../../generated/templates/Gauge/Gauge";
import { GaugeController as GaugeControllereContract } from "../../generated/GaugeController/GaugeController";

export function getRewardsData(gaugeAddress: Address): RewardsInfoType {
Expand Down

0 comments on commit dcc4354

Please sign in to comment.