Skip to content

Commit

Permalink
Remove get price by mint methods from kamino-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
peroxy committed Nov 1, 2023
1 parent 0512e85 commit 2364b7b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 97 deletions.
72 changes: 0 additions & 72 deletions packages/kamino-sdk/src/Kamino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1751,78 +1751,6 @@ export class Kamino {
return { oraclePrices, collateralInfos };
}

/**
* Get Kamino token spot price by mint
* @param mint token mint
* @param oraclePrices (optional) Scope Oracle prices
* @param collateralInfos (optional) Kamino Collateral Infos
*/
getPriceByMint = async (
mint: PublicKey | string,
oraclePrices?: OraclePrices,
collateralInfos?: CollateralInfo[]
): Promise<EnrichedScopePrice | undefined> => {
return (await this.getAllPrices(oraclePrices, collateralInfos)).spot[mint.toString()];
};

/**
* Get Kamino token TWAP by token mint
* @param mint token mint
* @param oraclePrices (optional) Scope Oracle prices
* @param collateralInfos (optional) Kamino Collateral Infos
*/
getTwapByMint = async (
mint: PublicKey | string,
oraclePrices?: OraclePrices,
collateralInfos?: CollateralInfo[]
): Promise<EnrichedScopePrice | undefined> => {
return (await this.getAllPrices(oraclePrices, collateralInfos)).twap[mint.toString()];
};

/**
* Get multiple Kamino token spot price by mint
* @param mints token mint
* @param oraclePrices (optional) Scope Oracle prices
* @param collateralInfos (optional) Kamino Collateral Infos
*/
getPricesByMints = async (
mints: (PublicKey | string)[],
oraclePrices?: OraclePrices,
collateralInfos?: CollateralInfo[]
): Promise<MintToPriceMap> => {
const prices = await this.getAllPrices(oraclePrices, collateralInfos);
const spotPrices: MintToPriceMap = {};
for (const mint of mints) {
const price = prices.spot[mint.toString()];
if (price) {
spotPrices[mint.toString()] = price;
}
}
return spotPrices;
};

/**
* Get multiple Kamino token TWAP by token mint
* @param mints token mints
* @param oraclePrices (optional) Scope Oracle prices
* @param collateralInfos (optional) Kamino Collateral Infos
*/
getTwapsByMints = async (
mints: (PublicKey | string)[],
oraclePrices?: OraclePrices,
collateralInfos?: CollateralInfo[]
): Promise<MintToPriceMap> => {
const prices = await this.getAllPrices(oraclePrices, collateralInfos);
const twaps: MintToPriceMap = {};
for (const mint of mints) {
const price = prices.twap[mint.toString()];
if (price) {
twaps[mint.toString()] = price;
}
}
return twaps;
};

/**
* Get the prices of all tokens in the specified strategy, or null if the reward token does not exist
* @param strategy
Expand Down
25 changes: 0 additions & 25 deletions packages/kamino-sdk/tests/kamino.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,26 +346,6 @@ describe('Kamino SDK Tests', () => {
expect(usdcTwap!.price.toNumber()).to.be.greaterThan(0);
});

it('should get Kamino price and twap by mint', async () => {
const kamino = new Kamino(
cluster,
connection,
fixtures.globalConfig,
fixtures.kaminoProgramId,
WHIRLPOOL_PROGRAM_ID,
LOCAL_RAYDIUM_PROGRAM_ID
);
const usdh = await kamino.getPriceByMint(fixtures.newTokenMintA);
expect(usdh).not.to.be.undefined;
expect(usdh!.name).to.be.equal('USDH');
expect(usdh!.price.toNumber()).to.be.greaterThan(0);

const usdhTwap = await kamino.getTwapByMint(fixtures.newTokenMintA);
expect(usdhTwap).not.to.be.undefined;
expect(usdhTwap!.name).to.be.equal('USDH');
expect(usdhTwap!.price.toNumber()).to.be.greaterThan(0);
});

it('should get all strategies', async () => {
let kamino = new Kamino(
cluster,
Expand Down Expand Up @@ -1978,11 +1958,6 @@ describe('Kamino SDK Tests', () => {
expect(usdhTwap).not.to.be.undefined;
expect(usdhTwap!.name).to.be.equal('USDH');
expect(usdhTwap!.price.toNumber()).to.be.greaterThan(0);

const price = await kamino.getPriceByMint('USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX');
expect(price).not.to.be.undefined;
expect(price!.name).to.be.equal('USDH');
expect(price!.price.toNumber()).to.be.greaterThan(0);
});
});

Expand Down

0 comments on commit 2364b7b

Please sign in to comment.