@gearbox-protocol/sdk 14.1.1 → 14.2.1
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/dev/claimDSToken.js +208 -0
- package/dist/cjs/plugins/accounts/AccountsPlugin.js +1 -2
- package/dist/cjs/sdk/OnchainSDK.js +12 -0
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +1448 -23
- package/dist/cjs/sdk/accounts/index.js +0 -4
- package/dist/cjs/sdk/market/credit/CreditFacadeV310Contract.js +6 -0
- package/dist/cjs/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +19 -2
- package/dist/cjs/sdk/market/kyc/securitize/types.js +20 -0
- package/dist/cjs/sdk/market/oracle/PriceOracleV310Contract.js +26 -0
- package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -0
- package/dist/esm/dev/claimDSToken.js +187 -0
- package/dist/esm/plugins/accounts/AccountsPlugin.js +2 -7
- package/dist/esm/sdk/OnchainSDK.js +14 -0
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +1466 -23
- package/dist/esm/sdk/accounts/index.js +0 -2
- package/dist/esm/sdk/accounts/multicall-utils.js +1 -5
- package/dist/esm/sdk/market/credit/CreditFacadeV310Contract.js +6 -0
- package/dist/esm/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +21 -2
- package/dist/esm/sdk/market/kyc/securitize/types.js +12 -0
- package/dist/esm/sdk/market/oracle/PriceOracleV310Contract.js +26 -0
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -0
- package/dist/types/dev/claimDSToken.d.ts +34 -0
- package/dist/types/sdk/OnchainSDK.d.ts +10 -0
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +181 -3
- package/dist/types/sdk/accounts/index.d.ts +0 -2
- package/dist/types/sdk/accounts/types.d.ts +56 -0
- package/dist/types/sdk/market/credit/CreditFacadeV310Contract.d.ts +2 -0
- package/dist/types/sdk/market/kyc/securitize/SecuritizeKYCFactory.d.ts +1 -1
- package/dist/types/sdk/market/kyc/securitize/types.d.ts +37 -22
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +5 -0
- package/dist/types/sdk/market/oracle/PriceOracleV310Contract.d.ts +4 -0
- package/dist/types/sdk/market/oracle/types.d.ts +9 -0
- package/dist/types/sdk/pools/types.d.ts +19 -0
- package/package.json +1 -1
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +0 -1411
- package/dist/cjs/sdk/accounts/createCreditAccountService.js +0 -35
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +0 -1405
- package/dist/esm/sdk/accounts/createCreditAccountService.js +0 -11
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +0 -226
- package/dist/types/sdk/accounts/createCreditAccountService.d.ts +0 -9
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
decodeFunctionData,
|
|
3
|
-
getAbiItem,
|
|
4
|
-
toFunctionSelector
|
|
5
|
-
} from "viem";
|
|
1
|
+
import { decodeFunctionData, getAbiItem, toFunctionSelector } from "viem";
|
|
6
2
|
import { iCreditFacadeMulticallV310Abi } from "../../abi/310/generated.js";
|
|
7
3
|
import { AddressMap } from "../utils/AddressMap.js";
|
|
8
4
|
import { AddressSet } from "../utils/AddressSet.js";
|
|
@@ -60,6 +60,12 @@ class CreditFacadeV310Contract extends CreditFacadeV310BaseContract {
|
|
|
60
60
|
args: lossPolicyData ? [ca, to, calls, lossPolicyData] : [ca, to, calls]
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
+
partiallyLiquidateCreditAccount(ca, token, repaidAmount, minSeizedAmount, to, updates) {
|
|
64
|
+
return this.createRawTx({
|
|
65
|
+
functionName: "partiallyLiquidateCreditAccount",
|
|
66
|
+
args: [ca, token, repaidAmount, minSeizedAmount, to, updates]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
63
69
|
closeCreditAccount(ca, calls) {
|
|
64
70
|
return this.createRawTx({
|
|
65
71
|
functionName: "closeCreditAccount",
|
|
@@ -3,6 +3,9 @@ import { iSecuritizeKYCFactoryAbi } from "../../../../abi/kyc/iSecuritizeKYCFact
|
|
|
3
3
|
import { BaseContract } from "../../../base/index.js";
|
|
4
4
|
import { AddressMap, AddressSet } from "../../../utils/index.js";
|
|
5
5
|
import { KYC_FACTORY_SECURITIZE } from "./constants.js";
|
|
6
|
+
import {
|
|
7
|
+
SECURITIZE_REGISTER_VAULT_TYPES
|
|
8
|
+
} from "./types.js";
|
|
6
9
|
const abi = iSecuritizeKYCFactoryAbi;
|
|
7
10
|
class SecuritizeKYCFactory extends BaseContract {
|
|
8
11
|
#sdk;
|
|
@@ -70,7 +73,23 @@ class SecuritizeKYCFactory extends BaseContract {
|
|
|
70
73
|
type: KYC_FACTORY_SECURITIZE,
|
|
71
74
|
factory: this.address,
|
|
72
75
|
cachedSignatures: [...cachedSignatures],
|
|
73
|
-
registerVaultMessages:
|
|
76
|
+
registerVaultMessages: registerVaultMessages.map((m) => ({
|
|
77
|
+
types: SECURITIZE_REGISTER_VAULT_TYPES,
|
|
78
|
+
primaryType: "RegisterVault",
|
|
79
|
+
domain: {
|
|
80
|
+
name: m.domain.name,
|
|
81
|
+
version: m.domain.version,
|
|
82
|
+
chainId: m.domain.chainId,
|
|
83
|
+
verifyingContract: m.domain.verifyingContract
|
|
84
|
+
},
|
|
85
|
+
message: {
|
|
86
|
+
investor: m.investor,
|
|
87
|
+
operator: m.operator,
|
|
88
|
+
token: m.token,
|
|
89
|
+
nonce: m.nonce,
|
|
90
|
+
deadline: m.deadline
|
|
91
|
+
}
|
|
92
|
+
})),
|
|
74
93
|
registeredTokens: [...registeredTokens],
|
|
75
94
|
creditAccounts: creditAccounts.map((ca) => {
|
|
76
95
|
const [registeredTokens2] = decodeAbiParameters(
|
|
@@ -140,7 +159,7 @@ class SecuritizeKYCFactory extends BaseContract {
|
|
|
140
159
|
const unsignedTokens = tokensToRegister.difference(signedTokens);
|
|
141
160
|
const securitizeTokensToRegister = tokensToRegister.difference(registredTokens);
|
|
142
161
|
const requiredSignatures = investorData.registerVaultMessages.filter(
|
|
143
|
-
(m) => unsignedTokens.has(m.token)
|
|
162
|
+
(m) => unsignedTokens.has(m.message.token)
|
|
144
163
|
);
|
|
145
164
|
return {
|
|
146
165
|
type: KYC_FACTORY_SECURITIZE,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const SECURITIZE_REGISTER_VAULT_TYPES = {
|
|
2
|
+
RegisterVault: [
|
|
3
|
+
{ name: "investor", type: "address" },
|
|
4
|
+
{ name: "operator", type: "address" },
|
|
5
|
+
{ name: "token", type: "address" },
|
|
6
|
+
{ name: "nonce", type: "uint256" },
|
|
7
|
+
{ name: "deadline", type: "uint256" }
|
|
8
|
+
]
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
SECURITIZE_REGISTER_VAULT_TYPES
|
|
12
|
+
};
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
iCreditFacadeMulticallV310Abi,
|
|
6
6
|
iPriceOracleV310Abi
|
|
7
7
|
} from "../../../abi/310/generated.js";
|
|
8
|
+
import { simulateWithPriceUpdates } from "../../utils/viem/simulateWithPriceUpdates.js";
|
|
8
9
|
import {
|
|
9
10
|
getRawPriceUpdates
|
|
10
11
|
} from "../pricefeeds/index.js";
|
|
@@ -48,6 +49,31 @@ class PriceOracleV310Contract extends PriceOracleBaseContract {
|
|
|
48
49
|
]
|
|
49
50
|
};
|
|
50
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* {@inheritDoc IPriceOracleContract.updateAndConvert}
|
|
54
|
+
**/
|
|
55
|
+
async updateAndConvert(from, to, amount) {
|
|
56
|
+
const fromFeed = this.mainPriceFeeds.mustGet(from).priceFeed;
|
|
57
|
+
const toFeed = this.mainPriceFeeds.mustGet(to).priceFeed;
|
|
58
|
+
const updates = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs([
|
|
59
|
+
fromFeed,
|
|
60
|
+
toFeed
|
|
61
|
+
]);
|
|
62
|
+
const [result] = await simulateWithPriceUpdates(this.sdk.client, {
|
|
63
|
+
priceUpdates: updates.txs,
|
|
64
|
+
contracts: [
|
|
65
|
+
{
|
|
66
|
+
abi: this.contract.abi,
|
|
67
|
+
functionName: "convert",
|
|
68
|
+
args: [amount, from, to],
|
|
69
|
+
address: this.contract.address
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
strictPrices: true,
|
|
73
|
+
gas: this.sdk.gasLimit
|
|
74
|
+
});
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
51
77
|
processLog(log) {
|
|
52
78
|
switch (log.eventName) {
|
|
53
79
|
case "SetPriceFeed":
|
|
@@ -85,6 +85,9 @@ class PriceFeedRegister extends SDKConstruct {
|
|
|
85
85
|
updateables = this.sdk.marketRegister.priceOracles.flatMap((o) => o.reservePriceFeeds.values()).flatMap((pf) => pf.priceFeed.updatableDependencies());
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
+
if (updateables.length === 0) {
|
|
89
|
+
return { txs: [], timestamp: 0 };
|
|
90
|
+
}
|
|
88
91
|
const txs = [];
|
|
89
92
|
const latestUpdate = {
|
|
90
93
|
updates: [],
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Address, type Hex } from "viem";
|
|
2
|
+
import { type ILogger } from "../sdk/index.js";
|
|
3
|
+
import type { AnvilClient } from "./createAnvilClient.js";
|
|
4
|
+
interface ClaimDSTokenProps {
|
|
5
|
+
anvil: AnvilClient;
|
|
6
|
+
claimer: Address;
|
|
7
|
+
adminPrivateKey: Hex;
|
|
8
|
+
/**
|
|
9
|
+
* DSToken addresses
|
|
10
|
+
*/
|
|
11
|
+
token: Address;
|
|
12
|
+
/**
|
|
13
|
+
* USD amount without decimals
|
|
14
|
+
*/
|
|
15
|
+
usdAmount?: string;
|
|
16
|
+
marketConfigurators?: Address[];
|
|
17
|
+
kycFactories?: Address[];
|
|
18
|
+
logger?: ILogger;
|
|
19
|
+
}
|
|
20
|
+
type ClaimDSTokensProps = Omit<ClaimDSTokenProps, "token"> & {
|
|
21
|
+
tokens: Address[];
|
|
22
|
+
};
|
|
23
|
+
export declare function registerInvestor(props: ClaimDSTokenProps): Promise<void>;
|
|
24
|
+
export declare function claimDSToken(props: ClaimDSTokenProps): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Helper function to claim DSToken from the faucet.
|
|
27
|
+
* Works both for MockDStoken and real DSToken connected by securitize-deploy script
|
|
28
|
+
* @param forkStatus
|
|
29
|
+
* @param publicClient
|
|
30
|
+
* @param claimer
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
export declare function claimDSTokens(props: ClaimDSTokensProps): Promise<void>;
|
|
34
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import { type PublicClient, type Transport } from "viem";
|
|
3
3
|
import type { HttpRpcClientOptions } from "viem/utils";
|
|
4
|
+
import { type ICreditAccountsService } from "./accounts/index.js";
|
|
4
5
|
import type { BaseState, IBaseContract } from "./base/index.js";
|
|
5
6
|
import { ChainContractsRegister } from "./base/index.js";
|
|
6
7
|
import type { GearboxChain, NetworkType } from "./chain/chains.js";
|
|
@@ -11,6 +12,7 @@ import { MarketRegister } from "./market/MarketRegister.js";
|
|
|
11
12
|
import { PriceFeedRegister } from "./market/pricefeeds/index.js";
|
|
12
13
|
import type { PythOptions, RedstoneOptions } from "./market/pricefeeds/updates/index.js";
|
|
13
14
|
import type { PluginsMap } from "./plugins/index.js";
|
|
15
|
+
import { type IPoolsService } from "./pools/index.js";
|
|
14
16
|
import { type IRouterContract } from "./router/index.js";
|
|
15
17
|
import type { GearboxState, GearboxStateHuman, ILogger } from "./types/index.js";
|
|
16
18
|
/**
|
|
@@ -177,6 +179,14 @@ export declare class OnchainSDK<const Plugins extends PluginsMap = {}> extends C
|
|
|
177
179
|
* When `true`, the SDK throws on unrecognised contract types.
|
|
178
180
|
**/
|
|
179
181
|
readonly strictContractTypes: boolean;
|
|
182
|
+
/**
|
|
183
|
+
* Namespace for credit accounts operations.
|
|
184
|
+
*/
|
|
185
|
+
readonly accounts: ICreditAccountsService;
|
|
186
|
+
/**
|
|
187
|
+
* Namespace for pool operations.
|
|
188
|
+
*/
|
|
189
|
+
readonly pools: IPoolsService;
|
|
180
190
|
/**
|
|
181
191
|
* @param network - Gearbox network type (e.g. `"Mainnet"`, `"Monad"`).
|
|
182
192
|
* @param clientOptions - Connection options (RPC URLs, transport, or client).
|
|
@@ -1,5 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { CreditAccountData } from "../base/index.js";
|
|
3
|
+
import { SDKConstruct } from "../base/index.js";
|
|
4
|
+
import { type PriceUpdate } from "../market/index.js";
|
|
5
|
+
import type { KYCOpenAccountRequirements } from "../market/kyc/index.js";
|
|
6
|
+
import type { OnchainSDK } from "../OnchainSDK.js";
|
|
7
|
+
import { type RouterCASlice } from "../router/index.js";
|
|
8
|
+
import type { MultiCall, RawTx } from "../types/index.js";
|
|
9
|
+
import type { AccountToCheck, AddCollateralProps, ChangeDeptProps, ClaimDelayedProps, ClaimFarmRewardsProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, CreditAccountTokensSlice, CreditManagerOperationResult, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, OpenCAProps, PartiallyLiquidateProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, Rewards, SetBotProps, StartDelayedWithdrawalProps, UpdateQuotasProps, WithdrawCollateralProps } from "./types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Options for configuring the credit account service.
|
|
12
|
+
**/
|
|
13
|
+
export interface CreditAccountServiceOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Maximum number of credit accounts to fetch per compressor call.
|
|
16
|
+
* When set, accounts are loaded in batches of this size until all are fetched.
|
|
17
|
+
**/
|
|
18
|
+
batchSize?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns the withdrawal compressor contract address for the given chain, or `undefined` if none is configured.
|
|
22
|
+
* @param chainId - Numeric chain ID.
|
|
23
|
+
* @returns Withdrawal compressor address, or `undefined`.
|
|
24
|
+
**/
|
|
25
|
+
export declare function getWithdrawalCompressorAddress(chainId: number): `0x${string}`;
|
|
3
26
|
/**
|
|
4
27
|
* Service for querying and operating on Gearbox credit accounts.
|
|
5
28
|
*
|
|
@@ -9,7 +32,138 @@ import type { ClaimFarmRewardsProps, CreditAccountOperationResult, CreditManager
|
|
|
9
32
|
*
|
|
10
33
|
* @see {@link ICreditAccountsService}
|
|
11
34
|
**/
|
|
12
|
-
export declare class
|
|
35
|
+
export declare class CreditAccountsServiceV310 extends SDKConstruct implements ICreditAccountsService {
|
|
36
|
+
#private;
|
|
37
|
+
constructor(sdk: OnchainSDK, options?: CreditAccountServiceOptions);
|
|
38
|
+
setBatchSize(batchSize: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* {@inheritDoc ICreditAccountsService.getCreditAccountData}
|
|
41
|
+
**/
|
|
42
|
+
getCreditAccountData(account: Address, blockNumber?: bigint): Promise<CreditAccountData<true> | undefined>;
|
|
43
|
+
/**
|
|
44
|
+
* {@inheritDoc ICreditAccountsService.getCreditAccounts}
|
|
45
|
+
**/
|
|
46
|
+
getCreditAccounts(options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountData>>;
|
|
47
|
+
/**
|
|
48
|
+
* {@inheritDoc ICreditAccountsService.getBorrowerCreditAccounts}
|
|
49
|
+
**/
|
|
50
|
+
getBorrowerCreditAccounts(borrower: Address, options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountData<true>>>;
|
|
51
|
+
/**
|
|
52
|
+
* {@inheritDoc ICreditAccountsService.getRewards}
|
|
53
|
+
**/
|
|
54
|
+
getRewards(creditAccount: Address): Promise<Array<Rewards>>;
|
|
55
|
+
/**
|
|
56
|
+
* {@inheritDoc ICreditAccountsService.getConnectedBots}
|
|
57
|
+
**/
|
|
58
|
+
getConnectedBots(accountsToCheck: Array<AccountToCheck>, legacyMigrationBot: Address | undefined, additionalBots: Array<Address>): Promise<{
|
|
59
|
+
legacy: GetConnectedBotsResult;
|
|
60
|
+
legacyMigration: GetConnectedMigrationBotsResult;
|
|
61
|
+
additionalBots: Array<Omit<NonNullable<GetConnectedMigrationBotsResult>, "botAddress">>;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* {@inheritDoc ICreditAccountsService.fullyLiquidate}
|
|
65
|
+
**/
|
|
66
|
+
fullyLiquidate(props: FullyLiquidateProps): Promise<FullyLiquidateResult>;
|
|
67
|
+
/**
|
|
68
|
+
* {@inheritDoc ICreditAccountsService.calcMinSeizedAmount}
|
|
69
|
+
*/
|
|
70
|
+
calcMinSeizedAmount(props: PartiallyLiquidateProps): bigint;
|
|
71
|
+
/**
|
|
72
|
+
* {@inheritDoc ICreditAccountsService.partiallyLiquidate}
|
|
73
|
+
*/
|
|
74
|
+
partiallyLiquidate(props: PartiallyLiquidateProps): Promise<RawTx>;
|
|
75
|
+
/**
|
|
76
|
+
* {@inheritDoc ICreditAccountsService.closeCreditAccount}
|
|
77
|
+
**/
|
|
78
|
+
closeCreditAccount({ operation, assetsToWithdraw, creditAccount: ca, to, slippage, closePath, }: CloseCreditAccountProps): Promise<CloseCreditAccountResult>;
|
|
79
|
+
/**
|
|
80
|
+
* {@inheritDoc ICreditAccountsService.updateQuotas}
|
|
81
|
+
**/
|
|
82
|
+
updateQuotas({ minQuota, averageQuota, creditAccount, }: UpdateQuotasProps): Promise<CreditAccountOperationResult>;
|
|
83
|
+
/**
|
|
84
|
+
* {@inheritDoc ICreditAccountsService.addCollateral}
|
|
85
|
+
**/
|
|
86
|
+
addCollateral({ creditAccount, asset, permit, ethAmount, minQuota, averageQuota, }: AddCollateralProps): Promise<CreditAccountOperationResult>;
|
|
87
|
+
/**
|
|
88
|
+
* {@inheritDoc ICreditAccountsService.changeDebt}
|
|
89
|
+
**/
|
|
90
|
+
changeDebt({ creditAccount, amount, collateral, }: ChangeDeptProps): Promise<CreditAccountOperationResult>;
|
|
91
|
+
/**
|
|
92
|
+
* {@inheritDoc ICreditAccountsService.executeSwap}
|
|
93
|
+
**/
|
|
94
|
+
executeSwap({ creditAccount, calls: swapCalls, minQuota, averageQuota, }: ExecuteSwapProps): Promise<CreditAccountOperationResult>;
|
|
95
|
+
/**
|
|
96
|
+
* {@inheritDoc ICreditAccountsService.previewDelayedWithdrawal}
|
|
97
|
+
**/
|
|
98
|
+
previewDelayedWithdrawal({ creditAccount, amount, token, }: PreviewDelayedWithdrawalProps): Promise<PreviewDelayedWithdrawalResult>;
|
|
99
|
+
/**
|
|
100
|
+
* {@inheritDoc ICreditAccountsService.getPendingWithdrawals}
|
|
101
|
+
**/
|
|
102
|
+
getPendingWithdrawals({ creditAccount, }: GetPendingWithdrawalsProps): Promise<GetPendingWithdrawalsResult>;
|
|
103
|
+
/**
|
|
104
|
+
* {@inheritDoc ICreditAccountsService.startDelayedWithdrawal}
|
|
105
|
+
**/
|
|
106
|
+
startDelayedWithdrawal({ creditAccount, minQuota, averageQuota, preview, }: StartDelayedWithdrawalProps): Promise<CreditAccountOperationResult>;
|
|
107
|
+
/**
|
|
108
|
+
* {@inheritDoc ICreditAccountsService.claimDelayed}
|
|
109
|
+
**/
|
|
110
|
+
claimDelayed({ creditAccount, minQuota, averageQuota, claimableNow, }: ClaimDelayedProps): Promise<CreditAccountOperationResult>;
|
|
111
|
+
/**
|
|
112
|
+
* {@inheritDoc ICreditAccountsService.getApprovalAddress}
|
|
113
|
+
**/
|
|
114
|
+
getApprovalAddress(options: GetApprovalAddressProps): Promise<Address>;
|
|
115
|
+
/**
|
|
116
|
+
* {@inheritDoc ICreditAccountsService.getOpenAccountRequirements}
|
|
117
|
+
*/
|
|
118
|
+
getOpenAccountRequirements(borrower: Address, creditManager: Address, props: GetOpenAccountRequirementsProps): Promise<KYCOpenAccountRequirements | undefined>;
|
|
119
|
+
/**
|
|
120
|
+
* {@inheritDoc ICreditAccountsService.openCA}
|
|
121
|
+
**/
|
|
122
|
+
openCA(props: OpenCAProps): Promise<CreditAccountOperationResult>;
|
|
123
|
+
/**
|
|
124
|
+
* {@inheritDoc ICreditAccountsService.getBorrowRate}
|
|
125
|
+
**/
|
|
126
|
+
getBorrowRate(ca: CreditAccountData): bigint;
|
|
127
|
+
/**
|
|
128
|
+
* {@inheritDoc ICreditAccountsService.getOptimalHFForPartialLiquidation}
|
|
129
|
+
**/
|
|
130
|
+
getOptimalHFForPartialLiquidation(ca: CreditAccountData): bigint;
|
|
131
|
+
/**
|
|
132
|
+
* Returns multicall entries to redeem (unwrap) KYC ERC-4626 vault shares into underlying for the given credit manager.
|
|
133
|
+
* Used when withdrawing debt from a KYC market: redeems adapter vault shares so the underlying can be withdrawn.
|
|
134
|
+
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
135
|
+
* @param amount - Number of vault shares (adapter tokens) to redeem
|
|
136
|
+
* @param creditManager - Credit manager address
|
|
137
|
+
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
138
|
+
*/
|
|
139
|
+
getKYCUnwrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
140
|
+
/**
|
|
141
|
+
* Returns multicall entries to deposit (wrap) underlying into KYC ERC-4626 vault shares for the given credit manager.
|
|
142
|
+
* Used when adding debt on a KYC market: deposits underlying into the adapter vault so shares are minted on the account.
|
|
143
|
+
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
144
|
+
* @param amount - Amount of underlying assets to deposit into the vault (in underlying decimals)
|
|
145
|
+
* @param creditManager - Credit manager address
|
|
146
|
+
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
147
|
+
*/
|
|
148
|
+
getKYCWrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
149
|
+
/**
|
|
150
|
+
* Returns multicall entries to call redeemDiff on the KYC ERC-4626 adapter for the given credit manager.
|
|
151
|
+
* Redeems the leftover vault shares (e.g. after repaying debt) so the account does not hold excess KYC vault tokens.
|
|
152
|
+
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
153
|
+
* @param amount - Leftover vault share amount to redeem (in adapter/vault decimals)
|
|
154
|
+
* @param creditManager - Credit manager address
|
|
155
|
+
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
156
|
+
*/
|
|
157
|
+
getRedeemDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
158
|
+
/**
|
|
159
|
+
* Returns multicall entries to call depositDiff on the KYC ERC-4626 adapter for the given credit manager.
|
|
160
|
+
* Deposits the leftover underlying (e.g. after decreasing debt) into the vault so the account does not hold excess underlying.
|
|
161
|
+
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
162
|
+
* @param amount - Leftover underlying amount to deposit into the vault (in underlying decimals)
|
|
163
|
+
* @param creditManager - Credit manager address
|
|
164
|
+
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
165
|
+
*/
|
|
166
|
+
getDepositDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
13
167
|
/**
|
|
14
168
|
* {@inheritDoc ICreditAccountsService.setBot}
|
|
15
169
|
*/
|
|
@@ -30,4 +184,28 @@ export declare class CreditAccountServiceV310 extends AbstractCreditAccountServi
|
|
|
30
184
|
* {@inheritDoc ICreditAccountsService.claimFarmRewards}
|
|
31
185
|
*/
|
|
32
186
|
claimFarmRewards({ calls: externalCalls, creditAccount: ca, minQuota, averageQuota, tokensToClaim, }: ClaimFarmRewardsProps): Promise<CreditAccountOperationResult>;
|
|
187
|
+
/**
|
|
188
|
+
* Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
|
|
189
|
+
* {@inheritDoc ICreditAccountsService.getOnDemandPriceUpdates}
|
|
190
|
+
**/
|
|
191
|
+
getOnDemandPriceUpdates(account: CreditAccountTokensSlice, ignoreReservePrices?: boolean): Promise<PriceUpdate[]>;
|
|
192
|
+
/**
|
|
193
|
+
* {@inheritDoc ICreditAccountsService.multicall}
|
|
194
|
+
*/
|
|
195
|
+
multicall(creditAccount: RouterCASlice, calls: MultiCall[], options?: {
|
|
196
|
+
ignoreReservePrices?: boolean;
|
|
197
|
+
}): Promise<RawTx>;
|
|
198
|
+
/**
|
|
199
|
+
* {@inheritDoc ICreditAccountsService.botMulticall}
|
|
200
|
+
*/
|
|
201
|
+
botMulticall(creditAccount: RouterCASlice, calls: MultiCall[], options?: {
|
|
202
|
+
ignoreReservePrices?: boolean;
|
|
203
|
+
}): Promise<RawTx>;
|
|
204
|
+
/**
|
|
205
|
+
* Returns addresses of market configurators
|
|
206
|
+
*/
|
|
207
|
+
private get marketConfigurators();
|
|
208
|
+
private get rewardCompressor();
|
|
209
|
+
private get peripheryCompressor();
|
|
210
|
+
private get compressor();
|
|
33
211
|
}
|
|
@@ -488,6 +488,42 @@ export interface FullyLiquidateProps {
|
|
|
488
488
|
*/
|
|
489
489
|
debtOnly?: boolean;
|
|
490
490
|
}
|
|
491
|
+
export interface CalcMinSeizedAmountProps {
|
|
492
|
+
/**
|
|
493
|
+
* Credit account to liquidate
|
|
494
|
+
*/
|
|
495
|
+
account: RouterCASlice;
|
|
496
|
+
/**
|
|
497
|
+
* Collateral token to seize
|
|
498
|
+
*/
|
|
499
|
+
token: Address;
|
|
500
|
+
/**
|
|
501
|
+
* Amount of underlying token to repay
|
|
502
|
+
*/
|
|
503
|
+
repaidAmount: bigint;
|
|
504
|
+
}
|
|
505
|
+
export interface PartiallyLiquidateProps {
|
|
506
|
+
/**
|
|
507
|
+
* Credit account to liquidate
|
|
508
|
+
*/
|
|
509
|
+
account: RouterCASlice;
|
|
510
|
+
/**
|
|
511
|
+
* Address to transfer underlying left after liquidation
|
|
512
|
+
*/
|
|
513
|
+
to: Address;
|
|
514
|
+
/**
|
|
515
|
+
* Collateral token to seize
|
|
516
|
+
*/
|
|
517
|
+
token: Address;
|
|
518
|
+
/**
|
|
519
|
+
* Amount of underlying token to repay
|
|
520
|
+
*/
|
|
521
|
+
repaidAmount: bigint;
|
|
522
|
+
/**
|
|
523
|
+
* Minimum amount of `token` to seize from `creditAccount`
|
|
524
|
+
*/
|
|
525
|
+
minSeizedAmount: bigint;
|
|
526
|
+
}
|
|
491
527
|
/**
|
|
492
528
|
* EIP-2612 permit signature data for a token, enabling gasless approval for credit account operations.
|
|
493
529
|
**/
|
|
@@ -681,6 +717,26 @@ export interface ICreditAccountsService extends Construct {
|
|
|
681
717
|
* @returns Transaction data and optional loss policy data
|
|
682
718
|
*/
|
|
683
719
|
fullyLiquidate(props: FullyLiquidateProps): Promise<FullyLiquidateResult>;
|
|
720
|
+
/**
|
|
721
|
+
* Calculates minimum amount of collateral token to seize from credit account
|
|
722
|
+
* for partial liquidation, can be passed to {@link partiallyLiquidate} as `minSeizedAmount`
|
|
723
|
+
* @param props - {@link CalcMinSeizedAmountProps}
|
|
724
|
+
* @returns Minimum amount of collateral token to seize
|
|
725
|
+
*/
|
|
726
|
+
calcMinSeizedAmount(props: CalcMinSeizedAmountProps): bigint;
|
|
727
|
+
/**
|
|
728
|
+
* Generates transaction to partially liquidate credit account;
|
|
729
|
+
*
|
|
730
|
+
* Transaction partially liquidates credit account's debt in exchange for discounted collateral
|
|
731
|
+
* by transferring underlying from the caller (requires approval to the credit manager) and uses it to repay
|
|
732
|
+
* account's debt and pay fees to the treasury
|
|
733
|
+
* Transfers chosen collateral token at discounted oracle price to the liquidator (liquidation discount
|
|
734
|
+
* and fee are the same as for full liquidations, though fees are not deposited into the pool)
|
|
735
|
+
*
|
|
736
|
+
* @param props - {@link PartiallyLiquidateProps}
|
|
737
|
+
* @returns Raw transaction ready to be signed and sent
|
|
738
|
+
*/
|
|
739
|
+
partiallyLiquidate(props: PartiallyLiquidateProps): Promise<RawTx>;
|
|
684
740
|
/**
|
|
685
741
|
* Closes credit account or closes credit account and keeps it open with zero debt.
|
|
686
742
|
* - Ca is closed in the following order: price update -> close path to swap all tokens into underlying ->
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Address, ContractEventName, Hex, Log } from "viem";
|
|
2
2
|
import type { ConstructOptions, CreditFacadeState, CreditSuiteState } from "../../base/index.js";
|
|
3
3
|
import type { CreditFacadeStateHuman, MultiCall, RawTx } from "../../types/index.js";
|
|
4
|
+
import type { PriceUpdate } from "../pricefeeds/index.js";
|
|
4
5
|
import type { CreditFacadeV310Abi } from "./CreditFacadeV310BaseContract.js";
|
|
5
6
|
import { CreditFacadeV310BaseContract } from "./CreditFacadeV310BaseContract.js";
|
|
6
7
|
type abi = CreditFacadeV310Abi;
|
|
@@ -12,6 +13,7 @@ export declare class CreditFacadeV310Contract extends CreditFacadeV310BaseContra
|
|
|
12
13
|
stateHuman(raw?: boolean): CreditFacadeStateHuman;
|
|
13
14
|
processLog(log: Log<bigint, number, false, undefined, undefined, abi, ContractEventName<abi>>): void;
|
|
14
15
|
liquidateCreditAccount(ca: Address, to: Address, calls: MultiCall[], lossPolicyData?: Hex): RawTx;
|
|
16
|
+
partiallyLiquidateCreditAccount(ca: Address, token: Address, repaidAmount: bigint, minSeizedAmount: bigint, to: Address, updates: PriceUpdate[]): RawTx;
|
|
15
17
|
closeCreditAccount(ca: Address, calls: MultiCall[]): RawTx;
|
|
16
18
|
multicall(ca: Address, calls: MultiCall[]): RawTx;
|
|
17
19
|
botMulticall(ca: Address, calls: MultiCall[]): RawTx;
|
|
@@ -5,7 +5,7 @@ import type { OnchainSDK } from "../../../OnchainSDK.js";
|
|
|
5
5
|
import type { MultiCall, RawTx } from "../../../types/index.js";
|
|
6
6
|
import type { IKYCFactory, KYCCompressorInvestorData, KYCFactoryData } from "../types.js";
|
|
7
7
|
import { KYC_FACTORY_SECURITIZE } from "./constants.js";
|
|
8
|
-
import type
|
|
8
|
+
import { type DStokenData, type SecuritizeInvestorData, type SecuritizeKYCFactoryStateHuman, type SecuritizeOpenAccountRequirements, type SecuritizeOperationParams } from "./types.js";
|
|
9
9
|
declare const abi: readonly [{
|
|
10
10
|
readonly type: "function";
|
|
11
11
|
readonly name: "contractType";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Address, Hex } from "viem";
|
|
1
|
+
import type { Address, Hex, TypedDataDefinition } from "viem";
|
|
2
2
|
import type { BaseContractStateHuman } from "../../../types/index.js";
|
|
3
3
|
import type { KYC_FACTORY_SECURITIZE } from "./constants.js";
|
|
4
4
|
/**
|
|
@@ -33,31 +33,46 @@ export interface SecuritizeSignature {
|
|
|
33
33
|
/** Raw EIP-712 signature bytes. */
|
|
34
34
|
signature: Hex;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* EIP-712 type schema for the `RegisterVault` message expected by Securitize's
|
|
38
|
+
* VaultRegistrar. Matches the contract's `RegisterVault` typehash field order.
|
|
39
|
+
**/
|
|
40
|
+
export declare const SECURITIZE_REGISTER_VAULT_TYPES: {
|
|
41
|
+
readonly RegisterVault: readonly [{
|
|
42
|
+
readonly name: "investor";
|
|
43
|
+
readonly type: "address";
|
|
44
|
+
}, {
|
|
45
|
+
readonly name: "operator";
|
|
46
|
+
readonly type: "address";
|
|
47
|
+
}, {
|
|
48
|
+
readonly name: "token";
|
|
49
|
+
readonly type: "address";
|
|
50
|
+
}, {
|
|
51
|
+
readonly name: "nonce";
|
|
52
|
+
readonly type: "uint256";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "deadline";
|
|
55
|
+
readonly type: "uint256";
|
|
56
|
+
}];
|
|
57
|
+
};
|
|
36
58
|
/**
|
|
37
59
|
* EIP-712 typed-data message that must be signed by the investor to allow the
|
|
38
|
-
* KYC factory to register a credit account as a vault in Securitize's VaultRegistrar
|
|
39
|
-
*
|
|
60
|
+
* KYC factory to register a credit account as a vault in Securitize's VaultRegistrar.
|
|
61
|
+
*
|
|
62
|
+
* Shaped as a viem {@link TypedDataDefinition} so it can be spread directly into
|
|
63
|
+
* `walletClient.signTypedData({ account, ...message })`. The caller only has to
|
|
64
|
+
* supply the signing `account`.
|
|
65
|
+
*
|
|
66
|
+
* - `domain` — EIP-712 domain from the VaultRegistrar contract.
|
|
67
|
+
* - `message.investor` — investor EOA that will sign the message.
|
|
68
|
+
* - `message.operator` — operator address (the DegenNFT contract).
|
|
69
|
+
* - `message.token` — DSToken address to register for.
|
|
70
|
+
* - `message.nonce` — monotonic nonce from VaultRegistrar `(investor, operator)`.
|
|
71
|
+
* - `message.deadline` — unix timestamp after which the message is no longer valid.
|
|
40
72
|
*
|
|
73
|
+
* @see VaultRegistrar in https://github.com/Gearbox-protocol/periphery-v3
|
|
41
74
|
**/
|
|
42
|
-
export
|
|
43
|
-
/** EIP-712 domain from the VaultRegistrar contract. */
|
|
44
|
-
domain: {
|
|
45
|
-
name: string;
|
|
46
|
-
version: string;
|
|
47
|
-
chainId: bigint;
|
|
48
|
-
verifyingContract: Address;
|
|
49
|
-
};
|
|
50
|
-
/** Investor EOA that will sign the message. */
|
|
51
|
-
investor: Address;
|
|
52
|
-
/** Operator address (the DegenNFT contract). */
|
|
53
|
-
operator: Address;
|
|
54
|
-
/** DSToken address to register for. */
|
|
55
|
-
token: Address;
|
|
56
|
-
/** Monotonic nonce from VaultRegistrar (investor, operator). */
|
|
57
|
-
nonce: bigint;
|
|
58
|
-
/** Unix timestamp after which the message is no longer valid. */
|
|
59
|
-
deadline: bigint;
|
|
60
|
-
}
|
|
75
|
+
export type SecuritizeRegisterVaultMessage = TypedDataDefinition<typeof SECURITIZE_REGISTER_VAULT_TYPES, "RegisterVault">;
|
|
61
76
|
/**
|
|
62
77
|
* Per-credit-account data decoded from the KYC compressor's
|
|
63
78
|
* `getCreditAccountData` extra details for a Securitize factory.
|
|
@@ -56,6 +56,11 @@ export declare abstract class PriceOracleBaseContract<abi extends Abi | readonly
|
|
|
56
56
|
* {@inheritDoc IPriceOracleContract.usesPriceFeed}
|
|
57
57
|
**/
|
|
58
58
|
usesPriceFeed(priceFeed: Address): boolean;
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* {@inheritDoc IPriceOracleContract.updateAndConvert}
|
|
62
|
+
**/
|
|
63
|
+
abstract updateAndConvert(from: Address, to: Address, amount: bigint): Promise<bigint>;
|
|
59
64
|
/**
|
|
60
65
|
* {@inheritDoc IPriceOracleContract.convert}
|
|
61
66
|
**/
|
|
@@ -349,6 +349,10 @@ export declare class PriceOracleV310Contract extends PriceOracleBaseContract<abi
|
|
|
349
349
|
* @returns
|
|
350
350
|
*/
|
|
351
351
|
onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult): OnDemandPriceUpdates;
|
|
352
|
+
/**
|
|
353
|
+
* {@inheritDoc IPriceOracleContract.updateAndConvert}
|
|
354
|
+
**/
|
|
355
|
+
updateAndConvert(from: Address, to: Address, amount: bigint): Promise<bigint>;
|
|
352
356
|
processLog(log: Log<bigint, number, false, undefined, undefined, abi, ContractEventName<abi>>): void;
|
|
353
357
|
}
|
|
354
358
|
export {};
|
|
@@ -114,6 +114,15 @@ export interface IPriceOracleContract extends IBaseContract {
|
|
|
114
114
|
* @param reserve - Use reserve feeds instead of main.
|
|
115
115
|
**/
|
|
116
116
|
convertFromUSD: (to: Address, amount: bigint, reserve?: boolean) => bigint;
|
|
117
|
+
/**
|
|
118
|
+
* Unlike {@link convert}, this method will update the price feeds before converting,
|
|
119
|
+
* and conversion will be peformed onchain using main price feeds
|
|
120
|
+
* @param from
|
|
121
|
+
* @param to
|
|
122
|
+
* @param amount
|
|
123
|
+
* @returns
|
|
124
|
+
*/
|
|
125
|
+
updateAndConvert: (from: Address, to: Address, amount: bigint) => Promise<bigint>;
|
|
117
126
|
/**
|
|
118
127
|
* @internal
|
|
119
128
|
**/
|
|
@@ -121,6 +121,25 @@ export interface IPoolsService {
|
|
|
121
121
|
* @param tokenOut can be undefined if deposit is not resulting in a token out (e.g. for KYC underlying on demand)
|
|
122
122
|
*/
|
|
123
123
|
getDepositMetadata(pool: Address, tokenIn: Address, tokenOut?: Address): DepositMetadata;
|
|
124
|
+
/**
|
|
125
|
+
* Returns a list of tokens that can be redeemed from a pool
|
|
126
|
+
* @param pool
|
|
127
|
+
*/
|
|
128
|
+
getWithdrawalTokensIn(pool: Address): Address[];
|
|
129
|
+
/**
|
|
130
|
+
* Returns a list of tokens that can be received after redeeming from a pool
|
|
131
|
+
* @param pool
|
|
132
|
+
* @param tokenIn token that will be redeemed from the pool
|
|
133
|
+
*/
|
|
134
|
+
getWithdrawalTokensOut(pool: Address, tokenIn: Address): Address[];
|
|
135
|
+
/**
|
|
136
|
+
* After user chooses tokenIn from {@link getWithdrawalTokensIn} and tokenOut from {@link getWithdrawalTokensOut},
|
|
137
|
+
* this method returns metadata that will be used to perform the withdrawal.
|
|
138
|
+
* @param pool
|
|
139
|
+
* @param tokenIn
|
|
140
|
+
* @param tokenOut
|
|
141
|
+
*/
|
|
142
|
+
getWithdrawalMetadata(pool: Address, tokenIn: Address, tokenOut?: Address): WithdrawalMetadata;
|
|
124
143
|
/**
|
|
125
144
|
* Returns contract call parameters for adding liquidity to a pool
|
|
126
145
|
* Or undefined if no deposit action is required (e.g. for KYC underlying on demand)
|