Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions src/adaptors/rocky/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const config = {
sei: {
chainName: 'sei',
USDr: '0x53fdd705873d8259d6d179901fc3fdcb5339f921',
sUSDr: '0xc0029b98f09c9062056c14c0329d3a114a098617',
},
};

module.exports = { config };
61 changes: 61 additions & 0 deletions src/adaptors/rocky/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const utils = require('../utils');
const sdk = require('@defillama/sdk');
const ethers = require('ethers');
const { config } = require('./config');
const BigNumber = require('bignumber.js');

// function getEstimatedAPR is misleading, it returns the estimated APY
const getEstimatedAPR =
'function estimatedAPR() external view returns (uint256)';
const getTotalAssets = 'function totalAssets() external view returns (uint256)';

const getsUSDrData = async (chain, chainConfig) => {
const { chainName, USDr, sUSDr } = chainConfig;
let estimatedAPY;
let totalAssets;
const api = new sdk.ChainApi({ chain });
[estimatedAPY, totalAssets] = await Promise.all([
api.call({
abi: getEstimatedAPR,
target: sUSDr,
}),
api.call({
abi: getTotalAssets,
target: sUSDr,
}),
]);

const tvlUsd = new BigNumber(
ethers.utils.formatUnits(totalAssets, 18)
).toNumber();
const apyBase = new BigNumber(
ethers.utils.formatUnits(estimatedAPY, 16)
).toNumber();

return {
pool: `${sUSDr}-rocky`.toLowerCase(),
chain: utils.formatChain(chainName),
project: 'rocky',
symbol: 'sUSDr',
tvlUsd: tvlUsd,
apyBase: apyBase,
rewardTokens: [USDr],
underlyingTokens: [USDr],
poolMeta: 'saving',
};
};

const main = async () => {
const markets = [];
for (let [chain, data] of Object.entries(config)) {
const result = await getsUSDrData(chain, data);
markets.push(result);
}
return markets;
};

module.exports = {
timetravel: false,
apy: main,
url: 'https://app.rocky.cash/earn',
};
Loading