@gearbox-protocol/sdk 4.2.0-next.3 → 5.0.0-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/bots/BotsPlugin.js +2 -2
- 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/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/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 +3 -2
- package/dist/cjs/sdk/market/oracle/createPriceOracle.js +3 -2
- 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/PriceFeedsRegister.js +2 -2
- 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/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/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/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 +7 -3
- package/dist/esm/sdk/market/oracle/createPriceOracle.js +3 -2
- 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/PriceFeedsRegister.js +4 -3
- 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/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
|
@@ -58,9 +58,9 @@ class BotsPlugin extends import_sdk.SDKConstruct {
|
|
|
58
58
|
}
|
|
59
59
|
async #load() {
|
|
60
60
|
this.#botsByMarket.clear();
|
|
61
|
-
const pcAddr = this.sdk.addressProvider.
|
|
61
|
+
const [pcAddr] = this.sdk.addressProvider.mustGetLatest(
|
|
62
62
|
import_sdk.AP_PERIPHERY_COMPRESSOR,
|
|
63
|
-
|
|
63
|
+
import_sdk.VERSION_RANGE_310
|
|
64
64
|
);
|
|
65
65
|
this.#logger?.debug(`loading bots with periphery compressor ${pcAddr}`);
|
|
66
66
|
const mcs = this.sdk.marketRegister.marketConfigurators.map(
|
package/dist/cjs/dev/index.js
CHANGED
|
@@ -23,7 +23,6 @@ __reExport(dev_exports, require("./createTransport.js"), module.exports);
|
|
|
23
23
|
__reExport(dev_exports, require("./detectChain.js"), module.exports);
|
|
24
24
|
__reExport(dev_exports, require("./ltUtils.js"), module.exports);
|
|
25
25
|
__reExport(dev_exports, require("./migrateFaucet.js"), module.exports);
|
|
26
|
-
__reExport(dev_exports, require("./PriceFeedStore.js"), module.exports);
|
|
27
26
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
27
|
0 && (module.exports = {
|
|
29
28
|
...require("./AccountOpener.js"),
|
|
@@ -33,6 +32,5 @@ __reExport(dev_exports, require("./PriceFeedStore.js"), module.exports);
|
|
|
33
32
|
...require("./createTransport.js"),
|
|
34
33
|
...require("./detectChain.js"),
|
|
35
34
|
...require("./ltUtils.js"),
|
|
36
|
-
...require("./migrateFaucet.js")
|
|
37
|
-
...require("./PriceFeedStore.js")
|
|
35
|
+
...require("./migrateFaucet.js")
|
|
38
36
|
});
|
package/dist/cjs/dev/ltUtils.js
CHANGED
|
@@ -45,9 +45,9 @@ async function setLTs(anvil, cm, newLTs, logger) {
|
|
|
45
45
|
}
|
|
46
46
|
async function setLTZero(anvil, cm, logger) {
|
|
47
47
|
const v = Number(cm.creditConfigurator.baseParams.version);
|
|
48
|
-
if (
|
|
48
|
+
if ((0, import_sdk.isV300)(v)) {
|
|
49
49
|
await setLTZeroV300(anvil, cm, logger);
|
|
50
|
-
} else if (
|
|
50
|
+
} else if ((0, import_sdk.isV310)(v)) {
|
|
51
51
|
await setLTZeroV310(anvil, cm, logger);
|
|
52
52
|
} else {
|
|
53
53
|
throw new Error(
|
|
@@ -485,11 +485,8 @@ class GearboxSDK {
|
|
|
485
485
|
facadeAddr = cm.creditFacade.address;
|
|
486
486
|
}
|
|
487
487
|
const facadeV = this.contracts.mustGet(facadeAddr).version;
|
|
488
|
-
const routerRange = facadeV
|
|
489
|
-
const routerEntry = this.addressProvider.
|
|
490
|
-
import_constants.AP_ROUTER,
|
|
491
|
-
routerRange
|
|
492
|
-
);
|
|
488
|
+
const routerRange = (0, import_constants.isV310)(facadeV) ? import_constants.VERSION_RANGE_310 : import_constants.VERSION_RANGE_300;
|
|
489
|
+
const routerEntry = this.addressProvider.getLatest(import_constants.AP_ROUTER, routerRange);
|
|
493
490
|
if (!routerEntry) {
|
|
494
491
|
throw new Error(
|
|
495
492
|
`router not found for facade v ${facadeV} at ${facadeAddr}`
|
|
@@ -39,8 +39,9 @@ class CreditAccountsService extends import_base.SDKConstruct {
|
|
|
39
39
|
#logger;
|
|
40
40
|
constructor(sdk, options) {
|
|
41
41
|
super(sdk);
|
|
42
|
-
[this.#compressor] = sdk.addressProvider.
|
|
43
|
-
import_constants.AP_CREDIT_ACCOUNT_COMPRESSOR
|
|
42
|
+
[this.#compressor] = sdk.addressProvider.mustGetLatest(
|
|
43
|
+
import_constants.AP_CREDIT_ACCOUNT_COMPRESSOR,
|
|
44
|
+
import_constants.VERSION_RANGE_310
|
|
44
45
|
);
|
|
45
46
|
this.#batchSize = options?.batchSize;
|
|
46
47
|
this.#logger = (0, import_utils.childLogger)("CreditAccountsService", sdk.logger);
|
|
@@ -1176,11 +1177,15 @@ class CreditAccountsService extends import_base.SDKConstruct {
|
|
|
1176
1177
|
return this.sdk.marketRegister.marketConfigurators.map((mc) => mc.address);
|
|
1177
1178
|
}
|
|
1178
1179
|
get rewardCompressor() {
|
|
1179
|
-
return this.sdk.addressProvider.
|
|
1180
|
+
return this.sdk.addressProvider.mustGetLatest(
|
|
1181
|
+
import_constants.AP_REWARDS_COMPRESSOR,
|
|
1182
|
+
import_constants.VERSION_RANGE_310
|
|
1183
|
+
)[0];
|
|
1180
1184
|
}
|
|
1181
1185
|
get peripheryCompressor() {
|
|
1182
|
-
return this.sdk.addressProvider.
|
|
1183
|
-
import_constants.AP_PERIPHERY_COMPRESSOR
|
|
1186
|
+
return this.sdk.addressProvider.mustGetLatest(
|
|
1187
|
+
import_constants.AP_PERIPHERY_COMPRESSOR,
|
|
1188
|
+
import_constants.VERSION_RANGE_310
|
|
1184
1189
|
)[0];
|
|
1185
1190
|
}
|
|
1186
1191
|
}
|
|
@@ -21,6 +21,7 @@ __reExport(constants_exports, require("./bot-permissions.js"), module.exports);
|
|
|
21
21
|
__reExport(constants_exports, require("./math.js"), module.exports);
|
|
22
22
|
__reExport(constants_exports, require("./networks.js"), module.exports);
|
|
23
23
|
__reExport(constants_exports, require("./periphery.js"), module.exports);
|
|
24
|
+
__reExport(constants_exports, require("./versions.js"), module.exports);
|
|
24
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
25
26
|
0 && (module.exports = {
|
|
26
27
|
...require("./address-provider.js"),
|
|
@@ -28,5 +29,6 @@ __reExport(constants_exports, require("./periphery.js"), module.exports);
|
|
|
28
29
|
...require("./bot-permissions.js"),
|
|
29
30
|
...require("./math.js"),
|
|
30
31
|
...require("./networks.js"),
|
|
31
|
-
...require("./periphery.js")
|
|
32
|
+
...require("./periphery.js"),
|
|
33
|
+
...require("./versions.js")
|
|
32
34
|
});
|
|
@@ -16,20 +16,31 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var versions_exports = {};
|
|
20
|
+
__export(versions_exports, {
|
|
21
|
+
VERSION_RANGE_300: () => VERSION_RANGE_300,
|
|
22
|
+
VERSION_RANGE_310: () => VERSION_RANGE_310,
|
|
21
23
|
isV300: () => isV300,
|
|
22
|
-
isV310: () => isV310
|
|
24
|
+
isV310: () => isV310,
|
|
25
|
+
isVersionRange: () => isVersionRange
|
|
23
26
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
27
|
+
module.exports = __toCommonJS(versions_exports);
|
|
28
|
+
const VERSION_RANGE_300 = [300, 309];
|
|
29
|
+
const VERSION_RANGE_310 = [310, 319];
|
|
25
30
|
function isV300(version) {
|
|
26
|
-
return version
|
|
31
|
+
return isVersionRange(version, VERSION_RANGE_300);
|
|
27
32
|
}
|
|
28
33
|
function isV310(version) {
|
|
29
|
-
return version
|
|
34
|
+
return isVersionRange(version, VERSION_RANGE_310);
|
|
35
|
+
}
|
|
36
|
+
function isVersionRange(version, range) {
|
|
37
|
+
return Number(version) >= range[0] && Number(version) <= range[1];
|
|
30
38
|
}
|
|
31
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
40
|
0 && (module.exports = {
|
|
41
|
+
VERSION_RANGE_300,
|
|
42
|
+
VERSION_RANGE_310,
|
|
33
43
|
isV300,
|
|
34
|
-
isV310
|
|
44
|
+
isV310,
|
|
45
|
+
isVersionRange
|
|
35
46
|
});
|
|
@@ -27,7 +27,6 @@ var import_constants = require("../../constants/index.js");
|
|
|
27
27
|
var import_mappers = require("../../utils/mappers.js");
|
|
28
28
|
class AbstractAddressProviderContract extends import_base.BaseContract {
|
|
29
29
|
#addresses = {};
|
|
30
|
-
#latest = {};
|
|
31
30
|
constructor(sdk, args, addresses = {}) {
|
|
32
31
|
super(sdk, args);
|
|
33
32
|
this.#addresses = addresses;
|
|
@@ -38,9 +37,6 @@ class AbstractAddressProviderContract extends import_base.BaseContract {
|
|
|
38
37
|
this.#addresses[k] = {};
|
|
39
38
|
}
|
|
40
39
|
this.#addresses[k][version] = address;
|
|
41
|
-
if (!this.#latest[k] || version > this.#latest[k]) {
|
|
42
|
-
this.#latest[k] = version;
|
|
43
|
-
}
|
|
44
40
|
this.logger?.debug(`Set address for ${k}@${version} to ${address}`);
|
|
45
41
|
}
|
|
46
42
|
getAddress(contract, version = import_constants.NO_VERSION) {
|
|
@@ -53,14 +49,7 @@ class AbstractAddressProviderContract extends import_base.BaseContract {
|
|
|
53
49
|
}
|
|
54
50
|
return result;
|
|
55
51
|
}
|
|
56
|
-
|
|
57
|
-
const version = this.#latest[contract];
|
|
58
|
-
if (!version) {
|
|
59
|
-
throw new Error(`Latest version for ${contract} not found`);
|
|
60
|
-
}
|
|
61
|
-
return [this.getAddress(contract, version), version];
|
|
62
|
-
}
|
|
63
|
-
getLatestInRange(contract, range) {
|
|
52
|
+
getLatest(contract, range) {
|
|
64
53
|
const allVersions = this.#addresses[contract];
|
|
65
54
|
if (!allVersions) {
|
|
66
55
|
return void 0;
|
|
@@ -79,6 +68,13 @@ class AbstractAddressProviderContract extends import_base.BaseContract {
|
|
|
79
68
|
}
|
|
80
69
|
return [address, version];
|
|
81
70
|
}
|
|
71
|
+
mustGetLatest(contract, range) {
|
|
72
|
+
const result = this.getLatest(contract, range);
|
|
73
|
+
if (!result) {
|
|
74
|
+
throw new Error(`no address found for ${contract} in range ${range}`);
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
82
78
|
get state() {
|
|
83
79
|
return {
|
|
84
80
|
baseParams: {
|
|
@@ -23,7 +23,7 @@ __export(createAddressProvider_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(createAddressProvider_exports);
|
|
25
25
|
var import_iVersion = require("../../../abi/iVersion.js");
|
|
26
|
-
var
|
|
26
|
+
var import_constants = require("../../constants/index.js");
|
|
27
27
|
var import_AddressProviderV300Contract = require("./AddressProviderV300Contract.js");
|
|
28
28
|
var import_AddressProviderV310Contract = require("./AddressProviderV310Contract.js");
|
|
29
29
|
async function createAddressProvider(sdk, address) {
|
|
@@ -39,10 +39,10 @@ function hydrateAddressProvider(sdk, state) {
|
|
|
39
39
|
return newAddressProvider(sdk, addr, Number(version), state.addresses);
|
|
40
40
|
}
|
|
41
41
|
function newAddressProvider(sdk, address, version, addresses) {
|
|
42
|
-
if ((0,
|
|
42
|
+
if ((0, import_constants.isV300)(version)) {
|
|
43
43
|
return new import_AddressProviderV300Contract.AddressProviderV300Contract(sdk, address, version, addresses);
|
|
44
44
|
}
|
|
45
|
-
if ((0,
|
|
45
|
+
if ((0, import_constants.isV310)(version)) {
|
|
46
46
|
return new import_AddressProviderV310Contract.AddressProviderV310Contract(sdk, address, version, addresses);
|
|
47
47
|
}
|
|
48
48
|
throw new Error(`unsupported address provider version: ${version}`);
|
|
@@ -28,7 +28,10 @@ class GaugeStakingService extends import_base.SDKConstruct {
|
|
|
28
28
|
#compressor;
|
|
29
29
|
constructor(sdk) {
|
|
30
30
|
super(sdk);
|
|
31
|
-
[this.#compressor] = this.sdk.addressProvider.
|
|
31
|
+
[this.#compressor] = this.sdk.addressProvider.mustGetLatest(
|
|
32
|
+
import_constants.AP_GAUGE_COMPRESSOR,
|
|
33
|
+
import_constants.VERSION_RANGE_310
|
|
34
|
+
);
|
|
32
35
|
}
|
|
33
36
|
/**
|
|
34
37
|
* Returns voting state for wallet
|
|
@@ -85,9 +85,9 @@ class MarketRegister extends import_base.SDKConstruct {
|
|
|
85
85
|
pools,
|
|
86
86
|
underlying: import_constants.ADDRESS_0X0
|
|
87
87
|
};
|
|
88
|
-
const marketCompressorAddress = this.sdk.addressProvider.
|
|
88
|
+
const [marketCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
|
|
89
89
|
import_constants.AP_MARKET_COMPRESSOR,
|
|
90
|
-
|
|
90
|
+
import_constants.VERSION_RANGE_310
|
|
91
91
|
);
|
|
92
92
|
let txs = [];
|
|
93
93
|
if (!ignoreUpdateablePrices) {
|
|
@@ -21,13 +21,14 @@ __export(createCreditConfigurator_exports, {
|
|
|
21
21
|
default: () => createCreditConfigurator
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(createCreditConfigurator_exports);
|
|
24
|
+
var import_constants = require("../../constants/index.js");
|
|
24
25
|
var import_CreditConfiguratorV300Contract = require("./CreditConfiguratorV300Contract.js");
|
|
25
26
|
var import_CreditConfiguratorV310Contract = require("./CreditConfiguratorV310Contract.js");
|
|
26
27
|
function createCreditConfigurator(sdk, data) {
|
|
27
28
|
const v = data.creditConfigurator.baseParams.version;
|
|
28
|
-
if (
|
|
29
|
+
if ((0, import_constants.isV300)(v)) {
|
|
29
30
|
return new import_CreditConfiguratorV300Contract.CreditConfiguratorV300Contract(sdk, data);
|
|
30
|
-
} else if (
|
|
31
|
+
} else if ((0, import_constants.isV310)(v)) {
|
|
31
32
|
return new import_CreditConfiguratorV310Contract.CreditConfiguratorV310Contract(sdk, data);
|
|
32
33
|
}
|
|
33
34
|
throw new Error(`Unsupported credit configurator version: ${v}`);
|
|
@@ -21,13 +21,14 @@ __export(createCreditFacade_exports, {
|
|
|
21
21
|
default: () => createCreditFacade
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(createCreditFacade_exports);
|
|
24
|
+
var import_constants = require("../../constants/index.js");
|
|
24
25
|
var import_CreditFacadeV300Contract = require("./CreditFacadeV300Contract.js");
|
|
25
26
|
var import_CreditFacadeV310Contract = require("./CreditFacadeV310Contract.js");
|
|
26
27
|
function createCreditFacade(sdk, data) {
|
|
27
28
|
const v = data.creditFacade.baseParams.version;
|
|
28
|
-
if (
|
|
29
|
+
if ((0, import_constants.isV300)(v)) {
|
|
29
30
|
return new import_CreditFacadeV300Contract.CreditFacadeV300Contract(sdk, data);
|
|
30
|
-
} else if (
|
|
31
|
+
} else if ((0, import_constants.isV310)(v)) {
|
|
31
32
|
return new import_CreditFacadeV310Contract.CreditFacadeV310Contract(sdk, data);
|
|
32
33
|
}
|
|
33
34
|
throw new Error(`Unsupported credit facade version: ${v}`);
|
|
@@ -21,13 +21,14 @@ __export(createCreditManager_exports, {
|
|
|
21
21
|
default: () => createCreditManager
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(createCreditManager_exports);
|
|
24
|
+
var import_constants = require("../../constants/index.js");
|
|
24
25
|
var import_CreditManagerV300Contract = require("./CreditManagerV300Contract.js");
|
|
25
26
|
var import_CreditManagerV310Contract = require("./CreditManagerV310Contract.js");
|
|
26
27
|
function createCreditManager(sdk, data) {
|
|
27
28
|
const v = data.creditManager.baseParams.version;
|
|
28
|
-
if (
|
|
29
|
+
if ((0, import_constants.isV300)(v)) {
|
|
29
30
|
return new import_CreditManagerV300Contract.CreditManagerV300Contract(sdk, data);
|
|
30
|
-
} else if (
|
|
31
|
+
} else if ((0, import_constants.isV310)(v)) {
|
|
31
32
|
return new import_CreditManagerV310Contract.CreditManagerV310Contract(sdk, data);
|
|
32
33
|
}
|
|
33
34
|
throw new Error(`Unsupported credit manager version: ${v}`);
|
|
@@ -242,8 +242,9 @@ class PriceOracleBaseContract extends import_base.BaseContract {
|
|
|
242
242
|
)
|
|
243
243
|
);
|
|
244
244
|
}
|
|
245
|
-
const [address] = this.sdk.addressProvider.
|
|
246
|
-
import_constants.AP_PRICE_FEED_COMPRESSOR
|
|
245
|
+
const [address] = this.sdk.addressProvider.mustGetLatest(
|
|
246
|
+
import_constants.AP_PRICE_FEED_COMPRESSOR,
|
|
247
|
+
import_constants.VERSION_RANGE_310
|
|
247
248
|
);
|
|
248
249
|
return {
|
|
249
250
|
call: {
|
|
@@ -21,14 +21,15 @@ __export(createPriceOracle_exports, {
|
|
|
21
21
|
createPriceOracle: () => createPriceOracle
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(createPriceOracle_exports);
|
|
24
|
+
var import_constants = require("../../constants/index.js");
|
|
24
25
|
var import_PriceOracleV300Contract = require("./PriceOracleV300Contract.js");
|
|
25
26
|
var import_PriceOracleV310Contract = require("./PriceOracleV310Contract.js");
|
|
26
27
|
function createPriceOracle(sdk, data, underlying) {
|
|
27
28
|
const v = data.baseParams.version;
|
|
28
|
-
if (
|
|
29
|
+
if ((0, import_constants.isV300)(v)) {
|
|
29
30
|
return new import_PriceOracleV300Contract.PriceOracleV300Contract(sdk, data, underlying);
|
|
30
31
|
}
|
|
31
|
-
if (
|
|
32
|
+
if ((0, import_constants.isV310)(v)) {
|
|
32
33
|
return new import_PriceOracleV310Contract.PriceOracleV310Contract(sdk, data, underlying);
|
|
33
34
|
}
|
|
34
35
|
throw new Error(`Unsupported oracle version ${v}`);
|
|
@@ -21,14 +21,15 @@ __export(createPool_exports, {
|
|
|
21
21
|
default: () => createPool
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(createPool_exports);
|
|
24
|
+
var import_constants = require("../../constants/index.js");
|
|
24
25
|
var import_PoolV300Contract = require("./PoolV300Contract.js");
|
|
25
26
|
var import_PoolV310Contract = require("./PoolV310Contract.js");
|
|
26
27
|
function createPool(sdk, data) {
|
|
27
28
|
const v = data.baseParams.version;
|
|
28
|
-
if (
|
|
29
|
+
if ((0, import_constants.isV300)(v)) {
|
|
29
30
|
return new import_PoolV300Contract.PoolV300Contract(sdk, data);
|
|
30
31
|
}
|
|
31
|
-
if (
|
|
32
|
+
if ((0, import_constants.isV310)(v)) {
|
|
32
33
|
return new import_PoolV310Contract.PoolV310Contract(sdk, data);
|
|
33
34
|
}
|
|
34
35
|
throw new Error(`Unsupported pool version ${v}`);
|
|
@@ -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}`);
|
|
@@ -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(
|
|
@@ -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(
|
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,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}`);
|
|
@@ -3,7 +3,10 @@ import { decodeFunctionData, stringToHex } from "viem";
|
|
|
3
3
|
import { iPriceFeedCompressorAbi } from "../../../abi/compressors.js";
|
|
4
4
|
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
5
5
|
import { BaseContract } from "../../base/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
AP_PRICE_FEED_COMPRESSOR,
|
|
8
|
+
VERSION_RANGE_310
|
|
9
|
+
} from "../../constants/index.js";
|
|
7
10
|
import { AddressMap, formatBN } from "../../utils/index.js";
|
|
8
11
|
import { PriceFeedRef } from "../pricefeeds/index.js";
|
|
9
12
|
import PriceFeedAnswerMap from "./PriceFeedAnswerMap.js";
|
|
@@ -209,8 +212,9 @@ class PriceOracleBaseContract extends BaseContract {
|
|
|
209
212
|
)
|
|
210
213
|
);
|
|
211
214
|
}
|
|
212
|
-
const [address] = this.sdk.addressProvider.
|
|
213
|
-
AP_PRICE_FEED_COMPRESSOR
|
|
215
|
+
const [address] = this.sdk.addressProvider.mustGetLatest(
|
|
216
|
+
AP_PRICE_FEED_COMPRESSOR,
|
|
217
|
+
VERSION_RANGE_310
|
|
214
218
|
);
|
|
215
219
|
return {
|
|
216
220
|
call: {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { isV300, isV310 } from "../../constants/index.js";
|
|
1
2
|
import { PriceOracleV300Contract } from "./PriceOracleV300Contract.js";
|
|
2
3
|
import { PriceOracleV310Contract } from "./PriceOracleV310Contract.js";
|
|
3
4
|
function createPriceOracle(sdk, data, underlying) {
|
|
4
5
|
const v = data.baseParams.version;
|
|
5
|
-
if (v
|
|
6
|
+
if (isV300(v)) {
|
|
6
7
|
return new PriceOracleV300Contract(sdk, data, underlying);
|
|
7
8
|
}
|
|
8
|
-
if (v
|
|
9
|
+
if (isV310(v)) {
|
|
9
10
|
return new PriceOracleV310Contract(sdk, data, underlying);
|
|
10
11
|
}
|
|
11
12
|
throw new Error(`Unsupported oracle version ${v}`);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { isV300, isV310 } from "../../constants/index.js";
|
|
1
2
|
import { PoolV300Contract } from "./PoolV300Contract.js";
|
|
2
3
|
import { PoolV310Contract } from "./PoolV310Contract.js";
|
|
3
4
|
function createPool(sdk, data) {
|
|
4
5
|
const v = data.baseParams.version;
|
|
5
|
-
if (v
|
|
6
|
+
if (isV300(v)) {
|
|
6
7
|
return new PoolV300Contract(sdk, data);
|
|
7
8
|
}
|
|
8
|
-
if (v
|
|
9
|
+
if (isV310(v)) {
|
|
9
10
|
return new PoolV310Contract(sdk, data);
|
|
10
11
|
}
|
|
11
12
|
throw new Error(`Unsupported pool version ${v}`);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { isV300, isV310 } from "../../constants/index.js";
|
|
1
2
|
import { PoolQuotaKeeperV300Contract } from "./PoolQuotaKeeperV300Contract.js";
|
|
2
3
|
import { PoolQuotaKeeperV310Contract } from "./PoolQuotaKeeperV310Contract.js";
|
|
3
4
|
function createPoolQuotaKeeper(sdk, pool, pqk) {
|
|
4
5
|
const v = pqk.baseParams.version;
|
|
5
|
-
if (v
|
|
6
|
+
if (isV300(v)) {
|
|
6
7
|
return new PoolQuotaKeeperV300Contract(sdk, pool, pqk);
|
|
7
8
|
}
|
|
8
|
-
if (v
|
|
9
|
+
if (isV310(v)) {
|
|
9
10
|
return new PoolQuotaKeeperV310Contract(sdk, pool, pqk);
|
|
10
11
|
}
|
|
11
12
|
throw new Error(`Unsupported pool quota keeper version ${v}`);
|
|
@@ -2,7 +2,8 @@ import { iPriceFeedCompressorAbi } from "../../../abi/compressors.js";
|
|
|
2
2
|
import { SDKConstruct } from "../../base/index.js";
|
|
3
3
|
import {
|
|
4
4
|
ADDRESS_0X0,
|
|
5
|
-
AP_PRICE_FEED_COMPRESSOR
|
|
5
|
+
AP_PRICE_FEED_COMPRESSOR,
|
|
6
|
+
VERSION_RANGE_310
|
|
6
7
|
} from "../../constants/index.js";
|
|
7
8
|
import { AddressMap, bytes32ToString, childLogger } from "../../utils/index.js";
|
|
8
9
|
import { Hooks } from "../../utils/internal/index.js";
|
|
@@ -109,9 +110,9 @@ class PriceFeedRegister extends SDKConstruct {
|
|
|
109
110
|
* This is not saved anywhere in PriceFeedRegister, and can later be used to load price feed updates
|
|
110
111
|
*/
|
|
111
112
|
async getPartialUpdatablePriceFeeds(marketConfigurators, pools) {
|
|
112
|
-
const priceFeedCompressorAddress = this.sdk.addressProvider.
|
|
113
|
+
const [priceFeedCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
|
|
113
114
|
AP_PRICE_FEED_COMPRESSOR,
|
|
114
|
-
|
|
115
|
+
VERSION_RANGE_310
|
|
115
116
|
);
|
|
116
117
|
const configurators = marketConfigurators ?? this.sdk.marketRegister.marketConfigurators.map((mc) => mc.address);
|
|
117
118
|
this.logger?.debug(
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { isV300, isV310 } from "../constants/index.js";
|
|
1
2
|
import { RouterV300Contract } from "./RouterV300Contract.js";
|
|
2
3
|
import { RouterV310Contract } from "./RouterV310Contract.js";
|
|
3
4
|
function createRouter(sdk, address, version) {
|
|
4
|
-
if (version
|
|
5
|
+
if (isV300(version)) {
|
|
5
6
|
return new RouterV300Contract(sdk, address, version);
|
|
6
7
|
}
|
|
7
|
-
if (version
|
|
8
|
+
if (isV310(version)) {
|
|
8
9
|
return new RouterV310Contract(sdk, address, version);
|
|
9
10
|
}
|
|
10
11
|
throw new Error(`Unsupported router version ${version}`);
|
|
@@ -2,7 +2,8 @@ import { iPeripheryCompressorAbi } from "../abi/compressors.js";
|
|
|
2
2
|
import {
|
|
3
3
|
AddressMap,
|
|
4
4
|
AP_PERIPHERY_COMPRESSOR,
|
|
5
|
-
SDKConstruct
|
|
5
|
+
SDKConstruct,
|
|
6
|
+
VERSION_RANGE_310
|
|
6
7
|
} from "../sdk/index.js";
|
|
7
8
|
class ZappersPlugin extends SDKConstruct {
|
|
8
9
|
#zappers;
|
|
@@ -12,9 +13,9 @@ class ZappersPlugin extends SDKConstruct {
|
|
|
12
13
|
}
|
|
13
14
|
async loadZappers() {
|
|
14
15
|
this.#zappers = new AddressMap(void 0, "zappers");
|
|
15
|
-
const pcAddr = this.sdk.addressProvider.
|
|
16
|
+
const [pcAddr] = this.sdk.addressProvider.mustGetLatest(
|
|
16
17
|
AP_PERIPHERY_COMPRESSOR,
|
|
17
|
-
|
|
18
|
+
VERSION_RANGE_310
|
|
18
19
|
);
|
|
19
20
|
this.sdk.logger?.debug(
|
|
20
21
|
`loading zappers with periphery compressor ${pcAddr}`
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version range, inclusive of both ends
|
|
3
|
+
*/
|
|
4
|
+
export type VersionRange = [number, number];
|
|
5
|
+
export declare const VERSION_RANGE_300: VersionRange;
|
|
6
|
+
export declare const VERSION_RANGE_310: VersionRange;
|
|
7
|
+
export declare function isV300(version: number | bigint | string): boolean;
|
|
8
|
+
export declare function isV310(version: number | bigint | string): boolean;
|
|
9
|
+
export declare function isVersionRange(version: number | bigint | string, range: VersionRange): boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Abi, type Address } from "viem";
|
|
2
2
|
import type { BaseContractOptions } from "../../base/BaseContract.js";
|
|
3
3
|
import { BaseContract } from "../../base/index.js";
|
|
4
|
+
import type { VersionRange } from "../../constants/index.js";
|
|
4
5
|
import type { GearboxSDK } from "../../GearboxSDK.js";
|
|
5
6
|
import type { AddressProviderV3StateHuman } from "../../types/index.js";
|
|
6
7
|
import type { AddressProviderState } from "./types.js";
|
|
@@ -9,8 +10,8 @@ export default abstract class AbstractAddressProviderContract<abi extends Abi |
|
|
|
9
10
|
constructor(sdk: GearboxSDK, args: BaseContractOptions<abi>, addresses?: Record<string, Record<number, Address>>);
|
|
10
11
|
protected setInternalAddress(key: string, address: Address, version: number): void;
|
|
11
12
|
getAddress(contract: string, version?: number): Address;
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
getLatest(contract: string, range: VersionRange): [address: Address, version: number] | undefined;
|
|
14
|
+
mustGetLatest(contract: string, range: VersionRange): [address: Address, version: number];
|
|
14
15
|
get state(): AddressProviderState;
|
|
15
16
|
stateHuman(raw?: boolean): AddressProviderV3StateHuman;
|
|
16
17
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import type { BaseParams, IBaseContract } from "../../base/index.js";
|
|
3
|
+
import type { VersionRange } from "../../constants/versions.js";
|
|
3
4
|
import type { AddressProviderV3StateHuman } from "../../types/index.js";
|
|
4
5
|
export interface AddressProviderState {
|
|
5
6
|
baseParams: BaseParams;
|
|
@@ -8,8 +9,8 @@ export interface AddressProviderState {
|
|
|
8
9
|
export interface IAddressProviderContract extends IBaseContract {
|
|
9
10
|
state: AddressProviderState;
|
|
10
11
|
getAddress: (contract: string, version?: number) => Address;
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
getLatest: (contract: string, range: VersionRange) => [address: Address, version: number] | undefined;
|
|
13
|
+
mustGetLatest: (contract: string, range: VersionRange) => [address: Address, version: number];
|
|
13
14
|
syncState: (blockNumber: bigint) => Promise<void>;
|
|
14
15
|
stateHuman: (raw?: boolean) => AddressProviderV3StateHuman;
|
|
15
16
|
}
|
package/package.json
CHANGED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var PriceFeedStore_exports = {};
|
|
20
|
-
__export(PriceFeedStore_exports, {
|
|
21
|
-
PriceFeedStore: () => PriceFeedStore
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(PriceFeedStore_exports);
|
|
24
|
-
var import_compressors = require("../abi/compressors.js");
|
|
25
|
-
var import_iPriceFeedStore = require("../abi/iPriceFeedStore.js");
|
|
26
|
-
var import_sdk = require("../sdk/index.js");
|
|
27
|
-
class PriceFeedStore extends import_sdk.SDKConstruct {
|
|
28
|
-
#store;
|
|
29
|
-
#compressor;
|
|
30
|
-
#logger;
|
|
31
|
-
constructor(sdk) {
|
|
32
|
-
super(sdk);
|
|
33
|
-
this.#store = this.sdk.addressProvider.getAddress("PRICE_FEED_STORE");
|
|
34
|
-
[this.#compressor] = this.sdk.addressProvider.getLatestVersion(
|
|
35
|
-
import_sdk.AP_PRICE_FEED_COMPRESSOR
|
|
36
|
-
);
|
|
37
|
-
this.#logger = sdk.logger?.child?.({
|
|
38
|
-
module: "PriceFeedStore"
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
async load(update = true) {
|
|
42
|
-
const pfMap = await this.provider.publicClient.readContract({
|
|
43
|
-
address: this.#store,
|
|
44
|
-
abi: import_iPriceFeedStore.iPriceFeedStoreAbi,
|
|
45
|
-
functionName: "getTokenPriceFeedsMap"
|
|
46
|
-
});
|
|
47
|
-
const addresses = pfMap.flatMap((f) => f.priceFeeds);
|
|
48
|
-
const nodes = await this.#loadFromCompressor(addresses, update);
|
|
49
|
-
const result = new import_sdk.AddressMap();
|
|
50
|
-
for (const { token, priceFeeds } of pfMap) {
|
|
51
|
-
result.upsert(
|
|
52
|
-
token,
|
|
53
|
-
priceFeeds.map((pf) => nodes.find((n) => n.baseParams.addr === pf)).filter(Boolean)
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
return result;
|
|
57
|
-
}
|
|
58
|
-
async #loadFromCompressor(priceFeeds, update = true) {
|
|
59
|
-
let result = await this.provider.publicClient.readContract({
|
|
60
|
-
address: this.#compressor,
|
|
61
|
-
abi: import_compressors.iPriceFeedCompressorAbi,
|
|
62
|
-
functionName: "loadPriceFeedTree",
|
|
63
|
-
args: [priceFeeds]
|
|
64
|
-
});
|
|
65
|
-
if (update) {
|
|
66
|
-
const feeds = result.map((f) => this.sdk.priceFeeds.create(f));
|
|
67
|
-
const { txs } = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(feeds);
|
|
68
|
-
const [resp] = await (0, import_sdk.simulateWithPriceUpdates)(
|
|
69
|
-
this.provider.publicClient,
|
|
70
|
-
{
|
|
71
|
-
priceUpdates: txs,
|
|
72
|
-
contracts: [
|
|
73
|
-
{
|
|
74
|
-
address: this.#compressor,
|
|
75
|
-
abi: import_compressors.iPriceFeedCompressorAbi,
|
|
76
|
-
functionName: "loadPriceFeedTree",
|
|
77
|
-
args: [priceFeeds]
|
|
78
|
-
}
|
|
79
|
-
]
|
|
80
|
-
}
|
|
81
|
-
);
|
|
82
|
-
return resp;
|
|
83
|
-
}
|
|
84
|
-
this.#logger?.debug(
|
|
85
|
-
`loaded ${result.length} price feed nodes from compressor`
|
|
86
|
-
);
|
|
87
|
-
return [...result];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
-
0 && (module.exports = {
|
|
92
|
-
PriceFeedStore
|
|
93
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { iPriceFeedCompressorAbi } from "../abi/compressors.js";
|
|
2
|
-
import { iPriceFeedStoreAbi } from "../abi/iPriceFeedStore.js";
|
|
3
|
-
import {
|
|
4
|
-
AddressMap,
|
|
5
|
-
AP_PRICE_FEED_COMPRESSOR,
|
|
6
|
-
SDKConstruct,
|
|
7
|
-
simulateWithPriceUpdates
|
|
8
|
-
} from "../sdk/index.js";
|
|
9
|
-
class PriceFeedStore extends SDKConstruct {
|
|
10
|
-
#store;
|
|
11
|
-
#compressor;
|
|
12
|
-
#logger;
|
|
13
|
-
constructor(sdk) {
|
|
14
|
-
super(sdk);
|
|
15
|
-
this.#store = this.sdk.addressProvider.getAddress("PRICE_FEED_STORE");
|
|
16
|
-
[this.#compressor] = this.sdk.addressProvider.getLatestVersion(
|
|
17
|
-
AP_PRICE_FEED_COMPRESSOR
|
|
18
|
-
);
|
|
19
|
-
this.#logger = sdk.logger?.child?.({
|
|
20
|
-
module: "PriceFeedStore"
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
async load(update = true) {
|
|
24
|
-
const pfMap = await this.provider.publicClient.readContract({
|
|
25
|
-
address: this.#store,
|
|
26
|
-
abi: iPriceFeedStoreAbi,
|
|
27
|
-
functionName: "getTokenPriceFeedsMap"
|
|
28
|
-
});
|
|
29
|
-
const addresses = pfMap.flatMap((f) => f.priceFeeds);
|
|
30
|
-
const nodes = await this.#loadFromCompressor(addresses, update);
|
|
31
|
-
const result = new AddressMap();
|
|
32
|
-
for (const { token, priceFeeds } of pfMap) {
|
|
33
|
-
result.upsert(
|
|
34
|
-
token,
|
|
35
|
-
priceFeeds.map((pf) => nodes.find((n) => n.baseParams.addr === pf)).filter(Boolean)
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
async #loadFromCompressor(priceFeeds, update = true) {
|
|
41
|
-
let result = await this.provider.publicClient.readContract({
|
|
42
|
-
address: this.#compressor,
|
|
43
|
-
abi: iPriceFeedCompressorAbi,
|
|
44
|
-
functionName: "loadPriceFeedTree",
|
|
45
|
-
args: [priceFeeds]
|
|
46
|
-
});
|
|
47
|
-
if (update) {
|
|
48
|
-
const feeds = result.map((f) => this.sdk.priceFeeds.create(f));
|
|
49
|
-
const { txs } = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(feeds);
|
|
50
|
-
const [resp] = await simulateWithPriceUpdates(
|
|
51
|
-
this.provider.publicClient,
|
|
52
|
-
{
|
|
53
|
-
priceUpdates: txs,
|
|
54
|
-
contracts: [
|
|
55
|
-
{
|
|
56
|
-
address: this.#compressor,
|
|
57
|
-
abi: iPriceFeedCompressorAbi,
|
|
58
|
-
functionName: "loadPriceFeedTree",
|
|
59
|
-
args: [priceFeeds]
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
return resp;
|
|
65
|
-
}
|
|
66
|
-
this.#logger?.debug(
|
|
67
|
-
`loaded ${result.length} price feed nodes from compressor`
|
|
68
|
-
);
|
|
69
|
-
return [...result];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
export {
|
|
73
|
-
PriceFeedStore
|
|
74
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from "abitype";
|
|
2
|
-
import { iPriceFeedStoreAbi } from "../abi/iPriceFeedStore.js";
|
|
3
|
-
import type { GearboxSDK, PriceFeedTreeNode, Unarray } from "../sdk/index.js";
|
|
4
|
-
import { AddressMap, SDKConstruct } from "../sdk/index.js";
|
|
5
|
-
export type ConnectedPriceFeed = Unarray<AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof iPriceFeedStoreAbi, "getTokenPriceFeedsMap">["outputs"]>[0]>;
|
|
6
|
-
export declare class PriceFeedStore extends SDKConstruct {
|
|
7
|
-
#private;
|
|
8
|
-
constructor(sdk: GearboxSDK);
|
|
9
|
-
load(update?: boolean): Promise<AddressMap<PriceFeedTreeNode[]>>;
|
|
10
|
-
}
|