-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81cff6f
commit 36418a1
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ <h3 class="text-center">ggAVAX Delegations</h3> | |
<div class="container w-95 border border-5 rounded pb-3"> | ||
<h3 class="text-center">ggAVAX Stats</h3> | ||
<div id="ggavax-stats" class="text-center"><div class="loader">Loading...</div></div> | ||
<div>WAVAX Balance: <span id="wavax-balance"></span></div> | ||
<div>Next Rewards Amt: <span id="next-rewards-amt"></span></div> | ||
</div> | ||
|
||
<style> | ||
|
@@ -30,17 +32,21 @@ <h3 class="text-center">ggAVAX Stats</h3> | |
</style> | ||
|
||
<script type="module"> | ||
import { utils as ethersUtils, BigNumber } from "https://esm.sh/[email protected]"; | ||
import { DEPLOYMENT } from "/deployments/selected.js"; | ||
import { GoGoPool } from "/js/gogopool.js"; | ||
import { ggAVAX } from "/js/ggavax.js"; | ||
import { ggAVAXDef, ggAVAXStatsDef } from "/js/tabulator.js"; | ||
import { formatters } from "/js/utils.js"; | ||
|
||
let GGAVAX, GGP; | ||
|
||
async function initData() { | ||
GGP = new GoGoPool(DEPLOYMENT); | ||
GGAVAX = new ggAVAX(DEPLOYMENT); | ||
await GGP.fetchContracts(); | ||
await Promise.all([GGP.fetchDashboardData(), GGAVAX.fetchCurrentDelegations()]); | ||
await Promise.all([GGP.fetchDashboardData(), GGAVAX.fetchCurrentDelegations(), GGAVAX.fetchWavaxBalance()]); | ||
console.log(GGP.dashboard); | ||
} | ||
|
||
await initData(); | ||
|
@@ -49,6 +55,10 @@ <h3 class="text-center">ggAVAX Stats</h3> | |
|
||
GGAVAX.refreshDataLoop(() => { | ||
tableCurrentDelegations.updateOrAddData(GGAVAX.currentDelegations); | ||
const wavaxEl = document.getElementById("wavax-balance"); | ||
wavaxEl.innerHTML = formatters.formatEther(GGAVAX.wavaxBalance); | ||
const nextRewardsAmtEl = document.getElementById("next-rewards-amt"); | ||
nextRewardsAmtEl.innerHTML = formatters.formatEther(calcNextRewardAmt()); | ||
}); | ||
|
||
const tableStats = new Tabulator("#ggavax-stats", ggAVAXStatsDef); | ||
|
@@ -57,6 +67,18 @@ <h3 class="text-center">ggAVAX Stats</h3> | |
// Reusing the GGP data, but just grabbing what we want for this page | ||
const data = GGP.dashboardAsTabulatorData().filter((obj) => obj.contract === "TokenggAVAX"); | ||
tableStats.updateOrAddData(data); | ||
const x = calcNextRewardAmt(); | ||
console.log(x); | ||
}); | ||
|
||
// Ugh lame figure out better way | ||
function calcNextRewardAmt() { | ||
// uint256 nextRewardsAmt = (asset.balanceOf(address(this)) + stakingTotalAssets_) - totalReleasedAssets_ - lastRewardsAmt_; | ||
const stakingTotalAssets = GGP.dashboardValue("TokenggAVAX", "stakingTotalAssets"); | ||
const totalReleasedAssets = GGP.dashboardValue("TokenggAVAX", "totalReleasedAssets"); | ||
const lastRewardsAmt = GGP.dashboardValue("TokenggAVAX", "lastRewardsAmt"); | ||
|
||
return BigNumber.from(GGAVAX.wavaxBalance).add(stakingTotalAssets).sub(totalReleasedAssets).sub(lastRewardsAmt); | ||
} | ||
</script> | ||
{{end}} |
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
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