Skip to content

Commit

Permalink
some rankings
Browse files Browse the repository at this point in the history
  • Loading branch information
MeatDeveloper committed Dec 10, 2023
1 parent 8ff5771 commit 970093e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/dashboard/holders/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export default function PageDashboardHolders() {

<ul>
{Array.isArray(topHolders?.result) && topHolders.result?.map((holder : any) => (
<li key={holder.TokenHolderAddress} className="flex justify-between">
<a href={`https://snowtrace.io/address/${holder.address}`} target="_blank" rel="noreferrer">
<li key={holder?.TokenHolderAddress} className="flex justify-between">
<a href={`https://snowtrace.io/address/${holder?.TokenHolderAddress}`} target="_blank" rel="noreferrer">
<RenderName address={holder?.TokenHolderAddress} chainId={chain?.id} />
</a>
{trimFormattedBalance(String(Number(holder?.TokenHolderQuantity) / 1e6)?.toString(), 0)} {"MEAT"}
Expand Down
11 changes: 7 additions & 4 deletions app/dashboard/liquidityProviders/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ import { lpAddress } from "@/config/site"
import useSWR from "swr"
import RenderName from "@/components/blockchain/render-name"
import { useNetwork } from "wagmi"
import { trimFormattedBalance } from "@/lib/utils"
import { trimFormattedBalance, filterAddresses } from "@/lib/utils"

const fetcher = (url: string) => fetch(url).then((res) => res.json())
export default function PageDashboardLPers() {
const { chain } = useNetwork()
const endpoint = `https://api.routescan.io/v2/network/mainnet/evm/43114/etherscan/api?module=token&action=tokenholderlist&contractaddress=${lpAddress}&page=1&offset=25&apikey=YourApiKeyToken`
const { data: topHolders } = useSWR(endpoint, fetcher);



return (
<motion.div
animate="show"
Expand All @@ -29,9 +32,9 @@ export default function PageDashboardLPers() {
<p className="text-sm font-light text-gray-400">top liquidity providers</p>

<ul>
{Array.isArray(topHolders?.result) && topHolders.result?.map((holder : any) => (
<li key={holder.TokenHolderAddress} className="flex justify-between">
<a href={`https://snowtrace.io/address/${holder.address}`} target="_blank" rel="noreferrer">
{Array.isArray(topHolders?.result) && topHolders.result.map((holder : any) => (
<li key={holder?.TokenHolderAddress} className="flex justify-between">
<a href={`https://snowtrace.io/address/${holder?.TokenHolderAddress}`} target="_blank" rel="noreferrer">
<RenderName address={holder?.TokenHolderAddress} chainId={chain?.id} />
</a>
{trimFormattedBalance(String(Number(holder?.TokenHolderQuantity) / 1e6)?.toString(), 0)} {"MEAT"}
Expand Down
13 changes: 13 additions & 0 deletions lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,16 @@ export function trimFormattedBalance(
export function truncateEthAddress(address: string) {
return `${address.slice(0, 6)}...${address.slice(-4)}`
}

interface Response {
TokenHolderAddress: string
TokenHolderQuantity: string
}

export function filterAddresses(addresses: Response[]) {
const addressesToIgnore = ["0x2fD2C0E235D6F3aA42c328415D8C7266572256A4".toLowerCase(), "0x665d1C8337F1035cfBe13DD94bB669110b975f5F".toLowerCase(), "0x0000000000000000000000000000000000000000"]
const arr = addresses.filter( address => { !addressesToIgnore.find(object => object === address.TokenHolderAddress.toLowerCase())});
console.log(arr);
console.log(addresses)
return arr;
}

0 comments on commit 970093e

Please sign in to comment.