-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
95 lines (87 loc) · 15.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html>
<head>
<title>Pool Together V3 to V4 Flippening</title>
<meta name=viewport content="width=device-width, initial-scale=1" />
<script src=https://cdn.ethers.io/lib/ethers-5.2.umd.min.js type=application/javascript></script>
<style>body,html{height:100%;margin:0;font:400 15px/1.8 "Lato",sans-serif;color:#777}a{text-decoration:none;color:#fff}.bgimg-1,.bgimg-2,.bgimg-3{position:relative;background-position:center;background-repeat:no-repeat;background-size:cover}.bgimg-2{background-image:url("background.png");height:100%}.bgimg-1{background:linear-gradient(149deg,rgba(111,22,172,1) 0,rgba(66,181,235,1) 51%,rgba(199,0,255,1) 100%);height:100%}.caption{position:absolute;left:0;top:3%;width:100%;text-align:center;color:#000}.caption span.border{color:#fff;padding:18px;font-size:6vmin;letter-spacing:10px}.caption2 span.border{background-color:#4f28a2;border-radius:10000px;color:#fff;padding:18px;font-size:3.2vmin;letter-spacing:8px;cursor:pointer}.apynumba{display:inline-block;font-size:5vmin;}.v{display:inline-block;font-size:4.2vmin;color: #e5b4f5}h3{letter-spacing:5px;text-transform:uppercase;font:10px "Lato",sans-serif;color:rgb(129, 113, 113)}
#myProgress {
width: 60%;
text-align: center;
background-color: rgb(226, 223, 223);
border-radius: 20px;
}
#myBar {
width: 1%;
height: 40px;
color: white;
font-size: 22px;
background-color: transparent;
border-radius: 20px;
}</style>
</head>
<body>
<script>
function numberWithCommas(x){return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",");}
const calcApy=async()=>{let json={}
let amount=0;let tvl=0;let name="";const mainAPI="https://pooltogether-api.com/pools/1.json"
const polyAPI="https://pooltogether-api.com/pools/137.json";const celoAPI="https://pooltogether-api.com/pools/42220.json";
const avaxEndpoint = "https://api.avax.network/ext/bc/C/rpc";const endpoint="https://polygon-mainnet.g.alchemy.com/v2/Km46Q-DZ04ftPfKNgPwaP6cp957PJHNl";const mainEndpoint="https://mainnet.infura.io/v3/657600e9d48d467aaa0cbee1bb5ce0d9";const provider=new ethers.providers.JsonRpcProvider(endpoint);const mainProvider=new ethers.providers.JsonRpcProvider(mainEndpoint);const avaxProvider=new ethers.providers.JsonRpcProvider(avaxEndpoint);const polyTicket="0x6a304dFdb9f808741244b6bfEe65ca7B3b3A6076";const avaxTicket="0xB27f379C050f6eD0973A01667458af6eCeBc1d90";const ethTicket="0xdd4d117723C257CEe402285D3aCF218E9A8236E1";const contractAbi=JSON.parse('[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"},{"internalType":"address","name":"_controller","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"delegate","type":"address"}],"name":"Delegated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTotalSupplyTwab","type":"tuple"}],"name":"NewTotalSupplyTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"indexed":false,"internalType":"struct ObservationLib.Observation","name":"newTwab","type":"tuple"}],"name":"NewUserTwab","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint8","name":"decimals","type":"uint8"},{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"TicketInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerBurnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"controllerDelegateFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"controllerMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"delegateOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_newDelegate","type":"address"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"delegateWithSignature","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getAccountDetails","outputs":[{"components":[{"internalType":"uint208","name":"balance","type":"uint208"},{"internalType":"uint24","name":"nextTwabIndex","type":"uint24"},{"internalType":"uint24","name":"cardinality","type":"uint24"}],"internalType":"struct TwabLib.AccountDetails","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_startTime","type":"uint64"},{"internalType":"uint64","name":"_endTime","type":"uint64"}],"name":"getAverageBalanceBetween","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageBalancesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_startTimes","type":"uint64[]"},{"internalType":"uint64[]","name":"_endTimes","type":"uint64[]"}],"name":"getAverageTotalSuppliesBetween","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getBalanceAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getBalancesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_targets","type":"uint64[]"}],"name":"getTotalSuppliesAt","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_target","type":"uint64"}],"name":"getTotalSupplyAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint16","name":"_index","type":"uint16"}],"name":"getTwab","outputs":[{"components":[{"internalType":"uint224","name":"amount","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"internalType":"struct ObservationLib.Observation","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]');const contract=new ethers.Contract(polyTicket,contractAbi,provider);const ethContract=new ethers.Contract(ethTicket,contractAbi,mainProvider);const avaxContract=new ethers.Contract(avaxTicket,contractAbi,avaxProvider);let[polySupply,ethSupply,avaxSupply,result,resultPoly,resultCelo]=await Promise.all([contract.totalSupply(),ethContract.totalSupply(),avaxContract.totalSupply(),fetch(mainAPI),fetch(polyAPI),fetch(celoAPI)])
polySupply=parseFloat(ethers.utils.formatUnits(polySupply,"mwei"));ethSupply=parseFloat(ethers.utils.formatUnits(ethSupply,"mwei"));avaxSupply=parseFloat(ethers.utils.formatUnits(avaxSupply,"mwei"));let resultJson=await result.json();let resultPolyJson=await resultPoly.json();json=resultJson.concat(resultPolyJson);let resultCeloJson=await resultCelo.json();json=json.concat(resultCeloJson);
for(let x in json){amount=parseFloat(json[x].prizePool.totalValueLockedUsd)
name=json[x].tokens.underlyingToken.symbol;tvl+=amount;console.log(name," ",amount)}
console.log("v3 total: ",tvl);let totalDeposits=polySupply+ethSupply+avaxSupply;console.log("v4 total: ",totalDeposits);flippened=parseInt((totalDeposits/tvl)*100);
let div3=document.getElementById("div3");let v3=document.getElementById("v3");let v4=document.getElementById("v4");v3.innerHTML = "V4 ";div3.innerHTML=numberWithCommas(parseInt(tvl));let div=document.getElementById("apynumba");v4.innerHTML = "V3";div.innerHTML=numberWithCommas(parseInt(totalDeposits));move(flippened);};calcApy();
</script>
<div class=bgimg-1>
<div class=bgimg-2>
<div class=caption><span class="border" style="
border-width: medium;
font-weight: 600;
">
PoolTogether V4 FTW</span><br><br>
<center><br>
<div id="myProgress">
<div id="myBar"></div>
</div><br>
<span class=border><div id="v3" class=v></div><div id=apynumba class=apynumba></div> <div id="v4" class=v></div>
<div id=div3 class=apynumba></div>
</span><br /><br /><br />
<div class=caption2>
<span class=border><a href=https://v4.pooltogether.com/>DEPOSIT NOW</a></span>
</center>
</div>
</div>
</div>
</div>
<p style="padding:5px 15px">
* Sourced from pooltogether-api.com, Alchemy, and Infura
</p><script>
var i = 50;
var i = 0;
function move(ratio) {
var elem = document.getElementById("myBar");
elem.style.backgroundColor = "#350f7a"
console.log("ratio: ",ratio)
if(ratio > 100){ratio=100}
console.log("ok")
if (i == 0) {
i = 1;
var elem = document.getElementById("myBar");
var width = 1;
var id = setInterval(frame, 10);
function frame() {
if (width >= ratio) {
clearInterval(id);
i = 0;
} else {
width++;
elem.style.width = width + "%";
elem.innerHTML = width + "%";
}
}
}
}
</script>
</body>
</html>