Skip to content

Commit

Permalink
add Amnis yield (#1046)
Browse files Browse the repository at this point in the history
* add Amnis yield

* recalculate apy
  • Loading branch information
john2798 authored Oct 25, 2023
1 parent 78e5895 commit be86a04
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/adaptors/amnis-finance/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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
const { data: { rewards_rate, rewards_rate_denominator } } = await utils.getData(`${NODE_URL}/accounts/0x1/resource/0x1::staking_config::StakingConfig`)
const amStakedData = await utils.getData(`${NODE_URL}/view`, {"function": `${AMNIS_RESOURCE_ACCOUNT}::stapt_token::total_amapt_staked`,"type_arguments": [],"arguments": []})
const amStaked = amStakedData[0]
const amTotalSupplyData = await utils.getData(`${NODE_URL}/view`, {"function": `${AMNIS_RESOURCE_ACCOUNT}::amapt_token::total_supply`,"type_arguments": [],"arguments": []})
const amTotalSupply = amTotalSupplyData[0]
const apy = (Math.pow(1 + rewards_rate * amTotalSupply / amStaked / rewards_rate_denominator, 12 * 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 be86a04

Please sign in to comment.