Skip to content

feat(parallel-protocol-v3): add support to sUSDp yield token #2026

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
24 changes: 24 additions & 0 deletions src/adaptors/parallel-protocol-v3/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const config = {
ethereum: {
chainName: 'Ethereum',
USDp: '0x9B3a8f7CEC208e247d97dEE13313690977e24459',
sUSDp: '0x0d45b129dc868963025Db79A9074EA9c9e32Cae4',
},
base: {
chainName: 'Base',
USDp: ' 0x76A9A0062ec6712b99B4f63bD2b4270185759dd5',
sUSDp: '0x472eD57b376fE400259FB28e5C46eB53f0E3e7E7',
},
sonic: {
chainName: 'Sonic',
USDp: '0x08417cdb7F52a5021bB4eb6E0deAf3f295c3f182',
sUSDp: '0xe8a3DA6f5ed1cf04c58ac7f6A7383641e877517b',
},
hyperevm: {
chainName: 'hyperevm',
USDp: '0xBE65F0F410A72BeC163dC65d46c83699e957D588',
sUSDp: '0x9B3a8f7CEC208e247d97dEE13313690977e24459',
},
};

module.exports = { config };
73 changes: 73 additions & 0 deletions src/adaptors/parallel-protocol-v3/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
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 getsUSDpData = async (chain, chainConfig) => {
const { chainName, USDp, sUSDp } = chainConfig;
let estimatedAPY;
let totalAssets;
if (chain === 'hyperevm') {
const provider = new ethers.providers.JsonRpcProvider(
'https://rpc.hyperliquid.xyz/evm'
);
const abi = [getEstimatedAPR, getTotalAssets];
const contract = new ethers.Contract(sUSDp, abi, provider);
[estimatedAPY, totalAssets] = await Promise.all([
contract.estimatedAPR(),
contract.totalAssets(),
]);
} else {
const api = new sdk.ChainApi({ chain });
[estimatedAPY, totalAssets] = await Promise.all([
api.call({
abi: getEstimatedAPR,
target: sUSDp,
}),
api.call({
abi: getTotalAssets,
target: sUSDp,
}),
]);
}

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

return {
pool: `${sUSDp}-parallel-v3`.toLowerCase(),
chain: utils.formatChain(chainName),
project: 'parallel-protocol-v3',
symbol: 'sUSDp',
tvlUsd: tvlUsd,
apyBase: apyBase,
rewardTokens: [USDp],
underlyingTokens: [USDp],
poolMeta: 'saving',
};
};

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

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