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

Zivoe Adapter #12792

Closed
wants to merge 1 commit into from
Closed
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
46 changes: 46 additions & 0 deletions projects/zivoe/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const { getLogs } = require("../helper/cache/getLogs");
const { sumTokens2 } = require("../helper/unwrapLPs");

const LOANS_FROM_BLOCK = 20973423;

// On-Chain Credit Locker
const OCC_USDC = "0xfAb4e880467e26ED46F00c669C28fEaC58262698";

// TVL Owners
const DAO = "0xB65a66621D7dE34afec9b9AC0755133051550dD7";
const YDL = "0xfB7920B55887840643e20952f22Eb18dDC474B2B";
const ST_STT = "0x0D45c292baCdC47CE850E4c83a2FA2e8509DEd5D";
const ST_JTT = "0xcacdB1A5a11F824E02De4CA6E7b2D12BB278aA7c";

// TVL Asset
const USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";

async function borrowed(api) {
const logs = await getLogs({
api,
target: OCC_USDC,
eventAbi: "event OfferAccepted(uint256 indexed id, uint256 principal, address indexed borrower, uint256 paymentDueBy)",
fromBlock: LOANS_FROM_BLOCK,
onlyArgs: true,
});

const loansIds = logs.map(({ id }) => id);
const loans = await api.multiCall({
abi: "function loans(uint256) view returns (address borrower, uint256 principalOwed, uint256 APR, uint256 APRLateFee, uint256 paymentDueBy, uint256 paymentsRemaining, uint256 term, uint256 paymentInterval, uint256 offerExpiry, uint256 gracePeriod, int8 paymentSchedule, uint8 state)",
target: OCC_USDC,
calls: loansIds,
});
const owedAmounts = loans.map(({ principalOwed }) => principalOwed);

const occAsset = await api.call({ abi: "address:stablecoin", target: OCC_USDC });
const tokens = Array(owedAmounts.length).fill(occAsset);

api.addTokens(tokens, owedAmounts);
}

module.exports = {
ethereum: {
tvl: () => ({}),
borrowed,
},
};
Loading