Skip to content

Commit

Permalink
feat: set ironbank tvl to 0 after 2022-01-22T00:00:00Z because they l…
Browse files Browse the repository at this point in the history
…aunched as a separate product.
  • Loading branch information
mariuspod committed Jan 24, 2022
1 parent e1c2867 commit 7c4a75b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions yearn/ironbank.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from collections import defaultdict
from dataclasses import dataclass
from functools import cached_property
from datetime import datetime

from brownie import Contract, chain
from brownie.network.contract import InterfaceContainer
Expand All @@ -13,7 +14,7 @@
from yearn.networks import Network
from yearn.prices.compound import get_fantom_ironbank
from yearn.prices.compound import compound
from yearn.utils import contract
from yearn.utils import contract, get_block_timestamp
import logging

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -75,6 +76,9 @@ def ironbank(self):
return contract(addr) if isinstance(addr, str) else addr()

def describe(self, block=None):
block_ts = get_block_timestamp(block)
snapshot_ts = datetime.strptime('2022-01-22T00:00:00Z','%Y-%m-%dT%H:%M:%SZ').timestamp()

markets = self.active_vaults_at(block)
blocks_per_year = 365 * 86400 / 15
contracts = [m.vault for m in markets]
Expand Down Expand Up @@ -103,7 +107,11 @@ def describe(self, block=None):
for attr in ["getCash", "totalBorrows", "totalReserves"]:
res[attr] /= 10 ** m.decimals

tvl = (res["getCash"] + res["totalBorrows"] - res["totalReserves"]) * price
if block_ts > snapshot_ts:
tvl = 0
else:
tvl = (res["getCash"] + res["totalBorrows"] - res["totalReserves"]) * price

supplied = res["getCash"] + res["totalBorrows"] - res["totalReserves"]
ratio = res["totalBorrows"] / supplied if supplied != 0 else None

Expand Down

0 comments on commit 7c4a75b

Please sign in to comment.