bet-test-sdk 1.2.0 → 1.2.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.
@@ -16043,6 +16043,7 @@ class CurveState {
16043
16043
  let r = n / i + 1n;
16044
16044
  // Calculate the amount of tokens to be purchased
16045
16045
  let s = this.virtualTokenReserves - r;
16046
+ s = s < 0n ? 0n : s;
16046
16047
  // Return the minimum of the calculated tokens and real token reserves
16047
16048
  return s < this.realTokenReserves ? s : this.realTokenReserves;
16048
16049
  }
@@ -16058,6 +16059,9 @@ class CurveState {
16058
16059
  // Calculate the fee amount in the same units
16059
16060
  let a = (n * feeBasisPoints) / DENOMINATOR;
16060
16061
  // Return the net amount after deducting the fee
16062
+ if (n - a < 0n) {
16063
+ return 0n;
16064
+ }
16061
16065
  return n - a;
16062
16066
  }
16063
16067
  getMarketCapSOL() {
@@ -16115,8 +16119,8 @@ class BetState {
16115
16119
  totalTokenIn;
16116
16120
  migrateType;
16117
16121
  isWithdrawed;
16118
- isCompted;
16119
- constructor(discriminator, creator, curveState, mint, poolOfSol, poolOfToken, totalSolIn, totalTokenOut, totalSolOut, totalTokenIn, migrateType, isWithdrawed, isCompted) {
16122
+ isCompleted;
16123
+ constructor(discriminator, creator, curveState, mint, poolOfSol, poolOfToken, totalSolIn, totalTokenOut, totalSolOut, totalTokenIn, migrateType, isWithdrawed, isCompleted) {
16120
16124
  this.discriminator = discriminator;
16121
16125
  this.creator = creator;
16122
16126
  this.curveState = curveState;
@@ -16129,7 +16133,7 @@ class BetState {
16129
16133
  this.totalTokenIn = totalTokenIn;
16130
16134
  this.migrateType = migrateType;
16131
16135
  this.isWithdrawed = isWithdrawed;
16132
- this.isCompted = isCompted;
16136
+ this.isCompleted = isCompleted;
16133
16137
  }
16134
16138
  static fromBuffer(buffer) {
16135
16139
  const structure = struct$1([
@@ -16145,10 +16149,10 @@ class BetState {
16145
16149
  u128("totalTokenIn"),
16146
16150
  u8$1("migrateType"),
16147
16151
  bool("isWithdrawed"),
16148
- bool("isCompted"),
16152
+ bool("isCompleted"),
16149
16153
  ]);
16150
16154
  let value = structure.decode(buffer);
16151
- return new BetState(BigInt(value.discriminator), new PublicKey(value.creator), new PublicKey(value.curveState), new PublicKey(value.mint), new PublicKey(value.poolOfSol), new PublicKey(value.poolOfToken), toBigInt(value.totalSolIn), toBigInt(value.totalTokenOut), toBigInt(value.totalSolOut), toBigInt(value.totalTokenIn), value.migrateType, value.isWithdrawed, value.isCompted);
16155
+ return new BetState(BigInt(value.discriminator), new PublicKey(value.creator), new PublicKey(value.curveState), new PublicKey(value.mint), new PublicKey(value.poolOfSol), new PublicKey(value.poolOfToken), toBigInt(value.totalSolIn), toBigInt(value.totalTokenOut), toBigInt(value.totalSolOut), toBigInt(value.totalTokenIn), value.migrateType, value.isWithdrawed, value.isCompleted);
16152
16156
  }
16153
16157
  }
16154
16158
 
@@ -18527,7 +18531,7 @@ var types = [
18527
18531
  type: "bool"
18528
18532
  },
18529
18533
  {
18530
- name: "is_compted",
18534
+ name: "is_completed",
18531
18535
  type: "bool"
18532
18536
  }
18533
18537
  ]
@@ -21843,7 +21847,7 @@ class BetSDK {
21843
21847
  if (!curveState) {
21844
21848
  throw new Error(`Curve state account not found: ${mint.toBase58()}`);
21845
21849
  }
21846
- let buyTokenAmount = curveState.getBuyPrice(buyAmountSol, betState.isCompted);
21850
+ let buyTokenAmount = curveState.getBuyPrice(buyAmountSol, betState.isCompleted);
21847
21851
  let buyAmountWithSlippage = calculateWithSlippage(buyTokenAmount, slippageBasisPoints);
21848
21852
  return await this.getBuyInstructions(buyer, mint, buyAmountSol, buyAmountWithSlippage);
21849
21853
  }
@@ -21878,7 +21882,7 @@ class BetSDK {
21878
21882
  if (!curveState) {
21879
21883
  throw new Error(`Curve state account not found: ${mint.toBase58()}`);
21880
21884
  }
21881
- const isCompleted = betState.isCompted;
21885
+ const isCompleted = betState.isCompleted;
21882
21886
  let minSolOutput = curveState.getSellPrice(sellTokenAmount, FEE_BASIS_POINTS, isCompleted);
21883
21887
  let minSolOutputWithSlippage = calculateWithSlippage(minSolOutput, slippageBasisPoints);
21884
21888
  return await this.getSellInstructions(seller, mint, sellTokenAmount, minSolOutputWithSlippage);
@@ -22123,8 +22127,8 @@ class BetSDK {
22123
22127
  console.error("Mint does not exist");
22124
22128
  return null;
22125
22129
  }
22126
- if (betStateAccount.isCompted) {
22127
- console.error("Compted");
22130
+ if (betStateAccount.isCompleted) {
22131
+ console.error("Completed");
22128
22132
  return null;
22129
22133
  }
22130
22134
  return curveStateAccount;