pinpet-sdk 2.1.29 → 2.1.30
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.
- package/dist/pinpet-sdk.cjs.js +238 -235
- package/dist/pinpet-sdk.esm.js +238 -235
- package/dist/pinpet-sdk.js +238 -235
- package/dist/pinpet-sdk.js.map +1 -1
- package/package.json +1 -1
- package/src/idl/pinpet.json +94 -99
- package/src/modules/chain.js +86 -79
- package/src/modules/simulator/buy_sell_token.js +16 -14
- package/src/modules/simulator/long_shrot_stop.js +12 -12
- package/src/modules/simulator.js +22 -23
- package/src/modules/trading.js +8 -8
package/dist/pinpet-sdk.esm.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
35586
|
-
|
|
35587
|
-
|
|
35588
|
-
|
|
35589
|
-
|
|
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
|
-
|
|
35741
|
-
|
|
35742
|
-
|
|
35743
|
-
|
|
35744
|
-
|
|
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
|
|
36550
|
-
const priceResult = await
|
|
36551
|
-
|
|
36552
|
-
|
|
36553
|
-
|
|
36554
|
-
|
|
36555
|
-
|
|
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
|
|
36673
|
-
|
|
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
|
/**
|
|
@@ -36871,10 +36887,23 @@ class ChainModule$1 {
|
|
|
36871
36887
|
* @version 2.0.0 - Updated to use new OrderBook structure (up_orderbook/down_orderbook instead of upHead/downHead)
|
|
36872
36888
|
* @author SpinPet SDK Team
|
|
36873
36889
|
*/
|
|
36874
|
-
async getCurveAccount(mint) {
|
|
36890
|
+
async getCurveAccount(mint, options = {}) {
|
|
36891
|
+
const { skipBalances = false } = options;
|
|
36875
36892
|
try {
|
|
36876
36893
|
// Parameter validation and conversion
|
|
36877
36894
|
const mintPubkey = typeof mint === 'string' ? new PublicKey$3(mint) : mint;
|
|
36895
|
+
const mintKey = mintPubkey.toString();
|
|
36896
|
+
|
|
36897
|
+
// 检查缓存
|
|
36898
|
+
const cached = this._curveAccountCache.get(mintKey);
|
|
36899
|
+
if (cached && (Date.now() - cached.timestamp < this._CACHE_TTL)) {
|
|
36900
|
+
// 缓存命中:如果请求包含余额但缓存没有,需要重新获取余额部分
|
|
36901
|
+
if (!skipBalances && cached.skipBalances) {
|
|
36902
|
+
// 缓存是 skipBalances 的,但现在需要余额,需要补充查询
|
|
36903
|
+
} else {
|
|
36904
|
+
return cached.data;
|
|
36905
|
+
}
|
|
36906
|
+
}
|
|
36878
36907
|
|
|
36879
36908
|
// Calculate curve_account PDA address
|
|
36880
36909
|
// Use the same seeds as in the contract: [b"borrowing_curve", mint_account.key().as_ref()]
|
|
@@ -36932,18 +36961,25 @@ class ChainModule$1 {
|
|
|
36932
36961
|
this.sdk.programId
|
|
36933
36962
|
);
|
|
36934
36963
|
|
|
36935
|
-
// Query
|
|
36936
|
-
|
|
36937
|
-
|
|
36938
|
-
|
|
36939
|
-
|
|
36940
|
-
|
|
36941
|
-
|
|
36942
|
-
|
|
36943
|
-
|
|
36944
|
-
|
|
36945
|
-
|
|
36946
|
-
|
|
36964
|
+
// Query balances (skip if not needed)
|
|
36965
|
+
let baseFeeRecipientBalance = 0;
|
|
36966
|
+
let feeRecipientBalance = 0;
|
|
36967
|
+
let poolTokenBalance = { value: { amount: '0' } };
|
|
36968
|
+
let poolSolBalance = 0;
|
|
36969
|
+
|
|
36970
|
+
if (!skipBalances) {
|
|
36971
|
+
[
|
|
36972
|
+
baseFeeRecipientBalance,
|
|
36973
|
+
feeRecipientBalance,
|
|
36974
|
+
poolTokenBalance,
|
|
36975
|
+
poolSolBalance
|
|
36976
|
+
] = await Promise.all([
|
|
36977
|
+
this.sdk.connection.getBalance(decodedData.baseFeeRecipient),
|
|
36978
|
+
this.sdk.connection.getBalance(decodedData.feeRecipient),
|
|
36979
|
+
this.sdk.connection.getTokenAccountBalance(poolTokenAccountPDA).catch(() => ({ value: { amount: '0' } })),
|
|
36980
|
+
this.sdk.connection.getBalance(poolSolAccountPDA)
|
|
36981
|
+
]);
|
|
36982
|
+
}
|
|
36947
36983
|
|
|
36948
36984
|
// Convert data format
|
|
36949
36985
|
const convertedData = {
|
|
@@ -36999,6 +37035,13 @@ class ChainModule$1 {
|
|
|
36999
37035
|
}
|
|
37000
37036
|
};
|
|
37001
37037
|
|
|
37038
|
+
// 写入缓存
|
|
37039
|
+
this._curveAccountCache.set(mintKey, {
|
|
37040
|
+
data: convertedData,
|
|
37041
|
+
timestamp: Date.now(),
|
|
37042
|
+
skipBalances: skipBalances
|
|
37043
|
+
});
|
|
37044
|
+
|
|
37002
37045
|
// Return converted data
|
|
37003
37046
|
return convertedData;
|
|
37004
37047
|
|
|
@@ -37055,58 +37098,13 @@ class ChainModule$1 {
|
|
|
37055
37098
|
}
|
|
37056
37099
|
|
|
37057
37100
|
try {
|
|
37058
|
-
//
|
|
37059
|
-
|
|
37060
|
-
|
|
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
|
-
}
|
|
37090
|
-
|
|
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
|
-
}
|
|
37101
|
+
// 复用 getCurveAccount 缓存,避免重复 fetch 同一个账户
|
|
37102
|
+
const curveData = await this.getCurveAccount(mint, { skipBalances: true });
|
|
37103
|
+
const price = curveData.price;
|
|
37104
37104
|
|
|
37105
|
-
|
|
37106
|
-
|
|
37107
|
-
return decodedData.price.toString();
|
|
37105
|
+
if (price && price !== 0n) {
|
|
37106
|
+
return price.toString();
|
|
37108
37107
|
} else {
|
|
37109
|
-
// If no price data, return initial price
|
|
37110
37108
|
const initialPrice = CurveAMM$2.getInitialPrice();
|
|
37111
37109
|
if (initialPrice === null) {
|
|
37112
37110
|
throw new Error('price: Unable to calculate initial price');
|
|
@@ -37202,14 +37200,16 @@ class ChainModule$1 {
|
|
|
37202
37200
|
// Convert API type to orderbook direction
|
|
37203
37201
|
// "up_orders" = short orders = upOrderbook (orderType=2)
|
|
37204
37202
|
// "down_orders" = long orders = downOrderbook (orderType=1)
|
|
37205
|
-
const
|
|
37203
|
+
const seed = orderType === 'up_orders' ? 'up_orderbook' : 'down_orderbook';
|
|
37206
37204
|
|
|
37207
|
-
//
|
|
37208
|
-
const
|
|
37209
|
-
const
|
|
37205
|
+
// 本地计算 orderbook PDA,避免调用 getCurveAccount(省 5 个 RPC)
|
|
37206
|
+
const mintPubkey = new PublicKey$3(mint);
|
|
37207
|
+
const [orderbookPubkey] = PublicKey$3.findProgramAddressSync(
|
|
37208
|
+
[Buffer$3.from(seed), mintPubkey.toBuffer()],
|
|
37209
|
+
this.sdk.programId
|
|
37210
|
+
);
|
|
37210
37211
|
|
|
37211
37212
|
// Get OrderBook account data
|
|
37212
|
-
const orderbookPubkey = new PublicKey$3(orderbookAddress);
|
|
37213
37213
|
const accountInfo = await this.sdk.connection.getAccountInfo(orderbookPubkey);
|
|
37214
37214
|
|
|
37215
37215
|
if (!accountInfo) {
|
|
@@ -37660,15 +37660,15 @@ class ChainModule$1 {
|
|
|
37660
37660
|
throw new Error('debug_orders: order type must be "up_orders" or "down_orders"');
|
|
37661
37661
|
}
|
|
37662
37662
|
|
|
37663
|
-
//
|
|
37664
|
-
const
|
|
37665
|
-
|
|
37666
|
-
|
|
37667
|
-
|
|
37668
|
-
|
|
37663
|
+
// 本地计算 orderbook PDA,避免调用 getCurveAccount(省 5 个 RPC)
|
|
37664
|
+
const seed = orderType === 'up_orders' ? 'up_orderbook' : 'down_orderbook';
|
|
37665
|
+
const mintPubkey = new PublicKey$3(mint);
|
|
37666
|
+
const [orderbookPubkey] = PublicKey$3.findProgramAddressSync(
|
|
37667
|
+
[Buffer$3.from(seed), mintPubkey.toBuffer()],
|
|
37668
|
+
this.sdk.programId
|
|
37669
|
+
);
|
|
37669
37670
|
|
|
37670
37671
|
// Get OrderBook account data
|
|
37671
|
-
const orderbookPubkey = new PublicKey$3(orderbookAddress);
|
|
37672
37672
|
const accountInfo = await this.sdk.connection.getAccountInfo(orderbookPubkey);
|
|
37673
37673
|
|
|
37674
37674
|
if (!accountInfo) {
|
|
@@ -37871,10 +37871,18 @@ class ChainModule$1 {
|
|
|
37871
37871
|
const page = 1; // Always return page 1
|
|
37872
37872
|
const orderBy = options.order_by || 'start_time_desc';
|
|
37873
37873
|
|
|
37874
|
-
//
|
|
37875
|
-
const
|
|
37876
|
-
const
|
|
37877
|
-
|
|
37874
|
+
// 本地计算 orderbook PDA,避免调用 getCurveAccount(省 5 个 RPC)
|
|
37875
|
+
const mintPubkey = new PublicKey$3(mint);
|
|
37876
|
+
const [upOrderbookPubkey] = PublicKey$3.findProgramAddressSync(
|
|
37877
|
+
[Buffer$3.from('up_orderbook'), mintPubkey.toBuffer()],
|
|
37878
|
+
this.sdk.programId
|
|
37879
|
+
);
|
|
37880
|
+
const [downOrderbookPubkey] = PublicKey$3.findProgramAddressSync(
|
|
37881
|
+
[Buffer$3.from('down_orderbook'), mintPubkey.toBuffer()],
|
|
37882
|
+
this.sdk.programId
|
|
37883
|
+
);
|
|
37884
|
+
const upOrderbookAddress = upOrderbookPubkey.toString(); // Short orders (orderType=2)
|
|
37885
|
+
const downOrderbookAddress = downOrderbookPubkey.toString(); // Long orders (orderType=1)
|
|
37878
37886
|
|
|
37879
37887
|
// Collect all user orders from both OrderBooks
|
|
37880
37888
|
const allUserOrders = [];
|
|
@@ -38402,7 +38410,7 @@ class OrderUtils$2 {
|
|
|
38402
38410
|
|
|
38403
38411
|
var orderUtils = OrderUtils$2;
|
|
38404
38412
|
|
|
38405
|
-
var address = "
|
|
38413
|
+
var address = "F2FzigE1Z374iDvreiM6hZQe6oGXgomJfv8PyybvUXye";
|
|
38406
38414
|
var metadata = {
|
|
38407
38415
|
name: "pinpet",
|
|
38408
38416
|
version: "0.1.0",
|
|
@@ -40976,476 +40984,471 @@ var errors = [
|
|
|
40976
40984
|
},
|
|
40977
40985
|
{
|
|
40978
40986
|
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
40987
|
name: "FeeSplitCalculationOverflow",
|
|
40985
40988
|
msg: "Fee split calculation overflow"
|
|
40986
40989
|
},
|
|
40987
40990
|
{
|
|
40988
|
-
code:
|
|
40991
|
+
code: 6022,
|
|
40989
40992
|
name: "FeeAccumulationOverflow",
|
|
40990
40993
|
msg: "Fee accumulation overflow"
|
|
40991
40994
|
},
|
|
40992
40995
|
{
|
|
40993
|
-
code:
|
|
40996
|
+
code: 6023,
|
|
40994
40997
|
name: "PartnerFeeAdditionOverflow",
|
|
40995
40998
|
msg: "Partner fee addition overflow"
|
|
40996
40999
|
},
|
|
40997
41000
|
{
|
|
40998
|
-
code:
|
|
41001
|
+
code: 6024,
|
|
40999
41002
|
name: "BaseFeeAdditionOverflow",
|
|
41000
41003
|
msg: "Base fee addition overflow"
|
|
41001
41004
|
},
|
|
41002
41005
|
{
|
|
41003
|
-
code:
|
|
41006
|
+
code: 6025,
|
|
41004
41007
|
name: "PoolFeeDeductionOverflow",
|
|
41005
41008
|
msg: "Pool fee deduction overflow"
|
|
41006
41009
|
},
|
|
41007
41010
|
{
|
|
41008
|
-
code:
|
|
41011
|
+
code: 6026,
|
|
41009
41012
|
name: "FeeRandomDiscountOverflow",
|
|
41010
41013
|
msg: "Fee random discount calculation overflow"
|
|
41011
41014
|
},
|
|
41012
41015
|
{
|
|
41013
|
-
code:
|
|
41016
|
+
code: 6027,
|
|
41014
41017
|
name: "SolReserveAdditionOverflow",
|
|
41015
41018
|
msg: "SOL reserve addition overflow"
|
|
41016
41019
|
},
|
|
41017
41020
|
{
|
|
41018
|
-
code:
|
|
41021
|
+
code: 6028,
|
|
41019
41022
|
name: "SolReserveDeductionOverflow",
|
|
41020
41023
|
msg: "SOL reserve deduction overflow"
|
|
41021
41024
|
},
|
|
41022
41025
|
{
|
|
41023
|
-
code:
|
|
41026
|
+
code: 6029,
|
|
41024
41027
|
name: "TokenReserveAdditionOverflow",
|
|
41025
41028
|
msg: "Token reserve addition overflow"
|
|
41026
41029
|
},
|
|
41027
41030
|
{
|
|
41028
|
-
code:
|
|
41031
|
+
code: 6030,
|
|
41029
41032
|
name: "LamportsAdditionOverflow",
|
|
41030
41033
|
msg: "Lamports addition overflow"
|
|
41031
41034
|
},
|
|
41032
41035
|
{
|
|
41033
|
-
code:
|
|
41036
|
+
code: 6031,
|
|
41034
41037
|
name: "LamportsDeductionOverflow",
|
|
41035
41038
|
msg: "Lamports deduction overflow"
|
|
41036
41039
|
},
|
|
41037
41040
|
{
|
|
41038
|
-
code:
|
|
41041
|
+
code: 6032,
|
|
41039
41042
|
name: "DeadlineCalculationOverflow",
|
|
41040
41043
|
msg: "Deadline calculation overflow"
|
|
41041
41044
|
},
|
|
41042
41045
|
{
|
|
41043
|
-
code:
|
|
41046
|
+
code: 6033,
|
|
41044
41047
|
name: "FeeDiscountFlagOverflow",
|
|
41045
41048
|
msg: "Fee discount flag calculation overflow"
|
|
41046
41049
|
},
|
|
41047
41050
|
{
|
|
41048
|
-
code:
|
|
41051
|
+
code: 6034,
|
|
41049
41052
|
name: "Unauthorized",
|
|
41050
41053
|
msg: "Unauthorized operation"
|
|
41051
41054
|
},
|
|
41052
41055
|
{
|
|
41053
|
-
code:
|
|
41056
|
+
code: 6035,
|
|
41054
41057
|
name: "RequiredParameter",
|
|
41055
41058
|
msg: "All parameters are required during initialization"
|
|
41056
41059
|
},
|
|
41057
41060
|
{
|
|
41058
|
-
code:
|
|
41061
|
+
code: 6036,
|
|
41059
41062
|
name: "CurveCalculationError",
|
|
41060
41063
|
msg: "Curve calculation error"
|
|
41061
41064
|
},
|
|
41062
41065
|
{
|
|
41063
|
-
code:
|
|
41066
|
+
code: 6037,
|
|
41064
41067
|
name: "InitialPriceCalculationError",
|
|
41065
41068
|
msg: "Initial price calculation failed"
|
|
41066
41069
|
},
|
|
41067
41070
|
{
|
|
41068
|
-
code:
|
|
41071
|
+
code: 6038,
|
|
41069
41072
|
name: "BuyReserveRecalculationError",
|
|
41070
41073
|
msg: "Reserve recalculation failed (after buy)"
|
|
41071
41074
|
},
|
|
41072
41075
|
{
|
|
41073
|
-
code:
|
|
41076
|
+
code: 6039,
|
|
41074
41077
|
name: "SellReserveRecalculationError",
|
|
41075
41078
|
msg: "Reserve recalculation failed (after sell)"
|
|
41076
41079
|
},
|
|
41077
41080
|
{
|
|
41078
|
-
code:
|
|
41081
|
+
code: 6040,
|
|
41079
41082
|
name: "TotalAmountWithFeeError",
|
|
41080
41083
|
msg: "Total amount with fee calculation failed"
|
|
41081
41084
|
},
|
|
41082
41085
|
{
|
|
41083
|
-
code:
|
|
41086
|
+
code: 6041,
|
|
41084
41087
|
name: "AmountAfterFeeError",
|
|
41085
41088
|
msg: "Amount after fee calculation failed"
|
|
41086
41089
|
},
|
|
41087
41090
|
{
|
|
41088
|
-
code:
|
|
41091
|
+
code: 6042,
|
|
41089
41092
|
name: "BuyPriceRangeCalculationError",
|
|
41090
41093
|
msg: "Buy price range calculation failed"
|
|
41091
41094
|
},
|
|
41092
41095
|
{
|
|
41093
|
-
code:
|
|
41096
|
+
code: 6043,
|
|
41094
41097
|
name: "SellPriceRangeCalculationError",
|
|
41095
41098
|
msg: "Sell price range calculation failed"
|
|
41096
41099
|
},
|
|
41097
41100
|
{
|
|
41098
|
-
code:
|
|
41101
|
+
code: 6044,
|
|
41099
41102
|
name: "PriceAtStopLossBoundary",
|
|
41100
41103
|
msg: "Price has reached stop-loss boundary, head order must be liquidated first"
|
|
41101
41104
|
},
|
|
41102
41105
|
{
|
|
41103
|
-
code:
|
|
41106
|
+
code: 6045,
|
|
41104
41107
|
name: "RemainingRangeCalculationError",
|
|
41105
41108
|
msg: "Remaining range calculation failed"
|
|
41106
41109
|
},
|
|
41107
41110
|
{
|
|
41108
|
-
code:
|
|
41111
|
+
code: 6046,
|
|
41109
41112
|
name: "FullRangeCalculationError",
|
|
41110
41113
|
msg: "Full range calculation failed"
|
|
41111
41114
|
},
|
|
41112
41115
|
{
|
|
41113
|
-
code:
|
|
41116
|
+
code: 6047,
|
|
41114
41117
|
name: "BuyFromPriceWithTokenNoneError",
|
|
41115
41118
|
msg: "Curve function returned None: buy_from_price_with_token_output"
|
|
41116
41119
|
},
|
|
41117
41120
|
{
|
|
41118
|
-
code:
|
|
41121
|
+
code: 6048,
|
|
41119
41122
|
name: "SellFromPriceWithTokenNoneError",
|
|
41120
41123
|
msg: "Curve function returned None: sell_from_price_with_token_input"
|
|
41121
41124
|
},
|
|
41122
41125
|
{
|
|
41123
|
-
code:
|
|
41126
|
+
code: 6049,
|
|
41124
41127
|
name: "ExceedsMaxSolAmount",
|
|
41125
41128
|
msg: "Required SOL amount exceeds user-set maximum"
|
|
41126
41129
|
},
|
|
41127
41130
|
{
|
|
41128
|
-
code:
|
|
41131
|
+
code: 6050,
|
|
41129
41132
|
name: "InsufficientSolOutput",
|
|
41130
41133
|
msg: "Insufficient SOL output"
|
|
41131
41134
|
},
|
|
41132
41135
|
{
|
|
41133
|
-
code:
|
|
41136
|
+
code: 6051,
|
|
41134
41137
|
name: "InsufficientRepayment",
|
|
41135
41138
|
msg: "Insufficient proceeds to repay loan"
|
|
41136
41139
|
},
|
|
41137
41140
|
{
|
|
41138
|
-
code:
|
|
41141
|
+
code: 6052,
|
|
41139
41142
|
name: "InsufficientBorrowingReserve",
|
|
41140
41143
|
msg: "Insufficient borrowing reserve"
|
|
41141
41144
|
},
|
|
41142
41145
|
{
|
|
41143
|
-
code:
|
|
41146
|
+
code: 6053,
|
|
41144
41147
|
name: "InsufficientTokenSale",
|
|
41145
41148
|
msg: "Insufficient token sale amount"
|
|
41146
41149
|
},
|
|
41147
41150
|
{
|
|
41148
|
-
code:
|
|
41151
|
+
code: 6054,
|
|
41149
41152
|
name: "InsufficientLiquidity",
|
|
41150
41153
|
msg: "Insufficient liquidity in current order"
|
|
41151
41154
|
},
|
|
41152
41155
|
{
|
|
41153
|
-
code:
|
|
41156
|
+
code: 6055,
|
|
41154
41157
|
name: "InsufficientMarketLiquidity",
|
|
41155
41158
|
msg: "Insufficient market liquidity, cannot satisfy trade even after liquidating all stop-loss orders"
|
|
41156
41159
|
},
|
|
41157
41160
|
{
|
|
41158
|
-
code:
|
|
41161
|
+
code: 6056,
|
|
41159
41162
|
name: "TokenAmountDifferenceOutOfRange",
|
|
41160
41163
|
msg: "Token amount difference exceeds valid range in margin trade"
|
|
41161
41164
|
},
|
|
41162
41165
|
{
|
|
41163
|
-
code:
|
|
41166
|
+
code: 6057,
|
|
41164
41167
|
name: "BorrowAmountMismatch",
|
|
41165
41168
|
msg: "Borrow amount mismatch with locked tokens"
|
|
41166
41169
|
},
|
|
41167
41170
|
{
|
|
41168
|
-
code:
|
|
41171
|
+
code: 6058,
|
|
41169
41172
|
name: "CloseFeeCalculationError",
|
|
41170
41173
|
msg: "Close fee calculation error"
|
|
41171
41174
|
},
|
|
41172
41175
|
{
|
|
41173
|
-
code:
|
|
41176
|
+
code: 6059,
|
|
41174
41177
|
name: "InsufficientMargin",
|
|
41175
41178
|
msg: "Insufficient margin"
|
|
41176
41179
|
},
|
|
41177
41180
|
{
|
|
41178
|
-
code:
|
|
41181
|
+
code: 6060,
|
|
41179
41182
|
name: "InsufficientMinimumMargin",
|
|
41180
41183
|
msg: "Margin below minimum requirement"
|
|
41181
41184
|
},
|
|
41182
41185
|
{
|
|
41183
|
-
code:
|
|
41186
|
+
code: 6061,
|
|
41184
41187
|
name: "InvalidAccountOwner",
|
|
41185
41188
|
msg: "Invalid account owner"
|
|
41186
41189
|
},
|
|
41187
41190
|
{
|
|
41188
|
-
code:
|
|
41191
|
+
code: 6062,
|
|
41189
41192
|
name: "SellAmountExceedsOrderAmount",
|
|
41190
41193
|
msg: "Sell amount exceeds order's token holdings"
|
|
41191
41194
|
},
|
|
41192
41195
|
{
|
|
41193
|
-
code:
|
|
41196
|
+
code: 6063,
|
|
41194
41197
|
name: "OrderNotExpiredMustCloseByOwner",
|
|
41195
41198
|
msg: "Non-expired order must be closed by owner"
|
|
41196
41199
|
},
|
|
41197
41200
|
{
|
|
41198
|
-
code:
|
|
41201
|
+
code: 6064,
|
|
41199
41202
|
name: "SettlementAddressMustBeOwnerAddress",
|
|
41200
41203
|
msg: "Settlement address must be owner address"
|
|
41201
41204
|
},
|
|
41202
41205
|
{
|
|
41203
|
-
code:
|
|
41206
|
+
code: 6065,
|
|
41204
41207
|
name: "BuyAmountExceedsOrderAmount",
|
|
41205
41208
|
msg: "Buy amount exceeds order's token holdings"
|
|
41206
41209
|
},
|
|
41207
41210
|
{
|
|
41208
|
-
code:
|
|
41211
|
+
code: 6066,
|
|
41209
41212
|
name: "InsufficientTradeAmount",
|
|
41210
41213
|
msg: "Trade amount below minimum requirement"
|
|
41211
41214
|
},
|
|
41212
41215
|
{
|
|
41213
|
-
code:
|
|
41216
|
+
code: 6067,
|
|
41214
41217
|
name: "SolAmountTooLarge",
|
|
41215
41218
|
msg: "SOL amount exceeds maximum limit (10000000 SOL per transaction)"
|
|
41216
41219
|
},
|
|
41217
41220
|
{
|
|
41218
|
-
code:
|
|
41221
|
+
code: 6068,
|
|
41219
41222
|
name: "RemainingTokenAmountTooSmall",
|
|
41220
41223
|
msg: "Remaining token amount below minimum trade requirement"
|
|
41221
41224
|
},
|
|
41222
41225
|
{
|
|
41223
|
-
code:
|
|
41226
|
+
code: 6069,
|
|
41224
41227
|
name: "TradeCooldownNotExpired",
|
|
41225
41228
|
msg: "Trade cooldown period not expired, please try again later"
|
|
41226
41229
|
},
|
|
41227
41230
|
{
|
|
41228
|
-
code:
|
|
41231
|
+
code: 6070,
|
|
41229
41232
|
name: "ExceedApprovalAmount",
|
|
41230
41233
|
msg: "Sell amount exceeds approved amount, please call approval function first"
|
|
41231
41234
|
},
|
|
41232
41235
|
{
|
|
41233
|
-
code:
|
|
41236
|
+
code: 6071,
|
|
41234
41237
|
name: "CooldownNotInitialized",
|
|
41235
41238
|
msg: "Sell trade requires calling approval or buy function first to initialize cooldown PDA"
|
|
41236
41239
|
},
|
|
41237
41240
|
{
|
|
41238
|
-
code:
|
|
41241
|
+
code: 6072,
|
|
41239
41242
|
name: "CannotCloseCooldownWithBalance",
|
|
41240
41243
|
msg: "Cannot close cooldown PDA with non-zero token balance"
|
|
41241
41244
|
},
|
|
41242
41245
|
{
|
|
41243
|
-
code:
|
|
41246
|
+
code: 6073,
|
|
41244
41247
|
name: "PriceCalculationError",
|
|
41245
41248
|
msg: "Price calculation error"
|
|
41246
41249
|
},
|
|
41247
41250
|
{
|
|
41248
|
-
code:
|
|
41251
|
+
code: 6074,
|
|
41249
41252
|
name: "InvalidPartnerFeeRecipientAccount",
|
|
41250
41253
|
msg: "Invalid partner fee recipient account"
|
|
41251
41254
|
},
|
|
41252
41255
|
{
|
|
41253
|
-
code:
|
|
41256
|
+
code: 6075,
|
|
41254
41257
|
name: "InvalidBaseFeeRecipientAccount",
|
|
41255
41258
|
msg: "Invalid base fee recipient account"
|
|
41256
41259
|
},
|
|
41257
41260
|
{
|
|
41258
|
-
code:
|
|
41261
|
+
code: 6076,
|
|
41259
41262
|
name: "InvalidOrderbookAddress",
|
|
41260
41263
|
msg: "Orderbook address does not match curve account orderbook"
|
|
41261
41264
|
},
|
|
41262
41265
|
{
|
|
41263
|
-
code:
|
|
41266
|
+
code: 6077,
|
|
41264
41267
|
name: "InvalidFeePercentage",
|
|
41265
41268
|
msg: "Fee percentage must be between 0-100"
|
|
41266
41269
|
},
|
|
41267
41270
|
{
|
|
41268
|
-
code:
|
|
41271
|
+
code: 6078,
|
|
41269
41272
|
name: "InvalidFeeRate",
|
|
41270
41273
|
msg: "Fee rate exceeds maximum limit (10%)"
|
|
41271
41274
|
},
|
|
41272
41275
|
{
|
|
41273
|
-
code:
|
|
41276
|
+
code: 6079,
|
|
41274
41277
|
name: "InvalidCustomFeeRate",
|
|
41275
41278
|
msg: "Custom fee rate must be between 1000 (1%) and 5000 (5%)"
|
|
41276
41279
|
},
|
|
41277
41280
|
{
|
|
41278
|
-
code:
|
|
41281
|
+
code: 6080,
|
|
41279
41282
|
name: "InvalidBorrowDuration",
|
|
41280
41283
|
msg: "Borrow duration out of valid range (3-30 days)"
|
|
41281
41284
|
},
|
|
41282
41285
|
{
|
|
41283
|
-
code:
|
|
41286
|
+
code: 6081,
|
|
41284
41287
|
name: "InvalidStopLossPrice",
|
|
41285
41288
|
msg: "Stop loss price does not meet minimum interval requirement"
|
|
41286
41289
|
},
|
|
41287
41290
|
{
|
|
41288
|
-
code:
|
|
41291
|
+
code: 6082,
|
|
41289
41292
|
name: "NoProfitableFunds",
|
|
41290
41293
|
msg: "No profitable funds to transfer"
|
|
41291
41294
|
},
|
|
41292
41295
|
{
|
|
41293
|
-
code:
|
|
41296
|
+
code: 6083,
|
|
41294
41297
|
name: "InsufficientPoolFunds",
|
|
41295
41298
|
msg: "Insufficient pool funds"
|
|
41296
41299
|
},
|
|
41297
41300
|
{
|
|
41298
|
-
code:
|
|
41301
|
+
code: 6084,
|
|
41299
41302
|
name: "InsufficientPoolBalance",
|
|
41300
41303
|
msg: "Pool SOL account balance would fall below minimum required balance"
|
|
41301
41304
|
},
|
|
41302
41305
|
{
|
|
41303
|
-
code:
|
|
41306
|
+
code: 6085,
|
|
41304
41307
|
name: "OrderBookManagerOverflow",
|
|
41305
41308
|
msg: "Math operation overflow"
|
|
41306
41309
|
},
|
|
41307
41310
|
{
|
|
41308
|
-
code:
|
|
41311
|
+
code: 6086,
|
|
41309
41312
|
name: "OrderBookManagerInvalidSlotIndex",
|
|
41310
41313
|
msg: "Invalid slot index"
|
|
41311
41314
|
},
|
|
41312
41315
|
{
|
|
41313
|
-
code:
|
|
41316
|
+
code: 6087,
|
|
41314
41317
|
name: "OrderBookManagerInvalidAccountData",
|
|
41315
41318
|
msg: "Invalid account data"
|
|
41316
41319
|
},
|
|
41317
41320
|
{
|
|
41318
|
-
code:
|
|
41321
|
+
code: 6088,
|
|
41319
41322
|
name: "OrderBookManagerExceedsMaxCapacity",
|
|
41320
41323
|
msg: "New capacity exceeds maximum limit"
|
|
41321
41324
|
},
|
|
41322
41325
|
{
|
|
41323
|
-
code:
|
|
41326
|
+
code: 6089,
|
|
41324
41327
|
name: "OrderBookManagerExceedsAccountSizeLimit",
|
|
41325
41328
|
msg: "Account size exceeds 10MB limit"
|
|
41326
41329
|
},
|
|
41327
41330
|
{
|
|
41328
|
-
code:
|
|
41331
|
+
code: 6090,
|
|
41329
41332
|
name: "OrderBookManagerOrderIdMismatch",
|
|
41330
41333
|
msg: "Order ID mismatch"
|
|
41331
41334
|
},
|
|
41332
41335
|
{
|
|
41333
|
-
code:
|
|
41336
|
+
code: 6091,
|
|
41334
41337
|
name: "OrderBookManagerEmptyOrderBook",
|
|
41335
41338
|
msg: "Order book is empty"
|
|
41336
41339
|
},
|
|
41337
41340
|
{
|
|
41338
|
-
code:
|
|
41341
|
+
code: 6092,
|
|
41339
41342
|
name: "OrderBookManagerAccountNotWritable",
|
|
41340
41343
|
msg: "Account is not writable"
|
|
41341
41344
|
},
|
|
41342
41345
|
{
|
|
41343
|
-
code:
|
|
41346
|
+
code: 6093,
|
|
41344
41347
|
name: "OrderBookManagerNotRentExempt",
|
|
41345
41348
|
msg: "Account not rent-exempt"
|
|
41346
41349
|
},
|
|
41347
41350
|
{
|
|
41348
|
-
code:
|
|
41351
|
+
code: 6094,
|
|
41349
41352
|
name: "OrderBookManagerInvalidRentBalance",
|
|
41350
41353
|
msg: "Invalid rent balance"
|
|
41351
41354
|
},
|
|
41352
41355
|
{
|
|
41353
|
-
code:
|
|
41356
|
+
code: 6095,
|
|
41354
41357
|
name: "OrderBookManagerInsufficientFunds",
|
|
41355
41358
|
msg: "Insufficient funds"
|
|
41356
41359
|
},
|
|
41357
41360
|
{
|
|
41358
|
-
code:
|
|
41361
|
+
code: 6096,
|
|
41359
41362
|
name: "OrderBookManagerInvalidAccountOwner",
|
|
41360
41363
|
msg: "OrderBook account owner mismatch"
|
|
41361
41364
|
},
|
|
41362
41365
|
{
|
|
41363
|
-
code:
|
|
41366
|
+
code: 6097,
|
|
41364
41367
|
name: "OrderBookManagerDataOutOfBounds",
|
|
41365
41368
|
msg: "Data access out of bounds"
|
|
41366
41369
|
},
|
|
41367
41370
|
{
|
|
41368
|
-
code:
|
|
41371
|
+
code: 6098,
|
|
41369
41372
|
name: "NoValidInsertPosition",
|
|
41370
41373
|
msg: "Cannot find valid insert position, all candidates failed due to price range overlap"
|
|
41371
41374
|
},
|
|
41372
41375
|
{
|
|
41373
|
-
code:
|
|
41376
|
+
code: 6099,
|
|
41374
41377
|
name: "EmptyCloseInsertIndices",
|
|
41375
41378
|
msg: "close_insert_indices array cannot be empty"
|
|
41376
41379
|
},
|
|
41377
41380
|
{
|
|
41378
|
-
code:
|
|
41381
|
+
code: 6100,
|
|
41379
41382
|
name: "TooManyCloseInsertIndices",
|
|
41380
41383
|
msg: "close_insert_indices array cannot exceed 20 elements"
|
|
41381
41384
|
},
|
|
41382
41385
|
{
|
|
41383
|
-
code:
|
|
41386
|
+
code: 6101,
|
|
41384
41387
|
name: "CloseOrderNotFound",
|
|
41385
41388
|
msg: "Specified close order not found"
|
|
41386
41389
|
},
|
|
41387
41390
|
{
|
|
41388
|
-
code:
|
|
41391
|
+
code: 6102,
|
|
41389
41392
|
name: "LinkedListDeleteCountMismatch",
|
|
41390
41393
|
msg: "Linked list delete count mismatch: count inconsistent before/after deletion"
|
|
41391
41394
|
},
|
|
41392
41395
|
{
|
|
41393
|
-
code:
|
|
41396
|
+
code: 6103,
|
|
41394
41397
|
name: "NameTooLong",
|
|
41395
41398
|
msg: "Token name too long, max 32 bytes"
|
|
41396
41399
|
},
|
|
41397
41400
|
{
|
|
41398
|
-
code:
|
|
41401
|
+
code: 6104,
|
|
41399
41402
|
name: "NameEmpty",
|
|
41400
41403
|
msg: "Token name cannot be empty"
|
|
41401
41404
|
},
|
|
41402
41405
|
{
|
|
41403
|
-
code:
|
|
41406
|
+
code: 6105,
|
|
41404
41407
|
name: "SymbolTooLong",
|
|
41405
41408
|
msg: "Token symbol too long, max 10 bytes"
|
|
41406
41409
|
},
|
|
41407
41410
|
{
|
|
41408
|
-
code:
|
|
41411
|
+
code: 6106,
|
|
41409
41412
|
name: "SymbolEmpty",
|
|
41410
41413
|
msg: "Token symbol cannot be empty"
|
|
41411
41414
|
},
|
|
41412
41415
|
{
|
|
41413
|
-
code:
|
|
41416
|
+
code: 6107,
|
|
41414
41417
|
name: "UriTooLong",
|
|
41415
41418
|
msg: "URI too long, max 200 bytes"
|
|
41416
41419
|
},
|
|
41417
41420
|
{
|
|
41418
|
-
code:
|
|
41421
|
+
code: 6108,
|
|
41419
41422
|
name: "UriEmpty",
|
|
41420
41423
|
msg: "URI cannot be empty"
|
|
41421
41424
|
},
|
|
41422
41425
|
{
|
|
41423
|
-
code:
|
|
41426
|
+
code: 6109,
|
|
41424
41427
|
name: "IncompleteAdvancedPoolParams",
|
|
41425
41428
|
msg: "Incomplete advanced pool parameters: custom_lp_sol, custom_lp_token, custom_borrow_ratio, custom_borrow_duration must be provided together"
|
|
41426
41429
|
},
|
|
41427
41430
|
{
|
|
41428
|
-
code:
|
|
41431
|
+
code: 6110,
|
|
41429
41432
|
name: "InvalidInitialVirtualSol",
|
|
41430
41433
|
msg: "Initial virtual SOL out of valid range"
|
|
41431
41434
|
},
|
|
41432
41435
|
{
|
|
41433
|
-
code:
|
|
41436
|
+
code: 6111,
|
|
41434
41437
|
name: "InvalidInitialVirtualToken",
|
|
41435
41438
|
msg: "Initial virtual Token out of valid range"
|
|
41436
41439
|
},
|
|
41437
41440
|
{
|
|
41438
|
-
code:
|
|
41441
|
+
code: 6112,
|
|
41439
41442
|
name: "InvalidBorrowPoolRatio",
|
|
41440
41443
|
msg: "Borrow pool ratio out of valid range"
|
|
41441
41444
|
},
|
|
41442
41445
|
{
|
|
41443
|
-
code:
|
|
41446
|
+
code: 6113,
|
|
41444
41447
|
name: "BorrowTokenCalculationOverflow",
|
|
41445
41448
|
msg: "Borrow pool token amount calculation overflow"
|
|
41446
41449
|
},
|
|
41447
41450
|
{
|
|
41448
|
-
code:
|
|
41451
|
+
code: 6114,
|
|
41449
41452
|
name: "BorrowTokenAmountZero",
|
|
41450
41453
|
msg: "Borrow pool token amount cannot be zero"
|
|
41451
41454
|
}
|