@gearbox-protocol/sdk 14.12.0-next.12 → 14.12.0-next.13
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/preview/parse/parseRWAFactoryOperationCalldata.js +13 -12
- package/dist/cjs/preview/parse/types.js +1 -1
- package/dist/cjs/preview/prerequisites/AllowancePrerequisite.js +10 -16
- package/dist/cjs/preview/prerequisites/BalancePrerequisite.js +17 -33
- package/dist/cjs/preview/prerequisites/Prerequisite.js +13 -18
- package/dist/cjs/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +36 -15
- package/dist/cjs/preview/prerequisites/buildCollateralPrerequisites.js +57 -0
- package/dist/cjs/preview/prerequisites/{prepareAction.js → buildPartialLiquidationPrerequisites.js} +18 -24
- package/dist/cjs/preview/prerequisites/buildPoolPrerequisites.js +125 -0
- package/dist/cjs/preview/prerequisites/buildRWAPrerequisites.js +57 -0
- package/dist/cjs/preview/prerequisites/checkPrerequisites.js +85 -0
- package/dist/cjs/preview/prerequisites/helpers.js +47 -0
- package/dist/cjs/preview/prerequisites/index.js +2 -6
- package/dist/cjs/preview/preview/detectCloseOrRepay.js +51 -0
- package/dist/cjs/preview/preview/index.js +4 -0
- package/dist/cjs/preview/preview/previewCloseOrRepay.js +94 -0
- package/dist/cjs/preview/preview/previewOperation.js +10 -2
- package/dist/cjs/sdk/market/rwa/securitize/SecuritizeRWAFactory.js +26 -4
- package/dist/cjs/sdk/utils/AddressSet.js +7 -0
- package/dist/esm/preview/parse/parseRWAFactoryOperationCalldata.js +13 -12
- package/dist/esm/preview/parse/types.js +1 -1
- package/dist/esm/preview/prerequisites/AllowancePrerequisite.js +11 -20
- package/dist/esm/preview/prerequisites/BalancePrerequisite.js +18 -37
- package/dist/esm/preview/prerequisites/Prerequisite.js +13 -20
- package/dist/esm/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +36 -15
- package/dist/esm/preview/prerequisites/buildCollateralPrerequisites.js +35 -0
- package/dist/esm/preview/prerequisites/buildPartialLiquidationPrerequisites.js +18 -0
- package/dist/esm/preview/prerequisites/buildPoolPrerequisites.js +101 -0
- package/dist/esm/preview/prerequisites/buildRWAPrerequisites.js +33 -0
- package/dist/esm/preview/prerequisites/checkPrerequisites.js +63 -0
- package/dist/esm/preview/prerequisites/helpers.js +23 -0
- package/dist/esm/preview/prerequisites/index.js +1 -3
- package/dist/esm/preview/preview/detectCloseOrRepay.js +26 -0
- package/dist/esm/preview/preview/index.js +2 -0
- package/dist/esm/preview/preview/previewCloseOrRepay.js +76 -0
- package/dist/esm/preview/preview/previewOperation.js +10 -2
- package/dist/esm/sdk/market/rwa/securitize/SecuritizeRWAFactory.js +26 -4
- package/dist/esm/sdk/utils/AddressSet.js +7 -0
- package/dist/types/preview/parse/parseRWAFactoryOperationCalldata.d.ts +1 -1
- package/dist/types/preview/parse/types-rwa.d.ts +11 -23
- package/dist/types/preview/prerequisites/AllowancePrerequisite.d.ts +4 -5
- package/dist/types/preview/prerequisites/BalancePrerequisite.d.ts +4 -6
- package/dist/types/preview/prerequisites/Prerequisite.d.ts +16 -40
- package/dist/types/preview/prerequisites/RWAOpenRequirementsPrerequisite.d.ts +22 -16
- package/dist/types/preview/prerequisites/buildCollateralPrerequisites.d.ts +14 -0
- package/dist/types/preview/prerequisites/buildPartialLiquidationPrerequisites.d.ts +8 -0
- package/dist/types/preview/prerequisites/buildPoolPrerequisites.d.ts +8 -0
- package/dist/types/preview/prerequisites/buildRWAPrerequisites.d.ts +21 -0
- package/dist/types/preview/prerequisites/checkPrerequisites.d.ts +27 -0
- package/dist/types/preview/prerequisites/helpers.d.ts +15 -0
- package/dist/types/preview/prerequisites/index.d.ts +1 -3
- package/dist/types/preview/prerequisites/types.d.ts +21 -2
- package/dist/types/preview/preview/detectCloseOrRepay.d.ts +18 -0
- package/dist/types/preview/preview/index.d.ts +2 -0
- package/dist/types/preview/preview/previewAdjustCreditAccount.d.ts +2 -2
- package/dist/types/preview/preview/previewCloseOrRepay.d.ts +10 -0
- package/dist/types/preview/preview/previewOpenCreditAccount.d.ts +2 -2
- package/dist/types/preview/preview/types.d.ts +60 -3
- package/dist/types/sdk/accounts/types.d.ts +3 -3
- package/dist/types/sdk/market/rwa/securitize/SecuritizeRWAFactory.d.ts +11 -3
- package/dist/types/sdk/market/rwa/securitize/types.d.ts +18 -2
- package/dist/types/sdk/market/rwa/types.d.ts +26 -9
- package/dist/types/sdk/utils/AddressSet.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/preview/prerequisites/buildPrerequisites.js +0 -297
- package/dist/cjs/preview/prerequisites/runPrerequisites.js +0 -71
- package/dist/esm/preview/prerequisites/buildPrerequisites.js +0 -279
- package/dist/esm/preview/prerequisites/prepareAction.js +0 -23
- package/dist/esm/preview/prerequisites/runPrerequisites.js +0 -47
- package/dist/types/preview/prerequisites/buildPrerequisites.d.ts +0 -25
- package/dist/types/preview/prerequisites/prepareAction.d.ts +0 -52
- package/dist/types/preview/prerequisites/runPrerequisites.d.ts +0 -12
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import type { Address
|
|
2
|
-
import type {
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { RWAOperationArgs } from "../../sdk/index.js";
|
|
3
3
|
import { Prerequisite } from "./Prerequisite.js";
|
|
4
|
-
import type { PrerequisiteDetail, PrerequisiteResult } from "./types.js";
|
|
4
|
+
import type { PrerequisiteContext, PrerequisiteDetail, PrerequisiteResult } from "./types.js";
|
|
5
5
|
export interface RWAOpenRequirementsPrerequisiteProps {
|
|
6
|
-
/**
|
|
7
|
-
requirements: RWAOpenAccountRequirements;
|
|
8
|
-
/** RWA token (e.g. Securitize DSToken) the requirements were computed for. */
|
|
6
|
+
/** RWA token (e.g. Securitize DSToken) to check the requirements for. */
|
|
9
7
|
token: Address;
|
|
10
|
-
/**
|
|
8
|
+
/** Credit manager of the RWA market. */
|
|
9
|
+
creditManager: Address;
|
|
10
|
+
/** RWA factory that gates the token. */
|
|
11
11
|
factory: Address;
|
|
12
|
+
/**
|
|
13
|
+
* Factory-specific registration params already carried by the transaction
|
|
14
|
+
* calldata. Passed through to the factory's `getMissingRequirements`: e.g.
|
|
15
|
+
* signatures provided here need not be signed again, since the transaction
|
|
16
|
+
* itself caches them on-chain.
|
|
17
|
+
*/
|
|
18
|
+
providedArgs?: RWAOperationArgs;
|
|
12
19
|
title?: string;
|
|
13
20
|
id?: string;
|
|
14
21
|
}
|
|
@@ -16,12 +23,13 @@ export interface RWAOpenRequirementsPrerequisiteProps {
|
|
|
16
23
|
* Checks that the borrower has fulfilled the RWA factory's open-account
|
|
17
24
|
* requirements (issuer-side token registration, EIP-712 signatures).
|
|
18
25
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
26
|
+
* The requirements are fetched at verify time via
|
|
27
|
+
* `sdk.accounts.getOpenAccountRequirements`, so re-running verification picks
|
|
28
|
+
* up off-chain progress (the borrower registering on the issuer's website or
|
|
29
|
+
* signing the factory's message) without rebuilding the prerequisites. The
|
|
30
|
+
* unfulfilled subset is computed by the factory itself
|
|
31
|
+
* (`IRWAFactory.getMissingRequirements`) and exposed on the result's
|
|
32
|
+
* `detail.missing`; the full requirements are kept on `detail.requirements`.
|
|
25
33
|
*/
|
|
26
34
|
export declare class RWAOpenRequirementsPrerequisite extends Prerequisite<"rwaOpenRequirements"> {
|
|
27
35
|
#private;
|
|
@@ -30,7 +38,5 @@ export declare class RWAOpenRequirementsPrerequisite extends Prerequisite<"rwaOp
|
|
|
30
38
|
get kind(): "rwaOpenRequirements";
|
|
31
39
|
get title(): string;
|
|
32
40
|
get detail(): PrerequisiteDetail<"rwaOpenRequirements">;
|
|
33
|
-
|
|
34
|
-
calls(): ContractFunctionParameters[];
|
|
35
|
-
resolve(): PrerequisiteResult<"rwaOpenRequirements">;
|
|
41
|
+
protected check(ctx: PrerequisiteContext): Promise<PrerequisiteResult<"rwaOpenRequirements">>;
|
|
36
42
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type GetApprovalAddressProps } from "../../sdk/index.js";
|
|
2
|
+
import type { InnerOperation } from "../parse/index.js";
|
|
3
|
+
import type { AnyPrerequisite } from "./Prerequisite.js";
|
|
4
|
+
import type { PrerequisiteContext } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* For every `addCollateral` inside a multicall, requires the wallet to approve
|
|
7
|
+
* and hold the collateral token for the collateral spender.
|
|
8
|
+
*
|
|
9
|
+
* The approval spender is resolved via {@link OnchainSDK.accounts.getApprovalAddress}:
|
|
10
|
+
* the credit manager for classic markets, but a per-investor "special wallet"
|
|
11
|
+
* for RWA markets. The resolution happens at build time because the spender is
|
|
12
|
+
* part of the prerequisite's identity and UI detail.
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildCollateralPrerequisites(spenderOptions: GetApprovalAddressProps, multicall: InnerOperation[], ctx: PrerequisiteContext): Promise<AnyPrerequisite[]>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PartialLiquidationOperation } from "../parse/index.js";
|
|
2
|
+
import type { AnyPrerequisite } from "./Prerequisite.js";
|
|
3
|
+
import type { PrerequisiteContext } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Partial liquidation pulls the repaid underlying from the liquidator: they
|
|
6
|
+
* must have approved it to the credit manager and hold enough of it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildPartialLiquidationPrerequisites(tx: PartialLiquidationOperation, ctx: PrerequisiteContext): AnyPrerequisite[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Address } from "viem";
|
|
2
|
+
import type { PoolOperation } from "../parse/index.js";
|
|
3
|
+
import type { AnyPrerequisite } from "./Prerequisite.js";
|
|
4
|
+
/**
|
|
5
|
+
* Prerequisites for ERC4626 pool operations (deposit, mint, withdraw, redeem),
|
|
6
|
+
* either direct or zapper-routed.
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildPoolPrerequisites(tx: PoolOperation, wallet: Address): AnyPrerequisite[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import { type RWAOperationArgs } from "../../sdk/index.js";
|
|
3
|
+
import type { InnerOperation } from "../parse/index.js";
|
|
4
|
+
import type { AnyPrerequisite } from "./Prerequisite.js";
|
|
5
|
+
import type { PrerequisiteContext } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* For RWA-factory open-account operations (e.g. `RWAOpenCreditAccount`),
|
|
8
|
+
* builds a prerequisite per RWA token the multicall touches; each one checks
|
|
9
|
+
* the factory's open-account requirements (issuer-side token registration,
|
|
10
|
+
* EIP-712 signatures) at verify time.
|
|
11
|
+
*
|
|
12
|
+
* The `providedArgs` params are the registration values decoded from the
|
|
13
|
+
* transaction calldata itself: signatures already included there satisfy the
|
|
14
|
+
* signature requirement, so a fully built transaction is not reported as
|
|
15
|
+
* missing signatures. In the template flow they are empty and the verified
|
|
16
|
+
* result's `detail.missing` describes what is still unfulfilled; acting on it
|
|
17
|
+
* (signing, rebuilding calldata) is up to the consumer.
|
|
18
|
+
*
|
|
19
|
+
* Returns nothing for non-RWA markets.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildRWAPrerequisites(multicall: InnerOperation[], creditManager: Address, providedArgs: RWAOperationArgs, ctx: PrerequisiteContext): AnyPrerequisite[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PluginsMap } from "../../sdk/index.js";
|
|
2
|
+
import { type ParseOperationCalldataInput } from "../parse/parseOperationCalldata.js";
|
|
3
|
+
import type { AnyPrerequisiteResult } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Input of {@link checkPrerequisites}: the same raw-calldata input as the
|
|
6
|
+
* internal calldata parser, plus an optional block to read at.
|
|
7
|
+
*/
|
|
8
|
+
export type CheckPrerequisitesInput<P extends PluginsMap = PluginsMap> = ParseOperationCalldataInput<P> & {
|
|
9
|
+
/** Block to read at; defaults to latest. Only set for testnet forks. */
|
|
10
|
+
blockNumber?: bigint;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Derives and verifies the on-chain prerequisites for an operation given its
|
|
14
|
+
* raw calldata: the conditions that must hold for the call not to revert and
|
|
15
|
+
* that we can verify with the SDK (token approvals, wallet balances, RWA
|
|
16
|
+
* open-account requirements).
|
|
17
|
+
*
|
|
18
|
+
* Each prerequisite performs its own reads and resolves into an
|
|
19
|
+
* {@link AnyPrerequisiteResult} (`satisfied` or `error`).
|
|
20
|
+
*
|
|
21
|
+
* Only *sender-actionable* prerequisites belong here: conditions the LP
|
|
22
|
+
* provider or borrower can fix themselves before retrying (e.g. approve a
|
|
23
|
+
* token, top up a balance, sign the RWA factory's messages). Non-actionable
|
|
24
|
+
* protocol/admin state (e.g. pool is paused) is intentionally out of scope,
|
|
25
|
+
* since the user cannot resolve it.
|
|
26
|
+
*/
|
|
27
|
+
export declare function checkPrerequisites<P extends PluginsMap>(input: CheckPrerequisitesInput<P>): Promise<AnyPrerequisiteResult[]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { AnyPrerequisite } from "./Prerequisite.js";
|
|
3
|
+
export interface AllowanceAndBalanceProps {
|
|
4
|
+
token: Address;
|
|
5
|
+
owner: Address;
|
|
6
|
+
spender: Address;
|
|
7
|
+
required: bigint;
|
|
8
|
+
allowanceTitle: string;
|
|
9
|
+
balanceTitle: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The most common prerequisite pair: `owner` must have approved `spender` for
|
|
13
|
+
* `required` of `token` and must hold at least that much of it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function allowanceAndBalance(props: AllowanceAndBalanceProps): AnyPrerequisite[];
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export * from "./AllowancePrerequisite.js";
|
|
2
2
|
export * from "./BalancePrerequisite.js";
|
|
3
|
-
export * from "./
|
|
3
|
+
export * from "./checkPrerequisites.js";
|
|
4
4
|
export * from "./Prerequisite.js";
|
|
5
|
-
export * from "./prepareAction.js";
|
|
6
5
|
export * from "./RWAOpenRequirementsPrerequisite.js";
|
|
7
|
-
export * from "./runPrerequisites.js";
|
|
8
6
|
export * from "./types.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type { OnchainSDK, RWAOpenAccountRequirements } from "../../sdk/index.js";
|
|
2
|
+
import type { OnchainSDK, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements } from "../../sdk/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Extension point that ties each prerequisite kind to its detail payload.
|
|
5
5
|
*
|
|
@@ -33,7 +33,26 @@ export interface PrerequisiteDetailMap {
|
|
|
33
33
|
* registration and/or EIP-712 signatures the borrower must provide before
|
|
34
34
|
* opening a credit account in an RWA market.
|
|
35
35
|
*/
|
|
36
|
-
rwaOpenRequirements:
|
|
36
|
+
rwaOpenRequirements: {
|
|
37
|
+
/** RWA token (e.g. Securitize DSToken) the requirements are checked for. */
|
|
38
|
+
token: Address;
|
|
39
|
+
/** Credit manager of the RWA market. */
|
|
40
|
+
creditManager: Address;
|
|
41
|
+
/** RWA factory that gates the token. */
|
|
42
|
+
factory: Address;
|
|
43
|
+
/**
|
|
44
|
+
* Full requirements fetched at verify time via
|
|
45
|
+
* `sdk.accounts.getOpenAccountRequirements`; only present when the read
|
|
46
|
+
* succeeded and the factory gates the token.
|
|
47
|
+
*/
|
|
48
|
+
requirements?: RWAOpenAccountRequirements;
|
|
49
|
+
/**
|
|
50
|
+
* Subset of `requirements` still unfulfilled, computed by the RWA
|
|
51
|
+
* factory at verify time (`IRWAFactory.getMissingRequirements`);
|
|
52
|
+
* `undefined` when everything is satisfied.
|
|
53
|
+
*/
|
|
54
|
+
missing?: RWAMissingOpenAccountRequirements;
|
|
55
|
+
};
|
|
37
56
|
}
|
|
38
57
|
export type PrerequisiteKind = keyof PrerequisiteDetailMap;
|
|
39
58
|
export type PrerequisiteDetail<K extends PrerequisiteKind = PrerequisiteKind> = PrerequisiteDetailMap[K];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { InnerOperation } from "../parse/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Detects whether a credit-facade multicall fully closes or repays the
|
|
5
|
+
* account.
|
|
6
|
+
*
|
|
7
|
+
* Note that closing/repaying an account whose debt is already zero emits no
|
|
8
|
+
* `decreaseDebt` call at all and is not detected (previews as an adjustment).
|
|
9
|
+
*/
|
|
10
|
+
export declare function isCloseOrRepay(multicall: InnerOperation[]): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Distinguishes a closure from a repayment by how collateral leaves the
|
|
13
|
+
* account:
|
|
14
|
+
* - close swaps all assets into underlying and withdraws only the underlying
|
|
15
|
+
* - repay returns collateral in-kind: it adds collateral from the wallet to
|
|
16
|
+
* cover the debt and/or withdraws non-underlying tokens.
|
|
17
|
+
*/
|
|
18
|
+
export declare function classifyCloseOrRepay(multicall: InnerOperation[], underlying: Address): "close" | "repay";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from "./applyInnerOperations.js";
|
|
2
|
+
export * from "./detectCloseOrRepay.js";
|
|
2
3
|
export * from "./errors.js";
|
|
3
4
|
export * from "./previewAdjustCreditAccount.js";
|
|
5
|
+
export * from "./previewCloseOrRepay.js";
|
|
4
6
|
export * from "./previewOperation.js";
|
|
5
7
|
export * from "./types.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PluginsMap } from "../../sdk/index.js";
|
|
2
|
-
import type { MulticallOperation,
|
|
2
|
+
import type { MulticallOperation, RWAMulticallOperation } from "../parse/index.js";
|
|
3
3
|
import type { AdjustCreditAccountPreview, PreviewOperationInput, PreviewOperationOptions } from "./types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Previews a `multicall`/`botMulticall` operation on an existing credit
|
|
@@ -8,4 +8,4 @@ import type { AdjustCreditAccountPreview, PreviewOperationInput, PreviewOperatio
|
|
|
8
8
|
* minimal guaranteed post-state alongside the changes relative to the
|
|
9
9
|
* pre-state.
|
|
10
10
|
*/
|
|
11
|
-
export declare function previewAdjustCreditAccount<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: MulticallOperation |
|
|
11
|
+
export declare function previewAdjustCreditAccount<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: MulticallOperation | RWAMulticallOperation, options?: PreviewOperationOptions): Promise<AdjustCreditAccountPreview>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PluginsMap } from "../../sdk/index.js";
|
|
2
|
+
import type { CloseCreditAccountOperation, MulticallOperation, RWAMulticallOperation } from "../parse/index.js";
|
|
3
|
+
import type { OperationPreview, PreviewOperationInput, PreviewOperationOptions } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Any parsed operation that fully closes or repays a credit account: the
|
|
6
|
+
* facade `closeCreditAccount` entry point (permanent closure) or a plain
|
|
7
|
+
* multicall detected by `isCloseOrRepay` (zero-debt closure/repay).
|
|
8
|
+
*/
|
|
9
|
+
export type CloseOrRepayOperation = CloseCreditAccountOperation | MulticallOperation | RWAMulticallOperation;
|
|
10
|
+
export declare function previewCloseOrRepay<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: CloseOrRepayOperation, permanent: boolean, options?: PreviewOperationOptions): Promise<OperationPreview>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type PluginsMap } from "../../sdk/index.js";
|
|
2
|
-
import type { OpenCreditAccountOperation,
|
|
2
|
+
import type { OpenCreditAccountOperation, RWAOpenCreditAccountOperation } from "../parse/index.js";
|
|
3
3
|
import type { OpenCreditAccountPreview, PreviewOperationInput } from "./types.js";
|
|
4
|
-
export declare function previewOpenCreditAccount<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: OpenCreditAccountOperation |
|
|
4
|
+
export declare function previewOpenCreditAccount<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: OpenCreditAccountOperation | RWAOpenCreditAccountOperation): OpenCreditAccountPreview;
|
|
@@ -82,7 +82,7 @@ export interface PoolOperationPreview {
|
|
|
82
82
|
tokenOut: PreviewedAsset;
|
|
83
83
|
}
|
|
84
84
|
export interface OpenCreditAccountPreview {
|
|
85
|
-
operation: "OpenCreditAccount" | "
|
|
85
|
+
operation: "OpenCreditAccount" | "RWAOpenCreditAccount";
|
|
86
86
|
/**
|
|
87
87
|
* Credit manager the account is opened in
|
|
88
88
|
*/
|
|
@@ -170,8 +170,65 @@ export interface AdjustCreditAccountPreview {
|
|
|
170
170
|
*/
|
|
171
171
|
assetsChange: Asset[];
|
|
172
172
|
}
|
|
173
|
+
export interface CloseCreditAccountPreview {
|
|
174
|
+
operation: "CloseCreditAccount";
|
|
175
|
+
/**
|
|
176
|
+
* True when the account is closed permanently (facade `closeCreditAccount`
|
|
177
|
+
* entry point), false when the debt is zeroed but the account stays open
|
|
178
|
+
* (plain multicall).
|
|
179
|
+
*/
|
|
180
|
+
permanent: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Credit manager the account belongs to
|
|
183
|
+
*/
|
|
184
|
+
creditManager: Address;
|
|
185
|
+
/**
|
|
186
|
+
* Credit account that is being closed
|
|
187
|
+
*/
|
|
188
|
+
creditAccount: Address;
|
|
189
|
+
/**
|
|
190
|
+
* Underlying withdrawn to the user: minimal guaranteed amount, from the
|
|
191
|
+
* multicall replay (all collateral is swapped into underlying before
|
|
192
|
+
* withdrawal)
|
|
193
|
+
*/
|
|
194
|
+
receivedAmount: bigint;
|
|
195
|
+
}
|
|
196
|
+
export interface RepayCreditAccountPreview {
|
|
197
|
+
operation: "RepayCreditAccount";
|
|
198
|
+
/**
|
|
199
|
+
* True when the account is closed permanently (facade `closeCreditAccount`
|
|
200
|
+
* entry point), false when the debt is zeroed but the account stays open
|
|
201
|
+
* (plain multicall).
|
|
202
|
+
*/
|
|
203
|
+
permanent: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Credit manager the account belongs to
|
|
206
|
+
*/
|
|
207
|
+
creditManager: Address;
|
|
208
|
+
/**
|
|
209
|
+
* Credit account that is being repaid
|
|
210
|
+
*/
|
|
211
|
+
creditAccount: Address;
|
|
212
|
+
/**
|
|
213
|
+
* Tokens added from the wallet to cover the debt (`addCollateral` calls).
|
|
214
|
+
*
|
|
215
|
+
* When the transaction has native value attached, it is represented as a
|
|
216
|
+
* `NATIVE_ADDRESS` entry, with the wrapped native token amount reduced
|
|
217
|
+
* accordingly (omitted entirely when it reaches zero).
|
|
218
|
+
*/
|
|
219
|
+
collateralAdded: Asset[];
|
|
220
|
+
/**
|
|
221
|
+
* Tokens returned to the user in-kind (`withdrawCollateral` calls, with the
|
|
222
|
+
* MAX_UINT256 sentinel resolved against replayed balances)
|
|
223
|
+
*/
|
|
224
|
+
collateralWithdrawn: Asset[];
|
|
225
|
+
/**
|
|
226
|
+
* Total debt repaid: principal + accrued interest + fees, in underlying
|
|
227
|
+
*/
|
|
228
|
+
debtRepaid: bigint;
|
|
229
|
+
}
|
|
173
230
|
/**
|
|
174
231
|
* Result of previewing a raw operation calldata: currently pool operations and
|
|
175
|
-
* credit account opening are supported.
|
|
232
|
+
* credit account opening, adjustment, closure and repayment are supported.
|
|
176
233
|
*/
|
|
177
|
-
export type OperationPreview = PoolOperationPreview | OpenCreditAccountPreview | AdjustCreditAccountPreview;
|
|
234
|
+
export type OperationPreview = PoolOperationPreview | OpenCreditAccountPreview | AdjustCreditAccountPreview | CloseCreditAccountPreview | RepayCreditAccountPreview;
|
|
@@ -2,7 +2,7 @@ import type { Address, ContractFunctionArgs, GetContractReturnType, Hex, PublicC
|
|
|
2
2
|
import type { creditAccountCompressorAbi } from "../../abi/compressors/creditAccountCompressor.js";
|
|
3
3
|
import type { iWithdrawalCompressorV310Abi } from "../../abi/IWithdrawalCompressorV310.js";
|
|
4
4
|
import type { Asset, ConnectedBotData, Construct, CreditAccountData } from "../base/index.js";
|
|
5
|
-
import type { CreditSuite, PriceUpdate,
|
|
5
|
+
import type { CreditSuite, PriceUpdate, RWAOperationArgs } from "../market/index.js";
|
|
6
6
|
import type { RWAOpenAccountRequirements } from "../market/rwa/index.js";
|
|
7
7
|
import type { OnchainSDK } from "../OnchainSDK.js";
|
|
8
8
|
import type { RouterCASlice, RouterCloseResult } from "../router/index.js";
|
|
@@ -467,11 +467,11 @@ export interface OpenCAProps extends PrepareUpdateQuotasProps {
|
|
|
467
467
|
* RWA options to open credit account with, required for RWA factories
|
|
468
468
|
* First we ask for getOpenAccountRequirements,
|
|
469
469
|
* then perform necessary actions (e.g. for Securitize, convert requiredSignatures to signaturesToCache)
|
|
470
|
-
* to produce
|
|
470
|
+
* to produce RWAOperationArgs
|
|
471
471
|
* If getOpenAccountRequirements returned undefined, we need to pass undefined here too;
|
|
472
472
|
* It means that no RWA actions are required (e.g. when we open second credit account)
|
|
473
473
|
*/
|
|
474
|
-
rwaOptions?:
|
|
474
|
+
rwaOptions?: RWAOperationArgs;
|
|
475
475
|
}
|
|
476
476
|
export interface ChangeDeptProps {
|
|
477
477
|
/**
|
|
@@ -6,7 +6,7 @@ import type { MultiCall, RawTx } from "../../../types/index.js";
|
|
|
6
6
|
import type { IRWAFactory, RWACompressorInvestorData, RWAFactoryData } from "../types.js";
|
|
7
7
|
import { RWA_FACTORY_SECURITIZE } from "./constants.js";
|
|
8
8
|
import { SecuritizeDegenNFT } from "./SecuritizeDegenNFT.js";
|
|
9
|
-
import { type DStokenData, type SecuritizeInvestorData, type SecuritizeOpenAccountRequirements, type
|
|
9
|
+
import { type DStokenData, type SecuritizeInvestorData, type SecuritizeMissingOpenAccountRequirements, type SecuritizeOpenAccountRequirements, type SecuritizeOperationArgs, type SecuritizeRWAFactoryStateHuman } from "./types.js";
|
|
10
10
|
declare const abi: readonly [{
|
|
11
11
|
readonly type: "function";
|
|
12
12
|
readonly name: "contractType";
|
|
@@ -493,15 +493,23 @@ export declare class SecuritizeRWAFactory extends BaseContract<abi> implements I
|
|
|
493
493
|
/**
|
|
494
494
|
* {@inheritDoc IRWAFactory.multicall}
|
|
495
495
|
*/
|
|
496
|
-
multicall(creditAccount: Address, calls: MultiCall[],
|
|
496
|
+
multicall(creditAccount: Address, calls: MultiCall[], args?: SecuritizeOperationArgs): RawTx;
|
|
497
497
|
/**
|
|
498
498
|
* {@inheritDoc IRWAFactory.getOpenAccountRequirements}
|
|
499
499
|
*/
|
|
500
500
|
getOpenAccountRequirements(investor: Address, props: GetOpenAccountRequirementsProps): Promise<SecuritizeOpenAccountRequirements | undefined>;
|
|
501
|
+
/**
|
|
502
|
+
* {@inheritDoc IRWAFactory.getMissingRequirements}
|
|
503
|
+
*
|
|
504
|
+
* A required signature is omitted when `providedArgs.signaturesToCache`
|
|
505
|
+
* already carries a signature for the same token: the transaction caches it
|
|
506
|
+
* on-chain as part of the operation.
|
|
507
|
+
*/
|
|
508
|
+
getMissingRequirements(requirements: SecuritizeOpenAccountRequirements, providedArgs?: SecuritizeOperationArgs): SecuritizeMissingOpenAccountRequirements | undefined;
|
|
501
509
|
/**
|
|
502
510
|
* {@inheritDoc IRWAFactory.openCreditAccount}
|
|
503
511
|
*/
|
|
504
|
-
openCreditAccount(creditManager: Address, calls: MultiCall[],
|
|
512
|
+
openCreditAccount(creditManager: Address, calls: MultiCall[], args?: SecuritizeOperationArgs): RawTx;
|
|
505
513
|
stateHuman(_raw?: boolean): SecuritizeRWAFactoryStateHuman;
|
|
506
514
|
}
|
|
507
515
|
export {};
|
|
@@ -120,16 +120,32 @@ export interface SecuritizeRWAFactoryStateHuman extends BaseContractStateHuman {
|
|
|
120
120
|
}[];
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
|
-
* Factory-specific
|
|
123
|
+
* Factory-specific args for {@link SecuritizeRWAFactory.multicall}
|
|
124
124
|
* and {@link SecuritizeRWAFactory.openCreditAccount}.
|
|
125
125
|
**/
|
|
126
|
-
export interface
|
|
126
|
+
export interface SecuritizeOperationArgs {
|
|
127
127
|
type: typeof RWA_FACTORY_SECURITIZE;
|
|
128
128
|
/** DSToken addresses to register for this operation. */
|
|
129
129
|
tokensToRegister: Address[];
|
|
130
130
|
/** Cached EIP-712 registration signatures to store on-chain. */
|
|
131
131
|
signaturesToCache: SecuritizeRegisterMessage[];
|
|
132
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Subset of {@link SecuritizeOpenAccountRequirements} still unfulfilled given
|
|
135
|
+
* the params already carried by the transaction calldata. Returned by
|
|
136
|
+
* `SecuritizeRWAFactory.getMissingRequirements`; `undefined` there means the
|
|
137
|
+
* requirements are satisfied.
|
|
138
|
+
**/
|
|
139
|
+
export interface SecuritizeMissingOpenAccountRequirements {
|
|
140
|
+
type: typeof RWA_FACTORY_SECURITIZE;
|
|
141
|
+
/**
|
|
142
|
+
* EIP-712 messages the investor still has to sign (not covered by
|
|
143
|
+
* calldata-provided signatures). Once signed, they become the
|
|
144
|
+
* `signaturesToCache` arg of the factory's `openCreditAccount`/`multicall`
|
|
145
|
+
* calls (see {@link SecuritizeOperationArgs}).
|
|
146
|
+
*/
|
|
147
|
+
requiredSignatures: SecuritizeRegisterVaultMessage[];
|
|
148
|
+
}
|
|
133
149
|
export interface SecuritizeOpenAccountRequirements {
|
|
134
150
|
type: typeof RWA_FACTORY_SECURITIZE;
|
|
135
151
|
/**
|
|
@@ -4,7 +4,7 @@ import type { iRWACompressorAbi } from "../../../abi/rwa/iRWACompressor.js";
|
|
|
4
4
|
import type { GetOpenAccountRequirementsProps } from "../../accounts/types.js";
|
|
5
5
|
import type { IBaseContract, Unarray } from "../../base/index.js";
|
|
6
6
|
import type { MultiCall, RawTx } from "../../types/index.js";
|
|
7
|
-
import type { SecuritizeInvestorData, SecuritizeOpenAccountRequirements,
|
|
7
|
+
import type { SecuritizeInvestorData, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRWAFactoryStateHuman } from "./securitize/index.js";
|
|
8
8
|
import { RWA_FACTORY_SECURITIZE } from "./securitize/index.js";
|
|
9
9
|
/**
|
|
10
10
|
* Discriminated union of all known RWA factory contract type strings.
|
|
@@ -25,8 +25,9 @@ interface RWAFactoryTypeMap {
|
|
|
25
25
|
[RWA_FACTORY_SECURITIZE]: {
|
|
26
26
|
investorData: SecuritizeInvestorData;
|
|
27
27
|
openAccountRequirements: SecuritizeOpenAccountRequirements;
|
|
28
|
+
missingOpenAccountRequirements: SecuritizeMissingOpenAccountRequirements;
|
|
28
29
|
stateHuman: SecuritizeRWAFactoryStateHuman;
|
|
29
|
-
|
|
30
|
+
operationArgs: SecuritizeOperationArgs;
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
@@ -39,11 +40,17 @@ export type RWAInvestorData<T extends RWAFactoryType = RWAFactoryType> = RWAFact
|
|
|
39
40
|
* Can be discriminated by type
|
|
40
41
|
**/
|
|
41
42
|
export type RWAOpenAccountRequirements<T extends RWAFactoryType = RWAFactoryType> = RWAFactoryTypeMap[T]["openAccountRequirements"];
|
|
43
|
+
/**
|
|
44
|
+
* Subset of {@link RWAOpenAccountRequirements} that is still unfulfilled,
|
|
45
|
+
* defaults to union of all factory types.
|
|
46
|
+
* Can be discriminated by type
|
|
47
|
+
**/
|
|
48
|
+
export type RWAMissingOpenAccountRequirements<T extends RWAFactoryType = RWAFactoryType> = RWAFactoryTypeMap[T]["missingOpenAccountRequirements"];
|
|
42
49
|
/**
|
|
43
50
|
* Open credit account/Multicall extra params type for a RWA factory, defaults to union of all factory types
|
|
44
51
|
* Can be discriminated by type
|
|
45
52
|
**/
|
|
46
|
-
export type
|
|
53
|
+
export type RWAOperationArgs<T extends RWAFactoryType = RWAFactoryType> = RWAFactoryTypeMap[T]["operationArgs"];
|
|
47
54
|
/**
|
|
48
55
|
* Raw return type of `RWACompressor.getRWAMarketsData`.
|
|
49
56
|
**/
|
|
@@ -142,10 +149,10 @@ export interface IRWAFactory<T extends RWAFactoryType = RWAFactoryType> extends
|
|
|
142
149
|
*
|
|
143
150
|
* @param creditAccount - credit account address
|
|
144
151
|
* @param calls - calls to perform
|
|
145
|
-
* @param
|
|
146
|
-
*
|
|
152
|
+
* @param args - factory-specific args (e.g. tokens to register, signatures to cache).
|
|
153
|
+
* Undefined value means that no RWA actions are required
|
|
147
154
|
**/
|
|
148
|
-
multicall(creditAccount: Address, calls: MultiCall[],
|
|
155
|
+
multicall(creditAccount: Address, calls: MultiCall[], args?: RWAOperationArgs<T>): RawTx;
|
|
149
156
|
/**
|
|
150
157
|
* Checks if the user can open a credit account with this factory.
|
|
151
158
|
* @param investor - investor address
|
|
@@ -154,17 +161,27 @@ export interface IRWAFactory<T extends RWAFactoryType = RWAFactoryType> extends
|
|
|
154
161
|
* user can open a credit account without any further actions
|
|
155
162
|
**/
|
|
156
163
|
getOpenAccountRequirements(investor: Address, props: GetOpenAccountRequirementsProps): Promise<RWAOpenAccountRequirements<T> | undefined>;
|
|
164
|
+
/**
|
|
165
|
+
* Computes the subset of `requirements` still unfulfilled, given the
|
|
166
|
+
* factory-specific params already carried by the transaction calldata.
|
|
167
|
+
*
|
|
168
|
+
* @param requirements - requirements fetched via {@link getOpenAccountRequirements}
|
|
169
|
+
* @param providedArgs - params decoded from the transaction calldata, if
|
|
170
|
+
* any; e.g. signatures already included there need not be signed again
|
|
171
|
+
* @returns the missing requirements, or `undefined` when everything is
|
|
172
|
+
* satisfied
|
|
173
|
+
**/
|
|
174
|
+
getMissingRequirements(requirements: RWAOpenAccountRequirements<T>, providedArgs?: RWAOperationArgs<T>): RWAMissingOpenAccountRequirements<T> | undefined;
|
|
157
175
|
/**
|
|
158
176
|
* Creates a raw transaction to open a credit account.
|
|
159
177
|
* Similar to {@link CreditFacadeV310Contract.openCreditAccount}.
|
|
160
178
|
*
|
|
161
179
|
* @param creditManager - credit manager address
|
|
162
180
|
* @param calls - initial calls to perform
|
|
163
|
-
* @param
|
|
164
|
-
* register, signatures to cache).
|
|
181
|
+
* @param args - factory-specific args (e.g. tokens to register, signatures to cache).
|
|
165
182
|
* Undefined value means that no RWA actions are required (e.g. when we open second credit account)
|
|
166
183
|
**/
|
|
167
|
-
openCreditAccount(creditManager: Address, calls: MultiCall[],
|
|
184
|
+
openCreditAccount(creditManager: Address, calls: MultiCall[], args?: RWAOperationArgs<T>): RawTx;
|
|
168
185
|
}
|
|
169
186
|
/**
|
|
170
187
|
* Narrows any contract to an {@link IRWAFactory}.
|
|
@@ -13,6 +13,7 @@ export declare class AddressSet extends Set<Address> {
|
|
|
13
13
|
add(value: Address): this;
|
|
14
14
|
delete(value: Address): boolean;
|
|
15
15
|
has(value: Address): boolean;
|
|
16
|
+
difference<U>(other: ReadonlySetLike<U>): AddressSet;
|
|
16
17
|
/**
|
|
17
18
|
* Returns all addresses as an array.
|
|
18
19
|
**/
|