diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..94a25f7f4 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/projects/config/finnexus/abis.js b/projects/config/finnexus/abis.js new file mode 100644 index 000000000..de7cd066d --- /dev/null +++ b/projects/config/finnexus/abis.js @@ -0,0 +1,6 @@ +let abis = {}; + +abis.fnxOracle = [{"constant":true,"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getTotalCollateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]; +module.exports = { + abis +} \ No newline at end of file diff --git a/projects/finnexus.js b/projects/finnexus.js new file mode 100644 index 000000000..371f0af03 --- /dev/null +++ b/projects/finnexus.js @@ -0,0 +1,33 @@ +var Web3 = require('web3'); +const env = require('dotenv').config() +const web3 = new Web3(new Web3.providers.HttpProvider(`https://mainnet.infura.io/v3/${env.parsed.INFURA_KEY}`)); + +const BN = require("bignumber.js"); +const abis = require('./config/finnexus/abis.js') +const utils = require('./helper/utils'); + +async function getTotalCollateral(abi,contract) { + var dacontract = new web3.eth.Contract(abi, contract) + var totalCol = await dacontract.methods.getTotalCollateral().call(); + return totalCol; +} + +async function fetch() { + let usdcPool = '0x120f18f5b8edcaa3c083f9464c57c11d81a9e549'; + let fnxPool = '0xfdf252995da6d6c54c03fc993e7aa6b593a57b8d'; + + let usdcTotal = await getTotalCollateral(abis.abis.fnxOracle,usdcPool); + let fnxTotal = await getTotalCollateral(abis.abis.fnxOracle,fnxPool); + + usdcTotal = new BN(usdcTotal).div(new BN(10 ** 24)).toFixed(2); + fnxTotal = new BN(fnxTotal).div(new BN(10 ** 24)).toFixed(2); + + let tlv = parseFloat(usdcTotal) + parseFloat(fnxTotal); + + return tlv; +} + + +module.exports = { + fetch +} diff --git a/projects/hegic.js b/projects/hegic.js deleted file mode 100644 index f44072971..000000000 --- a/projects/hegic.js +++ /dev/null @@ -1,24 +0,0 @@ -var Web3 = require('web3'); -const env = require('dotenv').config() -const web3 = new Web3(new Web3.providers.HttpProvider(`https://mainnet.infura.io/v3/${env.parsed.INFURA_KEY}`)); -const BigNumber = require("bignumber.js"); -const utils = require('./helper/utils'); - - - -async function fetch() { - let ethPool = '0x878f15ffc8b894a1ba7647c7176e4c01f74e140b'; - let btcPool = '0x20DD9e22d22dd0a6ef74a520cb08303B5faD5dE7'; - let btcAmount = await utils.returnBalance('0x2260fac5e5542a773aa44fbcfedf7c193bc2c599', btcPool); - let getethBalanceRes = await web3.eth.getBalance(ethPool); - let price_feed = await utils.getPricesfromString('bitcoin,ethereum'); - let ethAmount = new BigNumber(getethBalanceRes).div(10 ** 18).toFixed(2); - let tvl = (price_feed.data.bitcoin.usd * btcAmount) + (ethAmount * price_feed.data.ethereum.usd) - return tvl; - -} - - -module.exports = { - fetch -}