Skip to content

Commit 62152aa

Browse files
authored
Merge pull request #2026 from parallel-protocol/feat/add-parallel-protocol-sUSDp
feat(parallel-protocol-v3): add support to sUSDp yield token
2 parents 1cb0e59 + 64031f3 commit 62152aa

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const config = {
2+
ethereum: {
3+
chainName: 'Ethereum',
4+
USDp: '0x9B3a8f7CEC208e247d97dEE13313690977e24459',
5+
sUSDp: '0x0d45b129dc868963025Db79A9074EA9c9e32Cae4',
6+
},
7+
base: {
8+
chainName: 'Base',
9+
USDp: ' 0x76A9A0062ec6712b99B4f63bD2b4270185759dd5',
10+
sUSDp: '0x472eD57b376fE400259FB28e5C46eB53f0E3e7E7',
11+
},
12+
sonic: {
13+
chainName: 'Sonic',
14+
USDp: '0x08417cdb7F52a5021bB4eb6E0deAf3f295c3f182',
15+
sUSDp: '0xe8a3DA6f5ed1cf04c58ac7f6A7383641e877517b',
16+
},
17+
hyperevm: {
18+
chainName: 'hyperevm',
19+
USDp: '0xBE65F0F410A72BeC163dC65d46c83699e957D588',
20+
sUSDp: '0x9B3a8f7CEC208e247d97dEE13313690977e24459',
21+
},
22+
};
23+
24+
module.exports = { config };
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
const utils = require('../utils');
2+
const sdk = require('@defillama/sdk');
3+
const ethers = require('ethers');
4+
const { config } = require('./config');
5+
const BigNumber = require('bignumber.js');
6+
7+
// function getEstimatedAPR is misleading, it returns the estimated APY
8+
const getEstimatedAPR =
9+
'function estimatedAPR() external view returns (uint256)';
10+
const getTotalAssets = 'function totalAssets() external view returns (uint256)';
11+
12+
const getsUSDpData = async (chain, chainConfig) => {
13+
const { chainName, USDp, sUSDp } = chainConfig;
14+
let estimatedAPY;
15+
let totalAssets;
16+
if (chain === 'hyperevm') {
17+
const provider = new ethers.providers.JsonRpcProvider(
18+
'https://rpc.hyperliquid.xyz/evm'
19+
);
20+
const abi = [getEstimatedAPR, getTotalAssets];
21+
const contract = new ethers.Contract(sUSDp, abi, provider);
22+
[estimatedAPY, totalAssets] = await Promise.all([
23+
contract.estimatedAPR(),
24+
contract.totalAssets(),
25+
]);
26+
} else {
27+
const api = new sdk.ChainApi({ chain });
28+
[estimatedAPY, totalAssets] = await Promise.all([
29+
api.call({
30+
abi: getEstimatedAPR,
31+
target: sUSDp,
32+
}),
33+
api.call({
34+
abi: getTotalAssets,
35+
target: sUSDp,
36+
}),
37+
]);
38+
}
39+
40+
const tvlUsd = new BigNumber(
41+
ethers.utils.formatUnits(totalAssets, 18)
42+
).toNumber();
43+
const apyBase = new BigNumber(
44+
ethers.utils.formatUnits(estimatedAPY, 16)
45+
).toNumber();
46+
47+
return {
48+
pool: `${sUSDp}-parallel-v3`.toLowerCase(),
49+
chain: utils.formatChain(chainName),
50+
project: 'parallel-protocol-v3',
51+
symbol: 'sUSDp',
52+
tvlUsd: tvlUsd,
53+
apyBase: apyBase,
54+
rewardTokens: [USDp],
55+
underlyingTokens: [USDp],
56+
poolMeta: 'saving',
57+
};
58+
};
59+
60+
const main = async () => {
61+
const markets = [];
62+
for (let [chain, data] of Object.entries(config)) {
63+
const result = await getsUSDpData(chain, data);
64+
markets.push(result);
65+
}
66+
return markets;
67+
};
68+
69+
module.exports = {
70+
timetravel: false,
71+
apy: main,
72+
url: 'https://app.parallel.best/earn',
73+
};

0 commit comments

Comments
 (0)