pinpet-sdk 2.1.29 → 2.1.31

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.
@@ -20374,8 +20374,8 @@ class TradingModule$1 {
20374
20374
  )
20375
20375
  : null;
20376
20376
 
20377
- // 6. Get fee recipient accounts from curve account
20378
- const curveAccountInfo = await this.sdk.chain.getCurveAccount(mint);
20377
+ // 6. Get fee recipient accounts from curve account (skipBalances: only need addresses)
20378
+ const curveAccountInfo = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
20379
20379
  const feeRecipientAccount = new PublicKey$6(curveAccountInfo.feeRecipient);
20380
20380
  const baseFeeRecipientAccount = new PublicKey$6(curveAccountInfo.baseFeeRecipient);
20381
20381
 
@@ -20510,8 +20510,8 @@ class TradingModule$1 {
20510
20510
  )
20511
20511
  : null;
20512
20512
 
20513
- // 6. Get fee recipient accounts from curve account
20514
- const curveAccountInfo = await this.sdk.chain.getCurveAccount(mint);
20513
+ // 6. Get fee recipient accounts from curve account (skipBalances: only need addresses)
20514
+ const curveAccountInfo = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
20515
20515
  const feeRecipientAccount = new PublicKey$6(curveAccountInfo.feeRecipient);
20516
20516
  const baseFeeRecipientAccount = new PublicKey$6(curveAccountInfo.baseFeeRecipient);
20517
20517
 
@@ -20890,8 +20890,8 @@ class TradingModule$1 {
20890
20890
  this.sdk.programId
20891
20891
  );
20892
20892
 
20893
- // 4. 从 curve account 获取手续费接收账户 / Get fee recipient accounts from curve account
20894
- const curveAccountInfo = await this.sdk.chain.getCurveAccount(mint);
20893
+ // 4. 从 curve account 获取手续费接收账户 / Get fee recipient accounts from curve account (skipBalances: only need addresses)
20894
+ const curveAccountInfo = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
20895
20895
  const feeRecipientAccount = new PublicKey$6(curveAccountInfo.feeRecipient);
20896
20896
  const baseFeeRecipientAccount = new PublicKey$6(curveAccountInfo.baseFeeRecipient);
20897
20897
 
@@ -21039,8 +21039,8 @@ class TradingModule$1 {
21039
21039
  this.sdk.programId
21040
21040
  );
21041
21041
 
21042
- // 4. 从 curve account 获取手续费接收账户 / Get fee recipient accounts from curve account
21043
- const curveAccountInfo = await this.sdk.chain.getCurveAccount(mint);
21042
+ // 4. 从 curve account 获取手续费接收账户 / Get fee recipient accounts from curve account (skipBalances: only need addresses)
21043
+ const curveAccountInfo = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
21044
21044
  const feeRecipientAccount = new PublicKey$6(curveAccountInfo.feeRecipient);
21045
21045
  const baseFeeRecipientAccount = new PublicKey$6(curveAccountInfo.baseFeeRecipient);
21046
21046
 
@@ -33865,7 +33865,7 @@ async function simulateLongStopLoss$1(mint, buyTokenAmount, stopLossPrice, lastP
33865
33865
 
33866
33866
  // 如果没有传入 borrowFee 或池子参数,从链上一次性获取
33867
33867
  if (borrowFee === null || initialVirtualSol === null || initialVirtualToken === null) {
33868
- const curveAccount = await this.sdk.chain.getCurveAccount(mint);
33868
+ const curveAccount = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
33869
33869
  if (borrowFee === null) borrowFee = curveAccount.borrowFee;
33870
33870
  // 链上返回的是 u64 原始单位(lamports/最小单位),需要除以 10^9 转为人类可读单位
33871
33871
  // 与 calcLiq.js 中的转换方式一致
@@ -34185,7 +34185,7 @@ async function simulateShortStopLoss$1(mint, sellTokenAmount, stopLossPrice, las
34185
34185
 
34186
34186
  // 如果没有传入 borrowFee 或池子参数,从链上一次性获取
34187
34187
  if (borrowFee === null || initialVirtualSol === null || initialVirtualToken === null) {
34188
- const curveAccount = await this.sdk.chain.getCurveAccount(mint);
34188
+ const curveAccount = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
34189
34189
  if (borrowFee === null) borrowFee = curveAccount.borrowFee;
34190
34190
  // 链上返回的是 u64 原始单位(lamports/最小单位),需要除以 10^9 转为人类可读单位
34191
34191
  // 与 calcLiq.js 中的转换方式一致
@@ -34433,19 +34433,19 @@ async function simulateShortStopLoss$1(mint, sellTokenAmount, stopLossPrice, las
34433
34433
  * @since 2.0.0
34434
34434
  * @version 2.0.0 - 从返回 prev_order_pda/next_order_pda 改为返回 close_insert_indices
34435
34435
  */
34436
- async function simulateLongSolStopLoss$1(mint, buySolAmount, stopLossPrice, lastPrice = null, ordersData = null, borrowFee = null, initialVirtualSol = null, initialVirtualToken = null) {
34436
+ async function simulateLongSolStopLoss$1(mint, buySolAmount, stopLossPrice, lastPrice = null, ordersData = null, borrowFee = null, initialVirtualSol = null, initialVirtualToken = null, curveAccount = null) {
34437
34437
  try {
34438
34438
  // Parameter validation
34439
34439
  if (!mint || !buySolAmount || !stopLossPrice) {
34440
34440
  throw new Error('Missing required parameters');
34441
34441
  }
34442
34442
 
34443
- // 如果没有传入 borrowFee 或池子参数,从链上一次性获取
34443
+ // 如果没有传入 borrowFee 或池子参数,从链上一次性获取(支持外部传入 curveAccount 避免重复 RPC)
34444
34444
  if (borrowFee === null || initialVirtualSol === null || initialVirtualToken === null) {
34445
- const curveAccount = await this.sdk.chain.getCurveAccount(mint);
34445
+ if (!curveAccount) {
34446
+ curveAccount = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
34447
+ }
34446
34448
  if (borrowFee === null) borrowFee = curveAccount.borrowFee;
34447
- // 链上返回的是 u64 原始单位(lamports/最小单位),需要除以 10^9 转为人类可读单位
34448
- // 与 calcLiq.js 中的转换方式一致
34449
34449
  if (initialVirtualSol === null) initialVirtualSol = new Decimal$1(curveAccount.initialVirtualSol.toString()).div(CurveAMM$6.SOL_PRECISION_FACTOR_DECIMAL).toString();
34450
34450
  if (initialVirtualToken === null) initialVirtualToken = new Decimal$1(curveAccount.initialVirtualToken.toString()).div(CurveAMM$6.TOKEN_PRECISION_FACTOR_DECIMAL).toString();
34451
34451
  }
@@ -34617,19 +34617,19 @@ async function simulateLongSolStopLoss$1(mint, buySolAmount, stopLossPrice, last
34617
34617
  * @since 2.0.0
34618
34618
  * @version 2.0.0 - 从返回 prev_order_pda/next_order_pda 改为返回 close_insert_indices
34619
34619
  */
34620
- async function simulateShortSolStopLoss$1(mint, sellSolAmount, stopLossPrice, lastPrice = null, ordersData = null, borrowFee = null, initialVirtualSol = null, initialVirtualToken = null) {
34620
+ async function simulateShortSolStopLoss$1(mint, sellSolAmount, stopLossPrice, lastPrice = null, ordersData = null, borrowFee = null, initialVirtualSol = null, initialVirtualToken = null, curveAccount = null) {
34621
34621
  try {
34622
34622
  // Parameter validation
34623
34623
  if (!mint || !sellSolAmount || !stopLossPrice) {
34624
34624
  throw new Error('Missing required parameters');
34625
34625
  }
34626
34626
 
34627
- // 如果没有传入 borrowFee 或池子参数,从链上一次性获取
34627
+ // 如果没有传入 borrowFee 或池子参数,从链上一次性获取(支持外部传入 curveAccount 避免重复 RPC)
34628
34628
  if (borrowFee === null || initialVirtualSol === null || initialVirtualToken === null) {
34629
- const curveAccount = await this.sdk.chain.getCurveAccount(mint);
34629
+ if (!curveAccount) {
34630
+ curveAccount = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
34631
+ }
34630
34632
  if (borrowFee === null) borrowFee = curveAccount.borrowFee;
34631
- // 链上返回的是 u64 原始单位(lamports/最小单位),需要除以 10^9 转为人类可读单位
34632
- // 与 calcLiq.js 中的转换方式一致
34633
34633
  if (initialVirtualSol === null) initialVirtualSol = new Decimal$1(curveAccount.initialVirtualSol.toString()).div(CurveAMM$6.SOL_PRECISION_FACTOR_DECIMAL).toString();
34634
34634
  if (initialVirtualToken === null) initialVirtualToken = new Decimal$1(curveAccount.initialVirtualToken.toString()).div(CurveAMM$6.TOKEN_PRECISION_FACTOR_DECIMAL).toString();
34635
34635
  }
@@ -35558,7 +35558,7 @@ const { calcLiqTokenBuy, calcLiqTokenSell } = calcLiq;
35558
35558
  * - suggestedTokenAmount: {string} Recommended token amount to buy based on available liquidity
35559
35559
  * - suggestedSolAmount: {string} Required SOL amount for suggested token purchase
35560
35560
  */
35561
- async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPrice = null, ordersData = null) {
35561
+ async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPrice = null, ordersData = null, curveData = null) {
35562
35562
  // 获取价格和订单数据
35563
35563
 
35564
35564
  //console.log('simulateTokenBuy', mint, buyTokenAmount, passOrder, lastPrice, ordersData);
@@ -35581,12 +35581,13 @@ async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPr
35581
35581
  orders = ordersData.data.orders.slice(0, this.sdk.MAX_ORDERS_COUNT + 1);
35582
35582
  }
35583
35583
 
35584
- // 获取动态流动池参数
35585
- let curveData;
35586
- try {
35587
- curveData = await this.sdk.chain.getCurveAccount(mint);
35588
- } catch (error) {
35589
- throw new Error(`Failed to get curve account data: ${error.message}`);
35584
+ // 获取动态流动池参数(支持外部传入,避免重复请求)
35585
+ if (!curveData) {
35586
+ try {
35587
+ curveData = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
35588
+ } catch (error) {
35589
+ throw new Error(`Failed to get curve account data: ${error.message}`);
35590
+ }
35590
35591
  }
35591
35592
 
35592
35593
  // 调用 calcLiqTokenBuy 进行流动性计算(传入动态流动池参数)
@@ -35714,7 +35715,7 @@ async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPr
35714
35715
  * - suggestedTokenAmount: {string} Recommended token amount to sell based on available liquidity
35715
35716
  * - suggestedSolAmount: {string} Expected SOL amount from suggested token sale
35716
35717
  */
35717
- async function simulateTokenSell$1(mint, sellTokenAmount, passOrder = null, lastPrice = null, ordersData = null) {
35718
+ async function simulateTokenSell$1(mint, sellTokenAmount, passOrder = null, lastPrice = null, ordersData = null, curveData = null) {
35718
35719
  // 获取价格和订单数据
35719
35720
  let price = lastPrice;
35720
35721
  if (!price) {
@@ -35736,12 +35737,13 @@ async function simulateTokenSell$1(mint, sellTokenAmount, passOrder = null, last
35736
35737
  orders = ordersData.data.orders.slice(0, this.sdk.MAX_ORDERS_COUNT + 1);
35737
35738
  }
35738
35739
 
35739
- // 获取动态流动池参数
35740
- let curveData;
35741
- try {
35742
- curveData = await this.sdk.chain.getCurveAccount(mint);
35743
- } catch (error) {
35744
- throw new Error(`Failed to get curve account data: ${error.message}`);
35740
+ // 获取动态流动池参数(支持外部传入,避免重复请求)
35741
+ if (!curveData) {
35742
+ try {
35743
+ curveData = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
35744
+ } catch (error) {
35745
+ throw new Error(`Failed to get curve account data: ${error.message}`);
35746
+ }
35745
35747
  }
35746
35748
 
35747
35749
  // console.log('simulateTokenSell 获取的数据:');
@@ -36385,8 +36387,8 @@ class SimulatorModule$1 {
36385
36387
  * - suggestedTokenAmount: {string} Recommended token amount to buy based on available liquidity
36386
36388
  * - suggestedSolAmount: {string} Required SOL amount for suggested token purchase
36387
36389
  */
36388
- async simulateTokenBuy(mint, buyTokenAmount, passOrder = null, lastPrice = null, ordersData = null) {
36389
- return simulateTokenBuy.call(this, mint, buyTokenAmount, passOrder, lastPrice, ordersData);
36390
+ async simulateTokenBuy(mint, buyTokenAmount, passOrder = null, lastPrice = null, ordersData = null, curveData = null) {
36391
+ return simulateTokenBuy.call(this, mint, buyTokenAmount, passOrder, lastPrice, ordersData, curveData);
36390
36392
  }
36391
36393
 
36392
36394
  /**
@@ -36412,8 +36414,8 @@ class SimulatorModule$1 {
36412
36414
  * - suggestedTokenAmount: {string} Recommended token amount to sell based on available liquidity
36413
36415
  * - suggestedSolAmount: {string} Expected SOL amount from suggested token sale
36414
36416
  */
36415
- async simulateTokenSell(mint, sellTokenAmount, passOrder = null, lastPrice = null, ordersData = null) {
36416
- return simulateTokenSell.call(this, mint, sellTokenAmount, passOrder, lastPrice, ordersData);
36417
+ async simulateTokenSell(mint, sellTokenAmount, passOrder = null, lastPrice = null, ordersData = null, curveData = null) {
36418
+ return simulateTokenSell.call(this, mint, sellTokenAmount, passOrder, lastPrice, ordersData, curveData);
36417
36419
  }
36418
36420
 
36419
36421
  /**
@@ -36452,8 +36454,8 @@ class SimulatorModule$1 {
36452
36454
  * @param {number} borrowFee - Borrow fee rate, default 2000 (2000/100000 = 0.02%)
36453
36455
  * @returns {Promise<Object>} Stop loss analysis result (same as simulateLongStopLoss)
36454
36456
  */
36455
- async simulateLongSolStopLoss(mint, buySolAmount, stopLossPrice, lastPrice = null, ordersData = null, borrowFee = null) {
36456
- return simulateLongSolStopLoss.call(this, mint, buySolAmount, stopLossPrice, lastPrice, ordersData, borrowFee);
36457
+ async simulateLongSolStopLoss(mint, buySolAmount, stopLossPrice, lastPrice = null, ordersData = null, borrowFee = null, initialVirtualSol = null, initialVirtualToken = null, curveAccount = null) {
36458
+ return simulateLongSolStopLoss.call(this, mint, buySolAmount, stopLossPrice, lastPrice, ordersData, borrowFee, initialVirtualSol, initialVirtualToken, curveAccount);
36457
36459
  }
36458
36460
 
36459
36461
  /**
@@ -36466,8 +36468,8 @@ class SimulatorModule$1 {
36466
36468
  * @param {number} borrowFee - Borrow fee rate, default 2000 (2000/100000 = 0.02%)
36467
36469
  * @returns {Promise<Object>} Stop loss analysis result (same as simulateShortStopLoss)
36468
36470
  */
36469
- async simulateShortSolStopLoss(mint, sellSolAmount, stopLossPrice, lastPrice = null, ordersData = null, borrowFee = null) {
36470
- return simulateShortSolStopLoss.call(this, mint, sellSolAmount, stopLossPrice, lastPrice, ordersData, borrowFee);
36471
+ async simulateShortSolStopLoss(mint, sellSolAmount, stopLossPrice, lastPrice = null, ordersData = null, borrowFee = null, initialVirtualSol = null, initialVirtualToken = null, curveAccount = null) {
36472
+ return simulateShortSolStopLoss.call(this, mint, sellSolAmount, stopLossPrice, lastPrice, ordersData, borrowFee, initialVirtualSol, initialVirtualToken, curveAccount);
36471
36473
  }
36472
36474
 
36473
36475
  /**
@@ -36546,15 +36548,13 @@ class SimulatorModule$1 {
36546
36548
  };
36547
36549
  }
36548
36550
 
36549
- // Get current price and orders data
36550
- const priceResult = await this.sdk.data.price(mint);
36551
- const ordersResult = await this.sdk.data.orders(mint, { type: 'down_orders' });
36552
-
36553
- console.log("ordersResult:",ordersResult);
36554
-
36555
- const upOrdersResult = await this.sdk.data.orders(mint, { type: 'up_orders' });
36556
- console.log("upOrdersResult:",upOrdersResult);
36557
- console.log("upOrdersResult:",upOrdersResult.data.orders);
36551
+ // Get current price, orders data, and curve account in parallel
36552
+ const [priceResult, ordersResult, upOrdersResult, curveAccount] = await Promise.all([
36553
+ this.sdk.data.price(mint),
36554
+ this.sdk.data.orders(mint, { type: 'down_orders' }),
36555
+ this.sdk.data.orders(mint, { type: 'up_orders' }),
36556
+ this.sdk.chain.getCurveAccount(mint, { skipBalances: true })
36557
+ ]);
36558
36558
 
36559
36559
  if (!priceResult || !ordersResult) {
36560
36560
  return {
@@ -36570,7 +36570,6 @@ class SimulatorModule$1 {
36570
36570
  const currentPrice = typeof priceResult === 'string' ? BigInt(priceResult) : BigInt(priceResult.last_price || priceResult);
36571
36571
 
36572
36572
  // Get curve account data for initialVirtualSol and initialVirtualToken
36573
- const curveAccount = await this.sdk.chain.getCurveAccount(mint);
36574
36573
  const initialVirtualSol = curveAccount.initialVirtualSol;
36575
36574
  const initialVirtualToken = curveAccount.initialVirtualToken;
36576
36575
 
@@ -36580,8 +36579,8 @@ class SimulatorModule$1 {
36580
36579
 
36581
36580
  const estimatedTokenAmount = reSolBuy.tokenAmount;
36582
36581
 
36583
- // Call simulateTokenBuy with estimated amount
36584
- const tokenBuyResult = await this.simulateTokenBuy(mint, estimatedTokenAmount, null, priceResult, ordersResult);
36582
+ // Call simulateTokenBuy with estimated amount, pass curveAccount to avoid duplicate RPC
36583
+ const tokenBuyResult = await this.simulateTokenBuy(mint, estimatedTokenAmount, null, priceResult, ordersResult, curveAccount);
36585
36584
 
36586
36585
  // Transform result to match simulateBuy format
36587
36586
  return {
@@ -36667,10 +36666,12 @@ class SimulatorModule$1 {
36667
36666
  };
36668
36667
  }
36669
36668
 
36670
- // Get current price and orders data
36669
+ // Get current price and orders data in parallel
36671
36670
  // For sell transactions, we need down_orders (long orders that provide buy liquidity)
36672
- const priceResult = await this.sdk.data.price(mint);
36673
- const ordersResult = await this.sdk.data.orders(mint, { type: 'down_orders' });
36671
+ const [priceResult, ordersResult] = await Promise.all([
36672
+ this.sdk.data.price(mint),
36673
+ this.sdk.data.orders(mint, { type: 'down_orders' })
36674
+ ]);
36674
36675
 
36675
36676
  if (!priceResult || !ordersResult) {
36676
36677
  return {
@@ -36743,6 +36744,21 @@ const { Buffer: Buffer$3 } = require$$2;
36743
36744
  class ChainModule$1 {
36744
36745
  constructor(sdk) {
36745
36746
  this.sdk = sdk;
36747
+ // getCurveAccount 缓存:key = mint string, value = { data, timestamp }
36748
+ this._curveAccountCache = new Map();
36749
+ this._CACHE_TTL = 10000; // 10 秒 TTL
36750
+ }
36751
+
36752
+ /**
36753
+ * 清除指定 mint 的 curveAccount 缓存(交易后调用)
36754
+ * @param {string} [mint] - 指定 mint 地址,不传则清除全部
36755
+ */
36756
+ invalidateCurveCache(mint) {
36757
+ if (mint) {
36758
+ this._curveAccountCache.delete(typeof mint === 'string' ? mint : mint.toString());
36759
+ } else {
36760
+ this._curveAccountCache.clear();
36761
+ }
36746
36762
  }
36747
36763
 
36748
36764
  /**
@@ -36784,6 +36800,12 @@ class ChainModule$1 {
36784
36800
  * @returns {string} returns.poolTokenAccount - Pool token account address, stores tokens in the liquidity pool
36785
36801
  * @returns {string} returns.poolSolAccount - Pool SOL account address, stores native SOL in the liquidity pool
36786
36802
  *
36803
+ * **Token Supply Information:**
36804
+ * @returns {bigint} returns.totalSupply - Total token supply (smallest unit)
36805
+ * @returns {number} returns.decimals - Token decimal places
36806
+ * @returns {bigint} returns.initialBorrowPool - Initial borrow pool size = totalSupply - initialVirtualToken
36807
+ * @returns {bigint} returns.circulatingSupply - Circulating supply = totalSupply - borrowTokenReserve
36808
+ *
36787
36809
  * **Balance Information:**
36788
36810
  * @returns {number} returns.baseFeeRecipientBalance - SOL balance of base fee recipient address (lamports)
36789
36811
  * @returns {number} returns.feeRecipientBalance - SOL balance of fee recipient address (lamports)
@@ -36871,10 +36893,23 @@ class ChainModule$1 {
36871
36893
  * @version 2.0.0 - Updated to use new OrderBook structure (up_orderbook/down_orderbook instead of upHead/downHead)
36872
36894
  * @author SpinPet SDK Team
36873
36895
  */
36874
- async getCurveAccount(mint) {
36896
+ async getCurveAccount(mint, options = {}) {
36897
+ const { skipBalances = false } = options;
36875
36898
  try {
36876
36899
  // Parameter validation and conversion
36877
36900
  const mintPubkey = typeof mint === 'string' ? new PublicKey$3(mint) : mint;
36901
+ const mintKey = mintPubkey.toString();
36902
+
36903
+ // 检查缓存
36904
+ const cached = this._curveAccountCache.get(mintKey);
36905
+ if (cached && (Date.now() - cached.timestamp < this._CACHE_TTL)) {
36906
+ // 缓存命中:如果请求包含余额但缓存没有,需要重新获取余额部分
36907
+ if (!skipBalances && cached.skipBalances) {
36908
+ // 缓存是 skipBalances 的,但现在需要余额,需要补充查询
36909
+ } else {
36910
+ return cached.data;
36911
+ }
36912
+ }
36878
36913
 
36879
36914
  // Calculate curve_account PDA address
36880
36915
  // Use the same seeds as in the contract: [b"borrowing_curve", mint_account.key().as_ref()]
@@ -36932,18 +36967,28 @@ class ChainModule$1 {
36932
36967
  this.sdk.programId
36933
36968
  );
36934
36969
 
36935
- // Query all balances concurrently
36936
- const [
36937
- baseFeeRecipientBalance,
36938
- feeRecipientBalance,
36939
- poolTokenBalance,
36940
- poolSolBalance
36941
- ] = await Promise.all([
36942
- this.sdk.connection.getBalance(decodedData.baseFeeRecipient),
36943
- this.sdk.connection.getBalance(decodedData.feeRecipient),
36944
- this.sdk.connection.getTokenAccountBalance(poolTokenAccountPDA).catch(() => ({ value: { amount: '0' } })),
36945
- this.sdk.connection.getBalance(poolSolAccountPDA)
36946
- ]);
36970
+ // Query balances (skip if not needed)
36971
+ let baseFeeRecipientBalance = 0;
36972
+ let feeRecipientBalance = 0;
36973
+ let poolTokenBalance = { value: { amount: '0' } };
36974
+ let poolSolBalance = 0;
36975
+ let tokenSupply = { value: { amount: '0', decimals: 0 } };
36976
+
36977
+ if (!skipBalances) {
36978
+ [
36979
+ baseFeeRecipientBalance,
36980
+ feeRecipientBalance,
36981
+ poolTokenBalance,
36982
+ poolSolBalance,
36983
+ tokenSupply
36984
+ ] = await Promise.all([
36985
+ this.sdk.connection.getBalance(decodedData.baseFeeRecipient),
36986
+ this.sdk.connection.getBalance(decodedData.feeRecipient),
36987
+ this.sdk.connection.getTokenAccountBalance(poolTokenAccountPDA).catch(() => ({ value: { amount: '0' } })),
36988
+ this.sdk.connection.getBalance(poolSolAccountPDA),
36989
+ this.sdk.connection.getTokenSupply(mintPubkey)
36990
+ ]);
36991
+ }
36947
36992
 
36948
36993
  // Convert data format
36949
36994
  const convertedData = {
@@ -36982,6 +37027,13 @@ class ChainModule$1 {
36982
37027
  poolType: decodedData.poolType, // u8, 0=普通版, 1=高级版
36983
37028
  borrowPoolRatio: decodedData.borrowPoolRatio, // u8, 5-30表示5%-30%
36984
37029
 
37030
+ // Token Supply 信息
37031
+ totalSupply: BigInt(tokenSupply.value.amount),
37032
+ decimals: tokenSupply.value.decimals,
37033
+ initialBorrowPool: BigInt(tokenSupply.value.amount) - BigInt(decodedData.initialVirtualToken.toString()),
37034
+ circulatingSupply: BigInt(decodedData.initialVirtualToken.toString())
37035
+ + (BigInt(tokenSupply.value.amount) - BigInt(decodedData.initialVirtualToken.toString()) - BigInt(decodedData.borrowTokenReserve.toString())),
37036
+
36985
37037
  // SOL balance information
36986
37038
  baseFeeRecipientBalance: baseFeeRecipientBalance, // Unit: lamports
36987
37039
  feeRecipientBalance: feeRecipientBalance, // Unit: lamports
@@ -36999,6 +37051,13 @@ class ChainModule$1 {
36999
37051
  }
37000
37052
  };
37001
37053
 
37054
+ // 写入缓存
37055
+ this._curveAccountCache.set(mintKey, {
37056
+ data: convertedData,
37057
+ timestamp: Date.now(),
37058
+ skipBalances: skipBalances
37059
+ });
37060
+
37002
37061
  // Return converted data
37003
37062
  return convertedData;
37004
37063
 
@@ -37055,58 +37114,13 @@ class ChainModule$1 {
37055
37114
  }
37056
37115
 
37057
37116
  try {
37058
- // Parameter validation and conversion
37059
- let mintPubkey;
37060
- try {
37061
- mintPubkey = typeof mint === 'string' ? new PublicKey$3(mint) : mint;
37062
- } catch (pubkeyError) {
37063
- throw new Error(`Invalid mint address: ${mint}`);
37064
- }
37065
-
37066
- // Validate mintPubkey
37067
- if (!mintPubkey || typeof mintPubkey.toBuffer !== 'function') {
37068
- throw new Error(`Invalid mintPubkey`);
37069
- }
37070
-
37071
- // Calculate curve_account PDA address
37072
- const [curveAccountPDA] = PublicKey$3.findProgramAddressSync(
37073
- [
37074
- Buffer$3.from("borrowing_curve"),
37075
- mintPubkey.toBuffer()
37076
- ],
37077
- this.sdk.programId
37078
- );
37079
-
37080
- // Use Anchor program to fetch account data directly
37081
- let decodedData;
37082
- try {
37083
- decodedData = await this.sdk.program.account.borrowingBondingCurve.fetch(curveAccountPDA);
37084
- } catch (fetchError) {
37085
- // If fetch fails, use raw method
37086
- const accountInfo = await this.sdk.connection.getAccountInfo(curveAccountPDA);
37087
- if (!accountInfo) {
37088
- throw new Error(`curve_account does not exist`);
37089
- }
37117
+ // 复用 getCurveAccount 缓存,避免重复 fetch 同一个账户
37118
+ const curveData = await this.getCurveAccount(mint, { skipBalances: true });
37119
+ const price = curveData.price;
37090
37120
 
37091
- // Manually decode with BorshAccountsCoder
37092
- const accountsCoder = new anchor$2.BorshAccountsCoder(this.sdk.program.idl);
37093
-
37094
- try {
37095
- decodedData = accountsCoder.decode('BorrowingBondingCurve', accountInfo.data);
37096
- } catch (decodeError1) {
37097
- try {
37098
- decodedData = accountsCoder.decode('borrowingBondingCurve', accountInfo.data);
37099
- } catch (decodeError2) {
37100
- throw new Error(`Cannot decode account data: ${decodeError1.message}`);
37101
- }
37102
- }
37103
- }
37104
-
37105
- // Check price data and return
37106
- if (decodedData.price && decodedData.price.toString() !== '0') {
37107
- return decodedData.price.toString();
37121
+ if (price && price !== 0n) {
37122
+ return price.toString();
37108
37123
  } else {
37109
- // If no price data, return initial price
37110
37124
  const initialPrice = CurveAMM$2.getInitialPrice();
37111
37125
  if (initialPrice === null) {
37112
37126
  throw new Error('price: Unable to calculate initial price');
@@ -37202,14 +37216,16 @@ class ChainModule$1 {
37202
37216
  // Convert API type to orderbook direction
37203
37217
  // "up_orders" = short orders = upOrderbook (orderType=2)
37204
37218
  // "down_orders" = long orders = downOrderbook (orderType=1)
37205
- const orderbookField = orderType === 'up_orders' ? 'upOrderbook' : 'downOrderbook';
37219
+ const seed = orderType === 'up_orders' ? 'up_orderbook' : 'down_orderbook';
37206
37220
 
37207
- // Get curve_account data to get orderbook address
37208
- const curveData = await this.getCurveAccount(mint);
37209
- const orderbookAddress = curveData[orderbookField];
37221
+ // 本地计算 orderbook PDA,避免调用 getCurveAccount(省 5 RPC)
37222
+ const mintPubkey = new PublicKey$3(mint);
37223
+ const [orderbookPubkey] = PublicKey$3.findProgramAddressSync(
37224
+ [Buffer$3.from(seed), mintPubkey.toBuffer()],
37225
+ this.sdk.programId
37226
+ );
37210
37227
 
37211
37228
  // Get OrderBook account data
37212
- const orderbookPubkey = new PublicKey$3(orderbookAddress);
37213
37229
  const accountInfo = await this.sdk.connection.getAccountInfo(orderbookPubkey);
37214
37230
 
37215
37231
  if (!accountInfo) {
@@ -37660,15 +37676,15 @@ class ChainModule$1 {
37660
37676
  throw new Error('debug_orders: order type must be "up_orders" or "down_orders"');
37661
37677
  }
37662
37678
 
37663
- // Convert API type to orderbook direction
37664
- const orderbookField = orderType === 'up_orders' ? 'upOrderbook' : 'downOrderbook';
37665
-
37666
- // Get curve_account data to get orderbook address
37667
- const curveData = await this.getCurveAccount(mint);
37668
- const orderbookAddress = curveData[orderbookField];
37679
+ // 本地计算 orderbook PDA,避免调用 getCurveAccount(省 5 个 RPC)
37680
+ const seed = orderType === 'up_orders' ? 'up_orderbook' : 'down_orderbook';
37681
+ const mintPubkey = new PublicKey$3(mint);
37682
+ const [orderbookPubkey] = PublicKey$3.findProgramAddressSync(
37683
+ [Buffer$3.from(seed), mintPubkey.toBuffer()],
37684
+ this.sdk.programId
37685
+ );
37669
37686
 
37670
37687
  // Get OrderBook account data
37671
- const orderbookPubkey = new PublicKey$3(orderbookAddress);
37672
37688
  const accountInfo = await this.sdk.connection.getAccountInfo(orderbookPubkey);
37673
37689
 
37674
37690
  if (!accountInfo) {
@@ -37871,10 +37887,18 @@ class ChainModule$1 {
37871
37887
  const page = 1; // Always return page 1
37872
37888
  const orderBy = options.order_by || 'start_time_desc';
37873
37889
 
37874
- // Get curve_account data to get both OrderBook addresses
37875
- const curveData = await this.getCurveAccount(mint);
37876
- const upOrderbookAddress = curveData.upOrderbook; // Short orders (orderType=2)
37877
- const downOrderbookAddress = curveData.downOrderbook; // Long orders (orderType=1)
37890
+ // 本地计算 orderbook PDA,避免调用 getCurveAccount(省 5 RPC)
37891
+ const mintPubkey = new PublicKey$3(mint);
37892
+ const [upOrderbookPubkey] = PublicKey$3.findProgramAddressSync(
37893
+ [Buffer$3.from('up_orderbook'), mintPubkey.toBuffer()],
37894
+ this.sdk.programId
37895
+ );
37896
+ const [downOrderbookPubkey] = PublicKey$3.findProgramAddressSync(
37897
+ [Buffer$3.from('down_orderbook'), mintPubkey.toBuffer()],
37898
+ this.sdk.programId
37899
+ );
37900
+ const upOrderbookAddress = upOrderbookPubkey.toString(); // Short orders (orderType=2)
37901
+ const downOrderbookAddress = downOrderbookPubkey.toString(); // Long orders (orderType=1)
37878
37902
 
37879
37903
  // Collect all user orders from both OrderBooks
37880
37904
  const allUserOrders = [];
@@ -38402,7 +38426,7 @@ class OrderUtils$2 {
38402
38426
 
38403
38427
  var orderUtils = OrderUtils$2;
38404
38428
 
38405
- var address = "CYdRzRacZ5kTc9Ht3U7mFhbsyxG3sZGEzC4cNf2Gjg2W";
38429
+ var address = "F2FzigE1Z374iDvreiM6hZQe6oGXgomJfv8PyybvUXye";
38406
38430
  var metadata = {
38407
38431
  name: "pinpet",
38408
38432
  version: "0.1.0",
@@ -40976,476 +41000,471 @@ var errors = [
40976
41000
  },
40977
41001
  {
40978
41002
  code: 6021,
40979
- name: "CloseShortImpossibleState",
40980
- msg: "Close short impossible state: current_total should always be greater than remaining_close_reduced_sol_with_fee"
40981
- },
40982
- {
40983
- code: 6022,
40984
41003
  name: "FeeSplitCalculationOverflow",
40985
41004
  msg: "Fee split calculation overflow"
40986
41005
  },
40987
41006
  {
40988
- code: 6023,
41007
+ code: 6022,
40989
41008
  name: "FeeAccumulationOverflow",
40990
41009
  msg: "Fee accumulation overflow"
40991
41010
  },
40992
41011
  {
40993
- code: 6024,
41012
+ code: 6023,
40994
41013
  name: "PartnerFeeAdditionOverflow",
40995
41014
  msg: "Partner fee addition overflow"
40996
41015
  },
40997
41016
  {
40998
- code: 6025,
41017
+ code: 6024,
40999
41018
  name: "BaseFeeAdditionOverflow",
41000
41019
  msg: "Base fee addition overflow"
41001
41020
  },
41002
41021
  {
41003
- code: 6026,
41022
+ code: 6025,
41004
41023
  name: "PoolFeeDeductionOverflow",
41005
41024
  msg: "Pool fee deduction overflow"
41006
41025
  },
41007
41026
  {
41008
- code: 6027,
41027
+ code: 6026,
41009
41028
  name: "FeeRandomDiscountOverflow",
41010
41029
  msg: "Fee random discount calculation overflow"
41011
41030
  },
41012
41031
  {
41013
- code: 6028,
41032
+ code: 6027,
41014
41033
  name: "SolReserveAdditionOverflow",
41015
41034
  msg: "SOL reserve addition overflow"
41016
41035
  },
41017
41036
  {
41018
- code: 6029,
41037
+ code: 6028,
41019
41038
  name: "SolReserveDeductionOverflow",
41020
41039
  msg: "SOL reserve deduction overflow"
41021
41040
  },
41022
41041
  {
41023
- code: 6030,
41042
+ code: 6029,
41024
41043
  name: "TokenReserveAdditionOverflow",
41025
41044
  msg: "Token reserve addition overflow"
41026
41045
  },
41027
41046
  {
41028
- code: 6031,
41047
+ code: 6030,
41029
41048
  name: "LamportsAdditionOverflow",
41030
41049
  msg: "Lamports addition overflow"
41031
41050
  },
41032
41051
  {
41033
- code: 6032,
41052
+ code: 6031,
41034
41053
  name: "LamportsDeductionOverflow",
41035
41054
  msg: "Lamports deduction overflow"
41036
41055
  },
41037
41056
  {
41038
- code: 6033,
41057
+ code: 6032,
41039
41058
  name: "DeadlineCalculationOverflow",
41040
41059
  msg: "Deadline calculation overflow"
41041
41060
  },
41042
41061
  {
41043
- code: 6034,
41062
+ code: 6033,
41044
41063
  name: "FeeDiscountFlagOverflow",
41045
41064
  msg: "Fee discount flag calculation overflow"
41046
41065
  },
41047
41066
  {
41048
- code: 6035,
41067
+ code: 6034,
41049
41068
  name: "Unauthorized",
41050
41069
  msg: "Unauthorized operation"
41051
41070
  },
41052
41071
  {
41053
- code: 6036,
41072
+ code: 6035,
41054
41073
  name: "RequiredParameter",
41055
41074
  msg: "All parameters are required during initialization"
41056
41075
  },
41057
41076
  {
41058
- code: 6037,
41077
+ code: 6036,
41059
41078
  name: "CurveCalculationError",
41060
41079
  msg: "Curve calculation error"
41061
41080
  },
41062
41081
  {
41063
- code: 6038,
41082
+ code: 6037,
41064
41083
  name: "InitialPriceCalculationError",
41065
41084
  msg: "Initial price calculation failed"
41066
41085
  },
41067
41086
  {
41068
- code: 6039,
41087
+ code: 6038,
41069
41088
  name: "BuyReserveRecalculationError",
41070
41089
  msg: "Reserve recalculation failed (after buy)"
41071
41090
  },
41072
41091
  {
41073
- code: 6040,
41092
+ code: 6039,
41074
41093
  name: "SellReserveRecalculationError",
41075
41094
  msg: "Reserve recalculation failed (after sell)"
41076
41095
  },
41077
41096
  {
41078
- code: 6041,
41097
+ code: 6040,
41079
41098
  name: "TotalAmountWithFeeError",
41080
41099
  msg: "Total amount with fee calculation failed"
41081
41100
  },
41082
41101
  {
41083
- code: 6042,
41102
+ code: 6041,
41084
41103
  name: "AmountAfterFeeError",
41085
41104
  msg: "Amount after fee calculation failed"
41086
41105
  },
41087
41106
  {
41088
- code: 6043,
41107
+ code: 6042,
41089
41108
  name: "BuyPriceRangeCalculationError",
41090
41109
  msg: "Buy price range calculation failed"
41091
41110
  },
41092
41111
  {
41093
- code: 6044,
41112
+ code: 6043,
41094
41113
  name: "SellPriceRangeCalculationError",
41095
41114
  msg: "Sell price range calculation failed"
41096
41115
  },
41097
41116
  {
41098
- code: 6045,
41117
+ code: 6044,
41099
41118
  name: "PriceAtStopLossBoundary",
41100
41119
  msg: "Price has reached stop-loss boundary, head order must be liquidated first"
41101
41120
  },
41102
41121
  {
41103
- code: 6046,
41122
+ code: 6045,
41104
41123
  name: "RemainingRangeCalculationError",
41105
41124
  msg: "Remaining range calculation failed"
41106
41125
  },
41107
41126
  {
41108
- code: 6047,
41127
+ code: 6046,
41109
41128
  name: "FullRangeCalculationError",
41110
41129
  msg: "Full range calculation failed"
41111
41130
  },
41112
41131
  {
41113
- code: 6048,
41132
+ code: 6047,
41114
41133
  name: "BuyFromPriceWithTokenNoneError",
41115
41134
  msg: "Curve function returned None: buy_from_price_with_token_output"
41116
41135
  },
41117
41136
  {
41118
- code: 6049,
41137
+ code: 6048,
41119
41138
  name: "SellFromPriceWithTokenNoneError",
41120
41139
  msg: "Curve function returned None: sell_from_price_with_token_input"
41121
41140
  },
41122
41141
  {
41123
- code: 6050,
41142
+ code: 6049,
41124
41143
  name: "ExceedsMaxSolAmount",
41125
41144
  msg: "Required SOL amount exceeds user-set maximum"
41126
41145
  },
41127
41146
  {
41128
- code: 6051,
41147
+ code: 6050,
41129
41148
  name: "InsufficientSolOutput",
41130
41149
  msg: "Insufficient SOL output"
41131
41150
  },
41132
41151
  {
41133
- code: 6052,
41152
+ code: 6051,
41134
41153
  name: "InsufficientRepayment",
41135
41154
  msg: "Insufficient proceeds to repay loan"
41136
41155
  },
41137
41156
  {
41138
- code: 6053,
41157
+ code: 6052,
41139
41158
  name: "InsufficientBorrowingReserve",
41140
41159
  msg: "Insufficient borrowing reserve"
41141
41160
  },
41142
41161
  {
41143
- code: 6054,
41162
+ code: 6053,
41144
41163
  name: "InsufficientTokenSale",
41145
41164
  msg: "Insufficient token sale amount"
41146
41165
  },
41147
41166
  {
41148
- code: 6055,
41167
+ code: 6054,
41149
41168
  name: "InsufficientLiquidity",
41150
41169
  msg: "Insufficient liquidity in current order"
41151
41170
  },
41152
41171
  {
41153
- code: 6056,
41172
+ code: 6055,
41154
41173
  name: "InsufficientMarketLiquidity",
41155
41174
  msg: "Insufficient market liquidity, cannot satisfy trade even after liquidating all stop-loss orders"
41156
41175
  },
41157
41176
  {
41158
- code: 6057,
41177
+ code: 6056,
41159
41178
  name: "TokenAmountDifferenceOutOfRange",
41160
41179
  msg: "Token amount difference exceeds valid range in margin trade"
41161
41180
  },
41162
41181
  {
41163
- code: 6058,
41182
+ code: 6057,
41164
41183
  name: "BorrowAmountMismatch",
41165
41184
  msg: "Borrow amount mismatch with locked tokens"
41166
41185
  },
41167
41186
  {
41168
- code: 6059,
41187
+ code: 6058,
41169
41188
  name: "CloseFeeCalculationError",
41170
41189
  msg: "Close fee calculation error"
41171
41190
  },
41172
41191
  {
41173
- code: 6060,
41192
+ code: 6059,
41174
41193
  name: "InsufficientMargin",
41175
41194
  msg: "Insufficient margin"
41176
41195
  },
41177
41196
  {
41178
- code: 6061,
41197
+ code: 6060,
41179
41198
  name: "InsufficientMinimumMargin",
41180
41199
  msg: "Margin below minimum requirement"
41181
41200
  },
41182
41201
  {
41183
- code: 6062,
41202
+ code: 6061,
41184
41203
  name: "InvalidAccountOwner",
41185
41204
  msg: "Invalid account owner"
41186
41205
  },
41187
41206
  {
41188
- code: 6063,
41207
+ code: 6062,
41189
41208
  name: "SellAmountExceedsOrderAmount",
41190
41209
  msg: "Sell amount exceeds order's token holdings"
41191
41210
  },
41192
41211
  {
41193
- code: 6064,
41212
+ code: 6063,
41194
41213
  name: "OrderNotExpiredMustCloseByOwner",
41195
41214
  msg: "Non-expired order must be closed by owner"
41196
41215
  },
41197
41216
  {
41198
- code: 6065,
41217
+ code: 6064,
41199
41218
  name: "SettlementAddressMustBeOwnerAddress",
41200
41219
  msg: "Settlement address must be owner address"
41201
41220
  },
41202
41221
  {
41203
- code: 6066,
41222
+ code: 6065,
41204
41223
  name: "BuyAmountExceedsOrderAmount",
41205
41224
  msg: "Buy amount exceeds order's token holdings"
41206
41225
  },
41207
41226
  {
41208
- code: 6067,
41227
+ code: 6066,
41209
41228
  name: "InsufficientTradeAmount",
41210
41229
  msg: "Trade amount below minimum requirement"
41211
41230
  },
41212
41231
  {
41213
- code: 6068,
41232
+ code: 6067,
41214
41233
  name: "SolAmountTooLarge",
41215
41234
  msg: "SOL amount exceeds maximum limit (10000000 SOL per transaction)"
41216
41235
  },
41217
41236
  {
41218
- code: 6069,
41237
+ code: 6068,
41219
41238
  name: "RemainingTokenAmountTooSmall",
41220
41239
  msg: "Remaining token amount below minimum trade requirement"
41221
41240
  },
41222
41241
  {
41223
- code: 6070,
41242
+ code: 6069,
41224
41243
  name: "TradeCooldownNotExpired",
41225
41244
  msg: "Trade cooldown period not expired, please try again later"
41226
41245
  },
41227
41246
  {
41228
- code: 6071,
41247
+ code: 6070,
41229
41248
  name: "ExceedApprovalAmount",
41230
41249
  msg: "Sell amount exceeds approved amount, please call approval function first"
41231
41250
  },
41232
41251
  {
41233
- code: 6072,
41252
+ code: 6071,
41234
41253
  name: "CooldownNotInitialized",
41235
41254
  msg: "Sell trade requires calling approval or buy function first to initialize cooldown PDA"
41236
41255
  },
41237
41256
  {
41238
- code: 6073,
41257
+ code: 6072,
41239
41258
  name: "CannotCloseCooldownWithBalance",
41240
41259
  msg: "Cannot close cooldown PDA with non-zero token balance"
41241
41260
  },
41242
41261
  {
41243
- code: 6074,
41262
+ code: 6073,
41244
41263
  name: "PriceCalculationError",
41245
41264
  msg: "Price calculation error"
41246
41265
  },
41247
41266
  {
41248
- code: 6075,
41267
+ code: 6074,
41249
41268
  name: "InvalidPartnerFeeRecipientAccount",
41250
41269
  msg: "Invalid partner fee recipient account"
41251
41270
  },
41252
41271
  {
41253
- code: 6076,
41272
+ code: 6075,
41254
41273
  name: "InvalidBaseFeeRecipientAccount",
41255
41274
  msg: "Invalid base fee recipient account"
41256
41275
  },
41257
41276
  {
41258
- code: 6077,
41277
+ code: 6076,
41259
41278
  name: "InvalidOrderbookAddress",
41260
41279
  msg: "Orderbook address does not match curve account orderbook"
41261
41280
  },
41262
41281
  {
41263
- code: 6078,
41282
+ code: 6077,
41264
41283
  name: "InvalidFeePercentage",
41265
41284
  msg: "Fee percentage must be between 0-100"
41266
41285
  },
41267
41286
  {
41268
- code: 6079,
41287
+ code: 6078,
41269
41288
  name: "InvalidFeeRate",
41270
41289
  msg: "Fee rate exceeds maximum limit (10%)"
41271
41290
  },
41272
41291
  {
41273
- code: 6080,
41292
+ code: 6079,
41274
41293
  name: "InvalidCustomFeeRate",
41275
41294
  msg: "Custom fee rate must be between 1000 (1%) and 5000 (5%)"
41276
41295
  },
41277
41296
  {
41278
- code: 6081,
41297
+ code: 6080,
41279
41298
  name: "InvalidBorrowDuration",
41280
41299
  msg: "Borrow duration out of valid range (3-30 days)"
41281
41300
  },
41282
41301
  {
41283
- code: 6082,
41302
+ code: 6081,
41284
41303
  name: "InvalidStopLossPrice",
41285
41304
  msg: "Stop loss price does not meet minimum interval requirement"
41286
41305
  },
41287
41306
  {
41288
- code: 6083,
41307
+ code: 6082,
41289
41308
  name: "NoProfitableFunds",
41290
41309
  msg: "No profitable funds to transfer"
41291
41310
  },
41292
41311
  {
41293
- code: 6084,
41312
+ code: 6083,
41294
41313
  name: "InsufficientPoolFunds",
41295
41314
  msg: "Insufficient pool funds"
41296
41315
  },
41297
41316
  {
41298
- code: 6085,
41317
+ code: 6084,
41299
41318
  name: "InsufficientPoolBalance",
41300
41319
  msg: "Pool SOL account balance would fall below minimum required balance"
41301
41320
  },
41302
41321
  {
41303
- code: 6086,
41322
+ code: 6085,
41304
41323
  name: "OrderBookManagerOverflow",
41305
41324
  msg: "Math operation overflow"
41306
41325
  },
41307
41326
  {
41308
- code: 6087,
41327
+ code: 6086,
41309
41328
  name: "OrderBookManagerInvalidSlotIndex",
41310
41329
  msg: "Invalid slot index"
41311
41330
  },
41312
41331
  {
41313
- code: 6088,
41332
+ code: 6087,
41314
41333
  name: "OrderBookManagerInvalidAccountData",
41315
41334
  msg: "Invalid account data"
41316
41335
  },
41317
41336
  {
41318
- code: 6089,
41337
+ code: 6088,
41319
41338
  name: "OrderBookManagerExceedsMaxCapacity",
41320
41339
  msg: "New capacity exceeds maximum limit"
41321
41340
  },
41322
41341
  {
41323
- code: 6090,
41342
+ code: 6089,
41324
41343
  name: "OrderBookManagerExceedsAccountSizeLimit",
41325
41344
  msg: "Account size exceeds 10MB limit"
41326
41345
  },
41327
41346
  {
41328
- code: 6091,
41347
+ code: 6090,
41329
41348
  name: "OrderBookManagerOrderIdMismatch",
41330
41349
  msg: "Order ID mismatch"
41331
41350
  },
41332
41351
  {
41333
- code: 6092,
41352
+ code: 6091,
41334
41353
  name: "OrderBookManagerEmptyOrderBook",
41335
41354
  msg: "Order book is empty"
41336
41355
  },
41337
41356
  {
41338
- code: 6093,
41357
+ code: 6092,
41339
41358
  name: "OrderBookManagerAccountNotWritable",
41340
41359
  msg: "Account is not writable"
41341
41360
  },
41342
41361
  {
41343
- code: 6094,
41362
+ code: 6093,
41344
41363
  name: "OrderBookManagerNotRentExempt",
41345
41364
  msg: "Account not rent-exempt"
41346
41365
  },
41347
41366
  {
41348
- code: 6095,
41367
+ code: 6094,
41349
41368
  name: "OrderBookManagerInvalidRentBalance",
41350
41369
  msg: "Invalid rent balance"
41351
41370
  },
41352
41371
  {
41353
- code: 6096,
41372
+ code: 6095,
41354
41373
  name: "OrderBookManagerInsufficientFunds",
41355
41374
  msg: "Insufficient funds"
41356
41375
  },
41357
41376
  {
41358
- code: 6097,
41377
+ code: 6096,
41359
41378
  name: "OrderBookManagerInvalidAccountOwner",
41360
41379
  msg: "OrderBook account owner mismatch"
41361
41380
  },
41362
41381
  {
41363
- code: 6098,
41382
+ code: 6097,
41364
41383
  name: "OrderBookManagerDataOutOfBounds",
41365
41384
  msg: "Data access out of bounds"
41366
41385
  },
41367
41386
  {
41368
- code: 6099,
41387
+ code: 6098,
41369
41388
  name: "NoValidInsertPosition",
41370
41389
  msg: "Cannot find valid insert position, all candidates failed due to price range overlap"
41371
41390
  },
41372
41391
  {
41373
- code: 6100,
41392
+ code: 6099,
41374
41393
  name: "EmptyCloseInsertIndices",
41375
41394
  msg: "close_insert_indices array cannot be empty"
41376
41395
  },
41377
41396
  {
41378
- code: 6101,
41397
+ code: 6100,
41379
41398
  name: "TooManyCloseInsertIndices",
41380
41399
  msg: "close_insert_indices array cannot exceed 20 elements"
41381
41400
  },
41382
41401
  {
41383
- code: 6102,
41402
+ code: 6101,
41384
41403
  name: "CloseOrderNotFound",
41385
41404
  msg: "Specified close order not found"
41386
41405
  },
41387
41406
  {
41388
- code: 6103,
41407
+ code: 6102,
41389
41408
  name: "LinkedListDeleteCountMismatch",
41390
41409
  msg: "Linked list delete count mismatch: count inconsistent before/after deletion"
41391
41410
  },
41392
41411
  {
41393
- code: 6104,
41412
+ code: 6103,
41394
41413
  name: "NameTooLong",
41395
41414
  msg: "Token name too long, max 32 bytes"
41396
41415
  },
41397
41416
  {
41398
- code: 6105,
41417
+ code: 6104,
41399
41418
  name: "NameEmpty",
41400
41419
  msg: "Token name cannot be empty"
41401
41420
  },
41402
41421
  {
41403
- code: 6106,
41422
+ code: 6105,
41404
41423
  name: "SymbolTooLong",
41405
41424
  msg: "Token symbol too long, max 10 bytes"
41406
41425
  },
41407
41426
  {
41408
- code: 6107,
41427
+ code: 6106,
41409
41428
  name: "SymbolEmpty",
41410
41429
  msg: "Token symbol cannot be empty"
41411
41430
  },
41412
41431
  {
41413
- code: 6108,
41432
+ code: 6107,
41414
41433
  name: "UriTooLong",
41415
41434
  msg: "URI too long, max 200 bytes"
41416
41435
  },
41417
41436
  {
41418
- code: 6109,
41437
+ code: 6108,
41419
41438
  name: "UriEmpty",
41420
41439
  msg: "URI cannot be empty"
41421
41440
  },
41422
41441
  {
41423
- code: 6110,
41442
+ code: 6109,
41424
41443
  name: "IncompleteAdvancedPoolParams",
41425
41444
  msg: "Incomplete advanced pool parameters: custom_lp_sol, custom_lp_token, custom_borrow_ratio, custom_borrow_duration must be provided together"
41426
41445
  },
41427
41446
  {
41428
- code: 6111,
41447
+ code: 6110,
41429
41448
  name: "InvalidInitialVirtualSol",
41430
41449
  msg: "Initial virtual SOL out of valid range"
41431
41450
  },
41432
41451
  {
41433
- code: 6112,
41452
+ code: 6111,
41434
41453
  name: "InvalidInitialVirtualToken",
41435
41454
  msg: "Initial virtual Token out of valid range"
41436
41455
  },
41437
41456
  {
41438
- code: 6113,
41457
+ code: 6112,
41439
41458
  name: "InvalidBorrowPoolRatio",
41440
41459
  msg: "Borrow pool ratio out of valid range"
41441
41460
  },
41442
41461
  {
41443
- code: 6114,
41462
+ code: 6113,
41444
41463
  name: "BorrowTokenCalculationOverflow",
41445
41464
  msg: "Borrow pool token amount calculation overflow"
41446
41465
  },
41447
41466
  {
41448
- code: 6115,
41467
+ code: 6114,
41449
41468
  name: "BorrowTokenAmountZero",
41450
41469
  msg: "Borrow pool token amount cannot be zero"
41451
41470
  }