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

Update Amet Finance #9733

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Changes from all commits
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
39 changes: 21 additions & 18 deletions projects/amet-finance/index.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
const { getLogs } = require("../helper/cache/getLogs");
const issuerEventABI = "event Create(address indexed issuer, address indexed contractAddress)";
const issuerEventABI = "event BondIssued(address bondAddress)";

const config = {
base: {
issuer: "0xE67BE43603260b0AD38bBfe89FcC6fDe6741e82A",
fromBlock: 12724500
},
manta: {
issuer: "0x875B73364432d14EEb99eb0eAC6bAaCbEe6829E2",
fromBlock: 574206
issuer: null,
},
polygon: {
issuer: "0x875B73364432d14EEb99eb0eAC6bAaCbEe6829E2",
fromBlock: 50204821
issuer: null,
},
polygon_zkevm: {
issuer: "0x875B73364432d14EEb99eb0eAC6bAaCbEe6829E2",
fromBlock: 7860004
issuer: null,
}
};

const FixedFlexIssuerABI = {
payoutToken: "function payoutToken() view returns (address)"
};


async function tvl(api) {
const { issuer, fromBlock } = config[api.chain];

const logs = await getLogs({ api, target: issuer, fromBlock, eventAbi: issuerEventABI, onlyArgs: true });
const calls = logs.map(item => item.contractAddress);
const res = await api.multiCall({ abi: ZCB_Issuer_V1.getInfo, calls });
const ownerTokens = res.map((v, i) => [[v.interestToken], calls[i]]);
return api.sumTokens({ ownerTokens });
if (!issuer) return {};

const issuerLogs = await getLogs({api, target: issuer, fromBlock, eventAbi: issuerEventABI, onlyArgs: true});
const bondAddresses = issuerLogs.map(item => item.bondAddress);
const payoutTokens = await api.multiCall({abi: FixedFlexIssuerABI.payoutToken, calls: bondAddresses});
const ownerTokens = payoutTokens.map((payoutToken, index) => [[payoutToken], bondAddresses[index]]);
return await api.sumTokens({ownerTokens});
}

module.exports = {
start: 1700036718369,
methodology: "Get the issuer contract logs to understand what bonds were issued and add what is locked in the contract."
methodology: "On DeFiLlama, the TVL (Total Value Locked) calculation for Amet Finance is derived from analyzing issuer logs to identify all issued bonds. We then assess the payout balance held within these bonds. The aggregate of these balances across all bonds represents the TVL for Amet Finance."
};

Object.keys(config).forEach(chain => {
module.exports[chain] = { tvl };
});

const ZCB_Issuer_V1 = {
getInfo: "function getInfo() view returns (address, uint256, uint256 purchased, uint256, uint256, address investmentToken, uint256 investmentTokenAmount, address interestToken, uint256, uint16, uint256)"
};
Loading