@gearbox-protocol/sdk 14.10.3-next.2 → 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/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/market/MarketSuite.d.ts +70 -1
- package/dist/types/sdk/market/ZapperRegister.d.ts +4 -4
- 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 +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
|
@@ -524,11 +524,12 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
524
524
|
if (!depositCall) {
|
|
525
525
|
throw new Error(`no deposit call could be created for ${poolName}`);
|
|
526
526
|
}
|
|
527
|
-
txHash = await this.#anvil.
|
|
527
|
+
txHash = await this.#anvil.writeContract({
|
|
528
528
|
account: depositor,
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
529
|
+
address: depositCall.target,
|
|
530
|
+
abi: depositCall.abi,
|
|
531
|
+
functionName: depositCall.functionName,
|
|
532
|
+
args: depositCall.args,
|
|
532
533
|
chain: this.#anvil.chain
|
|
533
534
|
});
|
|
534
535
|
receipt = await this.#anvil.waitForTransactionReceipt({ hash: txHash });
|
|
@@ -154,7 +154,7 @@ class OnchainSdkStrategyDataSource {
|
|
|
154
154
|
maxEnabledTokensLength: cm.maxEnabledTokens,
|
|
155
155
|
version: Number(facade.version),
|
|
156
156
|
isBorrowingForbidden: facade.maxDebtPerBlockMultiplier === 0,
|
|
157
|
-
marketConfigurator: lc(cs.marketConfigurator),
|
|
157
|
+
marketConfigurator: lc(cs.marketConfigurator.address),
|
|
158
158
|
supportedTokens,
|
|
159
159
|
forbiddenTokens,
|
|
160
160
|
name: cs.name,
|
|
@@ -28,17 +28,55 @@ var import_MarketConfiguratorContract = require("./MarketConfiguratorContract.js
|
|
|
28
28
|
var import_oracle = require("./oracle/index.js");
|
|
29
29
|
var import_pool = require("./pool/index.js");
|
|
30
30
|
class MarketSuite extends import_base.SDKConstruct {
|
|
31
|
+
/**
|
|
32
|
+
* Access-control list contract that owns market roles such as pausable and
|
|
33
|
+
* unpausable admins.
|
|
34
|
+
*/
|
|
31
35
|
acl;
|
|
36
|
+
/**
|
|
37
|
+
* Treasury splitter or fee recipient associated with this market.
|
|
38
|
+
*/
|
|
32
39
|
treasury;
|
|
40
|
+
/**
|
|
41
|
+
* Market-level configurator that controls pool and credit-suite risk
|
|
42
|
+
* parameters.
|
|
43
|
+
*/
|
|
33
44
|
configurator;
|
|
45
|
+
/**
|
|
46
|
+
* Pool-side contract bundle: ERC-4626 pool, quota keeper, rate keeper, and
|
|
47
|
+
* interest-rate model.
|
|
48
|
+
*/
|
|
34
49
|
pool;
|
|
50
|
+
/**
|
|
51
|
+
* Market price oracle used by credit managers and pool for normalized
|
|
52
|
+
* price conversion and safe-price checks.
|
|
53
|
+
*/
|
|
35
54
|
priceOracle;
|
|
55
|
+
/**
|
|
56
|
+
* Bad-debt liquidation policy shared by the market's credit facades.
|
|
57
|
+
*/
|
|
36
58
|
lossPolicy;
|
|
59
|
+
/**
|
|
60
|
+
* Credit-suite wrappers connected to the pool.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* Each suite corresponds to one credit manager branch with its own facade,
|
|
64
|
+
* configurator, collateral set, adapters, debt limits, and expiration policy.
|
|
65
|
+
*/
|
|
37
66
|
creditManagers = [];
|
|
38
67
|
/**
|
|
39
|
-
* Original
|
|
68
|
+
* Original market snapshot received from the market compressor contract.
|
|
40
69
|
*/
|
|
41
70
|
state;
|
|
71
|
+
/**
|
|
72
|
+
* Creates a market aggregate from compressor state.
|
|
73
|
+
*
|
|
74
|
+
* @param sdk - Attached on-chain SDK instance used for contract lookup,
|
|
75
|
+
* labels, token metadata, and plugin access.
|
|
76
|
+
* @param marketData - Full market state returned by the market compressor.
|
|
77
|
+
* @throws If the configurator address from `marketData` is not already
|
|
78
|
+
* registered as a {@link MarketConfiguratorContract}.
|
|
79
|
+
*/
|
|
42
80
|
constructor(sdk, marketData) {
|
|
43
81
|
super(sdk);
|
|
44
82
|
this.state = marketData;
|
|
@@ -56,21 +94,37 @@ class MarketSuite extends import_base.SDKConstruct {
|
|
|
56
94
|
sdk.setAddressLabel(t.addr, t.symbol);
|
|
57
95
|
}
|
|
58
96
|
this.pool = new import_pool.PoolSuite(sdk, marketData);
|
|
59
|
-
for (
|
|
60
|
-
this.creditManagers.push(new import_credit.CreditSuite(sdk,
|
|
97
|
+
for (const suiteData of marketData.creditManagers) {
|
|
98
|
+
this.creditManagers.push(new import_credit.CreditSuite(sdk, suiteData));
|
|
61
99
|
}
|
|
62
100
|
this.priceOracle = (0, import_oracle.createPriceOracle)(sdk, marketData.priceOracle);
|
|
63
101
|
this.lossPolicy = (0, import_loss_policy.createLossPolicy)(sdk, marketData.lossPolicy);
|
|
64
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Underlying token of the market pool.
|
|
105
|
+
*/
|
|
65
106
|
get underlying() {
|
|
66
107
|
return this.pool.underlying;
|
|
67
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Factory contract that opens and manages RWA-compliant credit accounts for
|
|
111
|
+
* this market. Defined only for RWA markets.
|
|
112
|
+
*/
|
|
68
113
|
get rwaFactory() {
|
|
69
114
|
return this.pool.rwaFactory;
|
|
70
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Whether any child contract wrapper has observed events that require a
|
|
118
|
+
* market resync.
|
|
119
|
+
*/
|
|
71
120
|
get dirty() {
|
|
72
121
|
return this.configurator.dirty || this.pool.dirty || this.priceOracle.dirty || this.creditManagers.some((cm) => cm.dirty);
|
|
73
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Contract addresses whose logs are enough to detect stale market state.
|
|
125
|
+
*
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
74
128
|
get watchAddresses() {
|
|
75
129
|
return /* @__PURE__ */ new Set([
|
|
76
130
|
this.configurator.address,
|
|
@@ -80,6 +134,12 @@ class MarketSuite extends import_base.SDKConstruct {
|
|
|
80
134
|
...Array.from(this.pool.watchAddresses)
|
|
81
135
|
]);
|
|
82
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Returns a label-enriched, JSON-friendly view of the market state.
|
|
139
|
+
*
|
|
140
|
+
* @param raw - Whether child wrappers should keep raw numeric values when
|
|
141
|
+
* applying human formatting.
|
|
142
|
+
*/
|
|
83
143
|
stateHuman(raw = true) {
|
|
84
144
|
return {
|
|
85
145
|
configurator: this.labelAddress(this.configurator.address),
|
|
@@ -25,10 +25,9 @@ var import_peripheryCompressor = require("../../abi/compressors/peripheryCompres
|
|
|
25
25
|
var import_base = require("../base/index.js");
|
|
26
26
|
var import_constants = require("../constants/index.js");
|
|
27
27
|
var import_utils = require("../utils/index.js");
|
|
28
|
-
var import_zapper = require("./zapper/index.js");
|
|
29
28
|
class ZapperRegister extends import_base.SDKConstruct {
|
|
30
29
|
/**
|
|
31
|
-
* Mapping pool.address ->
|
|
30
|
+
* Mapping pool.address -> ZapperData[]
|
|
32
31
|
* Needs to be loaded explicitly using loadZappers method
|
|
33
32
|
*/
|
|
34
33
|
#zappers;
|
|
@@ -76,17 +75,16 @@ class ZapperRegister extends import_base.SDKConstruct {
|
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
77
|
#addZapper(z) {
|
|
79
|
-
const zapper = (0, import_zapper.createZapper)(this.sdk, z);
|
|
80
78
|
const existing = this.zappers.get(z.pool);
|
|
81
79
|
if (existing) {
|
|
82
80
|
const hasZapper = existing.some(
|
|
83
81
|
(zz) => (0, import_utils.hexEq)(zz.baseParams.addr, z.baseParams.addr)
|
|
84
82
|
);
|
|
85
83
|
if (!hasZapper) {
|
|
86
|
-
existing.push(
|
|
84
|
+
existing.push(z);
|
|
87
85
|
}
|
|
88
86
|
} else {
|
|
89
|
-
this.zappers.upsert(z.pool, [
|
|
87
|
+
this.zappers.upsert(z.pool, [z]);
|
|
90
88
|
}
|
|
91
89
|
const zappersTokens = [z.tokenIn, z.tokenOut];
|
|
92
90
|
for (const t of zappersTokens) {
|
|
@@ -36,35 +36,101 @@ var import_createCreditConfigurator = __toESM(require("./createCreditConfigurato
|
|
|
36
36
|
var import_createCreditFacade = __toESM(require("./createCreditFacade.js"));
|
|
37
37
|
var import_createCreditManager = __toESM(require("./createCreditManager.js"));
|
|
38
38
|
class CreditSuite extends import_base.SDKConstruct {
|
|
39
|
+
/**
|
|
40
|
+
* Pool that supplies underlying liquidity to this credit manager.
|
|
41
|
+
*/
|
|
39
42
|
pool;
|
|
40
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Wrapper around the core credit manager contract.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* The credit manager owns account accounting, collateral checks, enabled
|
|
48
|
+
* collateral token masks, adapter mappings, debt updates, and liquidation
|
|
49
|
+
* calculations for this branch.
|
|
50
|
+
*/
|
|
41
51
|
creditManager;
|
|
52
|
+
/**
|
|
53
|
+
* Wrapper around the credit facade contract used to build account
|
|
54
|
+
* transactions such as open, close, liquidate, and multicall.
|
|
55
|
+
*/
|
|
42
56
|
creditFacade;
|
|
57
|
+
/**
|
|
58
|
+
* Wrapper around the credit configurator that mutates risk
|
|
59
|
+
* parameters, collateral tokens, adapter permissions, and facade settings.
|
|
60
|
+
*/
|
|
43
61
|
creditConfigurator;
|
|
44
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Original compressor contract snapshot for this credit suite.
|
|
64
|
+
*/
|
|
45
65
|
state;
|
|
66
|
+
/**
|
|
67
|
+
* Human-readable credit manager name from the core contract state.
|
|
68
|
+
*/
|
|
46
69
|
name;
|
|
47
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Creates a credit suite from one entry in a market compressor snapshot.
|
|
72
|
+
*
|
|
73
|
+
* @param sdk - Attached SDK instance.
|
|
74
|
+
* @param data - Parent market snapshot part that contains the credit suite data.
|
|
75
|
+
*/
|
|
76
|
+
constructor(sdk, data) {
|
|
48
77
|
super(sdk);
|
|
49
|
-
|
|
50
|
-
this.
|
|
51
|
-
this.
|
|
52
|
-
this.pool = pool.baseParams.addr;
|
|
53
|
-
this.underlying = pool.underlying;
|
|
78
|
+
this.name = data.creditManager.name;
|
|
79
|
+
this.state = data;
|
|
80
|
+
this.pool = data.creditManager.pool;
|
|
54
81
|
this.creditManager = (0, import_createCreditManager.default)(sdk, this.state);
|
|
55
82
|
this.creditFacade = (0, import_createCreditFacade.default)(sdk, this.state);
|
|
56
83
|
this.creditConfigurator = (0, import_createCreditConfigurator.default)(sdk, this.state);
|
|
57
|
-
this.marketConfigurator = marketData.configurator;
|
|
58
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Token borrowed from the pool and used as the account debt asset.
|
|
87
|
+
*/
|
|
88
|
+
get underlying() {
|
|
89
|
+
return this.creditManager.underlying;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Parent market that contains this credit manager
|
|
93
|
+
*/
|
|
94
|
+
get market() {
|
|
95
|
+
return this.sdk.marketRegister.findByCreditManager(
|
|
96
|
+
this.creditManager.address
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Market configurator that governs this credit suite and its parent pool.
|
|
101
|
+
*/
|
|
102
|
+
get marketConfigurator() {
|
|
103
|
+
return this.market.configurator;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Router configured for this credit suite.
|
|
107
|
+
*/
|
|
59
108
|
get router() {
|
|
60
109
|
return this.sdk.routerFor(this);
|
|
61
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Whether this suite's facade is past its configured expiration timestamp.
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* Expired credit suites can have different liquidation parameters on-chain.
|
|
116
|
+
* Non-expirable facades and facades with zero expiration are treated as not
|
|
117
|
+
* expired.
|
|
118
|
+
*/
|
|
62
119
|
get isExpired() {
|
|
63
120
|
return this.creditFacade.expirable && this.creditFacade.expirationDate > 0 && this.creditFacade.expirationDate < this.sdk.timestamp;
|
|
64
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Whether the facade, manager, or configurator has observed logs that require
|
|
124
|
+
* a credit-suite resync.
|
|
125
|
+
*/
|
|
65
126
|
get dirty() {
|
|
66
127
|
return this.creditFacade.dirty || this.creditManager.dirty || this.creditConfigurator.dirty;
|
|
67
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Credit contracts whose events are enough to detect stale suite state.
|
|
131
|
+
*
|
|
132
|
+
* @internal
|
|
133
|
+
*/
|
|
68
134
|
get watchAddresses() {
|
|
69
135
|
return /* @__PURE__ */ new Set([
|
|
70
136
|
this.creditConfigurator.address,
|
|
@@ -72,6 +138,12 @@ class CreditSuite extends import_base.SDKConstruct {
|
|
|
72
138
|
this.creditFacade.address
|
|
73
139
|
]);
|
|
74
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Returns a label-enriched, JSON-friendly view of this credit suite.
|
|
143
|
+
*
|
|
144
|
+
* @param raw - Whether child wrappers should keep raw numeric values instead
|
|
145
|
+
* of applying human formatting where they support both modes.
|
|
146
|
+
*/
|
|
75
147
|
stateHuman(raw = true) {
|
|
76
148
|
return {
|
|
77
149
|
isExpired: this.isExpired,
|
|
@@ -24,7 +24,6 @@ __reExport(market_exports, require("./pool/index.js"), module.exports);
|
|
|
24
24
|
__reExport(market_exports, require("./pricefeeds/index.js"), module.exports);
|
|
25
25
|
__reExport(market_exports, require("./rwa/index.js"), module.exports);
|
|
26
26
|
__reExport(market_exports, require("./types.js"), module.exports);
|
|
27
|
-
__reExport(market_exports, require("./zapper/index.js"), module.exports);
|
|
28
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
29
28
|
0 && (module.exports = {
|
|
30
29
|
...require("./adapters/index.js"),
|
|
@@ -35,6 +34,5 @@ __reExport(market_exports, require("./zapper/index.js"), module.exports);
|
|
|
35
34
|
...require("./pool/index.js"),
|
|
36
35
|
...require("./pricefeeds/index.js"),
|
|
37
36
|
...require("./rwa/index.js"),
|
|
38
|
-
...require("./types.js")
|
|
39
|
-
...require("./zapper/index.js")
|
|
37
|
+
...require("./types.js")
|
|
40
38
|
});
|
|
@@ -40,11 +40,34 @@ var import_GaugeContract = require("./GaugeContract.js");
|
|
|
40
40
|
var import_LinearInterestRateModelContract = require("./LinearInterestRateModelContract.js");
|
|
41
41
|
var import_TumblerContract = require("./TumblerContract.js");
|
|
42
42
|
class PoolSuite extends import_base.SDKConstruct {
|
|
43
|
+
/**
|
|
44
|
+
* ERC-4626 liquidity pool wrapper for deposits, withdrawals, borrowing
|
|
45
|
+
* limits, and base interest accounting.
|
|
46
|
+
*/
|
|
43
47
|
pool;
|
|
48
|
+
/**
|
|
49
|
+
* Quota keeper wrapper that tracks per-token quota limits, quoted exposure,
|
|
50
|
+
* quota rates, and credit-manager access.
|
|
51
|
+
*/
|
|
44
52
|
pqk;
|
|
53
|
+
/**
|
|
54
|
+
* Rate keeper used by the quota keeper to obtain collateral-specific quota
|
|
55
|
+
* rates. Can be a {@link GaugeContract} or a {@link TumblerContract}.
|
|
56
|
+
*/
|
|
45
57
|
rateKeeper;
|
|
58
|
+
/**
|
|
59
|
+
* Interest-rate model used by the pool to calculate the base borrow rate from
|
|
60
|
+
* expected and available liquidity.
|
|
61
|
+
*/
|
|
46
62
|
interestRateModel;
|
|
47
63
|
#marketConfigurator;
|
|
64
|
+
/**
|
|
65
|
+
* Creates the pool aggregate from a market compressor snapshot.
|
|
66
|
+
*
|
|
67
|
+
* @param sdk - Attached SDK instance
|
|
68
|
+
* @param data - Full market snapshot containing pool, quota, rate, and
|
|
69
|
+
* interest-rate model state.
|
|
70
|
+
*/
|
|
48
71
|
constructor(sdk, data) {
|
|
49
72
|
super(sdk);
|
|
50
73
|
this.pool = (0, import_createPool.default)(sdk, data.pool);
|
|
@@ -56,6 +79,11 @@ class PoolSuite extends import_base.SDKConstruct {
|
|
|
56
79
|
);
|
|
57
80
|
this.#marketConfigurator = data.configurator;
|
|
58
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Narrows `rateKeeper` to a gauge rate keeper.
|
|
84
|
+
*
|
|
85
|
+
* @throws If the market uses a different rate keeper type.
|
|
86
|
+
*/
|
|
59
87
|
get gauge() {
|
|
60
88
|
if (this.rateKeeper instanceof import_GaugeContract.GaugeContract) {
|
|
61
89
|
return this.rateKeeper;
|
|
@@ -64,6 +92,11 @@ class PoolSuite extends import_base.SDKConstruct {
|
|
|
64
92
|
`Rate keeper is not a gauge, but a ${this.rateKeeper.contractType}`
|
|
65
93
|
);
|
|
66
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Narrows `rateKeeper` to a tumbler rate keeper.
|
|
97
|
+
*
|
|
98
|
+
* @throws If the market uses a different rate keeper type.
|
|
99
|
+
*/
|
|
67
100
|
get tumbler() {
|
|
68
101
|
if (this.rateKeeper instanceof import_TumblerContract.TumblerContract) {
|
|
69
102
|
return this.rateKeeper;
|
|
@@ -72,6 +105,11 @@ class PoolSuite extends import_base.SDKConstruct {
|
|
|
72
105
|
`Rate keeper is not a tumbler, but a ${this.rateKeeper.contractType}`
|
|
73
106
|
);
|
|
74
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Narrows `interestRateModel` to the linear interest-rate model.
|
|
110
|
+
*
|
|
111
|
+
* @throws If the market uses a different interest-rate model type.
|
|
112
|
+
*/
|
|
75
113
|
get linearModel() {
|
|
76
114
|
if (this.interestRateModel instanceof import_LinearInterestRateModelContract.LinearInterestRateModelContract) {
|
|
77
115
|
return this.interestRateModel;
|
|
@@ -80,20 +118,40 @@ class PoolSuite extends import_base.SDKConstruct {
|
|
|
80
118
|
`Interest rate model is not a linear model, but a ${this.interestRateModel.contractType}`
|
|
81
119
|
);
|
|
82
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Market configurator that governs the pool and its connected credit suites.
|
|
123
|
+
*
|
|
124
|
+
* @throws If the configurator is missing from the SDK contract register.
|
|
125
|
+
*/
|
|
83
126
|
get marketConfigurator() {
|
|
84
127
|
return this.register.mustGetContract(
|
|
85
128
|
this.#marketConfigurator
|
|
86
129
|
);
|
|
87
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Underlying asset deposited into the pool and borrowed by connected credit
|
|
133
|
+
* suites.
|
|
134
|
+
*/
|
|
88
135
|
get underlying() {
|
|
89
136
|
return this.pool.underlying;
|
|
90
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* RWA factory associated with the pool's underlying, undefined for non-RWA markets.
|
|
140
|
+
*/
|
|
91
141
|
get rwaFactory() {
|
|
92
142
|
return this.pool.rwaFactory;
|
|
93
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Whether any pool-side wrapper has observed logs that require a resync.
|
|
146
|
+
*/
|
|
94
147
|
get dirty() {
|
|
95
148
|
return this.pool.dirty || this.rateKeeper.dirty || this.pqk.dirty || this.interestRateModel.dirty;
|
|
96
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Pool-side contract addresses whose logs are enough to detect stale state.
|
|
152
|
+
*
|
|
153
|
+
* @internal
|
|
154
|
+
*/
|
|
97
155
|
get watchAddresses() {
|
|
98
156
|
return /* @__PURE__ */ new Set([
|
|
99
157
|
this.pool.address,
|
|
@@ -102,6 +160,12 @@ class PoolSuite extends import_base.SDKConstruct {
|
|
|
102
160
|
this.interestRateModel.address
|
|
103
161
|
]);
|
|
104
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Returns a label-enriched, JSON-friendly view of the pool-side state.
|
|
165
|
+
*
|
|
166
|
+
* @param raw - Whether child wrappers should keep raw numeric values instead
|
|
167
|
+
* of applying human formatting where they support both modes.
|
|
168
|
+
*/
|
|
105
169
|
stateHuman(raw = true) {
|
|
106
170
|
return {
|
|
107
171
|
pool: this.pool.stateHuman(raw),
|
|
@@ -127,26 +127,6 @@ class PoolV310Contract extends import_base.BaseContract {
|
|
|
127
127
|
break;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
/**
|
|
131
|
-
* Deposits underlying assets into the pool on behalf of a user with a
|
|
132
|
-
* referral code.
|
|
133
|
-
*/
|
|
134
|
-
depositWithReferral(amount, onBehalfOf, referralCode) {
|
|
135
|
-
return this.createRawTx({
|
|
136
|
-
functionName: "depositWithReferral",
|
|
137
|
-
args: [amount, onBehalfOf, referralCode]
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Redeems pool shares from the owner and sends the underlying assets to
|
|
142
|
-
* the receiver.
|
|
143
|
-
*/
|
|
144
|
-
redeem(amount, owner, receiver) {
|
|
145
|
-
return this.createRawTx({
|
|
146
|
-
functionName: "redeem",
|
|
147
|
-
args: [amount, owner, receiver]
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
130
|
stringifyFunctionParams(params) {
|
|
151
131
|
switch (params.functionName) {
|
|
152
132
|
case "deposit": {
|
|
@@ -21,10 +21,13 @@ __export(PoolService_exports, {
|
|
|
21
21
|
PoolService: () => PoolService
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(PoolService_exports);
|
|
24
|
+
var import_generated = require("../../abi/310/generated.js");
|
|
24
25
|
var import_iERC20 = require("../../abi/iERC20.js");
|
|
26
|
+
var import_iERC20ZapperDeposits = require("../../abi/iERC20ZapperDeposits.js");
|
|
27
|
+
var import_iETHZapperDeposits = require("../../abi/iETHZapperDeposits.js");
|
|
28
|
+
var import_iZapper = require("../../abi/iZapper.js");
|
|
25
29
|
var import_base = require("../base/index.js");
|
|
26
30
|
var import_constants = require("../constants/index.js");
|
|
27
|
-
var import_market = require("../market/index.js");
|
|
28
31
|
var import_utils = require("../utils/index.js");
|
|
29
32
|
class PoolService extends import_base.SDKConstruct {
|
|
30
33
|
/**
|
|
@@ -96,42 +99,42 @@ class PoolService extends import_base.SDKConstruct {
|
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
const { zapper } = meta;
|
|
99
|
-
if (zapper
|
|
100
|
-
const tx2 = zapper.depositWithReferral(wallet, referralCode ?? 0n);
|
|
101
|
-
tx2.value = collateral.balance.toString();
|
|
102
|
+
if (zapper && (0, import_utils.hexEq)(zapper.tokenIn.addr, import_constants.NATIVE_ADDRESS)) {
|
|
102
103
|
return {
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
target: zapper.baseParams.addr,
|
|
105
|
+
abi: import_iETHZapperDeposits.iethZapperDepositsAbi,
|
|
106
|
+
functionName: "depositWithReferral",
|
|
107
|
+
args: [wallet, referralCode],
|
|
108
|
+
value: collateral.balance
|
|
105
109
|
};
|
|
106
|
-
} else if (zapper
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
110
|
+
} else if (zapper) {
|
|
111
|
+
return permit ? {
|
|
112
|
+
target: zapper.baseParams.addr,
|
|
113
|
+
abi: import_iERC20ZapperDeposits.ierc20ZapperDepositsAbi,
|
|
114
|
+
functionName: "depositWithReferralAndPermit",
|
|
115
|
+
args: [
|
|
116
|
+
collateral.balance,
|
|
117
|
+
wallet,
|
|
118
|
+
referralCode,
|
|
119
|
+
permit.deadline,
|
|
120
|
+
permit.v,
|
|
121
|
+
permit.r,
|
|
122
|
+
permit.s
|
|
123
|
+
]
|
|
124
|
+
} : {
|
|
125
|
+
target: zapper.baseParams.addr,
|
|
126
|
+
abi: import_iERC20ZapperDeposits.ierc20ZapperDepositsAbi,
|
|
127
|
+
functionName: "depositWithReferral",
|
|
128
|
+
args: [collateral.balance, wallet, referralCode]
|
|
129
|
+
};
|
|
130
|
+
} else {
|
|
120
131
|
return {
|
|
121
|
-
|
|
122
|
-
|
|
132
|
+
target: pool,
|
|
133
|
+
abi: import_generated.iPoolV310Abi,
|
|
134
|
+
functionName: "depositWithReferral",
|
|
135
|
+
args: [collateral.balance, wallet, referralCode]
|
|
123
136
|
};
|
|
124
137
|
}
|
|
125
|
-
const poolContract = this.sdk.marketRegister.findByPool(pool).pool.pool;
|
|
126
|
-
const tx = poolContract.depositWithReferral(
|
|
127
|
-
collateral.balance,
|
|
128
|
-
wallet,
|
|
129
|
-
referralCode ?? 0n
|
|
130
|
-
);
|
|
131
|
-
return {
|
|
132
|
-
tx,
|
|
133
|
-
calls: [{ target: pool, callData: tx.callData }]
|
|
134
|
-
};
|
|
135
138
|
}
|
|
136
139
|
/**
|
|
137
140
|
* {@inheritDoc IPoolsService.getWithdrawalTokensIn}
|
|
@@ -171,40 +174,39 @@ class PoolService extends import_base.SDKConstruct {
|
|
|
171
174
|
const underlying = this.#describeUnderlying(pool);
|
|
172
175
|
if (this.sdk.tokensMeta.isRWAUnderlying(underlying)) {
|
|
173
176
|
if (underlying.contractType === import_base.RWA_UNDERLYING_ON_DEMAND) {
|
|
174
|
-
|
|
175
|
-
addr: underlying.asset,
|
|
177
|
+
return {
|
|
176
178
|
abi: import_iERC20.ierc20Abi,
|
|
177
|
-
name: "ERC20"
|
|
178
|
-
});
|
|
179
|
-
const tx2 = tokenContract.createRawTx({
|
|
180
179
|
functionName: "approve",
|
|
181
|
-
args: [underlying.liquidityProvider
|
|
182
|
-
|
|
183
|
-
return {
|
|
184
|
-
tx: tx2,
|
|
185
|
-
calls: [{ target: underlying.asset, callData: tx2.callData }]
|
|
180
|
+
args: [underlying.liquidityProvider, 0n],
|
|
181
|
+
target: underlying.asset
|
|
186
182
|
};
|
|
187
183
|
}
|
|
188
184
|
}
|
|
189
|
-
if (meta.zapper
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
185
|
+
if (meta.zapper) {
|
|
186
|
+
return permit ? {
|
|
187
|
+
target: meta.zapper.baseParams.addr,
|
|
188
|
+
abi: import_iZapper.iZapperAbi,
|
|
189
|
+
functionName: "redeemWithPermit",
|
|
190
|
+
args: [
|
|
191
|
+
amount,
|
|
192
|
+
wallet,
|
|
193
|
+
permit.deadline,
|
|
194
|
+
permit.v,
|
|
195
|
+
permit.r,
|
|
196
|
+
permit.s
|
|
197
|
+
]
|
|
198
|
+
} : {
|
|
199
|
+
target: meta.zapper.baseParams.addr,
|
|
200
|
+
abi: import_iZapper.iZapperAbi,
|
|
201
|
+
functionName: "redeem",
|
|
202
|
+
args: [amount, wallet]
|
|
201
203
|
};
|
|
202
204
|
}
|
|
203
|
-
const poolContract = this.sdk.marketRegister.findByPool(pool).pool.pool;
|
|
204
|
-
const tx = poolContract.redeem(amount, wallet, wallet);
|
|
205
205
|
return {
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
target: pool,
|
|
207
|
+
abi: import_generated.iPoolV310Abi,
|
|
208
|
+
functionName: "redeem",
|
|
209
|
+
args: [amount, wallet, wallet]
|
|
208
210
|
};
|
|
209
211
|
}
|
|
210
212
|
/**
|
|
@@ -516,11 +516,12 @@ class AccountOpener extends SDKConstruct {
|
|
|
516
516
|
if (!depositCall) {
|
|
517
517
|
throw new Error(`no deposit call could be created for ${poolName}`);
|
|
518
518
|
}
|
|
519
|
-
txHash = await this.#anvil.
|
|
519
|
+
txHash = await this.#anvil.writeContract({
|
|
520
520
|
account: depositor,
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
521
|
+
address: depositCall.target,
|
|
522
|
+
abi: depositCall.abi,
|
|
523
|
+
functionName: depositCall.functionName,
|
|
524
|
+
args: depositCall.args,
|
|
524
525
|
chain: this.#anvil.chain
|
|
525
526
|
});
|
|
526
527
|
receipt = await this.#anvil.waitForTransactionReceipt({ hash: txHash });
|
|
@@ -138,7 +138,7 @@ class OnchainSdkStrategyDataSource {
|
|
|
138
138
|
maxEnabledTokensLength: cm.maxEnabledTokens,
|
|
139
139
|
version: Number(facade.version),
|
|
140
140
|
isBorrowingForbidden: facade.maxDebtPerBlockMultiplier === 0,
|
|
141
|
-
marketConfigurator: lc(cs.marketConfigurator),
|
|
141
|
+
marketConfigurator: lc(cs.marketConfigurator.address),
|
|
142
142
|
supportedTokens,
|
|
143
143
|
forbiddenTokens,
|
|
144
144
|
name: cs.name,
|