Skip to content

Commit

Permalink
add identifier for Orca positions
Browse files Browse the repository at this point in the history
  • Loading branch information
Geninsus committed Nov 7, 2024
1 parent b9f0cd3 commit ad393b7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/plugins/src/plugins/orca/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const aquafarmsProgram = new PublicKey(
'82yxjeMsvaURa4MbZZ7WZZHfobirZYkH1zF8fmeGtyaQ'
);

export const positionsIdentifier = 'Orca Whirlpool Position';
export const positionsIdentifiers = ['Orca Whirlpool Position', 'OWP'];
export const whirlpoolPrefix = `${platformId}-whirlpool`;
export const whirlpoolProgram = new PublicKey(
'whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc'
Expand Down
10 changes: 3 additions & 7 deletions packages/plugins/src/plugins/orca/getWhirlpoolPositions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export function getOrcaNftFetcher(
positionInfo.tickUpperIndex,
false
);

const rewardAssets: PortfolioAsset[] = [];

const tokenPriceA = tokenPrices.get(whirlpoolInfo.tokenMintA.toString());
Expand Down Expand Up @@ -240,12 +239,7 @@ export function getOrcaNftFetcher(
}
}

if (
!assetTokenA ||
!assetTokenB ||
(assetTokenA.value === null && assetTokenB.value === null)
)
continue;
if (!assetTokenA || !assetTokenB) continue;

const assets = [assetTokenA, assetTokenB];

Expand All @@ -258,6 +252,8 @@ export function getOrcaNftFetcher(
);
const totalValue = getUsdValueSum([assetsValue, rewardAssetsValue]);

if (totalValue === 0 || totalValue === null) continue;

elements.push({
type: PortfolioElementType.liquidity,
networkId: NetworkId.solana,
Expand Down
6 changes: 4 additions & 2 deletions packages/plugins/src/plugins/orca/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import BN from 'bn.js';
import Decimal from 'decimal.js';

import { PortfolioAssetCollectible } from '@sonarwatch/portfolio-core';
import { positionsIdentifier } from './constants';
import { positionsIdentifiers } from './constants';

export function isAnOrcaPosition(nft: PortfolioAssetCollectible): boolean {
return nft.name === positionsIdentifier;
return positionsIdentifiers.some((identifier) =>
nft.name?.includes(identifier)
);
}

export function signedShiftRight(n0: BN, shiftBy: number, bitWidth: number) {
Expand Down

0 comments on commit ad393b7

Please sign in to comment.