Last active
September 27, 2022 16:00
-
-
Save pavelTU/5a56c940952f01e838a3ca98215eab15 to your computer and use it in GitHub Desktop.
Course on indexers: liquidity baking example
This file contains hidden or 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
| <!DOCTYPE html > | |
| </Access-Control-Allow-Origin: *> | |
| <head> | |
| <title>Sirius DEX (Liquidity Baking) stats</title> | |
| <script src="https://code.jquery.com/jquery-3.6.1.min.js"></script> | |
| </head> | |
| <body> | |
| <script> | |
| $(document).ready(function(){ | |
| $.ajax({ | |
| "url" : "https://api.tzkt.io/v1/contracts/KT1TxqZ8QtKvLu3V3JH7Gx58n7Co8pgtpQU5", | |
| "type" : "GET", | |
| "success" : function(data) { | |
| var balanceInTez = Math.floor((data.balance)/1000000); | |
| checkTimeAndSubsidy(balanceInTez); | |
| document.getElementById("balanceInTez").innerHTML = balanceInTez; | |
| }}); | |
| function checkTimeAndSubsidy(balanceInTez){ | |
| $.ajax({ | |
| "url" : "https://api.tzkt.io/v1/protocols/current", | |
| "type" : "GET", | |
| "success" : function(data) { | |
| var secondsInYear = 31556926; | |
| var timeBetweenBlocks = data.constants.timeBetweenBlocks; | |
| var lbSubsidy = (data.constants.lbSubsidy)/1000000; | |
| var yearlySubsidy = Math.floor((secondsInYear/timeBetweenBlocks) * lbSubsidy); | |
| var APY = Math.floor(yearlySubsidy / (balanceInTez * 2) * 100); | |
| document.getElementById("yearlySubsidy").innerHTML = yearlySubsidy; | |
| document.getElementById("APY").innerHTML = APY; | |
| }});}}); | |
| $.ajax({ | |
| "url" : "https://api.tzkt.io/v1/contracts/KT1TxqZ8QtKvLu3V3JH7Gx58n7Co8pgtpQU5/storage", | |
| "type" : "GET", | |
| "success" : function(data) { | |
| var balanceInTZBTC = (data.tokenPool)/100000000; | |
| document.getElementById("balanceInTZBTC").innerHTML = balanceInTZBTC; | |
| }}); | |
| </script> | |
| <div id="balanceDiv" style="display:block"> | |
| <h2> | |
| Sirius DEX tez balance is <span id="balanceInTez"></span> tez | |
| </h2> | |
| <h2> | |
| Sirius DEX tzBTC balance is <span id="balanceInTZBTC"></span> tzBTC | |
| </h2> | |
| <h2> | |
| Sirius DEX yearly subsidy is <span id="yearlySubsidy"></span> tez | |
| </h2> | |
| <h2> | |
| Sirius DEX APY in tez is ~<span id="APY"></span>% | |
| </h2> | |
| </div> | |
| </body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment