Skip to content

Commit

Permalink
Merge branch 'release/v4.7.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerEther committed May 23, 2024
2 parents 0580150 + e74a28d commit 84ce58c
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 24 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog

## 4.7.1
## v4.7.2
### Dependencies
- Upgrade adrastia-core to v4.7.1.

### Accumulators
- Add constructor args validation and events to AccumulatorConfig.

## v4.7.1
### Prudentia
#### Controllers
- Update RateController
Expand Down
13 changes: 10 additions & 3 deletions contracts/accumulators/AccumulatorConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ abstract contract AccumulatorConfig is AccessControlEnumerable {
constructor(uint32 updateThreshold_, uint32 updateDelay_, uint32 heartbeat_) {
initializeRoles();

config.updateThreshold = updateThreshold_;
config.updateDelay = updateDelay_;
config.heartbeat = heartbeat_;
setConfigInternal(
Config({updateThreshold: updateThreshold_, updateDelay: updateDelay_, heartbeat: heartbeat_})
);
}

/**
Expand All @@ -63,6 +63,13 @@ abstract contract AccumulatorConfig is AccessControlEnumerable {
/// @param newConfig The new configuration values.
/// @dev Only accounts with the CONFIG_ADMIN role can call this function.
function setConfig(Config calldata newConfig) external virtual onlyRole(Roles.CONFIG_ADMIN) {
setConfigInternal(newConfig);
}

/// @notice Sets a new configuration.
/// @param newConfig The new configuration values.
/// @dev Only accounts with the CONFIG_ADMIN role can call this function.
function setConfigInternal(Config memory newConfig) internal virtual {
// Ensure that updateDelay is not greater than heartbeat
if (newConfig.updateDelay > newConfig.heartbeat) revert InvalidConfig(newConfig);
// Ensure that updateThreshold is not zero
Expand Down
13 changes: 13 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ module.exports = {
url: process.env.OPTIMISM_URL || "",
accounts: [process.env.PRIVATE_KEY_DEPLOYER || ""],
},
mode: {
chainId: 34443,
url: process.env.MODE_URL || "",
accounts: [process.env.PRIVATE_KEY_DEPLOYER || ""],
},
},
etherscan: {
apiKey: {
Expand All @@ -74,6 +79,14 @@ module.exports = {
browserURL: "https://zkevm.polygonscan.com",
},
},
{
network: "mode",
chainId: 34443,
urls: {
apiURL: "https://explorer.mode.network/api",
browserURL: "https://explorer.mode.network",
},
},
],
},
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adrastia-oracle/adrastia-periphery",
"version": "4.7.1",
"version": "4.7.2",
"main": "index.js",
"author": "TRILEZ SOFTWARE INC.",
"license": "BUSL-1.1",
Expand Down Expand Up @@ -30,7 +30,7 @@
"access": "public"
},
"dependencies": {
"@adrastia-oracle/adrastia-core": "4.7.0",
"@adrastia-oracle/adrastia-core": "4.7.1",
"@openzeppelin-v3/contracts": "npm:@openzeppelin/contracts@3.4.2",
"@openzeppelin-v4/contracts": "npm:@openzeppelin/contracts@4.6.0"
},
Expand Down
18 changes: 12 additions & 6 deletions scripts/oracles/print-accumulator-config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
const hre = require("hardhat");

const ethers = hre.ethers;
const parseUnits = hre.ethers.utils.parseUnits;

const UPDATE_THRESHOLD_0_1_PERCENT = ethers.utils.parseUnits("0.001", 8); // 0.1%
const UPDATE_THRESHOLD_0_5_PERCENT = ethers.utils.parseUnits("0.005", 8); // 0.5%
const UPDATE_THRESHOLD_1_PERCENT = ethers.utils.parseUnits("0.01", 8); // 1%
const UPDATE_THRESHOLD_10_PERCENT = ethers.utils.parseUnits("0.1", 8); // 10%
const CHANGE_PRECISION_DECIMALS = 8;

const UPDATE_THRESHOLD_0_1_PERCENT = parseUnits("0.001", CHANGE_PRECISION_DECIMALS); // 0.1%
const UPDATE_THRESHOLD_0_5_PERCENT = parseUnits("0.005", CHANGE_PRECISION_DECIMALS); // 0.5%
const UPDATE_THRESHOLD_1_PERCENT = parseUnits("0.01", CHANGE_PRECISION_DECIMALS); // 1%
const UPDATE_THRESHOLD_10_PERCENT = parseUnits("0.1", CHANGE_PRECISION_DECIMALS); // 10%

async function main() {
const updateThreshold = UPDATE_THRESHOLD_10_PERCENT;
const updateThreshold = UPDATE_THRESHOLD_0_1_PERCENT;
const updateDelay = 10; // 10 seconds
const heartbeat = 60 * 60 * 4; // 4 hours

console.log("Update threshold:", updateThreshold.toNumber());
console.log("Update delay:", updateDelay);
console.log("Heartbeat:", heartbeat);

// Assemble the configuration as a string
const configuration =
'["' + updateThreshold.toString() + '","' + updateDelay.toString() + '","' + heartbeat.toString() + '"]';
Expand Down
2 changes: 2 additions & 0 deletions scripts/print-interface-ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ async function main() {
ids["IOracle"] = await interfaceIds.iOracle();
ids["AggregatorV3Interface"] = await interfaceIds.aggregatorV3Interface();
ids["IOracleAggregator"] = await interfaceIds.iOracleAggregator();
ids["IAccessControl"] = await interfaceIds.iAccessControl();
ids["IAccessControlEnumerable"] = await interfaceIds.iAccessControlEnumerable();

console.log(ids);
}
Expand Down
5 changes: 5 additions & 0 deletions scripts/rates/caps/deploy-cap-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ async function main() {
const updatersMustBeEoa = true;
const newAdmin = "0xec89a5dd6c179c345EA7996AA879E59cB18c8484"; // Adrastia Admin
const assignAllRolesToAdmin = true;
const anyoneCanUpdate = true;

const factory = await ethers.getContractFactory("ManagedCapController");
const rateController = await factory.deploy(period, initialBufferCardinality, updatersMustBeEoa);
Expand All @@ -112,6 +113,10 @@ async function main() {
await tryGrantRole(rateController, newAdmin, RATE_ADMIN_ROLE);
await tryGrantRole(rateController, newAdmin, UPDATE_PAUSE_ADMIN_ROLE);

if (anyoneCanUpdate) {
await tryGrantRole(rateController, ethers.constants.AddressZero, ORACLE_UPDATER_ROLE);
}

// Revoke the deployer's updater admin role
await tryRevokeRole(rateController, deployer.address, ORACLE_UPDATER_MANAGER_ROLE);
}
Expand Down
21 changes: 13 additions & 8 deletions scripts/rates/print-mutated-value-computer-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,33 @@ const hre = require("hardhat");

const ethers = hre.ethers;

async function main() {
const token = "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"; // WMATIC on Polygon
const DEFAULT_ONE_X_SCALAR = BigNumber.from(10).pow(6);

async function main() {
// Default 1x scalar. Make sure to verify that the computer uses the same 1x scaler.
const oneXScalar = ethers.BigNumber.from(10).pow(6);
const oneXScalar = DEFAULT_ONE_X_SCALAR;

// The following configuration assumes all amounts are whole token amounts (no decimals)
const decimals = 4;

// The maximum value that will be returned by the computer (up to 2^64-1)
const max = ethers.BigNumber.from(2).pow(64).sub(1);
// The minimum value that will be returned by the computer (up to 2^64-1)
const min = ethers.BigNumber.from(0);
const min = ethers.utils.parseUnits("1", decimals);
// The value to add after the value has been scaled by the scalar below
const offset = ethers.BigNumber.from(100_000);
const offset = ethers.utils.parseUnits("200000", decimals);
// The scalar to multiply the value by before adding the offset
const scalar = oneXScalar.add(oneXScalar.div(5)); // 1.2x
const scalar = oneXScalar.add(oneXScalar.div(50)); // 1.02x

const configuration =
'["' + max.toString() + '","' + min.toString() + '","' + offset.toString() + '","' + scalar.toString() + '"]';

console.log("max: " + max.toString());
console.log("min: " + min.toString());
console.log("offset: " + offset.toString());
console.log("scalar: " + scalar.toString());

// Print the configuration
console.log("MutatedValueComputer configuration for " + token + ": " + configuration);
console.log("MutatedValueComputer configuration: " + configuration);
}

main()
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# yarn lockfile v1


"@adrastia-oracle/adrastia-core@4.7.0":
version "4.7.0"
resolved "https://registry.yarnpkg.com/@adrastia-oracle/adrastia-core/-/adrastia-core-4.7.0.tgz#7e5c194e1175d2d426a0c3b296934ea7f972fac6"
integrity sha512-Zcux4XTiV1ocTmTU69+NgfYk4Bk2lvPI/U99GGW8F1SQGcAShmEYBDEkSMsxFaPS0fQMyDvaGhWDJgHR6LruDg==
"@adrastia-oracle/adrastia-core@4.7.1":
version "4.7.1"
resolved "https://registry.yarnpkg.com/@adrastia-oracle/adrastia-core/-/adrastia-core-4.7.1.tgz#787bed1195a5ad0504b7dd3483a56a99a71e6a52"
integrity sha512-Cu7c8mP8g6Bgywwer7xB0sK2F+2n5vqPeQSD91RjjrmUhfHG2AgbPCWRJs4e4qutwXwzDWpErBOgHsr4c9tQsg==
dependencies:
"@openzeppelin-v4/contracts" "npm:@openzeppelin/contracts@4.6.0"
"@prb/math" "^2.5.0"
Expand Down

0 comments on commit 84ce58c

Please sign in to comment.