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.
@@ -36100,11 +36100,46 @@ jsonBigint.exports.stringify = json_stringify;
36100
36100
 
36101
36101
  var jsonBigintExports = jsonBigint.exports;
36102
36102
 
36103
+ /** Format a non-negative integer ratio without converting its operands to Number. */
36104
+
36105
+ function formatRatio$2(numerator, denominator, decimals, multiplier = 1n, rounding = 'down', trim = false) {
36106
+ numerator = BigInt(numerator);
36107
+ denominator = BigInt(denominator);
36108
+ if (numerator < 0n || denominator <= 0n || !Number.isInteger(decimals) || decimals < 0) {
36109
+ throw new RangeError('Invalid ratio');
36110
+ }
36111
+
36112
+ const factor = 10n ** BigInt(decimals);
36113
+ const scaledNumerator = numerator * multiplier * factor;
36114
+ let quotient = scaledNumerator / denominator;
36115
+ if (rounding === 'half-up') {
36116
+ if ((scaledNumerator % denominator) * 2n >= denominator) quotient++;
36117
+ } else if (rounding !== 'down') {
36118
+ throw new RangeError('Invalid rounding mode');
36119
+ }
36120
+
36121
+ if (decimals === 0) return quotient.toString();
36122
+ const integer = quotient / factor;
36123
+ const fraction = (quotient % factor).toString().padStart(decimals, '0');
36124
+ const value = `${integer}.${fraction}`;
36125
+ return trim ? value.replace(/\.?0+$/, '') : value;
36126
+ }
36127
+
36128
+ function ceilDiv$1(numerator, denominator) {
36129
+ numerator = BigInt(numerator);
36130
+ denominator = BigInt(denominator);
36131
+ if (numerator < 0n || denominator <= 0n) throw new RangeError('Invalid division');
36132
+ return (numerator + denominator - 1n) / denominator;
36133
+ }
36134
+
36135
+ var precision = { formatRatio: formatRatio$2, ceilDiv: ceilDiv$1 };
36136
+
36103
36137
  const Decimal$1 = decimalExports;
36104
36138
  const CurveAMM$6 = curve_amm;
36105
36139
  const {transformOrdersData , checkPriceRangeOverlap} = stop_loss_utils;
36106
36140
  const { PRICE_ADJUSTMENT_PERCENTAGE, MIN_STOP_LOSS_PERCENT } = utils$2;
36107
36141
  jsonBigintExports({ storeAsString: false });
36142
+ const { formatRatio: formatRatio$1, ceilDiv } = precision;
36108
36143
 
36109
36144
  /**
36110
36145
  * Simulate long position stop loss calculation
@@ -36136,10 +36171,11 @@ jsonBigintExports({ storeAsString: false });
36136
36171
  * - For example: 3.5 means the stop loss price is 3.5% lower than the current price
36137
36172
  * - For a long position this value should be positive (stop loss price below current price)
36138
36173
  *
36139
- * @returns {number} returns.leverage - Leverage ratio
36174
+ * @returns {number} returns.leverage - Leverage ratio (existing four-decimal downward truncation)
36140
36175
  * - Formula: currentPrice / (currentPrice - executableStopLossPrice)
36141
36176
  * - For example: 28.57 means about 28.57x leverage
36142
36177
  * - The higher the leverage, the higher the risk, but also the higher the potential return
36178
+ * @returns {string} returns.leverageDisplay - Rounded display value derived from the executable stop-loss price; not a maximum leverage limit
36143
36179
  *
36144
36180
  * @returns {bigint} returns.currentPrice - Current price (u128 format)
36145
36181
  * - The current token price used in the calculation
@@ -36373,10 +36409,17 @@ async function simulateLongStopLoss$1(mint, buyTokenAmount, stopLossPrice, lastP
36373
36409
  // Calculate stop loss percentage
36374
36410
  let stopLossPercentage = 0;
36375
36411
  let leverage = 1;
36412
+ let leverageDisplay = '1';
36376
36413
 
36377
36414
  if (currentPrice !== executableStopLossPrice) {
36378
- stopLossPercentage = Number((BigInt(10000) * (currentPrice - executableStopLossPrice)) / currentPrice) / 100;
36379
- leverage = Number((BigInt(10000) * currentPrice) / (currentPrice - executableStopLossPrice)) / 10000;
36415
+ const priceDiff = currentPrice - executableStopLossPrice;
36416
+ stopLossPercentage = priceDiff >= 0n
36417
+ ? Number(formatRatio$1(priceDiff, currentPrice, 2, 100n))
36418
+ : Number((10000n * priceDiff) / currentPrice) / 100;
36419
+ leverage = Number((10000n * currentPrice) / priceDiff) / 10000;
36420
+ leverageDisplay = priceDiff > 0n
36421
+ ? formatRatio$1(currentPrice, priceDiff, 2, 1n, 'half-up', true)
36422
+ : String(leverage);
36380
36423
  }
36381
36424
 
36382
36425
  // Calculate margin requirement
@@ -36412,6 +36455,7 @@ async function simulateLongStopLoss$1(mint, buyTokenAmount, stopLossPrice, lastP
36412
36455
  tradeAmount: finalTradeAmount, // SOL output amount
36413
36456
  stopLossPercentage: stopLossPercentage, // Stop loss percentage relative to current price
36414
36457
  leverage: leverage, // Leverage ratio
36458
+ leverageDisplay: leverageDisplay, // Rounded display value; leverage keeps its existing meaning
36415
36459
  currentPrice: currentPrice, // Current price
36416
36460
  iterations: iteration, // Number of adjustments
36417
36461
  originalStopLossPrice: BigInt(stopLossPrice), // Original stop loss price
@@ -36456,10 +36500,11 @@ async function simulateLongStopLoss$1(mint, buyTokenAmount, stopLossPrice, lastP
36456
36500
  * - For example: 3.5 means the stop loss price is 3.5% higher than the current price
36457
36501
  * - For a short position this value should be positive (stop loss price above current price)
36458
36502
  *
36459
- * @returns {number} returns.leverage - Leverage ratio
36503
+ * @returns {number} returns.leverage - Leverage ratio (existing four-decimal downward truncation)
36460
36504
  * - Formula: currentPrice / (executableStopLossPrice - currentPrice)
36461
36505
  * - For example: 28.57 means about 28.57x leverage
36462
36506
  * - The higher the leverage, the higher the risk, but also the higher the potential return
36507
+ * @returns {string} returns.leverageDisplay - Rounded display value derived from the executable stop-loss price; not a maximum leverage limit
36463
36508
  *
36464
36509
  * @returns {bigint} returns.currentPrice - Current price (u128 format)
36465
36510
  * - The current token price used in the calculation
@@ -36685,11 +36730,17 @@ async function simulateShortStopLoss$1(mint, sellTokenAmount, stopLossPrice, las
36685
36730
 
36686
36731
  // Calculate stop loss percentage
36687
36732
  // For short position, stop loss price is higher than current price, so it's a positive percentage
36688
- const stopLossPercentage = Number((BigInt(10000) * (executableStopLossPrice - currentPrice)) / currentPrice) / 100;
36733
+ const priceDiff = executableStopLossPrice - currentPrice;
36734
+ const stopLossPercentage = priceDiff >= 0n
36735
+ ? Number(formatRatio$1(priceDiff, currentPrice, 2, 100n))
36736
+ : Number((10000n * priceDiff) / currentPrice) / 100;
36689
36737
 
36690
36738
  // Calculate leverage ratio
36691
36739
  // For short position, leverage = current price / (stop loss price - current price)
36692
- const leverage = Number((BigInt(10000) * currentPrice) / (executableStopLossPrice - currentPrice)) / 10000;
36740
+ const leverage = Number((10000n * currentPrice) / priceDiff) / 10000;
36741
+ const leverageDisplay = priceDiff > 0n
36742
+ ? formatRatio$1(currentPrice, priceDiff, 2, 1n, 'half-up', true)
36743
+ : String(leverage);
36693
36744
 
36694
36745
  // Calculate margin requirement
36695
36746
  // Consistent with the contract formula (long_short.rs lines 890-894):
@@ -36729,6 +36780,7 @@ async function simulateShortStopLoss$1(mint, sellTokenAmount, stopLossPrice, las
36729
36780
  tradeAmount: finalTradeAmount, // SOL input amount (SOL needed to buy back tokens at close)
36730
36781
  stopLossPercentage: stopLossPercentage, // Stop loss percentage relative to current price
36731
36782
  leverage: leverage, // Leverage ratio
36783
+ leverageDisplay: leverageDisplay, // Rounded display value; leverage keeps its existing meaning
36732
36784
  currentPrice: currentPrice, // Current price
36733
36785
  iterations: iteration, // Number of adjustments
36734
36786
  originalStopLossPrice: BigInt(stopLossPrice), // Original stop loss price
@@ -36856,8 +36908,9 @@ async function simulateLongSolStopLoss$1(mint, buySolAmount, stopLossPrice, last
36856
36908
  // Calculate dynamic binary search upper bound based on leverage
36857
36909
  const stopLossPriceBigInt = BigInt(stopLossPrice);
36858
36910
  const priceDiff = currentPrice - stopLossPriceBigInt;
36859
- const estimatedLeverage = priceDiff > 0n ? Number(currentPrice * 10000n / priceDiff) / 10000 : 10;
36860
- const safeMultiplier = BigInt(Math.ceil(estimatedLeverage * 3)); // 3x safety factor
36911
+ // Keep the original four-decimal leverage truncation used to size the search range.
36912
+ const scaledLeverage = priceDiff > 0n ? currentPrice * 10000n / priceDiff : 100000n;
36913
+ const safeMultiplier = ceilDiv(scaledLeverage * 3n, 10000n); // 3x safety factor
36861
36914
  const multiplier = safeMultiplier > 10n ? safeMultiplier : 10n; // minimum 10x
36862
36915
 
36863
36916
  // Use a binary search algorithm to find the maximum estimatedMargin that is less than buySolAmount
@@ -37042,8 +37095,9 @@ async function simulateShortSolStopLoss$1(mint, sellSolAmount, stopLossPrice, la
37042
37095
  // Calculate dynamic binary search upper bound based on leverage
37043
37096
  const stopLossPriceBigInt = BigInt(stopLossPrice);
37044
37097
  const priceDiff = stopLossPriceBigInt - currentPrice;
37045
- const estimatedLeverage = priceDiff > 0n ? Number(currentPrice * 10000n / priceDiff) / 10000 : 10;
37046
- const safeMultiplier = BigInt(Math.ceil(estimatedLeverage * 3)); // 3x safety factor
37098
+ // Keep the original four-decimal leverage truncation used to size the search range.
37099
+ const scaledLeverage = priceDiff > 0n ? currentPrice * 10000n / priceDiff : 100000n;
37100
+ const safeMultiplier = ceilDiv(scaledLeverage * 3n, 10000n); // 3x safety factor
37047
37101
  const multiplier = safeMultiplier > 10n ? safeMultiplier : 10n; // minimum 10x
37048
37102
 
37049
37103
  // Use a binary search algorithm to find the maximum estimatedMargin that is less than sellSolAmount
@@ -37881,6 +37935,7 @@ var calcLiq = {
37881
37935
  };
37882
37936
 
37883
37937
  const { calcLiqTokenBuy, calcLiqTokenSell } = calcLiq;
37938
+ const { formatRatio } = precision;
37884
37939
 
37885
37940
  /**
37886
37941
  * Simulate token buy transaction - calculate if target token amount can be purchased
@@ -37975,8 +38030,7 @@ async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPr
37975
38030
  if (freeTokenAmount >= buyTokenAmountBig) {
37976
38031
  completionPercentage = "100.0";
37977
38032
  } else {
37978
- const percentage = Math.floor((Number(freeTokenAmount) / Number(buyTokenAmountBig)) * 1000) / 10;
37979
- completionPercentage = percentage.toFixed(1);
38033
+ completionPercentage = formatRatio(freeTokenAmount, buyTokenAmountBig, 1, 100n);
37980
38034
  }
37981
38035
 
37982
38036
  // 2. Calculate slippage percentage and get final SOL amount
@@ -37987,8 +38041,7 @@ async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPr
37987
38041
  if (realSolAmount > 0n) {
37988
38042
  // Normal case: calculate slippage
37989
38043
  const diff = idealSolAmount > realSolAmount ? idealSolAmount - realSolAmount : realSolAmount - idealSolAmount;
37990
- const slippage = Math.floor((Number(diff) / Number(idealSolAmount)) * 1000) / 10;
37991
- slippagePercentage = slippage.toFixed(1);
38044
+ slippagePercentage = formatRatio(diff, idealSolAmount, 1, 100n);
37992
38045
  } else {
37993
38046
  // Special case: real SOL amount is 0, need to recalculate with suggested liquidity
37994
38047
  const suggestedAmount = (freeTokenAmount * BigInt(this.sdk.SUGGEST_LIQ_RATIO)) / 1000n;
@@ -38013,8 +38066,7 @@ async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPr
38013
38066
  finalRealSolAmount = recalcRealSol;
38014
38067
 
38015
38068
  const diff = recalcIdealSol > recalcRealSol ? recalcIdealSol - recalcRealSol : recalcRealSol - recalcIdealSol;
38016
- const slippage = Math.floor((Number(diff) / Number(recalcIdealSol)) * 1000) / 10;
38017
- slippagePercentage = slippage.toFixed(1);
38069
+ slippagePercentage = formatRatio(diff, recalcIdealSol, 1, 100n);
38018
38070
  }
38019
38071
 
38020
38072
  // 3. Calculate suggested liquidity
@@ -38133,8 +38185,7 @@ async function simulateTokenSell$1(mint, sellTokenAmount, passOrder = null, last
38133
38185
  if (freeTokenAmount >= sellTokenAmountBig) {
38134
38186
  completionPercentage = "100.0";
38135
38187
  } else {
38136
- const percentage = Math.floor((Number(freeTokenAmount) / Number(sellTokenAmountBig)) * 1000) / 10;
38137
- completionPercentage = percentage.toFixed(1);
38188
+ completionPercentage = formatRatio(freeTokenAmount, sellTokenAmountBig, 1, 100n);
38138
38189
  }
38139
38190
 
38140
38191
  // 2. Calculate slippage percentage and get final SOL amount
@@ -38145,8 +38196,7 @@ async function simulateTokenSell$1(mint, sellTokenAmount, passOrder = null, last
38145
38196
  if (realSolAmount > 0n) {
38146
38197
  // Normal case: calculate slippage
38147
38198
  const diff = idealSolAmount > realSolAmount ? idealSolAmount - realSolAmount : realSolAmount - idealSolAmount;
38148
- const slippage = Math.floor((Number(diff) / Number(idealSolAmount)) * 1000) / 10;
38149
- slippagePercentage = slippage.toFixed(1);
38199
+ slippagePercentage = formatRatio(diff, idealSolAmount, 1, 100n);
38150
38200
  } else {
38151
38201
  // Special case: real SOL amount is 0, need to recalculate with suggested liquidity
38152
38202
  const suggestedAmount = (freeTokenAmount * BigInt(this.sdk.SUGGEST_LIQ_RATIO)) / 1000n;
@@ -38171,8 +38221,7 @@ async function simulateTokenSell$1(mint, sellTokenAmount, passOrder = null, last
38171
38221
  finalRealSolAmount = recalcRealSol;
38172
38222
 
38173
38223
  const diff = recalcIdealSol > recalcRealSol ? recalcIdealSol - recalcRealSol : recalcRealSol - recalcIdealSol;
38174
- const slippage = Math.floor((Number(diff) / Number(recalcIdealSol)) * 1000) / 10;
38175
- slippagePercentage = slippage.toFixed(1);
38224
+ slippagePercentage = formatRatio(diff, recalcIdealSol, 1, 100n);
38176
38225
  }
38177
38226
 
38178
38227
  // 3. Calculate suggested liquidity
@@ -39027,9 +39076,9 @@ class SimulatorModule$1 {
39027
39076
  const tokenSellResult = await this.simulateTokenSell(mint, tokenAmountBigInt, null, priceResult, ordersResult);
39028
39077
 
39029
39078
  // Estimate ideal SOL amount
39030
- const priceDecimal = CurveAMM$3.u128ToDecimal(currentPrice);
39031
- const tokenInDecimal = Number(tokenAmountBigInt) / 1e9; // Convert token lamports to tokens (9-digit precision)
39032
- const estimatedSolAmount = BigInt(Math.floor((tokenInDecimal * priceDecimal) * 1e9)); // Convert to SOL lamports
39079
+ // Token and SOL both use 9 decimals, so their unit conversions cancel out.
39080
+ const priceScale = BigInt(CurveAMM$3.PRICE_PRECISION_FACTOR_DECIMAL.toFixed(0));
39081
+ const estimatedSolAmount = tokenAmountBigInt * currentPrice / priceScale;
39033
39082
 
39034
39083
  // Transform result to match simulateSell format
39035
39084
  return {
@@ -40790,7 +40839,7 @@ class OrderUtils$2 {
40790
40839
 
40791
40840
  var orderUtils = OrderUtils$2;
40792
40841
 
40793
- var address$1 = "sGecRTjTZmnqJBmLK4ZMNCzsaMrgkFfNqEcYk1GhRde";
40842
+ var address$1 = "EVNaaiyg9z876PUmLCVQcdc5L5eJukT4pni5GtVJ8P37";
40794
40843
  var metadata$1 = {
40795
40844
  name: "fun100x",
40796
40845
  version: "0.1.0",
@@ -43807,271 +43856,281 @@ var errors$1 = [
43807
43856
  },
43808
43857
  {
43809
43858
  code: 6062,
43859
+ name: "InsufficientLongPayerBalance",
43860
+ msg: "Payer wallet balance insufficient for long margin and fees"
43861
+ },
43862
+ {
43863
+ code: 6063,
43864
+ name: "InsufficientShortPayerBalance",
43865
+ msg: "Payer wallet balance insufficient for short margin and fees"
43866
+ },
43867
+ {
43868
+ code: 6064,
43810
43869
  name: "InvalidAccountOwner",
43811
43870
  msg: "Invalid account owner"
43812
43871
  },
43813
43872
  {
43814
- code: 6063,
43873
+ code: 6065,
43815
43874
  name: "SellAmountExceedsOrderAmount",
43816
43875
  msg: "Sell amount exceeds order's token holdings"
43817
43876
  },
43818
43877
  {
43819
- code: 6064,
43878
+ code: 6066,
43820
43879
  name: "OrderNotExpiredMustCloseByOwner",
43821
43880
  msg: "Non-expired order must be closed by owner"
43822
43881
  },
43823
43882
  {
43824
- code: 6065,
43883
+ code: 6067,
43825
43884
  name: "SettlementAddressMustBeOwnerAddress",
43826
43885
  msg: "Settlement address must be owner address"
43827
43886
  },
43828
43887
  {
43829
- code: 6066,
43888
+ code: 6068,
43830
43889
  name: "BuyAmountExceedsOrderAmount",
43831
43890
  msg: "Buy amount exceeds order's token holdings"
43832
43891
  },
43833
43892
  {
43834
- code: 6067,
43893
+ code: 6069,
43835
43894
  name: "InsufficientTradeAmount",
43836
43895
  msg: "Trade amount below minimum requirement"
43837
43896
  },
43838
43897
  {
43839
- code: 6068,
43898
+ code: 6070,
43840
43899
  name: "SolAmountTooLarge",
43841
43900
  msg: "SOL amount exceeds maximum limit (10000000 SOL per transaction)"
43842
43901
  },
43843
43902
  {
43844
- code: 6069,
43903
+ code: 6071,
43845
43904
  name: "RemainingTokenAmountTooSmall",
43846
43905
  msg: "Remaining token amount below minimum trade requirement"
43847
43906
  },
43848
43907
  {
43849
- code: 6070,
43908
+ code: 6072,
43850
43909
  name: "TradeCooldownNotExpired",
43851
43910
  msg: "Trade cooldown period not expired, please try again later"
43852
43911
  },
43853
43912
  {
43854
- code: 6071,
43913
+ code: 6073,
43855
43914
  name: "ExceedApprovalAmount",
43856
43915
  msg: "Sell amount exceeds approved amount, please call approval function first"
43857
43916
  },
43858
43917
  {
43859
- code: 6072,
43918
+ code: 6074,
43860
43919
  name: "CooldownNotInitialized",
43861
43920
  msg: "Sell trade requires calling approval or buy function first to initialize cooldown PDA"
43862
43921
  },
43863
43922
  {
43864
- code: 6073,
43923
+ code: 6075,
43865
43924
  name: "CannotCloseCooldownWithBalance",
43866
43925
  msg: "Cannot close cooldown PDA with non-zero token balance"
43867
43926
  },
43868
43927
  {
43869
- code: 6074,
43928
+ code: 6076,
43870
43929
  name: "PriceCalculationError",
43871
43930
  msg: "Price calculation error"
43872
43931
  },
43873
43932
  {
43874
- code: 6075,
43933
+ code: 6077,
43875
43934
  name: "InvalidPartnerFeeRecipientAccount",
43876
43935
  msg: "Invalid partner fee recipient account"
43877
43936
  },
43878
43937
  {
43879
- code: 6076,
43938
+ code: 6078,
43880
43939
  name: "InvalidBaseFeeRecipientAccount",
43881
43940
  msg: "Invalid base fee recipient account"
43882
43941
  },
43883
43942
  {
43884
- code: 6077,
43943
+ code: 6079,
43885
43944
  name: "InvalidOrderbookAddress",
43886
43945
  msg: "Orderbook address does not match curve account orderbook"
43887
43946
  },
43888
43947
  {
43889
- code: 6078,
43948
+ code: 6080,
43890
43949
  name: "InvalidFeePercentage",
43891
43950
  msg: "Fee percentage must be between 0-100"
43892
43951
  },
43893
43952
  {
43894
- code: 6079,
43953
+ code: 6081,
43895
43954
  name: "InvalidFeeRate",
43896
43955
  msg: "Fee rate exceeds maximum limit (10%)"
43897
43956
  },
43898
43957
  {
43899
- code: 6080,
43958
+ code: 6082,
43900
43959
  name: "InvalidCustomFeeRate",
43901
43960
  msg: "Custom fee rate must be between 1000 (1%) and 5000 (5%)"
43902
43961
  },
43903
43962
  {
43904
- code: 6081,
43963
+ code: 6083,
43905
43964
  name: "InvalidBorrowDuration",
43906
43965
  msg: "Borrow duration out of valid range (3-30 days)"
43907
43966
  },
43908
43967
  {
43909
- code: 6082,
43968
+ code: 6084,
43910
43969
  name: "InvalidStopLossPrice",
43911
43970
  msg: "Stop loss price does not meet minimum interval requirement"
43912
43971
  },
43913
43972
  {
43914
- code: 6083,
43973
+ code: 6085,
43915
43974
  name: "NoProfitableFunds",
43916
43975
  msg: "No profitable funds to transfer"
43917
43976
  },
43918
43977
  {
43919
- code: 6084,
43978
+ code: 6086,
43920
43979
  name: "InsufficientPoolFunds",
43921
43980
  msg: "Insufficient pool funds"
43922
43981
  },
43923
43982
  {
43924
- code: 6085,
43983
+ code: 6087,
43925
43984
  name: "InsufficientPoolBalance",
43926
43985
  msg: "Pool SOL account balance would fall below minimum required balance"
43927
43986
  },
43928
43987
  {
43929
- code: 6086,
43988
+ code: 6088,
43930
43989
  name: "OrderBookManagerOverflow",
43931
43990
  msg: "Math operation overflow"
43932
43991
  },
43933
43992
  {
43934
- code: 6087,
43993
+ code: 6089,
43935
43994
  name: "OrderBookManagerInvalidSlotIndex",
43936
43995
  msg: "Invalid slot index"
43937
43996
  },
43938
43997
  {
43939
- code: 6088,
43998
+ code: 6090,
43940
43999
  name: "OrderBookManagerInvalidAccountData",
43941
44000
  msg: "Invalid account data"
43942
44001
  },
43943
44002
  {
43944
- code: 6089,
44003
+ code: 6091,
43945
44004
  name: "OrderBookManagerExceedsMaxCapacity",
43946
44005
  msg: "New capacity exceeds maximum limit"
43947
44006
  },
43948
44007
  {
43949
- code: 6090,
44008
+ code: 6092,
43950
44009
  name: "OrderBookManagerExceedsAccountSizeLimit",
43951
44010
  msg: "Account size exceeds 10MB limit"
43952
44011
  },
43953
44012
  {
43954
- code: 6091,
44013
+ code: 6093,
43955
44014
  name: "OrderBookManagerOrderIdMismatch",
43956
44015
  msg: "Order ID mismatch"
43957
44016
  },
43958
44017
  {
43959
- code: 6092,
44018
+ code: 6094,
43960
44019
  name: "OrderBookManagerEmptyOrderBook",
43961
44020
  msg: "Order book is empty"
43962
44021
  },
43963
44022
  {
43964
- code: 6093,
44023
+ code: 6095,
43965
44024
  name: "OrderBookManagerAccountNotWritable",
43966
44025
  msg: "Account is not writable"
43967
44026
  },
43968
44027
  {
43969
- code: 6094,
44028
+ code: 6096,
43970
44029
  name: "OrderBookManagerNotRentExempt",
43971
44030
  msg: "Account not rent-exempt"
43972
44031
  },
43973
44032
  {
43974
- code: 6095,
44033
+ code: 6097,
43975
44034
  name: "OrderBookManagerInvalidRentBalance",
43976
44035
  msg: "Invalid rent balance"
43977
44036
  },
43978
44037
  {
43979
- code: 6096,
44038
+ code: 6098,
43980
44039
  name: "OrderBookManagerInsufficientFunds",
43981
44040
  msg: "Insufficient funds"
43982
44041
  },
43983
44042
  {
43984
- code: 6097,
44043
+ code: 6099,
43985
44044
  name: "OrderBookManagerInvalidAccountOwner",
43986
44045
  msg: "OrderBook account owner mismatch"
43987
44046
  },
43988
44047
  {
43989
- code: 6098,
44048
+ code: 6100,
43990
44049
  name: "OrderBookManagerDataOutOfBounds",
43991
44050
  msg: "Data access out of bounds"
43992
44051
  },
43993
44052
  {
43994
- code: 6099,
44053
+ code: 6101,
43995
44054
  name: "NoValidInsertPosition",
43996
44055
  msg: "Cannot find valid insert position, all candidates failed due to price range overlap"
43997
44056
  },
43998
44057
  {
43999
- code: 6100,
44058
+ code: 6102,
44000
44059
  name: "EmptyCloseInsertIndices",
44001
44060
  msg: "close_insert_indices array cannot be empty"
44002
44061
  },
44003
44062
  {
44004
- code: 6101,
44063
+ code: 6103,
44005
44064
  name: "TooManyCloseInsertIndices",
44006
44065
  msg: "close_insert_indices array cannot exceed 20 elements"
44007
44066
  },
44008
44067
  {
44009
- code: 6102,
44068
+ code: 6104,
44010
44069
  name: "CloseOrderNotFound",
44011
44070
  msg: "Specified close order not found"
44012
44071
  },
44013
44072
  {
44014
- code: 6103,
44073
+ code: 6105,
44015
44074
  name: "LinkedListDeleteCountMismatch",
44016
44075
  msg: "Linked list delete count mismatch: count inconsistent before/after deletion"
44017
44076
  },
44018
44077
  {
44019
- code: 6104,
44078
+ code: 6106,
44020
44079
  name: "NameTooLong",
44021
44080
  msg: "Token name too long, max 32 bytes"
44022
44081
  },
44023
44082
  {
44024
- code: 6105,
44083
+ code: 6107,
44025
44084
  name: "NameEmpty",
44026
44085
  msg: "Token name cannot be empty"
44027
44086
  },
44028
44087
  {
44029
- code: 6106,
44088
+ code: 6108,
44030
44089
  name: "SymbolTooLong",
44031
44090
  msg: "Token symbol too long, max 10 bytes"
44032
44091
  },
44033
44092
  {
44034
- code: 6107,
44093
+ code: 6109,
44035
44094
  name: "SymbolEmpty",
44036
44095
  msg: "Token symbol cannot be empty"
44037
44096
  },
44038
44097
  {
44039
- code: 6108,
44098
+ code: 6110,
44040
44099
  name: "UriTooLong",
44041
44100
  msg: "URI too long, max 200 bytes"
44042
44101
  },
44043
44102
  {
44044
- code: 6109,
44103
+ code: 6111,
44045
44104
  name: "UriEmpty",
44046
44105
  msg: "URI cannot be empty"
44047
44106
  },
44048
44107
  {
44049
- code: 6110,
44108
+ code: 6112,
44050
44109
  name: "IncompleteAdvancedPoolParams",
44051
44110
  msg: "Incomplete advanced pool parameters: custom_lp_sol, custom_lp_token, custom_borrow_ratio, custom_borrow_duration must be provided together"
44052
44111
  },
44053
44112
  {
44054
- code: 6111,
44113
+ code: 6113,
44055
44114
  name: "InvalidInitialVirtualSol",
44056
44115
  msg: "Initial virtual SOL out of valid range"
44057
44116
  },
44058
44117
  {
44059
- code: 6112,
44118
+ code: 6114,
44060
44119
  name: "InvalidInitialVirtualToken",
44061
44120
  msg: "Initial virtual Token out of valid range"
44062
44121
  },
44063
44122
  {
44064
- code: 6113,
44123
+ code: 6115,
44065
44124
  name: "InvalidBorrowPoolRatio",
44066
44125
  msg: "Borrow pool ratio out of valid range"
44067
44126
  },
44068
44127
  {
44069
- code: 6114,
44128
+ code: 6116,
44070
44129
  name: "BorrowTokenCalculationOverflow",
44071
44130
  msg: "Borrow pool token amount calculation overflow"
44072
44131
  },
44073
44132
  {
44074
- code: 6115,
44133
+ code: 6117,
44075
44134
  name: "BorrowTokenAmountZero",
44076
44135
  msg: "Borrow pool token amount cannot be zero"
44077
44136
  }
@@ -44218,8 +44277,10 @@ var types$1 = [
44218
44277
  name: "pool_type",
44219
44278
  docs: [
44220
44279
  "Pool type",
44221
- "0 = Basic version (uses default parameters, supports fee halving)",
44222
- "1 = Advanced version (custom parameters, fees never halved)"
44280
+ "0 = Basic version (uses default parameters)",
44281
+ "1 = Advanced version (custom parameters)",
44282
+ "Note: BOTH pool types participate in fee halving milestones",
44283
+ "(dynamic thresholds at 100x/1000x/10000x of the pool's own initial price)"
44223
44284
  ],
44224
44285
  type: "u8"
44225
44286
  },
@@ -44227,8 +44288,8 @@ var types$1 = [
44227
44288
  name: "borrow_pool_ratio",
44228
44289
  docs: [
44229
44290
  "Borrow pool token ratio (recorded only for information display)",
44230
- "Actual value range: 5-30 (represents 5%-30%)",
44231
- "Basic version fixed at 20"
44291
+ "Actual value range: 2-8 (represents 2%-8%, deducted from total supply)",
44292
+ "Basic version fixed at 4"
44232
44293
  ],
44233
44294
  type: "u8"
44234
44295
  }
@@ -44804,7 +44865,7 @@ var require$$1 = {
44804
44865
  types: types$1
44805
44866
  };
44806
44867
 
44807
- var address = "sGecRTjTZmnqJBmLK4ZMNCzsaMrgkFfNqEcYk1GhRde";
44868
+ var address = "EVNaaiyg9z876PUmLCVQcdc5L5eJukT4pni5GtVJ8P37";
44808
44869
  var metadata = {
44809
44870
  name: "fun100x",
44810
44871
  version: "0.1.0",
@@ -47821,271 +47882,281 @@ var errors = [
47821
47882
  },
47822
47883
  {
47823
47884
  code: 6062,
47885
+ name: "InsufficientLongPayerBalance",
47886
+ msg: "Payer wallet balance insufficient for long margin and fees"
47887
+ },
47888
+ {
47889
+ code: 6063,
47890
+ name: "InsufficientShortPayerBalance",
47891
+ msg: "Payer wallet balance insufficient for short margin and fees"
47892
+ },
47893
+ {
47894
+ code: 6064,
47824
47895
  name: "InvalidAccountOwner",
47825
47896
  msg: "Invalid account owner"
47826
47897
  },
47827
47898
  {
47828
- code: 6063,
47899
+ code: 6065,
47829
47900
  name: "SellAmountExceedsOrderAmount",
47830
47901
  msg: "Sell amount exceeds order's token holdings"
47831
47902
  },
47832
47903
  {
47833
- code: 6064,
47904
+ code: 6066,
47834
47905
  name: "OrderNotExpiredMustCloseByOwner",
47835
47906
  msg: "Non-expired order must be closed by owner"
47836
47907
  },
47837
47908
  {
47838
- code: 6065,
47909
+ code: 6067,
47839
47910
  name: "SettlementAddressMustBeOwnerAddress",
47840
47911
  msg: "Settlement address must be owner address"
47841
47912
  },
47842
47913
  {
47843
- code: 6066,
47914
+ code: 6068,
47844
47915
  name: "BuyAmountExceedsOrderAmount",
47845
47916
  msg: "Buy amount exceeds order's token holdings"
47846
47917
  },
47847
47918
  {
47848
- code: 6067,
47919
+ code: 6069,
47849
47920
  name: "InsufficientTradeAmount",
47850
47921
  msg: "Trade amount below minimum requirement"
47851
47922
  },
47852
47923
  {
47853
- code: 6068,
47924
+ code: 6070,
47854
47925
  name: "SolAmountTooLarge",
47855
47926
  msg: "SOL amount exceeds maximum limit (10000000 SOL per transaction)"
47856
47927
  },
47857
47928
  {
47858
- code: 6069,
47929
+ code: 6071,
47859
47930
  name: "RemainingTokenAmountTooSmall",
47860
47931
  msg: "Remaining token amount below minimum trade requirement"
47861
47932
  },
47862
47933
  {
47863
- code: 6070,
47934
+ code: 6072,
47864
47935
  name: "TradeCooldownNotExpired",
47865
47936
  msg: "Trade cooldown period not expired, please try again later"
47866
47937
  },
47867
47938
  {
47868
- code: 6071,
47939
+ code: 6073,
47869
47940
  name: "ExceedApprovalAmount",
47870
47941
  msg: "Sell amount exceeds approved amount, please call approval function first"
47871
47942
  },
47872
47943
  {
47873
- code: 6072,
47944
+ code: 6074,
47874
47945
  name: "CooldownNotInitialized",
47875
47946
  msg: "Sell trade requires calling approval or buy function first to initialize cooldown PDA"
47876
47947
  },
47877
47948
  {
47878
- code: 6073,
47949
+ code: 6075,
47879
47950
  name: "CannotCloseCooldownWithBalance",
47880
47951
  msg: "Cannot close cooldown PDA with non-zero token balance"
47881
47952
  },
47882
47953
  {
47883
- code: 6074,
47954
+ code: 6076,
47884
47955
  name: "PriceCalculationError",
47885
47956
  msg: "Price calculation error"
47886
47957
  },
47887
47958
  {
47888
- code: 6075,
47959
+ code: 6077,
47889
47960
  name: "InvalidPartnerFeeRecipientAccount",
47890
47961
  msg: "Invalid partner fee recipient account"
47891
47962
  },
47892
47963
  {
47893
- code: 6076,
47964
+ code: 6078,
47894
47965
  name: "InvalidBaseFeeRecipientAccount",
47895
47966
  msg: "Invalid base fee recipient account"
47896
47967
  },
47897
47968
  {
47898
- code: 6077,
47969
+ code: 6079,
47899
47970
  name: "InvalidOrderbookAddress",
47900
47971
  msg: "Orderbook address does not match curve account orderbook"
47901
47972
  },
47902
47973
  {
47903
- code: 6078,
47974
+ code: 6080,
47904
47975
  name: "InvalidFeePercentage",
47905
47976
  msg: "Fee percentage must be between 0-100"
47906
47977
  },
47907
47978
  {
47908
- code: 6079,
47979
+ code: 6081,
47909
47980
  name: "InvalidFeeRate",
47910
47981
  msg: "Fee rate exceeds maximum limit (10%)"
47911
47982
  },
47912
47983
  {
47913
- code: 6080,
47984
+ code: 6082,
47914
47985
  name: "InvalidCustomFeeRate",
47915
47986
  msg: "Custom fee rate must be between 1000 (1%) and 5000 (5%)"
47916
47987
  },
47917
47988
  {
47918
- code: 6081,
47989
+ code: 6083,
47919
47990
  name: "InvalidBorrowDuration",
47920
47991
  msg: "Borrow duration out of valid range (3-30 days)"
47921
47992
  },
47922
47993
  {
47923
- code: 6082,
47994
+ code: 6084,
47924
47995
  name: "InvalidStopLossPrice",
47925
47996
  msg: "Stop loss price does not meet minimum interval requirement"
47926
47997
  },
47927
47998
  {
47928
- code: 6083,
47999
+ code: 6085,
47929
48000
  name: "NoProfitableFunds",
47930
48001
  msg: "No profitable funds to transfer"
47931
48002
  },
47932
48003
  {
47933
- code: 6084,
48004
+ code: 6086,
47934
48005
  name: "InsufficientPoolFunds",
47935
48006
  msg: "Insufficient pool funds"
47936
48007
  },
47937
48008
  {
47938
- code: 6085,
48009
+ code: 6087,
47939
48010
  name: "InsufficientPoolBalance",
47940
48011
  msg: "Pool SOL account balance would fall below minimum required balance"
47941
48012
  },
47942
48013
  {
47943
- code: 6086,
48014
+ code: 6088,
47944
48015
  name: "OrderBookManagerOverflow",
47945
48016
  msg: "Math operation overflow"
47946
48017
  },
47947
48018
  {
47948
- code: 6087,
48019
+ code: 6089,
47949
48020
  name: "OrderBookManagerInvalidSlotIndex",
47950
48021
  msg: "Invalid slot index"
47951
48022
  },
47952
48023
  {
47953
- code: 6088,
48024
+ code: 6090,
47954
48025
  name: "OrderBookManagerInvalidAccountData",
47955
48026
  msg: "Invalid account data"
47956
48027
  },
47957
48028
  {
47958
- code: 6089,
48029
+ code: 6091,
47959
48030
  name: "OrderBookManagerExceedsMaxCapacity",
47960
48031
  msg: "New capacity exceeds maximum limit"
47961
48032
  },
47962
48033
  {
47963
- code: 6090,
48034
+ code: 6092,
47964
48035
  name: "OrderBookManagerExceedsAccountSizeLimit",
47965
48036
  msg: "Account size exceeds 10MB limit"
47966
48037
  },
47967
48038
  {
47968
- code: 6091,
48039
+ code: 6093,
47969
48040
  name: "OrderBookManagerOrderIdMismatch",
47970
48041
  msg: "Order ID mismatch"
47971
48042
  },
47972
48043
  {
47973
- code: 6092,
48044
+ code: 6094,
47974
48045
  name: "OrderBookManagerEmptyOrderBook",
47975
48046
  msg: "Order book is empty"
47976
48047
  },
47977
48048
  {
47978
- code: 6093,
48049
+ code: 6095,
47979
48050
  name: "OrderBookManagerAccountNotWritable",
47980
48051
  msg: "Account is not writable"
47981
48052
  },
47982
48053
  {
47983
- code: 6094,
48054
+ code: 6096,
47984
48055
  name: "OrderBookManagerNotRentExempt",
47985
48056
  msg: "Account not rent-exempt"
47986
48057
  },
47987
48058
  {
47988
- code: 6095,
48059
+ code: 6097,
47989
48060
  name: "OrderBookManagerInvalidRentBalance",
47990
48061
  msg: "Invalid rent balance"
47991
48062
  },
47992
48063
  {
47993
- code: 6096,
48064
+ code: 6098,
47994
48065
  name: "OrderBookManagerInsufficientFunds",
47995
48066
  msg: "Insufficient funds"
47996
48067
  },
47997
48068
  {
47998
- code: 6097,
48069
+ code: 6099,
47999
48070
  name: "OrderBookManagerInvalidAccountOwner",
48000
48071
  msg: "OrderBook account owner mismatch"
48001
48072
  },
48002
48073
  {
48003
- code: 6098,
48074
+ code: 6100,
48004
48075
  name: "OrderBookManagerDataOutOfBounds",
48005
48076
  msg: "Data access out of bounds"
48006
48077
  },
48007
48078
  {
48008
- code: 6099,
48079
+ code: 6101,
48009
48080
  name: "NoValidInsertPosition",
48010
48081
  msg: "Cannot find valid insert position, all candidates failed due to price range overlap"
48011
48082
  },
48012
48083
  {
48013
- code: 6100,
48084
+ code: 6102,
48014
48085
  name: "EmptyCloseInsertIndices",
48015
48086
  msg: "close_insert_indices array cannot be empty"
48016
48087
  },
48017
48088
  {
48018
- code: 6101,
48089
+ code: 6103,
48019
48090
  name: "TooManyCloseInsertIndices",
48020
48091
  msg: "close_insert_indices array cannot exceed 20 elements"
48021
48092
  },
48022
48093
  {
48023
- code: 6102,
48094
+ code: 6104,
48024
48095
  name: "CloseOrderNotFound",
48025
48096
  msg: "Specified close order not found"
48026
48097
  },
48027
48098
  {
48028
- code: 6103,
48099
+ code: 6105,
48029
48100
  name: "LinkedListDeleteCountMismatch",
48030
48101
  msg: "Linked list delete count mismatch: count inconsistent before/after deletion"
48031
48102
  },
48032
48103
  {
48033
- code: 6104,
48104
+ code: 6106,
48034
48105
  name: "NameTooLong",
48035
48106
  msg: "Token name too long, max 32 bytes"
48036
48107
  },
48037
48108
  {
48038
- code: 6105,
48109
+ code: 6107,
48039
48110
  name: "NameEmpty",
48040
48111
  msg: "Token name cannot be empty"
48041
48112
  },
48042
48113
  {
48043
- code: 6106,
48114
+ code: 6108,
48044
48115
  name: "SymbolTooLong",
48045
48116
  msg: "Token symbol too long, max 10 bytes"
48046
48117
  },
48047
48118
  {
48048
- code: 6107,
48119
+ code: 6109,
48049
48120
  name: "SymbolEmpty",
48050
48121
  msg: "Token symbol cannot be empty"
48051
48122
  },
48052
48123
  {
48053
- code: 6108,
48124
+ code: 6110,
48054
48125
  name: "UriTooLong",
48055
48126
  msg: "URI too long, max 200 bytes"
48056
48127
  },
48057
48128
  {
48058
- code: 6109,
48129
+ code: 6111,
48059
48130
  name: "UriEmpty",
48060
48131
  msg: "URI cannot be empty"
48061
48132
  },
48062
48133
  {
48063
- code: 6110,
48134
+ code: 6112,
48064
48135
  name: "IncompleteAdvancedPoolParams",
48065
48136
  msg: "Incomplete advanced pool parameters: custom_lp_sol, custom_lp_token, custom_borrow_ratio, custom_borrow_duration must be provided together"
48066
48137
  },
48067
48138
  {
48068
- code: 6111,
48139
+ code: 6113,
48069
48140
  name: "InvalidInitialVirtualSol",
48070
48141
  msg: "Initial virtual SOL out of valid range"
48071
48142
  },
48072
48143
  {
48073
- code: 6112,
48144
+ code: 6114,
48074
48145
  name: "InvalidInitialVirtualToken",
48075
48146
  msg: "Initial virtual Token out of valid range"
48076
48147
  },
48077
48148
  {
48078
- code: 6113,
48149
+ code: 6115,
48079
48150
  name: "InvalidBorrowPoolRatio",
48080
48151
  msg: "Borrow pool ratio out of valid range"
48081
48152
  },
48082
48153
  {
48083
- code: 6114,
48154
+ code: 6116,
48084
48155
  name: "BorrowTokenCalculationOverflow",
48085
48156
  msg: "Borrow pool token amount calculation overflow"
48086
48157
  },
48087
48158
  {
48088
- code: 6115,
48159
+ code: 6117,
48089
48160
  name: "BorrowTokenAmountZero",
48090
48161
  msg: "Borrow pool token amount cannot be zero"
48091
48162
  }
@@ -48232,8 +48303,10 @@ var types = [
48232
48303
  name: "pool_type",
48233
48304
  docs: [
48234
48305
  "Pool type",
48235
- "0 = Basic version (uses default parameters, supports fee halving)",
48236
- "1 = Advanced version (custom parameters, fees never halved)"
48306
+ "0 = Basic version (uses default parameters)",
48307
+ "1 = Advanced version (custom parameters)",
48308
+ "Note: BOTH pool types participate in fee halving milestones",
48309
+ "(dynamic thresholds at 100x/1000x/10000x of the pool's own initial price)"
48237
48310
  ],
48238
48311
  type: "u8"
48239
48312
  },
@@ -48241,8 +48314,8 @@ var types = [
48241
48314
  name: "borrow_pool_ratio",
48242
48315
  docs: [
48243
48316
  "Borrow pool token ratio (recorded only for information display)",
48244
- "Actual value range: 5-30 (represents 5%-30%)",
48245
- "Basic version fixed at 20"
48317
+ "Actual value range: 2-8 (represents 2%-8%, deducted from total supply)",
48318
+ "Basic version fixed at 4"
48246
48319
  ],
48247
48320
  type: "u8"
48248
48321
  }
@@ -49032,8 +49105,8 @@ const DEFAULT_NETWORKS = {
49032
49105
  network: 'mainnet',
49033
49106
  programId: 'sGecRTjTZmnqJBmLK4ZMNCzsaMrgkFfNqEcYk1GhRde',
49034
49107
  defaultDataSource: 'fast',
49035
- solanaEndpoint: 'https://solana-rpc.pinpet.fun',
49036
- fastApiUrl: 'https://api.pinpet.fun/',
49108
+ solanaEndpoint: 'https://solana-rpc.100x.fun',
49109
+ fastApiUrl: 'https://api.100x.fun/',
49037
49110
  feeRecipient: 'CmDe8JRAPJ7QpZNCb4ArVEyzyxYoCNL7WZw5qXLePULn',
49038
49111
  baseFeeRecipient: '2xhAfEfnH8wg7ZGujSijJi4Zt4ge1ZuwMypo7etntgXA',
49039
49112
  paramsAccount: 'CJSn3n4MVCg4qWQ7qb2nxzosYwfcRyBvmwhtM77ugu1V'
@@ -49044,7 +49117,7 @@ const DEFAULT_NETWORKS = {
49044
49117
  programId: 'sGecRTjTZmnqJBmLK4ZMNCzsaMrgkFfNqEcYk1GhRde',
49045
49118
  defaultDataSource: 'fast',
49046
49119
  solanaEndpoint: 'https://lu-ura5lv-fast-devnet.helius-rpc.com',
49047
- fastApiUrl: 'https://devtestapi.pinpet.fun',
49120
+ fastApiUrl: 'https://devtestapi.100x.fun',
49048
49121
  feeRecipient: 'GesAj2dTn2wdNcxj4x8qsqS9aNRVPBPkE76aaqg7skxu',
49049
49122
  baseFeeRecipient: '5YHi1HsxobLiTD6NQfHJQpoPoRjMuNyXp4RroTvR6dKi',
49050
49123
  paramsAccount: 'Ckz5CmbpyKtKmwgw7NDLzFnVACxekWqrX8i6vhCyLkqY'
@@ -49056,8 +49129,6 @@ const DEFAULT_NETWORKS = {
49056
49129
  defaultDataSource: 'fast', // 'fast' or 'chain'
49057
49130
  solanaEndpoint: 'http://127.0.0.1:8899',
49058
49131
  fastApiUrl: 'http://127.0.0.1:3000',
49059
- // solanaEndpoint: 'http://216.158.231.58:8899',
49060
- // fastApiUrl: 'http://216.158.231.58:3000',
49061
49132
  feeRecipient: 'GesAj2dTn2wdNcxj4x8qsqS9aNRVPBPkE76aaqg7skxu',
49062
49133
  baseFeeRecipient: '5YHi1HsxobLiTD6NQfHJQpoPoRjMuNyXp4RroTvR6dKi',
49063
49134
  paramsAccount: 'HPuvtLLcgSMPSyRmULPiFe9oAvm1o8mR4weqXZrUhzRM'