def balances(self, blocks): bentobox = contract('0xF5BCE5077908a1b7370B9ae04AdC565EBd643966') vault = Vault.from_address(self.vault) balances = batch_call( [[bentobox, 'balanceOf', self.vault, self.wrapper, block] for block in blocks]) return [(balance or 0) / vault.scale for balance in balances]
def vault_from_event(self, event): return Vault( vault=Contract.from_abi("Vault", event["vault"], self.releases[event["api_version"]].abi), token=event["token"], api_version=event["api_version"], registry=self, )
def get_formatted_lend_rates(vault: VaultV2, samples: ApySamples) -> list: apy = vault.apy(samples) lend_rate_apy = apy.net_apy lend_rate_apr = ((apy.net_apy + 1) ** (1 / 365) - 1) * 365 if apy.type == 'crv': return [ {"apr": lend_rate_apr, "apy": lend_rate_apy, "tokenSymbol": contract(curve_pool_token_address).symbol()} for curve_pool_token_address in curve.get_underlying_coins(vault.token) ] else: return [{"apr": lend_rate_apr, "apy": lend_rate_apy, "tokenSymbol": vault.token.symbol()}]
def get_protocol_fees(address): """ Get all protocol fee payouts for a given vault. Fees can be found as vault share transfers to the rewards address. """ vault = Vault.from_address(address) rewards = vault.vault.rewards() topics = construct_event_topic_set( filter_by_name('Transfer', vault.vault.abi)[0], web3.codec, { 'sender': address, 'receiver': rewards }, ) logs = decode_logs(get_logs_asap(address, topics)) return {log.block_number: log['value'] / vault.scale for log in logs}
def mim(): samples = get_samples() address = "0x2DfB14E32e2F8156ec15a2c21c3A6c053af52Be8" vault = VaultV2.from_address(address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
def tricrypto(): samples = get_samples() address = "0x3D980E50508CFd41a13837A60149927a11c03731" vault = VaultV2.from_address(address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
def rai(): samples = get_samples() address = "0x873fB544277FD7b977B196a826459a69E27eA4ea" vault = VaultV2.from_address(address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
def lusd(): samples = get_samples() address = "0x5fA5B62c8AF877CB37031e0a3B2f34A78e3C56A6" vault = VaultV2.from_address(address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
def old_dai(): samples = get_samples() address = "0x19D3364A399d251E894aC732651be8B0E4e85001" vault = VaultV2.from_address(address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
def fetch_apy(vault_address): if chain.id != Network.Fantom: raise Exception("run on fantom") samples = get_samples() vault = VaultV2.from_address(vault_address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
def yvboost(): samples = get_samples() address = "0x9d409a0A012CFbA9B15F6D4B36Ac57A46966Ab9a" vault = VaultV2.from_address(address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
def ibeur(): samples = get_samples() address = "0x67e019bfbd5a67207755D04467D6A70c0B75bF60" vault = VaultV2.from_address(address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
def sushi(): samples = get_samples() address = "0x6d765CbE5bC922694afE112C140b8878b9FB0390" vault = VaultV2.from_address(address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
def yfi(): samples = get_samples() address = "0xdb25cA703181E7484a155DD612b06f57E12Be5F0" vault = VaultV2.from_address(address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
def ibJPY(): samples = get_samples() address = "0x59518884EeBFb03e90a18ADBAAAB770d4666471e" vault = VaultV2.from_address(address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
def cvxCRV(): samples = get_samples() address = "0x4560b99C904aAD03027B5178CCa81584744AC01f" vault = VaultV2.from_address(address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
def eurt(): samples = get_samples() address = "0x0d4EA8536F9A13e4FBa16042a46c30f092b06aA5" vault = VaultV2.from_address(address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
def ibgbp(): samples = get_samples() address = "0x595a68a8c9D5C230001848B69b1947ee2A607164" vault = VaultV2.from_address(address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
def total_supplies(self, blocks): vault = Vault.from_address(self.vault) supplies = batch_call([[vault.vault, 'totalSupply', block] for block in blocks]) return [supply / vault.scale for supply in supplies]
def balances(self, blocks): vault = Vault.from_address(self.vault) balances = batch_call([[vault.vault, 'balanceOf', self.wrapper, block] for block in blocks]) return [balance / vault.scale for balance in balances]
def ibkrw(): samples = get_samples() address = "0x528D50dC9a333f01544177a924893FA1F5b9F748" vault = VaultV2.from_address(address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
def dai(): samples = get_samples() address = "0xdA816459F1AB5631232FE5e97a05BBBb94970c95" vault = VaultV2.from_address(address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
def calculate_apy(address): samples = get_samples() vault = VaultV2.from_address(address) print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))