@gearbox-protocol/sdk 16.0.0-next.18 → 16.0.0-next.19
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/cjs/common-utils/index.js +3 -21
- package/dist/cjs/common-utils/test-utils/index.js +4 -3
- package/dist/cjs/common-utils/utils/index.js +3 -22
- package/dist/cjs/common-utils/utils/strategies/index.js +3 -0
- package/dist/cjs/common-utils/utils/strategies/strategy-info/cm-availability-condition.js +5 -5
- package/dist/cjs/common-utils/utils/strategies/strategy-info/credit-manager-issues.js +135 -0
- package/dist/cjs/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +12 -23
- package/dist/cjs/common-utils/utils/strategies/strategy-info/index.js +3 -0
- package/dist/cjs/onchain/accounts/index.js +2 -3
- package/dist/cjs/onchain/accounts/intents/guards.js +55 -50
- package/dist/cjs/onchain/accounts/intents/index.js +7 -8
- package/dist/cjs/onchain/accounts/intents/math.js +15 -22
- package/dist/cjs/onchain/accounts/intents/open-strategy.js +5 -5
- package/dist/cjs/onchain/accounts/intents/plan.js +27 -41
- package/dist/cjs/onchain/accounts/intents/realize.js +14 -21
- package/dist/cjs/onchain/accounts/intents/tail.js +2 -2
- package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/cjs/onchain/accounts/intents/view.js +1 -0
- package/dist/cjs/onchain/constants/index.js +1 -0
- package/dist/cjs/onchain/constants/math.js +11 -0
- package/dist/cjs/onchain/index.js +32 -3
- package/dist/cjs/onchain/validation/checks.js +250 -0
- package/dist/cjs/onchain/validation/index.js +29 -0
- package/dist/cjs/onchain/{accounts/intents → validation}/refusal.js +12 -1
- package/dist/cjs/onchain/validation/token.js +29 -0
- package/dist/cjs/preview/index.js +10 -0
- package/dist/cjs/preview/preview/buildDelayedPreview.js +1 -0
- package/dist/cjs/preview/preview/previewAdjustCreditAccount.js +1 -0
- package/dist/cjs/preview/preview/previewOpenCreditAccount.js +1 -0
- package/dist/cjs/preview/validate/checkOperation.js +173 -0
- package/dist/cjs/preview/validate/checkSimulation.js +52 -0
- package/dist/cjs/preview/validate/index.js +6 -0
- package/dist/cjs/sdk/index.js +4 -0
- package/dist/cjs/sdk/prepare/PrepareApi.js +17 -13
- package/dist/cjs/sdk/prepare/index.js +4 -0
- package/dist/cjs/sdk/prepare/types.js +4 -0
- package/dist/esm/common-utils/index.js +2 -11
- package/dist/esm/common-utils/test-utils/index.js +4 -3
- package/dist/esm/common-utils/utils/index.js +2 -12
- package/dist/esm/common-utils/utils/strategies/index.js +2 -1
- package/dist/esm/common-utils/utils/strategies/strategy-info/cm-availability-condition.js +5 -5
- package/dist/esm/common-utils/utils/strategies/strategy-info/credit-manager-issues.js +133 -0
- package/dist/esm/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +12 -23
- package/dist/esm/common-utils/utils/strategies/strategy-info/index.js +2 -1
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/onchain/accounts/index.js +2 -2
- package/dist/esm/onchain/accounts/intents/guards.js +55 -50
- package/dist/esm/onchain/accounts/intents/index.js +5 -5
- package/dist/esm/onchain/accounts/intents/math.js +14 -21
- package/dist/esm/onchain/accounts/intents/open-strategy.js +4 -4
- package/dist/esm/onchain/accounts/intents/plan.js +15 -29
- package/dist/esm/onchain/accounts/intents/realize.js +12 -19
- package/dist/esm/onchain/accounts/intents/tail.js +1 -1
- package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/esm/onchain/accounts/intents/view.js +1 -0
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/onchain/base/TokensMeta.js +3 -3
- package/dist/esm/onchain/chain/detectNetwork.js +1 -1
- package/dist/esm/onchain/constants/index.js +2 -2
- package/dist/esm/onchain/constants/math.js +11 -1
- package/dist/esm/onchain/core/createAddressProvider.js +1 -1
- package/dist/esm/onchain/index.js +7 -3
- package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/onchain/pools/PoolService.js +1 -1
- package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/onchain/validation/checks.js +230 -0
- package/dist/esm/onchain/validation/index.js +4 -0
- package/dist/esm/onchain/{accounts/intents → validation}/refusal.js +12 -2
- package/dist/esm/onchain/validation/token.js +27 -0
- package/dist/esm/preview/index.js +5 -1
- package/dist/esm/preview/preview/buildDelayedPreview.js +1 -0
- package/dist/esm/preview/preview/previewAdjustCreditAccount.js +1 -0
- package/dist/esm/preview/preview/previewOpenCreditAccount.js +1 -0
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/preview/validate/checkOperation.js +171 -0
- package/dist/esm/preview/validate/checkSimulation.js +51 -0
- package/dist/esm/preview/validate/index.js +3 -0
- package/dist/esm/sdk/index.js +2 -1
- package/dist/esm/sdk/prepare/PrepareApi.js +15 -11
- package/dist/esm/sdk/prepare/index.js +2 -1
- package/dist/esm/sdk/prepare/types.js +2 -1
- package/dist/types/common-utils/index.d.ts +2 -12
- package/dist/types/common-utils/utils/index.d.ts +2 -13
- package/dist/types/common-utils/utils/strategies/index.d.ts +2 -1
- package/dist/types/common-utils/utils/strategies/strategy-info/credit-manager-issues.d.ts +34 -0
- package/dist/types/common-utils/utils/strategies/strategy-info/index.d.ts +2 -1
- package/dist/types/model/previews.d.ts +22 -0
- package/dist/types/onchain/accounts/index.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/guards.d.ts +8 -4
- package/dist/types/onchain/accounts/intents/index.d.ts +4 -3
- package/dist/types/onchain/accounts/intents/math.d.ts +2 -1
- package/dist/types/onchain/accounts/intents/plan.d.ts +3 -0
- package/dist/types/onchain/accounts/intents/types.d.ts +7 -1
- package/dist/types/onchain/constants/index.d.ts +2 -2
- package/dist/types/onchain/constants/math.d.ts +9 -1
- package/dist/types/onchain/index.d.ts +7 -3
- package/dist/types/onchain/validation/checks.d.ts +167 -0
- package/dist/types/onchain/validation/index.d.ts +4 -0
- package/dist/types/onchain/{accounts/intents → validation}/refusal.d.ts +100 -31
- package/dist/types/onchain/validation/token.d.ts +17 -0
- package/dist/types/preview/index.d.ts +5 -1
- package/dist/types/preview/validate/checkOperation.d.ts +46 -0
- package/dist/types/preview/validate/checkSimulation.d.ts +34 -0
- package/dist/types/preview/validate/index.d.ts +3 -0
- package/dist/types/sdk/index.d.ts +2 -2
- package/dist/types/sdk/prepare/index.d.ts +2 -2
- package/dist/types/sdk/prepare/types.d.ts +2 -2
- package/package.json +1 -1
- package/dist/cjs/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.spec.js +0 -267
- package/dist/cjs/common-utils/utils/validation/index.js +0 -23
- package/dist/cjs/common-utils/utils/validation/is-zero-balance.js +0 -7
- package/dist/cjs/common-utils/utils/validation/validate-balance.js +0 -22
- package/dist/cjs/common-utils/utils/validation/validate-balance.spec.js +0 -54
- package/dist/cjs/common-utils/utils/validation/validate-balances.js +0 -17
- package/dist/cjs/common-utils/utils/validation/validate-balances.spec.js +0 -45
- package/dist/cjs/common-utils/utils/validation/validate-credit-manager.js +0 -8
- package/dist/cjs/common-utils/utils/validation/validate-credit-manager.spec.js +0 -36
- package/dist/cjs/common-utils/utils/validation/validate-hf.js +0 -10
- package/dist/cjs/common-utils/utils/validation/validate-hf.spec.js +0 -26
- package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-quota-status.js +0 -14
- package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-quota-status.spec.js +0 -29
- package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-status.js +0 -37
- package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-status.spec.js +0 -98
- package/dist/cjs/common-utils/utils/validation/validate-open-account.js +0 -18
- package/dist/cjs/common-utils/utils/validation/validate-open-account.spec.js +0 -56
- package/dist/cjs/common-utils/utils/validation/validate-quota.js +0 -23
- package/dist/cjs/common-utils/utils/validation/validate-quota.spec.js +0 -88
- package/dist/cjs/common-utils/utils/validation/validate-token-to-obtain.js +0 -18
- package/dist/cjs/common-utils/utils/validation/validate-token-to-obtain.spec.js +0 -36
- package/dist/cjs/common-utils/utils/validation/validation-types.js +0 -1
- package/dist/esm/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.spec.js +0 -264
- package/dist/esm/common-utils/utils/validation/index.js +0 -12
- package/dist/esm/common-utils/utils/validation/is-zero-balance.js +0 -6
- package/dist/esm/common-utils/utils/validation/validate-balance.js +0 -21
- package/dist/esm/common-utils/utils/validation/validate-balance.spec.js +0 -54
- package/dist/esm/common-utils/utils/validation/validate-balances.js +0 -16
- package/dist/esm/common-utils/utils/validation/validate-balances.spec.js +0 -45
- package/dist/esm/common-utils/utils/validation/validate-credit-manager.js +0 -7
- package/dist/esm/common-utils/utils/validation/validate-credit-manager.spec.js +0 -36
- package/dist/esm/common-utils/utils/validation/validate-hf.js +0 -8
- package/dist/esm/common-utils/utils/validation/validate-hf.spec.js +0 -26
- package/dist/esm/common-utils/utils/validation/validate-open-account-pool-quota-status.js +0 -13
- package/dist/esm/common-utils/utils/validation/validate-open-account-pool-quota-status.spec.js +0 -29
- package/dist/esm/common-utils/utils/validation/validate-open-account-pool-status.js +0 -36
- package/dist/esm/common-utils/utils/validation/validate-open-account-pool-status.spec.js +0 -98
- package/dist/esm/common-utils/utils/validation/validate-open-account.js +0 -17
- package/dist/esm/common-utils/utils/validation/validate-open-account.spec.js +0 -56
- package/dist/esm/common-utils/utils/validation/validate-quota.js +0 -22
- package/dist/esm/common-utils/utils/validation/validate-quota.spec.js +0 -88
- package/dist/esm/common-utils/utils/validation/validate-token-to-obtain.js +0 -17
- package/dist/esm/common-utils/utils/validation/validate-token-to-obtain.spec.js +0 -36
- package/dist/esm/common-utils/utils/validation/validation-types.js +0 -1
- package/dist/types/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.spec.d.ts +0 -1
- package/dist/types/common-utils/utils/validation/index.d.ts +0 -12
- package/dist/types/common-utils/utils/validation/is-zero-balance.d.ts +0 -4
- package/dist/types/common-utils/utils/validation/validate-balance.d.ts +0 -25
- package/dist/types/common-utils/utils/validation/validate-balance.spec.d.ts +0 -1
- package/dist/types/common-utils/utils/validation/validate-balances.d.ts +0 -13
- package/dist/types/common-utils/utils/validation/validate-balances.spec.d.ts +0 -1
- package/dist/types/common-utils/utils/validation/validate-credit-manager.d.ts +0 -13
- package/dist/types/common-utils/utils/validation/validate-credit-manager.spec.d.ts +0 -1
- package/dist/types/common-utils/utils/validation/validate-hf.d.ts +0 -12
- package/dist/types/common-utils/utils/validation/validate-hf.spec.d.ts +0 -1
- package/dist/types/common-utils/utils/validation/validate-open-account-pool-quota-status.d.ts +0 -10
- package/dist/types/common-utils/utils/validation/validate-open-account-pool-quota-status.spec.d.ts +0 -1
- package/dist/types/common-utils/utils/validation/validate-open-account-pool-status.d.ts +0 -26
- package/dist/types/common-utils/utils/validation/validate-open-account-pool-status.spec.d.ts +0 -1
- package/dist/types/common-utils/utils/validation/validate-open-account.d.ts +0 -25
- package/dist/types/common-utils/utils/validation/validate-open-account.spec.d.ts +0 -1
- package/dist/types/common-utils/utils/validation/validate-quota.d.ts +0 -24
- package/dist/types/common-utils/utils/validation/validate-quota.spec.d.ts +0 -1
- package/dist/types/common-utils/utils/validation/validate-token-to-obtain.d.ts +0 -17
- package/dist/types/common-utils/utils/validation/validate-token-to-obtain.spec.d.ts +0 -1
- package/dist/types/common-utils/utils/validation/validation-types.d.ts +0 -10
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { validateBalance } from "./validate-balance.js";
|
|
2
|
-
import { mockToken1 } from "../../test-utils/index.js";
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
4
|
-
//#region src/common-utils/utils/validation/validate-balance.spec.ts
|
|
5
|
-
describe("validateBalance", () => {
|
|
6
|
-
it("returns null when all conditions are met", () => {
|
|
7
|
-
const result = validateBalance({
|
|
8
|
-
amount: 1000n,
|
|
9
|
-
tokenAddress: mockToken1,
|
|
10
|
-
maxAmount: 2000n,
|
|
11
|
-
zeroCheck: true,
|
|
12
|
-
single: false
|
|
13
|
-
});
|
|
14
|
-
expect(result).toBeNull();
|
|
15
|
-
});
|
|
16
|
-
it("returns error when amount exceeds maxAmount", () => {
|
|
17
|
-
const result = validateBalance({
|
|
18
|
-
amount: 3000n,
|
|
19
|
-
tokenAddress: mockToken1,
|
|
20
|
-
maxAmount: 2000n,
|
|
21
|
-
zeroCheck: true,
|
|
22
|
-
single: false
|
|
23
|
-
});
|
|
24
|
-
expect(result).toEqual({
|
|
25
|
-
message: "insufficientFunds",
|
|
26
|
-
token: mockToken1
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
it("returns error when amount is too small with zeroCheck", () => {
|
|
30
|
-
const result = validateBalance({
|
|
31
|
-
amount: 5n,
|
|
32
|
-
tokenAddress: mockToken1,
|
|
33
|
-
maxAmount: 2000n,
|
|
34
|
-
zeroCheck: true,
|
|
35
|
-
single: false
|
|
36
|
-
});
|
|
37
|
-
expect(result).toEqual({
|
|
38
|
-
message: "zeroBalance",
|
|
39
|
-
token: mockToken1
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
it("returns null when zeroCheck is false and amount is small", () => {
|
|
43
|
-
const result = validateBalance({
|
|
44
|
-
amount: 5n,
|
|
45
|
-
tokenAddress: mockToken1,
|
|
46
|
-
maxAmount: 2000n,
|
|
47
|
-
zeroCheck: false,
|
|
48
|
-
single: false
|
|
49
|
-
});
|
|
50
|
-
expect(result).toBeNull();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
//#endregion
|
|
54
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { validateBalance } from "./validate-balance.js";
|
|
2
|
-
//#region src/common-utils/utils/validation/validate-balances.ts
|
|
3
|
-
function validateBalances({ balances, assets, zeroCheck = true }) {
|
|
4
|
-
for (const { token: tokenAddress, balance: amount } of assets) {
|
|
5
|
-
const e = validateBalance({
|
|
6
|
-
tokenAddress,
|
|
7
|
-
amount,
|
|
8
|
-
maxAmount: balances[(tokenAddress || "").toLowerCase()] || 0n,
|
|
9
|
-
zeroCheck
|
|
10
|
-
});
|
|
11
|
-
if (e !== null) return e;
|
|
12
|
-
}
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
|
-
export { validateBalances };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { validateBalances } from "./validate-balances.js";
|
|
2
|
-
import { mockToken1, mockToken2 } from "../../test-utils/index.js";
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
4
|
-
//#region src/common-utils/utils/validation/validate-balances.spec.ts
|
|
5
|
-
describe("validateBalances", () => {
|
|
6
|
-
it("returns null when all balances are valid", () => {
|
|
7
|
-
const result = validateBalances({
|
|
8
|
-
balances: {
|
|
9
|
-
[mockToken1]: 2000n,
|
|
10
|
-
[mockToken2]: 3000n
|
|
11
|
-
},
|
|
12
|
-
assets: [{
|
|
13
|
-
token: mockToken1,
|
|
14
|
-
balance: 1000n
|
|
15
|
-
}, {
|
|
16
|
-
token: mockToken2,
|
|
17
|
-
balance: 2000n
|
|
18
|
-
}],
|
|
19
|
-
zeroCheck: true
|
|
20
|
-
});
|
|
21
|
-
expect(result).toBeNull();
|
|
22
|
-
});
|
|
23
|
-
it("returns error when any balance is invalid", () => {
|
|
24
|
-
const result = validateBalances({
|
|
25
|
-
balances: {
|
|
26
|
-
[mockToken1]: 500n,
|
|
27
|
-
[mockToken2]: 3000n
|
|
28
|
-
},
|
|
29
|
-
assets: [{
|
|
30
|
-
token: mockToken1,
|
|
31
|
-
balance: 1000n
|
|
32
|
-
}, {
|
|
33
|
-
token: mockToken2,
|
|
34
|
-
balance: 2000n
|
|
35
|
-
}],
|
|
36
|
-
zeroCheck: true
|
|
37
|
-
});
|
|
38
|
-
expect(result).toEqual({
|
|
39
|
-
message: "insufficientFunds",
|
|
40
|
-
token: mockToken1
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
//#endregion
|
|
45
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
//#region src/common-utils/utils/validation/validate-credit-manager.ts
|
|
2
|
-
function validateCreditManager({ creditManager, allowPausedCm }) {
|
|
3
|
-
if (creditManager.isPaused && !allowPausedCm) return { message: "paused" };
|
|
4
|
-
return null;
|
|
5
|
-
}
|
|
6
|
-
//#endregion
|
|
7
|
-
export { validateCreditManager };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { validateCreditManager } from "./validate-credit-manager.js";
|
|
2
|
-
import { buildCreditManager } from "../../test-utils/index.js";
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
4
|
-
//#region src/common-utils/utils/validation/validate-credit-manager.spec.ts
|
|
5
|
-
const mockCreditManager = buildCreditManager({ isPaused: false });
|
|
6
|
-
describe("validateCreditManager", () => {
|
|
7
|
-
it("returns null when credit manager is not paused", () => {
|
|
8
|
-
const result = validateCreditManager({
|
|
9
|
-
creditManager: mockCreditManager,
|
|
10
|
-
allowPausedCm: false
|
|
11
|
-
});
|
|
12
|
-
expect(result).toBeNull();
|
|
13
|
-
});
|
|
14
|
-
it("returns null when credit manager is paused but allowed", () => {
|
|
15
|
-
const result = validateCreditManager({
|
|
16
|
-
creditManager: buildCreditManager({
|
|
17
|
-
...mockCreditManager,
|
|
18
|
-
isPaused: true
|
|
19
|
-
}),
|
|
20
|
-
allowPausedCm: true
|
|
21
|
-
});
|
|
22
|
-
expect(result).toBeNull();
|
|
23
|
-
});
|
|
24
|
-
it("returns error when credit manager is paused and not allowed", () => {
|
|
25
|
-
const result = validateCreditManager({
|
|
26
|
-
creditManager: buildCreditManager({
|
|
27
|
-
...mockCreditManager,
|
|
28
|
-
isPaused: true
|
|
29
|
-
}),
|
|
30
|
-
allowPausedCm: false
|
|
31
|
-
});
|
|
32
|
-
expect(result).toEqual({ message: "paused" });
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
//#endregion
|
|
36
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
//#region src/common-utils/utils/validation/validate-hf.ts
|
|
2
|
-
const MIN_HF_LIMITED = 10100n;
|
|
3
|
-
function validateHF({ hf, hfCheck = true }) {
|
|
4
|
-
if (hfCheck && (hf === void 0 || hf <= 10100n)) return { message: "hfTooLow" };
|
|
5
|
-
return null;
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
8
|
-
export { MIN_HF_LIMITED, validateHF };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { MIN_HF_LIMITED, validateHF } from "./validate-hf.js";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
//#region src/common-utils/utils/validation/validate-hf.spec.ts
|
|
4
|
-
describe("validateHF", () => {
|
|
5
|
-
it("returns null when HF is above minimum", () => {
|
|
6
|
-
const result = validateHF({ hf: 15e3 });
|
|
7
|
-
expect(result).toBeNull();
|
|
8
|
-
});
|
|
9
|
-
it("returns error when HF is undefined", () => {
|
|
10
|
-
const result = validateHF({ hf: void 0 });
|
|
11
|
-
expect(result).toEqual({ message: "hfTooLow" });
|
|
12
|
-
});
|
|
13
|
-
it("returns error when HF is too low", () => {
|
|
14
|
-
const result = validateHF({ hf: Number(MIN_HF_LIMITED) });
|
|
15
|
-
expect(result).toEqual({ message: "hfTooLow" });
|
|
16
|
-
});
|
|
17
|
-
it("returns null when hfCheck is false and HF is too low", () => {
|
|
18
|
-
const result = validateHF({
|
|
19
|
-
hf: Number(MIN_HF_LIMITED - 1n),
|
|
20
|
-
hfCheck: false
|
|
21
|
-
});
|
|
22
|
-
expect(result).toBeNull();
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
//#endregion
|
|
26
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//#region src/common-utils/utils/validation/validate-open-account-pool-quota-status.ts
|
|
2
|
-
function validateOpenAccountPoolQuotaStatus(targetToken, creditManager, amountToBorrow) {
|
|
3
|
-
const quota = creditManager.quotas[targetToken];
|
|
4
|
-
if (quota) {
|
|
5
|
-
if ((quota.isActive ? quota.limit : 0n) - quota.totalQuoted < amountToBorrow) return {
|
|
6
|
-
message: "insufficientQuota",
|
|
7
|
-
token: targetToken
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
export { validateOpenAccountPoolQuotaStatus };
|
package/dist/esm/common-utils/utils/validation/validate-open-account-pool-quota-status.spec.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { validateOpenAccountPoolQuotaStatus } from "./validate-open-account-pool-quota-status.js";
|
|
2
|
-
import { buildCreditManager, buildQuota, mockToken1 } from "../../test-utils/index.js";
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
4
|
-
//#region src/common-utils/utils/validation/validate-open-account-pool-quota-status.spec.ts
|
|
5
|
-
const mockCreditManager = buildCreditManager({ quotas: { [mockToken1]: buildQuota({
|
|
6
|
-
token: mockToken1,
|
|
7
|
-
limit: 1000000n,
|
|
8
|
-
totalQuoted: 500000n,
|
|
9
|
-
rate: 0n
|
|
10
|
-
}) } });
|
|
11
|
-
describe("validateOpenAccountPoolQuotaStatus", () => {
|
|
12
|
-
it("returns null when quota is sufficient", () => {
|
|
13
|
-
const result = validateOpenAccountPoolQuotaStatus(mockToken1, mockCreditManager, 100000n);
|
|
14
|
-
expect(result).toBeNull();
|
|
15
|
-
});
|
|
16
|
-
it("returns error when quota is insufficient", () => {
|
|
17
|
-
const result = validateOpenAccountPoolQuotaStatus(mockToken1, mockCreditManager, 600000n);
|
|
18
|
-
expect(result).toEqual({
|
|
19
|
-
message: "insufficientQuota",
|
|
20
|
-
token: mockToken1
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
it("returns null when token has no quota", () => {
|
|
24
|
-
const result = validateOpenAccountPoolQuotaStatus("0x9999999999999999999999999999999999999999", mockCreditManager, 100000n);
|
|
25
|
-
expect(result).toBeNull();
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
//#endregion
|
|
29
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { BigIntMath } from "../../../onchain/utils/bigint-math.js";
|
|
2
|
-
import { validateOpenAccountPoolQuotaStatus } from "./validate-open-account-pool-quota-status.js";
|
|
3
|
-
//#region src/common-utils/utils/validation/validate-open-account-pool-status.ts
|
|
4
|
-
function validateOpenAccountPoolStatus(props) {
|
|
5
|
-
const { debt, creditManager, pool, targetToken } = props;
|
|
6
|
-
const effectiveDebt = BigIntMath.max(creditManager.minDebt, debt);
|
|
7
|
-
const hasDebtLimit = creditManager.totalDebtLimit >= 0n;
|
|
8
|
-
const debtLimitLeft = BigIntMath.max(creditManager.totalDebtLimit - creditManager.totalDebt, 0n);
|
|
9
|
-
const { totalDebtLimit = 0n, totalBorrowed = 0n } = pool || {};
|
|
10
|
-
const hasPoolDebtLimit = totalDebtLimit > 0n;
|
|
11
|
-
const poolDebtLimitLeft = totalDebtLimit - totalBorrowed;
|
|
12
|
-
const canOpenMinDebt = creditManager.minDebt <= debtLimitLeft && creditManager.minDebt <= poolDebtLimitLeft && creditManager.minDebt <= creditManager.availableToBorrow;
|
|
13
|
-
const minPositionSize = BigIntMath.min(BigIntMath.min(debtLimitLeft, poolDebtLimitLeft), creditManager.availableToBorrow);
|
|
14
|
-
if (hasDebtLimit && effectiveDebt > debtLimitLeft) return {
|
|
15
|
-
message: "insufficientDebtLimit",
|
|
16
|
-
amount: debtLimitLeft,
|
|
17
|
-
solutionAmount: canOpenMinDebt ? minPositionSize : void 0
|
|
18
|
-
};
|
|
19
|
-
if (hasPoolDebtLimit && effectiveDebt > poolDebtLimitLeft) return {
|
|
20
|
-
message: "insufficientPoolDebtLimit",
|
|
21
|
-
amount: poolDebtLimitLeft,
|
|
22
|
-
solutionAmount: canOpenMinDebt ? minPositionSize : void 0
|
|
23
|
-
};
|
|
24
|
-
if (effectiveDebt > creditManager.availableToBorrow) return {
|
|
25
|
-
message: "insufficientPoolLiquidity",
|
|
26
|
-
amount: creditManager.availableToBorrow,
|
|
27
|
-
solutionAmount: canOpenMinDebt ? minPositionSize : void 0
|
|
28
|
-
};
|
|
29
|
-
if (targetToken !== null) {
|
|
30
|
-
const quotaError = validateOpenAccountPoolQuotaStatus(targetToken, creditManager, effectiveDebt);
|
|
31
|
-
if (quotaError) return quotaError;
|
|
32
|
-
}
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
export { validateOpenAccountPoolStatus };
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { validateOpenAccountPoolStatus } from "./validate-open-account-pool-status.js";
|
|
2
|
-
import { buildCreditManager, buildPool, buildQuota, mockToken1 } from "../../test-utils/index.js";
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
4
|
-
//#region src/common-utils/utils/validation/validate-open-account-pool-status.spec.ts
|
|
5
|
-
const mockCreditManager = buildCreditManager({
|
|
6
|
-
minDebt: 1000n,
|
|
7
|
-
maxDebt: 1000000n,
|
|
8
|
-
totalDebtLimit: 5000000n,
|
|
9
|
-
totalDebt: 2000000n,
|
|
10
|
-
availableToBorrow: 3000000n,
|
|
11
|
-
quotas: { [mockToken1]: buildQuota({
|
|
12
|
-
token: mockToken1,
|
|
13
|
-
limit: 1000000n,
|
|
14
|
-
totalQuoted: 500000n,
|
|
15
|
-
rate: 0n
|
|
16
|
-
}) }
|
|
17
|
-
});
|
|
18
|
-
const mockPool = buildPool({
|
|
19
|
-
totalDebtLimit: 10000000n,
|
|
20
|
-
totalBorrowed: 5000000n
|
|
21
|
-
});
|
|
22
|
-
describe("validateOpenAccountPoolStatus", () => {
|
|
23
|
-
it("returns null when all conditions are met", () => {
|
|
24
|
-
const result = validateOpenAccountPoolStatus({
|
|
25
|
-
debt: 50000n,
|
|
26
|
-
creditManager: mockCreditManager,
|
|
27
|
-
pool: mockPool,
|
|
28
|
-
targetToken: mockToken1
|
|
29
|
-
});
|
|
30
|
-
expect(result).toBeNull();
|
|
31
|
-
});
|
|
32
|
-
it("returns error when debt exceeds debt limit", () => {
|
|
33
|
-
const result = validateOpenAccountPoolStatus({
|
|
34
|
-
debt: 4000000n,
|
|
35
|
-
creditManager: mockCreditManager,
|
|
36
|
-
pool: mockPool,
|
|
37
|
-
targetToken: mockToken1
|
|
38
|
-
});
|
|
39
|
-
expect(result).toEqual({
|
|
40
|
-
message: "insufficientDebtLimit",
|
|
41
|
-
amount: 3000000n,
|
|
42
|
-
solutionAmount: 3000000n
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
it("returns error when debt exceeds pool debt limit", () => {
|
|
46
|
-
const result = validateOpenAccountPoolStatus({
|
|
47
|
-
debt: 6000000n,
|
|
48
|
-
creditManager: buildCreditManager({
|
|
49
|
-
...mockCreditManager,
|
|
50
|
-
totalDebtLimit: -1n
|
|
51
|
-
}),
|
|
52
|
-
pool: mockPool,
|
|
53
|
-
targetToken: mockToken1
|
|
54
|
-
});
|
|
55
|
-
expect(result).toEqual({
|
|
56
|
-
message: "insufficientPoolDebtLimit",
|
|
57
|
-
amount: 5000000n
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
it("returns error when debt exceeds available liquidity", () => {
|
|
61
|
-
const result = validateOpenAccountPoolStatus({
|
|
62
|
-
debt: 4000000n,
|
|
63
|
-
creditManager: buildCreditManager({
|
|
64
|
-
...mockCreditManager,
|
|
65
|
-
totalDebtLimit: -1n
|
|
66
|
-
}),
|
|
67
|
-
pool: buildPool({ totalDebtLimit: -1n }),
|
|
68
|
-
targetToken: mockToken1
|
|
69
|
-
});
|
|
70
|
-
expect(result).toEqual({
|
|
71
|
-
message: "insufficientPoolLiquidity",
|
|
72
|
-
amount: 3000000n
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
it("returns error when quota is insufficient", () => {
|
|
76
|
-
const result = validateOpenAccountPoolStatus({
|
|
77
|
-
debt: 600000n,
|
|
78
|
-
creditManager: mockCreditManager,
|
|
79
|
-
pool: mockPool,
|
|
80
|
-
targetToken: mockToken1
|
|
81
|
-
});
|
|
82
|
-
expect(result).toEqual({
|
|
83
|
-
message: "insufficientQuota",
|
|
84
|
-
token: mockToken1
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
it("returns null when targetToken is null", () => {
|
|
88
|
-
const result = validateOpenAccountPoolStatus({
|
|
89
|
-
debt: 50000n,
|
|
90
|
-
creditManager: mockCreditManager,
|
|
91
|
-
pool: mockPool,
|
|
92
|
-
targetToken: null
|
|
93
|
-
});
|
|
94
|
-
expect(result).toBeNull();
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
//#endregion
|
|
98
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { validateQuota } from "./validate-quota.js";
|
|
2
|
-
//#region src/common-utils/utils/validation/validate-open-account.ts
|
|
3
|
-
function validateOpenAccount(props) {
|
|
4
|
-
const { debt, creditManager, loading } = props;
|
|
5
|
-
if (loading) return { message: "loading" };
|
|
6
|
-
if (debt < creditManager.minDebt) return {
|
|
7
|
-
message: "amountLessMin",
|
|
8
|
-
amount: creditManager.minDebt
|
|
9
|
-
};
|
|
10
|
-
if (debt > creditManager.maxDebt) return {
|
|
11
|
-
message: "debtGreaterMax",
|
|
12
|
-
amount: creditManager.maxDebt
|
|
13
|
-
};
|
|
14
|
-
return validateQuota(props);
|
|
15
|
-
}
|
|
16
|
-
//#endregion
|
|
17
|
-
export { validateOpenAccount };
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { validateOpenAccount } from "./validate-open-account.js";
|
|
2
|
-
import { buildCreditManager, mockUnderlyingToken } from "../../test-utils/index.js";
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
4
|
-
//#region src/common-utils/utils/validation/validate-open-account.spec.ts
|
|
5
|
-
const mockCreditManager = buildCreditManager({
|
|
6
|
-
minDebt: 1000n,
|
|
7
|
-
maxDebt: 1000000n,
|
|
8
|
-
underlyingToken: mockUnderlyingToken
|
|
9
|
-
});
|
|
10
|
-
describe("validateOpenAccount", () => {
|
|
11
|
-
it("returns null when all conditions are met", () => {
|
|
12
|
-
const result = validateOpenAccount({
|
|
13
|
-
debt: 50000n,
|
|
14
|
-
creditManager: mockCreditManager,
|
|
15
|
-
desiredQuota: {},
|
|
16
|
-
quotaUpdate: []
|
|
17
|
-
});
|
|
18
|
-
expect(result).toBeNull();
|
|
19
|
-
});
|
|
20
|
-
it("returns loading error when loading is true", () => {
|
|
21
|
-
const result = validateOpenAccount({
|
|
22
|
-
debt: 50000n,
|
|
23
|
-
creditManager: mockCreditManager,
|
|
24
|
-
desiredQuota: {},
|
|
25
|
-
quotaUpdate: [],
|
|
26
|
-
loading: true
|
|
27
|
-
});
|
|
28
|
-
expect(result).toEqual({ message: "loading" });
|
|
29
|
-
});
|
|
30
|
-
it("returns error when debt is less than min", () => {
|
|
31
|
-
const result = validateOpenAccount({
|
|
32
|
-
debt: 500n,
|
|
33
|
-
creditManager: mockCreditManager,
|
|
34
|
-
desiredQuota: {},
|
|
35
|
-
quotaUpdate: []
|
|
36
|
-
});
|
|
37
|
-
expect(result).toEqual({
|
|
38
|
-
message: "amountLessMin",
|
|
39
|
-
amount: 1000n
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
it("returns error when debt is greater than max", () => {
|
|
43
|
-
const result = validateOpenAccount({
|
|
44
|
-
debt: 2000000n,
|
|
45
|
-
creditManager: mockCreditManager,
|
|
46
|
-
desiredQuota: {},
|
|
47
|
-
quotaUpdate: []
|
|
48
|
-
});
|
|
49
|
-
expect(result).toEqual({
|
|
50
|
-
message: "debtGreaterMax",
|
|
51
|
-
amount: 1000000n
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
//#endregion
|
|
56
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//#region src/common-utils/utils/validation/validate-quota.ts
|
|
2
|
-
function validateQuota(props) {
|
|
3
|
-
const desiredQuotasList = Object.values(props.desiredQuota).filter((a) => a.balance > 0n);
|
|
4
|
-
if (desiredQuotasList.length > props.creditManager.maxEnabledTokensLength) return {
|
|
5
|
-
message: "maxQuotasLengthReached",
|
|
6
|
-
count: desiredQuotasList.length,
|
|
7
|
-
max: props.creditManager.maxEnabledTokensLength
|
|
8
|
-
};
|
|
9
|
-
if (props.quotaUpdate.length === 0 && props.throwOnZeroQuotaUpdate) return { message: "quotaShouldBeUpdated" };
|
|
10
|
-
for (const { token, balance: updateBy } of props.quotaUpdate) {
|
|
11
|
-
const quota = props.creditManager.quotas[token];
|
|
12
|
-
if (updateBy > 0 && quota) {
|
|
13
|
-
if ((quota.isActive ? quota.limit : 0n) - quota.totalQuoted < updateBy) return {
|
|
14
|
-
message: "insufficientQuota",
|
|
15
|
-
token
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { validateQuota };
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { validateQuota } from "./validate-quota.js";
|
|
2
|
-
import { buildCreditManager, buildQuota, mockToken1, mockToken2 } from "../../test-utils/index.js";
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
4
|
-
//#region src/common-utils/utils/validation/validate-quota.spec.ts
|
|
5
|
-
const mockCreditManager = buildCreditManager({
|
|
6
|
-
minDebt: 1000n,
|
|
7
|
-
maxDebt: 1000000n,
|
|
8
|
-
totalDebtLimit: 5000000n,
|
|
9
|
-
totalDebt: 2000000n,
|
|
10
|
-
availableToBorrow: 3000000n,
|
|
11
|
-
quotas: {
|
|
12
|
-
[mockToken1]: buildQuota({
|
|
13
|
-
token: mockToken1,
|
|
14
|
-
limit: 1000000n,
|
|
15
|
-
totalQuoted: 500000n,
|
|
16
|
-
rate: 0n
|
|
17
|
-
}),
|
|
18
|
-
[mockToken2]: buildQuota({
|
|
19
|
-
token: mockToken2,
|
|
20
|
-
limit: 2000000n,
|
|
21
|
-
totalQuoted: 1000000n,
|
|
22
|
-
rate: 0n
|
|
23
|
-
})
|
|
24
|
-
},
|
|
25
|
-
maxEnabledTokensLength: 2
|
|
26
|
-
});
|
|
27
|
-
describe("validateQuota", () => {
|
|
28
|
-
it("returns null when all conditions are met", () => {
|
|
29
|
-
const result = validateQuota({
|
|
30
|
-
desiredQuota: {},
|
|
31
|
-
quotaUpdate: [],
|
|
32
|
-
creditManager: mockCreditManager,
|
|
33
|
-
throwOnZeroQuotaUpdate: false
|
|
34
|
-
});
|
|
35
|
-
expect(result).toBeNull();
|
|
36
|
-
});
|
|
37
|
-
it("returns error when max quotas length is reached", () => {
|
|
38
|
-
const result = validateQuota({
|
|
39
|
-
desiredQuota: {
|
|
40
|
-
[mockToken1]: {
|
|
41
|
-
token: mockToken1,
|
|
42
|
-
balance: 1000n
|
|
43
|
-
},
|
|
44
|
-
[mockToken2]: {
|
|
45
|
-
token: mockToken2,
|
|
46
|
-
balance: 1000n
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
quotaUpdate: [],
|
|
50
|
-
creditManager: buildCreditManager({
|
|
51
|
-
...mockCreditManager,
|
|
52
|
-
maxEnabledTokensLength: 1
|
|
53
|
-
}),
|
|
54
|
-
throwOnZeroQuotaUpdate: false
|
|
55
|
-
});
|
|
56
|
-
expect(result).toEqual({
|
|
57
|
-
message: "maxQuotasLengthReached",
|
|
58
|
-
count: 2,
|
|
59
|
-
max: 1
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
it("returns error when quota update is empty and throwOnZeroQuotaUpdate is true", () => {
|
|
63
|
-
const result = validateQuota({
|
|
64
|
-
desiredQuota: {},
|
|
65
|
-
quotaUpdate: [],
|
|
66
|
-
creditManager: mockCreditManager,
|
|
67
|
-
throwOnZeroQuotaUpdate: true
|
|
68
|
-
});
|
|
69
|
-
expect(result).toEqual({ message: "quotaShouldBeUpdated" });
|
|
70
|
-
});
|
|
71
|
-
it("returns error when quota is insufficient", () => {
|
|
72
|
-
const result = validateQuota({
|
|
73
|
-
desiredQuota: {},
|
|
74
|
-
quotaUpdate: [{
|
|
75
|
-
token: mockToken1,
|
|
76
|
-
balance: 600000n
|
|
77
|
-
}],
|
|
78
|
-
creditManager: mockCreditManager,
|
|
79
|
-
throwOnZeroQuotaUpdate: false
|
|
80
|
-
});
|
|
81
|
-
expect(result).toEqual({
|
|
82
|
-
message: "insufficientQuota",
|
|
83
|
-
token: mockToken1
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
//#endregion
|
|
88
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//#region src/common-utils/utils/validation/validate-token-to-obtain.ts
|
|
2
|
-
function validateTokenToObtain({ creditManager, targetToken }) {
|
|
3
|
-
if (Array.isArray(targetToken)) {
|
|
4
|
-
for (const asset of targetToken) if (creditManager.forbiddenTokens[asset.token]) return {
|
|
5
|
-
message: "tokenIsForbidden",
|
|
6
|
-
token: asset.token
|
|
7
|
-
};
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
if (targetToken !== null && creditManager.forbiddenTokens[targetToken]) return {
|
|
11
|
-
message: "tokenIsForbidden",
|
|
12
|
-
token: targetToken
|
|
13
|
-
};
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
//#endregion
|
|
17
|
-
export { validateTokenToObtain };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { validateTokenToObtain } from "./validate-token-to-obtain.js";
|
|
2
|
-
import { buildCreditManager, mockToken1 } from "../../test-utils/index.js";
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
4
|
-
//#region src/common-utils/utils/validation/validate-token-to-obtain.spec.ts
|
|
5
|
-
const mockCreditManager = buildCreditManager({ forbiddenTokens: {} });
|
|
6
|
-
describe("validateTokenToObtain", () => {
|
|
7
|
-
it("returns null when targetToken is null", () => {
|
|
8
|
-
const result = validateTokenToObtain({
|
|
9
|
-
targetToken: null,
|
|
10
|
-
creditManager: mockCreditManager
|
|
11
|
-
});
|
|
12
|
-
expect(result).toBeNull();
|
|
13
|
-
});
|
|
14
|
-
it("returns null when targetToken is not forbidden", () => {
|
|
15
|
-
const result = validateTokenToObtain({
|
|
16
|
-
targetToken: mockToken1,
|
|
17
|
-
creditManager: mockCreditManager
|
|
18
|
-
});
|
|
19
|
-
expect(result).toBeNull();
|
|
20
|
-
});
|
|
21
|
-
it("returns error when targetToken is forbidden", () => {
|
|
22
|
-
const result = validateTokenToObtain({
|
|
23
|
-
targetToken: mockToken1,
|
|
24
|
-
creditManager: buildCreditManager({
|
|
25
|
-
...mockCreditManager,
|
|
26
|
-
forbiddenTokens: { [mockToken1]: true }
|
|
27
|
-
})
|
|
28
|
-
});
|
|
29
|
-
expect(result).toEqual({
|
|
30
|
-
message: "tokenIsForbidden",
|
|
31
|
-
token: mockToken1
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
//#endregion
|
|
36
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { isZeroBalance } from "./is-zero-balance.js";
|
|
2
|
-
import { ValidateBalanceProps, ValidateBalanceResult, validateBalance } from "./validate-balance.js";
|
|
3
|
-
import { ValidateBalancesProps, validateBalances } from "./validate-balances.js";
|
|
4
|
-
import { ValidateCreditManagerProps, ValidateCreditManagerResult, validateCreditManager } from "./validate-credit-manager.js";
|
|
5
|
-
import { MIN_HF_LIMITED, ValidateHFProps, ValidateHFResult, validateHF } from "./validate-hf.js";
|
|
6
|
-
import { ValidateQuotaProps, ValidateQuotaResult, validateQuota } from "./validate-quota.js";
|
|
7
|
-
import { ValidateOpenAccountProps, ValidateOpenAccountResult, validateOpenAccount } from "./validate-open-account.js";
|
|
8
|
-
import { ValidateOpenAccountPoolQuotaStatusResult, validateOpenAccountPoolQuotaStatus } from "./validate-open-account-pool-quota-status.js";
|
|
9
|
-
import { ValidateOpenAccountPoolStatusProps, ValidateOpenAccountPoolStatusResult, validateOpenAccountPoolStatus } from "./validate-open-account-pool-status.js";
|
|
10
|
-
import { ValidateTokenToObtainProps, ValidateTokenToObtainResult, validateTokenToObtain } from "./validate-token-to-obtain.js";
|
|
11
|
-
import { FlattenUnion } from "./validation-types.js";
|
|
12
|
-
export { FlattenUnion, MIN_HF_LIMITED, ValidateBalanceProps, ValidateBalanceResult, ValidateBalancesProps, ValidateCreditManagerProps, ValidateCreditManagerResult, ValidateHFProps, ValidateHFResult, ValidateOpenAccountPoolQuotaStatusResult, ValidateOpenAccountPoolStatusProps, ValidateOpenAccountPoolStatusResult, ValidateOpenAccountProps, ValidateOpenAccountResult, ValidateQuotaProps, ValidateQuotaResult, ValidateTokenToObtainProps, ValidateTokenToObtainResult, isZeroBalance, validateBalance, validateBalances, validateCreditManager, validateHF, validateOpenAccount, validateOpenAccountPoolQuotaStatus, validateOpenAccountPoolStatus, validateQuota, validateTokenToObtain };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Address } from "viem";
|
|
2
|
-
//#region src/common-utils/utils/validation/validate-balance.d.ts
|
|
3
|
-
interface ValidateBalanceProps {
|
|
4
|
-
amount: bigint;
|
|
5
|
-
tokenAddress: Address;
|
|
6
|
-
maxAmount: bigint | undefined;
|
|
7
|
-
zeroCheck?: boolean;
|
|
8
|
-
single?: boolean;
|
|
9
|
-
}
|
|
10
|
-
type ValidateBalanceResult = {
|
|
11
|
-
message: "unknownToken";
|
|
12
|
-
token: Address;
|
|
13
|
-
} | {
|
|
14
|
-
message: "insufficientFunds";
|
|
15
|
-
token: Address;
|
|
16
|
-
} | {
|
|
17
|
-
message: "zeroBalance";
|
|
18
|
-
token: Address;
|
|
19
|
-
} | {
|
|
20
|
-
message: "enterAmount";
|
|
21
|
-
token: Address;
|
|
22
|
-
};
|
|
23
|
-
declare function validateBalance({ amount, tokenAddress, maxAmount, zeroCheck, single }: ValidateBalanceProps): ValidateBalanceResult | null;
|
|
24
|
-
//#endregion
|
|
25
|
-
export { ValidateBalanceProps, ValidateBalanceResult, validateBalance };
|