Skip to content

Commit

Permalink
🐛 still fixing NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
kamikazebr committed May 29, 2024
1 parent 0469a7a commit 85510fb
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Badge, StatusBadge } from "@/components";
import { EthAddress } from "@/components";
import { cvStrategyABI } from "@/src/generated";
import { Abi, Address, createPublicClient, http } from "viem";
import { Abi, Address, createPublicClient, formatUnits, http } from "viem";
import { getChain } from "@/configs/chainServer";
import { ConvictionBarChart } from "@/components/Charts/ConvictionBarChart";
import { initUrqlClient, queryByChain } from "@/providers/urql";
Expand Down Expand Up @@ -171,23 +171,43 @@ export default async function Proposal({
// console.log(convictionLast);
console.log("convictionLast: %s", convictionLast);

const thresholdPct = calculatePercentageDecimals(
threshold,
maxCVSupply,
tokenDecimals,
);
// const thresholdPct = calculatePercentageDecimals(
// threshold,
// maxCVSupply,
// tokenDecimals,
// );

const totalSupportPct = calculatePercentageDecimals(
stakedAmount,
totalEffectiveActivePoints,
tokenDecimals,
);
const thresholdPct =
(parseFloat(formatUnits(threshold, tokenDecimals)) /
parseFloat(formatUnits(maxCVSupply, tokenDecimals))) *
100;

const currentConvictionPct = calculatePercentageDecimals(
updateConvictionLast,
maxCVSupply,
tokenDecimals,
);
console.log("thresholdPct: %s", thresholdPct);

// console.log("ff: %s", ff);

// const totalSupportPct = calculatePercentageDecimals(
// stakedAmount,
// totalEffectiveActivePoints,
// tokenDecimals,
// );

const totalSupportPct =
(parseFloat(formatUnits(stakedAmount, tokenDecimals)) /
parseFloat(formatUnits(totalEffectiveActivePoints, tokenDecimals))) *
100;

console.log("totalSupportPct: %s", totalSupportPct);
// const currentConvictionPct = calculatePercentageDecimals(
// updateConvictionLast,
// maxCVSupply,
// tokenDecimals,
// );

const currentConvictionPct =
(parseFloat(formatUnits(updateConvictionLast, tokenDecimals)) /
parseFloat(formatUnits(maxCVSupply, tokenDecimals))) *
100;

console.log("currentConviction: %s", currentConvictionPct);

Expand Down
4 changes: 2 additions & 2 deletions apps/web/components/Proposals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ export function Proposals({
inputAllocatedTokens,
memberActivatedPoints,
);
console.log("inputAllocatedTokens: %s", inputAllocatedTokens);
console.log("memberSupportedProposalsPct: %s", memberSupportedProposalsPct);
// console.log("inputAllocatedTokens: %s", inputAllocatedTokens);
// console.log("memberSupportedProposalsPct: %s", memberSupportedProposalsPct);

const memberPoolWeight = calculatePercentage(
memberActivatedPoints,
Expand Down
2 changes: 2 additions & 0 deletions apps/web/utils/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ function calculatePercentageDecimals(
decimals,
);

console.log(percentage);

const formattedPercentage = dn.format(percentage, 2);

// console.log(formattedPercentage);
Expand Down
12 changes: 6 additions & 6 deletions pkg/subgraph/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ schema:
dataSources:
- kind: ethereum/contract
name: RegistryFactory
network: sepolia
network: localhost
context:
chainId:
type: Int
data: 11155111
data: 1337
source:
address: "0x054e83880b6151513edeae79eb1b6bc6a3872df4"
address: "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707"
abi: RegistryFactory
startBlock: 5997994
startBlock: 0
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand All @@ -37,7 +37,7 @@ dataSources:
templates:
- kind: ethereum/contract
name: RegistryCommunity
network: sepolia
network: localhost
source:
abi: RegistryCommunity
mapping:
Expand Down Expand Up @@ -99,7 +99,7 @@ templates:

- kind: ethereum/contract
name: CVStrategy
network: sepolia
network: localhost
source:
abi: CVStrategy
mapping:
Expand Down

0 comments on commit 85510fb

Please sign in to comment.