Skip to content

Commit

Permalink
add Amnis yield
Browse files Browse the repository at this point in the history
  • Loading branch information
john2798 committed Oct 20, 2023
1 parent 8711550 commit af49ae8
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/adaptors/amnis-finance/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const { default: BigNumber } = require('bignumber.js');

const utils = require('../utils');

const AMNIS_RESOURCE_ACCOUNT ='0x111ae3e5bc816a5e63c2da97d0aa3886519e0cd5e4b046659fa35796bd11542a';
const NODE_URL = 'https://fullnode.mainnet.aptoslabs.com/v1';
const COINS_LLAMA_PRICE_URL = 'https://coins.llama.fi/prices/current/';
const DECIMALS = 1e8;
const axios = require('axios');


const aptosCoinName = 'coingecko:aptos';

async function main() {
//calculate apy
let currentRewardRate = await axios.post(`${NODE_URL}/view`, {
function: `${AMNIS_RESOURCE_ACCOUNT}::router::current_reward_rate`,
type_arguments: [],
arguments: []
})
currentRewardRate = currentRewardRate.data
const effectiveRewardRate = Number(currentRewardRate[0])
const rewardRateDenominator = Number(currentRewardRate[1])
const apy = (Math.pow(1 + effectiveRewardRate / rewardRateDenominator, 24 / 2 * 365) - 1) * 100;

//calculate tvlUsd
let tvlUsd = 0
const aptPrice = await utils.getData(`${COINS_LLAMA_PRICE_URL}${aptosCoinName}`)
const { data: { supply } } = await utils.getData(`${NODE_URL}/accounts/${AMNIS_RESOURCE_ACCOUNT}/resource/0x1::coin::CoinInfo%3C${AMNIS_RESOURCE_ACCOUNT}::amapt_token::AmnisApt%3E`)
tvlUsd = supply.vec[0].integer.vec[0].value/1e8 * aptPrice.coins[aptosCoinName].price

return [
{
pool: `${AMNIS_RESOURCE_ACCOUNT}-amnis-finance`,
chain: utils.formatChain('aptos'),
project: 'amnis-finance',
symbol: utils.formatSymbol('amApt'),
tvlUsd: tvlUsd,
apy: apy,
},
];
}

module.exports = {
timetravel: false,
apy: main,
url: 'https://amnis.finance',
};

0 comments on commit af49ae8

Please sign in to comment.