From 6968fd8048e177fb29a5b0c5274b51d43f54689b Mon Sep 17 00:00:00 2001 From: Dylan Melotik <60583747+dmelotik@users.noreply.github.com> Date: Mon, 29 Aug 2022 18:30:53 -0500 Subject: [PATCH] fix(#patch); abracadabra; div by 0 error (#898) Co-authored-by: Vincent Wen --- README.md | 2 +- .../abracadabra/config/networks/arbitrum/arbitrum.json | 5 ++++- .../abracadabra/config/networks/avalanche/avalanche.json | 5 ++++- .../protocols/abracadabra/config/networks/bsc/bsc.json | 5 ++++- .../abracadabra/config/networks/ethereum/ethereum.json | 5 ++++- .../abracadabra/config/networks/fantom/fantom.json | 5 ++++- .../config/templates/abracadabra.money.template.yaml | 8 ++++++++ subgraphs/abracadabra/src/common/constants.ts | 2 +- subgraphs/abracadabra/src/common/setters.ts | 5 ++++- subgraphs/abracadabra/src/positions.ts | 2 -- 10 files changed, 34 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 03566632d5..802fd76db8 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ This repo contains subgraphs defined using a set of standardized schemas. These | [Venus Protocol](https://venus.io/) | ✅ | 2.0.1 / 1.1.4 / 1.0.0 | [![Venus Protocol BSC](./docs/images/chains/bsc.png)](https://thegraph.com/hosted-service/subgraph/messari/venus-protocol-bsc) | | [Yeti Finance](https://yeti.finance/) | 🔨 | | | | **CDPs** | | | -| [Abracadabra](https://abracadabra.money/) | 🛠 | 2.0.1 / 1.2.6 / 1.0.0 | [![Abracadabra Money](./docs/images/chains/ethereum.png)](https://thegraph.com/hosted-service/subgraph/messari/abracadabra-money-ethereum) [![Abracadabra Money](./docs/images/chains/bsc.png)](https://thegraph.com/hosted-service/subgraph/messari/abracadabra-money-bsc) [![Abracadabra Money](./docs/images/chains/arbitrum.png)](https://thegraph.com/hosted-service/subgraph/messari/abracadabra-money-arbitrum) [![Abracadabra Money](./docs/images/chains/fantom.png)](https://thegraph.com/hosted-service/subgraph/messari/abracadabra-money-fantom) [![Abracadabra Money](./docs/images/chains/avalanche.png)](https://thegraph.com/hosted-service/subgraph/messari/abracadabra-money-avalanche) | +| [Abracadabra](https://abracadabra.money/) | 🛠 | 2.0.1 / 1.2.7 / 1.0.0 | [![Abracadabra Money](./docs/images/chains/ethereum.png)](https://thegraph.com/hosted-service/subgraph/messari/abracadabra-money-ethereum) [![Abracadabra Money](./docs/images/chains/bsc.png)](https://thegraph.com/hosted-service/subgraph/messari/abracadabra-money-bsc) [![Abracadabra Money](./docs/images/chains/arbitrum.png)](https://thegraph.com/hosted-service/subgraph/messari/abracadabra-money-arbitrum) [![Abracadabra Money](./docs/images/chains/fantom.png)](https://thegraph.com/hosted-service/subgraph/messari/abracadabra-money-fantom) [![Abracadabra Money](./docs/images/chains/avalanche.png)](https://thegraph.com/hosted-service/subgraph/messari/abracadabra-money-avalanche) | | [Inverse Finance](https://www.inverse.finance/) | 🛠 | 1.3.0 / 1.2.2 / 1.0.0 | [![Inverse Finance Ethereum](./docs/images/chains/ethereum.png)](https://thegraph.com/hosted-service/subgraph/messari/inverse-finance-ethereum) | | [Liquity](https://www.liquity.org/) | ✅ | 1.3.0 / 1.1.4 / 1.0.1 | [![Liquity Ethereum](./docs/images/chains/ethereum.png)](https://thegraph.com/hosted-service/subgraph/messari/liquity-ethereum) | | [MakerDAO](https://makerdao.com/en/) | 🛠 | 1.3.0 / 1.2.0 / 1.0.1 | [![MakerDAO Ethereum](./docs/images/chains/ethereum.png)](https://thegraph.com/hosted-service/subgraph/messari/makerdao-ethereum) | diff --git a/subgraphs/abracadabra/protocols/abracadabra/config/networks/arbitrum/arbitrum.json b/subgraphs/abracadabra/protocols/abracadabra/config/networks/arbitrum/arbitrum.json index 42bd18a4f7..f9f6d81f59 100644 --- a/subgraphs/abracadabra/protocols/abracadabra/config/networks/arbitrum/arbitrum.json +++ b/subgraphs/abracadabra/protocols/abracadabra/config/networks/arbitrum/arbitrum.json @@ -9,5 +9,8 @@ "SpellStartBlock": "821891", "OffchainAggregatorEnabled": true, "OffchainAggregatorAddress": "0x87121f6c9a9f6e90e59591e4cf4804873f54a95b", - "OffchainAggregatorStartBlock": "2370257" + "OffchainAggregatorStartBlock": "2370257", + "graftEnabled": true, + "subgraphId": "QmRA311PK6ZPevsPDMxohJkeQ5M4vNaq8mfVT8tTug2h7h", + "graftStartBlock": 21896462 } diff --git a/subgraphs/abracadabra/protocols/abracadabra/config/networks/avalanche/avalanche.json b/subgraphs/abracadabra/protocols/abracadabra/config/networks/avalanche/avalanche.json index 19726900c8..3de1f8bb87 100644 --- a/subgraphs/abracadabra/protocols/abracadabra/config/networks/avalanche/avalanche.json +++ b/subgraphs/abracadabra/protocols/abracadabra/config/networks/avalanche/avalanche.json @@ -9,5 +9,8 @@ "SpellEnabled": true, "SpellAddress": "0xCE1bFFBD5374Dac86a2893119683F4911a2F7814", "SpellStartBlock": "4041085", - "OffchainAggregatorEnabled": false + "OffchainAggregatorEnabled": false, + "graftEnabled": true, + "subgraphId": "QmcDpsUjwb6pVWq4XTgqTKraithR5CR1N3dXHDB7zAAqW8", + "graftStartBlock": 8283543 } diff --git a/subgraphs/abracadabra/protocols/abracadabra/config/networks/bsc/bsc.json b/subgraphs/abracadabra/protocols/abracadabra/config/networks/bsc/bsc.json index 90cae4ffe7..3657eaf5d9 100644 --- a/subgraphs/abracadabra/protocols/abracadabra/config/networks/bsc/bsc.json +++ b/subgraphs/abracadabra/protocols/abracadabra/config/networks/bsc/bsc.json @@ -7,5 +7,8 @@ "SpellEnabled": false, "OffchainAggregatorEnabled": true, "OffchainAggregatorAddress": "0x87a69a2988b33ea745008A47486890232630AABf", - "OffchainAggregatorStartBlock": "12743820" + "OffchainAggregatorStartBlock": "12743820", + "graftEnabled": true, + "subgraphId": "QmTFXTyX2AWfTmBjg84H4gzhoFBfin3bugP9YWL6Jnc8PD", + "graftStartBlock": 20874790 } diff --git a/subgraphs/abracadabra/protocols/abracadabra/config/networks/ethereum/ethereum.json b/subgraphs/abracadabra/protocols/abracadabra/config/networks/ethereum/ethereum.json index 12290bc83a..fe02dc9fdf 100644 --- a/subgraphs/abracadabra/protocols/abracadabra/config/networks/ethereum/ethereum.json +++ b/subgraphs/abracadabra/protocols/abracadabra/config/networks/ethereum/ethereum.json @@ -11,5 +11,8 @@ "SpellStartBlock": "12454535", "OffchainAggregatorEnabled": true, "OffchainAggregatorAddress": "0x18f0112E30769961AF90FDEe0D1c6B27E6d72D92", - "OffchainAggregatorStartBlock": "12505995" + "OffchainAggregatorStartBlock": "12505995", + "graftEnabled": true, + "subgraphId": "QmQZX9TNpPWguYZBEF9Zq4SPrcn8iMRotMp8FGwgrV5N2W", + "graftStartBlock": 15436152 } diff --git a/subgraphs/abracadabra/protocols/abracadabra/config/networks/fantom/fantom.json b/subgraphs/abracadabra/protocols/abracadabra/config/networks/fantom/fantom.json index 75f3913b50..a205fc0610 100644 --- a/subgraphs/abracadabra/protocols/abracadabra/config/networks/fantom/fantom.json +++ b/subgraphs/abracadabra/protocols/abracadabra/config/networks/fantom/fantom.json @@ -9,5 +9,8 @@ "SpellEnabled": true, "SpellAddress": "0x468003B688943977e6130F4F68F23aad939a1040", "SpellStartBlock": "16717812", - "OffchainAggregatorEnabled": false + "OffchainAggregatorEnabled": false, + "graftEnabled": true, + "subgraphId": "QmQvRHHY4sPMXsrMZmePXH3R6VCjK3CS6qK6dednurCZNU", + "graftStartBlock": 28576808 } diff --git a/subgraphs/abracadabra/protocols/abracadabra/config/templates/abracadabra.money.template.yaml b/subgraphs/abracadabra/protocols/abracadabra/config/templates/abracadabra.money.template.yaml index 56c6e99fa4..5f85359613 100644 --- a/subgraphs/abracadabra/protocols/abracadabra/config/templates/abracadabra.money.template.yaml +++ b/subgraphs/abracadabra/protocols/abracadabra/config/templates/abracadabra.money.template.yaml @@ -1,6 +1,14 @@ specVersion: 0.0.4 schema: file: ./schema.graphql +{{#graftEnabled}} +description: ... +features: + - grafting +graft: + base: {{subgraphId}} # Subgraph ID of base subgraph + block: {{graftStartBlock}} # Block number +{{/graftEnabled}} dataSources: - kind: ethereum name: BentoBox diff --git a/subgraphs/abracadabra/src/common/constants.ts b/subgraphs/abracadabra/src/common/constants.ts index 475d4e5b60..ebe25b00d0 100644 --- a/subgraphs/abracadabra/src/common/constants.ts +++ b/subgraphs/abracadabra/src/common/constants.ts @@ -193,5 +193,5 @@ export const BSC_NETWORK = "bsc"; export const AVALANCHE_NETWORK = "avalanche"; export const schemaVersion = "2.0.1"; -export const subgraphVersion = "1.2.6"; +export const subgraphVersion = "1.2.7"; export const methodologyVersion = "1.0.0"; diff --git a/subgraphs/abracadabra/src/common/setters.ts b/subgraphs/abracadabra/src/common/setters.ts index 967babedd4..d4dc6033c8 100644 --- a/subgraphs/abracadabra/src/common/setters.ts +++ b/subgraphs/abracadabra/src/common/setters.ts @@ -222,7 +222,10 @@ export function createLiquidateEvent(event: LogRemoveCollateral): void { // Update token price using the exchange rate // update on the market and token export function updateTokenPrice(rate: BigInt, token: Token, market: Market, blockNumber: BigInt): void { - let priceUSD = BIGDECIMAL_ONE.div(bigIntToBigDecimal(rate, token.decimals)); + let priceUSD = BIGDECIMAL_ZERO; + if (rate != BIGINT_ZERO) { + priceUSD = BIGDECIMAL_ONE.div(bigIntToBigDecimal(rate, token.decimals)); + } // update market market.inputTokenPriceUSD = priceUSD; diff --git a/subgraphs/abracadabra/src/positions.ts b/subgraphs/abracadabra/src/positions.ts index 5eb1043fa4..46a9d7150c 100644 --- a/subgraphs/abracadabra/src/positions.ts +++ b/subgraphs/abracadabra/src/positions.ts @@ -155,7 +155,6 @@ export function addAccountToProtocol(eventType: string, account: Account, event: dailySnapshot.cumulativeUniqueLiquidators = protocol.cumulativeUniqueLiquidators; } if (!activeEvent) { - log.warning("REACHED: {}", [activeEventId]) activeEvent = new ActiveEventAccount(activeEventId); dailySnapshot.dailyActiveLiquidators += 1; } @@ -168,7 +167,6 @@ export function addAccountToProtocol(eventType: string, account: Account, event: } if (!activeEvent) { activeEvent = new ActiveEventAccount(activeEventId); - log.warning("REACHED: {}", [activeEventId]) dailySnapshot.dailyActiveLiquidatees += 1; } dailySnapshot.save();