mirror of
https://github.com/alexgo-io/DefiLlama-Adapters.git
synced 2026-05-03 15:14:50 +08:00
feat: update zivoe's calculations (#16630)
This commit is contained in:
@@ -7,6 +7,7 @@ const LOANS_FROM_BLOCK = 20973423;
|
||||
// On-Chain Credit Lockers
|
||||
const OCC_USDC = "0xfAb4e880467e26ED46F00c669C28fEaC58262698";
|
||||
const OCC_Variable = "0x26Ac8662F7502EF246F763311176e3131326f29E";
|
||||
const OCC_Cycle = "0x161c42FB3cA3baE7755124b56D48a88BcEccc17F";
|
||||
|
||||
// TVL Owners
|
||||
const DAO = "0xB65a66621D7dE34afec9b9AC0755133051550dD7";
|
||||
@@ -14,6 +15,7 @@ const YDL = "0xfB7920B55887840643e20952f22Eb18dDC474B2B";
|
||||
const ST_STT = "0x0D45c292baCdC47CE850E4c83a2FA2e8509DEd5D";
|
||||
const OCT_DAO = "0xd702332915fDDf588793D54d63872a97ad78d108";
|
||||
const OCR = "0x7720e6eEe8EF2457d4e1C38D6A9295967b2a89ec";
|
||||
const OCR_Cycle = "0x12E46E69623350aB3AE6D52CAb86a152A078Ad6F";
|
||||
|
||||
// Token Addresses
|
||||
const USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
||||
@@ -23,7 +25,10 @@ const M0 = "0x437cc33344a0B27A429f795ff6B469C72698B291";
|
||||
const aUSDC = "0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c";
|
||||
|
||||
// Borrowers
|
||||
const OCC_VARIABLE_BORROWER = "0x50C72Ff8c5e7498F64BEAeB8Ed5BE83CABEB0Fd5";
|
||||
const BORROWER_NEW_CO = "0x50C72Ff8c5e7498F64BEAeB8Ed5BE83CABEB0Fd5";
|
||||
const BORROWER_ZINCLUSIVE = "0xC8d6248fFbc59BFD51B23E69b962C60590d5f026";
|
||||
|
||||
const OCC_CYCLE_START_BLOCK = 23484381;
|
||||
|
||||
async function tvl(api) {
|
||||
return sumTokens2({
|
||||
@@ -50,6 +55,7 @@ async function tvl(api) {
|
||||
|
||||
// aUSDC balance
|
||||
[aUSDC, OCR],
|
||||
[aUSDC, OCR_Cycle],
|
||||
],
|
||||
});
|
||||
}
|
||||
@@ -62,7 +68,7 @@ async function borrowed(api) {
|
||||
"event OfferAccepted(uint256 indexed id, uint256 principal, address indexed borrower, uint256 paymentDueBy)",
|
||||
fromBlock: LOANS_FROM_BLOCK,
|
||||
onlyArgs: true,
|
||||
extraKey: 'v2',
|
||||
extraKey: "v2",
|
||||
});
|
||||
|
||||
const loansIds = logs.map(({ id }) => id);
|
||||
@@ -73,15 +79,33 @@ async function borrowed(api) {
|
||||
});
|
||||
|
||||
const owedAmounts = loans.map(({ principalOwed }) => principalOwed);
|
||||
api.addTokens([USDC], owedAmounts);
|
||||
|
||||
const occVariableBorrowed = await api.call({
|
||||
abi: "function usage(address) view returns (uint256)",
|
||||
target: OCC_Variable,
|
||||
params: [OCC_VARIABLE_BORROWER],
|
||||
params: [BORROWER_NEW_CO],
|
||||
});
|
||||
|
||||
api.add(USDC, occVariableBorrowed);
|
||||
const zinclusiveBorrowed = await api.call({
|
||||
abi: "function usage(address) view returns (uint256)",
|
||||
target: OCC_Cycle,
|
||||
params: [BORROWER_ZINCLUSIVE],
|
||||
});
|
||||
|
||||
const newCoBorrowed = await api.call({
|
||||
abi: "function usage(address) view returns (uint256)",
|
||||
target: OCC_Cycle,
|
||||
params: [BORROWER_NEW_CO],
|
||||
});
|
||||
|
||||
const isOCCCycle = api.block >= OCC_CYCLE_START_BLOCK;
|
||||
if (isOCCCycle) {
|
||||
api.add(USDC, zinclusiveBorrowed);
|
||||
api.add(USDC, newCoBorrowed);
|
||||
} else {
|
||||
api.addTokens([USDC], owedAmounts);
|
||||
api.add(USDC, occVariableBorrowed);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user