100x-sdk 1.0.4 → 1.0.6

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/index.d.ts CHANGED
@@ -187,6 +187,26 @@ export interface SimulationResult {
187
187
  suggestedSolAmount: string;
188
188
  }
189
189
 
190
+ /** The leverage implied by the executable stop-loss price, not a maximum limit. */
191
+ export interface StopLossSimulationResult {
192
+ executableStopLossPrice: bigint;
193
+ tradeAmount: bigint;
194
+ stopLossPercentage: number;
195
+ /** Existing four-decimal, downward-truncated value. */
196
+ leverage: number;
197
+ /** Rounded to two decimals from the original price ratio, with trailing zeros removed. Display only. */
198
+ leverageDisplay: string;
199
+ currentPrice: bigint;
200
+ iterations: number;
201
+ originalStopLossPrice: bigint;
202
+ close_insert_indices: number[];
203
+ estimatedMargin: bigint;
204
+ rawSellSol?: bigint;
205
+ buyTokenAmount?: bigint;
206
+ sellTokenAmount?: bigint;
207
+ adjustmentIterations?: number;
208
+ }
209
+
190
210
  // ========================= Utility Related Types =========================
191
211
 
192
212
  export interface FindPrevNextResult {
@@ -238,8 +258,10 @@ export interface ParamModule {
238
258
  export interface SimulatorModule {
239
259
  simulateTokenBuy(mint: string, buyTokenAmount: bigint | string | number, passOrder?: string | null): Promise<SimulationResult>;
240
260
  simulateTokenSell(mint: string, sellTokenAmount: bigint | string | number, passOrder?: string | null): Promise<SimulationResult>;
241
- simulateLongStopLoss(mint: string, buyTokenAmount: bigint | string | number, stopLossPrice: bigint | string | number, lastPrice?: any, ordersData?: any): Promise<any>;
242
- simulateSellStopLoss(mint: string, sellTokenAmount: bigint | string | number, stopLossPrice: bigint | string | number, lastPrice?: any, ordersData?: any): Promise<any>;
261
+ simulateLongStopLoss(mint: string, buyTokenAmount: bigint | string | number, stopLossPrice: bigint | string | number, lastPrice?: any, ordersData?: any, borrowFee?: number | null): Promise<StopLossSimulationResult>;
262
+ simulateShortStopLoss(mint: string, sellTokenAmount: bigint | string | number, stopLossPrice: bigint | string | number, lastPrice?: any, ordersData?: any, borrowFee?: number | null): Promise<StopLossSimulationResult>;
263
+ simulateLongSolStopLoss(mint: string, buySolAmount: bigint | string | number, stopLossPrice: bigint | string | number, lastPrice?: any, ordersData?: any, borrowFee?: number | null, initialVirtualSol?: string | number | null, initialVirtualToken?: string | number | null, curveAccount?: any): Promise<StopLossSimulationResult>;
264
+ simulateShortSolStopLoss(mint: string, sellSolAmount: bigint | string | number, stopLossPrice: bigint | string | number, lastPrice?: any, ordersData?: any, borrowFee?: number | null, initialVirtualSol?: string | number | null, initialVirtualToken?: string | number | null, curveAccount?: any): Promise<StopLossSimulationResult>;
243
265
  }
244
266
 
245
267
  // ========================= Data Interface Types =========================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "100x-sdk",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Solana 100x.fun SDK",
5
5
  "main": "dist/100x-sdk.cjs.js",
6
6
  "module": "dist/100x-sdk.esm.js",
@@ -21,7 +21,7 @@
21
21
  "build": "rollup -c",
22
22
  "build:dev": "rollup -c -w",
23
23
  "build:types": "cp src/types/index.d.ts dist/index.d.ts",
24
- "test": "mocha tests/unit/**/*.test.js",
24
+ "test": "mocha \"{test,tests/unit}/**/*.test.js\"",
25
25
  "test:integration": "mocha tests/integration/**/*.test.js",
26
26
  "lint": "eslint src"
27
27
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "address": "sGecRTjTZmnqJBmLK4ZMNCzsaMrgkFfNqEcYk1GhRde",
2
+ "address": "EVNaaiyg9z876PUmLCVQcdc5L5eJukT4pni5GtVJ8P37",
3
3
  "metadata": {
4
4
  "name": "fun100x",
5
5
  "version": "0.1.0",
@@ -3013,271 +3013,281 @@
3013
3013
  },
3014
3014
  {
3015
3015
  "code": 6062,
3016
+ "name": "InsufficientLongPayerBalance",
3017
+ "msg": "Payer wallet balance insufficient for long margin and fees"
3018
+ },
3019
+ {
3020
+ "code": 6063,
3021
+ "name": "InsufficientShortPayerBalance",
3022
+ "msg": "Payer wallet balance insufficient for short margin and fees"
3023
+ },
3024
+ {
3025
+ "code": 6064,
3016
3026
  "name": "InvalidAccountOwner",
3017
3027
  "msg": "Invalid account owner"
3018
3028
  },
3019
3029
  {
3020
- "code": 6063,
3030
+ "code": 6065,
3021
3031
  "name": "SellAmountExceedsOrderAmount",
3022
3032
  "msg": "Sell amount exceeds order's token holdings"
3023
3033
  },
3024
3034
  {
3025
- "code": 6064,
3035
+ "code": 6066,
3026
3036
  "name": "OrderNotExpiredMustCloseByOwner",
3027
3037
  "msg": "Non-expired order must be closed by owner"
3028
3038
  },
3029
3039
  {
3030
- "code": 6065,
3040
+ "code": 6067,
3031
3041
  "name": "SettlementAddressMustBeOwnerAddress",
3032
3042
  "msg": "Settlement address must be owner address"
3033
3043
  },
3034
3044
  {
3035
- "code": 6066,
3045
+ "code": 6068,
3036
3046
  "name": "BuyAmountExceedsOrderAmount",
3037
3047
  "msg": "Buy amount exceeds order's token holdings"
3038
3048
  },
3039
3049
  {
3040
- "code": 6067,
3050
+ "code": 6069,
3041
3051
  "name": "InsufficientTradeAmount",
3042
3052
  "msg": "Trade amount below minimum requirement"
3043
3053
  },
3044
3054
  {
3045
- "code": 6068,
3055
+ "code": 6070,
3046
3056
  "name": "SolAmountTooLarge",
3047
3057
  "msg": "SOL amount exceeds maximum limit (10000000 SOL per transaction)"
3048
3058
  },
3049
3059
  {
3050
- "code": 6069,
3060
+ "code": 6071,
3051
3061
  "name": "RemainingTokenAmountTooSmall",
3052
3062
  "msg": "Remaining token amount below minimum trade requirement"
3053
3063
  },
3054
3064
  {
3055
- "code": 6070,
3065
+ "code": 6072,
3056
3066
  "name": "TradeCooldownNotExpired",
3057
3067
  "msg": "Trade cooldown period not expired, please try again later"
3058
3068
  },
3059
3069
  {
3060
- "code": 6071,
3070
+ "code": 6073,
3061
3071
  "name": "ExceedApprovalAmount",
3062
3072
  "msg": "Sell amount exceeds approved amount, please call approval function first"
3063
3073
  },
3064
3074
  {
3065
- "code": 6072,
3075
+ "code": 6074,
3066
3076
  "name": "CooldownNotInitialized",
3067
3077
  "msg": "Sell trade requires calling approval or buy function first to initialize cooldown PDA"
3068
3078
  },
3069
3079
  {
3070
- "code": 6073,
3080
+ "code": 6075,
3071
3081
  "name": "CannotCloseCooldownWithBalance",
3072
3082
  "msg": "Cannot close cooldown PDA with non-zero token balance"
3073
3083
  },
3074
3084
  {
3075
- "code": 6074,
3085
+ "code": 6076,
3076
3086
  "name": "PriceCalculationError",
3077
3087
  "msg": "Price calculation error"
3078
3088
  },
3079
3089
  {
3080
- "code": 6075,
3090
+ "code": 6077,
3081
3091
  "name": "InvalidPartnerFeeRecipientAccount",
3082
3092
  "msg": "Invalid partner fee recipient account"
3083
3093
  },
3084
3094
  {
3085
- "code": 6076,
3095
+ "code": 6078,
3086
3096
  "name": "InvalidBaseFeeRecipientAccount",
3087
3097
  "msg": "Invalid base fee recipient account"
3088
3098
  },
3089
3099
  {
3090
- "code": 6077,
3100
+ "code": 6079,
3091
3101
  "name": "InvalidOrderbookAddress",
3092
3102
  "msg": "Orderbook address does not match curve account orderbook"
3093
3103
  },
3094
3104
  {
3095
- "code": 6078,
3105
+ "code": 6080,
3096
3106
  "name": "InvalidFeePercentage",
3097
3107
  "msg": "Fee percentage must be between 0-100"
3098
3108
  },
3099
3109
  {
3100
- "code": 6079,
3110
+ "code": 6081,
3101
3111
  "name": "InvalidFeeRate",
3102
3112
  "msg": "Fee rate exceeds maximum limit (10%)"
3103
3113
  },
3104
3114
  {
3105
- "code": 6080,
3115
+ "code": 6082,
3106
3116
  "name": "InvalidCustomFeeRate",
3107
3117
  "msg": "Custom fee rate must be between 1000 (1%) and 5000 (5%)"
3108
3118
  },
3109
3119
  {
3110
- "code": 6081,
3120
+ "code": 6083,
3111
3121
  "name": "InvalidBorrowDuration",
3112
3122
  "msg": "Borrow duration out of valid range (3-30 days)"
3113
3123
  },
3114
3124
  {
3115
- "code": 6082,
3125
+ "code": 6084,
3116
3126
  "name": "InvalidStopLossPrice",
3117
3127
  "msg": "Stop loss price does not meet minimum interval requirement"
3118
3128
  },
3119
3129
  {
3120
- "code": 6083,
3130
+ "code": 6085,
3121
3131
  "name": "NoProfitableFunds",
3122
3132
  "msg": "No profitable funds to transfer"
3123
3133
  },
3124
3134
  {
3125
- "code": 6084,
3135
+ "code": 6086,
3126
3136
  "name": "InsufficientPoolFunds",
3127
3137
  "msg": "Insufficient pool funds"
3128
3138
  },
3129
3139
  {
3130
- "code": 6085,
3140
+ "code": 6087,
3131
3141
  "name": "InsufficientPoolBalance",
3132
3142
  "msg": "Pool SOL account balance would fall below minimum required balance"
3133
3143
  },
3134
3144
  {
3135
- "code": 6086,
3145
+ "code": 6088,
3136
3146
  "name": "OrderBookManagerOverflow",
3137
3147
  "msg": "Math operation overflow"
3138
3148
  },
3139
3149
  {
3140
- "code": 6087,
3150
+ "code": 6089,
3141
3151
  "name": "OrderBookManagerInvalidSlotIndex",
3142
3152
  "msg": "Invalid slot index"
3143
3153
  },
3144
3154
  {
3145
- "code": 6088,
3155
+ "code": 6090,
3146
3156
  "name": "OrderBookManagerInvalidAccountData",
3147
3157
  "msg": "Invalid account data"
3148
3158
  },
3149
3159
  {
3150
- "code": 6089,
3160
+ "code": 6091,
3151
3161
  "name": "OrderBookManagerExceedsMaxCapacity",
3152
3162
  "msg": "New capacity exceeds maximum limit"
3153
3163
  },
3154
3164
  {
3155
- "code": 6090,
3165
+ "code": 6092,
3156
3166
  "name": "OrderBookManagerExceedsAccountSizeLimit",
3157
3167
  "msg": "Account size exceeds 10MB limit"
3158
3168
  },
3159
3169
  {
3160
- "code": 6091,
3170
+ "code": 6093,
3161
3171
  "name": "OrderBookManagerOrderIdMismatch",
3162
3172
  "msg": "Order ID mismatch"
3163
3173
  },
3164
3174
  {
3165
- "code": 6092,
3175
+ "code": 6094,
3166
3176
  "name": "OrderBookManagerEmptyOrderBook",
3167
3177
  "msg": "Order book is empty"
3168
3178
  },
3169
3179
  {
3170
- "code": 6093,
3180
+ "code": 6095,
3171
3181
  "name": "OrderBookManagerAccountNotWritable",
3172
3182
  "msg": "Account is not writable"
3173
3183
  },
3174
3184
  {
3175
- "code": 6094,
3185
+ "code": 6096,
3176
3186
  "name": "OrderBookManagerNotRentExempt",
3177
3187
  "msg": "Account not rent-exempt"
3178
3188
  },
3179
3189
  {
3180
- "code": 6095,
3190
+ "code": 6097,
3181
3191
  "name": "OrderBookManagerInvalidRentBalance",
3182
3192
  "msg": "Invalid rent balance"
3183
3193
  },
3184
3194
  {
3185
- "code": 6096,
3195
+ "code": 6098,
3186
3196
  "name": "OrderBookManagerInsufficientFunds",
3187
3197
  "msg": "Insufficient funds"
3188
3198
  },
3189
3199
  {
3190
- "code": 6097,
3200
+ "code": 6099,
3191
3201
  "name": "OrderBookManagerInvalidAccountOwner",
3192
3202
  "msg": "OrderBook account owner mismatch"
3193
3203
  },
3194
3204
  {
3195
- "code": 6098,
3205
+ "code": 6100,
3196
3206
  "name": "OrderBookManagerDataOutOfBounds",
3197
3207
  "msg": "Data access out of bounds"
3198
3208
  },
3199
3209
  {
3200
- "code": 6099,
3210
+ "code": 6101,
3201
3211
  "name": "NoValidInsertPosition",
3202
3212
  "msg": "Cannot find valid insert position, all candidates failed due to price range overlap"
3203
3213
  },
3204
3214
  {
3205
- "code": 6100,
3215
+ "code": 6102,
3206
3216
  "name": "EmptyCloseInsertIndices",
3207
3217
  "msg": "close_insert_indices array cannot be empty"
3208
3218
  },
3209
3219
  {
3210
- "code": 6101,
3220
+ "code": 6103,
3211
3221
  "name": "TooManyCloseInsertIndices",
3212
3222
  "msg": "close_insert_indices array cannot exceed 20 elements"
3213
3223
  },
3214
3224
  {
3215
- "code": 6102,
3225
+ "code": 6104,
3216
3226
  "name": "CloseOrderNotFound",
3217
3227
  "msg": "Specified close order not found"
3218
3228
  },
3219
3229
  {
3220
- "code": 6103,
3230
+ "code": 6105,
3221
3231
  "name": "LinkedListDeleteCountMismatch",
3222
3232
  "msg": "Linked list delete count mismatch: count inconsistent before/after deletion"
3223
3233
  },
3224
3234
  {
3225
- "code": 6104,
3235
+ "code": 6106,
3226
3236
  "name": "NameTooLong",
3227
3237
  "msg": "Token name too long, max 32 bytes"
3228
3238
  },
3229
3239
  {
3230
- "code": 6105,
3240
+ "code": 6107,
3231
3241
  "name": "NameEmpty",
3232
3242
  "msg": "Token name cannot be empty"
3233
3243
  },
3234
3244
  {
3235
- "code": 6106,
3245
+ "code": 6108,
3236
3246
  "name": "SymbolTooLong",
3237
3247
  "msg": "Token symbol too long, max 10 bytes"
3238
3248
  },
3239
3249
  {
3240
- "code": 6107,
3250
+ "code": 6109,
3241
3251
  "name": "SymbolEmpty",
3242
3252
  "msg": "Token symbol cannot be empty"
3243
3253
  },
3244
3254
  {
3245
- "code": 6108,
3255
+ "code": 6110,
3246
3256
  "name": "UriTooLong",
3247
3257
  "msg": "URI too long, max 200 bytes"
3248
3258
  },
3249
3259
  {
3250
- "code": 6109,
3260
+ "code": 6111,
3251
3261
  "name": "UriEmpty",
3252
3262
  "msg": "URI cannot be empty"
3253
3263
  },
3254
3264
  {
3255
- "code": 6110,
3265
+ "code": 6112,
3256
3266
  "name": "IncompleteAdvancedPoolParams",
3257
3267
  "msg": "Incomplete advanced pool parameters: custom_lp_sol, custom_lp_token, custom_borrow_ratio, custom_borrow_duration must be provided together"
3258
3268
  },
3259
3269
  {
3260
- "code": 6111,
3270
+ "code": 6113,
3261
3271
  "name": "InvalidInitialVirtualSol",
3262
3272
  "msg": "Initial virtual SOL out of valid range"
3263
3273
  },
3264
3274
  {
3265
- "code": 6112,
3275
+ "code": 6114,
3266
3276
  "name": "InvalidInitialVirtualToken",
3267
3277
  "msg": "Initial virtual Token out of valid range"
3268
3278
  },
3269
3279
  {
3270
- "code": 6113,
3280
+ "code": 6115,
3271
3281
  "name": "InvalidBorrowPoolRatio",
3272
3282
  "msg": "Borrow pool ratio out of valid range"
3273
3283
  },
3274
3284
  {
3275
- "code": 6114,
3285
+ "code": 6116,
3276
3286
  "name": "BorrowTokenCalculationOverflow",
3277
3287
  "msg": "Borrow pool token amount calculation overflow"
3278
3288
  },
3279
3289
  {
3280
- "code": 6115,
3290
+ "code": 6117,
3281
3291
  "name": "BorrowTokenAmountZero",
3282
3292
  "msg": "Borrow pool token amount cannot be zero"
3283
3293
  }
@@ -3424,8 +3434,10 @@
3424
3434
  "name": "pool_type",
3425
3435
  "docs": [
3426
3436
  "Pool type",
3427
- "0 = Basic version (uses default parameters, supports fee halving)",
3428
- "1 = Advanced version (custom parameters, fees never halved)"
3437
+ "0 = Basic version (uses default parameters)",
3438
+ "1 = Advanced version (custom parameters)",
3439
+ "Note: BOTH pool types participate in fee halving milestones",
3440
+ "(dynamic thresholds at 100x/1000x/10000x of the pool's own initial price)"
3429
3441
  ],
3430
3442
  "type": "u8"
3431
3443
  },
@@ -3433,8 +3445,8 @@
3433
3445
  "name": "borrow_pool_ratio",
3434
3446
  "docs": [
3435
3447
  "Borrow pool token ratio (recorded only for information display)",
3436
- "Actual value range: 5-30 (represents 5%-30%)",
3437
- "Basic version fixed at 20"
3448
+ "Actual value range: 2-8 (represents 2%-8%, deducted from total supply)",
3449
+ "Basic version fixed at 4"
3438
3450
  ],
3439
3451
  "type": "u8"
3440
3452
  }