pnp-sdk 0.2.8 → 0.2.10

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/dist/index.d.cts CHANGED
@@ -960,6 +960,56 @@ declare class PNPClient {
960
960
  publicKey: PublicKey;
961
961
  account: GlobalConfigType;
962
962
  }>;
963
+ /**
964
+ * Get V2 AMM market price data including prices and multipliers
965
+ *
966
+ * ✅ READ-ONLY - No signer required! Works with just an RPC connection.
967
+ *
968
+ * This function fetches on-chain market data and calculates:
969
+ * - YES/NO token prices using the V2 AMM formula
970
+ * - Multipliers (potential payout ratios)
971
+ *
972
+ * Formulas:
973
+ * - YES Price: (marketReserves × yesTokenSupply) / (yesTokenSupply² + noTokenSupply²)
974
+ * - NO Price: (marketReserves × noTokenSupply) / (yesTokenSupply² + noTokenSupply²)
975
+ * - YES Multiplier: 1 + (noTokenSupply / yesTokenSupply)²
976
+ * - NO Multiplier: 1 + (yesTokenSupply / noTokenSupply)²
977
+ *
978
+ * @param market - Market public key or address string
979
+ * @returns V2 market price data with prices, multipliers, and supplies
980
+ *
981
+ * @example
982
+ * ```typescript
983
+ * // Works without a signer!
984
+ * const client = new PNPClient("https://api.devnet.solana.com");
985
+ * const priceData = await client.getMarketPriceV2("3LsfeB3RhQKJc2eHdEcb9XQzkF6eP9BFa6HTD6vvug9j");
986
+ * console.log(`YES Price: ${priceData.yesPrice}`);
987
+ * console.log(`NO Price: ${priceData.noPrice}`);
988
+ * console.log(`YES Multiplier: ${priceData.yesMultiplier}x`);
989
+ * ```
990
+ */
991
+ getMarketPriceV2(market: PublicKey | string): Promise<{
992
+ /** Market reserves (collateral) in UI units */
993
+ marketReserves: number;
994
+ /** YES tokens minted in UI units */
995
+ yesTokenSupply: number;
996
+ /** NO tokens minted in UI units */
997
+ noTokenSupply: number;
998
+ /** YES token price (0-1) */
999
+ yesPrice: number;
1000
+ /** NO token price (0-1) */
1001
+ noPrice: number;
1002
+ /** YES multiplier (potential payout ratio) */
1003
+ yesMultiplier: number;
1004
+ /** NO multiplier (potential payout ratio) */
1005
+ noMultiplier: number;
1006
+ /** Raw market reserves in base units */
1007
+ marketReservesRaw: bigint;
1008
+ /** Raw YES tokens in base units */
1009
+ yesTokenSupplyRaw: bigint;
1010
+ /** Raw NO tokens in base units */
1011
+ noTokenSupplyRaw: bigint;
1012
+ }>;
963
1013
  /**
964
1014
  * Set market resolvable status (V2 markets)
965
1015
  *
package/dist/index.d.ts CHANGED
@@ -960,6 +960,56 @@ declare class PNPClient {
960
960
  publicKey: PublicKey;
961
961
  account: GlobalConfigType;
962
962
  }>;
963
+ /**
964
+ * Get V2 AMM market price data including prices and multipliers
965
+ *
966
+ * ✅ READ-ONLY - No signer required! Works with just an RPC connection.
967
+ *
968
+ * This function fetches on-chain market data and calculates:
969
+ * - YES/NO token prices using the V2 AMM formula
970
+ * - Multipliers (potential payout ratios)
971
+ *
972
+ * Formulas:
973
+ * - YES Price: (marketReserves × yesTokenSupply) / (yesTokenSupply² + noTokenSupply²)
974
+ * - NO Price: (marketReserves × noTokenSupply) / (yesTokenSupply² + noTokenSupply²)
975
+ * - YES Multiplier: 1 + (noTokenSupply / yesTokenSupply)²
976
+ * - NO Multiplier: 1 + (yesTokenSupply / noTokenSupply)²
977
+ *
978
+ * @param market - Market public key or address string
979
+ * @returns V2 market price data with prices, multipliers, and supplies
980
+ *
981
+ * @example
982
+ * ```typescript
983
+ * // Works without a signer!
984
+ * const client = new PNPClient("https://api.devnet.solana.com");
985
+ * const priceData = await client.getMarketPriceV2("3LsfeB3RhQKJc2eHdEcb9XQzkF6eP9BFa6HTD6vvug9j");
986
+ * console.log(`YES Price: ${priceData.yesPrice}`);
987
+ * console.log(`NO Price: ${priceData.noPrice}`);
988
+ * console.log(`YES Multiplier: ${priceData.yesMultiplier}x`);
989
+ * ```
990
+ */
991
+ getMarketPriceV2(market: PublicKey | string): Promise<{
992
+ /** Market reserves (collateral) in UI units */
993
+ marketReserves: number;
994
+ /** YES tokens minted in UI units */
995
+ yesTokenSupply: number;
996
+ /** NO tokens minted in UI units */
997
+ noTokenSupply: number;
998
+ /** YES token price (0-1) */
999
+ yesPrice: number;
1000
+ /** NO token price (0-1) */
1001
+ noPrice: number;
1002
+ /** YES multiplier (potential payout ratio) */
1003
+ yesMultiplier: number;
1004
+ /** NO multiplier (potential payout ratio) */
1005
+ noMultiplier: number;
1006
+ /** Raw market reserves in base units */
1007
+ marketReservesRaw: bigint;
1008
+ /** Raw YES tokens in base units */
1009
+ yesTokenSupplyRaw: bigint;
1010
+ /** Raw NO tokens in base units */
1011
+ noTokenSupplyRaw: bigint;
1012
+ }>;
963
1013
  /**
964
1014
  * Set market resolvable status (V2 markets)
965
1015
  *
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  TransportError,
10
10
  ValidationError,
11
11
  pdas_exports
12
- } from "./chunk-HN2SKUTC.js";
12
+ } from "./chunk-SIMCEKAG.js";
13
13
  export {
14
14
  Client,
15
15
  MarketModule,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pnp-sdk",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",