@gearbox-protocol/sdk 4.2.0-next.3 → 5.0.0-next.2
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/bots/BotsPlugin.js +2 -2
- package/dist/cjs/dev/calcLiquidatableLTs.js +5 -1
- package/dist/cjs/dev/index.js +1 -3
- package/dist/cjs/dev/ltUtils.js +2 -2
- package/dist/cjs/sdk/GearboxSDK.js +2 -5
- package/dist/cjs/sdk/accounts/CreditAccountsService.js +10 -5
- package/dist/cjs/sdk/base/BaseContract.js +0 -1
- package/dist/cjs/sdk/constants/index.js +3 -1
- package/dist/cjs/sdk/{utils/version.js → constants/versions.js} +18 -7
- package/dist/cjs/sdk/core/address-provider/AbstractAddressProviderContract.js +8 -12
- package/dist/cjs/sdk/core/address-provider/createAddressProvider.js +3 -3
- package/dist/cjs/sdk/gauges/GaugeStakingService.js +4 -1
- package/dist/cjs/sdk/market/MarketRegister.js +2 -2
- package/dist/cjs/sdk/market/MarketSuite.js +1 -5
- package/dist/cjs/sdk/market/credit/createCreditConfigurator.js +3 -2
- package/dist/cjs/sdk/market/credit/createCreditFacade.js +3 -2
- package/dist/cjs/sdk/market/credit/createCreditManager.js +3 -2
- package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +55 -49
- package/dist/cjs/sdk/market/oracle/PriceOracleV300Contract.js +2 -3
- package/dist/cjs/sdk/market/oracle/PriceOracleV310Contract.js +2 -3
- package/dist/cjs/sdk/market/oracle/createPriceOracle.js +29 -9
- package/dist/cjs/sdk/market/pool/createPool.js +3 -2
- package/dist/cjs/sdk/market/pool/createPoolQuotaKeeper.js +3 -2
- package/dist/cjs/sdk/market/pricefeeds/AbstractLPPriceFeed.js +2 -1
- package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +2 -2
- package/dist/cjs/sdk/market/pricefeeds/RedstonePriceFeed.js +1 -1
- package/dist/cjs/sdk/plugins/V300StalenessPeriodPlugin.js +5 -5
- package/dist/cjs/sdk/router/createRouter.js +3 -2
- package/dist/cjs/sdk/utils/index.js +1 -3
- package/dist/cjs/zappers/ZappersPlugin.js +2 -2
- package/dist/esm/bots/BotsPlugin.js +4 -3
- package/dist/esm/dev/calcLiquidatableLTs.js +5 -1
- package/dist/esm/dev/index.js +0 -1
- package/dist/esm/dev/ltUtils.js +9 -3
- package/dist/esm/sdk/GearboxSDK.js +6 -6
- package/dist/esm/sdk/accounts/CreditAccountsService.js +12 -6
- package/dist/esm/sdk/base/BaseContract.js +0 -1
- package/dist/esm/sdk/constants/index.js +1 -0
- package/dist/esm/sdk/constants/versions.js +18 -0
- package/dist/esm/sdk/core/address-provider/AbstractAddressProviderContract.js +8 -12
- package/dist/esm/sdk/core/address-provider/createAddressProvider.js +1 -1
- package/dist/esm/sdk/gauges/GaugeStakingService.js +5 -2
- package/dist/esm/sdk/market/MarketRegister.js +7 -3
- package/dist/esm/sdk/market/MarketSuite.js +2 -6
- package/dist/esm/sdk/market/credit/createCreditConfigurator.js +3 -2
- package/dist/esm/sdk/market/credit/createCreditFacade.js +3 -2
- package/dist/esm/sdk/market/credit/createCreditManager.js +3 -2
- package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +60 -50
- package/dist/esm/sdk/market/oracle/PriceOracleV300Contract.js +2 -3
- package/dist/esm/sdk/market/oracle/PriceOracleV310Contract.js +2 -3
- package/dist/esm/sdk/market/oracle/createPriceOracle.js +28 -8
- package/dist/esm/sdk/market/pool/createPool.js +3 -2
- package/dist/esm/sdk/market/pool/createPoolQuotaKeeper.js +3 -2
- package/dist/esm/sdk/market/pricefeeds/AbstractLPPriceFeed.js +2 -1
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +4 -3
- package/dist/esm/sdk/market/pricefeeds/RedstonePriceFeed.js +2 -2
- package/dist/esm/sdk/plugins/V300StalenessPeriodPlugin.js +6 -6
- package/dist/esm/sdk/router/createRouter.js +3 -2
- package/dist/esm/sdk/utils/index.js +0 -1
- package/dist/esm/zappers/ZappersPlugin.js +4 -3
- package/dist/types/dev/index.d.ts +0 -1
- package/dist/types/sdk/constants/index.d.ts +1 -0
- package/dist/types/sdk/constants/versions.d.ts +9 -0
- package/dist/types/sdk/core/address-provider/AbstractAddressProviderContract.d.ts +3 -2
- package/dist/types/sdk/core/address-provider/types.d.ts +3 -2
- package/dist/types/sdk/market/MarketSuite.d.ts +2 -2
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +28 -684
- package/dist/types/sdk/market/oracle/PriceOracleV300Contract.d.ts +1 -1
- package/dist/types/sdk/market/oracle/PriceOracleV310Contract.d.ts +2 -2
- package/dist/types/sdk/market/oracle/createPriceOracle.d.ts +14 -3
- package/dist/types/sdk/market/oracle/types.d.ts +97 -6
- package/dist/types/sdk/plugins/V300StalenessPeriodPlugin.d.ts +3 -2
- package/dist/types/sdk/utils/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/cjs/dev/PriceFeedStore.js +0 -93
- package/dist/esm/dev/PriceFeedStore.js +0 -74
- package/dist/esm/sdk/utils/version.js +0 -10
- package/dist/types/dev/PriceFeedStore.d.ts +0 -10
- package/dist/types/sdk/utils/version.d.ts +0 -2
|
@@ -21,14 +21,15 @@ __export(createPoolQuotaKeeper_exports, {
|
|
|
21
21
|
default: () => createPoolQuotaKeeper
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(createPoolQuotaKeeper_exports);
|
|
24
|
+
var import_constants = require("../../constants/index.js");
|
|
24
25
|
var import_PoolQuotaKeeperV300Contract = require("./PoolQuotaKeeperV300Contract.js");
|
|
25
26
|
var import_PoolQuotaKeeperV310Contract = require("./PoolQuotaKeeperV310Contract.js");
|
|
26
27
|
function createPoolQuotaKeeper(sdk, pool, pqk) {
|
|
27
28
|
const v = pqk.baseParams.version;
|
|
28
|
-
if (
|
|
29
|
+
if ((0, import_constants.isV300)(v)) {
|
|
29
30
|
return new import_PoolQuotaKeeperV300Contract.PoolQuotaKeeperV300Contract(sdk, pool, pqk);
|
|
30
31
|
}
|
|
31
|
-
if (
|
|
32
|
+
if ((0, import_constants.isV310)(v)) {
|
|
32
33
|
return new import_PoolQuotaKeeperV310Contract.PoolQuotaKeeperV310Contract(sdk, pool, pqk);
|
|
33
34
|
}
|
|
34
35
|
throw new Error(`Unsupported pool quota keeper version ${v}`);
|
|
@@ -22,6 +22,7 @@ __export(AbstractLPPriceFeed_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(AbstractLPPriceFeed_exports);
|
|
24
24
|
var import_viem = require("viem");
|
|
25
|
+
var import_versions = require("../../constants/versions.js");
|
|
25
26
|
var import_AbstractPriceFeed = require("./AbstractPriceFeed.js");
|
|
26
27
|
const LOWER_BOUND_FACTOR = 99n;
|
|
27
28
|
class AbstractLPPriceFeedContract extends import_AbstractPriceFeed.AbstractPriceFeedContract {
|
|
@@ -36,7 +37,7 @@ class AbstractLPPriceFeedContract extends import_AbstractPriceFeed.AbstractPrice
|
|
|
36
37
|
constructor(sdk, args) {
|
|
37
38
|
super(sdk, { ...args, decimals: 8 });
|
|
38
39
|
this.hasLowerBoundCap = true;
|
|
39
|
-
if (args.baseParams.version
|
|
40
|
+
if ((0, import_versions.isV310)(args.baseParams.version)) {
|
|
40
41
|
const decoder = (0, import_viem.decodeAbiParameters)(
|
|
41
42
|
[
|
|
42
43
|
{ type: "address", name: "lpToken" },
|
|
@@ -127,9 +127,9 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
127
127
|
* This is not saved anywhere in PriceFeedRegister, and can later be used to load price feed updates
|
|
128
128
|
*/
|
|
129
129
|
async getPartialUpdatablePriceFeeds(marketConfigurators, pools) {
|
|
130
|
-
const priceFeedCompressorAddress = this.sdk.addressProvider.
|
|
130
|
+
const [priceFeedCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
|
|
131
131
|
import_constants.AP_PRICE_FEED_COMPRESSOR,
|
|
132
|
-
|
|
132
|
+
import_constants.VERSION_RANGE_310
|
|
133
133
|
);
|
|
134
134
|
const configurators = marketConfigurators ?? this.sdk.marketRegister.marketConfigurators.map((mc) => mc.address);
|
|
135
135
|
this.logger?.debug(
|
|
@@ -40,7 +40,7 @@ class RedstonePriceFeedContract extends import_AbstractPriceFeed.AbstractPriceFe
|
|
|
40
40
|
name: `RedstonePriceFeed`,
|
|
41
41
|
abi: import_abi.redstonePriceFeedAbi
|
|
42
42
|
});
|
|
43
|
-
if (args.baseParams.version
|
|
43
|
+
if ((0, import_constants.isV310)(args.baseParams.version)) {
|
|
44
44
|
const decoder = (0, import_viem.decodeAbiParameters)(
|
|
45
45
|
[
|
|
46
46
|
{ type: "address", name: "token" },
|
|
@@ -39,12 +39,12 @@ class V300StalenessPeriodPlugin extends import_base.SDKConstruct {
|
|
|
39
39
|
this.#logger = sdk.logger?.child?.({ name: "V300StalenessPeriodPlugin" }) ?? sdk.logger;
|
|
40
40
|
}
|
|
41
41
|
async attach() {
|
|
42
|
-
await this.#
|
|
42
|
+
await this.#syncPriceFeeds();
|
|
43
43
|
}
|
|
44
44
|
async syncState() {
|
|
45
|
-
await this.#
|
|
45
|
+
await this.#syncPriceFeeds();
|
|
46
46
|
}
|
|
47
|
-
async #
|
|
47
|
+
async #syncPriceFeeds() {
|
|
48
48
|
const oracles = this.#getOraclesMap();
|
|
49
49
|
const [fromBlock, toBlock] = [this.#syncedTo + 1n, this.sdk.currentBlock];
|
|
50
50
|
if (oracles.size === 0 || fromBlock > toBlock) {
|
|
@@ -67,7 +67,7 @@ class V300StalenessPeriodPlugin extends import_base.SDKConstruct {
|
|
|
67
67
|
strict: true
|
|
68
68
|
});
|
|
69
69
|
this.#logger?.info(
|
|
70
|
-
`loaded ${events.length}
|
|
70
|
+
`loaded ${events.length} price feed events in range [${fromBlock}; ${toBlock}]`
|
|
71
71
|
);
|
|
72
72
|
for (const e of events) {
|
|
73
73
|
const oracle = oracles.mustGet(e.address);
|
|
@@ -120,7 +120,7 @@ class V300StalenessPeriodPlugin extends import_base.SDKConstruct {
|
|
|
120
120
|
}
|
|
121
121
|
#getOraclesMap() {
|
|
122
122
|
return new import_utils.AddressMap(
|
|
123
|
-
this.sdk.marketRegister.markets.filter((m) => m.priceOracle.version
|
|
123
|
+
this.sdk.marketRegister.markets.filter((m) => (0, import_constants.isV300)(m.priceOracle.version)).map((m) => [m.priceOracle.address, m.priceOracle])
|
|
124
124
|
);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -21,13 +21,14 @@ __export(createRouter_exports, {
|
|
|
21
21
|
createRouter: () => createRouter
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(createRouter_exports);
|
|
24
|
+
var import_constants = require("../constants/index.js");
|
|
24
25
|
var import_RouterV300Contract = require("./RouterV300Contract.js");
|
|
25
26
|
var import_RouterV310Contract = require("./RouterV310Contract.js");
|
|
26
27
|
function createRouter(sdk, address, version) {
|
|
27
|
-
if (
|
|
28
|
+
if ((0, import_constants.isV300)(version)) {
|
|
28
29
|
return new import_RouterV300Contract.RouterV300Contract(sdk, address, version);
|
|
29
30
|
}
|
|
30
|
-
if (
|
|
31
|
+
if ((0, import_constants.isV310)(version)) {
|
|
31
32
|
return new import_RouterV310Contract.RouterV310Contract(sdk, address, version);
|
|
32
33
|
}
|
|
33
34
|
throw new Error(`Unsupported router version ${version}`);
|
|
@@ -27,7 +27,6 @@ __reExport(utils_exports, require("./json.js"), module.exports);
|
|
|
27
27
|
__reExport(utils_exports, require("./mappers.js"), module.exports);
|
|
28
28
|
__reExport(utils_exports, require("./retry.js"), module.exports);
|
|
29
29
|
__reExport(utils_exports, require("./toAddress.js"), module.exports);
|
|
30
|
-
__reExport(utils_exports, require("./version.js"), module.exports);
|
|
31
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
31
|
0 && (module.exports = {
|
|
33
32
|
...require("./AddressMap.js"),
|
|
@@ -41,6 +40,5 @@ __reExport(utils_exports, require("./version.js"), module.exports);
|
|
|
41
40
|
...require("./json.js"),
|
|
42
41
|
...require("./mappers.js"),
|
|
43
42
|
...require("./retry.js"),
|
|
44
|
-
...require("./toAddress.js")
|
|
45
|
-
...require("./version.js")
|
|
43
|
+
...require("./toAddress.js")
|
|
46
44
|
});
|
|
@@ -31,9 +31,9 @@ class ZappersPlugin extends import_sdk.SDKConstruct {
|
|
|
31
31
|
}
|
|
32
32
|
async loadZappers() {
|
|
33
33
|
this.#zappers = new import_sdk.AddressMap(void 0, "zappers");
|
|
34
|
-
const pcAddr = this.sdk.addressProvider.
|
|
34
|
+
const [pcAddr] = this.sdk.addressProvider.mustGetLatest(
|
|
35
35
|
import_sdk.AP_PERIPHERY_COMPRESSOR,
|
|
36
|
-
|
|
36
|
+
import_sdk.VERSION_RANGE_310
|
|
37
37
|
);
|
|
38
38
|
this.sdk.logger?.debug(
|
|
39
39
|
`loading zappers with periphery compressor ${pcAddr}`
|
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
isV300,
|
|
6
6
|
isV310,
|
|
7
7
|
SDKConstruct,
|
|
8
|
-
TypedObjectUtils
|
|
8
|
+
TypedObjectUtils,
|
|
9
|
+
VERSION_RANGE_310
|
|
9
10
|
} from "../sdk/index.js";
|
|
10
11
|
import { PartialLiquidationBotV300Contract } from "./PartialLiquidationBotV300Contract.js";
|
|
11
12
|
import { PartialLiquidationBotV310Contract } from "./PartialLiquidationBotV310Contract.js";
|
|
@@ -43,9 +44,9 @@ class BotsPlugin extends SDKConstruct {
|
|
|
43
44
|
}
|
|
44
45
|
async #load() {
|
|
45
46
|
this.#botsByMarket.clear();
|
|
46
|
-
const pcAddr = this.sdk.addressProvider.
|
|
47
|
+
const [pcAddr] = this.sdk.addressProvider.mustGetLatest(
|
|
47
48
|
AP_PERIPHERY_COMPRESSOR,
|
|
48
|
-
|
|
49
|
+
VERSION_RANGE_310
|
|
49
50
|
);
|
|
50
51
|
this.#logger?.debug(`loading bots with periphery compressor ${pcAddr}`);
|
|
51
52
|
const mcs = this.sdk.marketRegister.marketConfigurators.map(
|
|
@@ -7,7 +7,11 @@ async function calcLiquidatableLTs(sdk, ca, factor = 9990n, logger) {
|
|
|
7
7
|
return balance > minBalance;
|
|
8
8
|
}).map((t) => {
|
|
9
9
|
const { token, balance } = t;
|
|
10
|
-
const balanceU = market.priceOracle.
|
|
10
|
+
const balanceU = market.priceOracle.convert(
|
|
11
|
+
token,
|
|
12
|
+
ca.underlying,
|
|
13
|
+
balance
|
|
14
|
+
);
|
|
11
15
|
const lt = BigInt(cm.creditManager.liquidationThresholds.mustGet(token));
|
|
12
16
|
return {
|
|
13
17
|
token,
|
package/dist/esm/dev/index.js
CHANGED
package/dist/esm/dev/ltUtils.js
CHANGED
|
@@ -3,7 +3,13 @@ import {
|
|
|
3
3
|
iCreditConfiguratorV300Abi,
|
|
4
4
|
iCreditManagerV300Abi
|
|
5
5
|
} from "../abi/v300.js";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
hexEq,
|
|
8
|
+
isV300,
|
|
9
|
+
isV310,
|
|
10
|
+
PERCENTAGE_FACTOR,
|
|
11
|
+
TypedObjectUtils
|
|
12
|
+
} from "../sdk/index.js";
|
|
7
13
|
import { iaclTraitAbi, iOwnableAbi } from "./abi.js";
|
|
8
14
|
async function setLTs(anvil, cm, newLTs, logger) {
|
|
9
15
|
const configuratorAddr = await impresonateCCOwner(anvil, cm);
|
|
@@ -24,9 +30,9 @@ async function setLTs(anvil, cm, newLTs, logger) {
|
|
|
24
30
|
}
|
|
25
31
|
async function setLTZero(anvil, cm, logger) {
|
|
26
32
|
const v = Number(cm.creditConfigurator.baseParams.version);
|
|
27
|
-
if (v
|
|
33
|
+
if (isV300(v)) {
|
|
28
34
|
await setLTZeroV300(anvil, cm, logger);
|
|
29
|
-
} else if (v
|
|
35
|
+
} else if (isV310(v)) {
|
|
30
36
|
await setLTZeroV310(anvil, cm, logger);
|
|
31
37
|
} else {
|
|
32
38
|
throw new Error(
|
|
@@ -12,7 +12,10 @@ import {
|
|
|
12
12
|
AP_GEAR_STAKING,
|
|
13
13
|
AP_GEAR_TOKEN,
|
|
14
14
|
AP_ROUTER,
|
|
15
|
-
|
|
15
|
+
isV310,
|
|
16
|
+
NO_VERSION,
|
|
17
|
+
VERSION_RANGE_300,
|
|
18
|
+
VERSION_RANGE_310
|
|
16
19
|
} from "./constants/index.js";
|
|
17
20
|
import {
|
|
18
21
|
BotListContract,
|
|
@@ -480,11 +483,8 @@ class GearboxSDK {
|
|
|
480
483
|
facadeAddr = cm.creditFacade.address;
|
|
481
484
|
}
|
|
482
485
|
const facadeV = this.contracts.mustGet(facadeAddr).version;
|
|
483
|
-
const routerRange = facadeV
|
|
484
|
-
const routerEntry = this.addressProvider.
|
|
485
|
-
AP_ROUTER,
|
|
486
|
-
routerRange
|
|
487
|
-
);
|
|
486
|
+
const routerRange = isV310(facadeV) ? VERSION_RANGE_310 : VERSION_RANGE_300;
|
|
487
|
+
const routerEntry = this.addressProvider.getLatest(AP_ROUTER, routerRange);
|
|
488
488
|
if (!routerEntry) {
|
|
489
489
|
throw new Error(
|
|
490
490
|
`router not found for facade v ${facadeV} at ${facadeAddr}`
|
|
@@ -18,7 +18,8 @@ import {
|
|
|
18
18
|
AP_REWARDS_COMPRESSOR,
|
|
19
19
|
MAX_UINT256,
|
|
20
20
|
MIN_INT96,
|
|
21
|
-
NOT_DEPLOYED
|
|
21
|
+
NOT_DEPLOYED,
|
|
22
|
+
VERSION_RANGE_310
|
|
22
23
|
} from "../constants/index.js";
|
|
23
24
|
import { assetsMap } from "../router/index.js";
|
|
24
25
|
import {
|
|
@@ -43,8 +44,9 @@ class CreditAccountsService extends SDKConstruct {
|
|
|
43
44
|
#logger;
|
|
44
45
|
constructor(sdk, options) {
|
|
45
46
|
super(sdk);
|
|
46
|
-
[this.#compressor] = sdk.addressProvider.
|
|
47
|
-
AP_CREDIT_ACCOUNT_COMPRESSOR
|
|
47
|
+
[this.#compressor] = sdk.addressProvider.mustGetLatest(
|
|
48
|
+
AP_CREDIT_ACCOUNT_COMPRESSOR,
|
|
49
|
+
VERSION_RANGE_310
|
|
48
50
|
);
|
|
49
51
|
this.#batchSize = options?.batchSize;
|
|
50
52
|
this.#logger = childLogger("CreditAccountsService", sdk.logger);
|
|
@@ -1180,11 +1182,15 @@ class CreditAccountsService extends SDKConstruct {
|
|
|
1180
1182
|
return this.sdk.marketRegister.marketConfigurators.map((mc) => mc.address);
|
|
1181
1183
|
}
|
|
1182
1184
|
get rewardCompressor() {
|
|
1183
|
-
return this.sdk.addressProvider.
|
|
1185
|
+
return this.sdk.addressProvider.mustGetLatest(
|
|
1186
|
+
AP_REWARDS_COMPRESSOR,
|
|
1187
|
+
VERSION_RANGE_310
|
|
1188
|
+
)[0];
|
|
1184
1189
|
}
|
|
1185
1190
|
get peripheryCompressor() {
|
|
1186
|
-
return this.sdk.addressProvider.
|
|
1187
|
-
AP_PERIPHERY_COMPRESSOR
|
|
1191
|
+
return this.sdk.addressProvider.mustGetLatest(
|
|
1192
|
+
AP_PERIPHERY_COMPRESSOR,
|
|
1193
|
+
VERSION_RANGE_310
|
|
1188
1194
|
)[0];
|
|
1189
1195
|
}
|
|
1190
1196
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const VERSION_RANGE_300 = [300, 309];
|
|
2
|
+
const VERSION_RANGE_310 = [310, 319];
|
|
3
|
+
function isV300(version) {
|
|
4
|
+
return isVersionRange(version, VERSION_RANGE_300);
|
|
5
|
+
}
|
|
6
|
+
function isV310(version) {
|
|
7
|
+
return isVersionRange(version, VERSION_RANGE_310);
|
|
8
|
+
}
|
|
9
|
+
function isVersionRange(version, range) {
|
|
10
|
+
return Number(version) >= range[0] && Number(version) <= range[1];
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
VERSION_RANGE_300,
|
|
14
|
+
VERSION_RANGE_310,
|
|
15
|
+
isV300,
|
|
16
|
+
isV310,
|
|
17
|
+
isVersionRange
|
|
18
|
+
};
|
|
@@ -4,7 +4,6 @@ import { NO_VERSION } from "../../constants/index.js";
|
|
|
4
4
|
import { TypedObjectUtils } from "../../utils/mappers.js";
|
|
5
5
|
class AbstractAddressProviderContract extends BaseContract {
|
|
6
6
|
#addresses = {};
|
|
7
|
-
#latest = {};
|
|
8
7
|
constructor(sdk, args, addresses = {}) {
|
|
9
8
|
super(sdk, args);
|
|
10
9
|
this.#addresses = addresses;
|
|
@@ -15,9 +14,6 @@ class AbstractAddressProviderContract extends BaseContract {
|
|
|
15
14
|
this.#addresses[k] = {};
|
|
16
15
|
}
|
|
17
16
|
this.#addresses[k][version] = address;
|
|
18
|
-
if (!this.#latest[k] || version > this.#latest[k]) {
|
|
19
|
-
this.#latest[k] = version;
|
|
20
|
-
}
|
|
21
17
|
this.logger?.debug(`Set address for ${k}@${version} to ${address}`);
|
|
22
18
|
}
|
|
23
19
|
getAddress(contract, version = NO_VERSION) {
|
|
@@ -30,14 +26,7 @@ class AbstractAddressProviderContract extends BaseContract {
|
|
|
30
26
|
}
|
|
31
27
|
return result;
|
|
32
28
|
}
|
|
33
|
-
|
|
34
|
-
const version = this.#latest[contract];
|
|
35
|
-
if (!version) {
|
|
36
|
-
throw new Error(`Latest version for ${contract} not found`);
|
|
37
|
-
}
|
|
38
|
-
return [this.getAddress(contract, version), version];
|
|
39
|
-
}
|
|
40
|
-
getLatestInRange(contract, range) {
|
|
29
|
+
getLatest(contract, range) {
|
|
41
30
|
const allVersions = this.#addresses[contract];
|
|
42
31
|
if (!allVersions) {
|
|
43
32
|
return void 0;
|
|
@@ -56,6 +45,13 @@ class AbstractAddressProviderContract extends BaseContract {
|
|
|
56
45
|
}
|
|
57
46
|
return [address, version];
|
|
58
47
|
}
|
|
48
|
+
mustGetLatest(contract, range) {
|
|
49
|
+
const result = this.getLatest(contract, range);
|
|
50
|
+
if (!result) {
|
|
51
|
+
throw new Error(`no address found for ${contract} in range ${range}`);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
59
55
|
get state() {
|
|
60
56
|
return {
|
|
61
57
|
baseParams: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { iVersionAbi } from "../../../abi/iVersion.js";
|
|
2
|
-
import { isV300, isV310 } from "../../
|
|
2
|
+
import { isV300, isV310 } from "../../constants/index.js";
|
|
3
3
|
import { AddressProviderV300Contract } from "./AddressProviderV300Contract.js";
|
|
4
4
|
import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
|
|
5
5
|
async function createAddressProvider(sdk, address) {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { iGaugeCompressorAbi } from "../../abi/compressors.js";
|
|
2
2
|
import { SDKConstruct } from "../base/index.js";
|
|
3
|
-
import { AP_GAUGE_COMPRESSOR } from "../constants/index.js";
|
|
3
|
+
import { AP_GAUGE_COMPRESSOR, VERSION_RANGE_310 } from "../constants/index.js";
|
|
4
4
|
class GaugeStakingService extends SDKConstruct {
|
|
5
5
|
#compressor;
|
|
6
6
|
constructor(sdk) {
|
|
7
7
|
super(sdk);
|
|
8
|
-
[this.#compressor] = this.sdk.addressProvider.
|
|
8
|
+
[this.#compressor] = this.sdk.addressProvider.mustGetLatest(
|
|
9
|
+
AP_GAUGE_COMPRESSOR,
|
|
10
|
+
VERSION_RANGE_310
|
|
11
|
+
);
|
|
9
12
|
}
|
|
10
13
|
/**
|
|
11
14
|
* Returns voting state for wallet
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { iMarketCompressorAbi } from "../../abi/compressors.js";
|
|
2
2
|
import { SDKConstruct } from "../base/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ADDRESS_0X0,
|
|
5
|
+
AP_MARKET_COMPRESSOR,
|
|
6
|
+
VERSION_RANGE_310
|
|
7
|
+
} from "../constants/index.js";
|
|
4
8
|
import { AddressMap, childLogger } from "../utils/index.js";
|
|
5
9
|
import { simulateWithPriceUpdates } from "../utils/viem/index.js";
|
|
6
10
|
import { MarketSuite } from "./MarketSuite.js";
|
|
@@ -62,9 +66,9 @@ class MarketRegister extends SDKConstruct {
|
|
|
62
66
|
pools,
|
|
63
67
|
underlying: ADDRESS_0X0
|
|
64
68
|
};
|
|
65
|
-
const marketCompressorAddress = this.sdk.addressProvider.
|
|
69
|
+
const [marketCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
|
|
66
70
|
AP_MARKET_COMPRESSOR,
|
|
67
|
-
|
|
71
|
+
VERSION_RANGE_310
|
|
68
72
|
);
|
|
69
73
|
let txs = [];
|
|
70
74
|
if (!ignoreUpdateablePrices) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SDKConstruct } from "../base/index.js";
|
|
2
2
|
import { CreditSuite } from "./credit/index.js";
|
|
3
3
|
import { MarketConfiguratorContract } from "./MarketConfiguratorContract.js";
|
|
4
|
-
import {
|
|
4
|
+
import { getOrCreatePriceOracle } from "./oracle/index.js";
|
|
5
5
|
import { PoolSuite } from "./pool/index.js";
|
|
6
6
|
class MarketSuite extends SDKConstruct {
|
|
7
7
|
acl;
|
|
@@ -35,11 +35,7 @@ class MarketSuite extends SDKConstruct {
|
|
|
35
35
|
for (let i = 0; i < marketData.creditManagers.length; i++) {
|
|
36
36
|
this.creditManagers.push(new CreditSuite(sdk, marketData, i));
|
|
37
37
|
}
|
|
38
|
-
this.priceOracle =
|
|
39
|
-
sdk,
|
|
40
|
-
marketData.priceOracle,
|
|
41
|
-
marketData.pool.underlying
|
|
42
|
-
);
|
|
38
|
+
this.priceOracle = getOrCreatePriceOracle(sdk, marketData.priceOracle);
|
|
43
39
|
}
|
|
44
40
|
get dirty() {
|
|
45
41
|
return this.configurator.dirty || this.pool.dirty || this.priceOracle.dirty || this.creditManagers.some((cm) => cm.dirty);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { isV300, isV310 } from "../../constants/index.js";
|
|
1
2
|
import { CreditConfiguratorV300Contract } from "./CreditConfiguratorV300Contract.js";
|
|
2
3
|
import { CreditConfiguratorV310Contract } from "./CreditConfiguratorV310Contract.js";
|
|
3
4
|
function createCreditConfigurator(sdk, data) {
|
|
4
5
|
const v = data.creditConfigurator.baseParams.version;
|
|
5
|
-
if (v
|
|
6
|
+
if (isV300(v)) {
|
|
6
7
|
return new CreditConfiguratorV300Contract(sdk, data);
|
|
7
|
-
} else if (v
|
|
8
|
+
} else if (isV310(v)) {
|
|
8
9
|
return new CreditConfiguratorV310Contract(sdk, data);
|
|
9
10
|
}
|
|
10
11
|
throw new Error(`Unsupported credit configurator version: ${v}`);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { isV300, isV310 } from "../../constants/index.js";
|
|
1
2
|
import { CreditFacadeV300Contract } from "./CreditFacadeV300Contract.js";
|
|
2
3
|
import { CreditFacadeV310Contract } from "./CreditFacadeV310Contract.js";
|
|
3
4
|
function createCreditFacade(sdk, data) {
|
|
4
5
|
const v = data.creditFacade.baseParams.version;
|
|
5
|
-
if (v
|
|
6
|
+
if (isV300(v)) {
|
|
6
7
|
return new CreditFacadeV300Contract(sdk, data);
|
|
7
|
-
} else if (v
|
|
8
|
+
} else if (isV310(v)) {
|
|
8
9
|
return new CreditFacadeV310Contract(sdk, data);
|
|
9
10
|
}
|
|
10
11
|
throw new Error(`Unsupported credit facade version: ${v}`);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { isV300, isV310 } from "../../constants/index.js";
|
|
1
2
|
import { CreditManagerV300Contract } from "./CreditManagerV300Contract.js";
|
|
2
3
|
import { CreditManagerV310Contract } from "./CreditManagerV310Contract.js";
|
|
3
4
|
function createCreditManager(sdk, data) {
|
|
4
5
|
const v = data.creditManager.baseParams.version;
|
|
5
|
-
if (v
|
|
6
|
+
if (isV300(v)) {
|
|
6
7
|
return new CreditManagerV300Contract(sdk, data);
|
|
7
|
-
} else if (v
|
|
8
|
+
} else if (isV310(v)) {
|
|
8
9
|
return new CreditManagerV310Contract(sdk, data);
|
|
9
10
|
}
|
|
10
11
|
throw new Error(`Unsupported credit manager version: ${v}`);
|