Skip to content

Commit

Permalink
add position(bundle) mint supply
Browse files Browse the repository at this point in the history
  • Loading branch information
yugure-orca committed Dec 15, 2023
1 parent 0b586ca commit ec210c9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/build/bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/libs/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export type RPC = {

const _rpclist: RPC[] = [
{ id: "helius", name: "Mainnet HELIUS", network: "mainnet", url: "https://rpc-proxy.yugure-crypto.workers.dev" },
{ id: "everstake", name: "Mainnet Everstake", network: "mainnet", url: "https://solana-mainnet.rpc.extrnode.com" },
{ id: "anker", name: "Mainnet Anker", network: "mainnet", url: "https://rpc.ankr.com/solana" },
//{ id: "everstake", name: "Mainnet Everstake", network: "mainnet", url: "https://solana-mainnet.rpc.extrnode.com" },
//{ id: "anker", name: "Mainnet Anker", network: "mainnet", url: "https://rpc.ankr.com/solana" },
{ id: "solana", name: "Mainnet Solana", network: "mainnet", url: "https://api.mainnet-beta.solana.com" },
// { id: "serum", name: "Mainnet Serum", network: "mainnet", url: "https://solana-api.projectserum.com" },
{ id: "devnet", name: "Devnet Solana", network: "devnet", url: "https://api.devnet.solana.com" },
Expand Down
9 changes: 9 additions & 0 deletions src/libs/whirlpool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ type PositionDerivedInfo = {
isBundledPosition: boolean,
isFullRange: boolean,
positionBundle?: PublicKey,
positionMintSupply: number,
}

export type PositionInfo = {
Expand Down Expand Up @@ -338,12 +339,14 @@ export async function getPositionInfo(addr: Address): Promise<PositionInfo> {
mintPubkeys.push(whirlpoolData.rewardInfos[0].mint);
mintPubkeys.push(whirlpoolData.rewardInfos[1].mint);
mintPubkeys.push(whirlpoolData.rewardInfos[2].mint);
mintPubkeys.push(positionData.positionMint);
const mints = await fetcher.listMintInfos(mintPubkeys, true);
const decimalsA = mints[0].decimals;
const decimalsB = mints[1].decimals;
const decimalsR0 = mints[2]?.decimals;
const decimalsR1 = mints[3]?.decimals;
const decimalsR2 = mints[4]?.decimals;
const positionMintSupply = mints[5].supply.toNumber();

const priceLower = toFixedDecimal(PriceMath.tickIndexToPrice(positionData.tickLowerIndex, decimalsA, decimalsB), decimalsB);
const priceUpper = toFixedDecimal(PriceMath.tickIndexToPrice(positionData.tickUpperIndex, decimalsA, decimalsB), decimalsB);
Expand Down Expand Up @@ -443,6 +446,7 @@ export async function getPositionInfo(addr: Address): Promise<PositionInfo> {
isBundledPosition,
isFullRange,
positionBundle: isBundledPosition ? derivedPositionBundleAddress : undefined,
positionMintSupply,
}
};
}
Expand Down Expand Up @@ -818,6 +822,7 @@ type PositionBundleDerivedInfo = {
occupied: number;
unoccupied: number;
bundledPositions: BundledPositionInfo[],
positionBundleMintSupply: number;
}

type PositionBundleInfo = {
Expand All @@ -834,6 +839,9 @@ export async function getPositionBundleInfo(addr: Address): Promise<PositionBund
const { accountInfo, slotContext } = await getAccountInfo(connection, pubkey);
const positionBundleData = ParsablePositionBundle.parse(accountInfo.data);

const positionBundleMint = await fetcher.getMintInfo(positionBundleData.positionBundleMint, true);
const positionBundleMintSupply = positionBundleMint.supply.toNumber();

const occupiedIndexes = PositionBundleUtil.getOccupiedBundleIndexes(positionBundleData);
const bundledPositionAddresses = occupiedIndexes.map((index) => {
return PDAUtil.getBundledPosition(accountInfo.owner, positionBundleData.positionBundleMint, index).publicKey
Expand Down Expand Up @@ -867,6 +875,7 @@ export async function getPositionBundleInfo(addr: Address): Promise<PositionBund
occupied,
unoccupied,
bundledPositions,
positionBundleMintSupply,
},
};
}
Expand Down
1 change: 1 addition & 0 deletions src/pages/whirlpool/Position.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
<Data name="pool liquidity">{positionInfo.derived.poolLiquidity}</Data>
<Data name="current tick index">{positionInfo.derived.tickCurrentIndex}</Data>
<Data name="current price">{positionInfo.derived.currentPrice}</Data>
<Data name="position mint supply">{positionInfo.derived.positionMintSupply}{positionInfo.derived.positionMintSupply === 0 ? " (burnt)" : ""}</Data>
<Data name="position status">{positionInfo.derived.status}</Data>
<Data name="share of liquidity">{positionInfo.derived.sharePercentOfLiquidity} %</Data>
<Data name="lower tick array"><Pubkey type="whirlpool/tickarray" address={positionInfo.derived.lowerTickArray} /></Data>
Expand Down
1 change: 1 addition & 0 deletions src/pages/whirlpool/PositionBundle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
</tbody>
</table>
</Data>
<Data name="position bundle mint supply">{positionBundleInfo.derived.positionBundleMintSupply}{positionBundleInfo.derived.positionBundleMintSupply === 0 ? " (burnt)" : ""}</Data>
</DerivedData>
</ParsedAndDerivedData>
{/await}
Expand Down

0 comments on commit ec210c9

Please sign in to comment.