@strkfarm/sdk 2.0.0-dev.8 → 2.0.0-dev.9

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.
@@ -94315,32 +94315,101 @@ spurious results.`);
94315
94315
  }
94316
94316
  }
94317
94317
  async getDepositOrWithdrawalStatus(orderId, operationsType) {
94318
- try {
94319
- let transferHistory = await this.client.getAssetOperations({
94320
- operationsType: [operationsType],
94321
- operationsStatus: ["COMPLETED" /* COMPLETED */]
94322
- });
94323
- if (operationsType === "DEPOSIT" /* DEPOSIT */) {
94324
- const myTransferStatus = transferHistory.data.find(
94325
- (operation) => operation.transactionHash === orderId
94326
- );
94327
- if (!myTransferStatus) {
94328
- return true;
94318
+ const maxAttempts = 5;
94319
+ const retryDelayMs = 3e4;
94320
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
94321
+ try {
94322
+ let transferHistory = await this.client.getAssetOperations({
94323
+ operationsType: [operationsType],
94324
+ operationsStatus: ["COMPLETED" /* COMPLETED */]
94325
+ });
94326
+ if (operationsType === "DEPOSIT" /* DEPOSIT */) {
94327
+ const myTransferStatus = transferHistory.data.find(
94328
+ (operation) => operation.transactionHash === orderId
94329
+ );
94330
+ if (!myTransferStatus) {
94331
+ if (attempt < maxAttempts) {
94332
+ logger2.info(
94333
+ `Deposit operation not found for transactionHash ${orderId}, retrying (attempt ${attempt}/${maxAttempts})...`
94334
+ );
94335
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
94336
+ continue;
94337
+ }
94338
+ logger2.warn(
94339
+ `Deposit operation not found for transactionHash ${orderId} after ${maxAttempts} attempts`
94340
+ );
94341
+ return false;
94342
+ }
94343
+ if (myTransferStatus.status === "COMPLETED" /* COMPLETED */) {
94344
+ logger2.info(
94345
+ `Deposit operation ${orderId} completed successfully`
94346
+ );
94347
+ return true;
94348
+ } else {
94349
+ if (attempt < maxAttempts) {
94350
+ logger2.info(
94351
+ `Deposit operation ${orderId} found but status is ${myTransferStatus.status}, not COMPLETED. Retrying (attempt ${attempt}/${maxAttempts})...`
94352
+ );
94353
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
94354
+ continue;
94355
+ }
94356
+ logger2.warn(
94357
+ `Deposit operation ${orderId} status is ${myTransferStatus.status} after ${maxAttempts} attempts, expected COMPLETED`
94358
+ );
94359
+ return false;
94360
+ }
94361
+ } else {
94362
+ const myTransferStatus = transferHistory.data.find(
94363
+ (operation) => operation.id.toString() === orderId.toString()
94364
+ );
94365
+ if (!myTransferStatus) {
94366
+ if (attempt < maxAttempts) {
94367
+ logger2.info(
94368
+ `Withdrawal status not found for orderId ${orderId} in completed operations, retrying (attempt ${attempt}/${maxAttempts})...`
94369
+ );
94370
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
94371
+ continue;
94372
+ }
94373
+ logger2.warn(
94374
+ `Withdrawal operation not found for orderId ${orderId} after ${maxAttempts} attempts`
94375
+ );
94376
+ return false;
94377
+ }
94378
+ if (myTransferStatus.status === "COMPLETED" /* COMPLETED */) {
94379
+ logger2.info(
94380
+ `Withdrawal operation ${orderId} completed successfully`
94381
+ );
94382
+ return true;
94383
+ } else {
94384
+ if (attempt < maxAttempts) {
94385
+ logger2.info(
94386
+ `Withdrawal operation ${orderId} found but status is ${myTransferStatus.status}, not COMPLETED. Retrying (attempt ${attempt}/${maxAttempts})...`
94387
+ );
94388
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
94389
+ continue;
94390
+ }
94391
+ logger2.warn(
94392
+ `Withdrawal operation ${orderId} status is ${myTransferStatus.status} after ${maxAttempts} attempts, expected COMPLETED`
94393
+ );
94394
+ return false;
94395
+ }
94329
94396
  }
94330
- return true;
94331
- } else {
94332
- const myTransferStatus = transferHistory.data.find(
94333
- (operation) => operation.id.toString() === orderId.toString()
94397
+ } catch (err2) {
94398
+ logger2.error(
94399
+ `error getting deposit or withdrawal status (attempt ${attempt}/${maxAttempts}): ${err2}`
94334
94400
  );
94335
- if (!myTransferStatus) {
94336
- return true;
94401
+ if (attempt < maxAttempts) {
94402
+ logger2.info(`Retrying after ${retryDelayMs}ms...`);
94403
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
94404
+ continue;
94337
94405
  }
94338
- return true;
94406
+ logger2.error(
94407
+ `Max retry attempts reached for getDepositOrWithdrawalStatus`
94408
+ );
94409
+ return false;
94339
94410
  }
94340
- } catch (err2) {
94341
- logger2.error(`error getting deposit or withdrawal status: ${err2}`);
94342
- return false;
94343
94411
  }
94412
+ return false;
94344
94413
  }
94345
94414
  };
94346
94415
 
@@ -98741,7 +98810,6 @@ spurious results.`);
98741
98810
  if (!openLongPosition) {
98742
98811
  logger2.error(`error opening long position: ${openLongPosition}`);
98743
98812
  }
98744
- await new Promise((resolve) => setTimeout(resolve, 5e3));
98745
98813
  const updatedHoldings = await extendedAdapter.getExtendedDepositAmount();
98746
98814
  if (!updatedHoldings || new Web3Number(updatedHoldings.availableForWithdrawal, USDC_TOKEN_DECIMALS).lessThan(params.amount.abs())) {
98747
98815
  logger2.error(`Insufficient balance after opening position. Available: ${updatedHoldings?.availableForWithdrawal}, Needed: ${params.amount.abs()}`);
@@ -98752,7 +98820,7 @@ spurious results.`);
98752
98820
  if (withdrawalFromExtended) {
98753
98821
  const extendedHoldings2 = await extendedAdapter.getExtendedDepositAmount();
98754
98822
  logger2.info(`extendedHoldings after withdrawal ${extendedHoldings2?.availableForWithdrawal}`);
98755
- await new Promise((resolve) => setTimeout(resolve, 1e4));
98823
+ await new Promise((resolve) => setTimeout(resolve, 2e3));
98756
98824
  const calls = await this.moveAssetsToVaultAllocator(params.amount, extendedAdapter);
98757
98825
  if (calls.length > 0) {
98758
98826
  return {
@@ -30288,32 +30288,101 @@ var ExtendedAdapter = class _ExtendedAdapter extends BaseAdapter {
30288
30288
  }
30289
30289
  }
30290
30290
  async getDepositOrWithdrawalStatus(orderId, operationsType) {
30291
- try {
30292
- let transferHistory = await this.client.getAssetOperations({
30293
- operationsType: [operationsType],
30294
- operationsStatus: ["COMPLETED" /* COMPLETED */]
30295
- });
30296
- if (operationsType === "DEPOSIT" /* DEPOSIT */) {
30297
- const myTransferStatus = transferHistory.data.find(
30298
- (operation) => operation.transactionHash === orderId
30299
- );
30300
- if (!myTransferStatus) {
30301
- return true;
30291
+ const maxAttempts = 5;
30292
+ const retryDelayMs = 3e4;
30293
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
30294
+ try {
30295
+ let transferHistory = await this.client.getAssetOperations({
30296
+ operationsType: [operationsType],
30297
+ operationsStatus: ["COMPLETED" /* COMPLETED */]
30298
+ });
30299
+ if (operationsType === "DEPOSIT" /* DEPOSIT */) {
30300
+ const myTransferStatus = transferHistory.data.find(
30301
+ (operation) => operation.transactionHash === orderId
30302
+ );
30303
+ if (!myTransferStatus) {
30304
+ if (attempt < maxAttempts) {
30305
+ logger.info(
30306
+ `Deposit operation not found for transactionHash ${orderId}, retrying (attempt ${attempt}/${maxAttempts})...`
30307
+ );
30308
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
30309
+ continue;
30310
+ }
30311
+ logger.warn(
30312
+ `Deposit operation not found for transactionHash ${orderId} after ${maxAttempts} attempts`
30313
+ );
30314
+ return false;
30315
+ }
30316
+ if (myTransferStatus.status === "COMPLETED" /* COMPLETED */) {
30317
+ logger.info(
30318
+ `Deposit operation ${orderId} completed successfully`
30319
+ );
30320
+ return true;
30321
+ } else {
30322
+ if (attempt < maxAttempts) {
30323
+ logger.info(
30324
+ `Deposit operation ${orderId} found but status is ${myTransferStatus.status}, not COMPLETED. Retrying (attempt ${attempt}/${maxAttempts})...`
30325
+ );
30326
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
30327
+ continue;
30328
+ }
30329
+ logger.warn(
30330
+ `Deposit operation ${orderId} status is ${myTransferStatus.status} after ${maxAttempts} attempts, expected COMPLETED`
30331
+ );
30332
+ return false;
30333
+ }
30334
+ } else {
30335
+ const myTransferStatus = transferHistory.data.find(
30336
+ (operation) => operation.id.toString() === orderId.toString()
30337
+ );
30338
+ if (!myTransferStatus) {
30339
+ if (attempt < maxAttempts) {
30340
+ logger.info(
30341
+ `Withdrawal status not found for orderId ${orderId} in completed operations, retrying (attempt ${attempt}/${maxAttempts})...`
30342
+ );
30343
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
30344
+ continue;
30345
+ }
30346
+ logger.warn(
30347
+ `Withdrawal operation not found for orderId ${orderId} after ${maxAttempts} attempts`
30348
+ );
30349
+ return false;
30350
+ }
30351
+ if (myTransferStatus.status === "COMPLETED" /* COMPLETED */) {
30352
+ logger.info(
30353
+ `Withdrawal operation ${orderId} completed successfully`
30354
+ );
30355
+ return true;
30356
+ } else {
30357
+ if (attempt < maxAttempts) {
30358
+ logger.info(
30359
+ `Withdrawal operation ${orderId} found but status is ${myTransferStatus.status}, not COMPLETED. Retrying (attempt ${attempt}/${maxAttempts})...`
30360
+ );
30361
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
30362
+ continue;
30363
+ }
30364
+ logger.warn(
30365
+ `Withdrawal operation ${orderId} status is ${myTransferStatus.status} after ${maxAttempts} attempts, expected COMPLETED`
30366
+ );
30367
+ return false;
30368
+ }
30302
30369
  }
30303
- return true;
30304
- } else {
30305
- const myTransferStatus = transferHistory.data.find(
30306
- (operation) => operation.id.toString() === orderId.toString()
30370
+ } catch (err) {
30371
+ logger.error(
30372
+ `error getting deposit or withdrawal status (attempt ${attempt}/${maxAttempts}): ${err}`
30307
30373
  );
30308
- if (!myTransferStatus) {
30309
- return true;
30374
+ if (attempt < maxAttempts) {
30375
+ logger.info(`Retrying after ${retryDelayMs}ms...`);
30376
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
30377
+ continue;
30310
30378
  }
30311
- return true;
30379
+ logger.error(
30380
+ `Max retry attempts reached for getDepositOrWithdrawalStatus`
30381
+ );
30382
+ return false;
30312
30383
  }
30313
- } catch (err) {
30314
- logger.error(`error getting deposit or withdrawal status: ${err}`);
30315
- return false;
30316
30384
  }
30385
+ return false;
30317
30386
  }
30318
30387
  };
30319
30388
 
@@ -34719,7 +34788,6 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34719
34788
  if (!openLongPosition) {
34720
34789
  logger.error(`error opening long position: ${openLongPosition}`);
34721
34790
  }
34722
- await new Promise((resolve) => setTimeout(resolve, 5e3));
34723
34791
  const updatedHoldings = await extendedAdapter.getExtendedDepositAmount();
34724
34792
  if (!updatedHoldings || new Web3Number(updatedHoldings.availableForWithdrawal, USDC_TOKEN_DECIMALS).lessThan(params.amount.abs())) {
34725
34793
  logger.error(`Insufficient balance after opening position. Available: ${updatedHoldings?.availableForWithdrawal}, Needed: ${params.amount.abs()}`);
@@ -34730,7 +34798,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34730
34798
  if (withdrawalFromExtended) {
34731
34799
  const extendedHoldings2 = await extendedAdapter.getExtendedDepositAmount();
34732
34800
  logger.info(`extendedHoldings after withdrawal ${extendedHoldings2?.availableForWithdrawal}`);
34733
- await new Promise((resolve) => setTimeout(resolve, 1e4));
34801
+ await new Promise((resolve) => setTimeout(resolve, 2e3));
34734
34802
  const calls = await this.moveAssetsToVaultAllocator(params.amount, extendedAdapter);
34735
34803
  if (calls.length > 0) {
34736
34804
  return {
package/dist/index.d.ts CHANGED
@@ -1535,7 +1535,8 @@ declare class ExtendedAdapter extends BaseAdapter<DepositParams, WithdrawParams>
1535
1535
  createExtendedPositon(client: ExtendedWrapper, marketName: string, amount: string, price: string, side: OrderSide): Promise<{
1536
1536
  position_id: string;
1537
1537
  } | null>;
1538
- getDepositOrWithdrawalStatus(orderId: number | string, operationsType: AssetOperationType): Promise<boolean>;
1538
+ getDepositOrWithdrawalStatus(orderId: number | string, // for deposits, send txn hash as string
1539
+ operationsType: AssetOperationType): Promise<boolean>;
1539
1540
  }
1540
1541
 
1541
1542
  declare const SIMPLE_SANITIZER: ContractAddr;
package/dist/index.js CHANGED
@@ -30441,32 +30441,101 @@ var ExtendedAdapter = class _ExtendedAdapter extends BaseAdapter {
30441
30441
  }
30442
30442
  }
30443
30443
  async getDepositOrWithdrawalStatus(orderId, operationsType) {
30444
- try {
30445
- let transferHistory = await this.client.getAssetOperations({
30446
- operationsType: [operationsType],
30447
- operationsStatus: ["COMPLETED" /* COMPLETED */]
30448
- });
30449
- if (operationsType === "DEPOSIT" /* DEPOSIT */) {
30450
- const myTransferStatus = transferHistory.data.find(
30451
- (operation) => operation.transactionHash === orderId
30452
- );
30453
- if (!myTransferStatus) {
30454
- return true;
30444
+ const maxAttempts = 5;
30445
+ const retryDelayMs = 3e4;
30446
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
30447
+ try {
30448
+ let transferHistory = await this.client.getAssetOperations({
30449
+ operationsType: [operationsType],
30450
+ operationsStatus: ["COMPLETED" /* COMPLETED */]
30451
+ });
30452
+ if (operationsType === "DEPOSIT" /* DEPOSIT */) {
30453
+ const myTransferStatus = transferHistory.data.find(
30454
+ (operation) => operation.transactionHash === orderId
30455
+ );
30456
+ if (!myTransferStatus) {
30457
+ if (attempt < maxAttempts) {
30458
+ logger.info(
30459
+ `Deposit operation not found for transactionHash ${orderId}, retrying (attempt ${attempt}/${maxAttempts})...`
30460
+ );
30461
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
30462
+ continue;
30463
+ }
30464
+ logger.warn(
30465
+ `Deposit operation not found for transactionHash ${orderId} after ${maxAttempts} attempts`
30466
+ );
30467
+ return false;
30468
+ }
30469
+ if (myTransferStatus.status === "COMPLETED" /* COMPLETED */) {
30470
+ logger.info(
30471
+ `Deposit operation ${orderId} completed successfully`
30472
+ );
30473
+ return true;
30474
+ } else {
30475
+ if (attempt < maxAttempts) {
30476
+ logger.info(
30477
+ `Deposit operation ${orderId} found but status is ${myTransferStatus.status}, not COMPLETED. Retrying (attempt ${attempt}/${maxAttempts})...`
30478
+ );
30479
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
30480
+ continue;
30481
+ }
30482
+ logger.warn(
30483
+ `Deposit operation ${orderId} status is ${myTransferStatus.status} after ${maxAttempts} attempts, expected COMPLETED`
30484
+ );
30485
+ return false;
30486
+ }
30487
+ } else {
30488
+ const myTransferStatus = transferHistory.data.find(
30489
+ (operation) => operation.id.toString() === orderId.toString()
30490
+ );
30491
+ if (!myTransferStatus) {
30492
+ if (attempt < maxAttempts) {
30493
+ logger.info(
30494
+ `Withdrawal status not found for orderId ${orderId} in completed operations, retrying (attempt ${attempt}/${maxAttempts})...`
30495
+ );
30496
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
30497
+ continue;
30498
+ }
30499
+ logger.warn(
30500
+ `Withdrawal operation not found for orderId ${orderId} after ${maxAttempts} attempts`
30501
+ );
30502
+ return false;
30503
+ }
30504
+ if (myTransferStatus.status === "COMPLETED" /* COMPLETED */) {
30505
+ logger.info(
30506
+ `Withdrawal operation ${orderId} completed successfully`
30507
+ );
30508
+ return true;
30509
+ } else {
30510
+ if (attempt < maxAttempts) {
30511
+ logger.info(
30512
+ `Withdrawal operation ${orderId} found but status is ${myTransferStatus.status}, not COMPLETED. Retrying (attempt ${attempt}/${maxAttempts})...`
30513
+ );
30514
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
30515
+ continue;
30516
+ }
30517
+ logger.warn(
30518
+ `Withdrawal operation ${orderId} status is ${myTransferStatus.status} after ${maxAttempts} attempts, expected COMPLETED`
30519
+ );
30520
+ return false;
30521
+ }
30455
30522
  }
30456
- return true;
30457
- } else {
30458
- const myTransferStatus = transferHistory.data.find(
30459
- (operation) => operation.id.toString() === orderId.toString()
30523
+ } catch (err) {
30524
+ logger.error(
30525
+ `error getting deposit or withdrawal status (attempt ${attempt}/${maxAttempts}): ${err}`
30460
30526
  );
30461
- if (!myTransferStatus) {
30462
- return true;
30527
+ if (attempt < maxAttempts) {
30528
+ logger.info(`Retrying after ${retryDelayMs}ms...`);
30529
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
30530
+ continue;
30463
30531
  }
30464
- return true;
30532
+ logger.error(
30533
+ `Max retry attempts reached for getDepositOrWithdrawalStatus`
30534
+ );
30535
+ return false;
30465
30536
  }
30466
- } catch (err) {
30467
- logger.error(`error getting deposit or withdrawal status: ${err}`);
30468
- return false;
30469
30537
  }
30538
+ return false;
30470
30539
  }
30471
30540
  };
30472
30541
 
@@ -34872,7 +34941,6 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34872
34941
  if (!openLongPosition) {
34873
34942
  logger.error(`error opening long position: ${openLongPosition}`);
34874
34943
  }
34875
- await new Promise((resolve) => setTimeout(resolve, 5e3));
34876
34944
  const updatedHoldings = await extendedAdapter.getExtendedDepositAmount();
34877
34945
  if (!updatedHoldings || new Web3Number(updatedHoldings.availableForWithdrawal, USDC_TOKEN_DECIMALS).lessThan(params.amount.abs())) {
34878
34946
  logger.error(`Insufficient balance after opening position. Available: ${updatedHoldings?.availableForWithdrawal}, Needed: ${params.amount.abs()}`);
@@ -34883,7 +34951,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34883
34951
  if (withdrawalFromExtended) {
34884
34952
  const extendedHoldings2 = await extendedAdapter.getExtendedDepositAmount();
34885
34953
  logger.info(`extendedHoldings after withdrawal ${extendedHoldings2?.availableForWithdrawal}`);
34886
- await new Promise((resolve) => setTimeout(resolve, 1e4));
34954
+ await new Promise((resolve) => setTimeout(resolve, 2e3));
34887
34955
  const calls = await this.moveAssetsToVaultAllocator(params.amount, extendedAdapter);
34888
34956
  if (calls.length > 0) {
34889
34957
  return {
package/dist/index.mjs CHANGED
@@ -30299,32 +30299,101 @@ var ExtendedAdapter = class _ExtendedAdapter extends BaseAdapter {
30299
30299
  }
30300
30300
  }
30301
30301
  async getDepositOrWithdrawalStatus(orderId, operationsType) {
30302
- try {
30303
- let transferHistory = await this.client.getAssetOperations({
30304
- operationsType: [operationsType],
30305
- operationsStatus: ["COMPLETED" /* COMPLETED */]
30306
- });
30307
- if (operationsType === "DEPOSIT" /* DEPOSIT */) {
30308
- const myTransferStatus = transferHistory.data.find(
30309
- (operation) => operation.transactionHash === orderId
30310
- );
30311
- if (!myTransferStatus) {
30312
- return true;
30302
+ const maxAttempts = 5;
30303
+ const retryDelayMs = 3e4;
30304
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
30305
+ try {
30306
+ let transferHistory = await this.client.getAssetOperations({
30307
+ operationsType: [operationsType],
30308
+ operationsStatus: ["COMPLETED" /* COMPLETED */]
30309
+ });
30310
+ if (operationsType === "DEPOSIT" /* DEPOSIT */) {
30311
+ const myTransferStatus = transferHistory.data.find(
30312
+ (operation) => operation.transactionHash === orderId
30313
+ );
30314
+ if (!myTransferStatus) {
30315
+ if (attempt < maxAttempts) {
30316
+ logger.info(
30317
+ `Deposit operation not found for transactionHash ${orderId}, retrying (attempt ${attempt}/${maxAttempts})...`
30318
+ );
30319
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
30320
+ continue;
30321
+ }
30322
+ logger.warn(
30323
+ `Deposit operation not found for transactionHash ${orderId} after ${maxAttempts} attempts`
30324
+ );
30325
+ return false;
30326
+ }
30327
+ if (myTransferStatus.status === "COMPLETED" /* COMPLETED */) {
30328
+ logger.info(
30329
+ `Deposit operation ${orderId} completed successfully`
30330
+ );
30331
+ return true;
30332
+ } else {
30333
+ if (attempt < maxAttempts) {
30334
+ logger.info(
30335
+ `Deposit operation ${orderId} found but status is ${myTransferStatus.status}, not COMPLETED. Retrying (attempt ${attempt}/${maxAttempts})...`
30336
+ );
30337
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
30338
+ continue;
30339
+ }
30340
+ logger.warn(
30341
+ `Deposit operation ${orderId} status is ${myTransferStatus.status} after ${maxAttempts} attempts, expected COMPLETED`
30342
+ );
30343
+ return false;
30344
+ }
30345
+ } else {
30346
+ const myTransferStatus = transferHistory.data.find(
30347
+ (operation) => operation.id.toString() === orderId.toString()
30348
+ );
30349
+ if (!myTransferStatus) {
30350
+ if (attempt < maxAttempts) {
30351
+ logger.info(
30352
+ `Withdrawal status not found for orderId ${orderId} in completed operations, retrying (attempt ${attempt}/${maxAttempts})...`
30353
+ );
30354
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
30355
+ continue;
30356
+ }
30357
+ logger.warn(
30358
+ `Withdrawal operation not found for orderId ${orderId} after ${maxAttempts} attempts`
30359
+ );
30360
+ return false;
30361
+ }
30362
+ if (myTransferStatus.status === "COMPLETED" /* COMPLETED */) {
30363
+ logger.info(
30364
+ `Withdrawal operation ${orderId} completed successfully`
30365
+ );
30366
+ return true;
30367
+ } else {
30368
+ if (attempt < maxAttempts) {
30369
+ logger.info(
30370
+ `Withdrawal operation ${orderId} found but status is ${myTransferStatus.status}, not COMPLETED. Retrying (attempt ${attempt}/${maxAttempts})...`
30371
+ );
30372
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
30373
+ continue;
30374
+ }
30375
+ logger.warn(
30376
+ `Withdrawal operation ${orderId} status is ${myTransferStatus.status} after ${maxAttempts} attempts, expected COMPLETED`
30377
+ );
30378
+ return false;
30379
+ }
30313
30380
  }
30314
- return true;
30315
- } else {
30316
- const myTransferStatus = transferHistory.data.find(
30317
- (operation) => operation.id.toString() === orderId.toString()
30381
+ } catch (err) {
30382
+ logger.error(
30383
+ `error getting deposit or withdrawal status (attempt ${attempt}/${maxAttempts}): ${err}`
30318
30384
  );
30319
- if (!myTransferStatus) {
30320
- return true;
30385
+ if (attempt < maxAttempts) {
30386
+ logger.info(`Retrying after ${retryDelayMs}ms...`);
30387
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
30388
+ continue;
30321
30389
  }
30322
- return true;
30390
+ logger.error(
30391
+ `Max retry attempts reached for getDepositOrWithdrawalStatus`
30392
+ );
30393
+ return false;
30323
30394
  }
30324
- } catch (err) {
30325
- logger.error(`error getting deposit or withdrawal status: ${err}`);
30326
- return false;
30327
30395
  }
30396
+ return false;
30328
30397
  }
30329
30398
  };
30330
30399
 
@@ -34730,7 +34799,6 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34730
34799
  if (!openLongPosition) {
34731
34800
  logger.error(`error opening long position: ${openLongPosition}`);
34732
34801
  }
34733
- await new Promise((resolve) => setTimeout(resolve, 5e3));
34734
34802
  const updatedHoldings = await extendedAdapter.getExtendedDepositAmount();
34735
34803
  if (!updatedHoldings || new Web3Number(updatedHoldings.availableForWithdrawal, USDC_TOKEN_DECIMALS).lessThan(params.amount.abs())) {
34736
34804
  logger.error(`Insufficient balance after opening position. Available: ${updatedHoldings?.availableForWithdrawal}, Needed: ${params.amount.abs()}`);
@@ -34741,7 +34809,7 @@ var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy exten
34741
34809
  if (withdrawalFromExtended) {
34742
34810
  const extendedHoldings2 = await extendedAdapter.getExtendedDepositAmount();
34743
34811
  logger.info(`extendedHoldings after withdrawal ${extendedHoldings2?.availableForWithdrawal}`);
34744
- await new Promise((resolve) => setTimeout(resolve, 1e4));
34812
+ await new Promise((resolve) => setTimeout(resolve, 2e3));
34745
34813
  const calls = await this.moveAssetsToVaultAllocator(params.amount, extendedAdapter);
34746
34814
  if (calls.length > 0) {
34747
34815
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strkfarm/sdk",
3
- "version": "2.0.0-dev.8",
3
+ "version": "2.0.0-dev.9",
4
4
  "description": "STRKFarm TS SDK (Meant for our internal use, but feel free to use it)",
5
5
  "typings": "dist/index.d.ts",
6
6
  "types": "dist/index.d.ts",
@@ -866,34 +866,107 @@ export class ExtendedAdapter extends BaseAdapter<
866
866
  }
867
867
 
868
868
  async getDepositOrWithdrawalStatus(
869
- orderId: number | string,
869
+ orderId: number | string, // for deposits, send txn hash as string
870
870
  operationsType: AssetOperationType
871
871
  ): Promise<boolean> {
872
- try {
873
- let transferHistory = await this.client.getAssetOperations({
874
- operationsType: [operationsType],
875
- operationsStatus: [AssetOperationStatus.COMPLETED],
876
- });
877
- if (operationsType === AssetOperationType.DEPOSIT) {
878
- const myTransferStatus = transferHistory.data.find(
879
- (operation) => operation.transactionHash === orderId
880
- );
881
- if (!myTransferStatus) {
882
- return true;
872
+ const maxAttempts = 5;
873
+ const retryDelayMs = 30000; // 30 seconds
874
+
875
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
876
+ try {
877
+ let transferHistory = await this.client.getAssetOperations({
878
+ operationsType: [operationsType],
879
+ operationsStatus: [AssetOperationStatus.COMPLETED],
880
+ });
881
+ if (operationsType === AssetOperationType.DEPOSIT) {
882
+ const myTransferStatus = transferHistory.data.find(
883
+ (operation) => operation.transactionHash === orderId
884
+ );
885
+ if (!myTransferStatus) {
886
+ if (attempt < maxAttempts) {
887
+ logger.info(
888
+ `Deposit operation not found for transactionHash ${orderId}, retrying (attempt ${attempt}/${maxAttempts})...`
889
+ );
890
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
891
+ continue;
892
+ }
893
+ logger.warn(
894
+ `Deposit operation not found for transactionHash ${orderId} after ${maxAttempts} attempts`
895
+ );
896
+ return false;
897
+ }
898
+ // Check if status is COMPLETED
899
+ if (myTransferStatus.status === AssetOperationStatus.COMPLETED) {
900
+ logger.info(
901
+ `Deposit operation ${orderId} completed successfully`
902
+ );
903
+ return true;
904
+ } else {
905
+ if (attempt < maxAttempts) {
906
+ logger.info(
907
+ `Deposit operation ${orderId} found but status is ${myTransferStatus.status}, not COMPLETED. Retrying (attempt ${attempt}/${maxAttempts})...`
908
+ );
909
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
910
+ continue;
911
+ }
912
+ logger.warn(
913
+ `Deposit operation ${orderId} status is ${myTransferStatus.status} after ${maxAttempts} attempts, expected COMPLETED`
914
+ );
915
+ return false;
916
+ }
917
+ } else {
918
+ const myTransferStatus = transferHistory.data.find(
919
+ (operation) => operation.id.toString() === orderId.toString()
920
+ );
921
+ if (!myTransferStatus) {
922
+ if (attempt < maxAttempts) {
923
+ logger.info(
924
+ `Withdrawal status not found for orderId ${orderId} in completed operations, retrying (attempt ${attempt}/${maxAttempts})...`
925
+ );
926
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
927
+ continue;
928
+ }
929
+ logger.warn(
930
+ `Withdrawal operation not found for orderId ${orderId} after ${maxAttempts} attempts`
931
+ );
932
+ return false;
933
+ }
934
+ // Check if status is COMPLETED
935
+ if (myTransferStatus.status === AssetOperationStatus.COMPLETED) {
936
+ logger.info(
937
+ `Withdrawal operation ${orderId} completed successfully`
938
+ );
939
+ return true;
940
+ } else {
941
+ if (attempt < maxAttempts) {
942
+ logger.info(
943
+ `Withdrawal operation ${orderId} found but status is ${myTransferStatus.status}, not COMPLETED. Retrying (attempt ${attempt}/${maxAttempts})...`
944
+ );
945
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
946
+ continue;
947
+ }
948
+ logger.warn(
949
+ `Withdrawal operation ${orderId} status is ${myTransferStatus.status} after ${maxAttempts} attempts, expected COMPLETED`
950
+ );
951
+ return false;
952
+ }
883
953
  }
884
- return true;
885
- } else {
886
- const myTransferStatus = transferHistory.data.find(
887
- (operation) => operation.id.toString() === orderId.toString()
954
+ } catch (err) {
955
+ logger.error(
956
+ `error getting deposit or withdrawal status (attempt ${attempt}/${maxAttempts}): ${err}`
888
957
  );
889
- if (!myTransferStatus) {
890
- return true;
958
+ if (attempt < maxAttempts) {
959
+ logger.info(`Retrying after ${retryDelayMs}ms...`);
960
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
961
+ continue;
891
962
  }
892
- return true;
963
+ logger.error(
964
+ `Max retry attempts reached for getDepositOrWithdrawalStatus`
965
+ );
966
+ return false;
893
967
  }
894
- } catch (err) {
895
- logger.error(`error getting deposit or withdrawal status: ${err}`);
896
- return false;
897
968
  }
969
+
970
+ return false;
898
971
  }
899
972
  }
@@ -737,7 +737,6 @@ export class VesuExtendedMultiplierStrategy<
737
737
  if (!openLongPosition) {
738
738
  logger.error(`error opening long position: ${openLongPosition}`);
739
739
  }
740
- await new Promise(resolve => setTimeout(resolve, 5000));
741
740
  const updatedHoldings = await extendedAdapter.getExtendedDepositAmount();
742
741
  if (!updatedHoldings || new Web3Number(updatedHoldings.availableForWithdrawal, USDC_TOKEN_DECIMALS).lessThan(params.amount.abs())) {
743
742
  logger.error(`Insufficient balance after opening position. Available: ${updatedHoldings?.availableForWithdrawal}, Needed: ${params.amount.abs()}`);
@@ -752,7 +751,7 @@ export class VesuExtendedMultiplierStrategy<
752
751
  */
753
752
  const extendedHoldings = await extendedAdapter.getExtendedDepositAmount();
754
753
  logger.info(`extendedHoldings after withdrawal ${extendedHoldings?.availableForWithdrawal}`);
755
- await new Promise(resolve => setTimeout(resolve, 10000));
754
+ await new Promise(resolve => setTimeout(resolve, 2000));
756
755
  const calls = await this.moveAssetsToVaultAllocator(params.amount, extendedAdapter);
757
756
  if (calls.length > 0) {
758
757
  return {