@gearbox-protocol/sdk 14.10.3 → 14.10.5-next.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/abi/iERC20Zapper.js +33 -0
- package/dist/cjs/abi/iETHZapper.js +30 -0
- package/dist/cjs/dev/AccountOpener.js +4 -5
- package/dist/cjs/sdk/market/ZapperRegister.js +5 -3
- package/dist/cjs/sdk/market/index.js +3 -1
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +20 -0
- package/dist/cjs/sdk/market/zapper/IERC20ZapperContract.js +98 -0
- package/dist/cjs/sdk/market/zapper/IETHZapperContract.js +89 -0
- package/dist/cjs/sdk/market/zapper/Zapper.js +47 -0
- package/dist/cjs/sdk/market/zapper/createZapper.js +45 -0
- package/dist/cjs/sdk/market/zapper/index.js +28 -0
- package/dist/cjs/sdk/pools/PoolService.js +58 -60
- package/dist/esm/abi/iERC20Zapper.js +9 -0
- package/dist/esm/abi/iETHZapper.js +6 -0
- package/dist/esm/dev/AccountOpener.js +4 -5
- package/dist/esm/sdk/market/ZapperRegister.js +5 -3
- package/dist/esm/sdk/market/index.js +1 -0
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +20 -0
- package/dist/esm/sdk/market/zapper/IERC20ZapperContract.js +74 -0
- package/dist/esm/sdk/market/zapper/IETHZapperContract.js +65 -0
- package/dist/esm/sdk/market/zapper/Zapper.js +23 -0
- package/dist/esm/sdk/market/zapper/createZapper.js +21 -0
- package/dist/esm/sdk/market/zapper/index.js +4 -0
- package/dist/esm/sdk/pools/PoolService.js +62 -60
- package/dist/types/abi/iERC20Zapper.d.ts +313 -0
- package/dist/types/abi/iETHZapper.d.ts +153 -0
- package/dist/types/sdk/base/types.d.ts +9 -0
- 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 +2 -2
- 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 +1 -0
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +2 -2
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +14 -3
- package/dist/types/sdk/market/pool/createPool.d.ts +2 -2
- package/dist/types/sdk/market/pool/types.d.ts +117 -4
- package/dist/types/sdk/market/zapper/IERC20ZapperContract.d.ts +350 -0
- package/dist/types/sdk/market/zapper/IETHZapperContract.d.ts +186 -0
- package/dist/types/sdk/market/zapper/Zapper.d.ts +13 -0
- package/dist/types/sdk/market/zapper/createZapper.d.ts +6 -0
- package/dist/types/sdk/market/zapper/index.d.ts +4 -0
- package/dist/types/sdk/pools/PoolService.d.ts +3 -3
- package/dist/types/sdk/pools/types.d.ts +10 -5
- package/package.json +1 -1
|
@@ -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,7 +8,7 @@ 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
12
|
/**
|
|
13
13
|
* SDK aggregate for the pool-side contracts of a Gearbox market.
|
|
14
14
|
*
|
|
@@ -26,7 +26,7 @@ export declare class PoolSuite extends SDKConstruct {
|
|
|
26
26
|
* ERC-4626 liquidity pool wrapper for deposits, withdrawals, borrowing
|
|
27
27
|
* limits, and base interest accounting.
|
|
28
28
|
*/
|
|
29
|
-
readonly pool:
|
|
29
|
+
readonly pool: IPoolContract;
|
|
30
30
|
/**
|
|
31
31
|
* Quota keeper wrapper that tracks per-token quota limits, quoted exposure,
|
|
32
32
|
* quota rates, and credit-manager access.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { ContractEventName, DecodeFunctionDataReturnType, Log } from "viem";
|
|
1
|
+
import type { Address, 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 } from "../../types/index.js";
|
|
5
|
+
import type { PoolStateHuman, RawTx } 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,13 +1132,23 @@ 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;
|
|
1142
|
+
/**
|
|
1143
|
+
* Deposits underlying assets into the pool on behalf of a user with a
|
|
1144
|
+
* referral code.
|
|
1145
|
+
*/
|
|
1146
|
+
depositWithReferral(amount: bigint, onBehalfOf: Address, referralCode: bigint): RawTx;
|
|
1147
|
+
/**
|
|
1148
|
+
* Redeems pool shares from the owner and sends the underlying assets to
|
|
1149
|
+
* the receiver.
|
|
1150
|
+
*/
|
|
1151
|
+
redeem(amount: bigint, owner: Address, receiver: Address): RawTx;
|
|
1141
1152
|
protected stringifyFunctionParams(params: DecodeFunctionDataReturnType<abi>): string[];
|
|
1142
1153
|
}
|
|
1143
1154
|
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, RawTx } 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,117 @@ 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
|
+
/**
|
|
119
|
+
* Deposits underlying assets into the pool on behalf of a user with a
|
|
120
|
+
* referral code.
|
|
121
|
+
*/
|
|
122
|
+
depositWithReferral(amount: bigint, onBehalfOf: Address, referralCode: bigint): RawTx;
|
|
123
|
+
/**
|
|
124
|
+
* Redeems pool shares from the owner and sends the underlying assets to
|
|
125
|
+
* the receiver.
|
|
126
|
+
*/
|
|
127
|
+
redeem(amount: bigint, owner: Address, receiver: Address): RawTx;
|
|
128
|
+
}
|
|
16
129
|
export type PoolQuotaKeeperContract = PoolQuotaKeeperV310Contract;
|