Skip to content

Commit

Permalink
chore: support batch
Browse files Browse the repository at this point in the history
Signed-off-by: GopherJ <[email protected]>
  • Loading branch information
0x8f701 committed Nov 26, 2023
1 parent dd1f584 commit 958a5b7
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 69 deletions.
2 changes: 1 addition & 1 deletion helpers/hardhat-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export const MULTI_SIG_NONCE = process.env.MULTI_SIG_NONCE
? parseInt(process.env.MULTI_SIG_NONCE)
: undefined;
export const MULTI_SEND_CHUNK_SIZE = parseInt(
process.env.MULTI_SEND_CHUNK_SIZE || "30"
process.env.MULTI_SEND_CHUNK_SIZE || "45"
);

export const VERSION = version;
Expand Down
142 changes: 74 additions & 68 deletions tasks/dev/reserveConfigurator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {DRY_RUN} from "../../helpers/hardhat-constants";
import {waitForTx} from "../../helpers/misc-utils";

task("set-ltv", "Set LTV")
.addPositionalParam("asset", "asset")
.addPositionalParam("assets", "assets")
.addPositionalParam("ltv", "ltv")
.setAction(async ({asset, ltv}, DRE) => {
.setAction(async ({assets, ltv}, DRE) => {
await DRE.run("set-DRE");
const {dryRunEncodedData} = await import("../../helpers/contracts-helpers");
const {
Expand All @@ -19,40 +19,42 @@ task("set-ltv", "Set LTV")
const configurator = await getPoolConfiguratorProxy();
const [reservesData] = await ui.getReservesData(provider.address);

const reserveData = reservesData.find(
(x) => x.underlyingAsset === utils.getAddress(asset)
);
if (!reserveData) {
return;
}
for (const asset of assets.split(",")) {
const reserveData = reservesData.find(
(x) => x.underlyingAsset === utils.getAddress(asset)
);
if (!reserveData) {
return;
}

const encodedData = configurator.interface.encodeFunctionData(
"configureReserveAsCollateral",
[
reserveData.underlyingAsset,
ltv,
reserveData.reserveLiquidationThreshold,
reserveData.reserveLiquidationBonus,
]
);
if (DRY_RUN) {
await dryRunEncodedData(configurator.address, encodedData);
} else {
await waitForTx(
await configurator.configureReserveAsCollateral(
const encodedData = configurator.interface.encodeFunctionData(
"configureReserveAsCollateral",
[
reserveData.underlyingAsset,
ltv,
reserveData.reserveLiquidationThreshold,
reserveData.reserveLiquidationBonus
)
reserveData.reserveLiquidationBonus,
]
);
if (DRY_RUN) {
await dryRunEncodedData(configurator.address, encodedData);
} else {
await waitForTx(
await configurator.configureReserveAsCollateral(
reserveData.underlyingAsset,
ltv,
reserveData.reserveLiquidationThreshold,
reserveData.reserveLiquidationBonus
)
);
}
}
});

task("set-liquidation-threshold", "Set liquidation threshold")
.addPositionalParam("asset", "asset")
.addPositionalParam("assets", "assets")
.addPositionalParam("liquidationThreshold", "liquidation threshold")
.setAction(async ({asset, liquidationThreshold}, DRE) => {
.setAction(async ({assets, liquidationThreshold}, DRE) => {
await DRE.run("set-DRE");
const {dryRunEncodedData} = await import("../../helpers/contracts-helpers");
const {
Expand All @@ -65,40 +67,42 @@ task("set-liquidation-threshold", "Set liquidation threshold")
const configurator = await getPoolConfiguratorProxy();
const [reservesData] = await ui.getReservesData(provider.address);

const reserveData = reservesData.find(
(x) => x.underlyingAsset === utils.getAddress(asset)
);
if (!reserveData) {
return;
}
for (const asset of assets.split(",")) {
const reserveData = reservesData.find(
(x) => x.underlyingAsset === utils.getAddress(asset)
);
if (!reserveData) {
return;
}

const encodedData = configurator.interface.encodeFunctionData(
"configureReserveAsCollateral",
[
reserveData.underlyingAsset,
reserveData.baseLTVasCollateral,
liquidationThreshold,
reserveData.reserveLiquidationBonus,
]
);
if (DRY_RUN) {
await dryRunEncodedData(configurator.address, encodedData);
} else {
await waitForTx(
await configurator.configureReserveAsCollateral(
const encodedData = configurator.interface.encodeFunctionData(
"configureReserveAsCollateral",
[
reserveData.underlyingAsset,
reserveData.baseLTVasCollateral,
liquidationThreshold,
reserveData.reserveLiquidationBonus
)
reserveData.reserveLiquidationBonus,
]
);
if (DRY_RUN) {
await dryRunEncodedData(configurator.address, encodedData);
} else {
await waitForTx(
await configurator.configureReserveAsCollateral(
reserveData.underlyingAsset,
reserveData.baseLTVasCollateral,
liquidationThreshold,
reserveData.reserveLiquidationBonus
)
);
}
}
});

task("set-reserve-factor", "Set reserve factor")
.addPositionalParam("asset", "asset")
.addPositionalParam("assets", "assets")
.addPositionalParam("reserveFactor", "reserve factor")
.setAction(async ({asset, reserveFactor}, DRE) => {
.setAction(async ({assets, reserveFactor}, DRE) => {
await DRE.run("set-DRE");
const {dryRunEncodedData} = await import("../../helpers/contracts-helpers");
const {
Expand All @@ -111,26 +115,28 @@ task("set-reserve-factor", "Set reserve factor")
const configurator = await getPoolConfiguratorProxy();
const [reservesData] = await ui.getReservesData(provider.address);

const reserveData = reservesData.find(
(x) => x.underlyingAsset === utils.getAddress(asset)
);
if (!reserveData) {
return;
}
for (const asset of assets.split(",")) {
const reserveData = reservesData.find(
(x) => x.underlyingAsset === utils.getAddress(asset)
);
if (!reserveData) {
return;
}

const encodedData = configurator.interface.encodeFunctionData(
"setReserveFactor",
[reserveData.underlyingAsset, reserveFactor]
);
if (DRY_RUN) {
await dryRunEncodedData(configurator.address, encodedData);
} else {
await waitForTx(
await configurator.setReserveFactor(
reserveData.underlyingAsset,
reserveFactor
)
const encodedData = configurator.interface.encodeFunctionData(
"setReserveFactor",
[reserveData.underlyingAsset, reserveFactor]
);
if (DRY_RUN) {
await dryRunEncodedData(configurator.address, encodedData);
} else {
await waitForTx(
await configurator.setReserveFactor(
reserveData.underlyingAsset,
reserveFactor
)
);
}
}
});

Expand Down

0 comments on commit 958a5b7

Please sign in to comment.