100x-sdk 1.0.4 → 1.0.6

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.
@@ -47695,11 +47695,46 @@ jsonBigint.exports.stringify = json_stringify;
47695
47695
 
47696
47696
  var jsonBigintExports = jsonBigint.exports;
47697
47697
 
47698
+ /** Format a non-negative integer ratio without converting its operands to Number. */
47699
+
47700
+ function formatRatio$2(numerator, denominator, decimals, multiplier = 1n, rounding = 'down', trim = false) {
47701
+ numerator = BigInt(numerator);
47702
+ denominator = BigInt(denominator);
47703
+ if (numerator < 0n || denominator <= 0n || !Number.isInteger(decimals) || decimals < 0) {
47704
+ throw new RangeError('Invalid ratio');
47705
+ }
47706
+
47707
+ const factor = 10n ** BigInt(decimals);
47708
+ const scaledNumerator = numerator * multiplier * factor;
47709
+ let quotient = scaledNumerator / denominator;
47710
+ if (rounding === 'half-up') {
47711
+ if ((scaledNumerator % denominator) * 2n >= denominator) quotient++;
47712
+ } else if (rounding !== 'down') {
47713
+ throw new RangeError('Invalid rounding mode');
47714
+ }
47715
+
47716
+ if (decimals === 0) return quotient.toString();
47717
+ const integer = quotient / factor;
47718
+ const fraction = (quotient % factor).toString().padStart(decimals, '0');
47719
+ const value = `${integer}.${fraction}`;
47720
+ return trim ? value.replace(/\.?0+$/, '') : value;
47721
+ }
47722
+
47723
+ function ceilDiv$1(numerator, denominator) {
47724
+ numerator = BigInt(numerator);
47725
+ denominator = BigInt(denominator);
47726
+ if (numerator < 0n || denominator <= 0n) throw new RangeError('Invalid division');
47727
+ return (numerator + denominator - 1n) / denominator;
47728
+ }
47729
+
47730
+ var precision = { formatRatio: formatRatio$2, ceilDiv: ceilDiv$1 };
47731
+
47698
47732
  const Decimal$1 = decimalExports;
47699
47733
  const CurveAMM$6 = curve_amm;
47700
47734
  const {transformOrdersData , checkPriceRangeOverlap} = stop_loss_utils;
47701
47735
  const { PRICE_ADJUSTMENT_PERCENTAGE, MIN_STOP_LOSS_PERCENT } = utils$2;
47702
47736
  jsonBigintExports({ storeAsString: false });
47737
+ const { formatRatio: formatRatio$1, ceilDiv } = precision;
47703
47738
 
47704
47739
  /**
47705
47740
  * Simulate long position stop loss calculation
@@ -47731,10 +47766,11 @@ jsonBigintExports({ storeAsString: false });
47731
47766
  * - For example: 3.5 means the stop loss price is 3.5% lower than the current price
47732
47767
  * - For a long position this value should be positive (stop loss price below current price)
47733
47768
  *
47734
- * @returns {number} returns.leverage - Leverage ratio
47769
+ * @returns {number} returns.leverage - Leverage ratio (existing four-decimal downward truncation)
47735
47770
  * - Formula: currentPrice / (currentPrice - executableStopLossPrice)
47736
47771
  * - For example: 28.57 means about 28.57x leverage
47737
47772
  * - The higher the leverage, the higher the risk, but also the higher the potential return
47773
+ * @returns {string} returns.leverageDisplay - Rounded display value derived from the executable stop-loss price; not a maximum leverage limit
47738
47774
  *
47739
47775
  * @returns {bigint} returns.currentPrice - Current price (u128 format)
47740
47776
  * - The current token price used in the calculation
@@ -47968,10 +48004,17 @@ async function simulateLongStopLoss$1(mint, buyTokenAmount, stopLossPrice, lastP
47968
48004
  // Calculate stop loss percentage
47969
48005
  let stopLossPercentage = 0;
47970
48006
  let leverage = 1;
48007
+ let leverageDisplay = '1';
47971
48008
 
47972
48009
  if (currentPrice !== executableStopLossPrice) {
47973
- stopLossPercentage = Number((BigInt(10000) * (currentPrice - executableStopLossPrice)) / currentPrice) / 100;
47974
- leverage = Number((BigInt(10000) * currentPrice) / (currentPrice - executableStopLossPrice)) / 10000;
48010
+ const priceDiff = currentPrice - executableStopLossPrice;
48011
+ stopLossPercentage = priceDiff >= 0n
48012
+ ? Number(formatRatio$1(priceDiff, currentPrice, 2, 100n))
48013
+ : Number((10000n * priceDiff) / currentPrice) / 100;
48014
+ leverage = Number((10000n * currentPrice) / priceDiff) / 10000;
48015
+ leverageDisplay = priceDiff > 0n
48016
+ ? formatRatio$1(currentPrice, priceDiff, 2, 1n, 'half-up', true)
48017
+ : String(leverage);
47975
48018
  }
47976
48019
 
47977
48020
  // Calculate margin requirement
@@ -48007,6 +48050,7 @@ async function simulateLongStopLoss$1(mint, buyTokenAmount, stopLossPrice, lastP
48007
48050
  tradeAmount: finalTradeAmount, // SOL output amount
48008
48051
  stopLossPercentage: stopLossPercentage, // Stop loss percentage relative to current price
48009
48052
  leverage: leverage, // Leverage ratio
48053
+ leverageDisplay: leverageDisplay, // Rounded display value; leverage keeps its existing meaning
48010
48054
  currentPrice: currentPrice, // Current price
48011
48055
  iterations: iteration, // Number of adjustments
48012
48056
  originalStopLossPrice: BigInt(stopLossPrice), // Original stop loss price
@@ -48051,10 +48095,11 @@ async function simulateLongStopLoss$1(mint, buyTokenAmount, stopLossPrice, lastP
48051
48095
  * - For example: 3.5 means the stop loss price is 3.5% higher than the current price
48052
48096
  * - For a short position this value should be positive (stop loss price above current price)
48053
48097
  *
48054
- * @returns {number} returns.leverage - Leverage ratio
48098
+ * @returns {number} returns.leverage - Leverage ratio (existing four-decimal downward truncation)
48055
48099
  * - Formula: currentPrice / (executableStopLossPrice - currentPrice)
48056
48100
  * - For example: 28.57 means about 28.57x leverage
48057
48101
  * - The higher the leverage, the higher the risk, but also the higher the potential return
48102
+ * @returns {string} returns.leverageDisplay - Rounded display value derived from the executable stop-loss price; not a maximum leverage limit
48058
48103
  *
48059
48104
  * @returns {bigint} returns.currentPrice - Current price (u128 format)
48060
48105
  * - The current token price used in the calculation
@@ -48280,11 +48325,17 @@ async function simulateShortStopLoss$1(mint, sellTokenAmount, stopLossPrice, las
48280
48325
 
48281
48326
  // Calculate stop loss percentage
48282
48327
  // For short position, stop loss price is higher than current price, so it's a positive percentage
48283
- const stopLossPercentage = Number((BigInt(10000) * (executableStopLossPrice - currentPrice)) / currentPrice) / 100;
48328
+ const priceDiff = executableStopLossPrice - currentPrice;
48329
+ const stopLossPercentage = priceDiff >= 0n
48330
+ ? Number(formatRatio$1(priceDiff, currentPrice, 2, 100n))
48331
+ : Number((10000n * priceDiff) / currentPrice) / 100;
48284
48332
 
48285
48333
  // Calculate leverage ratio
48286
48334
  // For short position, leverage = current price / (stop loss price - current price)
48287
- const leverage = Number((BigInt(10000) * currentPrice) / (executableStopLossPrice - currentPrice)) / 10000;
48335
+ const leverage = Number((10000n * currentPrice) / priceDiff) / 10000;
48336
+ const leverageDisplay = priceDiff > 0n
48337
+ ? formatRatio$1(currentPrice, priceDiff, 2, 1n, 'half-up', true)
48338
+ : String(leverage);
48288
48339
 
48289
48340
  // Calculate margin requirement
48290
48341
  // Consistent with the contract formula (long_short.rs lines 890-894):
@@ -48324,6 +48375,7 @@ async function simulateShortStopLoss$1(mint, sellTokenAmount, stopLossPrice, las
48324
48375
  tradeAmount: finalTradeAmount, // SOL input amount (SOL needed to buy back tokens at close)
48325
48376
  stopLossPercentage: stopLossPercentage, // Stop loss percentage relative to current price
48326
48377
  leverage: leverage, // Leverage ratio
48378
+ leverageDisplay: leverageDisplay, // Rounded display value; leverage keeps its existing meaning
48327
48379
  currentPrice: currentPrice, // Current price
48328
48380
  iterations: iteration, // Number of adjustments
48329
48381
  originalStopLossPrice: BigInt(stopLossPrice), // Original stop loss price
@@ -48451,8 +48503,9 @@ async function simulateLongSolStopLoss$1(mint, buySolAmount, stopLossPrice, last
48451
48503
  // Calculate dynamic binary search upper bound based on leverage
48452
48504
  const stopLossPriceBigInt = BigInt(stopLossPrice);
48453
48505
  const priceDiff = currentPrice - stopLossPriceBigInt;
48454
- const estimatedLeverage = priceDiff > 0n ? Number(currentPrice * 10000n / priceDiff) / 10000 : 10;
48455
- const safeMultiplier = BigInt(Math.ceil(estimatedLeverage * 3)); // 3x safety factor
48506
+ // Keep the original four-decimal leverage truncation used to size the search range.
48507
+ const scaledLeverage = priceDiff > 0n ? currentPrice * 10000n / priceDiff : 100000n;
48508
+ const safeMultiplier = ceilDiv(scaledLeverage * 3n, 10000n); // 3x safety factor
48456
48509
  const multiplier = safeMultiplier > 10n ? safeMultiplier : 10n; // minimum 10x
48457
48510
 
48458
48511
  // Use a binary search algorithm to find the maximum estimatedMargin that is less than buySolAmount
@@ -48637,8 +48690,9 @@ async function simulateShortSolStopLoss$1(mint, sellSolAmount, stopLossPrice, la
48637
48690
  // Calculate dynamic binary search upper bound based on leverage
48638
48691
  const stopLossPriceBigInt = BigInt(stopLossPrice);
48639
48692
  const priceDiff = stopLossPriceBigInt - currentPrice;
48640
- const estimatedLeverage = priceDiff > 0n ? Number(currentPrice * 10000n / priceDiff) / 10000 : 10;
48641
- const safeMultiplier = BigInt(Math.ceil(estimatedLeverage * 3)); // 3x safety factor
48693
+ // Keep the original four-decimal leverage truncation used to size the search range.
48694
+ const scaledLeverage = priceDiff > 0n ? currentPrice * 10000n / priceDiff : 100000n;
48695
+ const safeMultiplier = ceilDiv(scaledLeverage * 3n, 10000n); // 3x safety factor
48642
48696
  const multiplier = safeMultiplier > 10n ? safeMultiplier : 10n; // minimum 10x
48643
48697
 
48644
48698
  // Use a binary search algorithm to find the maximum estimatedMargin that is less than sellSolAmount
@@ -49476,6 +49530,7 @@ var calcLiq = {
49476
49530
  };
49477
49531
 
49478
49532
  const { calcLiqTokenBuy, calcLiqTokenSell } = calcLiq;
49533
+ const { formatRatio } = precision;
49479
49534
 
49480
49535
  /**
49481
49536
  * Simulate token buy transaction - calculate if target token amount can be purchased
@@ -49570,8 +49625,7 @@ async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPr
49570
49625
  if (freeTokenAmount >= buyTokenAmountBig) {
49571
49626
  completionPercentage = "100.0";
49572
49627
  } else {
49573
- const percentage = Math.floor((Number(freeTokenAmount) / Number(buyTokenAmountBig)) * 1000) / 10;
49574
- completionPercentage = percentage.toFixed(1);
49628
+ completionPercentage = formatRatio(freeTokenAmount, buyTokenAmountBig, 1, 100n);
49575
49629
  }
49576
49630
 
49577
49631
  // 2. Calculate slippage percentage and get final SOL amount
@@ -49582,8 +49636,7 @@ async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPr
49582
49636
  if (realSolAmount > 0n) {
49583
49637
  // Normal case: calculate slippage
49584
49638
  const diff = idealSolAmount > realSolAmount ? idealSolAmount - realSolAmount : realSolAmount - idealSolAmount;
49585
- const slippage = Math.floor((Number(diff) / Number(idealSolAmount)) * 1000) / 10;
49586
- slippagePercentage = slippage.toFixed(1);
49639
+ slippagePercentage = formatRatio(diff, idealSolAmount, 1, 100n);
49587
49640
  } else {
49588
49641
  // Special case: real SOL amount is 0, need to recalculate with suggested liquidity
49589
49642
  const suggestedAmount = (freeTokenAmount * BigInt(this.sdk.SUGGEST_LIQ_RATIO)) / 1000n;
@@ -49608,8 +49661,7 @@ async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPr
49608
49661
  finalRealSolAmount = recalcRealSol;
49609
49662
 
49610
49663
  const diff = recalcIdealSol > recalcRealSol ? recalcIdealSol - recalcRealSol : recalcRealSol - recalcIdealSol;
49611
- const slippage = Math.floor((Number(diff) / Number(recalcIdealSol)) * 1000) / 10;
49612
- slippagePercentage = slippage.toFixed(1);
49664
+ slippagePercentage = formatRatio(diff, recalcIdealSol, 1, 100n);
49613
49665
  }
49614
49666
 
49615
49667
  // 3. Calculate suggested liquidity
@@ -49728,8 +49780,7 @@ async function simulateTokenSell$1(mint, sellTokenAmount, passOrder = null, last
49728
49780
  if (freeTokenAmount >= sellTokenAmountBig) {
49729
49781
  completionPercentage = "100.0";
49730
49782
  } else {
49731
- const percentage = Math.floor((Number(freeTokenAmount) / Number(sellTokenAmountBig)) * 1000) / 10;
49732
- completionPercentage = percentage.toFixed(1);
49783
+ completionPercentage = formatRatio(freeTokenAmount, sellTokenAmountBig, 1, 100n);
49733
49784
  }
49734
49785
 
49735
49786
  // 2. Calculate slippage percentage and get final SOL amount
@@ -49740,8 +49791,7 @@ async function simulateTokenSell$1(mint, sellTokenAmount, passOrder = null, last
49740
49791
  if (realSolAmount > 0n) {
49741
49792
  // Normal case: calculate slippage
49742
49793
  const diff = idealSolAmount > realSolAmount ? idealSolAmount - realSolAmount : realSolAmount - idealSolAmount;
49743
- const slippage = Math.floor((Number(diff) / Number(idealSolAmount)) * 1000) / 10;
49744
- slippagePercentage = slippage.toFixed(1);
49794
+ slippagePercentage = formatRatio(diff, idealSolAmount, 1, 100n);
49745
49795
  } else {
49746
49796
  // Special case: real SOL amount is 0, need to recalculate with suggested liquidity
49747
49797
  const suggestedAmount = (freeTokenAmount * BigInt(this.sdk.SUGGEST_LIQ_RATIO)) / 1000n;
@@ -49766,8 +49816,7 @@ async function simulateTokenSell$1(mint, sellTokenAmount, passOrder = null, last
49766
49816
  finalRealSolAmount = recalcRealSol;
49767
49817
 
49768
49818
  const diff = recalcIdealSol > recalcRealSol ? recalcIdealSol - recalcRealSol : recalcRealSol - recalcIdealSol;
49769
- const slippage = Math.floor((Number(diff) / Number(recalcIdealSol)) * 1000) / 10;
49770
- slippagePercentage = slippage.toFixed(1);
49819
+ slippagePercentage = formatRatio(diff, recalcIdealSol, 1, 100n);
49771
49820
  }
49772
49821
 
49773
49822
  // 3. Calculate suggested liquidity
@@ -50622,9 +50671,9 @@ class SimulatorModule$1 {
50622
50671
  const tokenSellResult = await this.simulateTokenSell(mint, tokenAmountBigInt, null, priceResult, ordersResult);
50623
50672
 
50624
50673
  // Estimate ideal SOL amount
50625
- const priceDecimal = CurveAMM$3.u128ToDecimal(currentPrice);
50626
- const tokenInDecimal = Number(tokenAmountBigInt) / 1e9; // Convert token lamports to tokens (9-digit precision)
50627
- const estimatedSolAmount = BigInt(Math.floor((tokenInDecimal * priceDecimal) * 1e9)); // Convert to SOL lamports
50674
+ // Token and SOL both use 9 decimals, so their unit conversions cancel out.
50675
+ const priceScale = BigInt(CurveAMM$3.PRICE_PRECISION_FACTOR_DECIMAL.toFixed(0));
50676
+ const estimatedSolAmount = tokenAmountBigInt * currentPrice / priceScale;
50628
50677
 
50629
50678
  // Transform result to match simulateSell format
50630
50679
  return {
@@ -52385,7 +52434,7 @@ class OrderUtils$2 {
52385
52434
 
52386
52435
  var orderUtils = OrderUtils$2;
52387
52436
 
52388
- var address$1 = "sGecRTjTZmnqJBmLK4ZMNCzsaMrgkFfNqEcYk1GhRde";
52437
+ var address$1 = "EVNaaiyg9z876PUmLCVQcdc5L5eJukT4pni5GtVJ8P37";
52389
52438
  var metadata$1 = {
52390
52439
  name: "fun100x",
52391
52440
  version: "0.1.0",
@@ -55402,271 +55451,281 @@ var errors$1 = [
55402
55451
  },
55403
55452
  {
55404
55453
  code: 6062,
55454
+ name: "InsufficientLongPayerBalance",
55455
+ msg: "Payer wallet balance insufficient for long margin and fees"
55456
+ },
55457
+ {
55458
+ code: 6063,
55459
+ name: "InsufficientShortPayerBalance",
55460
+ msg: "Payer wallet balance insufficient for short margin and fees"
55461
+ },
55462
+ {
55463
+ code: 6064,
55405
55464
  name: "InvalidAccountOwner",
55406
55465
  msg: "Invalid account owner"
55407
55466
  },
55408
55467
  {
55409
- code: 6063,
55468
+ code: 6065,
55410
55469
  name: "SellAmountExceedsOrderAmount",
55411
55470
  msg: "Sell amount exceeds order's token holdings"
55412
55471
  },
55413
55472
  {
55414
- code: 6064,
55473
+ code: 6066,
55415
55474
  name: "OrderNotExpiredMustCloseByOwner",
55416
55475
  msg: "Non-expired order must be closed by owner"
55417
55476
  },
55418
55477
  {
55419
- code: 6065,
55478
+ code: 6067,
55420
55479
  name: "SettlementAddressMustBeOwnerAddress",
55421
55480
  msg: "Settlement address must be owner address"
55422
55481
  },
55423
55482
  {
55424
- code: 6066,
55483
+ code: 6068,
55425
55484
  name: "BuyAmountExceedsOrderAmount",
55426
55485
  msg: "Buy amount exceeds order's token holdings"
55427
55486
  },
55428
55487
  {
55429
- code: 6067,
55488
+ code: 6069,
55430
55489
  name: "InsufficientTradeAmount",
55431
55490
  msg: "Trade amount below minimum requirement"
55432
55491
  },
55433
55492
  {
55434
- code: 6068,
55493
+ code: 6070,
55435
55494
  name: "SolAmountTooLarge",
55436
55495
  msg: "SOL amount exceeds maximum limit (10000000 SOL per transaction)"
55437
55496
  },
55438
55497
  {
55439
- code: 6069,
55498
+ code: 6071,
55440
55499
  name: "RemainingTokenAmountTooSmall",
55441
55500
  msg: "Remaining token amount below minimum trade requirement"
55442
55501
  },
55443
55502
  {
55444
- code: 6070,
55503
+ code: 6072,
55445
55504
  name: "TradeCooldownNotExpired",
55446
55505
  msg: "Trade cooldown period not expired, please try again later"
55447
55506
  },
55448
55507
  {
55449
- code: 6071,
55508
+ code: 6073,
55450
55509
  name: "ExceedApprovalAmount",
55451
55510
  msg: "Sell amount exceeds approved amount, please call approval function first"
55452
55511
  },
55453
55512
  {
55454
- code: 6072,
55513
+ code: 6074,
55455
55514
  name: "CooldownNotInitialized",
55456
55515
  msg: "Sell trade requires calling approval or buy function first to initialize cooldown PDA"
55457
55516
  },
55458
55517
  {
55459
- code: 6073,
55518
+ code: 6075,
55460
55519
  name: "CannotCloseCooldownWithBalance",
55461
55520
  msg: "Cannot close cooldown PDA with non-zero token balance"
55462
55521
  },
55463
55522
  {
55464
- code: 6074,
55523
+ code: 6076,
55465
55524
  name: "PriceCalculationError",
55466
55525
  msg: "Price calculation error"
55467
55526
  },
55468
55527
  {
55469
- code: 6075,
55528
+ code: 6077,
55470
55529
  name: "InvalidPartnerFeeRecipientAccount",
55471
55530
  msg: "Invalid partner fee recipient account"
55472
55531
  },
55473
55532
  {
55474
- code: 6076,
55533
+ code: 6078,
55475
55534
  name: "InvalidBaseFeeRecipientAccount",
55476
55535
  msg: "Invalid base fee recipient account"
55477
55536
  },
55478
55537
  {
55479
- code: 6077,
55538
+ code: 6079,
55480
55539
  name: "InvalidOrderbookAddress",
55481
55540
  msg: "Orderbook address does not match curve account orderbook"
55482
55541
  },
55483
55542
  {
55484
- code: 6078,
55543
+ code: 6080,
55485
55544
  name: "InvalidFeePercentage",
55486
55545
  msg: "Fee percentage must be between 0-100"
55487
55546
  },
55488
55547
  {
55489
- code: 6079,
55548
+ code: 6081,
55490
55549
  name: "InvalidFeeRate",
55491
55550
  msg: "Fee rate exceeds maximum limit (10%)"
55492
55551
  },
55493
55552
  {
55494
- code: 6080,
55553
+ code: 6082,
55495
55554
  name: "InvalidCustomFeeRate",
55496
55555
  msg: "Custom fee rate must be between 1000 (1%) and 5000 (5%)"
55497
55556
  },
55498
55557
  {
55499
- code: 6081,
55558
+ code: 6083,
55500
55559
  name: "InvalidBorrowDuration",
55501
55560
  msg: "Borrow duration out of valid range (3-30 days)"
55502
55561
  },
55503
55562
  {
55504
- code: 6082,
55563
+ code: 6084,
55505
55564
  name: "InvalidStopLossPrice",
55506
55565
  msg: "Stop loss price does not meet minimum interval requirement"
55507
55566
  },
55508
55567
  {
55509
- code: 6083,
55568
+ code: 6085,
55510
55569
  name: "NoProfitableFunds",
55511
55570
  msg: "No profitable funds to transfer"
55512
55571
  },
55513
55572
  {
55514
- code: 6084,
55573
+ code: 6086,
55515
55574
  name: "InsufficientPoolFunds",
55516
55575
  msg: "Insufficient pool funds"
55517
55576
  },
55518
55577
  {
55519
- code: 6085,
55578
+ code: 6087,
55520
55579
  name: "InsufficientPoolBalance",
55521
55580
  msg: "Pool SOL account balance would fall below minimum required balance"
55522
55581
  },
55523
55582
  {
55524
- code: 6086,
55583
+ code: 6088,
55525
55584
  name: "OrderBookManagerOverflow",
55526
55585
  msg: "Math operation overflow"
55527
55586
  },
55528
55587
  {
55529
- code: 6087,
55588
+ code: 6089,
55530
55589
  name: "OrderBookManagerInvalidSlotIndex",
55531
55590
  msg: "Invalid slot index"
55532
55591
  },
55533
55592
  {
55534
- code: 6088,
55593
+ code: 6090,
55535
55594
  name: "OrderBookManagerInvalidAccountData",
55536
55595
  msg: "Invalid account data"
55537
55596
  },
55538
55597
  {
55539
- code: 6089,
55598
+ code: 6091,
55540
55599
  name: "OrderBookManagerExceedsMaxCapacity",
55541
55600
  msg: "New capacity exceeds maximum limit"
55542
55601
  },
55543
55602
  {
55544
- code: 6090,
55603
+ code: 6092,
55545
55604
  name: "OrderBookManagerExceedsAccountSizeLimit",
55546
55605
  msg: "Account size exceeds 10MB limit"
55547
55606
  },
55548
55607
  {
55549
- code: 6091,
55608
+ code: 6093,
55550
55609
  name: "OrderBookManagerOrderIdMismatch",
55551
55610
  msg: "Order ID mismatch"
55552
55611
  },
55553
55612
  {
55554
- code: 6092,
55613
+ code: 6094,
55555
55614
  name: "OrderBookManagerEmptyOrderBook",
55556
55615
  msg: "Order book is empty"
55557
55616
  },
55558
55617
  {
55559
- code: 6093,
55618
+ code: 6095,
55560
55619
  name: "OrderBookManagerAccountNotWritable",
55561
55620
  msg: "Account is not writable"
55562
55621
  },
55563
55622
  {
55564
- code: 6094,
55623
+ code: 6096,
55565
55624
  name: "OrderBookManagerNotRentExempt",
55566
55625
  msg: "Account not rent-exempt"
55567
55626
  },
55568
55627
  {
55569
- code: 6095,
55628
+ code: 6097,
55570
55629
  name: "OrderBookManagerInvalidRentBalance",
55571
55630
  msg: "Invalid rent balance"
55572
55631
  },
55573
55632
  {
55574
- code: 6096,
55633
+ code: 6098,
55575
55634
  name: "OrderBookManagerInsufficientFunds",
55576
55635
  msg: "Insufficient funds"
55577
55636
  },
55578
55637
  {
55579
- code: 6097,
55638
+ code: 6099,
55580
55639
  name: "OrderBookManagerInvalidAccountOwner",
55581
55640
  msg: "OrderBook account owner mismatch"
55582
55641
  },
55583
55642
  {
55584
- code: 6098,
55643
+ code: 6100,
55585
55644
  name: "OrderBookManagerDataOutOfBounds",
55586
55645
  msg: "Data access out of bounds"
55587
55646
  },
55588
55647
  {
55589
- code: 6099,
55648
+ code: 6101,
55590
55649
  name: "NoValidInsertPosition",
55591
55650
  msg: "Cannot find valid insert position, all candidates failed due to price range overlap"
55592
55651
  },
55593
55652
  {
55594
- code: 6100,
55653
+ code: 6102,
55595
55654
  name: "EmptyCloseInsertIndices",
55596
55655
  msg: "close_insert_indices array cannot be empty"
55597
55656
  },
55598
55657
  {
55599
- code: 6101,
55658
+ code: 6103,
55600
55659
  name: "TooManyCloseInsertIndices",
55601
55660
  msg: "close_insert_indices array cannot exceed 20 elements"
55602
55661
  },
55603
55662
  {
55604
- code: 6102,
55663
+ code: 6104,
55605
55664
  name: "CloseOrderNotFound",
55606
55665
  msg: "Specified close order not found"
55607
55666
  },
55608
55667
  {
55609
- code: 6103,
55668
+ code: 6105,
55610
55669
  name: "LinkedListDeleteCountMismatch",
55611
55670
  msg: "Linked list delete count mismatch: count inconsistent before/after deletion"
55612
55671
  },
55613
55672
  {
55614
- code: 6104,
55673
+ code: 6106,
55615
55674
  name: "NameTooLong",
55616
55675
  msg: "Token name too long, max 32 bytes"
55617
55676
  },
55618
55677
  {
55619
- code: 6105,
55678
+ code: 6107,
55620
55679
  name: "NameEmpty",
55621
55680
  msg: "Token name cannot be empty"
55622
55681
  },
55623
55682
  {
55624
- code: 6106,
55683
+ code: 6108,
55625
55684
  name: "SymbolTooLong",
55626
55685
  msg: "Token symbol too long, max 10 bytes"
55627
55686
  },
55628
55687
  {
55629
- code: 6107,
55688
+ code: 6109,
55630
55689
  name: "SymbolEmpty",
55631
55690
  msg: "Token symbol cannot be empty"
55632
55691
  },
55633
55692
  {
55634
- code: 6108,
55693
+ code: 6110,
55635
55694
  name: "UriTooLong",
55636
55695
  msg: "URI too long, max 200 bytes"
55637
55696
  },
55638
55697
  {
55639
- code: 6109,
55698
+ code: 6111,
55640
55699
  name: "UriEmpty",
55641
55700
  msg: "URI cannot be empty"
55642
55701
  },
55643
55702
  {
55644
- code: 6110,
55703
+ code: 6112,
55645
55704
  name: "IncompleteAdvancedPoolParams",
55646
55705
  msg: "Incomplete advanced pool parameters: custom_lp_sol, custom_lp_token, custom_borrow_ratio, custom_borrow_duration must be provided together"
55647
55706
  },
55648
55707
  {
55649
- code: 6111,
55708
+ code: 6113,
55650
55709
  name: "InvalidInitialVirtualSol",
55651
55710
  msg: "Initial virtual SOL out of valid range"
55652
55711
  },
55653
55712
  {
55654
- code: 6112,
55713
+ code: 6114,
55655
55714
  name: "InvalidInitialVirtualToken",
55656
55715
  msg: "Initial virtual Token out of valid range"
55657
55716
  },
55658
55717
  {
55659
- code: 6113,
55718
+ code: 6115,
55660
55719
  name: "InvalidBorrowPoolRatio",
55661
55720
  msg: "Borrow pool ratio out of valid range"
55662
55721
  },
55663
55722
  {
55664
- code: 6114,
55723
+ code: 6116,
55665
55724
  name: "BorrowTokenCalculationOverflow",
55666
55725
  msg: "Borrow pool token amount calculation overflow"
55667
55726
  },
55668
55727
  {
55669
- code: 6115,
55728
+ code: 6117,
55670
55729
  name: "BorrowTokenAmountZero",
55671
55730
  msg: "Borrow pool token amount cannot be zero"
55672
55731
  }
@@ -55813,8 +55872,10 @@ var types$1 = [
55813
55872
  name: "pool_type",
55814
55873
  docs: [
55815
55874
  "Pool type",
55816
- "0 = Basic version (uses default parameters, supports fee halving)",
55817
- "1 = Advanced version (custom parameters, fees never halved)"
55875
+ "0 = Basic version (uses default parameters)",
55876
+ "1 = Advanced version (custom parameters)",
55877
+ "Note: BOTH pool types participate in fee halving milestones",
55878
+ "(dynamic thresholds at 100x/1000x/10000x of the pool's own initial price)"
55818
55879
  ],
55819
55880
  type: "u8"
55820
55881
  },
@@ -55822,8 +55883,8 @@ var types$1 = [
55822
55883
  name: "borrow_pool_ratio",
55823
55884
  docs: [
55824
55885
  "Borrow pool token ratio (recorded only for information display)",
55825
- "Actual value range: 5-30 (represents 5%-30%)",
55826
- "Basic version fixed at 20"
55886
+ "Actual value range: 2-8 (represents 2%-8%, deducted from total supply)",
55887
+ "Basic version fixed at 4"
55827
55888
  ],
55828
55889
  type: "u8"
55829
55890
  }
@@ -56399,7 +56460,7 @@ var require$$1 = {
56399
56460
  types: types$1
56400
56461
  };
56401
56462
 
56402
- var address = "sGecRTjTZmnqJBmLK4ZMNCzsaMrgkFfNqEcYk1GhRde";
56463
+ var address = "EVNaaiyg9z876PUmLCVQcdc5L5eJukT4pni5GtVJ8P37";
56403
56464
  var metadata = {
56404
56465
  name: "fun100x",
56405
56466
  version: "0.1.0",
@@ -59416,271 +59477,281 @@ var errors = [
59416
59477
  },
59417
59478
  {
59418
59479
  code: 6062,
59480
+ name: "InsufficientLongPayerBalance",
59481
+ msg: "Payer wallet balance insufficient for long margin and fees"
59482
+ },
59483
+ {
59484
+ code: 6063,
59485
+ name: "InsufficientShortPayerBalance",
59486
+ msg: "Payer wallet balance insufficient for short margin and fees"
59487
+ },
59488
+ {
59489
+ code: 6064,
59419
59490
  name: "InvalidAccountOwner",
59420
59491
  msg: "Invalid account owner"
59421
59492
  },
59422
59493
  {
59423
- code: 6063,
59494
+ code: 6065,
59424
59495
  name: "SellAmountExceedsOrderAmount",
59425
59496
  msg: "Sell amount exceeds order's token holdings"
59426
59497
  },
59427
59498
  {
59428
- code: 6064,
59499
+ code: 6066,
59429
59500
  name: "OrderNotExpiredMustCloseByOwner",
59430
59501
  msg: "Non-expired order must be closed by owner"
59431
59502
  },
59432
59503
  {
59433
- code: 6065,
59504
+ code: 6067,
59434
59505
  name: "SettlementAddressMustBeOwnerAddress",
59435
59506
  msg: "Settlement address must be owner address"
59436
59507
  },
59437
59508
  {
59438
- code: 6066,
59509
+ code: 6068,
59439
59510
  name: "BuyAmountExceedsOrderAmount",
59440
59511
  msg: "Buy amount exceeds order's token holdings"
59441
59512
  },
59442
59513
  {
59443
- code: 6067,
59514
+ code: 6069,
59444
59515
  name: "InsufficientTradeAmount",
59445
59516
  msg: "Trade amount below minimum requirement"
59446
59517
  },
59447
59518
  {
59448
- code: 6068,
59519
+ code: 6070,
59449
59520
  name: "SolAmountTooLarge",
59450
59521
  msg: "SOL amount exceeds maximum limit (10000000 SOL per transaction)"
59451
59522
  },
59452
59523
  {
59453
- code: 6069,
59524
+ code: 6071,
59454
59525
  name: "RemainingTokenAmountTooSmall",
59455
59526
  msg: "Remaining token amount below minimum trade requirement"
59456
59527
  },
59457
59528
  {
59458
- code: 6070,
59529
+ code: 6072,
59459
59530
  name: "TradeCooldownNotExpired",
59460
59531
  msg: "Trade cooldown period not expired, please try again later"
59461
59532
  },
59462
59533
  {
59463
- code: 6071,
59534
+ code: 6073,
59464
59535
  name: "ExceedApprovalAmount",
59465
59536
  msg: "Sell amount exceeds approved amount, please call approval function first"
59466
59537
  },
59467
59538
  {
59468
- code: 6072,
59539
+ code: 6074,
59469
59540
  name: "CooldownNotInitialized",
59470
59541
  msg: "Sell trade requires calling approval or buy function first to initialize cooldown PDA"
59471
59542
  },
59472
59543
  {
59473
- code: 6073,
59544
+ code: 6075,
59474
59545
  name: "CannotCloseCooldownWithBalance",
59475
59546
  msg: "Cannot close cooldown PDA with non-zero token balance"
59476
59547
  },
59477
59548
  {
59478
- code: 6074,
59549
+ code: 6076,
59479
59550
  name: "PriceCalculationError",
59480
59551
  msg: "Price calculation error"
59481
59552
  },
59482
59553
  {
59483
- code: 6075,
59554
+ code: 6077,
59484
59555
  name: "InvalidPartnerFeeRecipientAccount",
59485
59556
  msg: "Invalid partner fee recipient account"
59486
59557
  },
59487
59558
  {
59488
- code: 6076,
59559
+ code: 6078,
59489
59560
  name: "InvalidBaseFeeRecipientAccount",
59490
59561
  msg: "Invalid base fee recipient account"
59491
59562
  },
59492
59563
  {
59493
- code: 6077,
59564
+ code: 6079,
59494
59565
  name: "InvalidOrderbookAddress",
59495
59566
  msg: "Orderbook address does not match curve account orderbook"
59496
59567
  },
59497
59568
  {
59498
- code: 6078,
59569
+ code: 6080,
59499
59570
  name: "InvalidFeePercentage",
59500
59571
  msg: "Fee percentage must be between 0-100"
59501
59572
  },
59502
59573
  {
59503
- code: 6079,
59574
+ code: 6081,
59504
59575
  name: "InvalidFeeRate",
59505
59576
  msg: "Fee rate exceeds maximum limit (10%)"
59506
59577
  },
59507
59578
  {
59508
- code: 6080,
59579
+ code: 6082,
59509
59580
  name: "InvalidCustomFeeRate",
59510
59581
  msg: "Custom fee rate must be between 1000 (1%) and 5000 (5%)"
59511
59582
  },
59512
59583
  {
59513
- code: 6081,
59584
+ code: 6083,
59514
59585
  name: "InvalidBorrowDuration",
59515
59586
  msg: "Borrow duration out of valid range (3-30 days)"
59516
59587
  },
59517
59588
  {
59518
- code: 6082,
59589
+ code: 6084,
59519
59590
  name: "InvalidStopLossPrice",
59520
59591
  msg: "Stop loss price does not meet minimum interval requirement"
59521
59592
  },
59522
59593
  {
59523
- code: 6083,
59594
+ code: 6085,
59524
59595
  name: "NoProfitableFunds",
59525
59596
  msg: "No profitable funds to transfer"
59526
59597
  },
59527
59598
  {
59528
- code: 6084,
59599
+ code: 6086,
59529
59600
  name: "InsufficientPoolFunds",
59530
59601
  msg: "Insufficient pool funds"
59531
59602
  },
59532
59603
  {
59533
- code: 6085,
59604
+ code: 6087,
59534
59605
  name: "InsufficientPoolBalance",
59535
59606
  msg: "Pool SOL account balance would fall below minimum required balance"
59536
59607
  },
59537
59608
  {
59538
- code: 6086,
59609
+ code: 6088,
59539
59610
  name: "OrderBookManagerOverflow",
59540
59611
  msg: "Math operation overflow"
59541
59612
  },
59542
59613
  {
59543
- code: 6087,
59614
+ code: 6089,
59544
59615
  name: "OrderBookManagerInvalidSlotIndex",
59545
59616
  msg: "Invalid slot index"
59546
59617
  },
59547
59618
  {
59548
- code: 6088,
59619
+ code: 6090,
59549
59620
  name: "OrderBookManagerInvalidAccountData",
59550
59621
  msg: "Invalid account data"
59551
59622
  },
59552
59623
  {
59553
- code: 6089,
59624
+ code: 6091,
59554
59625
  name: "OrderBookManagerExceedsMaxCapacity",
59555
59626
  msg: "New capacity exceeds maximum limit"
59556
59627
  },
59557
59628
  {
59558
- code: 6090,
59629
+ code: 6092,
59559
59630
  name: "OrderBookManagerExceedsAccountSizeLimit",
59560
59631
  msg: "Account size exceeds 10MB limit"
59561
59632
  },
59562
59633
  {
59563
- code: 6091,
59634
+ code: 6093,
59564
59635
  name: "OrderBookManagerOrderIdMismatch",
59565
59636
  msg: "Order ID mismatch"
59566
59637
  },
59567
59638
  {
59568
- code: 6092,
59639
+ code: 6094,
59569
59640
  name: "OrderBookManagerEmptyOrderBook",
59570
59641
  msg: "Order book is empty"
59571
59642
  },
59572
59643
  {
59573
- code: 6093,
59644
+ code: 6095,
59574
59645
  name: "OrderBookManagerAccountNotWritable",
59575
59646
  msg: "Account is not writable"
59576
59647
  },
59577
59648
  {
59578
- code: 6094,
59649
+ code: 6096,
59579
59650
  name: "OrderBookManagerNotRentExempt",
59580
59651
  msg: "Account not rent-exempt"
59581
59652
  },
59582
59653
  {
59583
- code: 6095,
59654
+ code: 6097,
59584
59655
  name: "OrderBookManagerInvalidRentBalance",
59585
59656
  msg: "Invalid rent balance"
59586
59657
  },
59587
59658
  {
59588
- code: 6096,
59659
+ code: 6098,
59589
59660
  name: "OrderBookManagerInsufficientFunds",
59590
59661
  msg: "Insufficient funds"
59591
59662
  },
59592
59663
  {
59593
- code: 6097,
59664
+ code: 6099,
59594
59665
  name: "OrderBookManagerInvalidAccountOwner",
59595
59666
  msg: "OrderBook account owner mismatch"
59596
59667
  },
59597
59668
  {
59598
- code: 6098,
59669
+ code: 6100,
59599
59670
  name: "OrderBookManagerDataOutOfBounds",
59600
59671
  msg: "Data access out of bounds"
59601
59672
  },
59602
59673
  {
59603
- code: 6099,
59674
+ code: 6101,
59604
59675
  name: "NoValidInsertPosition",
59605
59676
  msg: "Cannot find valid insert position, all candidates failed due to price range overlap"
59606
59677
  },
59607
59678
  {
59608
- code: 6100,
59679
+ code: 6102,
59609
59680
  name: "EmptyCloseInsertIndices",
59610
59681
  msg: "close_insert_indices array cannot be empty"
59611
59682
  },
59612
59683
  {
59613
- code: 6101,
59684
+ code: 6103,
59614
59685
  name: "TooManyCloseInsertIndices",
59615
59686
  msg: "close_insert_indices array cannot exceed 20 elements"
59616
59687
  },
59617
59688
  {
59618
- code: 6102,
59689
+ code: 6104,
59619
59690
  name: "CloseOrderNotFound",
59620
59691
  msg: "Specified close order not found"
59621
59692
  },
59622
59693
  {
59623
- code: 6103,
59694
+ code: 6105,
59624
59695
  name: "LinkedListDeleteCountMismatch",
59625
59696
  msg: "Linked list delete count mismatch: count inconsistent before/after deletion"
59626
59697
  },
59627
59698
  {
59628
- code: 6104,
59699
+ code: 6106,
59629
59700
  name: "NameTooLong",
59630
59701
  msg: "Token name too long, max 32 bytes"
59631
59702
  },
59632
59703
  {
59633
- code: 6105,
59704
+ code: 6107,
59634
59705
  name: "NameEmpty",
59635
59706
  msg: "Token name cannot be empty"
59636
59707
  },
59637
59708
  {
59638
- code: 6106,
59709
+ code: 6108,
59639
59710
  name: "SymbolTooLong",
59640
59711
  msg: "Token symbol too long, max 10 bytes"
59641
59712
  },
59642
59713
  {
59643
- code: 6107,
59714
+ code: 6109,
59644
59715
  name: "SymbolEmpty",
59645
59716
  msg: "Token symbol cannot be empty"
59646
59717
  },
59647
59718
  {
59648
- code: 6108,
59719
+ code: 6110,
59649
59720
  name: "UriTooLong",
59650
59721
  msg: "URI too long, max 200 bytes"
59651
59722
  },
59652
59723
  {
59653
- code: 6109,
59724
+ code: 6111,
59654
59725
  name: "UriEmpty",
59655
59726
  msg: "URI cannot be empty"
59656
59727
  },
59657
59728
  {
59658
- code: 6110,
59729
+ code: 6112,
59659
59730
  name: "IncompleteAdvancedPoolParams",
59660
59731
  msg: "Incomplete advanced pool parameters: custom_lp_sol, custom_lp_token, custom_borrow_ratio, custom_borrow_duration must be provided together"
59661
59732
  },
59662
59733
  {
59663
- code: 6111,
59734
+ code: 6113,
59664
59735
  name: "InvalidInitialVirtualSol",
59665
59736
  msg: "Initial virtual SOL out of valid range"
59666
59737
  },
59667
59738
  {
59668
- code: 6112,
59739
+ code: 6114,
59669
59740
  name: "InvalidInitialVirtualToken",
59670
59741
  msg: "Initial virtual Token out of valid range"
59671
59742
  },
59672
59743
  {
59673
- code: 6113,
59744
+ code: 6115,
59674
59745
  name: "InvalidBorrowPoolRatio",
59675
59746
  msg: "Borrow pool ratio out of valid range"
59676
59747
  },
59677
59748
  {
59678
- code: 6114,
59749
+ code: 6116,
59679
59750
  name: "BorrowTokenCalculationOverflow",
59680
59751
  msg: "Borrow pool token amount calculation overflow"
59681
59752
  },
59682
59753
  {
59683
- code: 6115,
59754
+ code: 6117,
59684
59755
  name: "BorrowTokenAmountZero",
59685
59756
  msg: "Borrow pool token amount cannot be zero"
59686
59757
  }
@@ -59827,8 +59898,10 @@ var types = [
59827
59898
  name: "pool_type",
59828
59899
  docs: [
59829
59900
  "Pool type",
59830
- "0 = Basic version (uses default parameters, supports fee halving)",
59831
- "1 = Advanced version (custom parameters, fees never halved)"
59901
+ "0 = Basic version (uses default parameters)",
59902
+ "1 = Advanced version (custom parameters)",
59903
+ "Note: BOTH pool types participate in fee halving milestones",
59904
+ "(dynamic thresholds at 100x/1000x/10000x of the pool's own initial price)"
59832
59905
  ],
59833
59906
  type: "u8"
59834
59907
  },
@@ -59836,8 +59909,8 @@ var types = [
59836
59909
  name: "borrow_pool_ratio",
59837
59910
  docs: [
59838
59911
  "Borrow pool token ratio (recorded only for information display)",
59839
- "Actual value range: 5-30 (represents 5%-30%)",
59840
- "Basic version fixed at 20"
59912
+ "Actual value range: 2-8 (represents 2%-8%, deducted from total supply)",
59913
+ "Basic version fixed at 4"
59841
59914
  ],
59842
59915
  type: "u8"
59843
59916
  }
@@ -60630,8 +60703,8 @@ const DEFAULT_NETWORKS = {
60630
60703
  network: 'mainnet',
60631
60704
  programId: 'sGecRTjTZmnqJBmLK4ZMNCzsaMrgkFfNqEcYk1GhRde',
60632
60705
  defaultDataSource: 'fast',
60633
- solanaEndpoint: 'https://solana-rpc.pinpet.fun',
60634
- fastApiUrl: 'https://api.pinpet.fun/',
60706
+ solanaEndpoint: 'https://solana-rpc.100x.fun',
60707
+ fastApiUrl: 'https://api.100x.fun/',
60635
60708
  feeRecipient: 'CmDe8JRAPJ7QpZNCb4ArVEyzyxYoCNL7WZw5qXLePULn',
60636
60709
  baseFeeRecipient: '2xhAfEfnH8wg7ZGujSijJi4Zt4ge1ZuwMypo7etntgXA',
60637
60710
  paramsAccount: 'CJSn3n4MVCg4qWQ7qb2nxzosYwfcRyBvmwhtM77ugu1V'
@@ -60642,7 +60715,7 @@ const DEFAULT_NETWORKS = {
60642
60715
  programId: 'sGecRTjTZmnqJBmLK4ZMNCzsaMrgkFfNqEcYk1GhRde',
60643
60716
  defaultDataSource: 'fast',
60644
60717
  solanaEndpoint: 'https://lu-ura5lv-fast-devnet.helius-rpc.com',
60645
- fastApiUrl: 'https://devtestapi.pinpet.fun',
60718
+ fastApiUrl: 'https://devtestapi.100x.fun',
60646
60719
  feeRecipient: 'GesAj2dTn2wdNcxj4x8qsqS9aNRVPBPkE76aaqg7skxu',
60647
60720
  baseFeeRecipient: '5YHi1HsxobLiTD6NQfHJQpoPoRjMuNyXp4RroTvR6dKi',
60648
60721
  paramsAccount: 'Ckz5CmbpyKtKmwgw7NDLzFnVACxekWqrX8i6vhCyLkqY'
@@ -60654,8 +60727,6 @@ const DEFAULT_NETWORKS = {
60654
60727
  defaultDataSource: 'fast', // 'fast' or 'chain'
60655
60728
  solanaEndpoint: 'http://127.0.0.1:8899',
60656
60729
  fastApiUrl: 'http://127.0.0.1:3000',
60657
- // solanaEndpoint: 'http://216.158.231.58:8899',
60658
- // fastApiUrl: 'http://216.158.231.58:3000',
60659
60730
  feeRecipient: 'GesAj2dTn2wdNcxj4x8qsqS9aNRVPBPkE76aaqg7skxu',
60660
60731
  baseFeeRecipient: '5YHi1HsxobLiTD6NQfHJQpoPoRjMuNyXp4RroTvR6dKi',
60661
60732
  paramsAccount: 'HPuvtLLcgSMPSyRmULPiFe9oAvm1o8mR4weqXZrUhzRM'