@gearbox-protocol/sdk 16.3.0-next.3 → 16.3.0-next.5
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/model/errors/operation-errors.js +1 -1
- package/dist/cjs/model/index.js +2 -2
- package/dist/cjs/model/rwa.js +4 -4
- package/dist/cjs/model/rwa.schema.js +4 -4
- package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +1 -1
- package/dist/cjs/onchain/accounts/CreditAccountsServiceV310.js +1 -3
- package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/cjs/onchain/index.js +4 -4
- package/dist/cjs/onchain/market/credit/CreditSuite.js +19 -9
- package/dist/cjs/onchain/market/rwa/midas/MidasDegenNFT.js +45 -5
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +56 -12
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +0 -37
- package/dist/cjs/onchain/opportunities/MultichainOpportunitiesService.js +8 -2
- package/dist/cjs/onchain/opportunities/OpportunitiesService.js +16 -4
- package/dist/cjs/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
- package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +8 -7
- package/dist/cjs/onchain/validation/bundles/{checkDraw.js → checkIncreaseDebt.js} +10 -10
- package/dist/cjs/onchain/validation/bundles/{checkQuotasAsked.js → checkIncreaseQuota.js} +3 -3
- package/dist/cjs/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
- package/dist/cjs/onchain/validation/bundles/checkRWAOpening.js +6 -5
- package/dist/cjs/onchain/validation/bundles/index.js +4 -4
- package/dist/cjs/onchain/validation/checks/checkBorrowLimit.js +1 -1
- package/dist/cjs/onchain/validation/checks/checkPoolLiquidity.js +1 -1
- package/dist/cjs/onchain/validation/index.js +4 -4
- package/dist/cjs/sdk/execute/ExecuteApi.js +2 -2
- package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +9 -3
- package/dist/esm/model/errors/operation-errors.js +1 -1
- package/dist/esm/model/index.js +3 -3
- package/dist/esm/model/rwa.js +4 -4
- package/dist/esm/model/rwa.schema.js +5 -5
- package/dist/esm/offchain/opportunities/OffchainOpportunities.js +1 -1
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +1 -3
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/onchain/index.js +3 -3
- package/dist/esm/onchain/market/credit/CreditSuite.js +19 -9
- package/dist/esm/onchain/market/rwa/midas/MidasDegenNFT.js +45 -5
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +55 -10
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +0 -37
- package/dist/esm/onchain/opportunities/MultichainOpportunitiesService.js +8 -2
- package/dist/esm/onchain/opportunities/OpportunitiesService.js +16 -4
- package/dist/esm/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
- package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +8 -7
- package/dist/esm/onchain/validation/bundles/checkIncreaseDebt.js +27 -0
- package/dist/esm/onchain/validation/bundles/{checkQuotasAsked.js → checkIncreaseQuota.js} +3 -3
- package/dist/esm/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
- package/dist/esm/onchain/validation/bundles/checkRWAOpening.js +6 -5
- package/dist/esm/onchain/validation/bundles/index.js +3 -3
- package/dist/esm/onchain/validation/checks/checkBorrowLimit.js +1 -1
- package/dist/esm/onchain/validation/checks/checkPoolLiquidity.js +1 -1
- package/dist/esm/onchain/validation/index.js +3 -3
- package/dist/esm/sdk/execute/ExecuteApi.js +2 -2
- package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +9 -3
- package/dist/types/model/errors/operation-errors.d.ts +8 -6
- package/dist/types/model/index.d.ts +3 -3
- package/dist/types/model/opportunities.d.ts +6 -7
- package/dist/types/model/rwa.d.ts +47 -27
- package/dist/types/model/rwa.schema.d.ts +3 -3
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +1 -2
- package/dist/types/offchain/opportunities/types.d.ts +1 -4
- package/dist/types/onchain/accounts/types.d.ts +4 -2
- package/dist/types/onchain/index.d.ts +4 -4
- package/dist/types/onchain/market/credit/CreditSuite.d.ts +8 -3
- package/dist/types/onchain/market/index.d.ts +2 -2
- package/dist/types/onchain/market/pool/types.d.ts +1 -1
- package/dist/types/onchain/market/rwa/index.d.ts +2 -2
- package/dist/types/onchain/market/rwa/midas/MidasDegenNFT.d.ts +19 -4
- package/dist/types/onchain/market/rwa/securitize/SecuritizeDegenNFT.d.ts +24 -4
- package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +2 -14
- package/dist/types/onchain/market/rwa/types.d.ts +39 -37
- package/dist/types/onchain/opportunities/MultichainOpportunitiesService.d.ts +5 -1
- package/dist/types/onchain/opportunities/OpportunitiesService.d.ts +10 -3
- package/dist/types/onchain/opportunities/types.d.ts +6 -1
- package/dist/types/onchain/validation/bundles/checkCreditOperation.d.ts +3 -2
- package/dist/types/onchain/validation/bundles/{checkDraw.d.ts → checkIncreaseDebt.d.ts} +7 -7
- package/dist/types/onchain/validation/bundles/{checkQuotasAsked.d.ts → checkIncreaseQuota.d.ts} +3 -3
- package/dist/types/onchain/validation/bundles/checkRWAOpenRequirements.d.ts +2 -2
- package/dist/types/onchain/validation/bundles/checkRWAOpening.d.ts +3 -3
- package/dist/types/onchain/validation/bundles/index.d.ts +3 -3
- package/dist/types/onchain/validation/checks/checkBorrowLimit.d.ts +1 -1
- package/dist/types/onchain/validation/checks/checkPoolLiquidity.d.ts +1 -1
- package/dist/types/onchain/validation/index.d.ts +3 -3
- package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +5 -1
- package/dist/types/sdk/opportunities/types.d.ts +9 -3
- package/package.json +1 -1
- package/dist/esm/onchain/validation/bundles/checkDraw.js +0 -27
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { iRWACompressorAbi } from "../../../abi/rwa/iRWACompressor.js";
|
|
2
|
-
import {
|
|
2
|
+
import { RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOperationArgs, RWAProtocol, RWA_FACTORY_SECURITIZE } from "../../../model/rwa.js";
|
|
3
3
|
import "../../../model/index.js";
|
|
4
4
|
import { IBaseContract, Unarray } from "../../base/types.js";
|
|
5
5
|
import { SecuritizeInvestorData, SecuritizeRWAFactoryStateHuman } from "./securitize/types.js";
|
|
@@ -19,10 +19,15 @@ import { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from "abitype";
|
|
|
19
19
|
**/
|
|
20
20
|
interface RWAFactoryTypeMap {
|
|
21
21
|
[RWA_FACTORY_SECURITIZE]: {
|
|
22
|
+
protocol: "securitize";
|
|
22
23
|
investorData: SecuritizeInvestorData;
|
|
23
24
|
stateHuman: SecuritizeRWAFactoryStateHuman;
|
|
24
25
|
};
|
|
25
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* {@link RWAProtocol} of the factory type `T`.
|
|
29
|
+
**/
|
|
30
|
+
type RWAFactoryProtocol<T extends RWAFactoryType> = RWAFactoryTypeMap[T]["protocol"];
|
|
26
31
|
/**
|
|
27
32
|
* Investor data decoded from the RWA compressor, defaults to union of all factory types
|
|
28
33
|
* Can be discriminated by type
|
|
@@ -151,26 +156,7 @@ interface IRWAFactory<T extends RWAFactoryType = RWAFactoryType> extends IBaseCo
|
|
|
151
156
|
* @param args - factory-specific args (e.g. tokens to register, signatures to cache).
|
|
152
157
|
* Undefined value means that no RWA actions are required
|
|
153
158
|
**/
|
|
154
|
-
multicall(creditAccount: Address, calls: MultiCall[], args?: RWAOperationArgs<T
|
|
155
|
-
/**
|
|
156
|
-
* Checks if the user can open a credit account with this factory.
|
|
157
|
-
* @param investor - investor address
|
|
158
|
-
* @param props - {@link GetOpenAccountRequirementsProps}
|
|
159
|
-
* @returns open account requirements for the investor, or `undefined` if the
|
|
160
|
-
* user can open a credit account without any further actions
|
|
161
|
-
**/
|
|
162
|
-
getOpenAccountRequirements(investor: Address, props: GetOpenAccountRequirementsProps): Promise<RWAOpenAccountRequirements<T> | undefined>;
|
|
163
|
-
/**
|
|
164
|
-
* Computes the subset of `requirements` still unfulfilled, given the
|
|
165
|
-
* factory-specific params already carried by the transaction calldata.
|
|
166
|
-
*
|
|
167
|
-
* @param requirements - requirements fetched via {@link getOpenAccountRequirements}
|
|
168
|
-
* @param providedArgs - params decoded from the transaction calldata, if
|
|
169
|
-
* any; e.g. signatures already included there need not be signed again
|
|
170
|
-
* @returns the missing requirements, or `undefined` when everything is
|
|
171
|
-
* satisfied
|
|
172
|
-
**/
|
|
173
|
-
getMissingRequirements(requirements: RWAOpenAccountRequirements<T>, providedArgs?: RWAOperationArgs<T>): RWAMissingOpenAccountRequirements<T> | undefined;
|
|
159
|
+
multicall(creditAccount: Address, calls: MultiCall[], args?: RWAOperationArgs<RWAFactoryProtocol<T>>): RawTx;
|
|
174
160
|
/**
|
|
175
161
|
* Creates a raw transaction to open a credit account.
|
|
176
162
|
* Similar to {@link CreditFacadeV310Contract.openCreditAccount}.
|
|
@@ -180,25 +166,41 @@ interface IRWAFactory<T extends RWAFactoryType = RWAFactoryType> extends IBaseCo
|
|
|
180
166
|
* @param args - factory-specific args (e.g. tokens to register, signatures to cache).
|
|
181
167
|
* Undefined value means that no RWA actions are required (e.g. when we open second credit account)
|
|
182
168
|
**/
|
|
183
|
-
openCreditAccount(creditManager: Address, calls: MultiCall[], args?: RWAOperationArgs<T
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
eligible: boolean;
|
|
190
|
-
/** Token the wallet must be registered for. */
|
|
191
|
-
token: Address;
|
|
169
|
+
openCreditAccount(creditManager: Address, calls: MultiCall[], args?: RWAOperationArgs<RWAFactoryProtocol<T>>): RawTx;
|
|
170
|
+
/**
|
|
171
|
+
* Degen NFT this factory deploys as the KYC gate. Midas has no factory;
|
|
172
|
+
* its NFT is loaded separately via {@link createDegenNFT}.
|
|
173
|
+
**/
|
|
174
|
+
readonly degenNFT: IDegenNFT<RWAFactoryProtocol<T>>;
|
|
192
175
|
}
|
|
193
176
|
/**
|
|
194
|
-
* Degen NFT that gates credit-account opening behind
|
|
195
|
-
|
|
196
|
-
interface IDegenNFT extends IBaseContract {
|
|
197
|
-
readonly protocol:
|
|
177
|
+
* Degen NFT that gates credit-account opening behind an RWA KYC provider.
|
|
178
|
+
**/
|
|
179
|
+
interface IDegenNFT<P extends RWAProtocol = RWAProtocol> extends IBaseContract {
|
|
180
|
+
readonly protocol: P;
|
|
181
|
+
readonly registrationLink: string;
|
|
182
|
+
/**
|
|
183
|
+
* Tokens this gate is about: Securitize DS tokens, or the Midas mToken.
|
|
184
|
+
*/
|
|
185
|
+
getTokens(): Promise<Address[]>;
|
|
186
|
+
/**
|
|
187
|
+
* What `wallet` still has to do before this gate lets it open on the
|
|
188
|
+
* strategy token in `props`.
|
|
189
|
+
*/
|
|
190
|
+
getOpenAccountRequirements(wallet: Address, props: GetOpenAccountRequirementsProps): Promise<RWAOpenAccountRequirements<P>>;
|
|
191
|
+
/**
|
|
192
|
+
* Protocol-side KYC is done: registered at Securitize for every requested
|
|
193
|
+
* DS token, or greenlisted by Midas.
|
|
194
|
+
*
|
|
195
|
+
* User might still be required to do additional actions on Gearbox side,
|
|
196
|
+
* e.g. sign EIP-712 messages for Securitize
|
|
197
|
+
*/
|
|
198
|
+
isRegistered(requirements: RWAOpenAccountRequirements<P>): boolean;
|
|
198
199
|
/**
|
|
199
|
-
*
|
|
200
|
+
* Leftover Gearbox-tx work given `providedArgs` already on the calldata.
|
|
201
|
+
* Always `undefined` for Midas (no tx args).
|
|
200
202
|
*/
|
|
201
|
-
|
|
203
|
+
getMissingRequirements(requirements: RWAOpenAccountRequirements<P>, providedArgs?: RWAOperationArgs<P>): RWAMissingOpenAccountRequirements<P> | undefined;
|
|
202
204
|
}
|
|
203
205
|
/**
|
|
204
206
|
* Narrows any contract to an {@link IRWAFactory}.
|
|
@@ -211,4 +213,4 @@ interface IDegenNFT extends IBaseContract {
|
|
|
211
213
|
**/
|
|
212
214
|
declare function isRWAFactory<T extends RWAFactoryType = RWAFactoryType>(contract: IBaseContract, type?: T): contract is IRWAFactory<T>;
|
|
213
215
|
//#endregion
|
|
214
|
-
export { GetInvestorOptions, GetOpenAccountRequirementsProps, IDegenNFT, IRWAFactory,
|
|
216
|
+
export { GetInvestorOptions, GetOpenAccountRequirementsProps, IDegenNFT, IRWAFactory, RWACompressorCall, RWACompressorInvestorData, RWACompressorResponse, RWAFactoryData, RWAFactoryProtocol, RWAFactoryStateHuman, RWAInvestorData, RWAState, RWAStateHuman, RWAUnderlyingData, isRWAFactory };
|
|
@@ -33,7 +33,11 @@ declare class MultichainOpportunitiesService<const Plugins extends PluginsMap =
|
|
|
33
33
|
*
|
|
34
34
|
* See {@link MultichainOpportunitiesService.getPool}.
|
|
35
35
|
**/
|
|
36
|
-
getStrategy(key: StrategyOpportunityKey
|
|
36
|
+
getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
37
|
+
/**
|
|
38
|
+
* {@inheritDoc OpportunitiesService.isEligibleForStrategy}
|
|
39
|
+
**/
|
|
40
|
+
isEligibleForStrategy(key: StrategyOpportunityKey, wallet: Address): Promise<boolean>;
|
|
37
41
|
}
|
|
38
42
|
//#endregion
|
|
39
43
|
export { MultichainOpportunitiesService };
|
|
@@ -34,13 +34,20 @@ declare class OpportunitiesService extends SDKConstruct {
|
|
|
34
34
|
* A single strategy opportunity plus the rate curve of the pool it borrows
|
|
35
35
|
* from and the price feeds its liquidation price depends on.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
38
|
-
* with the strategy's KYC provider first; `null` otherwise.
|
|
37
|
+
* `kyc` is the strategy's KYC gate, independent of any wallet.
|
|
39
38
|
*
|
|
40
39
|
* @throws If the credit manager is unknown, or does not currently offer a
|
|
41
40
|
* strategy.
|
|
42
41
|
**/
|
|
43
|
-
getStrategy(key: StrategyOpportunityKey
|
|
42
|
+
getStrategy(key: StrategyOpportunityKey): Promise<StrategyOpportunityDetail>;
|
|
43
|
+
/**
|
|
44
|
+
* Whether `wallet` may open this strategy today: `true` when it is not
|
|
45
|
+
* KYC-gated or the wallet already passed the gate.
|
|
46
|
+
*
|
|
47
|
+
* @throws If the credit manager is unknown, or does not currently offer a
|
|
48
|
+
* strategy.
|
|
49
|
+
**/
|
|
50
|
+
isEligibleForStrategy(key: StrategyOpportunityKey, wallet: Address): Promise<boolean>;
|
|
44
51
|
}
|
|
45
52
|
//#endregion
|
|
46
53
|
export { OpportunitiesService };
|
|
@@ -22,7 +22,12 @@ interface IMultichainOpportunitiesService {
|
|
|
22
22
|
/**
|
|
23
23
|
* Detailed view of one strategy opportunity.
|
|
24
24
|
**/
|
|
25
|
-
getStrategy(key: StrategyOpportunityKey
|
|
25
|
+
getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
26
|
+
/**
|
|
27
|
+
* Whether `wallet` may open this strategy today. Throws when that chain
|
|
28
|
+
* cannot answer.
|
|
29
|
+
**/
|
|
30
|
+
isEligibleForStrategy(key: StrategyOpportunityKey, wallet: Address): Promise<boolean>;
|
|
26
31
|
}
|
|
27
32
|
//#endregion
|
|
28
33
|
export { IMultichainOpportunitiesService };
|
|
@@ -23,8 +23,9 @@ interface CreditOperationArgs extends HealthFactorThresholds {
|
|
|
23
23
|
* has to hold, approve or sign.
|
|
24
24
|
*
|
|
25
25
|
* The array is in check order, most fundamental first: the market's own state,
|
|
26
|
-
* then what the facade would revert on, then what the operation
|
|
27
|
-
*
|
|
26
|
+
* then what the facade would revert on, then what the operation borrows and the
|
|
27
|
+
* quota it increases, then the account it leaves behind, and last the wallet's
|
|
28
|
+
* side.
|
|
28
29
|
*/
|
|
29
30
|
declare function checkCreditOperation(args: CreditOperationArgs): Promise<CreditOperationError[]>;
|
|
30
31
|
//#endregion
|
|
@@ -3,18 +3,18 @@ import { InsufficientPoolLiquidityError } from "../../../model/errors/operation-
|
|
|
3
3
|
import "../../../model/index.js";
|
|
4
4
|
import { CreditSuite } from "../../market/credit/CreditSuite.js";
|
|
5
5
|
import { CreditOperationPreview } from "./checkCreditOperation.js";
|
|
6
|
-
//#region src/onchain/validation/bundles/
|
|
6
|
+
//#region src/onchain/validation/bundles/checkIncreaseDebt.d.ts
|
|
7
7
|
/**
|
|
8
|
-
* What the transaction
|
|
8
|
+
* What the transaction borrows, against what the market can lend right now.
|
|
9
9
|
*
|
|
10
|
-
* Only a
|
|
11
|
-
*
|
|
12
|
-
* `totalDebtChange`.
|
|
10
|
+
* Only a debt increase is weighed: repaying, or leaving the debt alone, can
|
|
11
|
+
* never exceed the borrow limit. Opening borrows the whole debt; adjusting
|
|
12
|
+
* borrows `totalDebtChange`.
|
|
13
13
|
*
|
|
14
14
|
* The engine holds every simulation to this already (`assertCanBorrow`), so
|
|
15
15
|
* this is here for the transactions it never saw — a pasted calldata reaches
|
|
16
16
|
* the confirm screen with nothing else standing between it and a revert.
|
|
17
17
|
*/
|
|
18
|
-
declare function
|
|
18
|
+
declare function checkIncreaseDebt(suite: CreditSuite, preview: CreditOperationPreview, underlying: Token): InsufficientPoolLiquidityError[];
|
|
19
19
|
//#endregion
|
|
20
|
-
export {
|
|
20
|
+
export { checkIncreaseDebt };
|
package/dist/types/onchain/validation/bundles/{checkQuotasAsked.d.ts → checkIncreaseQuota.d.ts}
RENAMED
|
@@ -3,8 +3,8 @@ import { QuotaLimitReachedError } from "../../../model/errors/operation-errors.j
|
|
|
3
3
|
import "../../../model/index.js";
|
|
4
4
|
import { MarketSuite } from "../../market/MarketSuite.js";
|
|
5
5
|
import { CreditOperationPreview } from "./checkCreditOperation.js";
|
|
6
|
-
//#region src/onchain/validation/bundles/
|
|
6
|
+
//#region src/onchain/validation/bundles/checkIncreaseQuota.d.ts
|
|
7
7
|
/** Every quota the operation raises, against the room the keeper has left. */
|
|
8
|
-
declare function
|
|
8
|
+
declare function checkIncreaseQuota(market: MarketSuite, preview: CreditOperationPreview, underlying: Token): QuotaLimitReachedError[];
|
|
9
9
|
//#endregion
|
|
10
|
-
export {
|
|
10
|
+
export { checkIncreaseQuota };
|
|
@@ -10,10 +10,10 @@ interface CheckRWAOpenRequirementsInput {
|
|
|
10
10
|
wallet: Address;
|
|
11
11
|
creditManager: Address;
|
|
12
12
|
token: Address;
|
|
13
|
-
providedArgs
|
|
13
|
+
providedArgs?: RWAOperationArgs;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* The
|
|
16
|
+
* The degen NFT is satisfied that `wallet` may open on `token` with the
|
|
17
17
|
* registration args already on the transaction.
|
|
18
18
|
*/
|
|
19
19
|
declare function checkRWAOpenRequirements(input: CheckRWAOpenRequirementsInput): Promise<(RWAOpenRequirementsError | UnexpectedFailureError)[]>;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { RWAOpenRequirementsError } from "../../../model/errors/operation-errors.js";
|
|
2
2
|
import { UnexpectedFailureError } from "../../../model/errors/prepare-errors.js";
|
|
3
|
-
import {
|
|
3
|
+
import { OpenStrategyPositionPreview } from "../../../model/previews.js";
|
|
4
4
|
import "../../../model/index.js";
|
|
5
5
|
import { OnchainSDK } from "../../OnchainSDK.js";
|
|
6
6
|
import { Address } from "viem";
|
|
7
7
|
//#region src/onchain/validation/bundles/checkRWAOpening.d.ts
|
|
8
8
|
interface CheckRWAOpeningInput {
|
|
9
9
|
sdk: OnchainSDK;
|
|
10
|
-
preview:
|
|
10
|
+
preview: OpenStrategyPositionPreview;
|
|
11
11
|
sender: Address;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* Per
|
|
14
|
+
* Per KYC-gated token among `collateralAdded ∪ quotas`, whether the
|
|
15
15
|
* borrower still has to register or sign before this opening can land.
|
|
16
16
|
*/
|
|
17
17
|
declare function checkRWAOpening(input: CheckRWAOpeningInput): Promise<(RWAOpenRequirementsError | UnexpectedFailureError)[]>;
|
|
@@ -4,15 +4,15 @@ import { CheckCollateralFundingInput, CollateralFundingPreview, checkCollateralF
|
|
|
4
4
|
import { HealthFactorThresholds, WeighedFactors, checkHealthFactors } from "./checkHealthFactors.js";
|
|
5
5
|
import { MarketStateError, checkMarket } from "./checkMarket.js";
|
|
6
6
|
import { CreditOperationArgs, CreditOperationError, CreditOperationPreview, checkCreditOperation } from "./checkCreditOperation.js";
|
|
7
|
-
import {
|
|
7
|
+
import { checkIncreaseDebt } from "./checkIncreaseDebt.js";
|
|
8
|
+
import { checkIncreaseQuota } from "./checkIncreaseQuota.js";
|
|
8
9
|
import { CheckLiquidationEligibilityInput, LiquidationEligibilityError, checkLiquidationEligibility } from "./checkLiquidationEligibility.js";
|
|
9
10
|
import { CheckLiquidationFundingInput, checkLiquidationFunding } from "./checkLiquidationFunding.js";
|
|
10
11
|
import { checkObtained } from "./checkObtained.js";
|
|
11
12
|
import { CheckPoolFundingInput, checkPoolFunding } from "./checkPoolFunding.js";
|
|
12
13
|
import { PoolOperationArgs, PoolOperationError, checkPoolOperation } from "./checkPoolOperation.js";
|
|
13
|
-
import { checkQuotasAsked } from "./checkQuotasAsked.js";
|
|
14
14
|
import { CheckRWAOpeningInput, checkRWAOpening } from "./checkRWAOpening.js";
|
|
15
15
|
import { CheckRWAOpenRequirementsInput, checkRWAOpenRequirements } from "./checkRWAOpenRequirements.js";
|
|
16
16
|
import { CheckWalletAllowanceInput, checkWalletAllowance } from "./checkWalletAllowance.js";
|
|
17
17
|
import { CheckWalletBalanceInput, checkWalletBalance } from "./checkWalletBalance.js";
|
|
18
|
-
export { CheckCollateralFundingInput, CheckLiquidationEligibilityInput, CheckLiquidationFundingInput, CheckPoolFundingInput, CheckRWAOpenRequirementsInput, CheckRWAOpeningInput, CheckWalletAllowanceInput, CheckWalletBalanceInput, CheckWalletInput, CollateralFundingPreview, CreditOperationArgs, CreditOperationError, CreditOperationPreview, HealthFactorThresholds, LiquidationEligibilityError, MarketStateError, PoolOperationArgs, PoolOperationError, WalletFundingError, WeighedFactors, checkAccountQuotas, checkCollateralFunding, checkCreditOperation,
|
|
18
|
+
export { CheckCollateralFundingInput, CheckLiquidationEligibilityInput, CheckLiquidationFundingInput, CheckPoolFundingInput, CheckRWAOpenRequirementsInput, CheckRWAOpeningInput, CheckWalletAllowanceInput, CheckWalletBalanceInput, CheckWalletInput, CollateralFundingPreview, CreditOperationArgs, CreditOperationError, CreditOperationPreview, HealthFactorThresholds, LiquidationEligibilityError, MarketStateError, PoolOperationArgs, PoolOperationError, WalletFundingError, WeighedFactors, checkAccountQuotas, checkCollateralFunding, checkCreditOperation, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLiquidationEligibility, checkLiquidationFunding, checkMarket, checkObtained, checkPoolFunding, checkPoolOperation, checkRWAOpenRequirements, checkRWAOpening, checkWallet, checkWalletAllowance, checkWalletBalance };
|
|
@@ -10,7 +10,7 @@ interface BorrowLimitArgs {
|
|
|
10
10
|
maxBorrowAmount?: bigint;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
* What the pool will hand over, against
|
|
13
|
+
* What the pool will hand over, against the amount requested.
|
|
14
14
|
*
|
|
15
15
|
* `available` and `limit` are the caller's reading of which limit is in the
|
|
16
16
|
* way; this check only compares. `maxBorrowAmount` is the largest debt still
|
|
@@ -11,7 +11,7 @@ interface PoolLiquidityArgs {
|
|
|
11
11
|
* What the pool holds, against what is being taken out of it.
|
|
12
12
|
*
|
|
13
13
|
* The operator is not `checkBorrowLimit`'s: a pool holding exactly the amount
|
|
14
|
-
*
|
|
14
|
+
* requested still cannot serve it, so equality is already a refusal. That is
|
|
15
15
|
* the rule the legacy withdrawal validator enforced and it is preserved to the
|
|
16
16
|
* unit.
|
|
17
17
|
*/
|
|
@@ -5,13 +5,13 @@ import { CheckCollateralFundingInput, CollateralFundingPreview, checkCollateralF
|
|
|
5
5
|
import { HealthFactorThresholds, WeighedFactors, checkHealthFactors } from "./bundles/checkHealthFactors.js";
|
|
6
6
|
import { MarketStateError, checkMarket } from "./bundles/checkMarket.js";
|
|
7
7
|
import { CreditOperationArgs, CreditOperationError, CreditOperationPreview, checkCreditOperation } from "./bundles/checkCreditOperation.js";
|
|
8
|
-
import {
|
|
8
|
+
import { checkIncreaseDebt } from "./bundles/checkIncreaseDebt.js";
|
|
9
|
+
import { checkIncreaseQuota } from "./bundles/checkIncreaseQuota.js";
|
|
9
10
|
import { CheckLiquidationEligibilityInput, LiquidationEligibilityError, checkLiquidationEligibility } from "./bundles/checkLiquidationEligibility.js";
|
|
10
11
|
import { CheckLiquidationFundingInput, checkLiquidationFunding } from "./bundles/checkLiquidationFunding.js";
|
|
11
12
|
import { checkObtained } from "./bundles/checkObtained.js";
|
|
12
13
|
import { CheckPoolFundingInput, checkPoolFunding } from "./bundles/checkPoolFunding.js";
|
|
13
14
|
import { PoolOperationArgs, PoolOperationError, checkPoolOperation } from "./bundles/checkPoolOperation.js";
|
|
14
|
-
import { checkQuotasAsked } from "./bundles/checkQuotasAsked.js";
|
|
15
15
|
import { CheckRWAOpeningInput, checkRWAOpening } from "./bundles/checkRWAOpening.js";
|
|
16
16
|
import { CheckRWAOpenRequirementsInput, checkRWAOpenRequirements } from "./bundles/checkRWAOpenRequirements.js";
|
|
17
17
|
import { CheckWalletAllowanceInput, checkWalletAllowance } from "./bundles/checkWalletAllowance.js";
|
|
@@ -40,4 +40,4 @@ import { amountOf } from "./helpers/amount.js";
|
|
|
40
40
|
import { MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM } from "./helpers/health-factor-limits.js";
|
|
41
41
|
import { toToken, toTokenAmount } from "./helpers/token.js";
|
|
42
42
|
import "./helpers/index.js";
|
|
43
|
-
export { BorrowLimitArgs, CheckCollateralFundingInput, CheckLiquidationEligibilityInput, CheckLiquidationFundingInput, CheckLiquidationInput, CheckLiquidationOptions, CheckOperationInput, CheckOperationOptions, CheckPoolFundingInput, CheckRWAOpenRequirementsInput, CheckRWAOpeningInput, CheckSimulationInput, CheckWalletAllowanceInput, CheckWalletBalanceInput, CheckWalletInput, CollateralFundingPreview, CollateralisedArgs, CreditAccountFrozenArgs, CreditManagerPausedArgs, CreditOperationArgs, CreditOperationError, CreditOperationPreview, CreditSimulationInput, DebtLimitsArgs, EmergencyLiquidatorArgs, ForbiddenTokenArgs, HealthFactorThresholds, type IntentValidationError, LeverageArgs, LiquidationEligibilityError, LiquidationValidationError, LiquidatorEligibleArgs, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM, MarketExpiredArgs, MarketStateError, OperationValidationError, PoolLiquidityArgs, PoolOperationArgs, PoolOperationError, PoolPausedArgs, PoolSunsetArgs, QuotaCountArgs, QuotaLimitArgs, SimulationValidationError, WalletFundingError, WeighedFactors, amountOf, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits,
|
|
43
|
+
export { BorrowLimitArgs, CheckCollateralFundingInput, CheckLiquidationEligibilityInput, CheckLiquidationFundingInput, CheckLiquidationInput, CheckLiquidationOptions, CheckOperationInput, CheckOperationOptions, CheckPoolFundingInput, CheckRWAOpenRequirementsInput, CheckRWAOpeningInput, CheckSimulationInput, CheckWalletAllowanceInput, CheckWalletBalanceInput, CheckWalletInput, CollateralFundingPreview, CollateralisedArgs, CreditAccountFrozenArgs, CreditManagerPausedArgs, CreditOperationArgs, CreditOperationError, CreditOperationPreview, CreditSimulationInput, DebtLimitsArgs, EmergencyLiquidatorArgs, ForbiddenTokenArgs, HealthFactorThresholds, type IntentValidationError, LeverageArgs, LiquidationEligibilityError, LiquidationValidationError, LiquidatorEligibleArgs, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM, MarketExpiredArgs, MarketStateError, OperationValidationError, PoolLiquidityArgs, PoolOperationArgs, PoolOperationError, PoolPausedArgs, PoolSunsetArgs, QuotaCountArgs, QuotaLimitArgs, SimulationValidationError, WalletFundingError, WeighedFactors, amountOf, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkRWAOpenRequirements, checkRWAOpening, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, raise, toToken, toTokenAmount };
|
|
@@ -47,7 +47,11 @@ declare class OpportunitiesNamespace extends AbstractNamespace<MultichainSDK["op
|
|
|
47
47
|
/**
|
|
48
48
|
* {@inheritDoc IOpportunitiesBase.getStrategy}
|
|
49
49
|
**/
|
|
50
|
-
getStrategy(key: StrategyOpportunityKey
|
|
50
|
+
getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
51
|
+
/**
|
|
52
|
+
* {@inheritDoc IOpportunitiesOnchainOnly.isEligibleForStrategy}
|
|
53
|
+
**/
|
|
54
|
+
isEligibleForStrategy(key: StrategyOpportunityKey, wallet: Address): Promise<boolean>;
|
|
51
55
|
/**
|
|
52
56
|
* {@inheritDoc IOpportunitiesBase.filter}
|
|
53
57
|
**/
|
|
@@ -30,10 +30,11 @@ interface IOpportunitiesBase {
|
|
|
30
30
|
**/
|
|
31
31
|
getPool(key: PoolOpportunityKey): Promise<DataResponse<PoolOpportunityDetail>>;
|
|
32
32
|
/**
|
|
33
|
-
* Detailed view of one strategy opportunity.
|
|
34
|
-
*
|
|
33
|
+
* Detailed view of one strategy opportunity. `kyc` is the strategy's KYC
|
|
34
|
+
* gate, independent of any wallet. Use {@link IOpportunitiesOnchainOnly.isEligibleForStrategy}
|
|
35
|
+
* for a wallet verdict.
|
|
35
36
|
**/
|
|
36
|
-
getStrategy(key: StrategyOpportunityKey
|
|
37
|
+
getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
37
38
|
/**
|
|
38
39
|
* Narrows an already-read list, rows and metadata alike. `undefined` passes
|
|
39
40
|
* through, so a read still in flight stays that way, and a list already read
|
|
@@ -88,6 +89,11 @@ interface IOpportunitiesOnchainOnly {
|
|
|
88
89
|
* same reason as {@link prepare}: it encodes against live chain state.
|
|
89
90
|
**/
|
|
90
91
|
readonly execute: IOpportunitiesExecute;
|
|
92
|
+
/**
|
|
93
|
+
* Whether `wallet` may open this strategy today: `true` when it is not
|
|
94
|
+
* KYC-gated or the wallet already passed the gate. Chain-only.
|
|
95
|
+
**/
|
|
96
|
+
isEligibleForStrategy(key: StrategyOpportunityKey, wallet: Address): Promise<boolean>;
|
|
91
97
|
}
|
|
92
98
|
/**
|
|
93
99
|
* The chain on its own, for a consumer that shows each source as it arrives.
|
package/package.json
CHANGED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { checkBorrowLimit } from "../checks/checkBorrowLimit.js";
|
|
2
|
-
import "../checks/index.js";
|
|
3
|
-
//#region src/onchain/validation/bundles/checkDraw.ts
|
|
4
|
-
/**
|
|
5
|
-
* What the transaction draws, against what the market can lend right now.
|
|
6
|
-
*
|
|
7
|
-
* Only a draw is weighed: repaying, or leaving the debt alone, can never exceed
|
|
8
|
-
* a ceiling. Opening borrows the whole debt; adjusting borrows
|
|
9
|
-
* `totalDebtChange`.
|
|
10
|
-
*
|
|
11
|
-
* The engine holds every simulation to this already (`assertCanBorrow`), so
|
|
12
|
-
* this is here for the transactions it never saw — a pasted calldata reaches
|
|
13
|
-
* the confirm screen with nothing else standing between it and a revert.
|
|
14
|
-
*/
|
|
15
|
-
function checkDraw(suite, preview, underlying) {
|
|
16
|
-
const drawn = preview.operation === "AdjustCreditAccount" ? preview.totalDebtChange.value : preview.totalDebt.value;
|
|
17
|
-
if (drawn <= 0n) return [];
|
|
18
|
-
const maxBorrowAmount = suite.maxBorrowAmount();
|
|
19
|
-
return checkBorrowLimit({
|
|
20
|
-
requested: drawn,
|
|
21
|
-
available: maxBorrowAmount.amount.value,
|
|
22
|
-
limit: maxBorrowAmount.limit,
|
|
23
|
-
underlying
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { checkDraw };
|