-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: OLAS burner contract #159
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,70 @@ | ||
{ | ||
"_format": "hh-sol-artifact-1", | ||
"contractName": "Burner", | ||
"sourceName": "contracts/Burner.sol", | ||
"abi": [ | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "_olas", | ||
"type": "address" | ||
} | ||
], | ||
"stateMutability": "nonpayable", | ||
"type": "constructor" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "ReentrancyGuard", | ||
"type": "error" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "ZeroAddress", | ||
"type": "error" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "ZeroValue", | ||
"type": "error" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": false, | ||
"internalType": "uint256", | ||
"name": "amount", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "Burned", | ||
"type": "event" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "burn", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "olas", | ||
"outputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "", | ||
"type": "address" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
} | ||
], | ||
"bytecode": "0x60a060405260015f55348015610013575f5ffd5b5060405161039e38038061039e8339810160408190526100329161006a565b6001600160a01b0381166100595760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b0316608052610097565b5f6020828403121561007a575f5ffd5b81516001600160a01b0381168114610090575f5ffd5b9392505050565b6080516102e26100bc5f395f8181603c0152818161010101526101e901526102e25ff3fe608060405234801561000f575f5ffd5b5060043610610033575f3560e01c806231d1151461003757806344df8e7014610087575b5f5ffd5b61005e7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61008f610091565b005b60015f5411156100cd576040517f8beb9d1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025f9081556040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa15801561015b573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061017f9190610295565b9050805f036101ba576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f42966c68000000000000000000000000000000000000000000000000000000008152600481018290527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906342966c68906024015f604051808303815f87803b15801561023f575f5ffd5b505af1158015610251573d5f5f3e3d5ffd5b505050507fd83c63197e8e676d80ab0122beba9a9d20f3828839e9a1d6fe81d242e9cd7e6e8160405161028691815260200190565b60405180910390a15060015f55565b5f602082840312156102a5575f5ffd5b505191905056fea264697066735822122081e9dea49c6f1f8ecd56cd03169c0ccbd30c2383dc8d4434d17aa7b5b3b6f1e264736f6c634300081c0033", | ||
"deployedBytecode": "0x608060405234801561000f575f5ffd5b5060043610610033575f3560e01c806231d1151461003757806344df8e7014610087575b5f5ffd5b61005e7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61008f610091565b005b60015f5411156100cd576040517f8beb9d1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025f9081556040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa15801561015b573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061017f9190610295565b9050805f036101ba576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f42966c68000000000000000000000000000000000000000000000000000000008152600481018290527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906342966c68906024015f604051808303815f87803b15801561023f575f5ffd5b505af1158015610251573d5f5f3e3d5ffd5b505050507fd83c63197e8e676d80ab0122beba9a9d20f3828839e9a1d6fe81d242e9cd7e6e8160405161028691815260200190565b60405180910390a15060015f55565b5f602082840312156102a5575f5ffd5b505191905056fea264697066735822122081e9dea49c6f1f8ecd56cd03169c0ccbd30c2383dc8d4434d17aa7b5b3b6f1e264736f6c634300081c0033", | ||
"linkReferences": {}, | ||
"deployedLinkReferences": {} | ||
} |
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,66 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.28; | ||
|
||
interface IToken { | ||
/// @dev Gets the amount of tokens owned by a specified account. | ||
/// @param account Account address. | ||
/// @return Amount of tokens owned. | ||
function balanceOf(address account) external view returns (uint256); | ||
|
||
/// @dev Burns tokens. | ||
/// @param amount Token amount to burn. | ||
function burn(uint256 amount) external; | ||
} | ||
|
||
/// @dev Provided zero address. | ||
error ZeroAddress(); | ||
|
||
/// @dev Provided value provided. | ||
error ZeroValue(); | ||
|
||
/// @dev Caught reentrancy violation. | ||
error ReentrancyGuard(); | ||
|
||
/// @title Burner - Smart contract for burning OLAS token. | ||
contract Burner { | ||
event Burned(uint256 amount); | ||
|
||
// OLAS address | ||
address public immutable olas; | ||
// Reentrancy lock | ||
uint256 internal _locked = 1; | ||
|
||
/// @dev Burner constructor. | ||
/// @param _olas OLAS address. | ||
constructor(address _olas) { | ||
if (_olas == address(0)) { | ||
revert ZeroAddress(); | ||
} | ||
|
||
olas = _olas; | ||
} | ||
|
||
/// @dev Burns OLAS tokens owned by this contract. | ||
function burn() external { | ||
// Reentrancy guard | ||
if (_locked > 1) { | ||
revert ReentrancyGuard(); | ||
} | ||
_locked = 2; | ||
|
||
// Get OLAS balance | ||
uint256 olasBalance = IToken(olas).balanceOf(address(this)); | ||
|
||
// Check for zero value | ||
if (olasBalance == 0) { | ||
revert ZeroValue(); | ||
} | ||
|
||
// Burn tokens | ||
IToken(olas).burn(olasBalance); | ||
|
||
emit Burned(olasBalance); | ||
|
||
_locked = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/*global process*/ | ||
|
||
const { expect } = require("chai"); | ||
const { ethers } = require("hardhat"); | ||
const { LedgerSigner } = require("@anders-t/ethers-ledger"); | ||
|
||
async function main() { | ||
const fs = require("fs"); | ||
const globalsFile = "globals.json"; | ||
const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); | ||
let parsedData = JSON.parse(dataFromJSON); | ||
const derivationPath = parsedData.derivationPath; | ||
const useLedger = parsedData.useLedger; | ||
const providerName = parsedData.providerName; | ||
let EOA; | ||
|
||
const provider = await ethers.providers.getDefaultProvider(providerName); | ||
const signers = await ethers.getSigners(); | ||
|
||
if (useLedger) { | ||
EOA = new LedgerSigner(provider, derivationPath); | ||
} else { | ||
EOA = signers[0]; | ||
} | ||
// EOA address | ||
const deployer = await EOA.getAddress(); | ||
console.log("EOA is:", deployer); | ||
|
||
// Transaction signing and execution | ||
console.log("24. EOA to deploy Burner contract pointed to OLAS"); | ||
const Burner = await ethers.getContractFactory("Burner"); | ||
console.log("You are signing the following transaction: Burner.connect(EOA).deploy(OLAS)"); | ||
const burner = await Burner.connect(EOA).deploy(parsedData.olasAddress); | ||
const result = await burner.deployed(); | ||
|
||
// Transaction details | ||
console.log("Contract deployment: burner"); | ||
console.log("Contract address:", burner.address); | ||
console.log("Transaction:", result.deployTransaction.hash); | ||
|
||
// If on sepolia, wait half a minute for the transaction completion | ||
if (providerName === "sepolia") { | ||
await new Promise(r => setTimeout(r, 30000)); | ||
} | ||
|
||
// Contract verification | ||
if (parsedData.contractVerification) { | ||
const execSync = require("child_process").execSync; | ||
execSync("npx hardhat verify --constructor-args scripts/deployment/verify_24_burner.js --network " + providerName + " " + burner.address, { encoding: "utf-8" }); | ||
} | ||
|
||
// Writing updated parameters back to the JSON file | ||
parsedData.burnerAddress = burner.address; | ||
fs.writeFileSync(globalsFile, JSON.stringify(parsedData)); | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const fs = require("fs"); | ||
const globalsFile = "globals.json"; | ||
const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); | ||
const parsedData = JSON.parse(dataFromJSON); | ||
|
||
module.exports = [ | ||
parsedData.olasAddress | ||
]; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/valory-xyz/autonolas-governance/blob/main/contracts/OLAS.sol#L118
What is the meaning of this contract, anyone can call this function for themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK