@gearbox-protocol/sdk 14.10.3-next.2 → 14.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/dev/AccountOpener.js +5 -4
- package/dist/cjs/plugins/apy/strategy-data-source.js +1 -1
- package/dist/cjs/sdk/market/MarketSuite.js +63 -3
- package/dist/cjs/sdk/market/ZapperRegister.js +3 -5
- package/dist/cjs/sdk/market/credit/CreditSuite.js +81 -9
- package/dist/cjs/sdk/market/index.js +1 -3
- package/dist/cjs/sdk/market/pool/PoolSuite.js +64 -0
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +0 -20
- package/dist/cjs/sdk/pools/PoolService.js +60 -58
- package/dist/esm/dev/AccountOpener.js +5 -4
- package/dist/esm/plugins/apy/strategy-data-source.js +1 -1
- package/dist/esm/sdk/market/MarketSuite.js +63 -3
- package/dist/esm/sdk/market/ZapperRegister.js +3 -5
- package/dist/esm/sdk/market/credit/CreditSuite.js +81 -9
- package/dist/esm/sdk/market/index.js +0 -1
- package/dist/esm/sdk/market/pool/PoolSuite.js +64 -0
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +0 -20
- package/dist/esm/sdk/pools/PoolService.js +60 -62
- package/dist/types/sdk/base/types.d.ts +9 -0
- package/dist/types/sdk/market/MarketSuite.d.ts +70 -1
- package/dist/types/sdk/market/ZapperRegister.d.ts +4 -4
- package/dist/types/sdk/market/credit/CreditFacadeV310Contract.d.ts +2 -1
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +86 -6
- package/dist/types/sdk/market/credit/createCreditFacade.d.ts +2 -2
- package/dist/types/sdk/market/credit/types.d.ts +134 -6
- package/dist/types/sdk/market/index.d.ts +0 -1
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +77 -2
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +4 -13
- package/dist/types/sdk/market/pool/createPool.d.ts +2 -2
- package/dist/types/sdk/market/pool/types.d.ts +107 -4
- package/dist/types/sdk/pools/PoolService.d.ts +3 -3
- package/dist/types/sdk/pools/types.d.ts +5 -10
- package/package.json +1 -1
- package/dist/cjs/abi/iERC20Zapper.js +0 -33
- package/dist/cjs/abi/iETHZapper.js +0 -30
- package/dist/cjs/sdk/market/zapper/IERC20ZapperContract.js +0 -98
- package/dist/cjs/sdk/market/zapper/IETHZapperContract.js +0 -89
- package/dist/cjs/sdk/market/zapper/Zapper.js +0 -41
- package/dist/cjs/sdk/market/zapper/createZapper.js +0 -38
- package/dist/cjs/sdk/market/zapper/index.js +0 -28
- package/dist/esm/abi/iERC20Zapper.js +0 -9
- package/dist/esm/abi/iETHZapper.js +0 -6
- package/dist/esm/sdk/market/zapper/IERC20ZapperContract.js +0 -74
- package/dist/esm/sdk/market/zapper/IETHZapperContract.js +0 -65
- package/dist/esm/sdk/market/zapper/Zapper.js +0 -17
- package/dist/esm/sdk/market/zapper/createZapper.js +0 -14
- package/dist/esm/sdk/market/zapper/index.js +0 -4
- package/dist/types/abi/iERC20Zapper.d.ts +0 -313
- package/dist/types/abi/iETHZapper.d.ts +0 -153
- package/dist/types/sdk/market/zapper/IERC20ZapperContract.d.ts +0 -350
- package/dist/types/sdk/market/zapper/IETHZapperContract.d.ts +0 -186
- package/dist/types/sdk/market/zapper/Zapper.d.ts +0 -10
- package/dist/types/sdk/market/zapper/createZapper.d.ts +0 -6
- package/dist/types/sdk/market/zapper/index.d.ts +0 -4
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import { SDKConstruct } from "../base/index.js";
|
|
3
3
|
import { AddressMap } from "../utils/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import type { ZapperData } from "./types.js";
|
|
5
5
|
export declare class ZapperRegister extends SDKConstruct {
|
|
6
6
|
#private;
|
|
7
7
|
/**
|
|
8
8
|
* Load zappers for all pools using periphery compressor, adds hardcoded zappers
|
|
9
9
|
*/
|
|
10
10
|
loadZappers(force?: boolean): Promise<void>;
|
|
11
|
-
get zappers(): AddressMap<
|
|
12
|
-
poolZappers(pool: Address):
|
|
11
|
+
get zappers(): AddressMap<ZapperData[]>;
|
|
12
|
+
poolZappers(pool: Address): ZapperData[];
|
|
13
13
|
/**
|
|
14
14
|
* Can return multiple zappers if there are multiple zappers for the same tokenIn and tokenOut
|
|
15
15
|
*/
|
|
16
|
-
getZapper(pool: Address, tokenIn: Address, tokenOut: Address): Array<
|
|
16
|
+
getZapper(pool: Address, tokenIn: Address, tokenOut: Address): Array<ZapperData> | undefined;
|
|
17
17
|
}
|
|
@@ -4,10 +4,11 @@ import type { CreditFacadeStateHuman, MultiCall, RawTx } from "../../types/index
|
|
|
4
4
|
import type { PriceUpdate } from "../pricefeeds/index.js";
|
|
5
5
|
import type { CreditFacadeV310Abi } from "./CreditFacadeV310BaseContract.js";
|
|
6
6
|
import { CreditFacadeV310BaseContract } from "./CreditFacadeV310BaseContract.js";
|
|
7
|
+
import type { ICreditFacadeContract } from "./types.js";
|
|
7
8
|
type abi = CreditFacadeV310Abi;
|
|
8
9
|
export interface CreditFacadeV310Contract extends Omit<CreditFacadeState, "baseParams">, CreditFacadeV310BaseContract {
|
|
9
10
|
}
|
|
10
|
-
export declare class CreditFacadeV310Contract extends CreditFacadeV310BaseContract {
|
|
11
|
+
export declare class CreditFacadeV310Contract extends CreditFacadeV310BaseContract implements ICreditFacadeContract {
|
|
11
12
|
readonly underlying: Address;
|
|
12
13
|
constructor(options: ConstructOptions, { creditFacade, creditManager }: CreditSuiteState);
|
|
13
14
|
stateHuman(raw?: boolean): CreditFacadeStateHuman;
|
|
@@ -1,23 +1,103 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type { CreditSuiteState
|
|
2
|
+
import type { CreditSuiteState } from "../../base/index.js";
|
|
3
3
|
import { SDKConstruct } from "../../base/index.js";
|
|
4
4
|
import type { OnchainSDK } from "../../OnchainSDK.js";
|
|
5
5
|
import type { IRouterContract } from "../../router/index.js";
|
|
6
6
|
import type { CreditSuiteStateHuman } from "../../types/index.js";
|
|
7
|
-
import type {
|
|
7
|
+
import type { MarketConfiguratorContract } from "../MarketConfiguratorContract.js";
|
|
8
|
+
import type { MarketSuite } from "../MarketSuite.js";
|
|
9
|
+
import type { ICreditConfiguratorContract, ICreditFacadeContract, ICreditManagerContract } from "./types.js";
|
|
10
|
+
/**
|
|
11
|
+
* SDK aggregate for one credit-manager branch inside a market.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* This is the market's "retail branch": it borrows
|
|
15
|
+
* liquidity from the pool to open credit accounts under an isolated mandate.
|
|
16
|
+
* The suite groups the three contracts that define that branch:
|
|
17
|
+
* `creditManager` for debt, collateral, adapters, and account accounting;
|
|
18
|
+
* `creditFacade` for user-facing account operations and multicalls; and
|
|
19
|
+
* `creditConfigurator` for risk-parameter and adapter configuration.
|
|
20
|
+
*/
|
|
8
21
|
export declare class CreditSuite extends SDKConstruct {
|
|
22
|
+
/**
|
|
23
|
+
* Pool that supplies underlying liquidity to this credit manager.
|
|
24
|
+
*/
|
|
9
25
|
readonly pool: Address;
|
|
10
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Wrapper around the core credit manager contract.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* The credit manager owns account accounting, collateral checks, enabled
|
|
31
|
+
* collateral token masks, adapter mappings, debt updates, and liquidation
|
|
32
|
+
* calculations for this branch.
|
|
33
|
+
*/
|
|
11
34
|
readonly creditManager: ICreditManagerContract;
|
|
12
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Wrapper around the credit facade contract used to build account
|
|
37
|
+
* transactions such as open, close, liquidate, and multicall.
|
|
38
|
+
*/
|
|
39
|
+
readonly creditFacade: ICreditFacadeContract;
|
|
40
|
+
/**
|
|
41
|
+
* Wrapper around the credit configurator that mutates risk
|
|
42
|
+
* parameters, collateral tokens, adapter permissions, and facade settings.
|
|
43
|
+
*/
|
|
13
44
|
readonly creditConfigurator: ICreditConfiguratorContract;
|
|
14
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Original compressor contract snapshot for this credit suite.
|
|
47
|
+
*/
|
|
15
48
|
readonly state: CreditSuiteState;
|
|
49
|
+
/**
|
|
50
|
+
* Human-readable credit manager name from the core contract state.
|
|
51
|
+
*/
|
|
16
52
|
readonly name: string;
|
|
17
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Creates a credit suite from one entry in a market compressor snapshot.
|
|
55
|
+
*
|
|
56
|
+
* @param sdk - Attached SDK instance.
|
|
57
|
+
* @param data - Parent market snapshot part that contains the credit suite data.
|
|
58
|
+
*/
|
|
59
|
+
constructor(sdk: OnchainSDK, data: CreditSuiteState);
|
|
60
|
+
/**
|
|
61
|
+
* Token borrowed from the pool and used as the account debt asset.
|
|
62
|
+
*/
|
|
63
|
+
get underlying(): Address;
|
|
64
|
+
/**
|
|
65
|
+
* Parent market that contains this credit manager
|
|
66
|
+
*/
|
|
67
|
+
get market(): MarketSuite;
|
|
68
|
+
/**
|
|
69
|
+
* Market configurator that governs this credit suite and its parent pool.
|
|
70
|
+
*/
|
|
71
|
+
get marketConfigurator(): MarketConfiguratorContract;
|
|
72
|
+
/**
|
|
73
|
+
* Router configured for this credit suite.
|
|
74
|
+
*/
|
|
18
75
|
get router(): IRouterContract;
|
|
76
|
+
/**
|
|
77
|
+
* Whether this suite's facade is past its configured expiration timestamp.
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* Expired credit suites can have different liquidation parameters on-chain.
|
|
81
|
+
* Non-expirable facades and facades with zero expiration are treated as not
|
|
82
|
+
* expired.
|
|
83
|
+
*/
|
|
19
84
|
get isExpired(): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Whether the facade, manager, or configurator has observed logs that require
|
|
87
|
+
* a credit-suite resync.
|
|
88
|
+
*/
|
|
20
89
|
get dirty(): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Credit contracts whose events are enough to detect stale suite state.
|
|
92
|
+
*
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
21
95
|
get watchAddresses(): Set<Address>;
|
|
96
|
+
/**
|
|
97
|
+
* Returns a label-enriched, JSON-friendly view of this credit suite.
|
|
98
|
+
*
|
|
99
|
+
* @param raw - Whether child wrappers should keep raw numeric values instead
|
|
100
|
+
* of applying human formatting where they support both modes.
|
|
101
|
+
*/
|
|
22
102
|
stateHuman(raw?: boolean): CreditSuiteStateHuman;
|
|
23
103
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { CreditSuiteState } from "../../base/index.js";
|
|
2
2
|
import type { OnchainSDK } from "../../OnchainSDK.js";
|
|
3
|
-
import type {
|
|
4
|
-
export default function createCreditFacade(sdk: OnchainSDK, data: CreditSuiteState):
|
|
3
|
+
import type { ICreditFacadeContract } from "./types.js";
|
|
4
|
+
export default function createCreditFacade(sdk: OnchainSDK, data: CreditSuiteState): ICreditFacadeContract;
|
|
@@ -1,15 +1,64 @@
|
|
|
1
|
-
import type { Address } from "viem";
|
|
2
|
-
import type {
|
|
3
|
-
import type { CreditConfiguratorStateHuman, CreditManagerStateHuman } from "../../types/index.js";
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
import type { IBaseContract } from "../../base/index.js";
|
|
3
|
+
import type { CreditConfiguratorStateHuman, CreditFacadeStateHuman, CreditManagerStateHuman, MultiCall, RawTx } from "../../types/index.js";
|
|
4
4
|
import type { AddressMap } from "../../utils/index.js";
|
|
5
5
|
import type { IAdapterContract } from "../adapters/index.js";
|
|
6
|
-
import type {
|
|
6
|
+
import type { RampEvent } from "../index.js";
|
|
7
|
+
import type { PriceUpdate } from "../pricefeeds/index.js";
|
|
7
8
|
export interface ICreditConfiguratorContract extends IBaseContract {
|
|
8
9
|
isPaused: boolean;
|
|
9
10
|
checkRamps: () => Promise<RampEvent[]>;
|
|
10
11
|
stateHuman: (raw?: boolean) => CreditConfiguratorStateHuman;
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Wrapper around the core credit manager contract.
|
|
15
|
+
*/
|
|
16
|
+
export interface ICreditManagerContract extends IBaseContract {
|
|
17
|
+
/**
|
|
18
|
+
* Account factory contract address.
|
|
19
|
+
*/
|
|
20
|
+
accountFactory: Address;
|
|
21
|
+
/**
|
|
22
|
+
* Underlying token address.
|
|
23
|
+
*/
|
|
24
|
+
underlying: Address;
|
|
25
|
+
/**
|
|
26
|
+
* Address of the pool credit manager is connected to.
|
|
27
|
+
*/
|
|
28
|
+
pool: Address;
|
|
29
|
+
/**
|
|
30
|
+
* Address of the connected credit facade.
|
|
31
|
+
*/
|
|
32
|
+
creditFacade: Address;
|
|
33
|
+
/**
|
|
34
|
+
* Address of the connected credit configurator.
|
|
35
|
+
*/
|
|
36
|
+
creditConfigurator: Address;
|
|
37
|
+
/**
|
|
38
|
+
* Maximum number of tokens that a credit account can have enabled as collateral.
|
|
39
|
+
*/
|
|
40
|
+
maxEnabledTokens: number;
|
|
41
|
+
/**
|
|
42
|
+
* Percentage of accrued interest in bps taken by the protocol as profit.
|
|
43
|
+
*/
|
|
44
|
+
feeInterest: number;
|
|
45
|
+
/**
|
|
46
|
+
* Percentage of liquidated account value in bps taken by the protocol as profit.
|
|
47
|
+
*/
|
|
48
|
+
feeLiquidation: number;
|
|
49
|
+
/**
|
|
50
|
+
* Percentage of liquidated account value in bps that is used to repay debt
|
|
51
|
+
* (i.e. `100% - liquidation premium`).
|
|
52
|
+
*/
|
|
53
|
+
liquidationDiscount: number;
|
|
54
|
+
/**
|
|
55
|
+
* Percentage of liquidated expired account value in bps taken by the protocol as profit.
|
|
56
|
+
*/
|
|
57
|
+
feeLiquidationExpired: number;
|
|
58
|
+
/**
|
|
59
|
+
* Percentage of liquidated expired account value in bps that is used to repay debt.
|
|
60
|
+
*/
|
|
61
|
+
liquidationDiscountExpired: number;
|
|
13
62
|
/**
|
|
14
63
|
* Mapping targetContract => adapter
|
|
15
64
|
*/
|
|
@@ -24,4 +73,83 @@ export interface ICreditManagerContract extends IBaseContract, Omit<CreditManage
|
|
|
24
73
|
collateralTokens: Address[];
|
|
25
74
|
stateHuman: (raw?: boolean) => CreditManagerStateHuman;
|
|
26
75
|
}
|
|
27
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Wrapper around the credit facade contract used to build account
|
|
78
|
+
* transactions such as open, close, liquidate, and multicall.
|
|
79
|
+
*/
|
|
80
|
+
export interface ICreditFacadeContract extends IBaseContract {
|
|
81
|
+
/**
|
|
82
|
+
* Degen NFT address (`address(0)` when Degen mode is disabled).
|
|
83
|
+
*/
|
|
84
|
+
degenNFT: Address;
|
|
85
|
+
/**
|
|
86
|
+
* Bot list address.
|
|
87
|
+
*/
|
|
88
|
+
botList: Address;
|
|
89
|
+
/**
|
|
90
|
+
* Whether the credit facade is expirable.
|
|
91
|
+
*/
|
|
92
|
+
expirable: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Expiration timestamp (only meaningful when `expirable` is `true`).
|
|
95
|
+
*/
|
|
96
|
+
expirationDate: number;
|
|
97
|
+
/**
|
|
98
|
+
* Maximum amount that can be borrowed by a credit manager in a single
|
|
99
|
+
* block, expressed as a multiple of `maxDebt`.
|
|
100
|
+
*/
|
|
101
|
+
maxDebtPerBlockMultiplier: number;
|
|
102
|
+
/**
|
|
103
|
+
* Minimum credit account debt allowed by the facade, in underlying.
|
|
104
|
+
*/
|
|
105
|
+
minDebt: bigint;
|
|
106
|
+
/**
|
|
107
|
+
* Maximum credit account debt allowed by the facade, in underlying.
|
|
108
|
+
*/
|
|
109
|
+
maxDebt: bigint;
|
|
110
|
+
/**
|
|
111
|
+
* Bit mask encoding the set of forbidden tokens.
|
|
112
|
+
*/
|
|
113
|
+
forbiddenTokensMask: bigint;
|
|
114
|
+
/**
|
|
115
|
+
* Whether the facade is currently paused.
|
|
116
|
+
*/
|
|
117
|
+
isPaused: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Underlying token of the connected credit manager.
|
|
120
|
+
*/
|
|
121
|
+
readonly underlying: Address;
|
|
122
|
+
stateHuman: (raw?: boolean) => CreditFacadeStateHuman;
|
|
123
|
+
/**
|
|
124
|
+
* Builds a raw transaction that liquidates a credit account.
|
|
125
|
+
*
|
|
126
|
+
* @param ca Credit account to liquidate.
|
|
127
|
+
* @param to Recipient of the liquidator's reward.
|
|
128
|
+
* @param calls Multicall body executed during liquidation.
|
|
129
|
+
* @param lossPolicyData Optional loss policy payload forwarded to the facade.
|
|
130
|
+
*/
|
|
131
|
+
liquidateCreditAccount(ca: Address, to: Address, calls: MultiCall[], lossPolicyData?: Hex): RawTx;
|
|
132
|
+
/**
|
|
133
|
+
* Builds a raw transaction that partially liquidates a credit account's
|
|
134
|
+
* debt in exchange for discounted collateral.
|
|
135
|
+
*/
|
|
136
|
+
partiallyLiquidateCreditAccount(ca: Address, token: Address, repaidAmount: bigint, minSeizedAmount: bigint, to: Address, updates: PriceUpdate[]): RawTx;
|
|
137
|
+
/**
|
|
138
|
+
* Builds a raw transaction that closes a credit account.
|
|
139
|
+
*/
|
|
140
|
+
closeCreditAccount(ca: Address, calls: MultiCall[]): RawTx;
|
|
141
|
+
/**
|
|
142
|
+
* Builds a raw transaction that executes an owner-driven multicall on a
|
|
143
|
+
* credit account.
|
|
144
|
+
*/
|
|
145
|
+
multicall(ca: Address, calls: MultiCall[]): RawTx;
|
|
146
|
+
/**
|
|
147
|
+
* Builds a raw transaction that executes a bot-driven multicall on a
|
|
148
|
+
* credit account.
|
|
149
|
+
*/
|
|
150
|
+
botMulticall(ca: Address, calls: MultiCall[]): RawTx;
|
|
151
|
+
/**
|
|
152
|
+
* Builds a raw transaction that opens a new credit account.
|
|
153
|
+
*/
|
|
154
|
+
openCreditAccount(to: Address, calls: MultiCall[], referralCode: bigint): RawTx;
|
|
155
|
+
}
|
|
@@ -8,21 +8,96 @@ import type { IRWAFactory } from "../rwa/types.js";
|
|
|
8
8
|
import { GaugeContract } from "./GaugeContract.js";
|
|
9
9
|
import { LinearInterestRateModelContract } from "./LinearInterestRateModelContract.js";
|
|
10
10
|
import { TumblerContract } from "./TumblerContract.js";
|
|
11
|
-
import type { IInterestRateModelContract,
|
|
11
|
+
import type { IInterestRateModelContract, IPoolContract, IRateKeeperContract, PoolQuotaKeeperContract } from "./types.js";
|
|
12
|
+
/**
|
|
13
|
+
* SDK aggregate for the pool-side contracts of a Gearbox market.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* The pool is the market's passive liquidity source. This suite groups the
|
|
17
|
+
* ERC-4626 pool wrapper with the quota keeper that caps collateral-side
|
|
18
|
+
* exposure, the rate keeper that supplies quota rates, and the interest-rate
|
|
19
|
+
* model that prices pool utilization. Higher-level market and pool services use
|
|
20
|
+
* this class when they need the complete pool control plane instead of a single
|
|
21
|
+
* contract wrapper.
|
|
22
|
+
*/
|
|
12
23
|
export declare class PoolSuite extends SDKConstruct {
|
|
13
24
|
#private;
|
|
14
|
-
|
|
25
|
+
/**
|
|
26
|
+
* ERC-4626 liquidity pool wrapper for deposits, withdrawals, borrowing
|
|
27
|
+
* limits, and base interest accounting.
|
|
28
|
+
*/
|
|
29
|
+
readonly pool: IPoolContract;
|
|
30
|
+
/**
|
|
31
|
+
* Quota keeper wrapper that tracks per-token quota limits, quoted exposure,
|
|
32
|
+
* quota rates, and credit-manager access.
|
|
33
|
+
*/
|
|
15
34
|
readonly pqk: PoolQuotaKeeperContract;
|
|
35
|
+
/**
|
|
36
|
+
* Rate keeper used by the quota keeper to obtain collateral-specific quota
|
|
37
|
+
* rates. Can be a {@link GaugeContract} or a {@link TumblerContract}.
|
|
38
|
+
*/
|
|
16
39
|
readonly rateKeeper: IRateKeeperContract;
|
|
40
|
+
/**
|
|
41
|
+
* Interest-rate model used by the pool to calculate the base borrow rate from
|
|
42
|
+
* expected and available liquidity.
|
|
43
|
+
*/
|
|
17
44
|
readonly interestRateModel: IInterestRateModelContract;
|
|
45
|
+
/**
|
|
46
|
+
* Creates the pool aggregate from a market compressor snapshot.
|
|
47
|
+
*
|
|
48
|
+
* @param sdk - Attached SDK instance
|
|
49
|
+
* @param data - Full market snapshot containing pool, quota, rate, and
|
|
50
|
+
* interest-rate model state.
|
|
51
|
+
*/
|
|
18
52
|
constructor(sdk: OnchainSDK, data: MarketData);
|
|
53
|
+
/**
|
|
54
|
+
* Narrows `rateKeeper` to a gauge rate keeper.
|
|
55
|
+
*
|
|
56
|
+
* @throws If the market uses a different rate keeper type.
|
|
57
|
+
*/
|
|
19
58
|
get gauge(): GaugeContract;
|
|
59
|
+
/**
|
|
60
|
+
* Narrows `rateKeeper` to a tumbler rate keeper.
|
|
61
|
+
*
|
|
62
|
+
* @throws If the market uses a different rate keeper type.
|
|
63
|
+
*/
|
|
20
64
|
get tumbler(): TumblerContract;
|
|
65
|
+
/**
|
|
66
|
+
* Narrows `interestRateModel` to the linear interest-rate model.
|
|
67
|
+
*
|
|
68
|
+
* @throws If the market uses a different interest-rate model type.
|
|
69
|
+
*/
|
|
21
70
|
get linearModel(): LinearInterestRateModelContract;
|
|
71
|
+
/**
|
|
72
|
+
* Market configurator that governs the pool and its connected credit suites.
|
|
73
|
+
*
|
|
74
|
+
* @throws If the configurator is missing from the SDK contract register.
|
|
75
|
+
*/
|
|
22
76
|
get marketConfigurator(): MarketConfiguratorContract;
|
|
77
|
+
/**
|
|
78
|
+
* Underlying asset deposited into the pool and borrowed by connected credit
|
|
79
|
+
* suites.
|
|
80
|
+
*/
|
|
23
81
|
get underlying(): Address;
|
|
82
|
+
/**
|
|
83
|
+
* RWA factory associated with the pool's underlying, undefined for non-RWA markets.
|
|
84
|
+
*/
|
|
24
85
|
get rwaFactory(): IRWAFactory | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Whether any pool-side wrapper has observed logs that require a resync.
|
|
88
|
+
*/
|
|
25
89
|
get dirty(): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Pool-side contract addresses whose logs are enough to detect stale state.
|
|
92
|
+
*
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
26
95
|
get watchAddresses(): Set<Address>;
|
|
96
|
+
/**
|
|
97
|
+
* Returns a label-enriched, JSON-friendly view of the pool-side state.
|
|
98
|
+
*
|
|
99
|
+
* @param raw - Whether child wrappers should keep raw numeric values instead
|
|
100
|
+
* of applying human formatting where they support both modes.
|
|
101
|
+
*/
|
|
27
102
|
stateHuman(raw?: boolean): PoolSuiteStateHuman;
|
|
28
103
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContractEventName, DecodeFunctionDataReturnType, Log } from "viem";
|
|
2
2
|
import type { CreditManagerDebtParams, PoolState } from "../../base/index.js";
|
|
3
3
|
import { BaseContract } from "../../base/index.js";
|
|
4
4
|
import type { OnchainSDK } from "../../OnchainSDK.js";
|
|
5
|
-
import type { PoolStateHuman
|
|
5
|
+
import type { PoolStateHuman } from "../../types/index.js";
|
|
6
6
|
import { AddressMap } from "../../utils/index.js";
|
|
7
7
|
import type { IRWAFactory } from "../rwa/types.js";
|
|
8
|
+
import type { IPoolContract } from "./types.js";
|
|
8
9
|
declare const abi: readonly [{
|
|
9
10
|
readonly type: "function";
|
|
10
11
|
readonly inputs: readonly [];
|
|
@@ -1131,23 +1132,13 @@ declare const abi: readonly [{
|
|
|
1131
1132
|
type abi = typeof abi;
|
|
1132
1133
|
export interface PoolV310Contract extends Omit<PoolState, "baseParams" | "creditManagerDebtParams" | "name">, BaseContract<abi> {
|
|
1133
1134
|
}
|
|
1134
|
-
export declare class PoolV310Contract extends BaseContract<abi> {
|
|
1135
|
+
export declare class PoolV310Contract extends BaseContract<abi> implements IPoolContract {
|
|
1135
1136
|
#private;
|
|
1136
1137
|
readonly creditManagerDebtParams: AddressMap<CreditManagerDebtParams>;
|
|
1137
1138
|
constructor(sdk: OnchainSDK, data: PoolState);
|
|
1138
1139
|
get rwaFactory(): IRWAFactory | undefined;
|
|
1139
1140
|
stateHuman(raw?: boolean): PoolStateHuman;
|
|
1140
1141
|
processLog(log: Log<bigint, number, false, undefined, undefined, abi, ContractEventName<abi>>): void;
|
|
1141
|
-
/**
|
|
1142
|
-
* Deposits underlying assets into the pool on behalf of a user with a
|
|
1143
|
-
* referral code.
|
|
1144
|
-
*/
|
|
1145
|
-
depositWithReferral(amount: bigint, onBehalfOf: Address, referralCode: bigint): RawTx;
|
|
1146
|
-
/**
|
|
1147
|
-
* Redeems pool shares from the owner and sends the underlying assets to
|
|
1148
|
-
* the receiver.
|
|
1149
|
-
*/
|
|
1150
|
-
redeem(amount: bigint, owner: Address, receiver: Address): RawTx;
|
|
1151
1142
|
protected stringifyFunctionParams(params: DecodeFunctionDataReturnType<abi>): string[];
|
|
1152
1143
|
}
|
|
1153
1144
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { PoolState } from "../../base/index.js";
|
|
2
2
|
import type { OnchainSDK } from "../../OnchainSDK.js";
|
|
3
|
-
import type {
|
|
4
|
-
export default function createPool(sdk: OnchainSDK, data: PoolState):
|
|
3
|
+
import type { IPoolContract } from "./types.js";
|
|
4
|
+
export default function createPool(sdk: OnchainSDK, data: PoolState): IPoolContract;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { CreditManagerDebtParams, IBaseContract } from "../../base/index.js";
|
|
3
|
+
import type { InterestRateModelStateHuman, PoolStateHuman, RateKeeperStateHuman } from "../../types/index.js";
|
|
3
4
|
import type { AddressMap } from "../../utils/index.js";
|
|
5
|
+
import type { IRWAFactory } from "../rwa/types.js";
|
|
4
6
|
import type { PoolQuotaKeeperV310Contract } from "./PoolQuotaKeeperV310Contract.js";
|
|
5
|
-
import type { PoolV310Contract } from "./PoolV310Contract.js";
|
|
6
7
|
export type RateKeeperType = `RATE_KEEPER::${string}`;
|
|
7
8
|
export type InterestRateModelType = `IRM::${string}`;
|
|
8
9
|
export interface IRateKeeperContract extends IBaseContract {
|
|
@@ -12,5 +13,107 @@ export interface IRateKeeperContract extends IBaseContract {
|
|
|
12
13
|
export interface IInterestRateModelContract extends IBaseContract {
|
|
13
14
|
stateHuman: (raw?: boolean) => InterestRateModelStateHuman;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Wrapper around the Gearbox lending pool contract.
|
|
18
|
+
* Pool implements ERC4626
|
|
19
|
+
*/
|
|
20
|
+
export interface IPoolContract extends IBaseContract {
|
|
21
|
+
/**
|
|
22
|
+
* Pool share token symbol (ERC20 metadata).
|
|
23
|
+
*/
|
|
24
|
+
symbol: string;
|
|
25
|
+
/**
|
|
26
|
+
* Pool shares decimals, matches underlying token decimals.
|
|
27
|
+
*/
|
|
28
|
+
decimals: number;
|
|
29
|
+
/**
|
|
30
|
+
* Total pool share token supply (ERC20).
|
|
31
|
+
*/
|
|
32
|
+
totalSupply: bigint;
|
|
33
|
+
/**
|
|
34
|
+
* Pool quota keeper contract address.
|
|
35
|
+
*/
|
|
36
|
+
quotaKeeper: Address;
|
|
37
|
+
/**
|
|
38
|
+
* Interest rate model contract address.
|
|
39
|
+
*/
|
|
40
|
+
interestRateModel: Address;
|
|
41
|
+
/**
|
|
42
|
+
* Pool's underlying token, same as `asset()`.
|
|
43
|
+
*/
|
|
44
|
+
underlying: Address;
|
|
45
|
+
/**
|
|
46
|
+
* Available liquidity in the pool.
|
|
47
|
+
*/
|
|
48
|
+
availableLiquidity: bigint;
|
|
49
|
+
/**
|
|
50
|
+
* Amount of underlying that would be in the pool if debt principal, base
|
|
51
|
+
* interest and quota revenue were fully repaid.
|
|
52
|
+
*/
|
|
53
|
+
expectedLiquidity: bigint;
|
|
54
|
+
/**
|
|
55
|
+
* Current cumulative base interest index in ray.
|
|
56
|
+
*/
|
|
57
|
+
baseInterestIndex: bigint;
|
|
58
|
+
/**
|
|
59
|
+
* Annual interest rate in ray that credit account owners pay per unit of
|
|
60
|
+
* borrowed capital.
|
|
61
|
+
*/
|
|
62
|
+
baseInterestRate: bigint;
|
|
63
|
+
/**
|
|
64
|
+
* Current pool share / underlying conversion rate, computed by the
|
|
65
|
+
* compressor
|
|
66
|
+
*/
|
|
67
|
+
dieselRate: bigint;
|
|
68
|
+
/**
|
|
69
|
+
* Current annual supply rate for depositors, computed by the compressor
|
|
70
|
+
*/
|
|
71
|
+
supplyRate: bigint;
|
|
72
|
+
/**
|
|
73
|
+
* Withdrawal fee in bps
|
|
74
|
+
*/
|
|
75
|
+
withdrawFee: bigint;
|
|
76
|
+
/**
|
|
77
|
+
* Total borrowed amount across all credit managers (principal only).
|
|
78
|
+
*/
|
|
79
|
+
totalBorrowed: bigint;
|
|
80
|
+
/**
|
|
81
|
+
* Total debt limit (`MAX_UINT256` means no limit).
|
|
82
|
+
*/
|
|
83
|
+
totalDebtLimit: bigint;
|
|
84
|
+
/**
|
|
85
|
+
* Cumulative base interest index stored as of last update in ray.
|
|
86
|
+
*/
|
|
87
|
+
baseInterestIndexLU: bigint;
|
|
88
|
+
/**
|
|
89
|
+
* Expected liquidity stored as of last update.
|
|
90
|
+
*/
|
|
91
|
+
expectedLiquidityLU: bigint;
|
|
92
|
+
/**
|
|
93
|
+
* Current annual quota revenue in underlying tokens.
|
|
94
|
+
*/
|
|
95
|
+
quotaRevenue: bigint;
|
|
96
|
+
/**
|
|
97
|
+
* Timestamp of the last base interest rate and index update.
|
|
98
|
+
*/
|
|
99
|
+
lastBaseInterestUpdate: number;
|
|
100
|
+
/**
|
|
101
|
+
* Timestamp of the last quota revenue update.
|
|
102
|
+
*/
|
|
103
|
+
lastQuotaRevenueUpdate: number;
|
|
104
|
+
/**
|
|
105
|
+
* Whether the pool is currently paused.
|
|
106
|
+
*/
|
|
107
|
+
isPaused: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Per-credit-manager debt parameters indexed by credit manager address.
|
|
110
|
+
*/
|
|
111
|
+
readonly creditManagerDebtParams: AddressMap<CreditManagerDebtParams>;
|
|
112
|
+
/**
|
|
113
|
+
* RWA factory associated with the pool's underlying, when the underlying
|
|
114
|
+
* is an RWA token. `undefined` for regular ERC-20 underlyings.
|
|
115
|
+
*/
|
|
116
|
+
readonly rwaFactory: IRWAFactory | undefined;
|
|
117
|
+
stateHuman: (raw?: boolean) => PoolStateHuman;
|
|
118
|
+
}
|
|
16
119
|
export type PoolQuotaKeeperContract = PoolQuotaKeeperV310Contract;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import { SDKConstruct } from "../base/index.js";
|
|
3
|
-
import type { AddLiquidityProps, DepositMetadata, IPoolsService,
|
|
3
|
+
import type { AddLiquidityProps, DepositMetadata, IPoolsService, PoolServiceCall, RemoveLiquidityProps, WithdrawalMetadata } from "./types.js";
|
|
4
4
|
export declare class PoolService extends SDKConstruct implements IPoolsService {
|
|
5
5
|
#private;
|
|
6
6
|
/**
|
|
@@ -18,7 +18,7 @@ export declare class PoolService extends SDKConstruct implements IPoolsService {
|
|
|
18
18
|
/**
|
|
19
19
|
* {@inheritDoc IPoolsService.addLiquidity}
|
|
20
20
|
*/
|
|
21
|
-
addLiquidity(props: AddLiquidityProps):
|
|
21
|
+
addLiquidity(props: AddLiquidityProps): PoolServiceCall | undefined;
|
|
22
22
|
/**
|
|
23
23
|
* {@inheritDoc IPoolsService.getWithdrawalTokensIn}
|
|
24
24
|
*/
|
|
@@ -30,7 +30,7 @@ export declare class PoolService extends SDKConstruct implements IPoolsService {
|
|
|
30
30
|
/**
|
|
31
31
|
* {@inheritDoc IPoolsService.removeLiquidity}
|
|
32
32
|
*/
|
|
33
|
-
removeLiquidity(props: RemoveLiquidityProps):
|
|
33
|
+
removeLiquidity(props: RemoveLiquidityProps): PoolServiceCall;
|
|
34
34
|
/**
|
|
35
35
|
* {@inheritDoc IPoolsService.getWithdrawalMetadata}
|
|
36
36
|
*/
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Abi, Address, ContractFunctionArgs, ContractFunctionName } from "viem";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ZapperData } from "../market/index.js";
|
|
3
3
|
import type { Asset } from "../router/index.js";
|
|
4
|
-
import type { MultiCall, RawTx } from "../types/transactions.js";
|
|
5
4
|
interface PermitResult {
|
|
6
5
|
r: Address;
|
|
7
6
|
s: Address;
|
|
@@ -20,10 +19,6 @@ export type PoolServiceCall<abi extends Abi | readonly unknown[] = Abi, function
|
|
|
20
19
|
target: Address;
|
|
21
20
|
value?: bigint;
|
|
22
21
|
};
|
|
23
|
-
export interface PoolServiceCallResult {
|
|
24
|
-
tx: RawTx;
|
|
25
|
-
calls: Array<MultiCall>;
|
|
26
|
-
}
|
|
27
22
|
export interface AddLiquidityProps {
|
|
28
23
|
/**
|
|
29
24
|
* Token and amount to deposit.
|
|
@@ -62,7 +57,7 @@ export interface DepositMetadata {
|
|
|
62
57
|
/**
|
|
63
58
|
* Zapper that will perform the deposit, undefined in case of direct pool underlying deposit
|
|
64
59
|
*/
|
|
65
|
-
zapper?:
|
|
60
|
+
zapper?: ZapperData;
|
|
66
61
|
/**
|
|
67
62
|
* Before deposit user will nedd to call approve method on token that he wants to deposit,
|
|
68
63
|
* this is the spender address that will be used to call approve method.
|
|
@@ -82,7 +77,7 @@ export interface WithdrawalMetadata {
|
|
|
82
77
|
/**
|
|
83
78
|
* Zapper that will perform the withdrawal, undefined in case of direct pool underlying withdrawal
|
|
84
79
|
*/
|
|
85
|
-
zapper?:
|
|
80
|
+
zapper?: ZapperData;
|
|
86
81
|
/**
|
|
87
82
|
* Before withdrawal user will need to call approve method on token that he wants to withdraw (diesel token),
|
|
88
83
|
* this is the spender address that will be used to call approve method.
|
|
@@ -151,13 +146,13 @@ export interface IPoolsService {
|
|
|
151
146
|
* @param props - {@link AddLiquidityProps}
|
|
152
147
|
* @returns - {@link AddLiquidityCall}
|
|
153
148
|
*/
|
|
154
|
-
addLiquidity(props: AddLiquidityProps):
|
|
149
|
+
addLiquidity(props: AddLiquidityProps): PoolServiceCall | undefined;
|
|
155
150
|
/**
|
|
156
151
|
* Construct a call to remove liquidity from a Gearbox lending pool.
|
|
157
152
|
*
|
|
158
153
|
* @param props - {@link RemoveLiquidityProps}
|
|
159
154
|
* @returns - {@link RemoveLiquidityCall}
|
|
160
155
|
*/
|
|
161
|
-
removeLiquidity(props: RemoveLiquidityProps):
|
|
156
|
+
removeLiquidity(props: RemoveLiquidityProps): PoolServiceCall;
|
|
162
157
|
}
|
|
163
158
|
export {};
|