@kamino-finance/kliquidity-sdk 8.0.0 → 8.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kamino-finance/kliquidity-sdk",
3
- "version": "8.0.0",
3
+ "version": "8.0.1",
4
4
  "description": "Typescript SDK for interacting with the Kamino Liquidity (kliquidity) protocol",
5
5
  "repository": {
6
6
  "type": "git",
package/src/Kamino.ts CHANGED
@@ -1379,6 +1379,20 @@ export class Kamino {
1379
1379
  }
1380
1380
  };
1381
1381
 
1382
+ /**
1383
+ * Get the token A and B per share for the specified Kamino whirlpool strategy
1384
+ * @param strategy
1385
+ */
1386
+ getTokenAAndBPerShare = async (strategy: Address | StrategyWithAddress): Promise<TokenAmounts> => {
1387
+ const strategyState = await this.getStrategyStateIfNotFetched(strategy);
1388
+ const sharesIssued = new Decimal(strategyState.strategy.sharesIssued.toString());
1389
+ const balances = await this.getStrategyBalances(strategyState.strategy);
1390
+ if (sharesIssued.isZero()) {
1391
+ return { a: new Decimal(0), b: new Decimal(0) };
1392
+ }
1393
+ return { a: balances.tokenAAmounts.div(sharesIssued), b: balances.tokenBAmounts.div(sharesIssued) };
1394
+ };
1395
+
1382
1396
  /**
1383
1397
  * Batch fetch share data for all or a filtered list of strategies
1384
1398
  * @param strategyFilters strategy filters or a list of strategy public keys