NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Pylon++
// @namespace http://twitter.com/dodo021_
// @version 0.1.3
// @description Add usefull informations on Pylon Protocol website
// @author dodo021
// @match https://app.pylon.money/*
// @icon https://www.google.com/s2/favicons?domain=pylon.money
// @grant none
// @license MIT
// @updateURL https://openuserjs.org/meta/dodo021/Pylon++.meta.js
// ==/UserScript==
// If you want to send any tips, you can send them to terra1acp2rn4fw2fglycgmy9ggpy7u4a4l08fv0rvj7
(function () {
"use strict";
const walletAddr = window.localStorage.__terra_chrome_extension_wallet_address__;
async function main() {
const mineData = await getMineInfos();
const poolAPY = await getPoolAPY();
const totalPoolMine = mineData.liquidityInfo.tokenReserve;
const totalPoolUST = mineData.liquidityInfo.ustReserve;
const totalLP = mineData.liquidityInfo.totalShares * 1000000;
const lp = await getPoolLP();
const poolTotalMine = (lp / totalLP) * totalPoolMine;
const poolTotalUST = (lp / totalLP) * totalPoolUST;
const totalPoolValueStaked = poolTotalMine * mineData.priceInUst + poolTotalUST;
let $poolInfo = document.createElement("div");
$poolInfo.style.position = "fixed";
$poolInfo.style.bottom = "10px";
$poolInfo.style.right = "10px";
$poolInfo.style.padding = "15px";
$poolInfo.style.borderRadius = "10px";
$poolInfo.style.backgroundColor = "#7ef9ff";
$poolInfo.style.color = "#333";
let poolHTML = "<h4>MINE-UST Pool Infos</h4>";
poolHTML += `<p>${poolTotalMine.toFixed(3)} MINE - ${poolTotalUST.toFixed(3)} UST</p>`;
poolHTML += `<h5>Total value</h5>`;
poolHTML += `<p>$${totalPoolValueStaked.toFixed(3)}</p>`;
poolHTML += `<h5>Estimated rewards</h5>`;
poolHTML += `<p>1d | $${((totalPoolValueStaked * poolAPY) / 365).toFixed(6)}<br />`;
poolHTML += `1w | $${(((totalPoolValueStaked * poolAPY) / 365) * 7).toFixed(6)}<br />`;
poolHTML += `1m | $${(((totalPoolValueStaked * poolAPY) / 365) * 30).toFixed(6)}<br />`;
poolHTML += `1y | $${(totalPoolValueStaked * poolAPY).toFixed(6)}</p>`;
$poolInfo.innerHTML = poolHTML;
document.body.appendChild($poolInfo);
}
async function getPoolLP() {
const resp = await fetch(`https://api.pylon.money/api/liquidity/v1/status/${walletAddr}`);
const data = await resp.json();
return data.stakedBalance * 1000000;
}
async function getPoolAPY() {
const resp = await fetch("https://api.pylon.money/api/liquidity/v1/overview");
const data = await resp.json();
return data.apy;
}
async function getMineInfos() {
const resp = await fetch("https://api.pylon.money/api/mine/v1/overview");
const mineData = await resp.json();
return mineData;
}
main();
})();