Skip to content

Commit

Permalink
add update reserve factor script
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoujia6139 committed Feb 28, 2024
1 parent 3abc516 commit 8fce35d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,10 @@ set-liquidation-threshold:
set-reserve-factor:
make TASK_NAME=set-reserve-factor run-task

.PHONY: reset-all-asset-reserve-factor
reset-all-asset-reserve-factor:
make TASK_NAME=reset-all-asset-reserve-factor run-task

.PHONY: set-interest-rate-strategy
set-interest-rate-strategy:
make TASK_NAME=set-interest-rate-strategy run-task
Expand Down
13 changes: 7 additions & 6 deletions contracts/protocol/pool/DefaultReserveInterestRateStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {IReserveInterestRateStrategy} from "../../interfaces/IReserveInterestRat
import {IPoolAddressesProvider} from "../../interfaces/IPoolAddressesProvider.sol";
import {IToken} from "../../interfaces/IToken.sol";
import {Errors} from "../libraries/helpers/Errors.sol";
import {MathUtils} from "../libraries/math/MathUtils.sol";

/**
* @title DefaultReserveInterestRateStrategy contract
Expand Down Expand Up @@ -103,12 +104,7 @@ contract DefaultReserveInterestRateStrategy is IReserveInterestRateStrategy {
}

/// @inheritdoc IReserveInterestRateStrategy
function getMaxVariableBorrowRate()
external
view
override
returns (uint256)
{
function getMaxVariableBorrowRate() public view override returns (uint256) {
return
_baseVariableBorrowRate + _variableRateSlope1 + _variableRateSlope2;
}
Expand Down Expand Up @@ -173,4 +169,9 @@ contract DefaultReserveInterestRateStrategy is IReserveInterestRateStrategy {

return (vars.currentLiquidityRate, vars.currentVariableBorrowRate);
}

function calculateMaxYearAPY() external view returns (uint256) {
uint256 maxRate = getMaxVariableBorrowRate();
return MathUtils.calculateCompoundedInterest(maxRate, 0, 31536000);
}
}
27 changes: 27 additions & 0 deletions tasks/dev/reserveConfigurator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,33 @@ task("set-reserve-factor", "Set reserve factor")
}
});

task("reset-all-asset-reserve-factor", "Reset all asset reserve factor")
.addPositionalParam("reserveFactor", "reserve factor")
.setAction(async ({reserveFactor}, DRE) => {
await DRE.run("set-DRE");
const {dryRunEncodedData} = await import("../../helpers/contracts-helpers");
const {getPoolProxy, getPoolConfiguratorProxy} = await import(
"../../helpers/contracts-getters"
);
const configurator = await getPoolConfiguratorProxy();
const poolProxy = await getPoolProxy();
const assets = await poolProxy.getReservesList();

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

task("set-interest-rate-strategy", "Set interest rate strategy")
.addPositionalParam("assets", "assets")
.addPositionalParam(
Expand Down

0 comments on commit 8fce35d

Please sign in to comment.