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.
@@ -45,8 +45,8 @@ import { Connection, PublicKey as PublicKey2 } from "@solana/web3.js";
45
45
  import { PublicKey, TransactionInstruction } from "@solana/web3.js";
46
46
  import { BorshCoder } from "@coral-xyz/anchor";
47
47
 
48
- // src/idl/pnp_exchange.json
49
- var pnp_exchange_default = {
48
+ // src/idl/pnp_protocol_solana.json
49
+ var pnp_protocol_solana_default = {
50
50
  address: "6fnYZUSyp3vJxTNnayq5S62d363EFaGARnqYux5bqrxb",
51
51
  metadata: {
52
52
  name: "pnp_protocol_solana",
@@ -141,14 +141,14 @@ var pnp_exchange_default = {
141
141
  {
142
142
  name: "yes_token_mint",
143
143
  docs: [
144
- "YES token mint account"
144
+ "YES token mint account (SPL Token only)"
145
145
  ],
146
146
  writable: true
147
147
  },
148
148
  {
149
149
  name: "no_token_mint",
150
150
  docs: [
151
- "NO token mint account"
151
+ "NO token mint account (SPL Token only)"
152
152
  ],
153
153
  writable: true
154
154
  },
@@ -167,7 +167,7 @@ var pnp_exchange_default = {
167
167
  },
168
168
  {
169
169
  kind: "account",
170
- path: "token_program"
170
+ path: "token_program_decision"
171
171
  },
172
172
  {
173
173
  kind: "account",
@@ -228,7 +228,7 @@ var pnp_exchange_default = {
228
228
  },
229
229
  {
230
230
  kind: "account",
231
- path: "token_program"
231
+ path: "token_program_decision"
232
232
  },
233
233
  {
234
234
  kind: "account",
@@ -472,9 +472,16 @@ var pnp_exchange_default = {
472
472
  {
473
473
  name: "token_program",
474
474
  docs: [
475
- "Token program interface"
475
+ "Token program for collateral (SPL or Token-2022)"
476
476
  ]
477
477
  },
478
+ {
479
+ name: "token_program_decision",
480
+ docs: [
481
+ "Token program for decision mints (SPL Token, auto-resolved)"
482
+ ],
483
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
484
+ },
478
485
  {
479
486
  name: "associated_token_program",
480
487
  docs: [
@@ -3436,14 +3443,14 @@ var pnp_exchange_default = {
3436
3443
  {
3437
3444
  name: "yes_token_mint",
3438
3445
  docs: [
3439
- "YES token mint account"
3446
+ "YES token mint account (SPL Token only)"
3440
3447
  ],
3441
3448
  writable: true
3442
3449
  },
3443
3450
  {
3444
3451
  name: "no_token_mint",
3445
3452
  docs: [
3446
- "NO token mint account"
3453
+ "NO token mint account (SPL Token only)"
3447
3454
  ],
3448
3455
  writable: true
3449
3456
  },
@@ -3462,7 +3469,7 @@ var pnp_exchange_default = {
3462
3469
  },
3463
3470
  {
3464
3471
  kind: "account",
3465
- path: "token_program"
3472
+ path: "token_program_decision"
3466
3473
  },
3467
3474
  {
3468
3475
  kind: "account",
@@ -3523,7 +3530,7 @@ var pnp_exchange_default = {
3523
3530
  },
3524
3531
  {
3525
3532
  kind: "account",
3526
- path: "token_program"
3533
+ path: "token_program_decision"
3527
3534
  },
3528
3535
  {
3529
3536
  kind: "account",
@@ -3767,9 +3774,16 @@ var pnp_exchange_default = {
3767
3774
  {
3768
3775
  name: "token_program",
3769
3776
  docs: [
3770
- "Token program interface"
3777
+ "Token program for collateral (SPL or Token-2022)"
3771
3778
  ]
3772
3779
  },
3780
+ {
3781
+ name: "token_program_decision",
3782
+ docs: [
3783
+ "Token program for decision mints (SPL Token, auto-resolved)"
3784
+ ],
3785
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
3786
+ },
3773
3787
  {
3774
3788
  name: "associated_token_program",
3775
3789
  docs: [
@@ -3882,14 +3896,14 @@ var pnp_exchange_default = {
3882
3896
  {
3883
3897
  name: "yes_token_mint",
3884
3898
  docs: [
3885
- "YES token mint account"
3899
+ "YES token mint account (SPL Token only)"
3886
3900
  ],
3887
3901
  writable: true
3888
3902
  },
3889
3903
  {
3890
3904
  name: "no_token_mint",
3891
3905
  docs: [
3892
- "NO token mint account"
3906
+ "NO token mint account (SPL Token only)"
3893
3907
  ],
3894
3908
  writable: true
3895
3909
  },
@@ -3908,7 +3922,7 @@ var pnp_exchange_default = {
3908
3922
  },
3909
3923
  {
3910
3924
  kind: "account",
3911
- path: "token_program"
3925
+ path: "token_program_decision"
3912
3926
  },
3913
3927
  {
3914
3928
  kind: "account",
@@ -3969,7 +3983,7 @@ var pnp_exchange_default = {
3969
3983
  },
3970
3984
  {
3971
3985
  kind: "account",
3972
- path: "token_program"
3986
+ path: "token_program_decision"
3973
3987
  },
3974
3988
  {
3975
3989
  kind: "account",
@@ -4213,9 +4227,16 @@ var pnp_exchange_default = {
4213
4227
  {
4214
4228
  name: "token_program",
4215
4229
  docs: [
4216
- "Token program interface"
4230
+ "Token program for collateral (SPL or Token-2022)"
4217
4231
  ]
4218
4232
  },
4233
+ {
4234
+ name: "token_program_decision",
4235
+ docs: [
4236
+ "Token program for decision mints (SPL Token, auto-resolved)"
4237
+ ],
4238
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
4239
+ },
4219
4240
  {
4220
4241
  name: "associated_token_program",
4221
4242
  docs: [
@@ -4306,14 +4327,14 @@ var pnp_exchange_default = {
4306
4327
  {
4307
4328
  name: "yes_token_mint",
4308
4329
  docs: [
4309
- "YES token mint account"
4330
+ "YES token mint account (SPL Token only)"
4310
4331
  ],
4311
4332
  writable: true
4312
4333
  },
4313
4334
  {
4314
4335
  name: "no_token_mint",
4315
4336
  docs: [
4316
- "NO token mint account"
4337
+ "NO token mint account (SPL Token only)"
4317
4338
  ],
4318
4339
  writable: true
4319
4340
  },
@@ -4332,7 +4353,7 @@ var pnp_exchange_default = {
4332
4353
  },
4333
4354
  {
4334
4355
  kind: "account",
4335
- path: "token_program"
4356
+ path: "token_program_decision"
4336
4357
  },
4337
4358
  {
4338
4359
  kind: "account",
@@ -4393,7 +4414,7 @@ var pnp_exchange_default = {
4393
4414
  },
4394
4415
  {
4395
4416
  kind: "account",
4396
- path: "token_program"
4417
+ path: "token_program_decision"
4397
4418
  },
4398
4419
  {
4399
4420
  kind: "account",
@@ -4637,9 +4658,16 @@ var pnp_exchange_default = {
4637
4658
  {
4638
4659
  name: "token_program",
4639
4660
  docs: [
4640
- "Token program interface"
4661
+ "Token program for collateral (SPL or Token-2022)"
4641
4662
  ]
4642
4663
  },
4664
+ {
4665
+ name: "token_program_decision",
4666
+ docs: [
4667
+ "Token program for decision mints (SPL Token, auto-resolved)"
4668
+ ],
4669
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
4670
+ },
4643
4671
  {
4644
4672
  name: "associated_token_program",
4645
4673
  docs: [
@@ -6181,14 +6209,14 @@ var pnp_exchange_default = {
6181
6209
  {
6182
6210
  name: "yes_token_mint",
6183
6211
  docs: [
6184
- "YES token mint account"
6212
+ "YES token mint account (SPL Token only)"
6185
6213
  ],
6186
6214
  writable: true
6187
6215
  },
6188
6216
  {
6189
6217
  name: "no_token_mint",
6190
6218
  docs: [
6191
- "NO token mint account"
6219
+ "NO token mint account (SPL Token only)"
6192
6220
  ],
6193
6221
  writable: true
6194
6222
  },
@@ -6207,7 +6235,7 @@ var pnp_exchange_default = {
6207
6235
  },
6208
6236
  {
6209
6237
  kind: "account",
6210
- path: "token_program"
6238
+ path: "token_program_decision"
6211
6239
  },
6212
6240
  {
6213
6241
  kind: "account",
@@ -6268,7 +6296,7 @@ var pnp_exchange_default = {
6268
6296
  },
6269
6297
  {
6270
6298
  kind: "account",
6271
- path: "token_program"
6299
+ path: "token_program_decision"
6272
6300
  },
6273
6301
  {
6274
6302
  kind: "account",
@@ -6512,9 +6540,16 @@ var pnp_exchange_default = {
6512
6540
  {
6513
6541
  name: "token_program",
6514
6542
  docs: [
6515
- "Token program interface"
6543
+ "Token program for collateral (SPL or Token-2022)"
6516
6544
  ]
6517
6545
  },
6546
+ {
6547
+ name: "token_program_decision",
6548
+ docs: [
6549
+ "Token program for decision mints (SPL Token, auto-resolved)"
6550
+ ],
6551
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
6552
+ },
6518
6553
  {
6519
6554
  name: "associated_token_program",
6520
6555
  docs: [
@@ -8326,7 +8361,7 @@ var pnp_exchange_default = {
8326
8361
 
8327
8362
  // src/idl/index.ts
8328
8363
  var DEBUG = process.env.PNP_DEBUG === "1";
8329
- var PNP_IDL = pnp_exchange_default;
8364
+ var PNP_IDL = pnp_protocol_solana_default;
8330
8365
  var PNP_PROGRAM_ID = new PublicKey(
8331
8366
  PNP_IDL.address ?? (() => {
8332
8367
  throw new Error("IDL missing address field");
@@ -8804,10 +8839,13 @@ var MarketModule = class {
8804
8839
  [Buffer.from("market_ext"), gidLe],
8805
8840
  this.client.programId
8806
8841
  );
8842
+ const collateralMintInfo = await this.client.connection.getAccountInfo(collateralMint, this.client.commitment);
8843
+ if (!collateralMintInfo) throw new Error("collateral_token_mint not found");
8844
+ const tokenProgram = collateralMintInfo.owner.equals(TOKEN_2022_PROGRAM_ID) ? TOKEN_2022_PROGRAM_ID : TOKEN_PROGRAM_ID2;
8807
8845
  const payer = this.signer.publicKey;
8808
8846
  const creator = payer;
8809
- const payerCollateralTokenAccount = deriveAta(payer, collateralMint);
8810
- const marketReserveVault = deriveAta(market, collateralMint, true);
8847
+ const payerCollateralTokenAccount = deriveAta(payer, collateralMint, false, tokenProgram);
8848
+ const marketReserveVault = deriveAta(market, collateralMint, true, tokenProgram);
8811
8849
  const [creatorFeeTreasury] = deriveCreatorFeeTreasuryPda(creator, this.client.programId, collateralMint);
8812
8850
  const accounts = {
8813
8851
  payer,
@@ -8820,7 +8858,10 @@ var MarketModule = class {
8820
8858
  payer_collateral_token_account: payerCollateralTokenAccount,
8821
8859
  market_reserve_vault: marketReserveVault,
8822
8860
  creator_fee_treasury: creatorFeeTreasury,
8823
- token_program: TOKEN_PROGRAM_ID2,
8861
+ token_program: tokenProgram,
8862
+ // For collateral (can be Token-2022)
8863
+ token_program_decision: TOKEN_PROGRAM_ID2,
8864
+ // For decision tokens (always SPL Token)
8824
8865
  associated_token_program: ASSOCIATED_TOKEN_PROGRAM_ID2,
8825
8866
  system_program: SystemProgram2.programId
8826
8867
  };
@@ -9141,20 +9182,17 @@ var TradingModule = class _TradingModule {
9141
9182
  this.client.connection.getAccountInfo(collateralMint, this.client.commitment)
9142
9183
  ]);
9143
9184
  if (!yesAi || !noAi || !colAi) throw new Error("one or more mint accounts not found");
9144
- const tokenProgramId = yesAi.owner.equals(TOKEN_2022_PROGRAM_ID2) ? TOKEN_2022_PROGRAM_ID2 : TOKEN_PROGRAM_ID3;
9185
+ const decisionTokenProgramId = TOKEN_PROGRAM_ID3;
9186
+ const collateralTokenProgramId = colAi.owner.equals(TOKEN_2022_PROGRAM_ID2) ? TOKEN_2022_PROGRAM_ID2 : TOKEN_PROGRAM_ID3;
9145
9187
  const ataProgramId = ASSOCIATED_TOKEN_PROGRAM_ID3;
9146
- const owners = [yesAi.owner.toBase58(), noAi.owner.toBase58(), colAi.owner.toBase58()];
9147
- if (!(yesAi.owner.equals(noAi.owner) && yesAi.owner.equals(colAi.owner))) {
9148
- throw new Error(`Market mint program mismatch. Owners: YES=${owners[0]}, NO=${owners[1]}, COLLATERAL=${owners[2]}. All mints must share the same token program.`);
9149
- }
9150
- await getMint(this.client.connection, collateralMint, this.client.commitment, tokenProgramId);
9151
- const buyerCollateralTokenAccount = deriveAta(buyer, collateralMint, false, tokenProgramId, ataProgramId);
9152
- const adminCollateralTokenAccount = deriveAta(admin, collateralMint, false, tokenProgramId, ataProgramId);
9153
- const marketReserveVault = deriveAta(market, collateralMint, true, tokenProgramId, ataProgramId);
9154
- const buyerYesTokenAccount = deriveAta(buyer, yesTokenMint, false, tokenProgramId, ataProgramId);
9155
- const buyerNoTokenAccount = deriveAta(buyer, noTokenMint, false, tokenProgramId, ataProgramId);
9188
+ await getMint(this.client.connection, collateralMint, this.client.commitment, collateralTokenProgramId);
9189
+ const buyerCollateralTokenAccount = deriveAta(buyer, collateralMint, false, collateralTokenProgramId, ataProgramId);
9190
+ const adminCollateralTokenAccount = deriveAta(admin, collateralMint, false, collateralTokenProgramId, ataProgramId);
9191
+ const marketReserveVault = deriveAta(market, collateralMint, true, collateralTokenProgramId, ataProgramId);
9192
+ const buyerYesTokenAccount = deriveAta(buyer, yesTokenMint, false, decisionTokenProgramId, ataProgramId);
9193
+ const buyerNoTokenAccount = deriveAta(buyer, noTokenMint, false, decisionTokenProgramId, ataProgramId);
9156
9194
  const preIxs = [];
9157
- const maybeCreateAta = async (owner, mint, ata, useTokenProgram = tokenProgramId, useAtaProgram = ataProgramId) => {
9195
+ const maybeCreateAta = async (owner, mint, ata, useTokenProgram, useAtaProgram = ataProgramId) => {
9158
9196
  const info = await this.client.connection.getAccountInfo(ata, this.client.commitment);
9159
9197
  if (!info) {
9160
9198
  preIxs.push(
@@ -9170,11 +9208,11 @@ var TradingModule = class _TradingModule {
9170
9208
  );
9171
9209
  }
9172
9210
  };
9173
- await maybeCreateAta(buyer, collateralMint, buyerCollateralTokenAccount);
9174
- await maybeCreateAta(admin, collateralMint, adminCollateralTokenAccount);
9175
- await maybeCreateAta(market, collateralMint, marketReserveVault);
9176
- await maybeCreateAta(buyer, yesTokenMint, buyerYesTokenAccount, tokenProgramId, ataProgramId);
9177
- await maybeCreateAta(buyer, noTokenMint, buyerNoTokenAccount, tokenProgramId, ataProgramId);
9211
+ await maybeCreateAta(buyer, collateralMint, buyerCollateralTokenAccount, collateralTokenProgramId);
9212
+ await maybeCreateAta(admin, collateralMint, adminCollateralTokenAccount, collateralTokenProgramId);
9213
+ await maybeCreateAta(market, collateralMint, marketReserveVault, collateralTokenProgramId);
9214
+ await maybeCreateAta(buyer, yesTokenMint, buyerYesTokenAccount, decisionTokenProgramId, ataProgramId);
9215
+ await maybeCreateAta(buyer, noTokenMint, buyerNoTokenAccount, decisionTokenProgramId, ataProgramId);
9178
9216
  const buyerCollateralInfo = await this.client.connection.getTokenAccountBalance(buyerCollateralTokenAccount).catch(() => null);
9179
9217
  if (!buyerCollateralInfo) {
9180
9218
  throw new Error("Buyer collateral token account missing or unreadable");
@@ -9198,7 +9236,10 @@ var TradingModule = class _TradingModule {
9198
9236
  buyer_collateral_token_account: buyerCollateralTokenAccount,
9199
9237
  admin_collateral_token_account: adminCollateralTokenAccount,
9200
9238
  creator_fee_treasury: creatorFeeTreasury,
9201
- token_program: tokenProgramId,
9239
+ token_program: collateralTokenProgramId,
9240
+ // For collateral (may be Token-2022)
9241
+ token_program_decision: decisionTokenProgramId,
9242
+ // For YES/NO tokens (always SPL Token)
9202
9243
  associated_token_program: ataProgramId,
9203
9244
  system_program: SystemProgram3.programId
9204
9245
  };
@@ -9233,17 +9274,14 @@ var TradingModule = class _TradingModule {
9233
9274
  this.client.connection.getAccountInfo(collateralMint, this.client.commitment)
9234
9275
  ]);
9235
9276
  if (!yesAi || !noAi || !colAi) throw new Error("one or more mint accounts not found");
9236
- const tokenProgramId = yesAi.owner.equals(TOKEN_2022_PROGRAM_ID2) ? TOKEN_2022_PROGRAM_ID2 : TOKEN_PROGRAM_ID3;
9277
+ const decisionTokenProgramId = TOKEN_PROGRAM_ID3;
9278
+ const collateralTokenProgramId = colAi.owner.equals(TOKEN_2022_PROGRAM_ID2) ? TOKEN_2022_PROGRAM_ID2 : TOKEN_PROGRAM_ID3;
9237
9279
  const ataProgramId = ASSOCIATED_TOKEN_PROGRAM_ID3;
9238
- if (!(yesAi.owner.equals(noAi.owner) && yesAi.owner.equals(colAi.owner))) {
9239
- const owners = [yesAi.owner.toBase58(), noAi.owner.toBase58(), colAi.owner.toBase58()];
9240
- throw new Error(`Market mint program mismatch. Owners: YES=${owners[0]}, NO=${owners[1]}, COLLATERAL=${owners[2]}. All mints must share the same token program.`);
9241
- }
9242
- const buyerYesTokenAccount = deriveAta(buyer, yesTokenMint, false, tokenProgramId, ataProgramId);
9243
- const buyerNoTokenAccount = deriveAta(buyer, noTokenMint, false, tokenProgramId, ataProgramId);
9244
- const buyerCollateralTokenAccount = deriveAta(buyer, collateralMint, false, tokenProgramId, ataProgramId);
9245
- const adminCollateralTokenAccount = deriveAta(admin, collateralMint, false, tokenProgramId, ataProgramId);
9246
- const marketReserveVault = deriveAta(market, collateralMint, true, tokenProgramId, ataProgramId);
9280
+ const buyerYesTokenAccount = deriveAta(buyer, yesTokenMint, false, decisionTokenProgramId, ataProgramId);
9281
+ const buyerNoTokenAccount = deriveAta(buyer, noTokenMint, false, decisionTokenProgramId, ataProgramId);
9282
+ const buyerCollateralTokenAccount = deriveAta(buyer, collateralMint, false, collateralTokenProgramId, ataProgramId);
9283
+ const adminCollateralTokenAccount = deriveAta(admin, collateralMint, false, collateralTokenProgramId, ataProgramId);
9284
+ const marketReserveVault = deriveAta(market, collateralMint, true, collateralTokenProgramId, ataProgramId);
9247
9285
  const accounts = {
9248
9286
  buyer,
9249
9287
  admin,
@@ -9259,7 +9297,10 @@ var TradingModule = class _TradingModule {
9259
9297
  buyer_collateral_token_account: buyerCollateralTokenAccount,
9260
9298
  admin_collateral_token_account: adminCollateralTokenAccount,
9261
9299
  creator_fee_treasury: creatorFeeTreasury,
9262
- token_program: tokenProgramId,
9300
+ token_program: collateralTokenProgramId,
9301
+ // For collateral (may be Token-2022)
9302
+ token_program_decision: decisionTokenProgramId,
9303
+ // For YES/NO tokens (always SPL Token)
9263
9304
  associated_token_program: ataProgramId,
9264
9305
  system_program: SystemProgram3.programId
9265
9306
  };
@@ -10910,6 +10951,98 @@ Cause: ${err.message}`);
10910
10951
  const acc = decodeAccount("GlobalConfig", ai.data);
10911
10952
  return { publicKey: pk, account: acc };
10912
10953
  }
10954
+ /**
10955
+ * Get V2 AMM market price data including prices and multipliers
10956
+ *
10957
+ * ✅ READ-ONLY - No signer required! Works with just an RPC connection.
10958
+ *
10959
+ * This function fetches on-chain market data and calculates:
10960
+ * - YES/NO token prices using the V2 AMM formula
10961
+ * - Multipliers (potential payout ratios)
10962
+ *
10963
+ * Formulas:
10964
+ * - YES Price: (marketReserves × yesTokenSupply) / (yesTokenSupply² + noTokenSupply²)
10965
+ * - NO Price: (marketReserves × noTokenSupply) / (yesTokenSupply² + noTokenSupply²)
10966
+ * - YES Multiplier: 1 + (noTokenSupply / yesTokenSupply)²
10967
+ * - NO Multiplier: 1 + (yesTokenSupply / noTokenSupply)²
10968
+ *
10969
+ * @param market - Market public key or address string
10970
+ * @returns V2 market price data with prices, multipliers, and supplies
10971
+ *
10972
+ * @example
10973
+ * ```typescript
10974
+ * // Works without a signer!
10975
+ * const client = new PNPClient("https://api.devnet.solana.com");
10976
+ * const priceData = await client.getMarketPriceV2("3LsfeB3RhQKJc2eHdEcb9XQzkF6eP9BFa6HTD6vvug9j");
10977
+ * console.log(`YES Price: ${priceData.yesPrice}`);
10978
+ * console.log(`NO Price: ${priceData.noPrice}`);
10979
+ * console.log(`YES Multiplier: ${priceData.yesMultiplier}x`);
10980
+ * ```
10981
+ */
10982
+ async getMarketPriceV2(market) {
10983
+ const marketPk = typeof market === "string" ? new PublicKey14(market) : market;
10984
+ const ai = await this.client.connection.getAccountInfo(marketPk, this.client.commitment);
10985
+ if (!ai) throw new Error("market account not found");
10986
+ const marketAccount = decodeAccount("Market", ai.data);
10987
+ const toBigInt = (value) => {
10988
+ if (value === void 0 || value === null) return 0n;
10989
+ if (typeof value === "bigint") return value;
10990
+ if (typeof value === "number") return BigInt(value);
10991
+ if (typeof value === "string") {
10992
+ try {
10993
+ return BigInt(value);
10994
+ } catch {
10995
+ return 0n;
10996
+ }
10997
+ }
10998
+ if (typeof value?.toString === "function") {
10999
+ try {
11000
+ return BigInt(value.toString());
11001
+ } catch {
11002
+ return 0n;
11003
+ }
11004
+ }
11005
+ return 0n;
11006
+ };
11007
+ const marketReservesRaw = toBigInt(marketAccount.marketReserves ?? marketAccount.market_reserves);
11008
+ const yesTokenSupplyRaw = toBigInt(marketAccount.yesTokenSupplyMinted ?? marketAccount.yes_token_supply_minted);
11009
+ const noTokenSupplyRaw = toBigInt(marketAccount.noTokenSupplyMinted ?? marketAccount.no_token_supply_minted);
11010
+ const SCALE = 1e6;
11011
+ const marketReserves = Number(marketReservesRaw) / SCALE;
11012
+ const yesTokenSupply = Number(yesTokenSupplyRaw) / SCALE;
11013
+ const noTokenSupply = Number(noTokenSupplyRaw) / SCALE;
11014
+ const denominator = Math.pow(yesTokenSupply, 2) + Math.pow(noTokenSupply, 2);
11015
+ let yesPrice = 0.5;
11016
+ let noPrice = 0.5;
11017
+ if (denominator > 0) {
11018
+ yesPrice = marketReserves * yesTokenSupply / denominator;
11019
+ noPrice = marketReserves * noTokenSupply / denominator;
11020
+ }
11021
+ let yesMultiplier = 2;
11022
+ let noMultiplier = 2;
11023
+ if (yesTokenSupply > 0 && noTokenSupply > 0) {
11024
+ yesMultiplier = 1 + Math.pow(noTokenSupply / yesTokenSupply, 2);
11025
+ noMultiplier = 1 + Math.pow(yesTokenSupply / noTokenSupply, 2);
11026
+ } else if (yesTokenSupply > 0) {
11027
+ yesMultiplier = 1;
11028
+ noMultiplier = Infinity;
11029
+ } else if (noTokenSupply > 0) {
11030
+ yesMultiplier = Infinity;
11031
+ noMultiplier = 1;
11032
+ }
11033
+ return {
11034
+ marketReserves,
11035
+ yesTokenSupply,
11036
+ noTokenSupply,
11037
+ yesPrice,
11038
+ noPrice,
11039
+ yesMultiplier,
11040
+ noMultiplier,
11041
+ marketReservesRaw,
11042
+ yesTokenSupplyRaw,
11043
+ noTokenSupplyRaw
11044
+ };
11045
+ }
10913
11046
  /**
10914
11047
  * Set market resolvable status (V2 markets)
10915
11048
  *
@@ -11661,4 +11794,4 @@ export {
11661
11794
  RedemptionModule,
11662
11795
  PNPClient
11663
11796
  };
11664
- //# sourceMappingURL=chunk-HN2SKUTC.js.map
11797
+ //# sourceMappingURL=chunk-SIMCEKAG.js.map