@gearbox-protocol/sdk 14.12.0-next.24 → 14.12.0-next.26

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.
@@ -227,43 +227,50 @@ async function fulfillSecuritizeWithdrawal(anvil, creditAccount, withdrawalPhant
227
227
  const redeemers = await anvil.readContract({
228
228
  address: redemptionGateway,
229
229
  abi: import_withdrawalAbi.securitizeRedemptionGatewayAbi,
230
- functionName: "getRedeemers",
230
+ functionName: "getUnclaimedRedeemers",
231
231
  args: [creditAccount]
232
232
  });
233
233
  logger?.debug(
234
- `securitize: gateway ${redemptionGateway}, stablecoin ${stableCoinToken}, ${redeemers.length} redeemers`
234
+ `securitize: gateway ${redemptionGateway}, stablecoin ${stableCoinToken}, ${redeemers.length} unclaimed redeemers`
235
235
  );
236
236
  if (redeemers.length === 0) {
237
237
  logger?.warn(
238
- `securitize: no redeemers found for credit account ${creditAccount}`
238
+ `securitize: no unclaimed redeemers found for credit account ${creditAccount}`
239
239
  );
240
240
  return;
241
241
  }
242
- const redeemer = redeemers[0];
243
- const [redemptionValue, redeemerBalance] = await anvil.multicall({
244
- allowFailure: false,
245
- contracts: [
246
- {
247
- address: redeemer,
248
- abi: import_withdrawalAbi.securitizeRedeemerAbi,
249
- functionName: "getCurrentRedemptionValue"
250
- },
251
- {
252
- address: stableCoinToken,
253
- abi: import_viem.erc20Abi,
254
- functionName: "balanceOf",
255
- args: [redeemer]
256
- }
257
- ]
258
- });
259
- logger?.debug(
260
- `securitize: dealing ${redemptionValue} of stablecoin ${stableCoinToken} to redeemer ${redeemer}`
261
- );
262
- await anvil.deal({
263
- erc20: stableCoinToken,
264
- account: redeemer,
265
- amount: redeemerBalance + redemptionValue
266
- });
242
+ for (const redeemer of redeemers) {
243
+ const [redemptionValue, redeemerBalance] = await anvil.multicall({
244
+ allowFailure: false,
245
+ contracts: [
246
+ {
247
+ address: redeemer,
248
+ abi: import_withdrawalAbi.securitizeRedeemerAbi,
249
+ functionName: "getCurrentRedemptionValue"
250
+ },
251
+ {
252
+ address: stableCoinToken,
253
+ abi: import_viem.erc20Abi,
254
+ functionName: "balanceOf",
255
+ args: [redeemer]
256
+ }
257
+ ]
258
+ });
259
+ if (redemptionValue === 0n) {
260
+ logger?.debug(
261
+ `securitize: skipping redeemer ${redeemer} with zero redemption value`
262
+ );
263
+ continue;
264
+ }
265
+ logger?.debug(
266
+ `securitize: dealing ${redemptionValue} of stablecoin ${stableCoinToken} to redeemer ${redeemer}`
267
+ );
268
+ await anvil.deal({
269
+ erc20: stableCoinToken,
270
+ account: redeemer,
271
+ amount: redeemerBalance + redemptionValue
272
+ });
273
+ }
267
274
  }
268
275
  // Annotate the CommonJS export names for ESM import in node:
269
276
  0 && (module.exports = {
@@ -591,13 +591,6 @@ class CreditAccountsServiceV310 extends import_base.SDKConstruct {
591
591
  closePath
592
592
  }) {
593
593
  const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
594
- await this.sdk.tokensMeta.loadTokenData(cm.underlying);
595
- const underlying = this.sdk.tokensMeta.mustGet(cm.underlying);
596
- if (this.sdk.tokensMeta.isRWAUnderlying(underlying)) {
597
- throw new Error(
598
- "closeCreditAccount is not supported for RWA underlying credit accounts"
599
- );
600
- }
601
594
  const routerCloseResult = closePath || await this.sdk.routerFor(ca).findBestClosePath({
602
595
  creditAccount: ca,
603
596
  creditManager: cm.creditManager,
@@ -627,14 +620,6 @@ class CreditAccountsServiceV310 extends import_base.SDKConstruct {
627
620
  assetsToWithdraw,
628
621
  to
629
622
  }) {
630
- const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
631
- await this.sdk.tokensMeta.loadTokenData(cm.underlying);
632
- const underlying = this.sdk.tokensMeta.mustGet(cm.underlying);
633
- if (this.sdk.tokensMeta.isRWAUnderlying(underlying)) {
634
- throw new Error(
635
- "closeCreditAccount is not supported for RWA underlying credit accounts"
636
- );
637
- }
638
623
  return [
639
624
  ...routerCalls,
640
625
  ...this.#prepareDisableQuotas(ca),
@@ -216,43 +216,50 @@ async function fulfillSecuritizeWithdrawal(anvil, creditAccount, withdrawalPhant
216
216
  const redeemers = await anvil.readContract({
217
217
  address: redemptionGateway,
218
218
  abi: securitizeRedemptionGatewayAbi,
219
- functionName: "getRedeemers",
219
+ functionName: "getUnclaimedRedeemers",
220
220
  args: [creditAccount]
221
221
  });
222
222
  logger?.debug(
223
- `securitize: gateway ${redemptionGateway}, stablecoin ${stableCoinToken}, ${redeemers.length} redeemers`
223
+ `securitize: gateway ${redemptionGateway}, stablecoin ${stableCoinToken}, ${redeemers.length} unclaimed redeemers`
224
224
  );
225
225
  if (redeemers.length === 0) {
226
226
  logger?.warn(
227
- `securitize: no redeemers found for credit account ${creditAccount}`
227
+ `securitize: no unclaimed redeemers found for credit account ${creditAccount}`
228
228
  );
229
229
  return;
230
230
  }
231
- const redeemer = redeemers[0];
232
- const [redemptionValue, redeemerBalance] = await anvil.multicall({
233
- allowFailure: false,
234
- contracts: [
235
- {
236
- address: redeemer,
237
- abi: securitizeRedeemerAbi,
238
- functionName: "getCurrentRedemptionValue"
239
- },
240
- {
241
- address: stableCoinToken,
242
- abi: erc20Abi,
243
- functionName: "balanceOf",
244
- args: [redeemer]
245
- }
246
- ]
247
- });
248
- logger?.debug(
249
- `securitize: dealing ${redemptionValue} of stablecoin ${stableCoinToken} to redeemer ${redeemer}`
250
- );
251
- await anvil.deal({
252
- erc20: stableCoinToken,
253
- account: redeemer,
254
- amount: redeemerBalance + redemptionValue
255
- });
231
+ for (const redeemer of redeemers) {
232
+ const [redemptionValue, redeemerBalance] = await anvil.multicall({
233
+ allowFailure: false,
234
+ contracts: [
235
+ {
236
+ address: redeemer,
237
+ abi: securitizeRedeemerAbi,
238
+ functionName: "getCurrentRedemptionValue"
239
+ },
240
+ {
241
+ address: stableCoinToken,
242
+ abi: erc20Abi,
243
+ functionName: "balanceOf",
244
+ args: [redeemer]
245
+ }
246
+ ]
247
+ });
248
+ if (redemptionValue === 0n) {
249
+ logger?.debug(
250
+ `securitize: skipping redeemer ${redeemer} with zero redemption value`
251
+ );
252
+ continue;
253
+ }
254
+ logger?.debug(
255
+ `securitize: dealing ${redemptionValue} of stablecoin ${stableCoinToken} to redeemer ${redeemer}`
256
+ );
257
+ await anvil.deal({
258
+ erc20: stableCoinToken,
259
+ account: redeemer,
260
+ amount: redeemerBalance + redemptionValue
261
+ });
262
+ }
256
263
  }
257
264
  export {
258
265
  makePendingWithdrawalsClaimable
@@ -587,13 +587,6 @@ class CreditAccountsServiceV310 extends SDKConstruct {
587
587
  closePath
588
588
  }) {
589
589
  const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
590
- await this.sdk.tokensMeta.loadTokenData(cm.underlying);
591
- const underlying = this.sdk.tokensMeta.mustGet(cm.underlying);
592
- if (this.sdk.tokensMeta.isRWAUnderlying(underlying)) {
593
- throw new Error(
594
- "closeCreditAccount is not supported for RWA underlying credit accounts"
595
- );
596
- }
597
590
  const routerCloseResult = closePath || await this.sdk.routerFor(ca).findBestClosePath({
598
591
  creditAccount: ca,
599
592
  creditManager: cm.creditManager,
@@ -623,14 +616,6 @@ class CreditAccountsServiceV310 extends SDKConstruct {
623
616
  assetsToWithdraw,
624
617
  to
625
618
  }) {
626
- const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
627
- await this.sdk.tokensMeta.loadTokenData(cm.underlying);
628
- const underlying = this.sdk.tokensMeta.mustGet(cm.underlying);
629
- if (this.sdk.tokensMeta.isRWAUnderlying(underlying)) {
630
- throw new Error(
631
- "closeCreditAccount is not supported for RWA underlying credit accounts"
632
- );
633
- }
634
619
  return [
635
620
  ...routerCalls,
636
621
  ...this.#prepareDisableQuotas(ca),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "14.12.0-next.24",
3
+ "version": "14.12.0-next.26",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {