@cypher-zk/sdk 0.5.0 → 0.7.0

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { __commonJS, __toESM } from './chunk-5WRI5ZAA.js';
2
- import idlJson from './cypher-M5PH6UM5.json';
2
+ import idlJson from './cypher-G57ZWFM3.json';
3
3
  import { PublicKey, AddressLookupTableProgram, SystemProgram, Transaction } from '@solana/web3.js';
4
4
  import { BN, AnchorProvider, Program, BorshCoder, EventParser } from '@anchor-lang/core';
5
5
  import { getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID } from '@solana/spl-token';
@@ -2009,7 +2009,7 @@ var CLUSTERS = {
2009
2009
  };
2010
2010
  var ACCOUNT_DISCRIMINATOR_SIZE = 8;
2011
2011
  var MIN_BET_USDC = 1000000n;
2012
- var CREATOR_BOND = 10000000n;
2012
+ var MIN_CREATOR_BOND = 20000000n;
2013
2013
  var DEFAULT_RESOLUTION_WINDOW_SECS = 7 * 24 * 3600;
2014
2014
  var DEFAULT_CLAIM_PERIOD_SECS = 14 * 24 * 3600;
2015
2015
  var DEFAULT_REFUND_PERIOD_SECS = 14 * 24 * 3600;
@@ -2224,11 +2224,12 @@ var CypherErrorCode = {
2224
2224
  NotAcceptedMint: 6034,
2225
2225
  InvalidCategory: 6035,
2226
2226
  InvalidChallengePeriod: 6036,
2227
- NotPendingResolution: 6037,
2228
- ChallengePeriodNotElapsed: 6038,
2229
- ChallengePeriodElapsed: 6039,
2230
- MarketDisputed: 6040,
2231
- MarketNotDisputed: 6041
2227
+ BondTooSmall: 6037,
2228
+ NotPendingResolution: 6038,
2229
+ ChallengePeriodNotElapsed: 6039,
2230
+ ChallengePeriodElapsed: 6040,
2231
+ MarketDisputed: 6041,
2232
+ MarketNotDisputed: 6042
2232
2233
  };
2233
2234
  var CYPHER_ERROR_MESSAGES = Object.freeze(
2234
2235
  Object.fromEntries(
@@ -2679,6 +2680,11 @@ function validateMarketDraft(params) {
2679
2680
  `createMarketIx: challengePeriod must be in [${MIN_CHALLENGE_PERIOD_SECS}, ${MAX_CHALLENGE_PERIOD_SECS}] seconds`
2680
2681
  );
2681
2682
  }
2683
+ if (BigInt(params.bondAmount) < MIN_CREATOR_BOND) {
2684
+ throw new Error(
2685
+ `createMarketIx: bondAmount must be >= ${MIN_CREATOR_BOND} (MIN_CREATOR_BOND = $20 USDC)`
2686
+ );
2687
+ }
2682
2688
  }
2683
2689
  async function createMarketIx(client, params) {
2684
2690
  validateMarketDraft(params);
@@ -2691,7 +2697,8 @@ async function createMarketIx(client, params) {
2691
2697
  params.question,
2692
2698
  toBN(params.closeTime),
2693
2699
  params.category,
2694
- toBN(params.challengePeriod)
2700
+ toBN(params.challengePeriod),
2701
+ toBN(params.bondAmount)
2695
2702
  ).accountsPartial({
2696
2703
  creator: params.creator,
2697
2704
  globalState: gsPda,
@@ -2721,7 +2728,8 @@ async function createMarketMultiIx(client, params) {
2721
2728
  toBN(params.closeTime),
2722
2729
  params.category,
2723
2730
  params.numOutcomes,
2724
- toBN(params.challengePeriod)
2731
+ toBN(params.challengePeriod),
2732
+ toBN(params.bondAmount)
2725
2733
  ).accountsPartial({
2726
2734
  creator: params.creator,
2727
2735
  globalState: gsPda,
@@ -3101,16 +3109,19 @@ async function createMarketCommon(client, inputs) {
3101
3109
  const acceptedMint = inputs.acceptedMint ?? gs.acceptedMint;
3102
3110
  const expectedMarketId = gs.marketCounter;
3103
3111
  const challengePeriod = inputs.challengePeriod ?? MIN_CHALLENGE_PERIOD_SECS;
3112
+ const bondAmount = inputs.bondAmount ?? MIN_CREATOR_BOND;
3104
3113
  const ix = inputs.kind === "yesno" ? await createMarketIx(client, {
3105
3114
  ...inputs,
3106
3115
  acceptedMint,
3107
3116
  expectedMarketId,
3108
- challengePeriod
3117
+ challengePeriod,
3118
+ bondAmount
3109
3119
  }) : await createMarketMultiIx(client, {
3110
3120
  ...inputs,
3111
3121
  acceptedMint,
3112
3122
  expectedMarketId,
3113
- challengePeriod
3123
+ challengePeriod,
3124
+ bondAmount
3114
3125
  });
3115
3126
  emitProgress(inputs.onProgress, "submitting", {
3116
3127
  message: "Submitting create-market transaction"
@@ -3927,6 +3938,6 @@ safe-buffer/index.js:
3927
3938
  (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
3928
3939
  */
3929
3940
 
3930
- export { ACCOUNT_DISCRIMINATOR_SIZE, ADDRESS_LOOKUP_TABLE_PROGRAM_ID, ALL_CIRCUITS, ALL_EVENT_NAMES, BPS_DENOMINATOR, CIRCUITS, CLUSTERS, CREATOR_BOND, CYPHER_ERROR_MESSAGES, CypherClient, CypherErrorCode, DEFAULT_CLAIM_PERIOD_SECS, DEFAULT_REFUND_PERIOD_SECS, DEFAULT_RESOLUTION_WINDOW_SECS, ENCRYPTED_POSITION_OFFSETS, GLOBAL_STATE_OFFSETS, IDL, IDL_PROGRAM_ID, INIT_COMP_DEF_INSTRUCTIONS, KNOWN_MINTS, LP_POSITION_OFFSETS, MARKET_OFFSETS, MAX_CHALLENGE_PERIOD_SECS, MAX_LP_FEE_BPS, MAX_OUTCOMES_MULTI, MAX_PROTOCOL_FEE_BPS, MAX_QUESTION_BYTES, MIN_BET_USDC, MIN_CHALLENGE_PERIOD_SECS, MIN_OUTCOMES_MULTI, MarketCategory, MarketState, MarketType, ODDS_SCALE, PROGRAM_ID, adminClaimRemainingIx, adminOverrideResolutionAction, adminOverrideResolutionIx, arciumSignerPda, awaitComputation, bigIntToLeBytes, buildAllInitCompDefIx, buildArciumQueueAccounts, cancelMarketAction, cancelMarketIx, claimPayoutAction, claimPayoutMultiIx, claimPayoutYesnoIx, claimRefundAction, claimRefundMultiIx, claimRefundYesnoIx, compDefOffsetBytes, compDefOffsetU32, computeFees, createCipher, createMarketAction, createMarketIx, createMarketMultiAction, createMarketMultiIx, createUserKeypair, cypherErrorName, decryptBetInput, deriveSharedSecret, discriminatorFilter, encryptBetInput, encryptRefundInput, fetchAllMarkets, fetchGlobalState, fetchLpPosition, fetchLpPositionsByProvider, fetchMarket, fetchMarketsByCreator, fetchMarketsByState, fetchMxeLookupTable, fetchMxePublicKey, fetchPosition, fetchPositionsForMarket, fetchUserPositions, finalizeResolutionAction, finalizeResolutionIx, flagResolutionAction, flagResolutionIx, freshNonce, globalStatePda, initCompDefIx, initializeIx, isBetAmountValid, isValidCloseTime, keypairToWallet, leBytesToBigInt, lpPositionFilters, lpPositionPda, marketFilters, marketPda, marketPhase, marketVaultPda, onBetPlaced, onCreatorWithdrawn, onMarketCancelled, onMarketCreated, onMarketFinalized, onMarketResolved, onPayoutClaimed, onRefundClaimed, onResolutionFlagged, onResolutionOverridden, parseCypherError, parseLogs, parseLogsFor, placeBetAction, placePrivateBetMultiIx, placePrivateBetYesnoIx, pollEvents, positionFilters, positionPda, projectDeadlines, randomComputationOffset, readonlyWallet, resolveMarketAction, resolveMarketMultiIx, resolveMarketYesnoIx, sendIx, sendIxAndAwaitArcium, subscribeAll, subscribeEvent, toBN, updateAcceptedMintIx, userAta, withdrawCreatorFundsAction, withdrawCreatorFundsIx };
3941
+ export { ACCOUNT_DISCRIMINATOR_SIZE, ADDRESS_LOOKUP_TABLE_PROGRAM_ID, ALL_CIRCUITS, ALL_EVENT_NAMES, BPS_DENOMINATOR, CIRCUITS, CLUSTERS, CYPHER_ERROR_MESSAGES, CypherClient, CypherErrorCode, DEFAULT_CLAIM_PERIOD_SECS, DEFAULT_REFUND_PERIOD_SECS, DEFAULT_RESOLUTION_WINDOW_SECS, ENCRYPTED_POSITION_OFFSETS, GLOBAL_STATE_OFFSETS, IDL, IDL_PROGRAM_ID, INIT_COMP_DEF_INSTRUCTIONS, KNOWN_MINTS, LP_POSITION_OFFSETS, MARKET_OFFSETS, MAX_CHALLENGE_PERIOD_SECS, MAX_LP_FEE_BPS, MAX_OUTCOMES_MULTI, MAX_PROTOCOL_FEE_BPS, MAX_QUESTION_BYTES, MIN_BET_USDC, MIN_CHALLENGE_PERIOD_SECS, MIN_CREATOR_BOND, MIN_OUTCOMES_MULTI, MarketCategory, MarketState, MarketType, ODDS_SCALE, PROGRAM_ID, adminClaimRemainingIx, adminOverrideResolutionAction, adminOverrideResolutionIx, arciumSignerPda, awaitComputation, bigIntToLeBytes, buildAllInitCompDefIx, buildArciumQueueAccounts, cancelMarketAction, cancelMarketIx, claimPayoutAction, claimPayoutMultiIx, claimPayoutYesnoIx, claimRefundAction, claimRefundMultiIx, claimRefundYesnoIx, compDefOffsetBytes, compDefOffsetU32, computeFees, createCipher, createMarketAction, createMarketIx, createMarketMultiAction, createMarketMultiIx, createUserKeypair, cypherErrorName, decryptBetInput, deriveSharedSecret, discriminatorFilter, encryptBetInput, encryptRefundInput, fetchAllMarkets, fetchGlobalState, fetchLpPosition, fetchLpPositionsByProvider, fetchMarket, fetchMarketsByCreator, fetchMarketsByState, fetchMxeLookupTable, fetchMxePublicKey, fetchPosition, fetchPositionsForMarket, fetchUserPositions, finalizeResolutionAction, finalizeResolutionIx, flagResolutionAction, flagResolutionIx, freshNonce, globalStatePda, initCompDefIx, initializeIx, isBetAmountValid, isValidCloseTime, keypairToWallet, leBytesToBigInt, lpPositionFilters, lpPositionPda, marketFilters, marketPda, marketPhase, marketVaultPda, onBetPlaced, onCreatorWithdrawn, onMarketCancelled, onMarketCreated, onMarketFinalized, onMarketResolved, onPayoutClaimed, onRefundClaimed, onResolutionFlagged, onResolutionOverridden, parseCypherError, parseLogs, parseLogsFor, placeBetAction, placePrivateBetMultiIx, placePrivateBetYesnoIx, pollEvents, positionFilters, positionPda, projectDeadlines, randomComputationOffset, readonlyWallet, resolveMarketAction, resolveMarketMultiIx, resolveMarketYesnoIx, sendIx, sendIxAndAwaitArcium, subscribeAll, subscribeEvent, toBN, updateAcceptedMintIx, userAta, withdrawCreatorFundsAction, withdrawCreatorFundsIx };
3931
3942
  //# sourceMappingURL=index.js.map
3932
3943
  //# sourceMappingURL=index.js.map