@bulletxyz/bullet-sdk 0.45.1 → 0.45.2-rc.2

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.
@@ -1732,7 +1732,7 @@ class ReadOnlyClient {
1732
1732
  this.wsManager = new WebSocketManager(endpoints.ws);
1733
1733
  }
1734
1734
  static async fromEndpoints(endpoints) {
1735
- validateEndpoints(endpoints), console.debug("Endpoints:", endpoints);
1735
+ validateEndpoints(endpoints), console.debug(`Connecting to ${endpoints.rest}`);
1736
1736
  let rollupConfig = {
1737
1737
  url: endpoints.rest,
1738
1738
  getSerializer: (schema) => new WasmSerializer(schema)
@@ -2943,25 +2943,28 @@ class AuthenticatedClient extends ReadOnlyClient {
2943
2943
  }
2944
2944
  });
2945
2945
  }
2946
- async updateBorrowLendPool(asset, optimalUtilisationRate, minBorrowRate, maxBorrowRate, optimalBorrowRate, assetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, depositLimit, borrowLimit, liquidationRewardRatio, liabilityLiquidationLimitRatio) {
2947
- let assetId = this.getAssetId(asset);
2946
+ async updateBorrowLendPool(asset, options) {
2947
+ let assetId = this.getAssetId(asset), toJson = (d) => d ? BulletWasm.convert_rust_decimal_to_json(d.toFixed()) : null;
2948
2948
  return await this.submitTransaction({
2949
2949
  exchange: {
2950
2950
  admin: {
2951
2951
  update_borrow_lend_pool: {
2952
2952
  args: {
2953
2953
  asset_id: assetId,
2954
- optimal_utilization_rate: optimalUtilisationRate ? BulletWasm.convert_rust_decimal_to_json(optimalUtilisationRate.toFixed()) : null,
2955
- min_borrow_rate: minBorrowRate ? BulletWasm.convert_rust_decimal_to_json(minBorrowRate.toFixed()) : null,
2956
- max_borrow_rate: maxBorrowRate ? BulletWasm.convert_rust_decimal_to_json(maxBorrowRate.toFixed()) : null,
2957
- optimal_borrow_rate: optimalBorrowRate ? BulletWasm.convert_rust_decimal_to_json(optimalBorrowRate.toFixed()) : null,
2958
- asset_weight: assetWeight ? BulletWasm.convert_rust_decimal_to_json(assetWeight.toFixed()) : null,
2959
- initial_liability_weight: initialLiabilityWeight ? BulletWasm.convert_rust_decimal_to_json(initialLiabilityWeight.toFixed()) : null,
2960
- maintenance_liability_weight: maintenanceLiabilityWeight ? BulletWasm.convert_rust_decimal_to_json(maintenanceLiabilityWeight.toFixed()) : null,
2961
- deposit_limit: depositLimit ? BulletWasm.convert_rust_decimal_to_json(depositLimit.toFixed()) : null,
2962
- borrow_limit: borrowLimit ? BulletWasm.convert_rust_decimal_to_json(borrowLimit.toFixed()) : null,
2963
- liquidation_reward_ratio: liquidationRewardRatio ? BulletWasm.convert_rust_decimal_to_json(liquidationRewardRatio.toFixed()) : null,
2964
- liability_liquidation_limit_ratio: liabilityLiquidationLimitRatio ? BulletWasm.convert_rust_decimal_to_json(liabilityLiquidationLimitRatio.toFixed()) : null
2954
+ optimal_utilization_rate: toJson(options.optimalUtilizationRate),
2955
+ min_borrow_rate: toJson(options.minBorrowRate),
2956
+ max_borrow_rate: toJson(options.maxBorrowRate),
2957
+ optimal_borrow_rate: toJson(options.optimalBorrowRate),
2958
+ asset_weight: toJson(options.assetWeight),
2959
+ initial_liability_weight: toJson(options.initialLiabilityWeight),
2960
+ maintenance_liability_weight: toJson(options.maintenanceLiabilityWeight),
2961
+ deposit_limit: toJson(options.depositLimit),
2962
+ borrow_limit: toJson(options.borrowLimit),
2963
+ max_utilization_rate: toJson(options.maxUtilizationRate),
2964
+ liquidation_total_reward_ratio: toJson(options.liquidationTotalRewardRatio),
2965
+ protocol_reward_ratio: toJson(options.protocolRewardRatio),
2966
+ liability_liquidation_limit_ratio: toJson(options.liabilityLiquidationLimitRatio),
2967
+ interest_fee_tenth_bps: options.interestFeeTenthBps ?? null
2965
2968
  }
2966
2969
  }
2967
2970
  }
@@ -3143,16 +3146,337 @@ class AuthenticatedClient extends ReadOnlyClient {
3143
3146
  }
3144
3147
  });
3145
3148
  }
3149
+ async settleFromPnlPool(subAccountIndex) {
3150
+ return await this.submitTransaction({
3151
+ exchange: {
3152
+ user: {
3153
+ settle_from_pnl_pool: {
3154
+ sub_account_index: subAccountIndex ?? null
3155
+ }
3156
+ }
3157
+ }
3158
+ });
3159
+ }
3160
+ async depositToTreasury(asset, amount) {
3161
+ let assetId = this.getAssetId(asset);
3162
+ return await this.submitTransaction({
3163
+ exchange: {
3164
+ user: {
3165
+ deposit_to_treasury: {
3166
+ asset_id: assetId,
3167
+ amount: BulletWasm.convert_rust_decimal_to_json(amount.toFixed())
3168
+ }
3169
+ }
3170
+ }
3171
+ });
3172
+ }
3173
+ async claimBorrowLendFees() {
3174
+ return await this.submitTransaction({
3175
+ exchange: {
3176
+ user: {
3177
+ claim_borrow_lend_fees: {}
3178
+ }
3179
+ }
3180
+ });
3181
+ }
3182
+ async queueWithdrawal(vaultAddress, shares) {
3183
+ return await this.submitTransaction({
3184
+ exchange: {
3185
+ user: {
3186
+ queue_withdrawal: {
3187
+ vault_address: vaultAddress,
3188
+ shares: BulletWasm.convert_rust_decimal_to_json(shares.toFixed())
3189
+ }
3190
+ }
3191
+ }
3192
+ });
3193
+ }
3194
+ async cancelQueuedWithdrawal(vaultAddress) {
3195
+ return await this.submitTransaction({
3196
+ exchange: {
3197
+ user: {
3198
+ cancel_queued_withdrawal: {
3199
+ vault_address: vaultAddress
3200
+ }
3201
+ }
3202
+ }
3203
+ });
3204
+ }
3205
+ async forceWithdrawVault(vaultAddress, shares) {
3206
+ return await this.submitTransaction({
3207
+ exchange: {
3208
+ user: {
3209
+ force_withdraw_vault: {
3210
+ vault_address: vaultAddress,
3211
+ shares: BulletWasm.convert_rust_decimal_to_json(shares.toFixed())
3212
+ }
3213
+ }
3214
+ }
3215
+ });
3216
+ }
3217
+ async updateVaultConfig(vaultAddress, options) {
3218
+ return await this.submitTransaction({
3219
+ exchange: {
3220
+ vault: {
3221
+ update_vault_config: {
3222
+ vault_address: vaultAddress,
3223
+ args: {
3224
+ deposit_limit: options.depositLimit ? BulletWasm.convert_rust_decimal_to_json(options.depositLimit.toFixed()) : null,
3225
+ withdraw_lockup_period_hours: options.withdrawLockupPeriodHours ?? null,
3226
+ profit_share_percentage: options.profitSharePercentage ?? null
3227
+ }
3228
+ }
3229
+ }
3230
+ }
3231
+ });
3232
+ }
3233
+ async processWithdrawalQueue(vaultAddress) {
3234
+ return await this.submitTransaction({
3235
+ exchange: {
3236
+ vault: {
3237
+ process_withdrawal_queue: {
3238
+ vault_address: vaultAddress
3239
+ }
3240
+ }
3241
+ }
3242
+ });
3243
+ }
3244
+ async whitelistDepositor(vaultAddress, userAddress) {
3245
+ return await this.submitTransaction({
3246
+ exchange: {
3247
+ vault: {
3248
+ whitelist_depositor: {
3249
+ vault_address: vaultAddress,
3250
+ user_address: userAddress
3251
+ }
3252
+ }
3253
+ }
3254
+ });
3255
+ }
3256
+ async unwhitelistDepositor(vaultAddress, userAddress) {
3257
+ return await this.submitTransaction({
3258
+ exchange: {
3259
+ vault: {
3260
+ unwhitelist_depositor: {
3261
+ vault_address: vaultAddress,
3262
+ user_address: userAddress
3263
+ }
3264
+ }
3265
+ }
3266
+ });
3267
+ }
3268
+ async adminDeleteMarket(marketId) {
3269
+ return await this.submitTransaction({
3270
+ exchange: {
3271
+ admin: {
3272
+ delete_market: {
3273
+ market_id: marketId
3274
+ }
3275
+ }
3276
+ }
3277
+ });
3278
+ }
3279
+ async adminCleanupUserMarketState(marketId, users) {
3280
+ return await this.submitTransaction({
3281
+ exchange: {
3282
+ admin: {
3283
+ cleanup_user_market_state: {
3284
+ market_id: marketId,
3285
+ users
3286
+ }
3287
+ }
3288
+ }
3289
+ });
3290
+ }
3291
+ async adminUpdatePerpLiquidationConfig(options) {
3292
+ return await this.submitTransaction({
3293
+ exchange: {
3294
+ admin: {
3295
+ update_perp_liquidation_config: {
3296
+ args: {
3297
+ liquidation_fee: options.liquidationFee ?? null,
3298
+ liquidation_ioc_buffer: options.liquidationIocBuffer ?? null,
3299
+ backstop_liquidation_threshold: options.backstopLiquidationThreshold ?? null,
3300
+ liquidation_protocol_reward_ratio: options.liquidationProtocolRewardRatio ?? null
3301
+ }
3302
+ }
3303
+ }
3304
+ }
3305
+ });
3306
+ }
3307
+ async adminUpdateGlobalVaultConfig(options) {
3308
+ return await this.submitTransaction({
3309
+ exchange: {
3310
+ admin: {
3311
+ update_global_vault_config: {
3312
+ args: {
3313
+ leader_minimum_holding_percentage: options.leaderMinimumHoldingPercentage ?? null,
3314
+ creation_fee_usdc: options.creationFeeUsdc ?? null,
3315
+ min_deposit_value: options.minDepositValue ?? null
3316
+ }
3317
+ }
3318
+ }
3319
+ }
3320
+ });
3321
+ }
3322
+ async adminWithdrawFromTreasury(assetId, amount, to) {
3323
+ return await this.submitTransaction({
3324
+ exchange: {
3325
+ admin: {
3326
+ withdraw_from_treasury: {
3327
+ asset_id: assetId,
3328
+ amount,
3329
+ to
3330
+ }
3331
+ }
3332
+ }
3333
+ });
3334
+ }
3335
+ async adminAutoDeleverage(options) {
3336
+ return await this.submitTransaction({
3337
+ exchange: {
3338
+ admin: {
3339
+ auto_deleverage: {
3340
+ counterparty_a: options.counterpartyA,
3341
+ counterparty_a_sub_account_index: options.counterpartyASubAccountIndex ?? null,
3342
+ counterparty_b: options.counterpartyB,
3343
+ counterparty_b_sub_account_index: options.counterpartyBSubAccountIndex ?? null,
3344
+ market_id: options.marketId,
3345
+ size: options.size ?? null,
3346
+ settlement_price: options.settlementPrice
3347
+ }
3348
+ }
3349
+ }
3350
+ });
3351
+ }
3352
+ async adminDeposit(userAddress, assetId, amount) {
3353
+ return await this.submitTransaction({
3354
+ exchange: {
3355
+ admin: {
3356
+ deposit: {
3357
+ user_address: userAddress,
3358
+ asset_id: assetId,
3359
+ amount
3360
+ }
3361
+ }
3362
+ }
3363
+ });
3364
+ }
3365
+ async warpRegister(options) {
3366
+ return await this.submitTransaction({
3367
+ warp: {
3368
+ register: {
3369
+ admin: {
3370
+ InsecureOwner: options.admin
3371
+ },
3372
+ token_source: {
3373
+ Synthetic: {
3374
+ remote_token_id: options.remoteTokenId,
3375
+ local_decimals: options.localDecimals,
3376
+ remote_decimals: options.remoteDecimals
3377
+ }
3378
+ },
3379
+ ism: {
3380
+ MessageIdMultisig: {
3381
+ threshold: options.ismThreshold,
3382
+ validators: options.ismValidators
3383
+ }
3384
+ },
3385
+ remote_routers: options.remoteRouters,
3386
+ inbound_transferrable_tokens_limit: options.inboundTransferrableTokensLimit,
3387
+ inbound_limit_replenishment_per_slot: options.inboundLimitReplenishmentPerSlot,
3388
+ outbound_transferrable_tokens_limit: options.outboundTransferrableTokensLimit,
3389
+ outbound_limit_replenishment_per_slot: options.outboundLimitReplenishmentPerSlot
3390
+ }
3391
+ }
3392
+ });
3393
+ }
3394
+ async warpUpdate(options) {
3395
+ return await this.submitTransaction({
3396
+ warp: {
3397
+ update: {
3398
+ warp_route: options.warpRoute,
3399
+ admin: options.admin ? { InsecureOwner: options.admin } : null,
3400
+ ism: options.ismThreshold != null && options.ismValidators != null ? {
3401
+ MessageIdMultisig: {
3402
+ threshold: options.ismThreshold,
3403
+ validators: options.ismValidators
3404
+ }
3405
+ } : null,
3406
+ inbound_transferrable_tokens_limit: options.inboundTransferrableTokensLimit ?? null,
3407
+ inbound_limit_replenishment_per_slot: options.inboundLimitReplenishmentPerSlot ?? null,
3408
+ outbound_transferrable_tokens_limit: options.outboundTransferrableTokensLimit ?? null,
3409
+ outbound_limit_replenishment_per_slot: options.outboundLimitReplenishmentPerSlot ?? null
3410
+ }
3411
+ }
3412
+ });
3413
+ }
3414
+ async warpEnrollRemoteRouter(warpRoute, remoteDomain, remoteRouterAddress) {
3415
+ return await this.submitTransaction({
3416
+ warp: {
3417
+ enroll_remote_router: {
3418
+ warp_route: warpRoute,
3419
+ remote_domain: remoteDomain,
3420
+ remote_router_address: remoteRouterAddress
3421
+ }
3422
+ }
3423
+ });
3424
+ }
3425
+ async warpUnenrollRemoteRouter(warpRoute, remoteDomain) {
3426
+ return await this.submitTransaction({
3427
+ warp: {
3428
+ un_enroll_remote_router: {
3429
+ warp_route: warpRoute,
3430
+ remote_domain: remoteDomain
3431
+ }
3432
+ }
3433
+ });
3434
+ }
3435
+ async warpTransferRemote(options) {
3436
+ return await this.submitTransaction({
3437
+ warp: {
3438
+ transfer_remote: {
3439
+ warp_route: options.warpRoute,
3440
+ amount: options.amount,
3441
+ destination_domain: options.destinationDomain,
3442
+ gas_payment_limit: options.gasPaymentLimit,
3443
+ recipient: options.recipient,
3444
+ relayer: options.relayer ?? null
3445
+ }
3446
+ }
3447
+ });
3448
+ }
3449
+ async setRelayerConfig(options) {
3450
+ return await this.submitTransaction({
3451
+ interchain_gas_paymaster: {
3452
+ set_relayer_config: {
3453
+ domain_oracle_data: options.domainOracleData.map((d) => ({
3454
+ domain: d.domain,
3455
+ data_value: {
3456
+ gas_price: d.dataValue.gasPrice,
3457
+ token_exchange_rate: d.dataValue.tokenExchangeRate
3458
+ }
3459
+ })),
3460
+ domain_default_gas: options.domainDefaultGas.map((d) => ({
3461
+ domain: d.domain,
3462
+ default_gas: d.defaultGas
3463
+ })),
3464
+ default_gas: options.defaultGas,
3465
+ beneficiary: options.beneficiary ?? null
3466
+ }
3467
+ }
3468
+ });
3469
+ }
3146
3470
  }
3147
3471
  async function createAuthenticatedClient(endpoints, wallet, delegatorAddress, txOpts) {
3148
- validateEndpoints(endpoints), console.debug("Endpoints:", endpoints);
3472
+ validateEndpoints(endpoints), console.debug(`Connecting to ${endpoints.rest}`);
3149
3473
  let rollupConfig = {
3150
3474
  url: endpoints.rest,
3151
3475
  getSerializer: (schema) => new WasmSerializer(schema)
3152
3476
  }, rollup = await createStandardRollup(rollupConfig), client = new AuthenticatedClient(endpoints, rollup, wallet, delegatorAddress);
3153
3477
  await client.initializeExchangeInfo();
3154
3478
  let chainId = await client.getChainId();
3155
- console.debug("Chain ID:", chainId), rollupConfig.context = {
3479
+ rollupConfig.context = {
3156
3480
  defaultTxDetails: {
3157
3481
  max_priority_fee_bips: txOpts?.maxPriorityFeeBps ?? DEFAULT_TRANSACTION_OPTS.maxPriorityFeeBps,
3158
3482
  max_fee: txOpts?.maxFee ?? DEFAULT_TRANSACTION_OPTS.maxFee,
@@ -3185,7 +3509,7 @@ class Wallet {
3185
3509
  address;
3186
3510
  publicKey;
3187
3511
  constructor(publicKey) {
3188
- this.publicKey = publicKey, this.address = hexToBase58(this.publicKey), console.debug("Address:", this.address);
3512
+ this.publicKey = publicKey, this.address = hexToBase58(this.publicKey);
3189
3513
  }
3190
3514
  }
3191
3515
  export {
@@ -3225,4 +3549,4 @@ export {
3225
3549
  AbortError
3226
3550
  };
3227
3551
 
3228
- //# debugId=3713099902D65CC564756E2164756E21
3552
+ //# debugId=CFEDCB7328E162E864756E2164756E21