From e3e07ea711fa5432d9720d1c951d966c8ea757ef Mon Sep 17 00:00:00 2001 From: Alexandru Serban Date: Mon, 13 Oct 2025 11:51:22 +0300 Subject: [PATCH] feat: update zivoe's calculations (#16630) --- projects/zivoe/index.js | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/projects/zivoe/index.js b/projects/zivoe/index.js index eada779ac..01a186799 100644 --- a/projects/zivoe/index.js +++ b/projects/zivoe/index.js @@ -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 = {