@gearbox-protocol/sdk 13.1.0-next.1 → 13.1.0
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/AccountOpener.js +5 -45
- package/dist/cjs/dev/index.js +8 -0
- package/dist/cjs/dev/isOutOfSyncError.js +56 -0
- package/dist/cjs/dev/isRateLimitError.js +80 -0
- package/dist/cjs/dev/isTransientError.js +83 -0
- package/dist/cjs/dev/providers.js +1 -1
- package/dist/cjs/dev/resilientTransport.js +104 -0
- package/dist/cjs/plugins/zappers/ZappersPlugin.js +144 -0
- package/dist/cjs/{sdk/market/ZapperRegister.js → plugins/zappers/extraZappers.js} +6 -110
- package/dist/cjs/plugins/zappers/index.js +26 -0
- package/dist/cjs/plugins/zappers/package.json +1 -0
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +104 -462
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +5 -16
- package/dist/cjs/sdk/base/ChainContractsRegister.js +1 -1
- package/dist/cjs/sdk/base/TokensMeta.js +32 -255
- package/dist/cjs/sdk/base/index.js +0 -2
- package/dist/cjs/sdk/chain/chains.js +5 -6
- package/dist/cjs/sdk/constants/index.js +2 -0
- package/dist/cjs/sdk/{base/token-types.js → constants/phantom-tokens.js} +3 -9
- package/dist/cjs/sdk/market/MarketRegister.js +2 -2
- package/dist/cjs/sdk/market/MarketSuite.js +0 -6
- package/dist/cjs/sdk/market/index.js +1 -3
- package/dist/cjs/sdk/market/pool/PoolSuite.js +0 -3
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +2 -17
- package/dist/cjs/sdk/market/pool/index.js +0 -4
- package/dist/cjs/sdk/pools/AbstractPoolService.js +137 -0
- package/dist/cjs/{abi/iStateSerializer.js → sdk/pools/PoolServiceV310.js} +8 -14
- package/dist/cjs/sdk/pools/createPoolService.js +35 -0
- package/dist/cjs/sdk/pools/index.js +4 -2
- package/dist/cjs/sdk/utils/AddressMap.js +1 -1
- package/dist/cjs/sdk/utils/viem/sendRawTx.js +0 -16
- package/dist/esm/dev/AccountOpener.js +6 -47
- package/dist/esm/dev/index.js +4 -0
- package/dist/esm/dev/isOutOfSyncError.js +32 -0
- package/dist/esm/dev/isRateLimitError.js +56 -0
- package/dist/esm/dev/isTransientError.js +59 -0
- package/dist/esm/dev/providers.js +1 -1
- package/dist/esm/dev/resilientTransport.js +79 -0
- package/dist/esm/plugins/zappers/ZappersPlugin.js +126 -0
- package/dist/esm/{sdk/market/ZapperRegister.js → plugins/zappers/extraZappers.js} +2 -109
- package/dist/esm/plugins/zappers/index.js +3 -0
- package/dist/esm/plugins/zappers/package.json +1 -0
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +104 -462
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +5 -16
- package/dist/esm/sdk/base/ChainContractsRegister.js +1 -1
- package/dist/esm/sdk/base/TokensMeta.js +32 -261
- package/dist/esm/sdk/base/index.js +0 -1
- package/dist/esm/sdk/chain/chains.js +5 -6
- package/dist/esm/sdk/constants/index.js +1 -0
- package/dist/esm/sdk/{base/token-types.js → constants/phantom-tokens.js} +0 -4
- package/dist/esm/sdk/market/MarketRegister.js +2 -2
- package/dist/esm/sdk/market/MarketSuite.js +0 -6
- package/dist/esm/sdk/market/index.js +0 -1
- package/dist/esm/sdk/market/pool/PoolSuite.js +0 -3
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +2 -17
- package/dist/esm/sdk/market/pool/index.js +0 -2
- package/dist/esm/sdk/pools/AbstractPoolService.js +113 -0
- package/dist/esm/sdk/pools/PoolServiceV310.js +6 -0
- package/dist/esm/sdk/pools/createPoolService.js +11 -0
- package/dist/esm/sdk/pools/index.js +2 -1
- package/dist/esm/sdk/utils/AddressMap.js +1 -1
- package/dist/esm/sdk/utils/viem/sendRawTx.js +1 -19
- package/dist/types/dev/index.d.ts +4 -0
- package/dist/types/dev/isOutOfSyncError.d.ts +4 -0
- package/dist/types/dev/isRateLimitError.d.ts +4 -0
- package/dist/types/dev/isTransientError.d.ts +4 -0
- package/dist/types/dev/resilientTransport.d.ts +19 -0
- package/dist/types/plugins/zappers/ZappersPlugin.d.ts +18 -0
- package/dist/types/plugins/zappers/extraZappers.d.ts +6 -0
- package/dist/types/plugins/zappers/index.d.ts +3 -0
- package/dist/types/plugins/zappers/types.d.ts +12 -0
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +27 -123
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
- package/dist/types/sdk/accounts/types.d.ts +8 -108
- package/dist/types/sdk/base/TokensMeta.d.ts +18 -34
- package/dist/types/sdk/base/index.d.ts +0 -1
- package/dist/types/sdk/base/types.d.ts +1 -0
- package/dist/types/sdk/chain/chains.d.ts +1 -1
- package/dist/types/sdk/constants/index.d.ts +1 -0
- package/dist/types/sdk/constants/phantom-tokens.d.ts +2 -0
- package/dist/types/sdk/market/MarketRegister.d.ts +2 -2
- package/dist/types/sdk/market/MarketSuite.d.ts +0 -3
- package/dist/types/sdk/market/index.d.ts +0 -1
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +0 -2
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +2 -6
- package/dist/types/sdk/market/pool/index.d.ts +0 -2
- package/dist/types/sdk/pools/AbstractPoolService.d.ts +9 -0
- package/dist/types/sdk/pools/PoolServiceV310.d.ts +4 -0
- package/dist/types/sdk/pools/createPoolService.d.ts +3 -0
- package/dist/types/sdk/pools/index.d.ts +2 -1
- package/dist/types/sdk/pools/types.d.ts +63 -84
- package/dist/types/sdk/utils/AddressMap.d.ts +1 -1
- package/dist/types/sdk/utils/viem/sendRawTx.d.ts +1 -5
- package/package.json +6 -5
- package/dist/cjs/abi/310/iSecuritizeDegenNFT.js +0 -263
- package/dist/cjs/abi/310/iSecuritizeKYCFactory.js +0 -278
- package/dist/cjs/sdk/market/pool/SecuritizeKYCFactory.js +0 -97
- package/dist/cjs/sdk/pools/PoolService.js +0 -391
- package/dist/esm/abi/310/iSecuritizeDegenNFT.js +0 -239
- package/dist/esm/abi/310/iSecuritizeKYCFactory.js +0 -254
- package/dist/esm/abi/iStateSerializer.js +0 -12
- package/dist/esm/sdk/market/pool/SecuritizeKYCFactory.js +0 -73
- package/dist/esm/sdk/pools/PoolService.js +0 -371
- package/dist/types/abi/310/iSecuritizeDegenNFT.d.ts +0 -324
- package/dist/types/abi/310/iSecuritizeKYCFactory.d.ts +0 -322
- package/dist/types/abi/iStateSerializer.d.ts +0 -11
- package/dist/types/sdk/base/token-types.d.ts +0 -33
- package/dist/types/sdk/market/ZapperRegister.d.ts +0 -17
- package/dist/types/sdk/market/pool/SecuritizeKYCFactory.d.ts +0 -345
- package/dist/types/sdk/market/types.d.ts +0 -10
- package/dist/types/sdk/pools/PoolService.d.ts +0 -14
- /package/dist/cjs/{sdk/market → plugins/zappers}/types.js +0 -0
- /package/dist/esm/{sdk/market → plugins/zappers}/types.js +0 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { iPoolV310Abi } from "../../abi/310/generated.js";
|
|
2
|
+
import { ierc20ZapperDepositsAbi } from "../../abi/iERC20ZapperDeposits.js";
|
|
3
|
+
import { iethZapperDepositsAbi } from "../../abi/iETHZapperDeposits.js";
|
|
4
|
+
import { iZapperAbi } from "../../abi/iZapper.js";
|
|
5
|
+
import { SDKConstruct } from "../base/index.js";
|
|
6
|
+
class AbstractPoolService extends SDKConstruct {
|
|
7
|
+
#version;
|
|
8
|
+
constructor(sdk, version) {
|
|
9
|
+
super(sdk);
|
|
10
|
+
this.#version = version;
|
|
11
|
+
this.logger?.debug(`Created PoolService with version: ${this.#version}`);
|
|
12
|
+
}
|
|
13
|
+
addLiquidity({
|
|
14
|
+
collateral,
|
|
15
|
+
pool,
|
|
16
|
+
account,
|
|
17
|
+
zapper,
|
|
18
|
+
permit,
|
|
19
|
+
nativeTokenAddress,
|
|
20
|
+
referralCode = 0n,
|
|
21
|
+
migrate
|
|
22
|
+
}) {
|
|
23
|
+
if (zapper?.tokenIn === nativeTokenAddress) {
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
target: zapper.zapper,
|
|
27
|
+
abi: iethZapperDepositsAbi,
|
|
28
|
+
functionName: "depositWithReferral",
|
|
29
|
+
args: [account, referralCode],
|
|
30
|
+
value: collateral.balance
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
} else if (zapper) {
|
|
34
|
+
return permit ? [
|
|
35
|
+
{
|
|
36
|
+
target: zapper.zapper,
|
|
37
|
+
abi: ierc20ZapperDepositsAbi,
|
|
38
|
+
functionName: "depositWithReferralAndPermit",
|
|
39
|
+
args: [
|
|
40
|
+
collateral.balance,
|
|
41
|
+
account,
|
|
42
|
+
referralCode,
|
|
43
|
+
permit.deadline,
|
|
44
|
+
permit.v,
|
|
45
|
+
permit.r,
|
|
46
|
+
permit.s
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
] : [
|
|
50
|
+
{
|
|
51
|
+
target: zapper.zapper,
|
|
52
|
+
abi: ierc20ZapperDepositsAbi,
|
|
53
|
+
functionName: "depositWithReferral",
|
|
54
|
+
args: [collateral.balance, account, referralCode]
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
} else {
|
|
58
|
+
if (migrate) throw Error("No zapper for migration");
|
|
59
|
+
return [
|
|
60
|
+
{
|
|
61
|
+
target: pool,
|
|
62
|
+
abi: iPoolV310Abi,
|
|
63
|
+
functionName: "depositWithReferral",
|
|
64
|
+
args: [collateral.balance, account, referralCode]
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
removeLiquidity({
|
|
70
|
+
pool,
|
|
71
|
+
amount,
|
|
72
|
+
account,
|
|
73
|
+
zapper,
|
|
74
|
+
permit
|
|
75
|
+
}) {
|
|
76
|
+
if (zapper) {
|
|
77
|
+
return permit ? [
|
|
78
|
+
{
|
|
79
|
+
target: zapper.zapper,
|
|
80
|
+
abi: iZapperAbi,
|
|
81
|
+
functionName: "redeemWithPermit",
|
|
82
|
+
args: [
|
|
83
|
+
amount,
|
|
84
|
+
account,
|
|
85
|
+
permit.deadline,
|
|
86
|
+
permit.v,
|
|
87
|
+
permit.r,
|
|
88
|
+
permit.s
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
] : [
|
|
92
|
+
{
|
|
93
|
+
target: zapper.zapper,
|
|
94
|
+
abi: iZapperAbi,
|
|
95
|
+
functionName: "redeem",
|
|
96
|
+
args: [amount, account]
|
|
97
|
+
}
|
|
98
|
+
];
|
|
99
|
+
} else {
|
|
100
|
+
return [
|
|
101
|
+
{
|
|
102
|
+
target: pool,
|
|
103
|
+
abi: iPoolV310Abi,
|
|
104
|
+
functionName: "redeem",
|
|
105
|
+
args: [amount, account, account]
|
|
106
|
+
}
|
|
107
|
+
];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export {
|
|
112
|
+
AbstractPoolService
|
|
113
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isV310 } from "../constants/index.js";
|
|
2
|
+
import { PoolServiceV310 } from "./PoolServiceV310.js";
|
|
3
|
+
function createPoolService(sdk, version) {
|
|
4
|
+
if (isV310(version)) {
|
|
5
|
+
return new PoolServiceV310(sdk, version);
|
|
6
|
+
}
|
|
7
|
+
throw new Error(`Unsupported Pool Service version ${version}`);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
createPoolService
|
|
11
|
+
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
estimateGas,
|
|
3
|
-
sendTransaction
|
|
4
|
-
} from "viem/actions";
|
|
1
|
+
import { sendTransaction } from "viem/actions";
|
|
5
2
|
import { getAction } from "viem/utils";
|
|
6
3
|
async function sendRawTx(client, params) {
|
|
7
4
|
const { tx, ...rest } = params;
|
|
@@ -16,21 +13,6 @@ async function sendRawTx(client, params) {
|
|
|
16
13
|
value: BigInt(tx.value)
|
|
17
14
|
});
|
|
18
15
|
}
|
|
19
|
-
async function estimateRawTxGas(client, params) {
|
|
20
|
-
const { tx, ...rest } = params;
|
|
21
|
-
return getAction(
|
|
22
|
-
client,
|
|
23
|
-
estimateGas,
|
|
24
|
-
"estimateGas"
|
|
25
|
-
)({
|
|
26
|
-
...rest,
|
|
27
|
-
account: params.account,
|
|
28
|
-
data: tx.callData,
|
|
29
|
-
to: tx.to,
|
|
30
|
-
value: BigInt(tx.value)
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
16
|
export {
|
|
34
|
-
estimateRawTxGas,
|
|
35
17
|
sendRawTx
|
|
36
18
|
};
|
|
@@ -6,11 +6,15 @@ export * from "./create2.js";
|
|
|
6
6
|
export * from "./createAnvilClient.js";
|
|
7
7
|
export * from "./detectChain.js";
|
|
8
8
|
export * from "./EthCallSpy.js";
|
|
9
|
+
export * from "./isOutOfSyncError.js";
|
|
10
|
+
export * from "./isRateLimitError.js";
|
|
11
|
+
export * from "./isTransientError.js";
|
|
9
12
|
export * from "./ltUtils.js";
|
|
10
13
|
export * from "./migrateFaucet.js";
|
|
11
14
|
export * from "./mint/index.js";
|
|
12
15
|
export * from "./providers.js";
|
|
13
16
|
export * from "./RevolverTransport.js";
|
|
14
17
|
export * from "./replaceStorage.js";
|
|
18
|
+
export * from "./resilientTransport.js";
|
|
15
19
|
export * from "./transports.js";
|
|
16
20
|
export * from "./types.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Transport } from "viem";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
|
+
/** Schema for {@link ResilientTransportOptions}. */
|
|
4
|
+
export declare const resilientTransportOptionsSchema: z.ZodObject<{
|
|
5
|
+
retryCount: z.ZodDefault<z.ZodNumber>;
|
|
6
|
+
delay: z.ZodDefault<z.ZodNumber>;
|
|
7
|
+
maxDelay: z.ZodDefault<z.ZodNumber>;
|
|
8
|
+
jitter: z.ZodDefault<z.ZodNumber>;
|
|
9
|
+
handleRateLimit: z.ZodDefault<z.ZodBoolean>;
|
|
10
|
+
handleTransient: z.ZodDefault<z.ZodBoolean>;
|
|
11
|
+
handleOutOfSync: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
/** Options accepted by {@link resilientTransport}. */
|
|
14
|
+
export type ResilientTransportOptions = z.input<typeof resilientTransportOptionsSchema>;
|
|
15
|
+
/**
|
|
16
|
+
* Wraps a viem {@link Transport} with retry logic for rate-limit, transient,
|
|
17
|
+
* and out-of-sync errors using exponential backoff + jitter.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resilientTransport(underlyingTransport: Transport, options?: ResilientTransportOptions): Transport;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { IGearboxSDKPlugin } from "../../sdk/index.js";
|
|
3
|
+
import { AddressMap, BasePlugin } from "../../sdk/index.js";
|
|
4
|
+
import type { ZapperDataFull, ZapperStateHuman } from "./types.js";
|
|
5
|
+
export interface ZappersPluginState {
|
|
6
|
+
zappers: Record<Address, ZapperDataFull[]>;
|
|
7
|
+
}
|
|
8
|
+
export declare class ZappersPlugin extends BasePlugin<ZappersPluginState> implements IGearboxSDKPlugin<ZappersPluginState> {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(extraZappers?: ZapperDataFull[], loadOnAttach?: boolean);
|
|
11
|
+
load(force?: boolean): Promise<ZappersPluginState>;
|
|
12
|
+
get extraZappers(): AddressMap<ZapperDataFull[]>;
|
|
13
|
+
get zappers(): AddressMap<ZapperDataFull[]>;
|
|
14
|
+
get loaded(): boolean;
|
|
15
|
+
stateHuman(_?: boolean): ZapperStateHuman[];
|
|
16
|
+
get state(): ZappersPluginState;
|
|
17
|
+
hydrate(state: ZappersPluginState): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from "abitype";
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
import type { peripheryCompressorAbi } from "../../abi/compressors/peripheryCompressor.js";
|
|
4
|
+
import type { BaseContractStateHuman, Unarray } from "../../sdk/index.js";
|
|
5
|
+
export type ZapperData = Unarray<AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof peripheryCompressorAbi, "getZappers">["outputs"]>>;
|
|
6
|
+
export interface ZapperDataFull extends ZapperData {
|
|
7
|
+
pool: Address;
|
|
8
|
+
}
|
|
9
|
+
export interface ZapperStateHuman extends BaseContractStateHuman {
|
|
10
|
+
tokenIn: string;
|
|
11
|
+
tokenOut: string;
|
|
12
|
+
}
|
|
@@ -2,10 +2,10 @@ import type { Address } from "viem";
|
|
|
2
2
|
import type { CreditAccountData } from "../base/index.js";
|
|
3
3
|
import { SDKConstruct } from "../base/index.js";
|
|
4
4
|
import type { GearboxSDK } from "../GearboxSDK.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { OnDemandPriceUpdates, UpdatePriceFeedsResult } from "../market/index.js";
|
|
6
6
|
import { type Asset, type RouterCASlice } from "../router/index.js";
|
|
7
|
-
import type {
|
|
8
|
-
import type { AccountToCheck, AddCollateralProps, ChangeDeptProps, ClaimDelayedProps, CloseCreditAccountProps, CloseCreditAccountResult,
|
|
7
|
+
import type { MultiCall } from "../types/index.js";
|
|
8
|
+
import type { AccountToCheck, AddCollateralProps, ChangeDeptProps, ClaimDelayedProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, OpenCAProps, PermitResult, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, PriceUpdatesOptions, Rewards, StartDelayedWithdrawalProps, UpdateQuotasProps } from "./types.js";
|
|
9
9
|
export interface CreditAccountServiceOptions {
|
|
10
10
|
batchSize?: number;
|
|
11
11
|
}
|
|
@@ -21,14 +21,6 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
21
21
|
* @returns
|
|
22
22
|
*/
|
|
23
23
|
getCreditAccountData(account: Address, blockNumber?: bigint): Promise<CreditAccountData | undefined>;
|
|
24
|
-
/**
|
|
25
|
-
* Returns credit account data for a single account with the investor address resolved.
|
|
26
|
-
* Loads CA via getCreditAccountData; for KYC underlyings fetches the investor from the KYC factory's getInvestor(creditAccount), otherwise uses the account owner.
|
|
27
|
-
* @param account - Credit account address
|
|
28
|
-
* @param blockNumber - Optional block number for the read
|
|
29
|
-
* @returns CreditAccountDataWithInvestor (CA data + investor address), or undefined if the account is not found
|
|
30
|
-
*/
|
|
31
|
-
getCreditAccountDataWithInvestor(account: Address, blockNumber?: bigint): Promise<CreditAccountDataWithInvestor | undefined>;
|
|
32
24
|
/**
|
|
33
25
|
* Methods to get all credit accounts with some optional filtering
|
|
34
26
|
* Performs all necessary price feed updates under the hood
|
|
@@ -37,31 +29,7 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
37
29
|
* @param blockNumber
|
|
38
30
|
* @returns returned credit accounts are sorted by health factor in ascending order
|
|
39
31
|
*/
|
|
40
|
-
getCreditAccounts(options?: GetCreditAccountsOptions, blockNumber?: bigint
|
|
41
|
-
/**
|
|
42
|
-
* Returns all credit accounts matching the filter, with investor set on each item.
|
|
43
|
-
* Delegates to getCreditAccounts; when options.owner is set, also loads KYC credit accounts for that owner and merges them into the list. Result is sorted by health factor ascending.
|
|
44
|
-
* @param options - Filter options (owner, creditManager, health factor, etc.)
|
|
45
|
-
* @param blockNumber - Optional block number for the read
|
|
46
|
-
* @returns Array of credit accounts (with investor field), sorted by health factor ascending
|
|
47
|
-
*/
|
|
48
|
-
getCreditAccountsWithInvestor(options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountDataWithInvestor>>;
|
|
49
|
-
protected getKYCCreditAccountsOfOwner(owner: Address, priceUpdateTxs: IPriceUpdateTx<{
|
|
50
|
-
priceFeed: `0x${string}`;
|
|
51
|
-
timestamp: number;
|
|
52
|
-
}>[], blockNumber?: bigint): Promise<Array<CreditAccountDataWithInvestor>>;
|
|
53
|
-
/**
|
|
54
|
-
* Loads credit account data for the given addresses using simulateWithPriceUpdates.
|
|
55
|
-
* Applies the provided price update txs before reading, so returned data is consistent with up-to-date prices.
|
|
56
|
-
* @param accounts - Credit account addresses to load
|
|
57
|
-
* @param priceUpdateTxs - Price feed update txs to simulate before the read (e.g. from generatePriceFeedsUpdateTxs)
|
|
58
|
-
* @param blockNumber - Optional block number for the read
|
|
59
|
-
* @returns Array of CreditAccountData in the same order as accounts (throws if any getCreditAccountData call reverts)
|
|
60
|
-
*/
|
|
61
|
-
loadSpecifiedAccounts(accounts: Address[], priceUpdateTxs: IPriceUpdateTx<{
|
|
62
|
-
priceFeed: `0x${string}`;
|
|
63
|
-
timestamp: number;
|
|
64
|
-
}>[], blockNumber?: bigint): Promise<Array<CreditAccountData>>;
|
|
32
|
+
getCreditAccounts(options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountData>>;
|
|
65
33
|
/**
|
|
66
34
|
* Method to get all claimable rewards for credit account (ex. stkUSDS SKY rewards)
|
|
67
35
|
Assosiates rewards by adapter + stakedPhantomToken
|
|
@@ -136,7 +104,7 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
136
104
|
positive value for debt increase.
|
|
137
105
|
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
138
106
|
*/
|
|
139
|
-
changeDebt({ creditAccount, amount,
|
|
107
|
+
changeDebt({ creditAccount, amount, addCollateral, }: ChangeDeptProps): Promise<CreditAccountOperationResult>;
|
|
140
108
|
/**
|
|
141
109
|
* Executes swap specified by given calls, update quotas of affected tokens
|
|
142
110
|
- Swap is executed in the following order: price update -> execute swap path -> update quotas
|
|
@@ -173,25 +141,31 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
173
141
|
* @returns
|
|
174
142
|
*/
|
|
175
143
|
claimDelayed({ creditAccount, minQuota, averageQuota, claimableNow, }: ClaimDelayedProps): Promise<CreditAccountOperationResult>;
|
|
176
|
-
/**
|
|
177
|
-
* Returns address to which approval should be given on collateral token
|
|
178
|
-
* It's credit manager for classical markets and special wallet for KYC markets
|
|
179
|
-
* @param options - {@link GetApprovalAddressProps}
|
|
180
|
-
* @returns
|
|
181
|
-
**/
|
|
182
|
-
getApprovalAddress(options: GetApprovalAddressProps): Promise<Address>;
|
|
183
144
|
/**
|
|
184
145
|
* Executes swap specified by given calls, update quotas of affected tokens
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
146
|
+
- Open credit account is executed in the following order: price update -> increase debt -> add collateral ->
|
|
147
|
+
-> update quotas -> (optionally: execute swap path for trading/strategy) ->
|
|
148
|
+
-> (optionally: withdraw debt for lending)
|
|
149
|
+
- Basic open credit account: price update -> increase debt -> add collateral -> update quotas
|
|
150
|
+
- Lending: price update -> increase debt -> add collateral -> update quotas -> withdraw debt
|
|
151
|
+
- Strategy/trading: price update -> increase debt -> add collateral -> update quotas -> execute swap path
|
|
152
|
+
- In strategy is possible situation when collateral is added, but not swapped; the only swapped value in this case will be debt
|
|
153
|
+
* @param {bigint} ethAmount - native token amount to attach to tx
|
|
154
|
+
* @param {Address} creditManager - address of credit manager to open credit account on
|
|
155
|
+
* @param {Array<Asset>} collateral - array of collateral which can be just directly added or swapped using the path {@link Asset}
|
|
156
|
+
* @param {Record<Address, PermitResult>} permits - permits of collateral tokens (in any permittable token is present) {@link PermitResult}
|
|
157
|
+
* @param {bigint} debt - debt to open credit account with
|
|
158
|
+
* @param {boolean} withdrawDebt - flag to withdraw debt to wallet after opening credit account;
|
|
159
|
+
used for borrowing functionality
|
|
160
|
+
* @param {bigint} referralCode - referral code to open credit account with
|
|
161
|
+
* @param {Address} to - wallet address to transfer credit account to\
|
|
162
|
+
* @param {Array<MultiCall>} calls - array of MultiCall from router methods findOpenStrategyPath {@link MultiCall}.
|
|
163
|
+
Used for trading and strategy functionality
|
|
164
|
+
* @param {Array<Asset>} averageQuota - average quota for tokens after open {@link Asset}
|
|
165
|
+
* @param {Array<Asset>} minQuota - minimum quota for tokens after open {@link Asset}
|
|
192
166
|
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
193
|
-
|
|
194
|
-
openCA(
|
|
167
|
+
*/
|
|
168
|
+
openCA({ ethAmount, creditManager, collateral, permits, debt, withdrawDebt, referralCode, to, calls: openPathCalls, minQuota, averageQuota, }: OpenCAProps): Promise<CreditAccountOperationResult>;
|
|
195
169
|
/**
|
|
196
170
|
* Returns borrow rate with 4 digits precision (10000 = 100%)
|
|
197
171
|
* @param ca
|
|
@@ -203,42 +177,6 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
203
177
|
* @param ca
|
|
204
178
|
*/
|
|
205
179
|
getOptimalHFForPartialLiquidation(ca: CreditAccountData): bigint;
|
|
206
|
-
/**
|
|
207
|
-
* Returns multicall entries to redeem (unwrap) KYC ERC-4626 vault shares into underlying for the given credit manager.
|
|
208
|
-
* Used when withdrawing debt from a KYC market: redeems adapter vault shares so the underlying can be withdrawn.
|
|
209
|
-
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
210
|
-
* @param amount - Number of vault shares (adapter tokens) to redeem
|
|
211
|
-
* @param creditManager - Credit manager address
|
|
212
|
-
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
213
|
-
*/
|
|
214
|
-
getKYCUnwrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
215
|
-
/**
|
|
216
|
-
* Returns multicall entries to deposit (wrap) underlying into KYC ERC-4626 vault shares for the given credit manager.
|
|
217
|
-
* Used when adding debt on a KYC market: deposits underlying into the adapter vault so shares are minted on the account.
|
|
218
|
-
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
219
|
-
* @param amount - Amount of underlying assets to deposit into the vault (in underlying decimals)
|
|
220
|
-
* @param creditManager - Credit manager address
|
|
221
|
-
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
222
|
-
*/
|
|
223
|
-
getKYCWrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
224
|
-
/**
|
|
225
|
-
* Returns multicall entries to call redeemDiff on the KYC ERC-4626 adapter for the given credit manager.
|
|
226
|
-
* Redeems the leftover vault shares (e.g. after repaying debt) so the account does not hold excess KYC vault tokens.
|
|
227
|
-
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
228
|
-
* @param amount - Leftover vault share amount to redeem (in adapter/vault decimals)
|
|
229
|
-
* @param creditManager - Credit manager address
|
|
230
|
-
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
231
|
-
*/
|
|
232
|
-
getRedeemDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
233
|
-
/**
|
|
234
|
-
* Returns multicall entries to call depositDiff on the KYC ERC-4626 adapter for the given credit manager.
|
|
235
|
-
* Deposits the leftover underlying (e.g. after decreasing debt) into the vault so the account does not hold excess underlying.
|
|
236
|
-
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
237
|
-
* @param amount - Leftover underlying amount to deposit into the vault (in underlying decimals)
|
|
238
|
-
* @param creditManager - Credit manager address
|
|
239
|
-
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
240
|
-
*/
|
|
241
|
-
getDepositDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
242
180
|
/**
|
|
243
181
|
* Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
|
|
244
182
|
*
|
|
@@ -274,38 +212,4 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
274
212
|
private get marketConfigurators();
|
|
275
213
|
private get rewardCompressor();
|
|
276
214
|
private get peripheryCompressor();
|
|
277
|
-
/**
|
|
278
|
-
* Wrapper that selects between credit facade and KYC factory
|
|
279
|
-
* @param suite
|
|
280
|
-
* @param to
|
|
281
|
-
* @param calls
|
|
282
|
-
* @param referralCode
|
|
283
|
-
* @returns
|
|
284
|
-
*/
|
|
285
|
-
protected openCreditAccountTx(suite: CreditSuite, to: Address, calls: MultiCall[], referralCode?: bigint): Promise<RawTx>;
|
|
286
|
-
/**
|
|
287
|
-
* Wrapper that selects between credit facade and KYC factory
|
|
288
|
-
* @param suite
|
|
289
|
-
* @param creditAccount
|
|
290
|
-
* @param calls
|
|
291
|
-
* @returns
|
|
292
|
-
*/
|
|
293
|
-
protected multicallTx(suite: CreditSuite, creditAccount: Address, calls: MultiCall[]): Promise<RawTx>;
|
|
294
|
-
/**
|
|
295
|
-
* Wrapper that selects between credit facade and KYC factory
|
|
296
|
-
* @param suite
|
|
297
|
-
* @param creditAccount
|
|
298
|
-
* @param calls
|
|
299
|
-
* @param operation
|
|
300
|
-
* @returns
|
|
301
|
-
*/
|
|
302
|
-
protected closeCreditAccountTx(suite: CreditSuite, creditAccount: Address, calls: MultiCall[], operation: CloseOptions): Promise<RawTx>;
|
|
303
|
-
/**
|
|
304
|
-
* Returns all KYC credit account addresses for an investor across the given market suites.
|
|
305
|
-
* Resolves KYC factory per suite, then multicalls each factory's getCreditAccounts(investor).
|
|
306
|
-
* @param investor - Owner address to query
|
|
307
|
-
* @param suites - Market suites (KYC factories are resolved for each; undefined entries are skipped)
|
|
308
|
-
* @returns Flat array of credit account addresses from all KYC markets
|
|
309
|
-
*/
|
|
310
|
-
protected getKYCCaOfInvestor(investor: Address, suites: Array<MarketSuite | undefined>): Promise<`0x${string}`[]>;
|
|
311
215
|
}
|
|
@@ -12,7 +12,7 @@ export declare class CreditAccountServiceV310 extends AbstractCreditAccountServi
|
|
|
12
12
|
/**
|
|
13
13
|
* Implements {@link ICreditAccountsService.repayCreditAccount}
|
|
14
14
|
*/
|
|
15
|
-
repayCreditAccount({ operation, collateralAssets, assetsToWithdraw, creditAccount: ca, permits, to, tokensToClaim,
|
|
15
|
+
repayCreditAccount({ operation, collateralAssets, assetsToWithdraw, creditAccount: ca, permits, to, tokensToClaim, }: RepayCreditAccountProps): Promise<CreditAccountOperationResult>;
|
|
16
16
|
/**
|
|
17
17
|
* Implements {@link ICreditAccountsService.repayAndLiquidateCreditAccount}
|
|
18
18
|
*/
|