replaced subgraph with ponder
This commit is contained in:
parent
5e6e21878c
commit
ba64e725dc
45 changed files with 386 additions and 7275 deletions
|
|
@ -211,16 +211,17 @@ watchEffect(() => {
|
|||
stakeSlots.value = (supplyFreeze.value * 1000)?.toFixed(2);
|
||||
});
|
||||
|
||||
// const stakeAbleHarbAmount = computed(() => statCollection.harbTotalSupply / 5n);
|
||||
// const stakeAbleHarbAmount = computed(() => statCollection.kraikenTotalSupply / 5n);
|
||||
//war das mal so, wurde das geändert --> funktioniert nicht mehr
|
||||
// const minStake = computed(() => stakeAbleHarbAmount.value / 600n);
|
||||
|
||||
|
||||
const tokenIssuance = computed(() => {
|
||||
if (statCollection.harbTotalSupply === 0n) {
|
||||
if (statCollection.kraikenTotalSupply === 0n) {
|
||||
return 0n;
|
||||
}
|
||||
|
||||
return (statCollection.nettoToken7d / statCollection.harbTotalSupply) * 100n;
|
||||
return (statCollection.nettoToken7d / statCollection.kraikenTotalSupply) * 100n;
|
||||
});
|
||||
|
||||
function getMinFloorTax() {
|
||||
|
|
@ -280,7 +281,7 @@ onMounted(async () => {
|
|||
}
|
||||
});
|
||||
// async function getGraphData(): Promise<Array<any>> {
|
||||
// let res = await axios.post("https://api.studio.thegraph.com/query/47986/harb/version/latest", {
|
||||
// let res = await axios.post("http://127.0.0.1:42069/graphql", {
|
||||
// query: "query MyQuery {\n positions {\n id\n lastTaxTime\n owner\n share\n status\n taxRate\n creationTime\n }\n}",
|
||||
// });
|
||||
// return res.data.data.positions;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ console.log("minStake", minStake.value);
|
|||
return formatBigIntDivision(minStake.value, 10n ** 18n);
|
||||
});
|
||||
|
||||
const stakeAbleHarbAmount = computed(() => statCollection.harbTotalSupply / 5n);
|
||||
const stakeAbleHarbAmount = computed(() => statCollection.kraikenTotalSupply / 5n);
|
||||
|
||||
const minStake = computed(() => stakeAbleHarbAmount.value / 600n);
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ const statCollection = useStatCollection();
|
|||
const snatchPositions = computed(() => {
|
||||
if (
|
||||
bigInt2Number(statCollection.outstandingStake, 18) + stake.stakingAmountNumber <=
|
||||
bigInt2Number(statCollection.harbTotalSupply, 18) * 0.2
|
||||
bigInt2Number(statCollection.kraikenTotalSupply, 18) * 0.2
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ if (
|
|||
const difference =
|
||||
bigInt2Number(statCollection.outstandingStake, 18) +
|
||||
stake.stakingAmountNumber -
|
||||
bigInt2Number(statCollection.harbTotalSupply, 18) * 0.2;
|
||||
bigInt2Number(statCollection.kraikenTotalSupply, 18) * 0.2;
|
||||
console.log("difference", difference);
|
||||
|
||||
//Division ohne Rest, um zu schauen wie viele Positionen gesnatched werden könnten
|
||||
|
|
|
|||
|
|
@ -162,14 +162,14 @@ async function loadActivePositionData() {
|
|||
|
||||
const multiplier =
|
||||
Number(formatUnits(props.position.totalSupplyInit, 18)) /
|
||||
Number(formatUnits(statCollection.harbTotalSupply, 18));
|
||||
Number(formatUnits(statCollection.kraikenTotalSupply, 18));
|
||||
console.log("props.position.totalSupplyInit", props.position.totalSupplyInit);
|
||||
|
||||
console.log("multiplier", multiplier);
|
||||
|
||||
profit.value =
|
||||
Number(formatUnits(statCollection.harbTotalSupply, 18)) * multiplier -
|
||||
Number(formatUnits(statCollection.harbTotalSupply, 18));
|
||||
Number(formatUnits(statCollection.kraikenTotalSupply, 18)) * multiplier -
|
||||
Number(formatUnits(statCollection.kraikenTotalSupply, 18));
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
|
|
|||
|
|
@ -108,32 +108,37 @@ const tresholdValue = computed(() => {
|
|||
|
||||
export async function loadActivePositions() {
|
||||
logger.info(`loadActivePositions for chain: ${chainData.value?.path}`);
|
||||
if (!chainData.value?.thegraph) {
|
||||
if (!chainData.value?.graphql) {
|
||||
return [];
|
||||
}
|
||||
console.log("chainData.value?.thegraph", chainData.value?.thegraph);
|
||||
console.log("chainData.value?.graphql", chainData.value?.graphql);
|
||||
|
||||
const res = await axios.post(chainData.value?.thegraph, {
|
||||
query: `query MyQuery {
|
||||
positions(where: {status: Active}, orderBy: taxRate, orderDirection: asc) {
|
||||
id
|
||||
lastTaxTime
|
||||
owner
|
||||
payout
|
||||
share
|
||||
harbDeposit
|
||||
snatched
|
||||
status
|
||||
taxPaid
|
||||
taxRate
|
||||
totalSupplyEnd
|
||||
totalSupplyInit
|
||||
}
|
||||
}`,
|
||||
const res = await axios.post(chainData.value?.graphql, {
|
||||
query: `query ActivePositions {
|
||||
positionss(where: { status: "Active" }, orderBy: "taxRate", orderDirection: "asc", limit: 1000) {
|
||||
items {
|
||||
id
|
||||
lastTaxTime
|
||||
owner
|
||||
payout
|
||||
share
|
||||
kraikenDeposit
|
||||
snatched
|
||||
status
|
||||
taxPaid
|
||||
taxRate
|
||||
totalSupplyEnd
|
||||
totalSupplyInit
|
||||
}
|
||||
}
|
||||
}`,
|
||||
});
|
||||
console.log("res", res.data);
|
||||
|
||||
return res.data.data.positions as Position[];
|
||||
const items = res.data?.data?.positionss?.items ?? [];
|
||||
return items.map((item: any) => ({
|
||||
...item,
|
||||
harbDeposit: item.kraikenDeposit ?? "0",
|
||||
})) as Position[];
|
||||
}
|
||||
|
||||
function formatId(id: Hex) {
|
||||
|
|
@ -144,33 +149,38 @@ function formatId(id: Hex) {
|
|||
|
||||
export async function loadMyClosedPositions(account: GetAccountReturnType) {
|
||||
logger.info(`loadMyClosedPositions for chain: ${chainData.value?.path}`);
|
||||
if (!chainData.value?.thegraph) {
|
||||
if (!chainData.value?.graphql) {
|
||||
return [];
|
||||
}
|
||||
const res = await axios.post(chainData.value?.thegraph, {
|
||||
query: `query MyQuery {
|
||||
positions(where: {status: Closed, owner: "${account.address?.toLowerCase()}"}) {
|
||||
id
|
||||
lastTaxTime
|
||||
owner
|
||||
payout
|
||||
share
|
||||
harbDeposit
|
||||
snatched
|
||||
status
|
||||
taxPaid
|
||||
taxRate
|
||||
totalSupplyEnd
|
||||
totalSupplyInit
|
||||
}
|
||||
}`,
|
||||
const res = await axios.post(chainData.value?.graphql, {
|
||||
query: `query ClosedPositions {
|
||||
positionss(where: { status: "Closed", owner: "${account.address?.toLowerCase()}" }, limit: 1000) {
|
||||
items {
|
||||
id
|
||||
lastTaxTime
|
||||
owner
|
||||
payout
|
||||
share
|
||||
kraikenDeposit
|
||||
snatched
|
||||
status
|
||||
taxPaid
|
||||
taxRate
|
||||
totalSupplyEnd
|
||||
totalSupplyInit
|
||||
}
|
||||
}
|
||||
}`,
|
||||
});
|
||||
if (res.data.errors?.length > 0) {
|
||||
console.error("todo nur laden, wenn eingeloggt");
|
||||
return [];
|
||||
}
|
||||
const positions: Position[] = res.data.data.positions;
|
||||
return positions;
|
||||
const items = res.data?.data?.positionss?.items ?? [];
|
||||
return items.map((item: any) => ({
|
||||
...item,
|
||||
harbDeposit: item.kraikenDeposit ?? "0",
|
||||
})) as Position[];
|
||||
}
|
||||
|
||||
export async function loadPositions() {
|
||||
|
|
|
|||
|
|
@ -8,72 +8,80 @@ import type { WatchBlocksReturnType } from "viem";
|
|||
import { bigInt2Number } from "@/utils/helper";
|
||||
const demo = sessionStorage.getItem("demo") === "true";
|
||||
|
||||
interface statsCollection {
|
||||
burnNextHourProjected: bigint;
|
||||
burnedLastDay: bigint;
|
||||
burnedLastWeek: bigint;
|
||||
interface StatsRecord {
|
||||
burnNextHourProjected: string;
|
||||
burnedLastDay: string;
|
||||
burnedLastWeek: string;
|
||||
id: string;
|
||||
lastUpdatedHour: number;
|
||||
mintNextHourProjected: bigint;
|
||||
mintedLastDay: bigint;
|
||||
mintedLastWeek: bigint;
|
||||
outstandingStake: bigint;
|
||||
harbTotalSupply: bigint;
|
||||
stakeTotalSupply: bigint;
|
||||
mintNextHourProjected: string;
|
||||
mintedLastDay: string;
|
||||
mintedLastWeek: string;
|
||||
outstandingStake: string;
|
||||
kraikenTotalSupply: string;
|
||||
stakeTotalSupply: string;
|
||||
ringBufferPointer: number;
|
||||
totalBurned: bigint;
|
||||
totalMinted: bigint;
|
||||
totalBurned: string;
|
||||
totalMinted: string;
|
||||
}
|
||||
|
||||
const rawStatsCollections = ref<Array<statsCollection>>([]);
|
||||
const rawStatsCollections = ref<Array<StatsRecord>>([]);
|
||||
const loading = ref(false);
|
||||
const initialized = ref(false);
|
||||
|
||||
export async function loadStatsCollection() {
|
||||
logger.info(`loadStatsCollection for chain: ${chainData.value?.path}`);
|
||||
if (!chainData.value?.thegraph) {
|
||||
if (!chainData.value?.graphql) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const res = await axios.post(chainData.value?.thegraph, {
|
||||
query: `query MyQuery {
|
||||
stats_collection {
|
||||
burnNextHourProjected
|
||||
burnedLastDay
|
||||
burnedLastWeek
|
||||
id
|
||||
lastUpdatedHour
|
||||
mintNextHourProjected
|
||||
mintedLastDay
|
||||
mintedLastWeek
|
||||
outstandingStake
|
||||
harbTotalSupply
|
||||
stakeTotalSupply
|
||||
ringBufferPointer
|
||||
totalBurned
|
||||
totalMinted
|
||||
}
|
||||
}`,
|
||||
const res = await axios.post(chainData.value?.graphql, {
|
||||
query: `query StatsQuery {
|
||||
stats(id: "0x01") {
|
||||
burnNextHourProjected
|
||||
burnedLastDay
|
||||
burnedLastWeek
|
||||
id
|
||||
mintNextHourProjected
|
||||
mintedLastDay
|
||||
mintedLastWeek
|
||||
outstandingStake
|
||||
kraikenTotalSupply
|
||||
stakeTotalSupply
|
||||
ringBufferPointer
|
||||
totalBurned
|
||||
totalMinted
|
||||
}
|
||||
}`,
|
||||
});
|
||||
console.groupEnd();
|
||||
return res.data?.data?.stats_collection;
|
||||
|
||||
const stats = res.data?.data?.stats as StatsRecord | undefined;
|
||||
if (!stats) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [{ ...stats, kraikenTotalSupply: stats.kraikenTotalSupply }];
|
||||
}
|
||||
|
||||
const profit7d = computed(() => {
|
||||
if (!statsCollection.value) {
|
||||
return 0n;
|
||||
}
|
||||
return (
|
||||
(BigInt(statsCollection.value?.mintedLastWeek) - BigInt(statsCollection.value?.burnedLastWeek)) /
|
||||
(BigInt(statsCollection.value?.totalMinted) - BigInt(statsCollection.value?.totalBurned))
|
||||
);
|
||||
const mintedLastWeek = BigInt(statsCollection.value.mintedLastWeek);
|
||||
const burnedLastWeek = BigInt(statsCollection.value.burnedLastWeek);
|
||||
const totalMinted = BigInt(statsCollection.value.totalMinted);
|
||||
const totalBurned = BigInt(statsCollection.value.totalBurned);
|
||||
const denominator = totalMinted - totalBurned;
|
||||
if (denominator === 0n) {
|
||||
return 0n;
|
||||
}
|
||||
return (mintedLastWeek - burnedLastWeek) / denominator;
|
||||
});
|
||||
const nettoToken7d = computed(() => {
|
||||
if (!statsCollection.value) {
|
||||
return 0n;
|
||||
}
|
||||
|
||||
return BigInt(statsCollection.value?.mintedLastWeek) - BigInt(statsCollection.value.burnedLastWeek);
|
||||
return BigInt(statsCollection.value.mintedLastWeek) - BigInt(statsCollection.value.burnedLastWeek);
|
||||
});
|
||||
|
||||
const statsCollection = computed(() => {
|
||||
|
|
@ -96,9 +104,9 @@ const outstandingStake = computed(() => {
|
|||
}
|
||||
});
|
||||
|
||||
const harbTotalSupply = computed(() => {
|
||||
const kraikenTotalSupply = computed(() => {
|
||||
if (rawStatsCollections.value?.length > 0) {
|
||||
return BigInt(rawStatsCollections.value[0].harbTotalSupply);
|
||||
return BigInt(rawStatsCollections.value[0].kraikenTotalSupply);
|
||||
} else {
|
||||
return 0n;
|
||||
}
|
||||
|
|
@ -115,7 +123,10 @@ const stakeTotalSupply = computed(() => {
|
|||
//Total Supply Change / 7d=mintedLastWeek−burnedLastWeek
|
||||
const totalSupplyChange7d = computed(() => {
|
||||
if (rawStatsCollections.value?.length > 0) {
|
||||
return BigInt(rawStatsCollections.value[0].mintedLastWeek - rawStatsCollections.value[0].burnedLastWeek);
|
||||
return (
|
||||
BigInt(rawStatsCollections.value[0].mintedLastWeek) -
|
||||
BigInt(rawStatsCollections.value[0].burnedLastWeek)
|
||||
);
|
||||
} else {
|
||||
return 0n;
|
||||
}
|
||||
|
|
@ -123,15 +134,18 @@ const totalSupplyChange7d = computed(() => {
|
|||
|
||||
//totalsupply Change7d / harbtotalsupply
|
||||
const inflation7d = computed(() => {
|
||||
if (rawStatsCollections.value?.length > 0 && rawStatsCollections.value[0].harbTotalSupply > 0) {
|
||||
return BigInt(rawStatsCollections.value[0].mintedLastWeek - rawStatsCollections.value[0].burnedLastWeek);
|
||||
if (rawStatsCollections.value?.length > 0 && BigInt(rawStatsCollections.value[0].kraikenTotalSupply) > 0n) {
|
||||
return (
|
||||
BigInt(rawStatsCollections.value[0].mintedLastWeek) -
|
||||
BigInt(rawStatsCollections.value[0].burnedLastWeek)
|
||||
);
|
||||
} else {
|
||||
return 0n;
|
||||
}
|
||||
});
|
||||
|
||||
const stakeableSupply = computed(() => {
|
||||
if (rawStatsCollections.value?.length > 0 && rawStatsCollections.value[0].harbTotalSupply > 0) {
|
||||
if (rawStatsCollections.value?.length > 0 && BigInt(rawStatsCollections.value[0].kraikenTotalSupply) > 0n) {
|
||||
console.log("rawStatsCollections.value[0]", rawStatsCollections.value[0]);
|
||||
|
||||
return stakeTotalSupply.value / 5n;
|
||||
|
|
@ -142,7 +156,7 @@ const stakeableSupply = computed(() => {
|
|||
|
||||
//maxSlots
|
||||
const maxSlots = computed(() => {
|
||||
if (rawStatsCollections.value?.length > 0 && rawStatsCollections.value[0].harbTotalSupply > 0) {
|
||||
if (rawStatsCollections.value?.length > 0 && BigInt(rawStatsCollections.value[0].kraikenTotalSupply) > 0n) {
|
||||
console.log("rawStatsCollections.value[0]", rawStatsCollections.value[0]);
|
||||
|
||||
return (bigInt2Number(stakeTotalSupply.value, 18) * 0.2) / 100;
|
||||
|
|
@ -206,7 +220,7 @@ export function useStatCollection() {
|
|||
nettoToken7d,
|
||||
inflation7d,
|
||||
outstandingStake,
|
||||
harbTotalSupply,
|
||||
kraikenTotalSupply,
|
||||
stakeTotalSupply,
|
||||
totalSupplyChange7d,
|
||||
initialized,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { getAllowance, HarbContract, getNonce } from "@/contracts/harb";
|
|||
import logger from "@/utils/logger";
|
||||
import { setHarbContract } from "@/contracts/harb";
|
||||
import { setStakeContract } from "@/contracts/stake";
|
||||
import {chainsData} from "@/config"
|
||||
import {chainsData, DEFAULT_CHAIN_ID} from "@/config"
|
||||
|
||||
const balance = ref<GetBalanceReturnType>({
|
||||
value: 0n,
|
||||
|
|
@ -28,8 +28,10 @@ const account = ref<GetAccountReturnType>({
|
|||
status: "disconnected",
|
||||
});
|
||||
|
||||
const selectedChainId = computed(() => account.value.chainId ?? DEFAULT_CHAIN_ID);
|
||||
|
||||
export const chainData = computed(() => {
|
||||
return chainsData.find((obj) => obj.id === account.value.chainId)
|
||||
return chainsData.find((obj) => obj.id === selectedChainId.value)
|
||||
})
|
||||
|
||||
let unwatch: any = null;
|
||||
|
|
|
|||
|
|
@ -1,31 +1,35 @@
|
|||
const LOCAL_PONDER_URL = "http://127.0.0.1:42069/graphql";
|
||||
|
||||
export const DEFAULT_CHAIN_ID = Number(import.meta.env.VITE_DEFAULT_CHAIN_ID ?? 84532);
|
||||
|
||||
export const chainsData = [
|
||||
{
|
||||
//sepolia
|
||||
// sepolia
|
||||
id: 11155111,
|
||||
thegraph: "https://api.studio.thegraph.com/query/71271/harb/v0.0.50",
|
||||
graphql: import.meta.env.VITE_PONDER_SEPOLIA ?? "",
|
||||
path: "sepolia",
|
||||
stake: "0xCd21a41a137BCAf8743E47D048F57D92398f7Da9",
|
||||
harb: "0x087F256D11fe533b0c7d372e44Ee0F9e47C89dF9",
|
||||
uniswap: "https://app.uniswap.org/swap?chain=mainnet&inputCurrency=NATIVE"
|
||||
}, {
|
||||
//base-sepolia
|
||||
// base-sepolia (local dev default)
|
||||
id: 84532,
|
||||
thegraph: "https://api.studio.thegraph.com/query/71271/harb-base-sepolia/v0.0.12",
|
||||
graphql: import.meta.env.VITE_PONDER_BASE_SEPOLIA_LOCAL_FORK ?? LOCAL_PONDER_URL,
|
||||
path: "sepoliabase",
|
||||
stake: "0xe28020BCdEeAf2779dd47c670A8eFC2973316EE2",
|
||||
harb: "0x22c264Ecf8D4E49D1E3CabD8DD39b7C4Ab51C1B8",
|
||||
uniswap: "https://app.uniswap.org/swap?chain=mainnet&inputCurrency=NATIVE"
|
||||
},
|
||||
{
|
||||
//base
|
||||
// base mainnet
|
||||
id: 8453,
|
||||
thegraph: import.meta.env.VITE_BASE_URL,
|
||||
graphql: import.meta.env.VITE_PONDER_BASE ?? "",
|
||||
path: "base",
|
||||
stake: "0xed70707fab05d973ad41eae8d17e2bcd36192cfc",
|
||||
harb: "0x45caa5929f6ee038039984205bdecf968b954820",
|
||||
uniswap: "https://app.uniswap.org/swap?chain=mainnet&inputCurrency=NATIVE"
|
||||
},
|
||||
]
|
||||
];
|
||||
|
||||
export function getChain(id:number){
|
||||
return chainsData.find((obj) => obj.id === id)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ const minStakeAmount = computed(() => {
|
|||
return formatBigIntDivision(minStake.value, 10n ** 18n);
|
||||
});
|
||||
|
||||
const stakeAbleHarbAmount = computed(() => statCollection.harbTotalSupply / 5n);
|
||||
const stakeAbleHarbAmount = computed(() => statCollection.kraikenTotalSupply / 5n);
|
||||
|
||||
const minStake = computed(() => stakeAbleHarbAmount.value / 600n);
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ const statCollection = useStatCollection();
|
|||
const snatchPositions = computed(() => {
|
||||
if (
|
||||
bigInt2Number(statCollection.outstandingStake, 18) + stake.stakingAmountNumber <=
|
||||
bigInt2Number(statCollection.harbTotalSupply, 18) * 0.2
|
||||
bigInt2Number(statCollection.kraikenTotalSupply, 18) * 0.2
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ const snatchPositions = computed(() => {
|
|||
const difference =
|
||||
bigInt2Number(statCollection.outstandingStake, 18) +
|
||||
stake.stakingAmountNumber -
|
||||
bigInt2Number(statCollection.harbTotalSupply, 18) * 0.2;
|
||||
bigInt2Number(statCollection.kraikenTotalSupply, 18) * 0.2;
|
||||
console.log("difference", difference);
|
||||
|
||||
//Division ohne Rest, um zu schauen wie viele Positionen gesnatched werden könnten
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue