@gearbox-protocol/sdk 14.10.3-next.1 → 14.10.3
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/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 +57 -67
- 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/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 +57 -72
- package/dist/types/sdk/market/MarketSuite.d.ts +70 -1
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +84 -4
- package/dist/types/sdk/market/index.d.ts +0 -1
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +75 -0
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +2 -12
- package/dist/types/sdk/pools/PoolService.d.ts +3 -3
- package/dist/types/sdk/pools/types.d.ts +2 -7
- package/package.json +1 -1
- package/dist/cjs/sdk/market/zapper/IERC20ZapperDepositsContract.js +0 -54
- package/dist/cjs/sdk/market/zapper/IETHZapperDepositsContract.js +0 -45
- package/dist/cjs/sdk/market/zapper/IZapperContract.js +0 -54
- package/dist/cjs/sdk/market/zapper/index.js +0 -26
- package/dist/esm/sdk/market/zapper/IERC20ZapperDepositsContract.js +0 -30
- package/dist/esm/sdk/market/zapper/IETHZapperDepositsContract.js +0 -21
- package/dist/esm/sdk/market/zapper/IZapperContract.js +0 -30
- package/dist/esm/sdk/market/zapper/index.js +0 -3
- package/dist/types/sdk/market/zapper/IERC20ZapperDepositsContract.d.ts +0 -211
- package/dist/types/sdk/market/zapper/IETHZapperDepositsContract.d.ts +0 -47
- package/dist/types/sdk/market/zapper/IZapperContract.d.ts +0 -139
- package/dist/types/sdk/market/zapper/index.d.ts +0 -3
|
@@ -7,17 +7,55 @@ import { MarketConfiguratorContract } from "./MarketConfiguratorContract.js";
|
|
|
7
7
|
import { createPriceOracle } from "./oracle/index.js";
|
|
8
8
|
import { PoolSuite } from "./pool/index.js";
|
|
9
9
|
class MarketSuite extends SDKConstruct {
|
|
10
|
+
/**
|
|
11
|
+
* Access-control list contract that owns market roles such as pausable and
|
|
12
|
+
* unpausable admins.
|
|
13
|
+
*/
|
|
10
14
|
acl;
|
|
15
|
+
/**
|
|
16
|
+
* Treasury splitter or fee recipient associated with this market.
|
|
17
|
+
*/
|
|
11
18
|
treasury;
|
|
19
|
+
/**
|
|
20
|
+
* Market-level configurator that controls pool and credit-suite risk
|
|
21
|
+
* parameters.
|
|
22
|
+
*/
|
|
12
23
|
configurator;
|
|
24
|
+
/**
|
|
25
|
+
* Pool-side contract bundle: ERC-4626 pool, quota keeper, rate keeper, and
|
|
26
|
+
* interest-rate model.
|
|
27
|
+
*/
|
|
13
28
|
pool;
|
|
29
|
+
/**
|
|
30
|
+
* Market price oracle used by credit managers and pool for normalized
|
|
31
|
+
* price conversion and safe-price checks.
|
|
32
|
+
*/
|
|
14
33
|
priceOracle;
|
|
34
|
+
/**
|
|
35
|
+
* Bad-debt liquidation policy shared by the market's credit facades.
|
|
36
|
+
*/
|
|
15
37
|
lossPolicy;
|
|
38
|
+
/**
|
|
39
|
+
* Credit-suite wrappers connected to the pool.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* Each suite corresponds to one credit manager branch with its own facade,
|
|
43
|
+
* configurator, collateral set, adapters, debt limits, and expiration policy.
|
|
44
|
+
*/
|
|
16
45
|
creditManagers = [];
|
|
17
46
|
/**
|
|
18
|
-
* Original
|
|
47
|
+
* Original market snapshot received from the market compressor contract.
|
|
19
48
|
*/
|
|
20
49
|
state;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a market aggregate from compressor state.
|
|
52
|
+
*
|
|
53
|
+
* @param sdk - Attached on-chain SDK instance used for contract lookup,
|
|
54
|
+
* labels, token metadata, and plugin access.
|
|
55
|
+
* @param marketData - Full market state returned by the market compressor.
|
|
56
|
+
* @throws If the configurator address from `marketData` is not already
|
|
57
|
+
* registered as a {@link MarketConfiguratorContract}.
|
|
58
|
+
*/
|
|
21
59
|
constructor(sdk, marketData) {
|
|
22
60
|
super(sdk);
|
|
23
61
|
this.state = marketData;
|
|
@@ -35,21 +73,37 @@ class MarketSuite extends SDKConstruct {
|
|
|
35
73
|
sdk.setAddressLabel(t.addr, t.symbol);
|
|
36
74
|
}
|
|
37
75
|
this.pool = new PoolSuite(sdk, marketData);
|
|
38
|
-
for (
|
|
39
|
-
this.creditManagers.push(new CreditSuite(sdk,
|
|
76
|
+
for (const suiteData of marketData.creditManagers) {
|
|
77
|
+
this.creditManagers.push(new CreditSuite(sdk, suiteData));
|
|
40
78
|
}
|
|
41
79
|
this.priceOracle = createPriceOracle(sdk, marketData.priceOracle);
|
|
42
80
|
this.lossPolicy = createLossPolicy(sdk, marketData.lossPolicy);
|
|
43
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Underlying token of the market pool.
|
|
84
|
+
*/
|
|
44
85
|
get underlying() {
|
|
45
86
|
return this.pool.underlying;
|
|
46
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Factory contract that opens and manages RWA-compliant credit accounts for
|
|
90
|
+
* this market. Defined only for RWA markets.
|
|
91
|
+
*/
|
|
47
92
|
get rwaFactory() {
|
|
48
93
|
return this.pool.rwaFactory;
|
|
49
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Whether any child contract wrapper has observed events that require a
|
|
97
|
+
* market resync.
|
|
98
|
+
*/
|
|
50
99
|
get dirty() {
|
|
51
100
|
return this.configurator.dirty || this.pool.dirty || this.priceOracle.dirty || this.creditManagers.some((cm) => cm.dirty);
|
|
52
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Contract addresses whose logs are enough to detect stale market state.
|
|
104
|
+
*
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
53
107
|
get watchAddresses() {
|
|
54
108
|
return /* @__PURE__ */ new Set([
|
|
55
109
|
this.configurator.address,
|
|
@@ -59,6 +113,12 @@ class MarketSuite extends SDKConstruct {
|
|
|
59
113
|
...Array.from(this.pool.watchAddresses)
|
|
60
114
|
]);
|
|
61
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Returns a label-enriched, JSON-friendly view of the market state.
|
|
118
|
+
*
|
|
119
|
+
* @param raw - Whether child wrappers should keep raw numeric values when
|
|
120
|
+
* applying human formatting.
|
|
121
|
+
*/
|
|
62
122
|
stateHuman(raw = true) {
|
|
63
123
|
return {
|
|
64
124
|
configurator: this.labelAddress(this.configurator.address),
|
|
@@ -3,35 +3,101 @@ import createCreditConfigurator from "./createCreditConfigurator.js";
|
|
|
3
3
|
import createCreditFacade from "./createCreditFacade.js";
|
|
4
4
|
import createCreditManager from "./createCreditManager.js";
|
|
5
5
|
class CreditSuite extends SDKConstruct {
|
|
6
|
+
/**
|
|
7
|
+
* Pool that supplies underlying liquidity to this credit manager.
|
|
8
|
+
*/
|
|
6
9
|
pool;
|
|
7
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Wrapper around the core credit manager contract.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* The credit manager owns account accounting, collateral checks, enabled
|
|
15
|
+
* collateral token masks, adapter mappings, debt updates, and liquidation
|
|
16
|
+
* calculations for this branch.
|
|
17
|
+
*/
|
|
8
18
|
creditManager;
|
|
19
|
+
/**
|
|
20
|
+
* Wrapper around the credit facade contract used to build account
|
|
21
|
+
* transactions such as open, close, liquidate, and multicall.
|
|
22
|
+
*/
|
|
9
23
|
creditFacade;
|
|
24
|
+
/**
|
|
25
|
+
* Wrapper around the credit configurator that mutates risk
|
|
26
|
+
* parameters, collateral tokens, adapter permissions, and facade settings.
|
|
27
|
+
*/
|
|
10
28
|
creditConfigurator;
|
|
11
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Original compressor contract snapshot for this credit suite.
|
|
31
|
+
*/
|
|
12
32
|
state;
|
|
33
|
+
/**
|
|
34
|
+
* Human-readable credit manager name from the core contract state.
|
|
35
|
+
*/
|
|
13
36
|
name;
|
|
14
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Creates a credit suite from one entry in a market compressor snapshot.
|
|
39
|
+
*
|
|
40
|
+
* @param sdk - Attached SDK instance.
|
|
41
|
+
* @param data - Parent market snapshot part that contains the credit suite data.
|
|
42
|
+
*/
|
|
43
|
+
constructor(sdk, data) {
|
|
15
44
|
super(sdk);
|
|
16
|
-
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.pool = pool.baseParams.addr;
|
|
20
|
-
this.underlying = pool.underlying;
|
|
45
|
+
this.name = data.creditManager.name;
|
|
46
|
+
this.state = data;
|
|
47
|
+
this.pool = data.creditManager.pool;
|
|
21
48
|
this.creditManager = createCreditManager(sdk, this.state);
|
|
22
49
|
this.creditFacade = createCreditFacade(sdk, this.state);
|
|
23
50
|
this.creditConfigurator = createCreditConfigurator(sdk, this.state);
|
|
24
|
-
this.marketConfigurator = marketData.configurator;
|
|
25
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Token borrowed from the pool and used as the account debt asset.
|
|
54
|
+
*/
|
|
55
|
+
get underlying() {
|
|
56
|
+
return this.creditManager.underlying;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Parent market that contains this credit manager
|
|
60
|
+
*/
|
|
61
|
+
get market() {
|
|
62
|
+
return this.sdk.marketRegister.findByCreditManager(
|
|
63
|
+
this.creditManager.address
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Market configurator that governs this credit suite and its parent pool.
|
|
68
|
+
*/
|
|
69
|
+
get marketConfigurator() {
|
|
70
|
+
return this.market.configurator;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Router configured for this credit suite.
|
|
74
|
+
*/
|
|
26
75
|
get router() {
|
|
27
76
|
return this.sdk.routerFor(this);
|
|
28
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Whether this suite's facade is past its configured expiration timestamp.
|
|
80
|
+
*
|
|
81
|
+
* @remarks
|
|
82
|
+
* Expired credit suites can have different liquidation parameters on-chain.
|
|
83
|
+
* Non-expirable facades and facades with zero expiration are treated as not
|
|
84
|
+
* expired.
|
|
85
|
+
*/
|
|
29
86
|
get isExpired() {
|
|
30
87
|
return this.creditFacade.expirable && this.creditFacade.expirationDate > 0 && this.creditFacade.expirationDate < this.sdk.timestamp;
|
|
31
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Whether the facade, manager, or configurator has observed logs that require
|
|
91
|
+
* a credit-suite resync.
|
|
92
|
+
*/
|
|
32
93
|
get dirty() {
|
|
33
94
|
return this.creditFacade.dirty || this.creditManager.dirty || this.creditConfigurator.dirty;
|
|
34
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Credit contracts whose events are enough to detect stale suite state.
|
|
98
|
+
*
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
35
101
|
get watchAddresses() {
|
|
36
102
|
return /* @__PURE__ */ new Set([
|
|
37
103
|
this.creditConfigurator.address,
|
|
@@ -39,6 +105,12 @@ class CreditSuite extends SDKConstruct {
|
|
|
39
105
|
this.creditFacade.address
|
|
40
106
|
]);
|
|
41
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Returns a label-enriched, JSON-friendly view of this credit suite.
|
|
110
|
+
*
|
|
111
|
+
* @param raw - Whether child wrappers should keep raw numeric values instead
|
|
112
|
+
* of applying human formatting where they support both modes.
|
|
113
|
+
*/
|
|
42
114
|
stateHuman(raw = true) {
|
|
43
115
|
return {
|
|
44
116
|
isExpired: this.isExpired,
|
|
@@ -7,11 +7,34 @@ import { GaugeContract } from "./GaugeContract.js";
|
|
|
7
7
|
import { LinearInterestRateModelContract } from "./LinearInterestRateModelContract.js";
|
|
8
8
|
import { TumblerContract } from "./TumblerContract.js";
|
|
9
9
|
class PoolSuite extends SDKConstruct {
|
|
10
|
+
/**
|
|
11
|
+
* ERC-4626 liquidity pool wrapper for deposits, withdrawals, borrowing
|
|
12
|
+
* limits, and base interest accounting.
|
|
13
|
+
*/
|
|
10
14
|
pool;
|
|
15
|
+
/**
|
|
16
|
+
* Quota keeper wrapper that tracks per-token quota limits, quoted exposure,
|
|
17
|
+
* quota rates, and credit-manager access.
|
|
18
|
+
*/
|
|
11
19
|
pqk;
|
|
20
|
+
/**
|
|
21
|
+
* Rate keeper used by the quota keeper to obtain collateral-specific quota
|
|
22
|
+
* rates. Can be a {@link GaugeContract} or a {@link TumblerContract}.
|
|
23
|
+
*/
|
|
12
24
|
rateKeeper;
|
|
25
|
+
/**
|
|
26
|
+
* Interest-rate model used by the pool to calculate the base borrow rate from
|
|
27
|
+
* expected and available liquidity.
|
|
28
|
+
*/
|
|
13
29
|
interestRateModel;
|
|
14
30
|
#marketConfigurator;
|
|
31
|
+
/**
|
|
32
|
+
* Creates the pool aggregate from a market compressor snapshot.
|
|
33
|
+
*
|
|
34
|
+
* @param sdk - Attached SDK instance
|
|
35
|
+
* @param data - Full market snapshot containing pool, quota, rate, and
|
|
36
|
+
* interest-rate model state.
|
|
37
|
+
*/
|
|
15
38
|
constructor(sdk, data) {
|
|
16
39
|
super(sdk);
|
|
17
40
|
this.pool = createPool(sdk, data.pool);
|
|
@@ -23,6 +46,11 @@ class PoolSuite extends SDKConstruct {
|
|
|
23
46
|
);
|
|
24
47
|
this.#marketConfigurator = data.configurator;
|
|
25
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Narrows `rateKeeper` to a gauge rate keeper.
|
|
51
|
+
*
|
|
52
|
+
* @throws If the market uses a different rate keeper type.
|
|
53
|
+
*/
|
|
26
54
|
get gauge() {
|
|
27
55
|
if (this.rateKeeper instanceof GaugeContract) {
|
|
28
56
|
return this.rateKeeper;
|
|
@@ -31,6 +59,11 @@ class PoolSuite extends SDKConstruct {
|
|
|
31
59
|
`Rate keeper is not a gauge, but a ${this.rateKeeper.contractType}`
|
|
32
60
|
);
|
|
33
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Narrows `rateKeeper` to a tumbler rate keeper.
|
|
64
|
+
*
|
|
65
|
+
* @throws If the market uses a different rate keeper type.
|
|
66
|
+
*/
|
|
34
67
|
get tumbler() {
|
|
35
68
|
if (this.rateKeeper instanceof TumblerContract) {
|
|
36
69
|
return this.rateKeeper;
|
|
@@ -39,6 +72,11 @@ class PoolSuite extends SDKConstruct {
|
|
|
39
72
|
`Rate keeper is not a tumbler, but a ${this.rateKeeper.contractType}`
|
|
40
73
|
);
|
|
41
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Narrows `interestRateModel` to the linear interest-rate model.
|
|
77
|
+
*
|
|
78
|
+
* @throws If the market uses a different interest-rate model type.
|
|
79
|
+
*/
|
|
42
80
|
get linearModel() {
|
|
43
81
|
if (this.interestRateModel instanceof LinearInterestRateModelContract) {
|
|
44
82
|
return this.interestRateModel;
|
|
@@ -47,20 +85,40 @@ class PoolSuite extends SDKConstruct {
|
|
|
47
85
|
`Interest rate model is not a linear model, but a ${this.interestRateModel.contractType}`
|
|
48
86
|
);
|
|
49
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Market configurator that governs the pool and its connected credit suites.
|
|
90
|
+
*
|
|
91
|
+
* @throws If the configurator is missing from the SDK contract register.
|
|
92
|
+
*/
|
|
50
93
|
get marketConfigurator() {
|
|
51
94
|
return this.register.mustGetContract(
|
|
52
95
|
this.#marketConfigurator
|
|
53
96
|
);
|
|
54
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Underlying asset deposited into the pool and borrowed by connected credit
|
|
100
|
+
* suites.
|
|
101
|
+
*/
|
|
55
102
|
get underlying() {
|
|
56
103
|
return this.pool.underlying;
|
|
57
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* RWA factory associated with the pool's underlying, undefined for non-RWA markets.
|
|
107
|
+
*/
|
|
58
108
|
get rwaFactory() {
|
|
59
109
|
return this.pool.rwaFactory;
|
|
60
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Whether any pool-side wrapper has observed logs that require a resync.
|
|
113
|
+
*/
|
|
61
114
|
get dirty() {
|
|
62
115
|
return this.pool.dirty || this.rateKeeper.dirty || this.pqk.dirty || this.interestRateModel.dirty;
|
|
63
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Pool-side contract addresses whose logs are enough to detect stale state.
|
|
119
|
+
*
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
64
122
|
get watchAddresses() {
|
|
65
123
|
return /* @__PURE__ */ new Set([
|
|
66
124
|
this.pool.address,
|
|
@@ -69,6 +127,12 @@ class PoolSuite extends SDKConstruct {
|
|
|
69
127
|
this.interestRateModel.address
|
|
70
128
|
]);
|
|
71
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Returns a label-enriched, JSON-friendly view of the pool-side state.
|
|
132
|
+
*
|
|
133
|
+
* @param raw - Whether child wrappers should keep raw numeric values instead
|
|
134
|
+
* of applying human formatting where they support both modes.
|
|
135
|
+
*/
|
|
72
136
|
stateHuman(raw = true) {
|
|
73
137
|
return {
|
|
74
138
|
pool: this.pool.stateHuman(raw),
|
|
@@ -109,26 +109,6 @@ class PoolV310Contract extends BaseContract {
|
|
|
109
109
|
break;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
/**
|
|
113
|
-
* Deposits underlying assets into the pool on behalf of a user with a
|
|
114
|
-
* referral code.
|
|
115
|
-
*/
|
|
116
|
-
depositWithReferral(amount, onBehalfOf, referralCode) {
|
|
117
|
-
return this.createRawTx({
|
|
118
|
-
functionName: "depositWithReferral",
|
|
119
|
-
args: [amount, onBehalfOf, referralCode]
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Redeems pool shares from the owner and sends the underlying assets to
|
|
124
|
-
* the receiver.
|
|
125
|
-
*/
|
|
126
|
-
redeem(amount, owner, receiver) {
|
|
127
|
-
return this.createRawTx({
|
|
128
|
-
functionName: "redeem",
|
|
129
|
-
args: [amount, owner, receiver]
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
112
|
stringifyFunctionParams(params) {
|
|
133
113
|
switch (params.functionName) {
|
|
134
114
|
case "deposit": {
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
+
import { iPoolV310Abi } from "../../abi/310/generated.js";
|
|
1
2
|
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
3
|
+
import { ierc20ZapperDepositsAbi } from "../../abi/iERC20ZapperDeposits.js";
|
|
4
|
+
import { iethZapperDepositsAbi } from "../../abi/iETHZapperDeposits.js";
|
|
5
|
+
import { iZapperAbi } from "../../abi/iZapper.js";
|
|
2
6
|
import {
|
|
3
|
-
BaseContract,
|
|
4
7
|
RWA_UNDERLYING_DEFAULT,
|
|
5
8
|
RWA_UNDERLYING_ON_DEMAND,
|
|
6
9
|
SDKConstruct
|
|
7
10
|
} from "../base/index.js";
|
|
8
11
|
import { NATIVE_ADDRESS } from "../constants/index.js";
|
|
9
|
-
import {
|
|
10
|
-
IERC20ZapperDepositsContract,
|
|
11
|
-
IETHZapperDepositsContract,
|
|
12
|
-
IZapperContract
|
|
13
|
-
} from "../market/zapper/index.js";
|
|
14
12
|
import { AddressSet, hexEq } from "../utils/index.js";
|
|
15
13
|
class PoolService extends SDKConstruct {
|
|
16
14
|
/**
|
|
@@ -83,49 +81,41 @@ class PoolService extends SDKConstruct {
|
|
|
83
81
|
}
|
|
84
82
|
const { zapper } = meta;
|
|
85
83
|
if (zapper && hexEq(zapper.tokenIn.addr, NATIVE_ADDRESS)) {
|
|
86
|
-
const zapperContract = new IETHZapperDepositsContract(this.sdk, {
|
|
87
|
-
addr: zapper.baseParams.addr,
|
|
88
|
-
name: `ETHZapper(${this.labelAddress(zapper.baseParams.addr)})`
|
|
89
|
-
});
|
|
90
|
-
const tx2 = zapperContract.depositWithReferral(wallet, referralCode ?? 0n);
|
|
91
|
-
tx2.value = collateral.balance.toString();
|
|
92
84
|
return {
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
target: zapper.baseParams.addr,
|
|
86
|
+
abi: iethZapperDepositsAbi,
|
|
87
|
+
functionName: "depositWithReferral",
|
|
88
|
+
args: [wallet, referralCode],
|
|
89
|
+
value: collateral.balance
|
|
95
90
|
};
|
|
96
91
|
} else if (zapper) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
92
|
+
return permit ? {
|
|
93
|
+
target: zapper.baseParams.addr,
|
|
94
|
+
abi: ierc20ZapperDepositsAbi,
|
|
95
|
+
functionName: "depositWithReferralAndPermit",
|
|
96
|
+
args: [
|
|
97
|
+
collateral.balance,
|
|
98
|
+
wallet,
|
|
99
|
+
referralCode,
|
|
100
|
+
permit.deadline,
|
|
101
|
+
permit.v,
|
|
102
|
+
permit.r,
|
|
103
|
+
permit.s
|
|
104
|
+
]
|
|
105
|
+
} : {
|
|
106
|
+
target: zapper.baseParams.addr,
|
|
107
|
+
abi: ierc20ZapperDepositsAbi,
|
|
108
|
+
functionName: "depositWithReferral",
|
|
109
|
+
args: [collateral.balance, wallet, referralCode]
|
|
110
|
+
};
|
|
111
|
+
} else {
|
|
114
112
|
return {
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
target: pool,
|
|
114
|
+
abi: iPoolV310Abi,
|
|
115
|
+
functionName: "depositWithReferral",
|
|
116
|
+
args: [collateral.balance, wallet, referralCode]
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
|
-
const poolContract = this.sdk.marketRegister.findByPool(pool).pool.pool;
|
|
120
|
-
const tx = poolContract.depositWithReferral(
|
|
121
|
-
collateral.balance,
|
|
122
|
-
wallet,
|
|
123
|
-
referralCode ?? 0n
|
|
124
|
-
);
|
|
125
|
-
return {
|
|
126
|
-
tx,
|
|
127
|
-
calls: [{ target: pool, callData: tx.callData }]
|
|
128
|
-
};
|
|
129
119
|
}
|
|
130
120
|
/**
|
|
131
121
|
* {@inheritDoc IPoolsService.getWithdrawalTokensIn}
|
|
@@ -165,44 +155,39 @@ class PoolService extends SDKConstruct {
|
|
|
165
155
|
const underlying = this.#describeUnderlying(pool);
|
|
166
156
|
if (this.sdk.tokensMeta.isRWAUnderlying(underlying)) {
|
|
167
157
|
if (underlying.contractType === RWA_UNDERLYING_ON_DEMAND) {
|
|
168
|
-
|
|
169
|
-
addr: underlying.asset,
|
|
158
|
+
return {
|
|
170
159
|
abi: ierc20Abi,
|
|
171
|
-
name: "ERC20"
|
|
172
|
-
});
|
|
173
|
-
const tx2 = tokenContract.createRawTx({
|
|
174
160
|
functionName: "approve",
|
|
175
|
-
args: [underlying.liquidityProvider
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
tx: tx2,
|
|
179
|
-
calls: [{ target: underlying.asset, callData: tx2.callData }]
|
|
161
|
+
args: [underlying.liquidityProvider, 0n],
|
|
162
|
+
target: underlying.asset
|
|
180
163
|
};
|
|
181
164
|
}
|
|
182
165
|
}
|
|
183
166
|
if (meta.zapper) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
167
|
+
return permit ? {
|
|
168
|
+
target: meta.zapper.baseParams.addr,
|
|
169
|
+
abi: iZapperAbi,
|
|
170
|
+
functionName: "redeemWithPermit",
|
|
171
|
+
args: [
|
|
172
|
+
amount,
|
|
173
|
+
wallet,
|
|
174
|
+
permit.deadline,
|
|
175
|
+
permit.v,
|
|
176
|
+
permit.r,
|
|
177
|
+
permit.s
|
|
178
|
+
]
|
|
179
|
+
} : {
|
|
180
|
+
target: meta.zapper.baseParams.addr,
|
|
181
|
+
abi: iZapperAbi,
|
|
182
|
+
functionName: "redeem",
|
|
183
|
+
args: [amount, wallet]
|
|
199
184
|
};
|
|
200
185
|
}
|
|
201
|
-
const poolContract = this.sdk.marketRegister.findByPool(pool).pool.pool;
|
|
202
|
-
const tx = poolContract.redeem(amount, wallet, wallet);
|
|
203
186
|
return {
|
|
204
|
-
|
|
205
|
-
|
|
187
|
+
target: pool,
|
|
188
|
+
abi: iPoolV310Abi,
|
|
189
|
+
functionName: "redeem",
|
|
190
|
+
args: [amount, wallet, wallet]
|
|
206
191
|
};
|
|
207
192
|
}
|
|
208
193
|
/**
|
|
@@ -9,22 +9,91 @@ import { MarketConfiguratorContract } from "./MarketConfiguratorContract.js";
|
|
|
9
9
|
import type { IPriceOracleContract } from "./oracle/index.js";
|
|
10
10
|
import { PoolSuite } from "./pool/index.js";
|
|
11
11
|
import type { IRWAFactory } from "./rwa/types.js";
|
|
12
|
+
/**
|
|
13
|
+
* Aggregates all SDK wrappers that make up one Gearbox market.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* A market is the SDK representation of the core "one pool, many markets"
|
|
17
|
+
* architecture: one liquidity pool can fund several isolated credit suites,
|
|
18
|
+
* while the market-level configurator, price oracle, and loss policy define
|
|
19
|
+
* the shared risk boundary.
|
|
20
|
+
*/
|
|
12
21
|
export declare class MarketSuite extends SDKConstruct {
|
|
22
|
+
/**
|
|
23
|
+
* Access-control list contract that owns market roles such as pausable and
|
|
24
|
+
* unpausable admins.
|
|
25
|
+
*/
|
|
13
26
|
readonly acl: Address;
|
|
27
|
+
/**
|
|
28
|
+
* Treasury splitter or fee recipient associated with this market.
|
|
29
|
+
*/
|
|
14
30
|
readonly treasury: Address;
|
|
31
|
+
/**
|
|
32
|
+
* Market-level configurator that controls pool and credit-suite risk
|
|
33
|
+
* parameters.
|
|
34
|
+
*/
|
|
15
35
|
readonly configurator: MarketConfiguratorContract;
|
|
36
|
+
/**
|
|
37
|
+
* Pool-side contract bundle: ERC-4626 pool, quota keeper, rate keeper, and
|
|
38
|
+
* interest-rate model.
|
|
39
|
+
*/
|
|
16
40
|
readonly pool: PoolSuite;
|
|
41
|
+
/**
|
|
42
|
+
* Market price oracle used by credit managers and pool for normalized
|
|
43
|
+
* price conversion and safe-price checks.
|
|
44
|
+
*/
|
|
17
45
|
readonly priceOracle: IPriceOracleContract;
|
|
46
|
+
/**
|
|
47
|
+
* Bad-debt liquidation policy shared by the market's credit facades.
|
|
48
|
+
*/
|
|
18
49
|
readonly lossPolicy: ILossPolicyContract;
|
|
50
|
+
/**
|
|
51
|
+
* Credit-suite wrappers connected to the pool.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* Each suite corresponds to one credit manager branch with its own facade,
|
|
55
|
+
* configurator, collateral set, adapters, debt limits, and expiration policy.
|
|
56
|
+
*/
|
|
19
57
|
readonly creditManagers: CreditSuite[];
|
|
20
58
|
/**
|
|
21
|
-
* Original
|
|
59
|
+
* Original market snapshot received from the market compressor contract.
|
|
22
60
|
*/
|
|
23
61
|
readonly state: MarketData;
|
|
62
|
+
/**
|
|
63
|
+
* Creates a market aggregate from compressor state.
|
|
64
|
+
*
|
|
65
|
+
* @param sdk - Attached on-chain SDK instance used for contract lookup,
|
|
66
|
+
* labels, token metadata, and plugin access.
|
|
67
|
+
* @param marketData - Full market state returned by the market compressor.
|
|
68
|
+
* @throws If the configurator address from `marketData` is not already
|
|
69
|
+
* registered as a {@link MarketConfiguratorContract}.
|
|
70
|
+
*/
|
|
24
71
|
constructor(sdk: OnchainSDK, marketData: MarketData);
|
|
72
|
+
/**
|
|
73
|
+
* Underlying token of the market pool.
|
|
74
|
+
*/
|
|
25
75
|
get underlying(): Address;
|
|
76
|
+
/**
|
|
77
|
+
* Factory contract that opens and manages RWA-compliant credit accounts for
|
|
78
|
+
* this market. Defined only for RWA markets.
|
|
79
|
+
*/
|
|
26
80
|
get rwaFactory(): IRWAFactory | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Whether any child contract wrapper has observed events that require a
|
|
83
|
+
* market resync.
|
|
84
|
+
*/
|
|
27
85
|
get dirty(): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Contract addresses whose logs are enough to detect stale market state.
|
|
88
|
+
*
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
28
91
|
get watchAddresses(): Set<Address>;
|
|
92
|
+
/**
|
|
93
|
+
* Returns a label-enriched, JSON-friendly view of the market state.
|
|
94
|
+
*
|
|
95
|
+
* @param raw - Whether child wrappers should keep raw numeric values when
|
|
96
|
+
* applying human formatting.
|
|
97
|
+
*/
|
|
29
98
|
stateHuman(raw?: boolean): MarketStateHuman;
|
|
30
99
|
}
|