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

Amphor #1113

Merged
merged 5 commits into from
Dec 13, 2023
Merged

Amphor #1113

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
35 changes: 27 additions & 8 deletions src/adaptors/amphor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ const sdk = require('@defillama/sdk');

const poolsFunction = async () => {

// const wbtc = "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599";
const wbtc = "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599";
const wsteth = "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0";
const prices = (await utils.getPrices([wsteth/*, wbtc*/], 'ethereum'))
const prices = (await utils.getPrices([wsteth, wbtc], 'ethereum'))
.pricesByAddress;
const usdcVaultAddress = '0x3b022EdECD65b63288704a6fa33A8B9185b5096b';
const wstethVaultAddress = '0x2791EB5807D69Fe10C02eED6B4DC12baC0701744';
const wbtcVaultAddress = '0xC4A324fDF8a2495776B4d6cA46599B5a52f96489';

const ERC4626TotalAssets =
{
Expand All @@ -24,16 +25,20 @@ const poolsFunction = async () => {
"stateMutability": "view",
"type": "function"
};

const wstethAprData = await utils.getData(
'https://app.amphor.io/api/apr?vaultSelected=ETH&networkId=1'
'https://app.amphor.io/api/apr?vault=wstethVault'
);
const wstethApy = ((1 + Number(wstethAprData.apr)/2600) ** (26) - 1) * 100;
const wstethApy = ((1 + Number(JSON.stringify(wstethAprData.wstethVault.strategyNetAPR))/2600) ** (26) - 1) * 100;

const usdcAprData = await utils.getData(
'https://app.amphor.io/api/apr?vaultSelected=USDC&networkId=1'
'https://app.amphor.io/api/apr?vault=usdcVault'
);
const usdcApy = ((1 + Number(JSON.stringify(usdcAprData.usdcVault.strategyNetAPR))/2600) ** (26) - 1) * 100;

const wbtcAprData = await utils.getData(
'https://app.amphor.io/api/apr?vault=wbtcVault'
);
const usdcApy = ((1 + Number(usdcAprData.apr)/2600) ** (26) - 1) * 100;
const wbtcApy = ((1 + Number(JSON.stringify(wbtcAprData.wbtcVault.strategyNetAPR))/2600) ** (26) - 1) * 100;

const usdcTotalAsset = await sdk.api.abi.call({
abi: ERC4626TotalAssets,
Expand All @@ -45,6 +50,11 @@ const poolsFunction = async () => {
chain: 'ethereum',
target: wstethVaultAddress,
});
const wbtcTotalAsset = await sdk.api.abi.call({
abi: ERC4626TotalAssets,
chain: 'ethereum',
target: wbtcVaultAddress,
});

const usdcPool = {
pool: usdcVaultAddress,
Expand All @@ -64,7 +74,16 @@ const poolsFunction = async () => {
apy: wstethApy,
};

return [usdcPool, wstethPool];
const wbtcPool = {
pool: wbtcVaultAddress,
chain: 'ethereum',
project: 'amphor',
symbol: utils.formatSymbol('WBTC'),
tvlUsd: (Number(wbtcTotalAsset.output)/1e18) * prices[wbtc.toLowerCase()],
apy: wbtcApy,
};

return [usdcPool, wstethPool, wbtcPool];
};

module.exports = {
Expand Down
Loading