@gearbox-protocol/sdk 16.4.0-next.1 → 16.4.0-next.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.
@@ -27,6 +27,7 @@ async function checkCreditOperation(args) {
27
27
  const market = suite.market;
28
28
  const underlying = require_onchain_validation_helpers_token.toToken(sdk, market.pool.underlying);
29
29
  const isOpening = preview.operation === "OpenCreditAccount";
30
+ const isEmptyOpening = preview.operation === "OpenCreditAccount" && preview.totalDebt.value === 0n && preview.collateralAdded.length === 0 && preview.quotas.length === 0;
30
31
  const protocol = [
31
32
  ...require_onchain_validation_bundles_checkMarket.checkMarket(suite),
32
33
  ...require_onchain_validation_checks_checkDebtLimits.checkDebtLimits({
@@ -34,7 +35,7 @@ async function checkCreditOperation(args) {
34
35
  minDebt: suite.creditFacade.minDebt,
35
36
  maxDebt: suite.creditFacade.maxDebt,
36
37
  underlying,
37
- allowZero: !isOpening,
38
+ allowZero: !isOpening || isEmptyOpening,
38
39
  maxBorrowAmount: suite.maxBorrowAmount()
39
40
  }),
40
41
  ...require_onchain_validation_bundles_checkIncreaseDebt.checkIncreaseDebt(suite, preview, underlying),
@@ -26,6 +26,7 @@ async function checkCreditOperation(args) {
26
26
  const market = suite.market;
27
27
  const underlying = toToken(sdk, market.pool.underlying);
28
28
  const isOpening = preview.operation === "OpenCreditAccount";
29
+ const isEmptyOpening = preview.operation === "OpenCreditAccount" && preview.totalDebt.value === 0n && preview.collateralAdded.length === 0 && preview.quotas.length === 0;
29
30
  const protocol = [
30
31
  ...checkMarket(suite),
31
32
  ...checkDebtLimits({
@@ -33,7 +34,7 @@ async function checkCreditOperation(args) {
33
34
  minDebt: suite.creditFacade.minDebt,
34
35
  maxDebt: suite.creditFacade.maxDebt,
35
36
  underlying,
36
- allowZero: !isOpening,
37
+ allowZero: !isOpening || isEmptyOpening,
37
38
  maxBorrowAmount: suite.maxBorrowAmount()
38
39
  }),
39
40
  ...checkIncreaseDebt(suite, preview, underlying),
@@ -12,8 +12,8 @@ interface DebtLimitsArgs {
12
12
  /**
13
13
  * Whether ending with no loan at all is acceptable. The one place the two
14
14
  * callers genuinely disagree: an account being adjusted may end owing
15
- * nothing, while one being opened may not — so the exemption is stated
16
- * rather than assumed.
15
+ * nothing, while one being opened may not unless it is opened empty — so the
16
+ * exemption is stated rather than assumed.
17
17
  */
18
18
  allowZero: boolean;
19
19
  /** From the caller's suite; a caller that raises to throw advises nobody. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "16.4.0-next.1",
3
+ "version": "16.4.0-next.2",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {