pinpet-sdk 2.1.22 → 2.1.24
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 +132 -122
- package/dist/pinpet-sdk.esm.js +132 -122
- package/dist/pinpet-sdk.js +132 -122
- package/dist/pinpet-sdk.js.map +1 -1
- package/package.json +1 -1
- package/src/idl/pinpet.json +94 -99
- package/src/modules/simulator/long_shrot_stop.js +37 -22
- package/src/utils/constants.js +1 -1
package/dist/pinpet-sdk.cjs.js
CHANGED
|
@@ -45198,7 +45198,7 @@ async function simulateLongStopLoss$1(mint, buyTokenAmount, stopLossPrice, lastP
|
|
|
45198
45198
|
throw new Error('Failed to get current price');
|
|
45199
45199
|
}
|
|
45200
45200
|
}
|
|
45201
|
-
console.log("simulateLongStopLoss lastPrice=",lastPrice)
|
|
45201
|
+
//console.log("simulateLongStopLoss lastPrice=",lastPrice)
|
|
45202
45202
|
|
|
45203
45203
|
// Get ordersData
|
|
45204
45204
|
if (!ordersData) {
|
|
@@ -45210,17 +45210,17 @@ async function simulateLongStopLoss$1(mint, buyTokenAmount, stopLossPrice, lastP
|
|
|
45210
45210
|
}
|
|
45211
45211
|
|
|
45212
45212
|
//console.log("ordersData=", JSONbig.stringify(ordersData, null, 2))
|
|
45213
|
-
console.log("ordersData len=", ordersData.data.orders.length)
|
|
45213
|
+
//console.log("ordersData len=", ordersData.data.orders.length)
|
|
45214
45214
|
|
|
45215
45215
|
// Calculate current price
|
|
45216
45216
|
let currentPrice;
|
|
45217
45217
|
if (lastPrice === null || lastPrice === undefined || lastPrice === '0') {
|
|
45218
|
-
console.log('Current price is empty, using initial price');
|
|
45218
|
+
//console.log('Current price is empty, using initial price');
|
|
45219
45219
|
currentPrice = CurveAMM$6.getInitialPrice();
|
|
45220
45220
|
} else {
|
|
45221
45221
|
currentPrice = BigInt(lastPrice);
|
|
45222
45222
|
if (!currentPrice || currentPrice === 0n) {
|
|
45223
|
-
console.log('Current price is 0, using initial price');
|
|
45223
|
+
//console.log('Current price is 0, using initial price');
|
|
45224
45224
|
currentPrice = CurveAMM$6.getInitialPrice();
|
|
45225
45225
|
}
|
|
45226
45226
|
}
|
|
@@ -45228,7 +45228,7 @@ async function simulateLongStopLoss$1(mint, buyTokenAmount, stopLossPrice, lastP
|
|
|
45228
45228
|
|
|
45229
45229
|
// Transform orders data
|
|
45230
45230
|
const downOrders = transformOrdersData(ordersData);
|
|
45231
|
-
console.log(`downOrders Found ${downOrders.length} existing long orders`);
|
|
45231
|
+
//console.log(`downOrders Found ${downOrders.length} existing long orders`);
|
|
45232
45232
|
//console.log("downOrders downOrders=",downOrders)
|
|
45233
45233
|
|
|
45234
45234
|
// Initialize stop loss prices
|
|
@@ -45519,24 +45519,24 @@ async function simulateShortStopLoss$1(mint, sellTokenAmount, stopLossPrice, las
|
|
|
45519
45519
|
}
|
|
45520
45520
|
|
|
45521
45521
|
//console.log("ordersData=", JSONbig.stringify(ordersData, null, 2))
|
|
45522
|
-
console.log("ordersData len=", ordersData.data.orders.length)
|
|
45522
|
+
//console.log("ordersData len=", ordersData.data.orders.length)
|
|
45523
45523
|
|
|
45524
45524
|
// Calculate current price
|
|
45525
45525
|
let currentPrice;
|
|
45526
45526
|
if (lastPrice === null || lastPrice === undefined || lastPrice === '0') {
|
|
45527
|
-
console.log('Current price is empty, using initial price');
|
|
45527
|
+
//console.log('Current price is empty, using initial price');
|
|
45528
45528
|
currentPrice = CurveAMM$6.getInitialPrice();
|
|
45529
45529
|
} else {
|
|
45530
45530
|
currentPrice = BigInt(lastPrice);
|
|
45531
45531
|
if (!currentPrice || currentPrice === 0n) {
|
|
45532
|
-
console.log('Current price is 0, using initial price');
|
|
45532
|
+
//console.log('Current price is 0, using initial price');
|
|
45533
45533
|
currentPrice = CurveAMM$6.getInitialPrice();
|
|
45534
45534
|
}
|
|
45535
45535
|
}
|
|
45536
45536
|
|
|
45537
45537
|
// Transform orders data
|
|
45538
45538
|
const upOrders = transformOrdersData(ordersData);
|
|
45539
|
-
console.log(`upOrders Found ${upOrders.length} existing short orders`);
|
|
45539
|
+
//console.log(`upOrders Found ${upOrders.length} existing short orders`);
|
|
45540
45540
|
|
|
45541
45541
|
// Initialize stop loss prices
|
|
45542
45542
|
let stopLossStartPrice = BigInt(stopLossPrice);
|
|
@@ -45554,11 +45554,7 @@ async function simulateShortStopLoss$1(mint, sellTokenAmount, stopLossPrice, las
|
|
|
45554
45554
|
stopLossStartPrice = minAllowedStopLoss;
|
|
45555
45555
|
const originalPercent = Number((originalStopLoss - currentPrice) * 1000n / currentPrice) / 10;
|
|
45556
45556
|
const adjustedPercent = Number((stopLossStartPrice - currentPrice) * 1000n / currentPrice) / 10;
|
|
45557
|
-
|
|
45558
|
-
console.log(` 原始止损距离: ${originalPercent.toFixed(2)}%`);
|
|
45559
|
-
console.log(` 调整后距离: ${adjustedPercent.toFixed(2)}% (最小要求: ${Number(MIN_STOP_LOSS_PERCENT) / 10}%)`);
|
|
45560
|
-
console.log(` 原始止损价: ${originalStopLoss}`);
|
|
45561
|
-
console.log(` 调整后止损价: ${stopLossStartPrice}`);
|
|
45557
|
+
|
|
45562
45558
|
}
|
|
45563
45559
|
|
|
45564
45560
|
//console.log(`Start price: ${stopLossStartPrice}, Target token amount: ${sellTokenAmount}`);
|
|
@@ -45647,9 +45643,10 @@ async function simulateShortStopLoss$1(mint, sellTokenAmount, stopLossPrice, las
|
|
|
45647
45643
|
const feeAmount = (finalTradeAmount * BigInt(borrowFee)) / 100000n;
|
|
45648
45644
|
const closeCostWithFee = finalTradeAmount + feeAmount;
|
|
45649
45645
|
|
|
45650
|
-
// 4. 计算保证金 = 平仓成本(含手续费)
|
|
45651
|
-
|
|
45652
|
-
|
|
45646
|
+
// 4. 计算保证金 = 平仓成本(含手续费) + 开仓手续费 - 开仓收益
|
|
45647
|
+
// 开仓手续费是支出,应该加到成本中
|
|
45648
|
+
if (closeCostWithFee + openingFee > openingSolGain) {
|
|
45649
|
+
estimatedMargin = closeCostWithFee + openingFee - openingSolGain;
|
|
45653
45650
|
}
|
|
45654
45651
|
}
|
|
45655
45652
|
} catch (marginError) {
|
|
@@ -45778,12 +45775,21 @@ async function simulateLongSolStopLoss$1(mint, buySolAmount, stopLossPrice, last
|
|
|
45778
45775
|
let buyTokenAmount = initialResult[1]; // Token amount
|
|
45779
45776
|
let stopLossResult;
|
|
45780
45777
|
let iterations = 0;
|
|
45781
|
-
const maxIterations =
|
|
45778
|
+
const maxIterations = 50;
|
|
45779
|
+
|
|
45780
|
+
// 根据杠杆倍数动态计算二分查找上界
|
|
45781
|
+
// 高杠杆(如20x)时止损距离小,每个代币的保证金贡献小,需要更多代币才能消耗完保证金
|
|
45782
|
+
// Calculate dynamic binary search upper bound based on leverage
|
|
45783
|
+
const stopLossPriceBigInt = BigInt(stopLossPrice);
|
|
45784
|
+
const priceDiff = currentPrice - stopLossPriceBigInt;
|
|
45785
|
+
const estimatedLeverage = priceDiff > 0n ? Number(currentPrice * 10000n / priceDiff) / 10000 : 10;
|
|
45786
|
+
const safeMultiplier = BigInt(Math.ceil(estimatedLeverage * 3)); // 3倍安全系数
|
|
45787
|
+
const multiplier = safeMultiplier > 10n ? safeMultiplier : 10n; // 最小10倍
|
|
45782
45788
|
|
|
45783
45789
|
// 使用二分查找算法找到 estimatedMargin < buySolAmount 的最大值
|
|
45784
45790
|
// Use binary search algorithm to find maximum estimatedMargin that is less than buySolAmount
|
|
45785
45791
|
let left = 1n; // 最小值,确保有一个有效的下界
|
|
45786
|
-
let right = buyTokenAmount *
|
|
45792
|
+
let right = buyTokenAmount * multiplier; // 上界:根据杠杆动态计算
|
|
45787
45793
|
let bestResult = null;
|
|
45788
45794
|
let bestMargin = 0n; // 记录最大的合法 estimatedMargin
|
|
45789
45795
|
let bestTokenAmount = buyTokenAmount;
|
|
@@ -45923,7 +45929,7 @@ async function simulateShortSolStopLoss$1(mint, sellSolAmount, stopLossPrice, la
|
|
|
45923
45929
|
}
|
|
45924
45930
|
}
|
|
45925
45931
|
|
|
45926
|
-
console.log("simulateShortSolStopLoss lastPrice=",lastPrice)
|
|
45932
|
+
//console.log("simulateShortSolStopLoss lastPrice=",lastPrice)
|
|
45927
45933
|
|
|
45928
45934
|
// Calculate current price
|
|
45929
45935
|
if (lastPrice === null || lastPrice === undefined || lastPrice === '0') {
|
|
@@ -45945,12 +45951,21 @@ async function simulateShortSolStopLoss$1(mint, sellSolAmount, stopLossPrice, la
|
|
|
45945
45951
|
let sellTokenAmount = initialResult[1]; // Token amount
|
|
45946
45952
|
let stopLossResult;
|
|
45947
45953
|
let iterations = 0;
|
|
45948
|
-
const maxIterations =
|
|
45954
|
+
const maxIterations = 50;
|
|
45955
|
+
|
|
45956
|
+
// 根据杠杆倍数动态计算二分查找上界
|
|
45957
|
+
// 高杠杆(如20x)时止损距离小,每个代币的保证金贡献小,需要更多代币才能消耗完保证金
|
|
45958
|
+
// Calculate dynamic binary search upper bound based on leverage
|
|
45959
|
+
const stopLossPriceBigInt = BigInt(stopLossPrice);
|
|
45960
|
+
const priceDiff = stopLossPriceBigInt - currentPrice;
|
|
45961
|
+
const estimatedLeverage = priceDiff > 0n ? Number(currentPrice * 10000n / priceDiff) / 10000 : 10;
|
|
45962
|
+
const safeMultiplier = BigInt(Math.ceil(estimatedLeverage * 3)); // 3倍安全系数
|
|
45963
|
+
const multiplier = safeMultiplier > 10n ? safeMultiplier : 10n; // 最小10倍
|
|
45949
45964
|
|
|
45950
45965
|
// 使用二分查找算法找到 estimatedMargin < sellSolAmount 的最大值
|
|
45951
45966
|
// Use binary search algorithm to find maximum estimatedMargin that is less than sellSolAmount
|
|
45952
45967
|
let left = 1n; // 最小值,确保有一个有效的下界
|
|
45953
|
-
let right = sellTokenAmount *
|
|
45968
|
+
let right = sellTokenAmount * multiplier; // 上界:根据杠杆动态计算
|
|
45954
45969
|
let bestResult = null;
|
|
45955
45970
|
let bestMargin = 0n; // 记录最大的合法 estimatedMargin
|
|
45956
45971
|
let bestTokenAmount = sellTokenAmount;
|
|
@@ -49673,7 +49688,7 @@ class OrderUtils$2 {
|
|
|
49673
49688
|
|
|
49674
49689
|
var orderUtils = OrderUtils$2;
|
|
49675
49690
|
|
|
49676
|
-
var address = "
|
|
49691
|
+
var address = "F2FzigE1Z374iDvreiM6hZQe6oGXgomJfv8PyybvUXye";
|
|
49677
49692
|
var metadata = {
|
|
49678
49693
|
name: "pinpet",
|
|
49679
49694
|
version: "0.1.0",
|
|
@@ -52247,476 +52262,471 @@ var errors = [
|
|
|
52247
52262
|
},
|
|
52248
52263
|
{
|
|
52249
52264
|
code: 6021,
|
|
52250
|
-
name: "CloseShortImpossibleState",
|
|
52251
|
-
msg: "Close short impossible state: current_total should always be greater than remaining_close_reduced_sol_with_fee"
|
|
52252
|
-
},
|
|
52253
|
-
{
|
|
52254
|
-
code: 6022,
|
|
52255
52265
|
name: "FeeSplitCalculationOverflow",
|
|
52256
52266
|
msg: "Fee split calculation overflow"
|
|
52257
52267
|
},
|
|
52258
52268
|
{
|
|
52259
|
-
code:
|
|
52269
|
+
code: 6022,
|
|
52260
52270
|
name: "FeeAccumulationOverflow",
|
|
52261
52271
|
msg: "Fee accumulation overflow"
|
|
52262
52272
|
},
|
|
52263
52273
|
{
|
|
52264
|
-
code:
|
|
52274
|
+
code: 6023,
|
|
52265
52275
|
name: "PartnerFeeAdditionOverflow",
|
|
52266
52276
|
msg: "Partner fee addition overflow"
|
|
52267
52277
|
},
|
|
52268
52278
|
{
|
|
52269
|
-
code:
|
|
52279
|
+
code: 6024,
|
|
52270
52280
|
name: "BaseFeeAdditionOverflow",
|
|
52271
52281
|
msg: "Base fee addition overflow"
|
|
52272
52282
|
},
|
|
52273
52283
|
{
|
|
52274
|
-
code:
|
|
52284
|
+
code: 6025,
|
|
52275
52285
|
name: "PoolFeeDeductionOverflow",
|
|
52276
52286
|
msg: "Pool fee deduction overflow"
|
|
52277
52287
|
},
|
|
52278
52288
|
{
|
|
52279
|
-
code:
|
|
52289
|
+
code: 6026,
|
|
52280
52290
|
name: "FeeRandomDiscountOverflow",
|
|
52281
52291
|
msg: "Fee random discount calculation overflow"
|
|
52282
52292
|
},
|
|
52283
52293
|
{
|
|
52284
|
-
code:
|
|
52294
|
+
code: 6027,
|
|
52285
52295
|
name: "SolReserveAdditionOverflow",
|
|
52286
52296
|
msg: "SOL reserve addition overflow"
|
|
52287
52297
|
},
|
|
52288
52298
|
{
|
|
52289
|
-
code:
|
|
52299
|
+
code: 6028,
|
|
52290
52300
|
name: "SolReserveDeductionOverflow",
|
|
52291
52301
|
msg: "SOL reserve deduction overflow"
|
|
52292
52302
|
},
|
|
52293
52303
|
{
|
|
52294
|
-
code:
|
|
52304
|
+
code: 6029,
|
|
52295
52305
|
name: "TokenReserveAdditionOverflow",
|
|
52296
52306
|
msg: "Token reserve addition overflow"
|
|
52297
52307
|
},
|
|
52298
52308
|
{
|
|
52299
|
-
code:
|
|
52309
|
+
code: 6030,
|
|
52300
52310
|
name: "LamportsAdditionOverflow",
|
|
52301
52311
|
msg: "Lamports addition overflow"
|
|
52302
52312
|
},
|
|
52303
52313
|
{
|
|
52304
|
-
code:
|
|
52314
|
+
code: 6031,
|
|
52305
52315
|
name: "LamportsDeductionOverflow",
|
|
52306
52316
|
msg: "Lamports deduction overflow"
|
|
52307
52317
|
},
|
|
52308
52318
|
{
|
|
52309
|
-
code:
|
|
52319
|
+
code: 6032,
|
|
52310
52320
|
name: "DeadlineCalculationOverflow",
|
|
52311
52321
|
msg: "Deadline calculation overflow"
|
|
52312
52322
|
},
|
|
52313
52323
|
{
|
|
52314
|
-
code:
|
|
52324
|
+
code: 6033,
|
|
52315
52325
|
name: "FeeDiscountFlagOverflow",
|
|
52316
52326
|
msg: "Fee discount flag calculation overflow"
|
|
52317
52327
|
},
|
|
52318
52328
|
{
|
|
52319
|
-
code:
|
|
52329
|
+
code: 6034,
|
|
52320
52330
|
name: "Unauthorized",
|
|
52321
52331
|
msg: "Unauthorized operation"
|
|
52322
52332
|
},
|
|
52323
52333
|
{
|
|
52324
|
-
code:
|
|
52334
|
+
code: 6035,
|
|
52325
52335
|
name: "RequiredParameter",
|
|
52326
52336
|
msg: "All parameters are required during initialization"
|
|
52327
52337
|
},
|
|
52328
52338
|
{
|
|
52329
|
-
code:
|
|
52339
|
+
code: 6036,
|
|
52330
52340
|
name: "CurveCalculationError",
|
|
52331
52341
|
msg: "Curve calculation error"
|
|
52332
52342
|
},
|
|
52333
52343
|
{
|
|
52334
|
-
code:
|
|
52344
|
+
code: 6037,
|
|
52335
52345
|
name: "InitialPriceCalculationError",
|
|
52336
52346
|
msg: "Initial price calculation failed"
|
|
52337
52347
|
},
|
|
52338
52348
|
{
|
|
52339
|
-
code:
|
|
52349
|
+
code: 6038,
|
|
52340
52350
|
name: "BuyReserveRecalculationError",
|
|
52341
52351
|
msg: "Reserve recalculation failed (after buy)"
|
|
52342
52352
|
},
|
|
52343
52353
|
{
|
|
52344
|
-
code:
|
|
52354
|
+
code: 6039,
|
|
52345
52355
|
name: "SellReserveRecalculationError",
|
|
52346
52356
|
msg: "Reserve recalculation failed (after sell)"
|
|
52347
52357
|
},
|
|
52348
52358
|
{
|
|
52349
|
-
code:
|
|
52359
|
+
code: 6040,
|
|
52350
52360
|
name: "TotalAmountWithFeeError",
|
|
52351
52361
|
msg: "Total amount with fee calculation failed"
|
|
52352
52362
|
},
|
|
52353
52363
|
{
|
|
52354
|
-
code:
|
|
52364
|
+
code: 6041,
|
|
52355
52365
|
name: "AmountAfterFeeError",
|
|
52356
52366
|
msg: "Amount after fee calculation failed"
|
|
52357
52367
|
},
|
|
52358
52368
|
{
|
|
52359
|
-
code:
|
|
52369
|
+
code: 6042,
|
|
52360
52370
|
name: "BuyPriceRangeCalculationError",
|
|
52361
52371
|
msg: "Buy price range calculation failed"
|
|
52362
52372
|
},
|
|
52363
52373
|
{
|
|
52364
|
-
code:
|
|
52374
|
+
code: 6043,
|
|
52365
52375
|
name: "SellPriceRangeCalculationError",
|
|
52366
52376
|
msg: "Sell price range calculation failed"
|
|
52367
52377
|
},
|
|
52368
52378
|
{
|
|
52369
|
-
code:
|
|
52379
|
+
code: 6044,
|
|
52370
52380
|
name: "PriceAtStopLossBoundary",
|
|
52371
52381
|
msg: "Price has reached stop-loss boundary, head order must be liquidated first"
|
|
52372
52382
|
},
|
|
52373
52383
|
{
|
|
52374
|
-
code:
|
|
52384
|
+
code: 6045,
|
|
52375
52385
|
name: "RemainingRangeCalculationError",
|
|
52376
52386
|
msg: "Remaining range calculation failed"
|
|
52377
52387
|
},
|
|
52378
52388
|
{
|
|
52379
|
-
code:
|
|
52389
|
+
code: 6046,
|
|
52380
52390
|
name: "FullRangeCalculationError",
|
|
52381
52391
|
msg: "Full range calculation failed"
|
|
52382
52392
|
},
|
|
52383
52393
|
{
|
|
52384
|
-
code:
|
|
52394
|
+
code: 6047,
|
|
52385
52395
|
name: "BuyFromPriceWithTokenNoneError",
|
|
52386
52396
|
msg: "Curve function returned None: buy_from_price_with_token_output"
|
|
52387
52397
|
},
|
|
52388
52398
|
{
|
|
52389
|
-
code:
|
|
52399
|
+
code: 6048,
|
|
52390
52400
|
name: "SellFromPriceWithTokenNoneError",
|
|
52391
52401
|
msg: "Curve function returned None: sell_from_price_with_token_input"
|
|
52392
52402
|
},
|
|
52393
52403
|
{
|
|
52394
|
-
code:
|
|
52404
|
+
code: 6049,
|
|
52395
52405
|
name: "ExceedsMaxSolAmount",
|
|
52396
52406
|
msg: "Required SOL amount exceeds user-set maximum"
|
|
52397
52407
|
},
|
|
52398
52408
|
{
|
|
52399
|
-
code:
|
|
52409
|
+
code: 6050,
|
|
52400
52410
|
name: "InsufficientSolOutput",
|
|
52401
52411
|
msg: "Insufficient SOL output"
|
|
52402
52412
|
},
|
|
52403
52413
|
{
|
|
52404
|
-
code:
|
|
52414
|
+
code: 6051,
|
|
52405
52415
|
name: "InsufficientRepayment",
|
|
52406
52416
|
msg: "Insufficient proceeds to repay loan"
|
|
52407
52417
|
},
|
|
52408
52418
|
{
|
|
52409
|
-
code:
|
|
52419
|
+
code: 6052,
|
|
52410
52420
|
name: "InsufficientBorrowingReserve",
|
|
52411
52421
|
msg: "Insufficient borrowing reserve"
|
|
52412
52422
|
},
|
|
52413
52423
|
{
|
|
52414
|
-
code:
|
|
52424
|
+
code: 6053,
|
|
52415
52425
|
name: "InsufficientTokenSale",
|
|
52416
52426
|
msg: "Insufficient token sale amount"
|
|
52417
52427
|
},
|
|
52418
52428
|
{
|
|
52419
|
-
code:
|
|
52429
|
+
code: 6054,
|
|
52420
52430
|
name: "InsufficientLiquidity",
|
|
52421
52431
|
msg: "Insufficient liquidity in current order"
|
|
52422
52432
|
},
|
|
52423
52433
|
{
|
|
52424
|
-
code:
|
|
52434
|
+
code: 6055,
|
|
52425
52435
|
name: "InsufficientMarketLiquidity",
|
|
52426
52436
|
msg: "Insufficient market liquidity, cannot satisfy trade even after liquidating all stop-loss orders"
|
|
52427
52437
|
},
|
|
52428
52438
|
{
|
|
52429
|
-
code:
|
|
52439
|
+
code: 6056,
|
|
52430
52440
|
name: "TokenAmountDifferenceOutOfRange",
|
|
52431
52441
|
msg: "Token amount difference exceeds valid range in margin trade"
|
|
52432
52442
|
},
|
|
52433
52443
|
{
|
|
52434
|
-
code:
|
|
52444
|
+
code: 6057,
|
|
52435
52445
|
name: "BorrowAmountMismatch",
|
|
52436
52446
|
msg: "Borrow amount mismatch with locked tokens"
|
|
52437
52447
|
},
|
|
52438
52448
|
{
|
|
52439
|
-
code:
|
|
52449
|
+
code: 6058,
|
|
52440
52450
|
name: "CloseFeeCalculationError",
|
|
52441
52451
|
msg: "Close fee calculation error"
|
|
52442
52452
|
},
|
|
52443
52453
|
{
|
|
52444
|
-
code:
|
|
52454
|
+
code: 6059,
|
|
52445
52455
|
name: "InsufficientMargin",
|
|
52446
52456
|
msg: "Insufficient margin"
|
|
52447
52457
|
},
|
|
52448
52458
|
{
|
|
52449
|
-
code:
|
|
52459
|
+
code: 6060,
|
|
52450
52460
|
name: "InsufficientMinimumMargin",
|
|
52451
52461
|
msg: "Margin below minimum requirement"
|
|
52452
52462
|
},
|
|
52453
52463
|
{
|
|
52454
|
-
code:
|
|
52464
|
+
code: 6061,
|
|
52455
52465
|
name: "InvalidAccountOwner",
|
|
52456
52466
|
msg: "Invalid account owner"
|
|
52457
52467
|
},
|
|
52458
52468
|
{
|
|
52459
|
-
code:
|
|
52469
|
+
code: 6062,
|
|
52460
52470
|
name: "SellAmountExceedsOrderAmount",
|
|
52461
52471
|
msg: "Sell amount exceeds order's token holdings"
|
|
52462
52472
|
},
|
|
52463
52473
|
{
|
|
52464
|
-
code:
|
|
52474
|
+
code: 6063,
|
|
52465
52475
|
name: "OrderNotExpiredMustCloseByOwner",
|
|
52466
52476
|
msg: "Non-expired order must be closed by owner"
|
|
52467
52477
|
},
|
|
52468
52478
|
{
|
|
52469
|
-
code:
|
|
52479
|
+
code: 6064,
|
|
52470
52480
|
name: "SettlementAddressMustBeOwnerAddress",
|
|
52471
52481
|
msg: "Settlement address must be owner address"
|
|
52472
52482
|
},
|
|
52473
52483
|
{
|
|
52474
|
-
code:
|
|
52484
|
+
code: 6065,
|
|
52475
52485
|
name: "BuyAmountExceedsOrderAmount",
|
|
52476
52486
|
msg: "Buy amount exceeds order's token holdings"
|
|
52477
52487
|
},
|
|
52478
52488
|
{
|
|
52479
|
-
code:
|
|
52489
|
+
code: 6066,
|
|
52480
52490
|
name: "InsufficientTradeAmount",
|
|
52481
52491
|
msg: "Trade amount below minimum requirement"
|
|
52482
52492
|
},
|
|
52483
52493
|
{
|
|
52484
|
-
code:
|
|
52494
|
+
code: 6067,
|
|
52485
52495
|
name: "SolAmountTooLarge",
|
|
52486
52496
|
msg: "SOL amount exceeds maximum limit (10000000 SOL per transaction)"
|
|
52487
52497
|
},
|
|
52488
52498
|
{
|
|
52489
|
-
code:
|
|
52499
|
+
code: 6068,
|
|
52490
52500
|
name: "RemainingTokenAmountTooSmall",
|
|
52491
52501
|
msg: "Remaining token amount below minimum trade requirement"
|
|
52492
52502
|
},
|
|
52493
52503
|
{
|
|
52494
|
-
code:
|
|
52504
|
+
code: 6069,
|
|
52495
52505
|
name: "TradeCooldownNotExpired",
|
|
52496
52506
|
msg: "Trade cooldown period not expired, please try again later"
|
|
52497
52507
|
},
|
|
52498
52508
|
{
|
|
52499
|
-
code:
|
|
52509
|
+
code: 6070,
|
|
52500
52510
|
name: "ExceedApprovalAmount",
|
|
52501
52511
|
msg: "Sell amount exceeds approved amount, please call approval function first"
|
|
52502
52512
|
},
|
|
52503
52513
|
{
|
|
52504
|
-
code:
|
|
52514
|
+
code: 6071,
|
|
52505
52515
|
name: "CooldownNotInitialized",
|
|
52506
52516
|
msg: "Sell trade requires calling approval or buy function first to initialize cooldown PDA"
|
|
52507
52517
|
},
|
|
52508
52518
|
{
|
|
52509
|
-
code:
|
|
52519
|
+
code: 6072,
|
|
52510
52520
|
name: "CannotCloseCooldownWithBalance",
|
|
52511
52521
|
msg: "Cannot close cooldown PDA with non-zero token balance"
|
|
52512
52522
|
},
|
|
52513
52523
|
{
|
|
52514
|
-
code:
|
|
52524
|
+
code: 6073,
|
|
52515
52525
|
name: "PriceCalculationError",
|
|
52516
52526
|
msg: "Price calculation error"
|
|
52517
52527
|
},
|
|
52518
52528
|
{
|
|
52519
|
-
code:
|
|
52529
|
+
code: 6074,
|
|
52520
52530
|
name: "InvalidPartnerFeeRecipientAccount",
|
|
52521
52531
|
msg: "Invalid partner fee recipient account"
|
|
52522
52532
|
},
|
|
52523
52533
|
{
|
|
52524
|
-
code:
|
|
52534
|
+
code: 6075,
|
|
52525
52535
|
name: "InvalidBaseFeeRecipientAccount",
|
|
52526
52536
|
msg: "Invalid base fee recipient account"
|
|
52527
52537
|
},
|
|
52528
52538
|
{
|
|
52529
|
-
code:
|
|
52539
|
+
code: 6076,
|
|
52530
52540
|
name: "InvalidOrderbookAddress",
|
|
52531
52541
|
msg: "Orderbook address does not match curve account orderbook"
|
|
52532
52542
|
},
|
|
52533
52543
|
{
|
|
52534
|
-
code:
|
|
52544
|
+
code: 6077,
|
|
52535
52545
|
name: "InvalidFeePercentage",
|
|
52536
52546
|
msg: "Fee percentage must be between 0-100"
|
|
52537
52547
|
},
|
|
52538
52548
|
{
|
|
52539
|
-
code:
|
|
52549
|
+
code: 6078,
|
|
52540
52550
|
name: "InvalidFeeRate",
|
|
52541
52551
|
msg: "Fee rate exceeds maximum limit (10%)"
|
|
52542
52552
|
},
|
|
52543
52553
|
{
|
|
52544
|
-
code:
|
|
52554
|
+
code: 6079,
|
|
52545
52555
|
name: "InvalidCustomFeeRate",
|
|
52546
52556
|
msg: "Custom fee rate must be between 1000 (1%) and 5000 (5%)"
|
|
52547
52557
|
},
|
|
52548
52558
|
{
|
|
52549
|
-
code:
|
|
52559
|
+
code: 6080,
|
|
52550
52560
|
name: "InvalidBorrowDuration",
|
|
52551
52561
|
msg: "Borrow duration out of valid range (3-30 days)"
|
|
52552
52562
|
},
|
|
52553
52563
|
{
|
|
52554
|
-
code:
|
|
52564
|
+
code: 6081,
|
|
52555
52565
|
name: "InvalidStopLossPrice",
|
|
52556
52566
|
msg: "Stop loss price does not meet minimum interval requirement"
|
|
52557
52567
|
},
|
|
52558
52568
|
{
|
|
52559
|
-
code:
|
|
52569
|
+
code: 6082,
|
|
52560
52570
|
name: "NoProfitableFunds",
|
|
52561
52571
|
msg: "No profitable funds to transfer"
|
|
52562
52572
|
},
|
|
52563
52573
|
{
|
|
52564
|
-
code:
|
|
52574
|
+
code: 6083,
|
|
52565
52575
|
name: "InsufficientPoolFunds",
|
|
52566
52576
|
msg: "Insufficient pool funds"
|
|
52567
52577
|
},
|
|
52568
52578
|
{
|
|
52569
|
-
code:
|
|
52579
|
+
code: 6084,
|
|
52570
52580
|
name: "InsufficientPoolBalance",
|
|
52571
52581
|
msg: "Pool SOL account balance would fall below minimum required balance"
|
|
52572
52582
|
},
|
|
52573
52583
|
{
|
|
52574
|
-
code:
|
|
52584
|
+
code: 6085,
|
|
52575
52585
|
name: "OrderBookManagerOverflow",
|
|
52576
52586
|
msg: "Math operation overflow"
|
|
52577
52587
|
},
|
|
52578
52588
|
{
|
|
52579
|
-
code:
|
|
52589
|
+
code: 6086,
|
|
52580
52590
|
name: "OrderBookManagerInvalidSlotIndex",
|
|
52581
52591
|
msg: "Invalid slot index"
|
|
52582
52592
|
},
|
|
52583
52593
|
{
|
|
52584
|
-
code:
|
|
52594
|
+
code: 6087,
|
|
52585
52595
|
name: "OrderBookManagerInvalidAccountData",
|
|
52586
52596
|
msg: "Invalid account data"
|
|
52587
52597
|
},
|
|
52588
52598
|
{
|
|
52589
|
-
code:
|
|
52599
|
+
code: 6088,
|
|
52590
52600
|
name: "OrderBookManagerExceedsMaxCapacity",
|
|
52591
52601
|
msg: "New capacity exceeds maximum limit"
|
|
52592
52602
|
},
|
|
52593
52603
|
{
|
|
52594
|
-
code:
|
|
52604
|
+
code: 6089,
|
|
52595
52605
|
name: "OrderBookManagerExceedsAccountSizeLimit",
|
|
52596
52606
|
msg: "Account size exceeds 10MB limit"
|
|
52597
52607
|
},
|
|
52598
52608
|
{
|
|
52599
|
-
code:
|
|
52609
|
+
code: 6090,
|
|
52600
52610
|
name: "OrderBookManagerOrderIdMismatch",
|
|
52601
52611
|
msg: "Order ID mismatch"
|
|
52602
52612
|
},
|
|
52603
52613
|
{
|
|
52604
|
-
code:
|
|
52614
|
+
code: 6091,
|
|
52605
52615
|
name: "OrderBookManagerEmptyOrderBook",
|
|
52606
52616
|
msg: "Order book is empty"
|
|
52607
52617
|
},
|
|
52608
52618
|
{
|
|
52609
|
-
code:
|
|
52619
|
+
code: 6092,
|
|
52610
52620
|
name: "OrderBookManagerAccountNotWritable",
|
|
52611
52621
|
msg: "Account is not writable"
|
|
52612
52622
|
},
|
|
52613
52623
|
{
|
|
52614
|
-
code:
|
|
52624
|
+
code: 6093,
|
|
52615
52625
|
name: "OrderBookManagerNotRentExempt",
|
|
52616
52626
|
msg: "Account not rent-exempt"
|
|
52617
52627
|
},
|
|
52618
52628
|
{
|
|
52619
|
-
code:
|
|
52629
|
+
code: 6094,
|
|
52620
52630
|
name: "OrderBookManagerInvalidRentBalance",
|
|
52621
52631
|
msg: "Invalid rent balance"
|
|
52622
52632
|
},
|
|
52623
52633
|
{
|
|
52624
|
-
code:
|
|
52634
|
+
code: 6095,
|
|
52625
52635
|
name: "OrderBookManagerInsufficientFunds",
|
|
52626
52636
|
msg: "Insufficient funds"
|
|
52627
52637
|
},
|
|
52628
52638
|
{
|
|
52629
|
-
code:
|
|
52639
|
+
code: 6096,
|
|
52630
52640
|
name: "OrderBookManagerInvalidAccountOwner",
|
|
52631
52641
|
msg: "OrderBook account owner mismatch"
|
|
52632
52642
|
},
|
|
52633
52643
|
{
|
|
52634
|
-
code:
|
|
52644
|
+
code: 6097,
|
|
52635
52645
|
name: "OrderBookManagerDataOutOfBounds",
|
|
52636
52646
|
msg: "Data access out of bounds"
|
|
52637
52647
|
},
|
|
52638
52648
|
{
|
|
52639
|
-
code:
|
|
52649
|
+
code: 6098,
|
|
52640
52650
|
name: "NoValidInsertPosition",
|
|
52641
52651
|
msg: "Cannot find valid insert position, all candidates failed due to price range overlap"
|
|
52642
52652
|
},
|
|
52643
52653
|
{
|
|
52644
|
-
code:
|
|
52654
|
+
code: 6099,
|
|
52645
52655
|
name: "EmptyCloseInsertIndices",
|
|
52646
52656
|
msg: "close_insert_indices array cannot be empty"
|
|
52647
52657
|
},
|
|
52648
52658
|
{
|
|
52649
|
-
code:
|
|
52659
|
+
code: 6100,
|
|
52650
52660
|
name: "TooManyCloseInsertIndices",
|
|
52651
52661
|
msg: "close_insert_indices array cannot exceed 20 elements"
|
|
52652
52662
|
},
|
|
52653
52663
|
{
|
|
52654
|
-
code:
|
|
52664
|
+
code: 6101,
|
|
52655
52665
|
name: "CloseOrderNotFound",
|
|
52656
52666
|
msg: "Specified close order not found"
|
|
52657
52667
|
},
|
|
52658
52668
|
{
|
|
52659
|
-
code:
|
|
52669
|
+
code: 6102,
|
|
52660
52670
|
name: "LinkedListDeleteCountMismatch",
|
|
52661
52671
|
msg: "Linked list delete count mismatch: count inconsistent before/after deletion"
|
|
52662
52672
|
},
|
|
52663
52673
|
{
|
|
52664
|
-
code:
|
|
52674
|
+
code: 6103,
|
|
52665
52675
|
name: "NameTooLong",
|
|
52666
52676
|
msg: "Token name too long, max 32 bytes"
|
|
52667
52677
|
},
|
|
52668
52678
|
{
|
|
52669
|
-
code:
|
|
52679
|
+
code: 6104,
|
|
52670
52680
|
name: "NameEmpty",
|
|
52671
52681
|
msg: "Token name cannot be empty"
|
|
52672
52682
|
},
|
|
52673
52683
|
{
|
|
52674
|
-
code:
|
|
52684
|
+
code: 6105,
|
|
52675
52685
|
name: "SymbolTooLong",
|
|
52676
52686
|
msg: "Token symbol too long, max 10 bytes"
|
|
52677
52687
|
},
|
|
52678
52688
|
{
|
|
52679
|
-
code:
|
|
52689
|
+
code: 6106,
|
|
52680
52690
|
name: "SymbolEmpty",
|
|
52681
52691
|
msg: "Token symbol cannot be empty"
|
|
52682
52692
|
},
|
|
52683
52693
|
{
|
|
52684
|
-
code:
|
|
52694
|
+
code: 6107,
|
|
52685
52695
|
name: "UriTooLong",
|
|
52686
52696
|
msg: "URI too long, max 200 bytes"
|
|
52687
52697
|
},
|
|
52688
52698
|
{
|
|
52689
|
-
code:
|
|
52699
|
+
code: 6108,
|
|
52690
52700
|
name: "UriEmpty",
|
|
52691
52701
|
msg: "URI cannot be empty"
|
|
52692
52702
|
},
|
|
52693
52703
|
{
|
|
52694
|
-
code:
|
|
52704
|
+
code: 6109,
|
|
52695
52705
|
name: "IncompleteAdvancedPoolParams",
|
|
52696
52706
|
msg: "Incomplete advanced pool parameters: custom_lp_sol, custom_lp_token, custom_borrow_ratio, custom_borrow_duration must be provided together"
|
|
52697
52707
|
},
|
|
52698
52708
|
{
|
|
52699
|
-
code:
|
|
52709
|
+
code: 6110,
|
|
52700
52710
|
name: "InvalidInitialVirtualSol",
|
|
52701
52711
|
msg: "Initial virtual SOL out of valid range"
|
|
52702
52712
|
},
|
|
52703
52713
|
{
|
|
52704
|
-
code:
|
|
52714
|
+
code: 6111,
|
|
52705
52715
|
name: "InvalidInitialVirtualToken",
|
|
52706
52716
|
msg: "Initial virtual Token out of valid range"
|
|
52707
52717
|
},
|
|
52708
52718
|
{
|
|
52709
|
-
code:
|
|
52719
|
+
code: 6112,
|
|
52710
52720
|
name: "InvalidBorrowPoolRatio",
|
|
52711
52721
|
msg: "Borrow pool ratio out of valid range"
|
|
52712
52722
|
},
|
|
52713
52723
|
{
|
|
52714
|
-
code:
|
|
52724
|
+
code: 6113,
|
|
52715
52725
|
name: "BorrowTokenCalculationOverflow",
|
|
52716
52726
|
msg: "Borrow pool token amount calculation overflow"
|
|
52717
52727
|
},
|
|
52718
52728
|
{
|
|
52719
|
-
code:
|
|
52729
|
+
code: 6114,
|
|
52720
52730
|
name: "BorrowTokenAmountZero",
|
|
52721
52731
|
msg: "Borrow pool token amount cannot be zero"
|
|
52722
52732
|
}
|
|
@@ -53629,7 +53639,7 @@ const DEFAULT_NETWORKS = {
|
|
|
53629
53639
|
MAINNET: {
|
|
53630
53640
|
name: 'mainnet-beta',
|
|
53631
53641
|
defaultDataSource: 'fast',
|
|
53632
|
-
solanaEndpoint: 'https://
|
|
53642
|
+
solanaEndpoint: 'https://melissa-ali6qz-fast-mainnet.helius-rpc.com',
|
|
53633
53643
|
pinPetFastApiUrl: 'https://api.pinpet.fun/',
|
|
53634
53644
|
feeRecipient: 'CmDe8JRAPJ7QpZNCb4ArVEyzyxYoCNL7WZw5qXLePULn',
|
|
53635
53645
|
baseFeeRecipient: '2xhAfEfnH8wg7ZGujSijJi4Zt4ge1ZuwMypo7etntgXA',
|