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.
@@ -15703,8 +15703,8 @@ class TradingModule$1 {
15703
15703
  )
15704
15704
  : null;
15705
15705
 
15706
- // 6. Get fee recipient accounts from curve account
15707
- const curveAccountInfo = await this.sdk.chain.getCurveAccount(mint);
15706
+ // 6. Get fee recipient accounts from curve account (skipBalances: only need addresses)
15707
+ const curveAccountInfo = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
15708
15708
  const feeRecipientAccount = new PublicKey$6(curveAccountInfo.feeRecipient);
15709
15709
  const baseFeeRecipientAccount = new PublicKey$6(curveAccountInfo.baseFeeRecipient);
15710
15710
 
@@ -15839,8 +15839,8 @@ class TradingModule$1 {
15839
15839
  )
15840
15840
  : null;
15841
15841
 
15842
- // 6. Get fee recipient accounts from curve account
15843
- const curveAccountInfo = await this.sdk.chain.getCurveAccount(mint);
15842
+ // 6. Get fee recipient accounts from curve account (skipBalances: only need addresses)
15843
+ const curveAccountInfo = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
15844
15844
  const feeRecipientAccount = new PublicKey$6(curveAccountInfo.feeRecipient);
15845
15845
  const baseFeeRecipientAccount = new PublicKey$6(curveAccountInfo.baseFeeRecipient);
15846
15846
 
@@ -16219,8 +16219,8 @@ class TradingModule$1 {
16219
16219
  this.sdk.programId
16220
16220
  );
16221
16221
 
16222
- // 4. 从 curve account 获取手续费接收账户 / Get fee recipient accounts from curve account
16223
- const curveAccountInfo = await this.sdk.chain.getCurveAccount(mint);
16222
+ // 4. 从 curve account 获取手续费接收账户 / Get fee recipient accounts from curve account (skipBalances: only need addresses)
16223
+ const curveAccountInfo = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
16224
16224
  const feeRecipientAccount = new PublicKey$6(curveAccountInfo.feeRecipient);
16225
16225
  const baseFeeRecipientAccount = new PublicKey$6(curveAccountInfo.baseFeeRecipient);
16226
16226
 
@@ -16368,8 +16368,8 @@ class TradingModule$1 {
16368
16368
  this.sdk.programId
16369
16369
  );
16370
16370
 
16371
- // 4. 从 curve account 获取手续费接收账户 / Get fee recipient accounts from curve account
16372
- const curveAccountInfo = await this.sdk.chain.getCurveAccount(mint);
16371
+ // 4. 从 curve account 获取手续费接收账户 / Get fee recipient accounts from curve account (skipBalances: only need addresses)
16372
+ const curveAccountInfo = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
16373
16373
  const feeRecipientAccount = new PublicKey$6(curveAccountInfo.feeRecipient);
16374
16374
  const baseFeeRecipientAccount = new PublicKey$6(curveAccountInfo.baseFeeRecipient);
16375
16375
 
@@ -45223,7 +45223,7 @@ async function simulateLongStopLoss$1(mint, buyTokenAmount, stopLossPrice, lastP
45223
45223
 
45224
45224
  // 如果没有传入 borrowFee 或池子参数,从链上一次性获取
45225
45225
  if (borrowFee === null || initialVirtualSol === null || initialVirtualToken === null) {
45226
- const curveAccount = await this.sdk.chain.getCurveAccount(mint);
45226
+ const curveAccount = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
45227
45227
  if (borrowFee === null) borrowFee = curveAccount.borrowFee;
45228
45228
  // 链上返回的是 u64 原始单位(lamports/最小单位),需要除以 10^9 转为人类可读单位
45229
45229
  // 与 calcLiq.js 中的转换方式一致
@@ -45543,7 +45543,7 @@ async function simulateShortStopLoss$1(mint, sellTokenAmount, stopLossPrice, las
45543
45543
 
45544
45544
  // 如果没有传入 borrowFee 或池子参数,从链上一次性获取
45545
45545
  if (borrowFee === null || initialVirtualSol === null || initialVirtualToken === null) {
45546
- const curveAccount = await this.sdk.chain.getCurveAccount(mint);
45546
+ const curveAccount = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
45547
45547
  if (borrowFee === null) borrowFee = curveAccount.borrowFee;
45548
45548
  // 链上返回的是 u64 原始单位(lamports/最小单位),需要除以 10^9 转为人类可读单位
45549
45549
  // 与 calcLiq.js 中的转换方式一致
@@ -45791,19 +45791,19 @@ async function simulateShortStopLoss$1(mint, sellTokenAmount, stopLossPrice, las
45791
45791
  * @since 2.0.0
45792
45792
  * @version 2.0.0 - 从返回 prev_order_pda/next_order_pda 改为返回 close_insert_indices
45793
45793
  */
45794
- async function simulateLongSolStopLoss$1(mint, buySolAmount, stopLossPrice, lastPrice = null, ordersData = null, borrowFee = null, initialVirtualSol = null, initialVirtualToken = null) {
45794
+ async function simulateLongSolStopLoss$1(mint, buySolAmount, stopLossPrice, lastPrice = null, ordersData = null, borrowFee = null, initialVirtualSol = null, initialVirtualToken = null, curveAccount = null) {
45795
45795
  try {
45796
45796
  // Parameter validation
45797
45797
  if (!mint || !buySolAmount || !stopLossPrice) {
45798
45798
  throw new Error('Missing required parameters');
45799
45799
  }
45800
45800
 
45801
- // 如果没有传入 borrowFee 或池子参数,从链上一次性获取
45801
+ // 如果没有传入 borrowFee 或池子参数,从链上一次性获取(支持外部传入 curveAccount 避免重复 RPC)
45802
45802
  if (borrowFee === null || initialVirtualSol === null || initialVirtualToken === null) {
45803
- const curveAccount = await this.sdk.chain.getCurveAccount(mint);
45803
+ if (!curveAccount) {
45804
+ curveAccount = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
45805
+ }
45804
45806
  if (borrowFee === null) borrowFee = curveAccount.borrowFee;
45805
- // 链上返回的是 u64 原始单位(lamports/最小单位),需要除以 10^9 转为人类可读单位
45806
- // 与 calcLiq.js 中的转换方式一致
45807
45807
  if (initialVirtualSol === null) initialVirtualSol = new Decimal$1(curveAccount.initialVirtualSol.toString()).div(CurveAMM$6.SOL_PRECISION_FACTOR_DECIMAL).toString();
45808
45808
  if (initialVirtualToken === null) initialVirtualToken = new Decimal$1(curveAccount.initialVirtualToken.toString()).div(CurveAMM$6.TOKEN_PRECISION_FACTOR_DECIMAL).toString();
45809
45809
  }
@@ -45975,19 +45975,19 @@ async function simulateLongSolStopLoss$1(mint, buySolAmount, stopLossPrice, last
45975
45975
  * @since 2.0.0
45976
45976
  * @version 2.0.0 - 从返回 prev_order_pda/next_order_pda 改为返回 close_insert_indices
45977
45977
  */
45978
- async function simulateShortSolStopLoss$1(mint, sellSolAmount, stopLossPrice, lastPrice = null, ordersData = null, borrowFee = null, initialVirtualSol = null, initialVirtualToken = null) {
45978
+ async function simulateShortSolStopLoss$1(mint, sellSolAmount, stopLossPrice, lastPrice = null, ordersData = null, borrowFee = null, initialVirtualSol = null, initialVirtualToken = null, curveAccount = null) {
45979
45979
  try {
45980
45980
  // Parameter validation
45981
45981
  if (!mint || !sellSolAmount || !stopLossPrice) {
45982
45982
  throw new Error('Missing required parameters');
45983
45983
  }
45984
45984
 
45985
- // 如果没有传入 borrowFee 或池子参数,从链上一次性获取
45985
+ // 如果没有传入 borrowFee 或池子参数,从链上一次性获取(支持外部传入 curveAccount 避免重复 RPC)
45986
45986
  if (borrowFee === null || initialVirtualSol === null || initialVirtualToken === null) {
45987
- const curveAccount = await this.sdk.chain.getCurveAccount(mint);
45987
+ if (!curveAccount) {
45988
+ curveAccount = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
45989
+ }
45988
45990
  if (borrowFee === null) borrowFee = curveAccount.borrowFee;
45989
- // 链上返回的是 u64 原始单位(lamports/最小单位),需要除以 10^9 转为人类可读单位
45990
- // 与 calcLiq.js 中的转换方式一致
45991
45991
  if (initialVirtualSol === null) initialVirtualSol = new Decimal$1(curveAccount.initialVirtualSol.toString()).div(CurveAMM$6.SOL_PRECISION_FACTOR_DECIMAL).toString();
45992
45992
  if (initialVirtualToken === null) initialVirtualToken = new Decimal$1(curveAccount.initialVirtualToken.toString()).div(CurveAMM$6.TOKEN_PRECISION_FACTOR_DECIMAL).toString();
45993
45993
  }
@@ -46916,7 +46916,7 @@ const { calcLiqTokenBuy, calcLiqTokenSell } = calcLiq;
46916
46916
  * - suggestedTokenAmount: {string} Recommended token amount to buy based on available liquidity
46917
46917
  * - suggestedSolAmount: {string} Required SOL amount for suggested token purchase
46918
46918
  */
46919
- async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPrice = null, ordersData = null) {
46919
+ async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPrice = null, ordersData = null, curveData = null) {
46920
46920
  // 获取价格和订单数据
46921
46921
 
46922
46922
  //console.log('simulateTokenBuy', mint, buyTokenAmount, passOrder, lastPrice, ordersData);
@@ -46939,12 +46939,13 @@ async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPr
46939
46939
  orders = ordersData.data.orders.slice(0, this.sdk.MAX_ORDERS_COUNT + 1);
46940
46940
  }
46941
46941
 
46942
- // 获取动态流动池参数
46943
- let curveData;
46944
- try {
46945
- curveData = await this.sdk.chain.getCurveAccount(mint);
46946
- } catch (error) {
46947
- throw new Error(`Failed to get curve account data: ${error.message}`);
46942
+ // 获取动态流动池参数(支持外部传入,避免重复请求)
46943
+ if (!curveData) {
46944
+ try {
46945
+ curveData = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
46946
+ } catch (error) {
46947
+ throw new Error(`Failed to get curve account data: ${error.message}`);
46948
+ }
46948
46949
  }
46949
46950
 
46950
46951
  // 调用 calcLiqTokenBuy 进行流动性计算(传入动态流动池参数)
@@ -47072,7 +47073,7 @@ async function simulateTokenBuy$1(mint, buyTokenAmount, passOrder = null, lastPr
47072
47073
  * - suggestedTokenAmount: {string} Recommended token amount to sell based on available liquidity
47073
47074
  * - suggestedSolAmount: {string} Expected SOL amount from suggested token sale
47074
47075
  */
47075
- async function simulateTokenSell$1(mint, sellTokenAmount, passOrder = null, lastPrice = null, ordersData = null) {
47076
+ async function simulateTokenSell$1(mint, sellTokenAmount, passOrder = null, lastPrice = null, ordersData = null, curveData = null) {
47076
47077
  // 获取价格和订单数据
47077
47078
  let price = lastPrice;
47078
47079
  if (!price) {
@@ -47094,12 +47095,13 @@ async function simulateTokenSell$1(mint, sellTokenAmount, passOrder = null, last
47094
47095
  orders = ordersData.data.orders.slice(0, this.sdk.MAX_ORDERS_COUNT + 1);
47095
47096
  }
47096
47097
 
47097
- // 获取动态流动池参数
47098
- let curveData;
47099
- try {
47100
- curveData = await this.sdk.chain.getCurveAccount(mint);
47101
- } catch (error) {
47102
- throw new Error(`Failed to get curve account data: ${error.message}`);
47098
+ // 获取动态流动池参数(支持外部传入,避免重复请求)
47099
+ if (!curveData) {
47100
+ try {
47101
+ curveData = await this.sdk.chain.getCurveAccount(mint, { skipBalances: true });
47102
+ } catch (error) {
47103
+ throw new Error(`Failed to get curve account data: ${error.message}`);
47104
+ }
47103
47105
  }
47104
47106
 
47105
47107
  // console.log('simulateTokenSell 获取的数据:');
@@ -47743,8 +47745,8 @@ class SimulatorModule$1 {
47743
47745
  * - suggestedTokenAmount: {string} Recommended token amount to buy based on available liquidity
47744
47746
  * - suggestedSolAmount: {string} Required SOL amount for suggested token purchase
47745
47747
  */
47746
- async simulateTokenBuy(mint, buyTokenAmount, passOrder = null, lastPrice = null, ordersData = null) {
47747
- return simulateTokenBuy.call(this, mint, buyTokenAmount, passOrder, lastPrice, ordersData);
47748
+ async simulateTokenBuy(mint, buyTokenAmount, passOrder = null, lastPrice = null, ordersData = null, curveData = null) {
47749
+ return simulateTokenBuy.call(this, mint, buyTokenAmount, passOrder, lastPrice, ordersData, curveData);
47748
47750
  }
47749
47751
 
47750
47752
  /**
@@ -47770,8 +47772,8 @@ class SimulatorModule$1 {
47770
47772
  * - suggestedTokenAmount: {string} Recommended token amount to sell based on available liquidity
47771
47773
  * - suggestedSolAmount: {string} Expected SOL amount from suggested token sale
47772
47774
  */
47773
- async simulateTokenSell(mint, sellTokenAmount, passOrder = null, lastPrice = null, ordersData = null) {
47774
- return simulateTokenSell.call(this, mint, sellTokenAmount, passOrder, lastPrice, ordersData);
47775
+ async simulateTokenSell(mint, sellTokenAmount, passOrder = null, lastPrice = null, ordersData = null, curveData = null) {
47776
+ return simulateTokenSell.call(this, mint, sellTokenAmount, passOrder, lastPrice, ordersData, curveData);
47775
47777
  }
47776
47778
 
47777
47779
  /**
@@ -47810,8 +47812,8 @@ class SimulatorModule$1 {
47810
47812
  * @param {number} borrowFee - Borrow fee rate, default 2000 (2000/100000 = 0.02%)
47811
47813
  * @returns {Promise<Object>} Stop loss analysis result (same as simulateLongStopLoss)
47812
47814
  */
47813
- async simulateLongSolStopLoss(mint, buySolAmount, stopLossPrice, lastPrice = null, ordersData = null, borrowFee = null) {
47814
- return simulateLongSolStopLoss.call(this, mint, buySolAmount, stopLossPrice, lastPrice, ordersData, borrowFee);
47815
+ async simulateLongSolStopLoss(mint, buySolAmount, stopLossPrice, lastPrice = null, ordersData = null, borrowFee = null, initialVirtualSol = null, initialVirtualToken = null, curveAccount = null) {
47816
+ return simulateLongSolStopLoss.call(this, mint, buySolAmount, stopLossPrice, lastPrice, ordersData, borrowFee, initialVirtualSol, initialVirtualToken, curveAccount);
47815
47817
  }
47816
47818
 
47817
47819
  /**
@@ -47824,8 +47826,8 @@ class SimulatorModule$1 {
47824
47826
  * @param {number} borrowFee - Borrow fee rate, default 2000 (2000/100000 = 0.02%)
47825
47827
  * @returns {Promise<Object>} Stop loss analysis result (same as simulateShortStopLoss)
47826
47828
  */
47827
- async simulateShortSolStopLoss(mint, sellSolAmount, stopLossPrice, lastPrice = null, ordersData = null, borrowFee = null) {
47828
- return simulateShortSolStopLoss.call(this, mint, sellSolAmount, stopLossPrice, lastPrice, ordersData, borrowFee);
47829
+ async simulateShortSolStopLoss(mint, sellSolAmount, stopLossPrice, lastPrice = null, ordersData = null, borrowFee = null, initialVirtualSol = null, initialVirtualToken = null, curveAccount = null) {
47830
+ return simulateShortSolStopLoss.call(this, mint, sellSolAmount, stopLossPrice, lastPrice, ordersData, borrowFee, initialVirtualSol, initialVirtualToken, curveAccount);
47829
47831
  }
47830
47832
 
47831
47833
  /**
@@ -47904,15 +47906,13 @@ class SimulatorModule$1 {
47904
47906
  };
47905
47907
  }
47906
47908
 
47907
- // Get current price and orders data
47908
- const priceResult = await this.sdk.data.price(mint);
47909
- const ordersResult = await this.sdk.data.orders(mint, { type: 'down_orders' });
47910
-
47911
- console.log("ordersResult:",ordersResult);
47912
-
47913
- const upOrdersResult = await this.sdk.data.orders(mint, { type: 'up_orders' });
47914
- console.log("upOrdersResult:",upOrdersResult);
47915
- console.log("upOrdersResult:",upOrdersResult.data.orders);
47909
+ // Get current price, orders data, and curve account in parallel
47910
+ const [priceResult, ordersResult, upOrdersResult, curveAccount] = await Promise.all([
47911
+ this.sdk.data.price(mint),
47912
+ this.sdk.data.orders(mint, { type: 'down_orders' }),
47913
+ this.sdk.data.orders(mint, { type: 'up_orders' }),
47914
+ this.sdk.chain.getCurveAccount(mint, { skipBalances: true })
47915
+ ]);
47916
47916
 
47917
47917
  if (!priceResult || !ordersResult) {
47918
47918
  return {
@@ -47928,7 +47928,6 @@ class SimulatorModule$1 {
47928
47928
  const currentPrice = typeof priceResult === 'string' ? BigInt(priceResult) : BigInt(priceResult.last_price || priceResult);
47929
47929
 
47930
47930
  // Get curve account data for initialVirtualSol and initialVirtualToken
47931
- const curveAccount = await this.sdk.chain.getCurveAccount(mint);
47932
47931
  const initialVirtualSol = curveAccount.initialVirtualSol;
47933
47932
  const initialVirtualToken = curveAccount.initialVirtualToken;
47934
47933
 
@@ -47938,8 +47937,8 @@ class SimulatorModule$1 {
47938
47937
 
47939
47938
  const estimatedTokenAmount = reSolBuy.tokenAmount;
47940
47939
 
47941
- // Call simulateTokenBuy with estimated amount
47942
- const tokenBuyResult = await this.simulateTokenBuy(mint, estimatedTokenAmount, null, priceResult, ordersResult);
47940
+ // Call simulateTokenBuy with estimated amount, pass curveAccount to avoid duplicate RPC
47941
+ const tokenBuyResult = await this.simulateTokenBuy(mint, estimatedTokenAmount, null, priceResult, ordersResult, curveAccount);
47943
47942
 
47944
47943
  // Transform result to match simulateBuy format
47945
47944
  return {
@@ -48025,10 +48024,12 @@ class SimulatorModule$1 {
48025
48024
  };
48026
48025
  }
48027
48026
 
48028
- // Get current price and orders data
48027
+ // Get current price and orders data in parallel
48029
48028
  // For sell transactions, we need down_orders (long orders that provide buy liquidity)
48030
- const priceResult = await this.sdk.data.price(mint);
48031
- const ordersResult = await this.sdk.data.orders(mint, { type: 'down_orders' });
48029
+ const [priceResult, ordersResult] = await Promise.all([
48030
+ this.sdk.data.price(mint),
48031
+ this.sdk.data.orders(mint, { type: 'down_orders' })
48032
+ ]);
48032
48033
 
48033
48034
  if (!priceResult || !ordersResult) {
48034
48035
  return {
@@ -48101,6 +48102,21 @@ const { Buffer: Buffer$3 } = require$$3__default["default"];
48101
48102
  class ChainModule$1 {
48102
48103
  constructor(sdk) {
48103
48104
  this.sdk = sdk;
48105
+ // getCurveAccount 缓存:key = mint string, value = { data, timestamp }
48106
+ this._curveAccountCache = new Map();
48107
+ this._CACHE_TTL = 10000; // 10 秒 TTL
48108
+ }
48109
+
48110
+ /**
48111
+ * 清除指定 mint 的 curveAccount 缓存(交易后调用)
48112
+ * @param {string} [mint] - 指定 mint 地址,不传则清除全部
48113
+ */
48114
+ invalidateCurveCache(mint) {
48115
+ if (mint) {
48116
+ this._curveAccountCache.delete(typeof mint === 'string' ? mint : mint.toString());
48117
+ } else {
48118
+ this._curveAccountCache.clear();
48119
+ }
48104
48120
  }
48105
48121
 
48106
48122
  /**
@@ -48142,6 +48158,12 @@ class ChainModule$1 {
48142
48158
  * @returns {string} returns.poolTokenAccount - Pool token account address, stores tokens in the liquidity pool
48143
48159
  * @returns {string} returns.poolSolAccount - Pool SOL account address, stores native SOL in the liquidity pool
48144
48160
  *
48161
+ * **Token Supply Information:**
48162
+ * @returns {bigint} returns.totalSupply - Total token supply (smallest unit)
48163
+ * @returns {number} returns.decimals - Token decimal places
48164
+ * @returns {bigint} returns.initialBorrowPool - Initial borrow pool size = totalSupply - initialVirtualToken
48165
+ * @returns {bigint} returns.circulatingSupply - Circulating supply = totalSupply - borrowTokenReserve
48166
+ *
48145
48167
  * **Balance Information:**
48146
48168
  * @returns {number} returns.baseFeeRecipientBalance - SOL balance of base fee recipient address (lamports)
48147
48169
  * @returns {number} returns.feeRecipientBalance - SOL balance of fee recipient address (lamports)
@@ -48229,10 +48251,23 @@ class ChainModule$1 {
48229
48251
  * @version 2.0.0 - Updated to use new OrderBook structure (up_orderbook/down_orderbook instead of upHead/downHead)
48230
48252
  * @author SpinPet SDK Team
48231
48253
  */
48232
- async getCurveAccount(mint) {
48254
+ async getCurveAccount(mint, options = {}) {
48255
+ const { skipBalances = false } = options;
48233
48256
  try {
48234
48257
  // Parameter validation and conversion
48235
48258
  const mintPubkey = typeof mint === 'string' ? new PublicKey$3(mint) : mint;
48259
+ const mintKey = mintPubkey.toString();
48260
+
48261
+ // 检查缓存
48262
+ const cached = this._curveAccountCache.get(mintKey);
48263
+ if (cached && (Date.now() - cached.timestamp < this._CACHE_TTL)) {
48264
+ // 缓存命中:如果请求包含余额但缓存没有,需要重新获取余额部分
48265
+ if (!skipBalances && cached.skipBalances) {
48266
+ // 缓存是 skipBalances 的,但现在需要余额,需要补充查询
48267
+ } else {
48268
+ return cached.data;
48269
+ }
48270
+ }
48236
48271
 
48237
48272
  // Calculate curve_account PDA address
48238
48273
  // Use the same seeds as in the contract: [b"borrowing_curve", mint_account.key().as_ref()]
@@ -48290,18 +48325,28 @@ class ChainModule$1 {
48290
48325
  this.sdk.programId
48291
48326
  );
48292
48327
 
48293
- // Query all balances concurrently
48294
- const [
48295
- baseFeeRecipientBalance,
48296
- feeRecipientBalance,
48297
- poolTokenBalance,
48298
- poolSolBalance
48299
- ] = await Promise.all([
48300
- this.sdk.connection.getBalance(decodedData.baseFeeRecipient),
48301
- this.sdk.connection.getBalance(decodedData.feeRecipient),
48302
- this.sdk.connection.getTokenAccountBalance(poolTokenAccountPDA).catch(() => ({ value: { amount: '0' } })),
48303
- this.sdk.connection.getBalance(poolSolAccountPDA)
48304
- ]);
48328
+ // Query balances (skip if not needed)
48329
+ let baseFeeRecipientBalance = 0;
48330
+ let feeRecipientBalance = 0;
48331
+ let poolTokenBalance = { value: { amount: '0' } };
48332
+ let poolSolBalance = 0;
48333
+ let tokenSupply = { value: { amount: '0', decimals: 0 } };
48334
+
48335
+ if (!skipBalances) {
48336
+ [
48337
+ baseFeeRecipientBalance,
48338
+ feeRecipientBalance,
48339
+ poolTokenBalance,
48340
+ poolSolBalance,
48341
+ tokenSupply
48342
+ ] = await Promise.all([
48343
+ this.sdk.connection.getBalance(decodedData.baseFeeRecipient),
48344
+ this.sdk.connection.getBalance(decodedData.feeRecipient),
48345
+ this.sdk.connection.getTokenAccountBalance(poolTokenAccountPDA).catch(() => ({ value: { amount: '0' } })),
48346
+ this.sdk.connection.getBalance(poolSolAccountPDA),
48347
+ this.sdk.connection.getTokenSupply(mintPubkey)
48348
+ ]);
48349
+ }
48305
48350
 
48306
48351
  // Convert data format
48307
48352
  const convertedData = {
@@ -48340,6 +48385,13 @@ class ChainModule$1 {
48340
48385
  poolType: decodedData.poolType, // u8, 0=普通版, 1=高级版
48341
48386
  borrowPoolRatio: decodedData.borrowPoolRatio, // u8, 5-30表示5%-30%
48342
48387
 
48388
+ // Token Supply 信息
48389
+ totalSupply: BigInt(tokenSupply.value.amount),
48390
+ decimals: tokenSupply.value.decimals,
48391
+ initialBorrowPool: BigInt(tokenSupply.value.amount) - BigInt(decodedData.initialVirtualToken.toString()),
48392
+ circulatingSupply: BigInt(decodedData.initialVirtualToken.toString())
48393
+ + (BigInt(tokenSupply.value.amount) - BigInt(decodedData.initialVirtualToken.toString()) - BigInt(decodedData.borrowTokenReserve.toString())),
48394
+
48343
48395
  // SOL balance information
48344
48396
  baseFeeRecipientBalance: baseFeeRecipientBalance, // Unit: lamports
48345
48397
  feeRecipientBalance: feeRecipientBalance, // Unit: lamports
@@ -48357,6 +48409,13 @@ class ChainModule$1 {
48357
48409
  }
48358
48410
  };
48359
48411
 
48412
+ // 写入缓存
48413
+ this._curveAccountCache.set(mintKey, {
48414
+ data: convertedData,
48415
+ timestamp: Date.now(),
48416
+ skipBalances: skipBalances
48417
+ });
48418
+
48360
48419
  // Return converted data
48361
48420
  return convertedData;
48362
48421
 
@@ -48413,58 +48472,13 @@ class ChainModule$1 {
48413
48472
  }
48414
48473
 
48415
48474
  try {
48416
- // Parameter validation and conversion
48417
- let mintPubkey;
48418
- try {
48419
- mintPubkey = typeof mint === 'string' ? new PublicKey$3(mint) : mint;
48420
- } catch (pubkeyError) {
48421
- throw new Error(`Invalid mint address: ${mint}`);
48422
- }
48423
-
48424
- // Validate mintPubkey
48425
- if (!mintPubkey || typeof mintPubkey.toBuffer !== 'function') {
48426
- throw new Error(`Invalid mintPubkey`);
48427
- }
48428
-
48429
- // Calculate curve_account PDA address
48430
- const [curveAccountPDA] = PublicKey$3.findProgramAddressSync(
48431
- [
48432
- Buffer$3.from("borrowing_curve"),
48433
- mintPubkey.toBuffer()
48434
- ],
48435
- this.sdk.programId
48436
- );
48437
-
48438
- // Use Anchor program to fetch account data directly
48439
- let decodedData;
48440
- try {
48441
- decodedData = await this.sdk.program.account.borrowingBondingCurve.fetch(curveAccountPDA);
48442
- } catch (fetchError) {
48443
- // If fetch fails, use raw method
48444
- const accountInfo = await this.sdk.connection.getAccountInfo(curveAccountPDA);
48445
- if (!accountInfo) {
48446
- throw new Error(`curve_account does not exist`);
48447
- }
48475
+ // 复用 getCurveAccount 缓存,避免重复 fetch 同一个账户
48476
+ const curveData = await this.getCurveAccount(mint, { skipBalances: true });
48477
+ const price = curveData.price;
48448
48478
 
48449
- // Manually decode with BorshAccountsCoder
48450
- const accountsCoder = new anchor$2.BorshAccountsCoder(this.sdk.program.idl);
48451
-
48452
- try {
48453
- decodedData = accountsCoder.decode('BorrowingBondingCurve', accountInfo.data);
48454
- } catch (decodeError1) {
48455
- try {
48456
- decodedData = accountsCoder.decode('borrowingBondingCurve', accountInfo.data);
48457
- } catch (decodeError2) {
48458
- throw new Error(`Cannot decode account data: ${decodeError1.message}`);
48459
- }
48460
- }
48461
- }
48462
-
48463
- // Check price data and return
48464
- if (decodedData.price && decodedData.price.toString() !== '0') {
48465
- return decodedData.price.toString();
48479
+ if (price && price !== 0n) {
48480
+ return price.toString();
48466
48481
  } else {
48467
- // If no price data, return initial price
48468
48482
  const initialPrice = CurveAMM$2.getInitialPrice();
48469
48483
  if (initialPrice === null) {
48470
48484
  throw new Error('price: Unable to calculate initial price');
@@ -48560,14 +48574,16 @@ class ChainModule$1 {
48560
48574
  // Convert API type to orderbook direction
48561
48575
  // "up_orders" = short orders = upOrderbook (orderType=2)
48562
48576
  // "down_orders" = long orders = downOrderbook (orderType=1)
48563
- const orderbookField = orderType === 'up_orders' ? 'upOrderbook' : 'downOrderbook';
48577
+ const seed = orderType === 'up_orders' ? 'up_orderbook' : 'down_orderbook';
48564
48578
 
48565
- // Get curve_account data to get orderbook address
48566
- const curveData = await this.getCurveAccount(mint);
48567
- const orderbookAddress = curveData[orderbookField];
48579
+ // 本地计算 orderbook PDA,避免调用 getCurveAccount(省 5 RPC)
48580
+ const mintPubkey = new PublicKey$3(mint);
48581
+ const [orderbookPubkey] = PublicKey$3.findProgramAddressSync(
48582
+ [Buffer$3.from(seed), mintPubkey.toBuffer()],
48583
+ this.sdk.programId
48584
+ );
48568
48585
 
48569
48586
  // Get OrderBook account data
48570
- const orderbookPubkey = new PublicKey$3(orderbookAddress);
48571
48587
  const accountInfo = await this.sdk.connection.getAccountInfo(orderbookPubkey);
48572
48588
 
48573
48589
  if (!accountInfo) {
@@ -49018,15 +49034,15 @@ class ChainModule$1 {
49018
49034
  throw new Error('debug_orders: order type must be "up_orders" or "down_orders"');
49019
49035
  }
49020
49036
 
49021
- // Convert API type to orderbook direction
49022
- const orderbookField = orderType === 'up_orders' ? 'upOrderbook' : 'downOrderbook';
49023
-
49024
- // Get curve_account data to get orderbook address
49025
- const curveData = await this.getCurveAccount(mint);
49026
- const orderbookAddress = curveData[orderbookField];
49037
+ // 本地计算 orderbook PDA,避免调用 getCurveAccount(省 5 个 RPC)
49038
+ const seed = orderType === 'up_orders' ? 'up_orderbook' : 'down_orderbook';
49039
+ const mintPubkey = new PublicKey$3(mint);
49040
+ const [orderbookPubkey] = PublicKey$3.findProgramAddressSync(
49041
+ [Buffer$3.from(seed), mintPubkey.toBuffer()],
49042
+ this.sdk.programId
49043
+ );
49027
49044
 
49028
49045
  // Get OrderBook account data
49029
- const orderbookPubkey = new PublicKey$3(orderbookAddress);
49030
49046
  const accountInfo = await this.sdk.connection.getAccountInfo(orderbookPubkey);
49031
49047
 
49032
49048
  if (!accountInfo) {
@@ -49229,10 +49245,18 @@ class ChainModule$1 {
49229
49245
  const page = 1; // Always return page 1
49230
49246
  const orderBy = options.order_by || 'start_time_desc';
49231
49247
 
49232
- // Get curve_account data to get both OrderBook addresses
49233
- const curveData = await this.getCurveAccount(mint);
49234
- const upOrderbookAddress = curveData.upOrderbook; // Short orders (orderType=2)
49235
- const downOrderbookAddress = curveData.downOrderbook; // Long orders (orderType=1)
49248
+ // 本地计算 orderbook PDA,避免调用 getCurveAccount(省 5 RPC)
49249
+ const mintPubkey = new PublicKey$3(mint);
49250
+ const [upOrderbookPubkey] = PublicKey$3.findProgramAddressSync(
49251
+ [Buffer$3.from('up_orderbook'), mintPubkey.toBuffer()],
49252
+ this.sdk.programId
49253
+ );
49254
+ const [downOrderbookPubkey] = PublicKey$3.findProgramAddressSync(
49255
+ [Buffer$3.from('down_orderbook'), mintPubkey.toBuffer()],
49256
+ this.sdk.programId
49257
+ );
49258
+ const upOrderbookAddress = upOrderbookPubkey.toString(); // Short orders (orderType=2)
49259
+ const downOrderbookAddress = downOrderbookPubkey.toString(); // Long orders (orderType=1)
49236
49260
 
49237
49261
  // Collect all user orders from both OrderBooks
49238
49262
  const allUserOrders = [];
@@ -49760,7 +49784,7 @@ class OrderUtils$2 {
49760
49784
 
49761
49785
  var orderUtils = OrderUtils$2;
49762
49786
 
49763
- var address = "CYdRzRacZ5kTc9Ht3U7mFhbsyxG3sZGEzC4cNf2Gjg2W";
49787
+ var address = "F2FzigE1Z374iDvreiM6hZQe6oGXgomJfv8PyybvUXye";
49764
49788
  var metadata = {
49765
49789
  name: "pinpet",
49766
49790
  version: "0.1.0",
@@ -52334,476 +52358,471 @@ var errors = [
52334
52358
  },
52335
52359
  {
52336
52360
  code: 6021,
52337
- name: "CloseShortImpossibleState",
52338
- msg: "Close short impossible state: current_total should always be greater than remaining_close_reduced_sol_with_fee"
52339
- },
52340
- {
52341
- code: 6022,
52342
52361
  name: "FeeSplitCalculationOverflow",
52343
52362
  msg: "Fee split calculation overflow"
52344
52363
  },
52345
52364
  {
52346
- code: 6023,
52365
+ code: 6022,
52347
52366
  name: "FeeAccumulationOverflow",
52348
52367
  msg: "Fee accumulation overflow"
52349
52368
  },
52350
52369
  {
52351
- code: 6024,
52370
+ code: 6023,
52352
52371
  name: "PartnerFeeAdditionOverflow",
52353
52372
  msg: "Partner fee addition overflow"
52354
52373
  },
52355
52374
  {
52356
- code: 6025,
52375
+ code: 6024,
52357
52376
  name: "BaseFeeAdditionOverflow",
52358
52377
  msg: "Base fee addition overflow"
52359
52378
  },
52360
52379
  {
52361
- code: 6026,
52380
+ code: 6025,
52362
52381
  name: "PoolFeeDeductionOverflow",
52363
52382
  msg: "Pool fee deduction overflow"
52364
52383
  },
52365
52384
  {
52366
- code: 6027,
52385
+ code: 6026,
52367
52386
  name: "FeeRandomDiscountOverflow",
52368
52387
  msg: "Fee random discount calculation overflow"
52369
52388
  },
52370
52389
  {
52371
- code: 6028,
52390
+ code: 6027,
52372
52391
  name: "SolReserveAdditionOverflow",
52373
52392
  msg: "SOL reserve addition overflow"
52374
52393
  },
52375
52394
  {
52376
- code: 6029,
52395
+ code: 6028,
52377
52396
  name: "SolReserveDeductionOverflow",
52378
52397
  msg: "SOL reserve deduction overflow"
52379
52398
  },
52380
52399
  {
52381
- code: 6030,
52400
+ code: 6029,
52382
52401
  name: "TokenReserveAdditionOverflow",
52383
52402
  msg: "Token reserve addition overflow"
52384
52403
  },
52385
52404
  {
52386
- code: 6031,
52405
+ code: 6030,
52387
52406
  name: "LamportsAdditionOverflow",
52388
52407
  msg: "Lamports addition overflow"
52389
52408
  },
52390
52409
  {
52391
- code: 6032,
52410
+ code: 6031,
52392
52411
  name: "LamportsDeductionOverflow",
52393
52412
  msg: "Lamports deduction overflow"
52394
52413
  },
52395
52414
  {
52396
- code: 6033,
52415
+ code: 6032,
52397
52416
  name: "DeadlineCalculationOverflow",
52398
52417
  msg: "Deadline calculation overflow"
52399
52418
  },
52400
52419
  {
52401
- code: 6034,
52420
+ code: 6033,
52402
52421
  name: "FeeDiscountFlagOverflow",
52403
52422
  msg: "Fee discount flag calculation overflow"
52404
52423
  },
52405
52424
  {
52406
- code: 6035,
52425
+ code: 6034,
52407
52426
  name: "Unauthorized",
52408
52427
  msg: "Unauthorized operation"
52409
52428
  },
52410
52429
  {
52411
- code: 6036,
52430
+ code: 6035,
52412
52431
  name: "RequiredParameter",
52413
52432
  msg: "All parameters are required during initialization"
52414
52433
  },
52415
52434
  {
52416
- code: 6037,
52435
+ code: 6036,
52417
52436
  name: "CurveCalculationError",
52418
52437
  msg: "Curve calculation error"
52419
52438
  },
52420
52439
  {
52421
- code: 6038,
52440
+ code: 6037,
52422
52441
  name: "InitialPriceCalculationError",
52423
52442
  msg: "Initial price calculation failed"
52424
52443
  },
52425
52444
  {
52426
- code: 6039,
52445
+ code: 6038,
52427
52446
  name: "BuyReserveRecalculationError",
52428
52447
  msg: "Reserve recalculation failed (after buy)"
52429
52448
  },
52430
52449
  {
52431
- code: 6040,
52450
+ code: 6039,
52432
52451
  name: "SellReserveRecalculationError",
52433
52452
  msg: "Reserve recalculation failed (after sell)"
52434
52453
  },
52435
52454
  {
52436
- code: 6041,
52455
+ code: 6040,
52437
52456
  name: "TotalAmountWithFeeError",
52438
52457
  msg: "Total amount with fee calculation failed"
52439
52458
  },
52440
52459
  {
52441
- code: 6042,
52460
+ code: 6041,
52442
52461
  name: "AmountAfterFeeError",
52443
52462
  msg: "Amount after fee calculation failed"
52444
52463
  },
52445
52464
  {
52446
- code: 6043,
52465
+ code: 6042,
52447
52466
  name: "BuyPriceRangeCalculationError",
52448
52467
  msg: "Buy price range calculation failed"
52449
52468
  },
52450
52469
  {
52451
- code: 6044,
52470
+ code: 6043,
52452
52471
  name: "SellPriceRangeCalculationError",
52453
52472
  msg: "Sell price range calculation failed"
52454
52473
  },
52455
52474
  {
52456
- code: 6045,
52475
+ code: 6044,
52457
52476
  name: "PriceAtStopLossBoundary",
52458
52477
  msg: "Price has reached stop-loss boundary, head order must be liquidated first"
52459
52478
  },
52460
52479
  {
52461
- code: 6046,
52480
+ code: 6045,
52462
52481
  name: "RemainingRangeCalculationError",
52463
52482
  msg: "Remaining range calculation failed"
52464
52483
  },
52465
52484
  {
52466
- code: 6047,
52485
+ code: 6046,
52467
52486
  name: "FullRangeCalculationError",
52468
52487
  msg: "Full range calculation failed"
52469
52488
  },
52470
52489
  {
52471
- code: 6048,
52490
+ code: 6047,
52472
52491
  name: "BuyFromPriceWithTokenNoneError",
52473
52492
  msg: "Curve function returned None: buy_from_price_with_token_output"
52474
52493
  },
52475
52494
  {
52476
- code: 6049,
52495
+ code: 6048,
52477
52496
  name: "SellFromPriceWithTokenNoneError",
52478
52497
  msg: "Curve function returned None: sell_from_price_with_token_input"
52479
52498
  },
52480
52499
  {
52481
- code: 6050,
52500
+ code: 6049,
52482
52501
  name: "ExceedsMaxSolAmount",
52483
52502
  msg: "Required SOL amount exceeds user-set maximum"
52484
52503
  },
52485
52504
  {
52486
- code: 6051,
52505
+ code: 6050,
52487
52506
  name: "InsufficientSolOutput",
52488
52507
  msg: "Insufficient SOL output"
52489
52508
  },
52490
52509
  {
52491
- code: 6052,
52510
+ code: 6051,
52492
52511
  name: "InsufficientRepayment",
52493
52512
  msg: "Insufficient proceeds to repay loan"
52494
52513
  },
52495
52514
  {
52496
- code: 6053,
52515
+ code: 6052,
52497
52516
  name: "InsufficientBorrowingReserve",
52498
52517
  msg: "Insufficient borrowing reserve"
52499
52518
  },
52500
52519
  {
52501
- code: 6054,
52520
+ code: 6053,
52502
52521
  name: "InsufficientTokenSale",
52503
52522
  msg: "Insufficient token sale amount"
52504
52523
  },
52505
52524
  {
52506
- code: 6055,
52525
+ code: 6054,
52507
52526
  name: "InsufficientLiquidity",
52508
52527
  msg: "Insufficient liquidity in current order"
52509
52528
  },
52510
52529
  {
52511
- code: 6056,
52530
+ code: 6055,
52512
52531
  name: "InsufficientMarketLiquidity",
52513
52532
  msg: "Insufficient market liquidity, cannot satisfy trade even after liquidating all stop-loss orders"
52514
52533
  },
52515
52534
  {
52516
- code: 6057,
52535
+ code: 6056,
52517
52536
  name: "TokenAmountDifferenceOutOfRange",
52518
52537
  msg: "Token amount difference exceeds valid range in margin trade"
52519
52538
  },
52520
52539
  {
52521
- code: 6058,
52540
+ code: 6057,
52522
52541
  name: "BorrowAmountMismatch",
52523
52542
  msg: "Borrow amount mismatch with locked tokens"
52524
52543
  },
52525
52544
  {
52526
- code: 6059,
52545
+ code: 6058,
52527
52546
  name: "CloseFeeCalculationError",
52528
52547
  msg: "Close fee calculation error"
52529
52548
  },
52530
52549
  {
52531
- code: 6060,
52550
+ code: 6059,
52532
52551
  name: "InsufficientMargin",
52533
52552
  msg: "Insufficient margin"
52534
52553
  },
52535
52554
  {
52536
- code: 6061,
52555
+ code: 6060,
52537
52556
  name: "InsufficientMinimumMargin",
52538
52557
  msg: "Margin below minimum requirement"
52539
52558
  },
52540
52559
  {
52541
- code: 6062,
52560
+ code: 6061,
52542
52561
  name: "InvalidAccountOwner",
52543
52562
  msg: "Invalid account owner"
52544
52563
  },
52545
52564
  {
52546
- code: 6063,
52565
+ code: 6062,
52547
52566
  name: "SellAmountExceedsOrderAmount",
52548
52567
  msg: "Sell amount exceeds order's token holdings"
52549
52568
  },
52550
52569
  {
52551
- code: 6064,
52570
+ code: 6063,
52552
52571
  name: "OrderNotExpiredMustCloseByOwner",
52553
52572
  msg: "Non-expired order must be closed by owner"
52554
52573
  },
52555
52574
  {
52556
- code: 6065,
52575
+ code: 6064,
52557
52576
  name: "SettlementAddressMustBeOwnerAddress",
52558
52577
  msg: "Settlement address must be owner address"
52559
52578
  },
52560
52579
  {
52561
- code: 6066,
52580
+ code: 6065,
52562
52581
  name: "BuyAmountExceedsOrderAmount",
52563
52582
  msg: "Buy amount exceeds order's token holdings"
52564
52583
  },
52565
52584
  {
52566
- code: 6067,
52585
+ code: 6066,
52567
52586
  name: "InsufficientTradeAmount",
52568
52587
  msg: "Trade amount below minimum requirement"
52569
52588
  },
52570
52589
  {
52571
- code: 6068,
52590
+ code: 6067,
52572
52591
  name: "SolAmountTooLarge",
52573
52592
  msg: "SOL amount exceeds maximum limit (10000000 SOL per transaction)"
52574
52593
  },
52575
52594
  {
52576
- code: 6069,
52595
+ code: 6068,
52577
52596
  name: "RemainingTokenAmountTooSmall",
52578
52597
  msg: "Remaining token amount below minimum trade requirement"
52579
52598
  },
52580
52599
  {
52581
- code: 6070,
52600
+ code: 6069,
52582
52601
  name: "TradeCooldownNotExpired",
52583
52602
  msg: "Trade cooldown period not expired, please try again later"
52584
52603
  },
52585
52604
  {
52586
- code: 6071,
52605
+ code: 6070,
52587
52606
  name: "ExceedApprovalAmount",
52588
52607
  msg: "Sell amount exceeds approved amount, please call approval function first"
52589
52608
  },
52590
52609
  {
52591
- code: 6072,
52610
+ code: 6071,
52592
52611
  name: "CooldownNotInitialized",
52593
52612
  msg: "Sell trade requires calling approval or buy function first to initialize cooldown PDA"
52594
52613
  },
52595
52614
  {
52596
- code: 6073,
52615
+ code: 6072,
52597
52616
  name: "CannotCloseCooldownWithBalance",
52598
52617
  msg: "Cannot close cooldown PDA with non-zero token balance"
52599
52618
  },
52600
52619
  {
52601
- code: 6074,
52620
+ code: 6073,
52602
52621
  name: "PriceCalculationError",
52603
52622
  msg: "Price calculation error"
52604
52623
  },
52605
52624
  {
52606
- code: 6075,
52625
+ code: 6074,
52607
52626
  name: "InvalidPartnerFeeRecipientAccount",
52608
52627
  msg: "Invalid partner fee recipient account"
52609
52628
  },
52610
52629
  {
52611
- code: 6076,
52630
+ code: 6075,
52612
52631
  name: "InvalidBaseFeeRecipientAccount",
52613
52632
  msg: "Invalid base fee recipient account"
52614
52633
  },
52615
52634
  {
52616
- code: 6077,
52635
+ code: 6076,
52617
52636
  name: "InvalidOrderbookAddress",
52618
52637
  msg: "Orderbook address does not match curve account orderbook"
52619
52638
  },
52620
52639
  {
52621
- code: 6078,
52640
+ code: 6077,
52622
52641
  name: "InvalidFeePercentage",
52623
52642
  msg: "Fee percentage must be between 0-100"
52624
52643
  },
52625
52644
  {
52626
- code: 6079,
52645
+ code: 6078,
52627
52646
  name: "InvalidFeeRate",
52628
52647
  msg: "Fee rate exceeds maximum limit (10%)"
52629
52648
  },
52630
52649
  {
52631
- code: 6080,
52650
+ code: 6079,
52632
52651
  name: "InvalidCustomFeeRate",
52633
52652
  msg: "Custom fee rate must be between 1000 (1%) and 5000 (5%)"
52634
52653
  },
52635
52654
  {
52636
- code: 6081,
52655
+ code: 6080,
52637
52656
  name: "InvalidBorrowDuration",
52638
52657
  msg: "Borrow duration out of valid range (3-30 days)"
52639
52658
  },
52640
52659
  {
52641
- code: 6082,
52660
+ code: 6081,
52642
52661
  name: "InvalidStopLossPrice",
52643
52662
  msg: "Stop loss price does not meet minimum interval requirement"
52644
52663
  },
52645
52664
  {
52646
- code: 6083,
52665
+ code: 6082,
52647
52666
  name: "NoProfitableFunds",
52648
52667
  msg: "No profitable funds to transfer"
52649
52668
  },
52650
52669
  {
52651
- code: 6084,
52670
+ code: 6083,
52652
52671
  name: "InsufficientPoolFunds",
52653
52672
  msg: "Insufficient pool funds"
52654
52673
  },
52655
52674
  {
52656
- code: 6085,
52675
+ code: 6084,
52657
52676
  name: "InsufficientPoolBalance",
52658
52677
  msg: "Pool SOL account balance would fall below minimum required balance"
52659
52678
  },
52660
52679
  {
52661
- code: 6086,
52680
+ code: 6085,
52662
52681
  name: "OrderBookManagerOverflow",
52663
52682
  msg: "Math operation overflow"
52664
52683
  },
52665
52684
  {
52666
- code: 6087,
52685
+ code: 6086,
52667
52686
  name: "OrderBookManagerInvalidSlotIndex",
52668
52687
  msg: "Invalid slot index"
52669
52688
  },
52670
52689
  {
52671
- code: 6088,
52690
+ code: 6087,
52672
52691
  name: "OrderBookManagerInvalidAccountData",
52673
52692
  msg: "Invalid account data"
52674
52693
  },
52675
52694
  {
52676
- code: 6089,
52695
+ code: 6088,
52677
52696
  name: "OrderBookManagerExceedsMaxCapacity",
52678
52697
  msg: "New capacity exceeds maximum limit"
52679
52698
  },
52680
52699
  {
52681
- code: 6090,
52700
+ code: 6089,
52682
52701
  name: "OrderBookManagerExceedsAccountSizeLimit",
52683
52702
  msg: "Account size exceeds 10MB limit"
52684
52703
  },
52685
52704
  {
52686
- code: 6091,
52705
+ code: 6090,
52687
52706
  name: "OrderBookManagerOrderIdMismatch",
52688
52707
  msg: "Order ID mismatch"
52689
52708
  },
52690
52709
  {
52691
- code: 6092,
52710
+ code: 6091,
52692
52711
  name: "OrderBookManagerEmptyOrderBook",
52693
52712
  msg: "Order book is empty"
52694
52713
  },
52695
52714
  {
52696
- code: 6093,
52715
+ code: 6092,
52697
52716
  name: "OrderBookManagerAccountNotWritable",
52698
52717
  msg: "Account is not writable"
52699
52718
  },
52700
52719
  {
52701
- code: 6094,
52720
+ code: 6093,
52702
52721
  name: "OrderBookManagerNotRentExempt",
52703
52722
  msg: "Account not rent-exempt"
52704
52723
  },
52705
52724
  {
52706
- code: 6095,
52725
+ code: 6094,
52707
52726
  name: "OrderBookManagerInvalidRentBalance",
52708
52727
  msg: "Invalid rent balance"
52709
52728
  },
52710
52729
  {
52711
- code: 6096,
52730
+ code: 6095,
52712
52731
  name: "OrderBookManagerInsufficientFunds",
52713
52732
  msg: "Insufficient funds"
52714
52733
  },
52715
52734
  {
52716
- code: 6097,
52735
+ code: 6096,
52717
52736
  name: "OrderBookManagerInvalidAccountOwner",
52718
52737
  msg: "OrderBook account owner mismatch"
52719
52738
  },
52720
52739
  {
52721
- code: 6098,
52740
+ code: 6097,
52722
52741
  name: "OrderBookManagerDataOutOfBounds",
52723
52742
  msg: "Data access out of bounds"
52724
52743
  },
52725
52744
  {
52726
- code: 6099,
52745
+ code: 6098,
52727
52746
  name: "NoValidInsertPosition",
52728
52747
  msg: "Cannot find valid insert position, all candidates failed due to price range overlap"
52729
52748
  },
52730
52749
  {
52731
- code: 6100,
52750
+ code: 6099,
52732
52751
  name: "EmptyCloseInsertIndices",
52733
52752
  msg: "close_insert_indices array cannot be empty"
52734
52753
  },
52735
52754
  {
52736
- code: 6101,
52755
+ code: 6100,
52737
52756
  name: "TooManyCloseInsertIndices",
52738
52757
  msg: "close_insert_indices array cannot exceed 20 elements"
52739
52758
  },
52740
52759
  {
52741
- code: 6102,
52760
+ code: 6101,
52742
52761
  name: "CloseOrderNotFound",
52743
52762
  msg: "Specified close order not found"
52744
52763
  },
52745
52764
  {
52746
- code: 6103,
52765
+ code: 6102,
52747
52766
  name: "LinkedListDeleteCountMismatch",
52748
52767
  msg: "Linked list delete count mismatch: count inconsistent before/after deletion"
52749
52768
  },
52750
52769
  {
52751
- code: 6104,
52770
+ code: 6103,
52752
52771
  name: "NameTooLong",
52753
52772
  msg: "Token name too long, max 32 bytes"
52754
52773
  },
52755
52774
  {
52756
- code: 6105,
52775
+ code: 6104,
52757
52776
  name: "NameEmpty",
52758
52777
  msg: "Token name cannot be empty"
52759
52778
  },
52760
52779
  {
52761
- code: 6106,
52780
+ code: 6105,
52762
52781
  name: "SymbolTooLong",
52763
52782
  msg: "Token symbol too long, max 10 bytes"
52764
52783
  },
52765
52784
  {
52766
- code: 6107,
52785
+ code: 6106,
52767
52786
  name: "SymbolEmpty",
52768
52787
  msg: "Token symbol cannot be empty"
52769
52788
  },
52770
52789
  {
52771
- code: 6108,
52790
+ code: 6107,
52772
52791
  name: "UriTooLong",
52773
52792
  msg: "URI too long, max 200 bytes"
52774
52793
  },
52775
52794
  {
52776
- code: 6109,
52795
+ code: 6108,
52777
52796
  name: "UriEmpty",
52778
52797
  msg: "URI cannot be empty"
52779
52798
  },
52780
52799
  {
52781
- code: 6110,
52800
+ code: 6109,
52782
52801
  name: "IncompleteAdvancedPoolParams",
52783
52802
  msg: "Incomplete advanced pool parameters: custom_lp_sol, custom_lp_token, custom_borrow_ratio, custom_borrow_duration must be provided together"
52784
52803
  },
52785
52804
  {
52786
- code: 6111,
52805
+ code: 6110,
52787
52806
  name: "InvalidInitialVirtualSol",
52788
52807
  msg: "Initial virtual SOL out of valid range"
52789
52808
  },
52790
52809
  {
52791
- code: 6112,
52810
+ code: 6111,
52792
52811
  name: "InvalidInitialVirtualToken",
52793
52812
  msg: "Initial virtual Token out of valid range"
52794
52813
  },
52795
52814
  {
52796
- code: 6113,
52815
+ code: 6112,
52797
52816
  name: "InvalidBorrowPoolRatio",
52798
52817
  msg: "Borrow pool ratio out of valid range"
52799
52818
  },
52800
52819
  {
52801
- code: 6114,
52820
+ code: 6113,
52802
52821
  name: "BorrowTokenCalculationOverflow",
52803
52822
  msg: "Borrow pool token amount calculation overflow"
52804
52823
  },
52805
52824
  {
52806
- code: 6115,
52825
+ code: 6114,
52807
52826
  name: "BorrowTokenAmountZero",
52808
52827
  msg: "Borrow pool token amount cannot be zero"
52809
52828
  }