-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/add-fees' into dev
# Conflicts: # deployments/16718.json # deployments/30746.json # package.json
- Loading branch information
Showing
10 changed files
with
250 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -963,4 +963,4 @@ | |
"fullyQualifiedName": "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters