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.cjs.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
46944
|
-
|
|
46945
|
-
|
|
46946
|
-
|
|
46947
|
-
|
|
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
|
-
|
|
47099
|
-
|
|
47100
|
-
|
|
47101
|
-
|
|
47102
|
-
|
|
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
|
|
47908
|
-
const priceResult = await
|
|
47909
|
-
|
|
47910
|
-
|
|
47911
|
-
|
|
47912
|
-
|
|
47913
|
-
|
|
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
|
|
48031
|
-
|
|
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
|
/**
|
|
@@ -48229,10 +48245,23 @@ class ChainModule$1 {
|
|
|
48229
48245
|
* @version 2.0.0 - Updated to use new OrderBook structure (up_orderbook/down_orderbook instead of upHead/downHead)
|
|
48230
48246
|
* @author SpinPet SDK Team
|
|
48231
48247
|
*/
|
|
48232
|
-
async getCurveAccount(mint) {
|
|
48248
|
+
async getCurveAccount(mint, options = {}) {
|
|
48249
|
+
const { skipBalances = false } = options;
|
|
48233
48250
|
try {
|
|
48234
48251
|
// Parameter validation and conversion
|
|
48235
48252
|
const mintPubkey = typeof mint === 'string' ? new PublicKey$3(mint) : mint;
|
|
48253
|
+
const mintKey = mintPubkey.toString();
|
|
48254
|
+
|
|
48255
|
+
// 检查缓存
|
|
48256
|
+
const cached = this._curveAccountCache.get(mintKey);
|
|
48257
|
+
if (cached && (Date.now() - cached.timestamp < this._CACHE_TTL)) {
|
|
48258
|
+
// 缓存命中:如果请求包含余额但缓存没有,需要重新获取余额部分
|
|
48259
|
+
if (!skipBalances && cached.skipBalances) {
|
|
48260
|
+
// 缓存是 skipBalances 的,但现在需要余额,需要补充查询
|
|
48261
|
+
} else {
|
|
48262
|
+
return cached.data;
|
|
48263
|
+
}
|
|
48264
|
+
}
|
|
48236
48265
|
|
|
48237
48266
|
// Calculate curve_account PDA address
|
|
48238
48267
|
// Use the same seeds as in the contract: [b"borrowing_curve", mint_account.key().as_ref()]
|
|
@@ -48290,18 +48319,25 @@ class ChainModule$1 {
|
|
|
48290
48319
|
this.sdk.programId
|
|
48291
48320
|
);
|
|
48292
48321
|
|
|
48293
|
-
// Query
|
|
48294
|
-
|
|
48295
|
-
|
|
48296
|
-
|
|
48297
|
-
|
|
48298
|
-
|
|
48299
|
-
|
|
48300
|
-
|
|
48301
|
-
|
|
48302
|
-
|
|
48303
|
-
|
|
48304
|
-
|
|
48322
|
+
// Query balances (skip if not needed)
|
|
48323
|
+
let baseFeeRecipientBalance = 0;
|
|
48324
|
+
let feeRecipientBalance = 0;
|
|
48325
|
+
let poolTokenBalance = { value: { amount: '0' } };
|
|
48326
|
+
let poolSolBalance = 0;
|
|
48327
|
+
|
|
48328
|
+
if (!skipBalances) {
|
|
48329
|
+
[
|
|
48330
|
+
baseFeeRecipientBalance,
|
|
48331
|
+
feeRecipientBalance,
|
|
48332
|
+
poolTokenBalance,
|
|
48333
|
+
poolSolBalance
|
|
48334
|
+
] = await Promise.all([
|
|
48335
|
+
this.sdk.connection.getBalance(decodedData.baseFeeRecipient),
|
|
48336
|
+
this.sdk.connection.getBalance(decodedData.feeRecipient),
|
|
48337
|
+
this.sdk.connection.getTokenAccountBalance(poolTokenAccountPDA).catch(() => ({ value: { amount: '0' } })),
|
|
48338
|
+
this.sdk.connection.getBalance(poolSolAccountPDA)
|
|
48339
|
+
]);
|
|
48340
|
+
}
|
|
48305
48341
|
|
|
48306
48342
|
// Convert data format
|
|
48307
48343
|
const convertedData = {
|
|
@@ -48357,6 +48393,13 @@ class ChainModule$1 {
|
|
|
48357
48393
|
}
|
|
48358
48394
|
};
|
|
48359
48395
|
|
|
48396
|
+
// 写入缓存
|
|
48397
|
+
this._curveAccountCache.set(mintKey, {
|
|
48398
|
+
data: convertedData,
|
|
48399
|
+
timestamp: Date.now(),
|
|
48400
|
+
skipBalances: skipBalances
|
|
48401
|
+
});
|
|
48402
|
+
|
|
48360
48403
|
// Return converted data
|
|
48361
48404
|
return convertedData;
|
|
48362
48405
|
|
|
@@ -48413,58 +48456,13 @@ class ChainModule$1 {
|
|
|
48413
48456
|
}
|
|
48414
48457
|
|
|
48415
48458
|
try {
|
|
48416
|
-
//
|
|
48417
|
-
|
|
48418
|
-
|
|
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
|
-
}
|
|
48448
|
-
|
|
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
|
-
}
|
|
48459
|
+
// 复用 getCurveAccount 缓存,避免重复 fetch 同一个账户
|
|
48460
|
+
const curveData = await this.getCurveAccount(mint, { skipBalances: true });
|
|
48461
|
+
const price = curveData.price;
|
|
48462
48462
|
|
|
48463
|
-
|
|
48464
|
-
|
|
48465
|
-
return decodedData.price.toString();
|
|
48463
|
+
if (price && price !== 0n) {
|
|
48464
|
+
return price.toString();
|
|
48466
48465
|
} else {
|
|
48467
|
-
// If no price data, return initial price
|
|
48468
48466
|
const initialPrice = CurveAMM$2.getInitialPrice();
|
|
48469
48467
|
if (initialPrice === null) {
|
|
48470
48468
|
throw new Error('price: Unable to calculate initial price');
|
|
@@ -48560,14 +48558,16 @@ class ChainModule$1 {
|
|
|
48560
48558
|
// Convert API type to orderbook direction
|
|
48561
48559
|
// "up_orders" = short orders = upOrderbook (orderType=2)
|
|
48562
48560
|
// "down_orders" = long orders = downOrderbook (orderType=1)
|
|
48563
|
-
const
|
|
48561
|
+
const seed = orderType === 'up_orders' ? 'up_orderbook' : 'down_orderbook';
|
|
48564
48562
|
|
|
48565
|
-
//
|
|
48566
|
-
const
|
|
48567
|
-
const
|
|
48563
|
+
// 本地计算 orderbook PDA,避免调用 getCurveAccount(省 5 个 RPC)
|
|
48564
|
+
const mintPubkey = new PublicKey$3(mint);
|
|
48565
|
+
const [orderbookPubkey] = PublicKey$3.findProgramAddressSync(
|
|
48566
|
+
[Buffer$3.from(seed), mintPubkey.toBuffer()],
|
|
48567
|
+
this.sdk.programId
|
|
48568
|
+
);
|
|
48568
48569
|
|
|
48569
48570
|
// Get OrderBook account data
|
|
48570
|
-
const orderbookPubkey = new PublicKey$3(orderbookAddress);
|
|
48571
48571
|
const accountInfo = await this.sdk.connection.getAccountInfo(orderbookPubkey);
|
|
48572
48572
|
|
|
48573
48573
|
if (!accountInfo) {
|
|
@@ -49018,15 +49018,15 @@ class ChainModule$1 {
|
|
|
49018
49018
|
throw new Error('debug_orders: order type must be "up_orders" or "down_orders"');
|
|
49019
49019
|
}
|
|
49020
49020
|
|
|
49021
|
-
//
|
|
49022
|
-
const
|
|
49023
|
-
|
|
49024
|
-
|
|
49025
|
-
|
|
49026
|
-
|
|
49021
|
+
// 本地计算 orderbook PDA,避免调用 getCurveAccount(省 5 个 RPC)
|
|
49022
|
+
const seed = orderType === 'up_orders' ? 'up_orderbook' : 'down_orderbook';
|
|
49023
|
+
const mintPubkey = new PublicKey$3(mint);
|
|
49024
|
+
const [orderbookPubkey] = PublicKey$3.findProgramAddressSync(
|
|
49025
|
+
[Buffer$3.from(seed), mintPubkey.toBuffer()],
|
|
49026
|
+
this.sdk.programId
|
|
49027
|
+
);
|
|
49027
49028
|
|
|
49028
49029
|
// Get OrderBook account data
|
|
49029
|
-
const orderbookPubkey = new PublicKey$3(orderbookAddress);
|
|
49030
49030
|
const accountInfo = await this.sdk.connection.getAccountInfo(orderbookPubkey);
|
|
49031
49031
|
|
|
49032
49032
|
if (!accountInfo) {
|
|
@@ -49229,10 +49229,18 @@ class ChainModule$1 {
|
|
|
49229
49229
|
const page = 1; // Always return page 1
|
|
49230
49230
|
const orderBy = options.order_by || 'start_time_desc';
|
|
49231
49231
|
|
|
49232
|
-
//
|
|
49233
|
-
const
|
|
49234
|
-
const
|
|
49235
|
-
|
|
49232
|
+
// 本地计算 orderbook PDA,避免调用 getCurveAccount(省 5 个 RPC)
|
|
49233
|
+
const mintPubkey = new PublicKey$3(mint);
|
|
49234
|
+
const [upOrderbookPubkey] = PublicKey$3.findProgramAddressSync(
|
|
49235
|
+
[Buffer$3.from('up_orderbook'), mintPubkey.toBuffer()],
|
|
49236
|
+
this.sdk.programId
|
|
49237
|
+
);
|
|
49238
|
+
const [downOrderbookPubkey] = PublicKey$3.findProgramAddressSync(
|
|
49239
|
+
[Buffer$3.from('down_orderbook'), mintPubkey.toBuffer()],
|
|
49240
|
+
this.sdk.programId
|
|
49241
|
+
);
|
|
49242
|
+
const upOrderbookAddress = upOrderbookPubkey.toString(); // Short orders (orderType=2)
|
|
49243
|
+
const downOrderbookAddress = downOrderbookPubkey.toString(); // Long orders (orderType=1)
|
|
49236
49244
|
|
|
49237
49245
|
// Collect all user orders from both OrderBooks
|
|
49238
49246
|
const allUserOrders = [];
|
|
@@ -49760,7 +49768,7 @@ class OrderUtils$2 {
|
|
|
49760
49768
|
|
|
49761
49769
|
var orderUtils = OrderUtils$2;
|
|
49762
49770
|
|
|
49763
|
-
var address = "
|
|
49771
|
+
var address = "F2FzigE1Z374iDvreiM6hZQe6oGXgomJfv8PyybvUXye";
|
|
49764
49772
|
var metadata = {
|
|
49765
49773
|
name: "pinpet",
|
|
49766
49774
|
version: "0.1.0",
|
|
@@ -52334,476 +52342,471 @@ var errors = [
|
|
|
52334
52342
|
},
|
|
52335
52343
|
{
|
|
52336
52344
|
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
52345
|
name: "FeeSplitCalculationOverflow",
|
|
52343
52346
|
msg: "Fee split calculation overflow"
|
|
52344
52347
|
},
|
|
52345
52348
|
{
|
|
52346
|
-
code:
|
|
52349
|
+
code: 6022,
|
|
52347
52350
|
name: "FeeAccumulationOverflow",
|
|
52348
52351
|
msg: "Fee accumulation overflow"
|
|
52349
52352
|
},
|
|
52350
52353
|
{
|
|
52351
|
-
code:
|
|
52354
|
+
code: 6023,
|
|
52352
52355
|
name: "PartnerFeeAdditionOverflow",
|
|
52353
52356
|
msg: "Partner fee addition overflow"
|
|
52354
52357
|
},
|
|
52355
52358
|
{
|
|
52356
|
-
code:
|
|
52359
|
+
code: 6024,
|
|
52357
52360
|
name: "BaseFeeAdditionOverflow",
|
|
52358
52361
|
msg: "Base fee addition overflow"
|
|
52359
52362
|
},
|
|
52360
52363
|
{
|
|
52361
|
-
code:
|
|
52364
|
+
code: 6025,
|
|
52362
52365
|
name: "PoolFeeDeductionOverflow",
|
|
52363
52366
|
msg: "Pool fee deduction overflow"
|
|
52364
52367
|
},
|
|
52365
52368
|
{
|
|
52366
|
-
code:
|
|
52369
|
+
code: 6026,
|
|
52367
52370
|
name: "FeeRandomDiscountOverflow",
|
|
52368
52371
|
msg: "Fee random discount calculation overflow"
|
|
52369
52372
|
},
|
|
52370
52373
|
{
|
|
52371
|
-
code:
|
|
52374
|
+
code: 6027,
|
|
52372
52375
|
name: "SolReserveAdditionOverflow",
|
|
52373
52376
|
msg: "SOL reserve addition overflow"
|
|
52374
52377
|
},
|
|
52375
52378
|
{
|
|
52376
|
-
code:
|
|
52379
|
+
code: 6028,
|
|
52377
52380
|
name: "SolReserveDeductionOverflow",
|
|
52378
52381
|
msg: "SOL reserve deduction overflow"
|
|
52379
52382
|
},
|
|
52380
52383
|
{
|
|
52381
|
-
code:
|
|
52384
|
+
code: 6029,
|
|
52382
52385
|
name: "TokenReserveAdditionOverflow",
|
|
52383
52386
|
msg: "Token reserve addition overflow"
|
|
52384
52387
|
},
|
|
52385
52388
|
{
|
|
52386
|
-
code:
|
|
52389
|
+
code: 6030,
|
|
52387
52390
|
name: "LamportsAdditionOverflow",
|
|
52388
52391
|
msg: "Lamports addition overflow"
|
|
52389
52392
|
},
|
|
52390
52393
|
{
|
|
52391
|
-
code:
|
|
52394
|
+
code: 6031,
|
|
52392
52395
|
name: "LamportsDeductionOverflow",
|
|
52393
52396
|
msg: "Lamports deduction overflow"
|
|
52394
52397
|
},
|
|
52395
52398
|
{
|
|
52396
|
-
code:
|
|
52399
|
+
code: 6032,
|
|
52397
52400
|
name: "DeadlineCalculationOverflow",
|
|
52398
52401
|
msg: "Deadline calculation overflow"
|
|
52399
52402
|
},
|
|
52400
52403
|
{
|
|
52401
|
-
code:
|
|
52404
|
+
code: 6033,
|
|
52402
52405
|
name: "FeeDiscountFlagOverflow",
|
|
52403
52406
|
msg: "Fee discount flag calculation overflow"
|
|
52404
52407
|
},
|
|
52405
52408
|
{
|
|
52406
|
-
code:
|
|
52409
|
+
code: 6034,
|
|
52407
52410
|
name: "Unauthorized",
|
|
52408
52411
|
msg: "Unauthorized operation"
|
|
52409
52412
|
},
|
|
52410
52413
|
{
|
|
52411
|
-
code:
|
|
52414
|
+
code: 6035,
|
|
52412
52415
|
name: "RequiredParameter",
|
|
52413
52416
|
msg: "All parameters are required during initialization"
|
|
52414
52417
|
},
|
|
52415
52418
|
{
|
|
52416
|
-
code:
|
|
52419
|
+
code: 6036,
|
|
52417
52420
|
name: "CurveCalculationError",
|
|
52418
52421
|
msg: "Curve calculation error"
|
|
52419
52422
|
},
|
|
52420
52423
|
{
|
|
52421
|
-
code:
|
|
52424
|
+
code: 6037,
|
|
52422
52425
|
name: "InitialPriceCalculationError",
|
|
52423
52426
|
msg: "Initial price calculation failed"
|
|
52424
52427
|
},
|
|
52425
52428
|
{
|
|
52426
|
-
code:
|
|
52429
|
+
code: 6038,
|
|
52427
52430
|
name: "BuyReserveRecalculationError",
|
|
52428
52431
|
msg: "Reserve recalculation failed (after buy)"
|
|
52429
52432
|
},
|
|
52430
52433
|
{
|
|
52431
|
-
code:
|
|
52434
|
+
code: 6039,
|
|
52432
52435
|
name: "SellReserveRecalculationError",
|
|
52433
52436
|
msg: "Reserve recalculation failed (after sell)"
|
|
52434
52437
|
},
|
|
52435
52438
|
{
|
|
52436
|
-
code:
|
|
52439
|
+
code: 6040,
|
|
52437
52440
|
name: "TotalAmountWithFeeError",
|
|
52438
52441
|
msg: "Total amount with fee calculation failed"
|
|
52439
52442
|
},
|
|
52440
52443
|
{
|
|
52441
|
-
code:
|
|
52444
|
+
code: 6041,
|
|
52442
52445
|
name: "AmountAfterFeeError",
|
|
52443
52446
|
msg: "Amount after fee calculation failed"
|
|
52444
52447
|
},
|
|
52445
52448
|
{
|
|
52446
|
-
code:
|
|
52449
|
+
code: 6042,
|
|
52447
52450
|
name: "BuyPriceRangeCalculationError",
|
|
52448
52451
|
msg: "Buy price range calculation failed"
|
|
52449
52452
|
},
|
|
52450
52453
|
{
|
|
52451
|
-
code:
|
|
52454
|
+
code: 6043,
|
|
52452
52455
|
name: "SellPriceRangeCalculationError",
|
|
52453
52456
|
msg: "Sell price range calculation failed"
|
|
52454
52457
|
},
|
|
52455
52458
|
{
|
|
52456
|
-
code:
|
|
52459
|
+
code: 6044,
|
|
52457
52460
|
name: "PriceAtStopLossBoundary",
|
|
52458
52461
|
msg: "Price has reached stop-loss boundary, head order must be liquidated first"
|
|
52459
52462
|
},
|
|
52460
52463
|
{
|
|
52461
|
-
code:
|
|
52464
|
+
code: 6045,
|
|
52462
52465
|
name: "RemainingRangeCalculationError",
|
|
52463
52466
|
msg: "Remaining range calculation failed"
|
|
52464
52467
|
},
|
|
52465
52468
|
{
|
|
52466
|
-
code:
|
|
52469
|
+
code: 6046,
|
|
52467
52470
|
name: "FullRangeCalculationError",
|
|
52468
52471
|
msg: "Full range calculation failed"
|
|
52469
52472
|
},
|
|
52470
52473
|
{
|
|
52471
|
-
code:
|
|
52474
|
+
code: 6047,
|
|
52472
52475
|
name: "BuyFromPriceWithTokenNoneError",
|
|
52473
52476
|
msg: "Curve function returned None: buy_from_price_with_token_output"
|
|
52474
52477
|
},
|
|
52475
52478
|
{
|
|
52476
|
-
code:
|
|
52479
|
+
code: 6048,
|
|
52477
52480
|
name: "SellFromPriceWithTokenNoneError",
|
|
52478
52481
|
msg: "Curve function returned None: sell_from_price_with_token_input"
|
|
52479
52482
|
},
|
|
52480
52483
|
{
|
|
52481
|
-
code:
|
|
52484
|
+
code: 6049,
|
|
52482
52485
|
name: "ExceedsMaxSolAmount",
|
|
52483
52486
|
msg: "Required SOL amount exceeds user-set maximum"
|
|
52484
52487
|
},
|
|
52485
52488
|
{
|
|
52486
|
-
code:
|
|
52489
|
+
code: 6050,
|
|
52487
52490
|
name: "InsufficientSolOutput",
|
|
52488
52491
|
msg: "Insufficient SOL output"
|
|
52489
52492
|
},
|
|
52490
52493
|
{
|
|
52491
|
-
code:
|
|
52494
|
+
code: 6051,
|
|
52492
52495
|
name: "InsufficientRepayment",
|
|
52493
52496
|
msg: "Insufficient proceeds to repay loan"
|
|
52494
52497
|
},
|
|
52495
52498
|
{
|
|
52496
|
-
code:
|
|
52499
|
+
code: 6052,
|
|
52497
52500
|
name: "InsufficientBorrowingReserve",
|
|
52498
52501
|
msg: "Insufficient borrowing reserve"
|
|
52499
52502
|
},
|
|
52500
52503
|
{
|
|
52501
|
-
code:
|
|
52504
|
+
code: 6053,
|
|
52502
52505
|
name: "InsufficientTokenSale",
|
|
52503
52506
|
msg: "Insufficient token sale amount"
|
|
52504
52507
|
},
|
|
52505
52508
|
{
|
|
52506
|
-
code:
|
|
52509
|
+
code: 6054,
|
|
52507
52510
|
name: "InsufficientLiquidity",
|
|
52508
52511
|
msg: "Insufficient liquidity in current order"
|
|
52509
52512
|
},
|
|
52510
52513
|
{
|
|
52511
|
-
code:
|
|
52514
|
+
code: 6055,
|
|
52512
52515
|
name: "InsufficientMarketLiquidity",
|
|
52513
52516
|
msg: "Insufficient market liquidity, cannot satisfy trade even after liquidating all stop-loss orders"
|
|
52514
52517
|
},
|
|
52515
52518
|
{
|
|
52516
|
-
code:
|
|
52519
|
+
code: 6056,
|
|
52517
52520
|
name: "TokenAmountDifferenceOutOfRange",
|
|
52518
52521
|
msg: "Token amount difference exceeds valid range in margin trade"
|
|
52519
52522
|
},
|
|
52520
52523
|
{
|
|
52521
|
-
code:
|
|
52524
|
+
code: 6057,
|
|
52522
52525
|
name: "BorrowAmountMismatch",
|
|
52523
52526
|
msg: "Borrow amount mismatch with locked tokens"
|
|
52524
52527
|
},
|
|
52525
52528
|
{
|
|
52526
|
-
code:
|
|
52529
|
+
code: 6058,
|
|
52527
52530
|
name: "CloseFeeCalculationError",
|
|
52528
52531
|
msg: "Close fee calculation error"
|
|
52529
52532
|
},
|
|
52530
52533
|
{
|
|
52531
|
-
code:
|
|
52534
|
+
code: 6059,
|
|
52532
52535
|
name: "InsufficientMargin",
|
|
52533
52536
|
msg: "Insufficient margin"
|
|
52534
52537
|
},
|
|
52535
52538
|
{
|
|
52536
|
-
code:
|
|
52539
|
+
code: 6060,
|
|
52537
52540
|
name: "InsufficientMinimumMargin",
|
|
52538
52541
|
msg: "Margin below minimum requirement"
|
|
52539
52542
|
},
|
|
52540
52543
|
{
|
|
52541
|
-
code:
|
|
52544
|
+
code: 6061,
|
|
52542
52545
|
name: "InvalidAccountOwner",
|
|
52543
52546
|
msg: "Invalid account owner"
|
|
52544
52547
|
},
|
|
52545
52548
|
{
|
|
52546
|
-
code:
|
|
52549
|
+
code: 6062,
|
|
52547
52550
|
name: "SellAmountExceedsOrderAmount",
|
|
52548
52551
|
msg: "Sell amount exceeds order's token holdings"
|
|
52549
52552
|
},
|
|
52550
52553
|
{
|
|
52551
|
-
code:
|
|
52554
|
+
code: 6063,
|
|
52552
52555
|
name: "OrderNotExpiredMustCloseByOwner",
|
|
52553
52556
|
msg: "Non-expired order must be closed by owner"
|
|
52554
52557
|
},
|
|
52555
52558
|
{
|
|
52556
|
-
code:
|
|
52559
|
+
code: 6064,
|
|
52557
52560
|
name: "SettlementAddressMustBeOwnerAddress",
|
|
52558
52561
|
msg: "Settlement address must be owner address"
|
|
52559
52562
|
},
|
|
52560
52563
|
{
|
|
52561
|
-
code:
|
|
52564
|
+
code: 6065,
|
|
52562
52565
|
name: "BuyAmountExceedsOrderAmount",
|
|
52563
52566
|
msg: "Buy amount exceeds order's token holdings"
|
|
52564
52567
|
},
|
|
52565
52568
|
{
|
|
52566
|
-
code:
|
|
52569
|
+
code: 6066,
|
|
52567
52570
|
name: "InsufficientTradeAmount",
|
|
52568
52571
|
msg: "Trade amount below minimum requirement"
|
|
52569
52572
|
},
|
|
52570
52573
|
{
|
|
52571
|
-
code:
|
|
52574
|
+
code: 6067,
|
|
52572
52575
|
name: "SolAmountTooLarge",
|
|
52573
52576
|
msg: "SOL amount exceeds maximum limit (10000000 SOL per transaction)"
|
|
52574
52577
|
},
|
|
52575
52578
|
{
|
|
52576
|
-
code:
|
|
52579
|
+
code: 6068,
|
|
52577
52580
|
name: "RemainingTokenAmountTooSmall",
|
|
52578
52581
|
msg: "Remaining token amount below minimum trade requirement"
|
|
52579
52582
|
},
|
|
52580
52583
|
{
|
|
52581
|
-
code:
|
|
52584
|
+
code: 6069,
|
|
52582
52585
|
name: "TradeCooldownNotExpired",
|
|
52583
52586
|
msg: "Trade cooldown period not expired, please try again later"
|
|
52584
52587
|
},
|
|
52585
52588
|
{
|
|
52586
|
-
code:
|
|
52589
|
+
code: 6070,
|
|
52587
52590
|
name: "ExceedApprovalAmount",
|
|
52588
52591
|
msg: "Sell amount exceeds approved amount, please call approval function first"
|
|
52589
52592
|
},
|
|
52590
52593
|
{
|
|
52591
|
-
code:
|
|
52594
|
+
code: 6071,
|
|
52592
52595
|
name: "CooldownNotInitialized",
|
|
52593
52596
|
msg: "Sell trade requires calling approval or buy function first to initialize cooldown PDA"
|
|
52594
52597
|
},
|
|
52595
52598
|
{
|
|
52596
|
-
code:
|
|
52599
|
+
code: 6072,
|
|
52597
52600
|
name: "CannotCloseCooldownWithBalance",
|
|
52598
52601
|
msg: "Cannot close cooldown PDA with non-zero token balance"
|
|
52599
52602
|
},
|
|
52600
52603
|
{
|
|
52601
|
-
code:
|
|
52604
|
+
code: 6073,
|
|
52602
52605
|
name: "PriceCalculationError",
|
|
52603
52606
|
msg: "Price calculation error"
|
|
52604
52607
|
},
|
|
52605
52608
|
{
|
|
52606
|
-
code:
|
|
52609
|
+
code: 6074,
|
|
52607
52610
|
name: "InvalidPartnerFeeRecipientAccount",
|
|
52608
52611
|
msg: "Invalid partner fee recipient account"
|
|
52609
52612
|
},
|
|
52610
52613
|
{
|
|
52611
|
-
code:
|
|
52614
|
+
code: 6075,
|
|
52612
52615
|
name: "InvalidBaseFeeRecipientAccount",
|
|
52613
52616
|
msg: "Invalid base fee recipient account"
|
|
52614
52617
|
},
|
|
52615
52618
|
{
|
|
52616
|
-
code:
|
|
52619
|
+
code: 6076,
|
|
52617
52620
|
name: "InvalidOrderbookAddress",
|
|
52618
52621
|
msg: "Orderbook address does not match curve account orderbook"
|
|
52619
52622
|
},
|
|
52620
52623
|
{
|
|
52621
|
-
code:
|
|
52624
|
+
code: 6077,
|
|
52622
52625
|
name: "InvalidFeePercentage",
|
|
52623
52626
|
msg: "Fee percentage must be between 0-100"
|
|
52624
52627
|
},
|
|
52625
52628
|
{
|
|
52626
|
-
code:
|
|
52629
|
+
code: 6078,
|
|
52627
52630
|
name: "InvalidFeeRate",
|
|
52628
52631
|
msg: "Fee rate exceeds maximum limit (10%)"
|
|
52629
52632
|
},
|
|
52630
52633
|
{
|
|
52631
|
-
code:
|
|
52634
|
+
code: 6079,
|
|
52632
52635
|
name: "InvalidCustomFeeRate",
|
|
52633
52636
|
msg: "Custom fee rate must be between 1000 (1%) and 5000 (5%)"
|
|
52634
52637
|
},
|
|
52635
52638
|
{
|
|
52636
|
-
code:
|
|
52639
|
+
code: 6080,
|
|
52637
52640
|
name: "InvalidBorrowDuration",
|
|
52638
52641
|
msg: "Borrow duration out of valid range (3-30 days)"
|
|
52639
52642
|
},
|
|
52640
52643
|
{
|
|
52641
|
-
code:
|
|
52644
|
+
code: 6081,
|
|
52642
52645
|
name: "InvalidStopLossPrice",
|
|
52643
52646
|
msg: "Stop loss price does not meet minimum interval requirement"
|
|
52644
52647
|
},
|
|
52645
52648
|
{
|
|
52646
|
-
code:
|
|
52649
|
+
code: 6082,
|
|
52647
52650
|
name: "NoProfitableFunds",
|
|
52648
52651
|
msg: "No profitable funds to transfer"
|
|
52649
52652
|
},
|
|
52650
52653
|
{
|
|
52651
|
-
code:
|
|
52654
|
+
code: 6083,
|
|
52652
52655
|
name: "InsufficientPoolFunds",
|
|
52653
52656
|
msg: "Insufficient pool funds"
|
|
52654
52657
|
},
|
|
52655
52658
|
{
|
|
52656
|
-
code:
|
|
52659
|
+
code: 6084,
|
|
52657
52660
|
name: "InsufficientPoolBalance",
|
|
52658
52661
|
msg: "Pool SOL account balance would fall below minimum required balance"
|
|
52659
52662
|
},
|
|
52660
52663
|
{
|
|
52661
|
-
code:
|
|
52664
|
+
code: 6085,
|
|
52662
52665
|
name: "OrderBookManagerOverflow",
|
|
52663
52666
|
msg: "Math operation overflow"
|
|
52664
52667
|
},
|
|
52665
52668
|
{
|
|
52666
|
-
code:
|
|
52669
|
+
code: 6086,
|
|
52667
52670
|
name: "OrderBookManagerInvalidSlotIndex",
|
|
52668
52671
|
msg: "Invalid slot index"
|
|
52669
52672
|
},
|
|
52670
52673
|
{
|
|
52671
|
-
code:
|
|
52674
|
+
code: 6087,
|
|
52672
52675
|
name: "OrderBookManagerInvalidAccountData",
|
|
52673
52676
|
msg: "Invalid account data"
|
|
52674
52677
|
},
|
|
52675
52678
|
{
|
|
52676
|
-
code:
|
|
52679
|
+
code: 6088,
|
|
52677
52680
|
name: "OrderBookManagerExceedsMaxCapacity",
|
|
52678
52681
|
msg: "New capacity exceeds maximum limit"
|
|
52679
52682
|
},
|
|
52680
52683
|
{
|
|
52681
|
-
code:
|
|
52684
|
+
code: 6089,
|
|
52682
52685
|
name: "OrderBookManagerExceedsAccountSizeLimit",
|
|
52683
52686
|
msg: "Account size exceeds 10MB limit"
|
|
52684
52687
|
},
|
|
52685
52688
|
{
|
|
52686
|
-
code:
|
|
52689
|
+
code: 6090,
|
|
52687
52690
|
name: "OrderBookManagerOrderIdMismatch",
|
|
52688
52691
|
msg: "Order ID mismatch"
|
|
52689
52692
|
},
|
|
52690
52693
|
{
|
|
52691
|
-
code:
|
|
52694
|
+
code: 6091,
|
|
52692
52695
|
name: "OrderBookManagerEmptyOrderBook",
|
|
52693
52696
|
msg: "Order book is empty"
|
|
52694
52697
|
},
|
|
52695
52698
|
{
|
|
52696
|
-
code:
|
|
52699
|
+
code: 6092,
|
|
52697
52700
|
name: "OrderBookManagerAccountNotWritable",
|
|
52698
52701
|
msg: "Account is not writable"
|
|
52699
52702
|
},
|
|
52700
52703
|
{
|
|
52701
|
-
code:
|
|
52704
|
+
code: 6093,
|
|
52702
52705
|
name: "OrderBookManagerNotRentExempt",
|
|
52703
52706
|
msg: "Account not rent-exempt"
|
|
52704
52707
|
},
|
|
52705
52708
|
{
|
|
52706
|
-
code:
|
|
52709
|
+
code: 6094,
|
|
52707
52710
|
name: "OrderBookManagerInvalidRentBalance",
|
|
52708
52711
|
msg: "Invalid rent balance"
|
|
52709
52712
|
},
|
|
52710
52713
|
{
|
|
52711
|
-
code:
|
|
52714
|
+
code: 6095,
|
|
52712
52715
|
name: "OrderBookManagerInsufficientFunds",
|
|
52713
52716
|
msg: "Insufficient funds"
|
|
52714
52717
|
},
|
|
52715
52718
|
{
|
|
52716
|
-
code:
|
|
52719
|
+
code: 6096,
|
|
52717
52720
|
name: "OrderBookManagerInvalidAccountOwner",
|
|
52718
52721
|
msg: "OrderBook account owner mismatch"
|
|
52719
52722
|
},
|
|
52720
52723
|
{
|
|
52721
|
-
code:
|
|
52724
|
+
code: 6097,
|
|
52722
52725
|
name: "OrderBookManagerDataOutOfBounds",
|
|
52723
52726
|
msg: "Data access out of bounds"
|
|
52724
52727
|
},
|
|
52725
52728
|
{
|
|
52726
|
-
code:
|
|
52729
|
+
code: 6098,
|
|
52727
52730
|
name: "NoValidInsertPosition",
|
|
52728
52731
|
msg: "Cannot find valid insert position, all candidates failed due to price range overlap"
|
|
52729
52732
|
},
|
|
52730
52733
|
{
|
|
52731
|
-
code:
|
|
52734
|
+
code: 6099,
|
|
52732
52735
|
name: "EmptyCloseInsertIndices",
|
|
52733
52736
|
msg: "close_insert_indices array cannot be empty"
|
|
52734
52737
|
},
|
|
52735
52738
|
{
|
|
52736
|
-
code:
|
|
52739
|
+
code: 6100,
|
|
52737
52740
|
name: "TooManyCloseInsertIndices",
|
|
52738
52741
|
msg: "close_insert_indices array cannot exceed 20 elements"
|
|
52739
52742
|
},
|
|
52740
52743
|
{
|
|
52741
|
-
code:
|
|
52744
|
+
code: 6101,
|
|
52742
52745
|
name: "CloseOrderNotFound",
|
|
52743
52746
|
msg: "Specified close order not found"
|
|
52744
52747
|
},
|
|
52745
52748
|
{
|
|
52746
|
-
code:
|
|
52749
|
+
code: 6102,
|
|
52747
52750
|
name: "LinkedListDeleteCountMismatch",
|
|
52748
52751
|
msg: "Linked list delete count mismatch: count inconsistent before/after deletion"
|
|
52749
52752
|
},
|
|
52750
52753
|
{
|
|
52751
|
-
code:
|
|
52754
|
+
code: 6103,
|
|
52752
52755
|
name: "NameTooLong",
|
|
52753
52756
|
msg: "Token name too long, max 32 bytes"
|
|
52754
52757
|
},
|
|
52755
52758
|
{
|
|
52756
|
-
code:
|
|
52759
|
+
code: 6104,
|
|
52757
52760
|
name: "NameEmpty",
|
|
52758
52761
|
msg: "Token name cannot be empty"
|
|
52759
52762
|
},
|
|
52760
52763
|
{
|
|
52761
|
-
code:
|
|
52764
|
+
code: 6105,
|
|
52762
52765
|
name: "SymbolTooLong",
|
|
52763
52766
|
msg: "Token symbol too long, max 10 bytes"
|
|
52764
52767
|
},
|
|
52765
52768
|
{
|
|
52766
|
-
code:
|
|
52769
|
+
code: 6106,
|
|
52767
52770
|
name: "SymbolEmpty",
|
|
52768
52771
|
msg: "Token symbol cannot be empty"
|
|
52769
52772
|
},
|
|
52770
52773
|
{
|
|
52771
|
-
code:
|
|
52774
|
+
code: 6107,
|
|
52772
52775
|
name: "UriTooLong",
|
|
52773
52776
|
msg: "URI too long, max 200 bytes"
|
|
52774
52777
|
},
|
|
52775
52778
|
{
|
|
52776
|
-
code:
|
|
52779
|
+
code: 6108,
|
|
52777
52780
|
name: "UriEmpty",
|
|
52778
52781
|
msg: "URI cannot be empty"
|
|
52779
52782
|
},
|
|
52780
52783
|
{
|
|
52781
|
-
code:
|
|
52784
|
+
code: 6109,
|
|
52782
52785
|
name: "IncompleteAdvancedPoolParams",
|
|
52783
52786
|
msg: "Incomplete advanced pool parameters: custom_lp_sol, custom_lp_token, custom_borrow_ratio, custom_borrow_duration must be provided together"
|
|
52784
52787
|
},
|
|
52785
52788
|
{
|
|
52786
|
-
code:
|
|
52789
|
+
code: 6110,
|
|
52787
52790
|
name: "InvalidInitialVirtualSol",
|
|
52788
52791
|
msg: "Initial virtual SOL out of valid range"
|
|
52789
52792
|
},
|
|
52790
52793
|
{
|
|
52791
|
-
code:
|
|
52794
|
+
code: 6111,
|
|
52792
52795
|
name: "InvalidInitialVirtualToken",
|
|
52793
52796
|
msg: "Initial virtual Token out of valid range"
|
|
52794
52797
|
},
|
|
52795
52798
|
{
|
|
52796
|
-
code:
|
|
52799
|
+
code: 6112,
|
|
52797
52800
|
name: "InvalidBorrowPoolRatio",
|
|
52798
52801
|
msg: "Borrow pool ratio out of valid range"
|
|
52799
52802
|
},
|
|
52800
52803
|
{
|
|
52801
|
-
code:
|
|
52804
|
+
code: 6113,
|
|
52802
52805
|
name: "BorrowTokenCalculationOverflow",
|
|
52803
52806
|
msg: "Borrow pool token amount calculation overflow"
|
|
52804
52807
|
},
|
|
52805
52808
|
{
|
|
52806
|
-
code:
|
|
52809
|
+
code: 6114,
|
|
52807
52810
|
name: "BorrowTokenAmountZero",
|
|
52808
52811
|
msg: "Borrow pool token amount cannot be zero"
|
|
52809
52812
|
}
|