@gearbox-protocol/sdk 14.12.0-next.2 → 14.12.0-next.4
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/index.js +2 -0
- package/dist/cjs/preview/parse/parseOperationCalldata.js +8 -0
- package/dist/cjs/preview/parse/parseRWAFactoryOperationCalldata.js +108 -0
- package/dist/cjs/preview/parse/types-rwa.js +16 -0
- package/dist/cjs/preview/parse/types.js +9 -2
- package/dist/cjs/preview/prerequisites/AllowancePrerequisite.js +13 -13
- package/dist/cjs/preview/prerequisites/BalancePrerequisite.js +13 -13
- package/dist/cjs/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +66 -0
- package/dist/cjs/preview/prerequisites/buildPrerequisites.js +77 -5
- package/dist/cjs/preview/prerequisites/index.js +2 -0
- package/dist/cjs/preview/simulate/index.js +5 -2
- package/dist/cjs/preview/simulate/simulateOperation.js +4 -0
- package/dist/cjs/preview/simulate/simulateRWAOperation.js +30 -0
- package/dist/cjs/sdk/market/rwa/securitize/SecuritizeRWAFactory.js +30 -0
- package/dist/cjs/sdk/market/rwa/types.js +5 -2
- package/dist/esm/preview/parse/index.js +1 -0
- package/dist/esm/preview/parse/parseOperationCalldata.js +9 -0
- package/dist/esm/preview/parse/parseRWAFactoryOperationCalldata.js +89 -0
- package/dist/esm/preview/parse/types-rwa.js +0 -0
- package/dist/esm/preview/parse/types.js +6 -1
- package/dist/esm/preview/prerequisites/AllowancePrerequisite.js +13 -13
- package/dist/esm/preview/prerequisites/BalancePrerequisite.js +13 -13
- package/dist/esm/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +42 -0
- package/dist/esm/preview/prerequisites/buildPrerequisites.js +79 -5
- package/dist/esm/preview/prerequisites/index.js +1 -0
- package/dist/esm/preview/simulate/index.js +3 -1
- package/dist/esm/preview/simulate/simulateOperation.js +8 -1
- package/dist/esm/preview/simulate/simulateRWAOperation.js +6 -0
- package/dist/esm/sdk/market/rwa/securitize/SecuritizeRWAFactory.js +33 -1
- package/dist/esm/sdk/market/rwa/types.js +5 -2
- package/dist/types/preview/parse/classifyInnerOperations.d.ts +0 -2
- package/dist/types/preview/parse/index.d.ts +1 -0
- package/dist/types/preview/parse/parseRWAFactoryOperationCalldata.d.ts +22 -0
- package/dist/types/preview/parse/types-rwa.d.ts +60 -0
- package/dist/types/preview/parse/types.d.ts +11 -6
- package/dist/types/preview/prerequisites/AllowancePrerequisite.d.ts +1 -3
- package/dist/types/preview/prerequisites/BalancePrerequisite.d.ts +1 -3
- package/dist/types/preview/prerequisites/RWAOpenRequirementsPrerequisite.d.ts +36 -0
- package/dist/types/preview/prerequisites/buildPrerequisites.d.ts +1 -1
- package/dist/types/preview/prerequisites/index.d.ts +1 -0
- package/dist/types/preview/prerequisites/types.d.ts +10 -8
- package/dist/types/preview/simulate/index.d.ts +2 -0
- package/dist/types/preview/simulate/simulateRWAOperation.d.ts +25 -0
- package/dist/types/sdk/market/rwa/securitize/SecuritizeRWAFactory.d.ts +6 -1
- package/dist/types/sdk/market/rwa/types.d.ts +13 -5
- package/package.json +1 -1
|
@@ -2,9 +2,11 @@ import type { AdaptersPlugin } from "../../plugins/adapters/index.js";
|
|
|
2
2
|
import type { OnchainSDK, PluginsMap } from "../../sdk/index.js";
|
|
3
3
|
import type { OuterFacadeOperation } from "./types-facades.js";
|
|
4
4
|
import type { PoolOperation } from "./types-pools.js";
|
|
5
|
+
import type { RWAOperation } from "./types-rwa.js";
|
|
5
6
|
export * from "./types-adapters.js";
|
|
6
7
|
export * from "./types-facades.js";
|
|
7
8
|
export * from "./types-pools.js";
|
|
9
|
+
export * from "./types-rwa.js";
|
|
8
10
|
/**
|
|
9
11
|
* True when the plugin map `P` contains the {@link AdaptersPlugin} under any
|
|
10
12
|
* key. Matched nominally (the plugin's private fields make it non-structural),
|
|
@@ -29,16 +31,19 @@ export type RequireAdaptersPlugin<P extends PluginsMap> = HasAdaptersPlugin<P> e
|
|
|
29
31
|
*/
|
|
30
32
|
export type SdkWithAdapters<P extends PluginsMap = PluginsMap> = OnchainSDK<P> & RequireAdaptersPlugin<P>;
|
|
31
33
|
/**
|
|
32
|
-
* Result of decoding a single raw operation calldata:
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* Calldata-only parse produces base (descriptor) adapter operations, so the
|
|
36
|
-
* facade operations are used with the default `Ext = {}`.
|
|
34
|
+
* Result of decoding a single raw operation calldata: a pool deposit/redeem,
|
|
35
|
+
* one of the credit-facade operations, or an RWA-factory operation.
|
|
37
36
|
*/
|
|
38
|
-
export type Operation = PoolOperation | OuterFacadeOperation;
|
|
37
|
+
export type Operation = PoolOperation | OuterFacadeOperation | RWAOperation;
|
|
39
38
|
/**
|
|
40
39
|
* Narrows an {@link Operation} to a {@link PoolOperation} (deposit, mint,
|
|
41
40
|
* withdraw or redeem). Used by the UI to decide whether a custom view exists for
|
|
42
41
|
* the parsed result; everything else falls back to the raw JSON view.
|
|
43
42
|
*/
|
|
44
43
|
export declare function isPoolOperation(tx: Operation): tx is PoolOperation;
|
|
44
|
+
/**
|
|
45
|
+
* Narrows an {@link Operation} to an {@link RWAOperation} (an RWA-factory
|
|
46
|
+
* open-account or multicall). Used to route parsed operations to the
|
|
47
|
+
* RWA-specific simulation path.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isRWAOperation(tx: Operation): tx is RWAOperation;
|
|
@@ -11,9 +11,7 @@ export interface AllowancePrerequisiteProps {
|
|
|
11
11
|
}
|
|
12
12
|
/** Checks that `owner` granted `spender` an ERC-20 allowance >= `required`. */
|
|
13
13
|
export declare class AllowancePrerequisite extends Prerequisite<"allowance"> {
|
|
14
|
-
private
|
|
15
|
-
private readonly _title;
|
|
16
|
-
private readonly _detail;
|
|
14
|
+
#private;
|
|
17
15
|
constructor(props: AllowancePrerequisiteProps);
|
|
18
16
|
get id(): string;
|
|
19
17
|
get kind(): "allowance";
|
|
@@ -10,9 +10,7 @@ export interface BalancePrerequisiteProps {
|
|
|
10
10
|
}
|
|
11
11
|
/** Checks that `owner` holds an ERC-20 balance >= `required`. */
|
|
12
12
|
export declare class BalancePrerequisite extends Prerequisite<"balance"> {
|
|
13
|
-
private
|
|
14
|
-
private readonly _title;
|
|
15
|
-
private readonly _detail;
|
|
13
|
+
#private;
|
|
16
14
|
constructor(props: BalancePrerequisiteProps);
|
|
17
15
|
get id(): string;
|
|
18
16
|
get kind(): "balance";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Address, ContractFunctionParameters } from "viem";
|
|
2
|
+
import type { RWAOpenAccountRequirements } from "../../sdk/index.js";
|
|
3
|
+
import { Prerequisite } from "./Prerequisite.js";
|
|
4
|
+
import type { PrerequisiteDetail, PrerequisiteResult } from "./types.js";
|
|
5
|
+
export interface RWAOpenRequirementsPrerequisiteProps {
|
|
6
|
+
/** Requirements already resolved via `sdk.accounts.getOpenAccountRequirements`. */
|
|
7
|
+
requirements: RWAOpenAccountRequirements;
|
|
8
|
+
/** RWA token (e.g. Securitize DSToken) the requirements were computed for. */
|
|
9
|
+
token: Address;
|
|
10
|
+
/** RWA factory that produced the requirements. */
|
|
11
|
+
factory: Address;
|
|
12
|
+
title?: string;
|
|
13
|
+
id?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Checks that the borrower has fulfilled the RWA factory's open-account
|
|
17
|
+
* requirements (issuer-side token registration, EIP-712 signatures).
|
|
18
|
+
*
|
|
19
|
+
* Unlike `allowance`/`balance`, the requirements cannot be derived from plain
|
|
20
|
+
* ERC-20 multicall reads: they come from an async compressor read performed by
|
|
21
|
+
* `sdk.accounts.getOpenAccountRequirements`. The prerequisite is therefore
|
|
22
|
+
* *pre-resolved*: it is constructed with the requirements already computed,
|
|
23
|
+
* contributes no calls to the verification multicall, and `resolve` only
|
|
24
|
+
* interprets the stored payload.
|
|
25
|
+
*/
|
|
26
|
+
export declare class RWAOpenRequirementsPrerequisite extends Prerequisite<"rwaOpenRequirements"> {
|
|
27
|
+
#private;
|
|
28
|
+
constructor(props: RWAOpenRequirementsPrerequisiteProps);
|
|
29
|
+
get id(): string;
|
|
30
|
+
get kind(): "rwaOpenRequirements";
|
|
31
|
+
get title(): string;
|
|
32
|
+
get detail(): PrerequisiteDetail<"rwaOpenRequirements">;
|
|
33
|
+
/** Pre-resolved: no on-chain reads to contribute. */
|
|
34
|
+
calls(): ContractFunctionParameters[];
|
|
35
|
+
resolve(): PrerequisiteResult<"rwaOpenRequirements">;
|
|
36
|
+
}
|
|
@@ -13,4 +13,4 @@ import type { PrerequisiteContext } from "./types.js";
|
|
|
13
13
|
* bot permissions) is intentionally out of scope, since the user cannot
|
|
14
14
|
* resolve it. New {@link AnyPrerequisite} subclasses must follow the same rule.
|
|
15
15
|
*/
|
|
16
|
-
export declare function buildPrerequisites(tx: Operation, ctx: PrerequisiteContext): AnyPrerequisite[]
|
|
16
|
+
export declare function buildPrerequisites(tx: Operation, ctx: PrerequisiteContext): Promise<AnyPrerequisite[]>;
|
|
@@ -3,5 +3,6 @@ export * from "./BalancePrerequisite.js";
|
|
|
3
3
|
export * from "./buildPrerequisites.js";
|
|
4
4
|
export * from "./Prerequisite.js";
|
|
5
5
|
export * from "./prepareAction.js";
|
|
6
|
+
export * from "./RWAOpenRequirementsPrerequisite.js";
|
|
6
7
|
export * from "./runPrerequisites.js";
|
|
7
8
|
export * from "./types.js";
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type { OnchainSDK } from "../../sdk/index.js";
|
|
2
|
+
import type { OnchainSDK, RWAOpenAccountRequirements } from "../../sdk/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Extension point that ties each prerequisite kind to its detail payload.
|
|
5
5
|
*
|
|
6
|
-
* Adding a new prerequisite kind only requires a new entry here: the generic
|
|
7
|
-
* machinery below and the UI renderer registry both key off this map, so TS
|
|
8
|
-
* forces every consumer to handle the new kind.
|
|
9
|
-
*
|
|
10
6
|
* IMPORTANT: only add prerequisites that are *actionable by the transaction
|
|
11
7
|
* sender* (the LP provider or borrower). A valid prerequisite is one the user
|
|
12
8
|
* can resolve themselves before retrying, e.g. approve a token (`allowance`)
|
|
13
|
-
* or
|
|
14
|
-
*
|
|
15
|
-
*
|
|
9
|
+
* or perform offchain KYC verification.
|
|
10
|
+
*
|
|
11
|
+
* Do NOT add protocol- or admin-level state the user cannot change.
|
|
16
12
|
*/
|
|
17
13
|
export interface PrerequisiteDetailMap {
|
|
18
14
|
/** ERC-20 allowance from `owner` to `spender` must cover `required`. */
|
|
@@ -32,6 +28,12 @@ export interface PrerequisiteDetailMap {
|
|
|
32
28
|
/** On-chain balance read; only present when the read succeeded. */
|
|
33
29
|
actual?: bigint;
|
|
34
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* RWA (e.g. Securitize) open-account requirements: off-chain token
|
|
33
|
+
* registration and/or EIP-712 signatures the borrower must provide before
|
|
34
|
+
* opening a credit account in an RWA market.
|
|
35
|
+
*/
|
|
36
|
+
rwaOpenRequirements: RWAOpenAccountRequirements;
|
|
35
37
|
}
|
|
36
38
|
export type PrerequisiteKind = keyof PrerequisiteDetailMap;
|
|
37
39
|
export type PrerequisiteDetail<K extends PrerequisiteKind = PrerequisiteKind> = PrerequisiteDetailMap[K];
|
|
@@ -5,4 +5,6 @@ export { simulateFacadeOperation } from "./simulateFacadeOperation.js";
|
|
|
5
5
|
export type { SimulateOperationInput } from "./simulateOperation.js";
|
|
6
6
|
export { simulateOperation } from "./simulateOperation.js";
|
|
7
7
|
export { simulatePoolOperation } from "./simulatePoolOperation.js";
|
|
8
|
+
export type { SimulateRWAOperationInput } from "./simulateRWAOperation.js";
|
|
9
|
+
export { simulateRWAOperation } from "./simulateRWAOperation.js";
|
|
8
10
|
export type { AddressBalanceChanges, OperationSimulationOptions, PoolOperationSimulation, PoolOperationSimulationInput, PoolOperationSimulationResult, TokenBalanceChange, } from "./types.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
import type { OnchainSDK } from "../../sdk/index.js";
|
|
3
|
+
import type { RWAOperation } from "../parse/index.js";
|
|
4
|
+
import type { OperationSimulationOptions, PoolOperationSimulation } from "./types.js";
|
|
5
|
+
export interface SimulateRWAOperationInput {
|
|
6
|
+
/** Only `client`/`networkType` are used, so any OnchainSDK works. */
|
|
7
|
+
sdk: OnchainSDK;
|
|
8
|
+
/** Parsed RWA-factory operation to simulate. */
|
|
9
|
+
operation: RWAOperation;
|
|
10
|
+
/** Target contract the calldata is sent to (the RWA factory). */
|
|
11
|
+
to: Address;
|
|
12
|
+
/** Raw RWA-factory calldata to simulate. */
|
|
13
|
+
calldata: Hex;
|
|
14
|
+
/** Wallet whose balance changes and transfers we track. */
|
|
15
|
+
wallet: Address;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Simulates an RWA-factory operation.
|
|
19
|
+
*
|
|
20
|
+
* Not yet implemented: like credit-facade simulation, it requires
|
|
21
|
+
* multicall-aware balance/transfer accounting that the pool simulation does
|
|
22
|
+
* not cover. The signature mirrors {@link simulatePoolOperation} so the
|
|
23
|
+
* {@link simulateOperation} wrapper can delegate uniformly once implemented.
|
|
24
|
+
*/
|
|
25
|
+
export declare function simulateRWAOperation(_input: SimulateRWAOperationInput, _options?: OperationSimulationOptions): Promise<PoolOperationSimulation>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Address } from "viem";
|
|
1
|
+
import { type Address, type DecodeFunctionDataReturnType } from "viem";
|
|
2
2
|
import type { GetOpenAccountRequirementsProps } from "../../../accounts/types.js";
|
|
3
3
|
import { BaseContract } from "../../../base/index.js";
|
|
4
4
|
import type { OnchainSDK } from "../../../OnchainSDK.js";
|
|
@@ -463,10 +463,15 @@ export declare class SecuritizeRWAFactory extends BaseContract<abi> implements I
|
|
|
463
463
|
readonly dsTokens: DStokenData[];
|
|
464
464
|
readonly contractType = "RWA_FACTORY::SECURITIZE";
|
|
465
465
|
constructor(sdk: OnchainSDK, data: RWAFactoryData);
|
|
466
|
+
protected parseFunctionParamsV2(params: DecodeFunctionDataReturnType<abi>, strict?: boolean): Record<string, unknown>;
|
|
466
467
|
/**
|
|
467
468
|
* {@inheritDoc IRWAFactory.decodeInvestorData}
|
|
468
469
|
*/
|
|
469
470
|
decodeInvestorData(data: RWACompressorInvestorData): SecuritizeInvestorData;
|
|
471
|
+
/**
|
|
472
|
+
* {@inheritDoc IRWAFactory.getTokens}
|
|
473
|
+
*/
|
|
474
|
+
getTokens(): Address[];
|
|
470
475
|
/**
|
|
471
476
|
* {@inheritDoc IRWAFactory.getInvestor}
|
|
472
477
|
*/
|
|
@@ -102,6 +102,12 @@ export interface IRWAFactory<T extends RWAFactoryType = RWAFactoryType> extends
|
|
|
102
102
|
* @param data - raw RWACompressor InvestorData
|
|
103
103
|
**/
|
|
104
104
|
decodeInvestorData(data: RWACompressorInvestorData): RWAInvestorData<T>;
|
|
105
|
+
/**
|
|
106
|
+
* Returns the RWA token addresses this factory can register/gate
|
|
107
|
+
* (e.g. Securitize DSTokens). Named for parity with the Solidity
|
|
108
|
+
* `IRWAFactory` contract.
|
|
109
|
+
**/
|
|
110
|
+
getTokens(): Address[];
|
|
105
111
|
/**
|
|
106
112
|
* Returns the investor address for a credit account.
|
|
107
113
|
* @param creditAccount - credit account address
|
|
@@ -161,11 +167,13 @@ export interface IRWAFactory<T extends RWAFactoryType = RWAFactoryType> extends
|
|
|
161
167
|
openCreditAccount(creditManager: Address, calls: MultiCall[], options?: RWAOperationParams<T>): RawTx;
|
|
162
168
|
}
|
|
163
169
|
/**
|
|
164
|
-
* Narrows an {@link IRWAFactory}
|
|
170
|
+
* Narrows any contract to an {@link IRWAFactory}.
|
|
165
171
|
*
|
|
166
|
-
* @param
|
|
167
|
-
* @param type - expected factory type literal
|
|
168
|
-
*
|
|
172
|
+
* @param contract - contract instance to check
|
|
173
|
+
* @param type - optional expected factory type literal. When provided, narrows
|
|
174
|
+
* to the concrete `IRWAFactory<T>`; when omitted, narrows to the
|
|
175
|
+
* generalized {@link IRWAFactory}
|
|
176
|
+
* @returns `true` if the contract is an RWA factory (of the given type, if provided)
|
|
169
177
|
**/
|
|
170
|
-
export declare function isRWAFactory<T extends RWAFactoryType>(
|
|
178
|
+
export declare function isRWAFactory<T extends RWAFactoryType = RWAFactoryType>(contract: IBaseContract, type?: T): contract is IRWAFactory<T>;
|
|
171
179
|
export {};
|