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

feat(#minor); Curve Finance ETH; Address spike in TVL and missing volume for few pools #2526

Merged
merged 5 commits into from
Apr 22, 2024
Merged
Changes from 1 commit
Commits
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
Next Next commit
Fix bug
harsh9200 committed Apr 11, 2024
commit e80ec5a27b222fefaf6cfa1d1f6fd42dc9985aaf
39 changes: 39 additions & 0 deletions subgraphs/curve-finance/abis/Pool.json
Original file line number Diff line number Diff line change
@@ -11,6 +11,20 @@
"anonymous": false,
"type": "event"
},
{
"name": "TokenExchange",
"inputs": [
{ "name": "buyer", "type": "address", "indexed": true },
{ "name": "sold_id", "type": "uint256", "indexed": false },
{ "name": "tokens_sold", "type": "uint256", "indexed": false },
{ "name": "bought_id", "type": "uint256", "indexed": false },
{ "name": "tokens_bought", "type": "uint256", "indexed": false },
{ "name": "fee", "type": "uint256", "indexed": false },
{ "name": "packed_price_scale", "type": "uint256", "indexed": false }
],
"anonymous": false,
"type": "event"
},
{
"name": "TokenExchange",
"inputs": [
@@ -93,6 +107,18 @@
"anonymous": false,
"type": "event"
},
{
"name": "AddLiquidity",
"inputs": [
{ "name": "provider", "type": "address", "indexed": true },
{ "name": "token_amounts", "type": "uint256[3]", "indexed": false },
{ "name": "fee", "type": "uint256", "indexed": false },
{ "name": "token_supply", "type": "uint256", "indexed": false },
{ "name": "packed_price_scale", "type": "uint256", "indexed": false }
],
"anonymous": false,
"type": "event"
},
{
"name": "RemoveLiquidity",
"inputs": [
@@ -167,6 +193,19 @@
"anonymous": false,
"type": "event"
},
{
"name": "RemoveLiquidityOne",
"inputs": [
{ "name": "provider", "type": "address", "indexed": true },
{ "name": "token_amount", "type": "uint256", "indexed": false },
{ "name": "coin_index", "type": "uint256", "indexed": false },
{ "name": "coin_amount", "type": "uint256", "indexed": false },
{ "name": "approx_fee", "type": "uint256", "indexed": false },
{ "name": "packed_price_scale", "type": "uint256", "indexed": false }
],
"anonymous": false,
"type": "event"
},
{
"name": "RemoveLiquidityImbalance",
"inputs": [
5,973 changes: 3,174 additions & 2,799 deletions subgraphs/curve-finance/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions subgraphs/curve-finance/package.json
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
"build": "node ../../deployment/deployment.js --deploy=${npm_config_deploy} --token=${npm_config_token} --service=${npm_config_service} --id=${npm_config_id} --span=${npm_config_span} --target=${npm_config_target} --slug=${npm_config_slug} --printlogs=${npm_config_printlogs}"
},
"dependencies": {
"@graphprotocol/graph-cli": "^0.32.0",
"@graphprotocol/graph-ts": "^0.27.0"
"@graphprotocol/graph-cli": "^0.46.1",
"@graphprotocol/graph-ts": "^0.29.3"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
specVersion: 0.0.5
specVersion: 1.0.0
repository: https://github.com/messari/subgraphs
{{#graftEnabled}}
features:
@@ -180,13 +180,17 @@ dataSources:
handler: handleTokenExchange
- event: TokenExchange(indexed address,uint256,uint256,uint256,uint256)
handler: handleTokenExchange
- event: TokenExchange(indexed address,uint256,uint256,uint256,uint256,uint256,uint256)
handler: handleTokenExchangeWithPriceScale

- event: TokenExchangeUnderlying(indexed address,int128,uint256,int128,uint256)
handler: handleTokenExchangeUnderlying
receipt: true

- event: AddLiquidity(indexed address,uint256[3],uint256,uint256)
handler: handleAddLiquidity
- event: AddLiquidity(indexed address,uint256[3],uint256,uint256,uint256)
handler: handleAddLiquidityWithPriceScale
- event: AddLiquidity(indexed address,uint256[2],uint256[2],uint256,uint256)
handler: handleAddLiquidityWithFees
- event: AddLiquidity(indexed address,uint256[3],uint256[3],uint256,uint256)
@@ -216,6 +220,9 @@ dataSources:
- event: RemoveLiquidityOne(indexed address,uint256,uint256,uint256)
handler: handleRemoveLiquidityOneWithSupply
receipt: true
- event: RemoveLiquidityOne(indexed address,uint256,uint256,uint256,uint256,uint256)
handler: handleRemoveLiquidityOneWithPriceScale
receipt: true

- event: RemoveLiquidityImbalance(indexed address,uint256[2],uint256[2],uint256,uint256)
handler: handleRemoveLiquidityImbalance
@@ -377,13 +384,17 @@ templates:
handler: handleTokenExchange
- event: TokenExchange(indexed address,uint256,uint256,uint256,uint256)
handler: handleTokenExchange
- event: TokenExchange(indexed address,uint256,uint256,uint256,uint256,uint256,uint256)
handler: handleTokenExchangeWithPriceScale

- event: TokenExchangeUnderlying(indexed address,int128,uint256,int128,uint256)
handler: handleTokenExchangeUnderlying
receipt: true

- event: AddLiquidity(indexed address,uint256[3],uint256,uint256)
handler: handleAddLiquidity
- event: AddLiquidity(indexed address,uint256[3],uint256,uint256,uint256)
handler: handleAddLiquidityWithPriceScale
- event: AddLiquidity(indexed address,uint256[2],uint256[2],uint256,uint256)
handler: handleAddLiquidityWithFees
- event: AddLiquidity(indexed address,uint256[3],uint256[3],uint256,uint256)
@@ -413,6 +424,9 @@ templates:
- event: RemoveLiquidityOne(indexed address,uint256,uint256,uint256)
handler: handleRemoveLiquidityOneWithSupply
receipt: true
- event: RemoveLiquidityOne(indexed address,uint256,uint256,uint256,uint256,uint256)
handler: handleRemoveLiquidityOneWithPriceScale
receipt: true

- event: RemoveLiquidityImbalance(indexed address,uint256[2],uint256[2],uint256,uint256)
handler: handleRemoveLiquidityImbalance
71 changes: 71 additions & 0 deletions subgraphs/curve-finance/src/mappings/poolMappings.ts
Original file line number Diff line number Diff line change
@@ -11,8 +11,11 @@ import {
TokenExchangeUnderlying,
RemoveLiquidityImbalance,
AddLiquidity2 as AddLiquidityWithFees,
AddLiquidity5 as AddLiquidityWithPriceScale,
RemoveLiquidity2 as RemoveLiquidityWithFees,
TokenExchange1 as TokenExchangeWithPriceScale,
RemoveLiquidityOne1 as RemoveLiquidityOneWithSupply,
RemoveLiquidityOne2 as RemoveLiquidityOneWithPriceScale,
} from "../../generated/templates/PoolTemplate/Pool";
import { Swap } from "../modules/Swap";
import { Deposit } from "../modules/Deposit";
@@ -44,6 +47,32 @@ export function handleTokenExchange(event: TokenExchange): void {
updateFinancials(event.block);
}

export function handleTokenExchangeWithPriceScale(event: TokenExchangeWithPriceScale): void {
const buyer = event.params.buyer;
const liquidityPoolAddress = event.address;

const soldId = event.params.sold_id;
const amountIn = event.params.tokens_sold;

const boughtId = event.params.bought_id;
const amountOut = event.params.tokens_bought;

Swap(
liquidityPoolAddress,
soldId,
amountIn,
boughtId,
amountOut,
buyer,
event.transaction,
event.block
);

updateUsageMetrics(event.block, buyer);
updatePoolSnapshots(liquidityPoolAddress, event.block);
updateFinancials(event.block);
}

export function handleTokenExchangeUnderlying(
event: TokenExchangeUnderlying
): void {
@@ -92,6 +121,27 @@ export function handleAddLiquidity(event: AddLiquidity): void {
updateFinancials(event.block);
}

export function handleAddLiquidityWithPriceScale(event: AddLiquidityWithPriceScale): void {
const liquidityPoolAddress = event.address;

const provider = event.params.provider;
const tokenAmounts = event.params.token_amounts;
const totalSupply = event.params.token_supply;

Deposit(
liquidityPoolAddress,
tokenAmounts,
totalSupply,
provider,
event.transaction,
event.block
);

updateUsageMetrics(event.block, provider);
updatePoolSnapshots(liquidityPoolAddress, event.block);
updateFinancials(event.block);
}

export function handleAddLiquidityWithFees(event: AddLiquidityWithFees): void {
const liquidityPoolAddress = event.address;

@@ -203,6 +253,27 @@ export function handleRemoveLiquidityOneWithSupply(
updateFinancials(event.block);
}

export function handleRemoveLiquidityOneWithPriceScale(event: RemoveLiquidityOneWithPriceScale): void {
const provider = event.params.provider;
const liquidityPoolAddress = event.address;
const outputTokenBurntAmount = event.params.token_amount;

Withdraw(
liquidityPoolAddress,
[],
outputTokenBurntAmount,
null,
provider,
event.transaction,
event.block,
event
);

updateUsageMetrics(event.block, provider);
updatePoolSnapshots(liquidityPoolAddress, event.block);
updateFinancials(event.block);
}

export function handleRemoveLiquidityImbalance(
event: RemoveLiquidityImbalance
): void {
4 changes: 3 additions & 1 deletion subgraphs/curve-finance/src/prices/config/mainnet.ts
Original file line number Diff line number Diff line change
@@ -81,7 +81,9 @@ export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = [
Address.fromString("0xca3d75ac011bf5ad07a98d02f18225f9bd9a6bdf"), // crvTriCrypto
Address.fromString("0xc4ad29ba4b3c580e6d59105fff484999997675ff"), // crv3Crypto
];
export const INCH_ORACLE_BLACKLIST: Address[] = [];
export const INCH_ORACLE_BLACKLIST: Address[] = [
Address.fromString("0x365accfca291e7d3914637abf1f7635db165bb09"), // FXN
];
export const AAVE_ORACLE_BLACKLIST: Address[] = [];
export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = [];