Skip to content
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
63 changes: 35 additions & 28 deletions src/adaptors/smardex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@ const CONFIG = {
TIME_BETWEEN_BLOCK: 12,
STAKING_ADDRESS: '0x80497049b005Fd236591c3CD431DBD6E06eB1A31',
},
arbitrum: {
ENDPOINT: `${ENDPOINT_BASE}/arbitrum`,
SDEX_TOKEN_ADDRESS: '0xabD587f2607542723b17f14d00d99b987C29b074',
FARMING_RANGE_ADDRESS: '0x53D165DF0414bD02E91747775450934BF2257f69',
TIME_BETWEEN_BLOCK: 0.25,
},
polygon: {
ENDPOINT: `${ENDPOINT_BASE}/polygon`,
SDEX_TOKEN_ADDRESS: '0x6899fAcE15c14348E1759371049ab64A3a06bFA6',
FARMING_RANGE_ADDRESS: '0x7DB73A1e526db36c40e508b09428420c1fA8e46b',
TIME_BETWEEN_BLOCK: 2.2,
},
bsc: {
ENDPOINT: `${ENDPOINT_BASE}/bsc`,
SDEX_TOKEN_ADDRESS: '0xFdc66A08B0d0Dc44c17bbd471B88f49F50CdD20F',
FARMING_RANGE_ADDRESS: '0xb891Aeb2130805171796644a2af76Fc7Ff25a0b9',
TIME_BETWEEN_BLOCK: 3,
},
base: {
ENDPOINT: `${ENDPOINT_BASE}/base`,
SDEX_TOKEN_ADDRESS: '0xFd4330b0312fdEEC6d4225075b82E00493FF2e3f',
FARMING_RANGE_ADDRESS: '0xa5D378c05192E3f1F365D6298921879C4D51c5a3',
TIME_BETWEEN_BLOCK: 2,
},
// arbitrum: {
// ENDPOINT: `${ENDPOINT_BASE}/arbitrum`,
// SDEX_TOKEN_ADDRESS: '0xabD587f2607542723b17f14d00d99b987C29b074',
// FARMING_RANGE_ADDRESS: '0x53D165DF0414bD02E91747775450934BF2257f69',
// TIME_BETWEEN_BLOCK: 0.25,
// },
// polygon: {
// ENDPOINT: `${ENDPOINT_BASE}/polygon`,
// SDEX_TOKEN_ADDRESS: '0x6899fAcE15c14348E1759371049ab64A3a06bFA6',
// FARMING_RANGE_ADDRESS: '0x7DB73A1e526db36c40e508b09428420c1fA8e46b',
// TIME_BETWEEN_BLOCK: 2.2,
// },
// bsc: {
// ENDPOINT: `${ENDPOINT_BASE}/bsc`,
// SDEX_TOKEN_ADDRESS: '0xFdc66A08B0d0Dc44c17bbd471B88f49F50CdD20F',
// FARMING_RANGE_ADDRESS: '0xb891Aeb2130805171796644a2af76Fc7Ff25a0b9',
// TIME_BETWEEN_BLOCK: 3,
// },
// base: {
// ENDPOINT: `${ENDPOINT_BASE}/base`,
// SDEX_TOKEN_ADDRESS: '0xFd4330b0312fdEEC6d4225075b82E00493FF2e3f',
// FARMING_RANGE_ADDRESS: '0xa5D378c05192E3f1F365D6298921879C4D51c5a3',
// TIME_BETWEEN_BLOCK: 2,
// },
};

const EXCEPTIONS = {
Expand Down Expand Up @@ -134,6 +134,14 @@ const EXCEPTIONS = {
})
).output / 1e18;
const apyBase = await computeUsdnApr();
console.log({
pool: USDN_TOKEN_ADDRESS,
symbol: 'USDN',
project: 'smardex',
chain: utils.formatChain(chainString),
tvlUsd: totalSupply,
apyBase,
});
return {
pool: USDN_TOKEN_ADDRESS,
symbol: 'USDN',
Expand Down Expand Up @@ -567,7 +575,7 @@ async function fetchUSDNData(chain, timestamp) {
});

const wstEthPrice = await getWstEthPriceAtTimestamp(chain, timestamp);
const formattedWstEthPrice = BigInt(Math.round(wstEthPrice * 10 ** 8));
const formattedWstEthPrice = BigInt(Math.round(wstEthPrice * 10 ** 18));

const usdnVaultAssetAvailableWithFundingCall = sdk.api.abi.call({
target: USDN_PROTOCOL_ADDRESS,
Expand Down Expand Up @@ -610,7 +618,7 @@ const getWstEthPriceAtTimestamp = async (chain, timestamp) => {
};

const computeUsdnApr = async (chain = 'ethereum') => {
const timestampNow = Math.floor(Date.now() / 1_000);
const timestampNow = Math.floor(Date.now() / 1_000) - 24 * 60 * 60 * 7;
const timestampOneYearAgo = Math.max(
timestampNow - 24 * 60 * 60 * 365,
USDN_PROTOCOL_FIRST_DEPOSIT
Expand All @@ -634,8 +642,7 @@ const computeUsdnApr = async (chain = 'ethereum') => {
BIGINT_10_POW_18) *
BigInt(DAYS_IN_YEAR)) /
(BigInt(timestampNow) - BigInt(timestampOneYearAgo));

return Number(formatEther(apr));
return Number(formatEther(apr) * 100_000);
};

module.exports = {
Expand Down
Loading