final fix for the boosted apy
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
5faa7b0ba9
commit
f68551043e
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "ghost-dao-interface",
|
"name": "ghost-dao-interface",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.7.41",
|
"version": "0.7.42",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
30
src/constants/gatekeeper.js
Normal file
30
src/constants/gatekeeper.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { NetworkId } from "../constants";
|
||||||
|
|
||||||
|
export const amountInHistory = {
|
||||||
|
[NetworkId.TESTNET_SEPOLIA]: 0n,
|
||||||
|
[NetworkId.TESTNET_HOODI]: 0n,
|
||||||
|
[NetworkId.TESTNET_MORDOR]: 0n,
|
||||||
|
}
|
||||||
|
|
||||||
|
export const amountOutHistory = {
|
||||||
|
[NetworkId.TESTNET_SEPOLIA]: 0n,
|
||||||
|
[NetworkId.TESTNET_HOODI]: 0n,
|
||||||
|
[NetworkId.TESTNET_MORDOR]: 0n,
|
||||||
|
}
|
||||||
|
|
||||||
|
// denominator is 1e5
|
||||||
|
export const feeIn = {
|
||||||
|
[NetworkId.TESTNET_SEPOLIA]: 6900n,
|
||||||
|
[NetworkId.TESTNET_HOODI]: 6900n,
|
||||||
|
[NetworkId.TESTNET_MORDOR]: 6900n,
|
||||||
|
}
|
||||||
|
|
||||||
|
// denominator is 1e5
|
||||||
|
export const feeOut = {
|
||||||
|
[NetworkId.TESTNET_SEPOLIA]: 0n,
|
||||||
|
[NetworkId.TESTNET_HOODI]: 0n,
|
||||||
|
[NetworkId.TESTNET_MORDOR]: 0n,
|
||||||
|
}
|
||||||
|
|
||||||
|
// denominator is 1e5
|
||||||
|
export const stakeRatio = 5000n;
|
||||||
@ -1,6 +1,7 @@
|
|||||||
import { useReadContract } from "wagmi";
|
import { useReadContract } from "wagmi";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
|
|
||||||
|
import * from "../../constants/gatekeeper";
|
||||||
import { STAKING_ADDRESSES } from "../../constants/addresses";
|
import { STAKING_ADDRESSES } from "../../constants/addresses";
|
||||||
import { abi as StakingAbi } from "../../abi/GhostStaking.json";
|
import { abi as StakingAbi } from "../../abi/GhostStaking.json";
|
||||||
import { abi as GatekeeperAbi } from "../../abi/GhostGatekeeper.json";
|
import { abi as GatekeeperAbi } from "../../abi/GhostGatekeeper.json";
|
||||||
@ -23,18 +24,24 @@ export const useGatekeeperApy = (chainId) => {
|
|||||||
chainId: chainId,
|
chainId: chainId,
|
||||||
});
|
});
|
||||||
|
|
||||||
const amountIn = new DecimalBigNumber(metadata?.amountIn ?? 0n, 18);
|
const amountIn = new DecimalBigNumber(
|
||||||
const amountOut = new DecimalBigNumber(metadata?.amountOut ?? 0n, 18);
|
(metadata?.amountIn ?? 0n) + (amountInHistory[chainId] ?? 0n),
|
||||||
|
18,
|
||||||
|
);
|
||||||
|
const amountOut = new DecimalBigNumber(
|
||||||
|
(metadata?.amountOut ?? 0n) + (amountOutHistory[chainId] ?? 0n),
|
||||||
|
18,
|
||||||
|
);
|
||||||
|
|
||||||
const deployedAt = metadata?.deployedAt ?? 0;
|
const deployedAt = metadata?.deployedAt ?? 0;
|
||||||
const unixSeconds = Math.floor(Date.now() / 1000);
|
const unixSeconds = Math.floor(Date.now() / 1000);
|
||||||
const power = 365 * 86400 / (unixSeconds - deployedAt);
|
const power = 365 * 86400 / (unixSeconds - deployedAt);
|
||||||
|
|
||||||
const feeIn = new DecimalBigNumber(6900n, 2);
|
const feeInBig = new DecimalBigNumber((feeIn[chainId] ?? 0n), 5);
|
||||||
const feeOut = new DecimalBigNumber(6900n, 2);
|
const feeOutBig = new DecimalBigNumber((feeOut[chainId] ?? 0n), 5);
|
||||||
const stakeRatio = new DecimalBigNumber(69000n, 3);
|
const stakeRatioBig = new DecimalBigNumber((stakeRatio[chainId] ?? 0n), 5);
|
||||||
|
|
||||||
const numerator = amountIn.mul(feeIn).add(amountOut.mul(feeOut));
|
const numerator = amountIn.mul(feeInBig).add(amountOut.mul(feeOutBig));
|
||||||
const denominator = amountIn.mul(stakeRatio).sub(amountOut.mul(stakeRatio));
|
const denominator = amountIn.mul(stakeRatio).sub(amountOut.mul(stakeRatio));
|
||||||
|
|
||||||
let apyInner = Infinity;
|
let apyInner = Infinity;
|
||||||
@ -50,7 +57,7 @@ export const useGatekeeperApy = (chainId) => {
|
|||||||
return { gatekeepedApy: apyInner, apyInner };
|
return { gatekeepedApy: apyInner, apyInner };
|
||||||
}
|
}
|
||||||
const result = Number(numerator.div(denominator).toString());
|
const result = Number(numerator.div(denominator).toString());
|
||||||
const gatekeepedApy = Math.pow(1 + result, power);
|
const gatekeepedApy = Math.pow(1 + result, power) * 100;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
gatekeepedApy: apyInner + gatekeepedApy + (apyInner * gatekeepedApy) / 100,
|
gatekeepedApy: apyInner + gatekeepedApy + (apyInner * gatekeepedApy) / 100,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user