Skip to content

Commit

Permalink
update sui
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Oct 27, 2024
1 parent a7911ce commit 80128e0
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/adapters/peggedAssets/helper/sui.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { graph } from "@defillama/sdk";
import http from "../helper/http";
const axios = require("axios");

interface CallOptions {
withMetadata?: boolean;
}

export const endpoint = (): string => "https://fullnode.mainnet.sui.io/";
export const graphEndpoint = (): string => "https://sui-mainnet.mystenlabs.com/graphql";

export async function getObject(objectId: string): Promise<any> {
return (
Expand Down Expand Up @@ -37,17 +38,13 @@ export async function call(


export async function getTokenSupply(token: string) {
const { data: { result: { decimals } } } = await axios.post(endpoint(), {
"jsonrpc": "2.0",
"id": 1,
"method": "suix_getCoinMetadata",
"params": [token]
});
const { data: { result: { value: supply } } } = await axios.post(endpoint(), {
"jsonrpc": "2.0",
"id": 1,
"method": "suix_getTotalSupply",
"params": [token]
});
return supply / 10 ** decimals;
const query = `{
coinMetadata(coinType:"${token}") {
decimals
symbol
supply
}
}`
const { coinMetadata: { supply, decimals } } = await graph.request(graphEndpoint(), query)
return supply / 10 ** decimals
}

0 comments on commit 80128e0

Please sign in to comment.