Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/add-fees' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	deployments/16718.json
#	deployments/30746.json
#	package.json
  • Loading branch information
SvineruS committed Jan 15, 2024
2 parents 4ec581c + e7a78f8 commit 9565ae1
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 4 deletions.
58 changes: 58 additions & 0 deletions contracts/fees/Fees.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copyright: Ambrosus Inc.
Email: [email protected]
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.
*/
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol";
import "./IFees.sol";

contract Fees is UUPSUpgradeable, AccessControlEnumerableUpgradeable, IFees {
uint gasPrice;
address payAddress;
uint feePercent;

event GasPriceChanged(uint indexed price);
event FeesParamsChanged(address indexed addr, uint indexed percent);

function initialize(
uint _gasPrice,
address _payAddress,
uint _feePercent
) public initializer {
gasPrice = _gasPrice;
payAddress = _payAddress;
feePercent = _feePercent;

_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
}

function setGasPrice(uint price) external onlyRole(DEFAULT_ADMIN_ROLE) {
gasPrice = price;

emit GasPriceChanged(price);
}

function getGasPrice() public view returns (uint) {
return gasPrice;
}

function setFeesParams(address addr, uint percent) external onlyRole(DEFAULT_ADMIN_ROLE) {
payAddress = addr;
feePercent = percent;

emit FeesParamsChanged(addr, percent);
}

function getFeesParams() public view returns (address addr, uint percent) {
return (payAddress, feePercent);
}

function _authorizeUpgrade(address) internal override onlyRole(DEFAULT_ADMIN_ROLE) {}
}
17 changes: 17 additions & 0 deletions contracts/fees/IFees.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Copyright: Ambrosus Inc.
Email: [email protected]
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.
*/
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

interface IFees {
function setGasPrice(uint price) external;
function getGasPrice() external view returns (uint);
function setFeesParams(address addr, uint percent) external;
function getFeesParams() external view returns (address, uint);
}
2 changes: 1 addition & 1 deletion deployments/16718.json
Original file line number Diff line number Diff line change
Expand Up @@ -963,4 +963,4 @@
"fullyQualifiedName": "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy"
}
}
}
}
93 changes: 92 additions & 1 deletion deployments/30746.json
Original file line number Diff line number Diff line change
Expand Up @@ -962,5 +962,96 @@
"implementation": "0x0784273B3eb7EC159bb48Da834e230fe583D11CC",
"fullyQualifiedName": "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy"
}
},
"Fees_Multisig": {
"address": "0xeAAd95c57BC920A175767f1b6187820B193E0889",
"abi": [
"constructor(address[] _signers, bool[] isInitiatorFlags, uint256 _threshold, address owner)",
"event Confirmation(address indexed sender, uint256 indexed txId)",
"event Execution(uint256 indexed txId)",
"event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)",
"event Revocation(address indexed sender, uint256 indexed txId)",
"event SignerAddition(address indexed signer, bool isInitiator)",
"event SignerRemoval(address indexed signer)",
"event Submission(uint256 indexed txId)",
"event ThresholdChange(uint256 required)",
"function changeSigners(address[] signersToRemove, address[] signersToAdd, bool[] isInitiatorFlags)",
"function changeThreshold(uint256 _threshold)",
"function checkBeforeSubmitTransaction(address destination, uint256 value, bytes data) payable",
"function confirmTransaction(uint256 txId)",
"function confirmations(uint256, address) view returns (bool)",
"function getConfirmations(uint256 txId) view returns (address[])",
"function getInitiatorsCount() view returns (uint256)",
"function getRequiredSignersCount() view returns (uint256)",
"function getSigners() view returns (address[], bool[])",
"function getTransactionData(uint256 txId) view returns (tuple(address destination, uint256 value, bytes data, bool executed), address[])",
"function getTransactionIds(uint256 from, uint256 to, bool pending, bool executed) view returns (uint256[] result)",
"function isConfirmed(uint256 txId) view returns (bool)",
"function isInitiator(address) view returns (bool)",
"function isSigner(address) view returns (bool)",
"function owner() view returns (address)",
"function renounceOwnership()",
"function revokeConfirmation(uint256 txId)",
"function signers(uint256) view returns (address)",
"function submitTransaction(address destination, uint256 value, bytes data) payable returns (uint256 txId)",
"function threshold() view returns (uint256)",
"function transactionCount() view returns (uint256)",
"function transactions(uint256) view returns (address destination, uint256 value, bytes data, bool executed)",
"function transferOwnership(address newOwner)",
"function withdraw(address to, uint256 amount)"
],
"deployTx": "0x23b436a5636802cb07c7f5c56a2a175fba4618096e1fcf22d31380a238ac04f0",
"fullyQualifiedName": "contracts/multisig/Multisig.sol:Multisig"
},
"Fees_Treasure": {
"address": "0x009Ae4Bf3A00Ee4f9981bf7a808702f18b86d217",
"abi": [
"constructor(address owner)",
"event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)",
"event Withdraw(address addressTo, uint256 amount)",
"function owner() view returns (address)",
"function renounceOwnership()",
"function transferOwnership(address newOwner)",
"function withdraw(address addressTo, uint256 amount)"
],
"deployTx": "0x08ebe2e73acea5ec155d8d09ee653a55fcbc75cddd24ac9bc3d46a73b725ecfb",
"fullyQualifiedName": "contracts/finance/Finance.sol:Finance"
},
"Fees": {
"address": "0x52d026B38b3382Fe1b8a28EA55895aF875191750",
"abi": [
"event AdminChanged(address previousAdmin, address newAdmin)",
"event BeaconUpgraded(address indexed beacon)",
"event FeesParamsChanged(address indexed addr, uint256 indexed percent)",
"event GasPriceChanged(uint256 indexed price)",
"event Initialized(uint8 version)",
"event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole)",
"event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender)",
"event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender)",
"event Upgraded(address indexed implementation)",
"function DEFAULT_ADMIN_ROLE() view returns (bytes32)",
"function getFeesParams() view returns (address addr, uint256 percent)",
"function getGasPrice() view returns (uint256)",
"function getRoleAdmin(bytes32 role) view returns (bytes32)",
"function getRoleMember(bytes32 role, uint256 index) view returns (address)",
"function getRoleMemberCount(bytes32 role) view returns (uint256)",
"function grantRole(bytes32 role, address account)",
"function hasRole(bytes32 role, address account) view returns (bool)",
"function initialize(uint256 _gasPrice, address _payAddress, uint256 _feePercent)",
"function proxiableUUID() view returns (bytes32)",
"function renounceRole(bytes32 role, address account)",
"function revokeRole(bytes32 role, address account)",
"function setFeesParams(address addr, uint256 percent)",
"function setGasPrice(uint256 price)",
"function supportsInterface(bytes4 interfaceId) view returns (bool)",
"function upgradeTo(address newImplementation)",
"function upgradeToAndCall(address newImplementation, bytes data) payable"
],
"deployTx": "0xe723bab69fd455737f1660348691c1361f83636ef8ed09ca4538b31e59c9328c",
"fullyQualifiedName": "contracts/fees/Fees.sol:Fees",
"proxy": {
"implementation": "0x480ca9040a1e64E9337c6Adac6730069B509DC08",
"fullyQualifiedName": "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy"
}
}
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"deploy_staking": "npm run deploy_validatorset && npm run deploy_treasury && npm run deploy_basenodes_manager && npm run deploy_servernodes_manager && npm run deploy_legacy_pool_manager",
"deploy_all": "npm run deploy_multisig && npm run deploy_finance && npm run deploy_airdrop && npm run deploy_staking",
"migration_to_new_staking": "hardhat run scripts/staking/migrate_to_new_staking.ts --network dev",
"test_script": "hardhat run scripts/test.ts",
"deploy_fees": "hardhat run scripts/fees/deploy_fees.ts --network dev",
"test_script": "hardhat run scripts/test.ts --network test",
"integration_test_script": "hardhat run scripts/staking/new_validatorset_integration_test.ts --network local",
"sourcify:dev": "hardhat sourcify --network dev",
"sourcify:test": "hardhat sourcify --network test",
Expand Down
48 changes: 48 additions & 0 deletions scripts/fees/deploy_fees.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {deploy, loadDeployment} from "@airdao/deployments/deploying";
import {ethers} from "hardhat";
import {Fees__factory, Finance__factory, Multisig__factory} from "../../typechain-types";
import {ContractNames} from "../../src";
import {Roadmap2023MultisigSettings} from "../addresses";

export async function main() {
const { chainId } = await ethers.provider.getNetwork();

const [deployer] = await ethers.getSigners();
const masterMultisig = loadDeployment(ContractNames.MasterMultisig, chainId).address;

const multisig = await deploy<Multisig__factory>({
contractName: ContractNames.FeesMultisig,
artifactName: "Multisig",
deployArgs: [...Roadmap2023MultisigSettings, masterMultisig],
signer: deployer,
loadIfAlreadyDeployed: true,
});

const treasure = await deploy<Finance__factory>({
contractName: ContractNames.FeesTreasure,
artifactName: "Finance",
deployArgs: [multisig.address],
signer: deployer,
});

const gasPrice = 10;
const payAddress = treasure.address;
const feePercent = 300000;

const fees = await deploy<Fees__factory>({
contractName: ContractNames.Fees,
artifactName: "Fees",
deployArgs: [gasPrice, payAddress, feePercent],
signer: deployer,
isUpgradeableProxy: true,
});

await (await fees.grantRole(await fees.DEFAULT_ADMIN_ROLE(), multisig.address)).wait();
}

if (require.main === module) {
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
}
2 changes: 1 addition & 1 deletion scripts/staking/deploy_treasury.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ContractNames } from "../../src";
import { Multisig__factory, Treasury__factory } from "../../typechain-types";
import {Roadmap2023MultisigSettings} from "../addresses";

async function main() {
export async function main() {
const { chainId } = await ethers.provider.getNetwork();

const [deployer] = await ethers.getSigners();
Expand Down
6 changes: 6 additions & 0 deletions src/contracts/names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export enum ContractNames {
AirDrop = "AirDrop",

LockKeeper = "LockKeeper",

Fees = "Fees",
FeesMultisig = "Fees_Multisig",
FeesTreasure = "Fees_Treasure",
}

export const MULTISIGS = {
Expand All @@ -68,6 +72,8 @@ export const MULTISIGS = {
[ContractNames.LegacyPoolManagerRewardsBank]: ContractNames.LegacyPoolManagerMultisig,
[ContractNames.ServerNodesManagerRewardsBank]: ContractNames.ServerNodesManagerMultisig,
[ContractNames.Treasury]: ContractNames.TreasuryMultisig,
[ContractNames.Fees]: ContractNames.FeesMultisig,
[ContractNames.FeesTreasure]: ContractNames.FeesMultisig,
};

export const slavesMultisigsNames = [...new Set(Object.values(MULTISIGS))];
Expand Down
23 changes: 23 additions & 0 deletions src/methods/fees.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { BigNumberish } from "ethers";
import { Contracts } from "../contracts/contracts";
import { ContractNames } from "../contracts/names";
import { submitTransaction2 } from "./internal";
import { Fees } from "../../typechain-types";

export async function feesSetGasPrice(contracts: Contracts, price: BigNumberish) {
return await submitTransaction2<Fees>(contracts, ContractNames.Fees, 0, (fees) => fees.setGasPrice(price) );
}

export async function feesGetGasPrice(contracts: Contracts) {
const fees = contracts.getContractByName(ContractNames.Fees) as Fees;
return fees.getGasPrice();
}

export async function feesSetFeesParams(contracts: Contracts, payAddress: string, percent: BigNumberish) {
return await submitTransaction2<Fees>(contracts, ContractNames.Fees, 0, (fees) => fees.setFeesParams(payAddress, percent) );
}

export async function feesGetFeesParams(contracts: Contracts) {
const fees = contracts.getContractByName(ContractNames.Fees) as Fees;
return fees.getFeesParams();
}
2 changes: 2 additions & 0 deletions src/methods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import * as staking from "./staking";
import * as multisigs from "./multisigs";
import * as consensus from "./consensus";
import * as apolloDashboard from "./apolloDashboard";
import * as fees from "./fees";

const Methods = {
...multisigs,
...finance,
...staking,
...consensus,
...apolloDashboard,
...fees,
};

export default Methods;

0 comments on commit 9565ae1

Please sign in to comment.