Created
November 26, 2021 14:33
-
-
Save divs1210/cd80838ac01e3fd2aebddcc3d1d83f8b to your computer and use it in GitHub Desktop.
Tinyman APRs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){ | |
function parseDollarVal(_txt) { | |
let txt = _txt.split("$")[1] || "0"; | |
let lastChar = txt[txt.length-1]; | |
let multiplier = | |
lastChar == 'M' ? 1000000 | |
: lastChar == 'K' ? 1000 | |
: 1; | |
let lastCharIsNum = lastChar >= '0' && lastChar <= '9'; | |
txt = lastCharIsNum? txt : txt.substring(0, txt.length-1); | |
return parseFloat(txt) * multiplier; | |
} | |
let table = document.querySelector(".popular-pool-table"); | |
let rows = table.querySelector(".table-body").children; | |
for(let row of rows) { | |
let TVLElement = row.children[1].querySelector(".typography--secondary-body"); | |
let TVL = parseDollarVal(TVLElement.innerText); | |
let feesElement = row.children[4].children[0]; | |
let fees = parseDollarVal(feesElement.innerText); | |
let APR = (365 * fees / TVL * 100).toFixed(2); | |
feesElement.innerText += " (" + APR + "%)"; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Details and discussion