diff --git a/.github/workflows/onpush.yml b/.github/workflows/onpush.yml index 06b1402..3dfb44e 100644 --- a/.github/workflows/onpush.yml +++ b/.github/workflows/onpush.yml @@ -3,7 +3,10 @@ name: onpush on: push: - workflow_dispatch: + branches: + - master + - stable + pull_request: jobs: check: diff --git a/.gitignore b/.gitignore index 9bb733d..3d74aa5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ __pycache__/ # Root directories /.mypy_cache/ +/build/ /dist/ # Root files diff --git a/AUTONITY_VERSION b/AUTONITY_VERSION new file mode 100644 index 0000000..4a29f93 --- /dev/null +++ b/AUTONITY_VERSION @@ -0,0 +1 @@ +v0.14.0 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6504fe1 --- /dev/null +++ b/Makefile @@ -0,0 +1,61 @@ +VERSION := $(shell cat AUTONITY_VERSION) +AUTONITY := build/autonity +ABIDIR := $(AUTONITY)/params/generated +SRCDIR := $(AUTONITY)/autonity/solidity/contracts +OUTDIR := autonity/contracts +BINDINGS := \ + $(OUTDIR)/accountability.py \ + $(OUTDIR)/acu.py \ + $(OUTDIR)/autonity.py \ + $(OUTDIR)/ierc20.py \ + $(OUTDIR)/inflation_controller.py \ + $(OUTDIR)/liquid.py \ + $(OUTDIR)/non_stakable_vesting.py \ + $(OUTDIR)/oracle.py \ + $(OUTDIR)/stabilization.py \ + $(OUTDIR)/supply_control.py \ + $(OUTDIR)/upgrade_manager.py + +gentargets = $(shell find $(SRCDIR) -name $(1).sol) $(addprefix $(ABIDIR)/$(1),.docdev .docuser .abi) + +all: $(BINDINGS) + +$(OUTDIR)/accountability.py: $(call gentargets,Accountability) +$(OUTDIR)/acu.py: $(call gentargets,ACU) +$(OUTDIR)/autonity.py: $(call gentargets,Autonity) +$(OUTDIR)/ierc20.py: $(call gentargets,IERC20) +$(OUTDIR)/inflation_controller.py: $(call gentargets,InflationController) +$(OUTDIR)/liquid.py: $(call gentargets,Liquid) +$(OUTDIR)/non_stakable_vesting.py: $(call gentargets,NonStakableVesting) +$(OUTDIR)/oracle.py: $(call gentargets,Oracle) +$(OUTDIR)/stabilization.py: $(call gentargets,Stabilization) +$(OUTDIR)/supply_control.py: $(call gentargets,SupplyControl) +$(OUTDIR)/upgrade_manager.py: $(call gentargets,UpgradeManager) + +$(BINDINGS): + hatch run generate:pyabigen \ + --version $(VERSION) \ + --src $(word 1,$^) \ + --devdoc $(word 2,$^) \ + --userdoc $(word 3,$^) \ + $(word 4,$^) >$@ + +$(ABIDIR)/%.abi: $(AUTONITY) AUTONITY_VERSION + cd $< && \ + git fetch origin && \ + git checkout $(VERSION) && \ + make contracts + +# This recipe can be removed after https://github.com/autonity/autonity/pull/1035 is released +$(ABIDIR)/%.docuser $(ABIDIR)/%.docdev: $(ABIDIR)/%.abi + $(AUTONITY)/build/bin/solc_static_linux_v0.8.21 \ + --overwrite --userdoc --devdoc -o $(ABIDIR) \ + $$(find $(AUTONITY)/autonity/solidity/contracts -name $(basename $(notdir $<)).sol) + +$(AUTONITY): + git clone git@github.com:autonity/autonity.git $@ + +clean: + rm -rf $(AUTONITY) + +.PHONY = clean diff --git a/README.md b/README.md index ba9ff9f..e976b53 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,10 @@ settlement infrastructure specialized for developing new risk markets. It is a fork of the [Ethereum protocol](https://ethereum.org/). See the [Autonity documentation](https://docs.autonity.org) for further information. -This package provides typed wrappers around the Autonity-specific extensions of -Ethereum, using the [Web3.py](https://github.com/ethereum/web3.py) framework, -for convenient and statically checked interactions with the Autonity network. +This package provides typed bindings (a.k.a. wrappers) around the +Autonity-specific extensions of Ethereum, using the +[Web3.py](https://github.com/ethereum/web3.py) framework, for convenient and +statically checked interactions with the Autonity network. ## Installation @@ -17,42 +18,41 @@ pip install autonity ## Usage -The primary utility of this library is the typed wrappers around the Autonity -protocol contract, which provides access to Autonity-specific functionality. +Example usage: ```python -from autonity.utils.web3 import create_web3_for_endpoint -from autonity import Autonity, Validator +from web3 import Web3 +from autonity import Autonity, Liquid, networks -w3 = create_web3_for_endpoint("") +# Connect to the default RPC provider on the Autonity Piccadilly Testnet +w3 = Web3(networks.piccadilly.http_provider) -# Create the typed wrapper around the Autonity contract. +# Create the typed binding around the Autonity contract autonity = Autonity(w3) -# Get total supply of Newton +# Get the total supply of Newton ntn_supply = autonity.total_supply() +print(f"Total NTN supply: {ntn_supply}") # Get the current validator list -validator_ids = autonity.get_validators() +validator_addresses = autonity.get_validators() -# Get descriptor for the 0-th validator. Print LNTN contract address. -validator_desc_0 = autonity.get_validator(validator_ids[0]) -print(f"LNTN contract addr: {validator_desc_0['liquid_contract']}") +# Get the description of the 0-th validator and print its Liquid contract address +validator = autonity.get_validator(validator_addresses[0]) +print(f"LNTN contract address: {validator.liquid_contract}") -# Typed validator Liquid Newton contract. Query unclaimed fees for
. -validator_0 = Validator(w3, validator_desc_0) -unclaimed_atn, unclaimed_ntn = validator_0.unclaimed_rewards("
") -print(f"unclaimed rewards: {unclaimed_atn} ATN, {unclaimed_ntn} NTN") +# Query unclaimed fees for
from the validator's Liquid contract +liquid = Liquid(w3, validator.liquid_contract) +unclaimed_atn, unclaimed_ntn = liquid.unclaimed_rewards("
") +print(f"Unclaimed rewards: {unclaimed_atn} ATN, {unclaimed_ntn} NTN") ``` -Where`` is the name of the Autonity network being connected to. -See for information about specific -networks. - ## Development The project uses [hatch](https://hatch.pypa.io/latest/install/#pipx) as the -build tool. To launch the tests, run: +build tool. + +To launch the tests, run: ```console hatch run test:all @@ -64,15 +64,24 @@ For linting use the command: hatch run lint:check ``` -### Updating the Contract ABIs +### Updating the Contract Bindings + +To update contract bindings for a new version of the Autonity protocol, add the +new [AGC](https://github.com/autonity/autonity) version (Git tag or commit ID) +to `AUTONITY_VERSION`, then generate the contract bindings with `make`: + +```console +echo v0.14.0 > AUTONITY_VERSION +make +``` -The script `script/update_abi.sh [AUTONITY_COMMIT]` builds the contract ABIs -using AGC at the specified Git commit ID or tag. Keys are ordered via the `jq` -tool, in order to produce deterministic output, and the results written to the -`autonity/abi` directory. Further, it normalizes the commit ID that was used. +Contract functions are ordered alphabetically in order to produce deterministic +output. After executing the script against a new version of the code, the diffs +can be reviewed to determine which methods have been modified, removed or +added. The generated Python bindings include the contract ABIs as Python dictionaries. -After executing the script against a new version of the code, the diffs can be -reviewed to determine which methods have been modified, removed or added. +If there is a new contract to include, add a new target to `Makefile` and a new +factory function to `autonity/factory.py` and `autonity/__init__.py`. ## Reporting a Vulnerability diff --git a/autonity/__init__.py b/autonity/__init__.py index 9424818..8842a34 100644 --- a/autonity/__init__.py +++ b/autonity/__init__.py @@ -1,19 +1,33 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. +# Copyright (C) 2015-2024 Clearmatics Technologies Ltd - All Rights Reserved. -""" -Top-level Autonity module exposing primary types. -""" +"""Package for interacting with the protocol contracts of the Autonity network.""" -# pylint: disable=unused-import -# flake8: noqa - -from autonity.autonity import ( +from . import constants, contracts, networks +from .factory import ( + Accountability, + ACU, Autonity, - AUTONITY_CONTRACT_ADDRESS, - get_autonity_contract_version, - get_autonity_contract_abi_path, + InflationController, + Liquid, + NonStakableVesting, + Oracle, + Stabilization, + SupplyControl, + UpgradeManager, +) + +__all__ = ( + "constants", + "contracts", + "networks", + "Accountability", + "ACU", + "Autonity", + "InflationController", + "Liquid", + "NonStakableVesting", + "Oracle", + "Stabilization", + "SupplyControl", + "UpgradeManager", ) -from autonity.config import Config -from autonity.committee_member import CommitteeMember -from autonity.validator import ValidatorDescriptor, Validator -from autonity.tendermint import Tendermint diff --git a/autonity/__version__.py b/autonity/__version__.py index 710dca6..20f5f01 100644 --- a/autonity/__version__.py +++ b/autonity/__version__.py @@ -1,5 +1 @@ -""" -Release version of autonity package. -""" - __version__ = "v4.0.0" diff --git a/autonity/abi/ACU.abi b/autonity/abi/ACU.abi deleted file mode 100644 index 0e4c6de..0000000 --- a/autonity/abi/ACU.abi +++ /dev/null @@ -1,249 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "string[]", - "name": "symbols_", - "type": "string[]" - }, - { - "internalType": "uint256[]", - "name": "quantities_", - "type": "uint256[]" - }, - { - "internalType": "uint256", - "name": "scale_", - "type": "uint256" - }, - { - "internalType": "address", - "name": "autonity", - "type": "address" - }, - { - "internalType": "address", - "name": "operator", - "type": "address" - }, - { - "internalType": "address", - "name": "oracle", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "InvalidBasket", - "type": "error" - }, - { - "inputs": [], - "name": "NoACUValue", - "type": "error" - }, - { - "inputs": [], - "name": "Unauthorized", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string[]", - "name": "symbols", - "type": "string[]" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "quantities", - "type": "uint256[]" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "scale", - "type": "uint256" - } - ], - "name": "BasketModified", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "height", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "round", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "int256", - "name": "value", - "type": "int256" - } - ], - "name": "Updated", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "string[]", - "name": "symbols_", - "type": "string[]" - }, - { - "internalType": "uint256[]", - "name": "quantities_", - "type": "uint256[]" - }, - { - "internalType": "uint256", - "name": "scale_", - "type": "uint256" - } - ], - "name": "modifyBasket", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "quantities", - "outputs": [ - { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "round", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "scale", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "scaleFactor", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "operator", - "type": "address" - } - ], - "name": "setOperator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "oracle", - "type": "address" - } - ], - "name": "setOracle", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "symbols", - "outputs": [ - { - "internalType": "string[]", - "name": "", - "type": "string[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "update", - "outputs": [ - { - "internalType": "bool", - "name": "status", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "value", - "outputs": [ - { - "internalType": "int256", - "name": "", - "type": "int256" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/autonity/abi/Accountability.abi b/autonity/abi/Accountability.abi deleted file mode 100644 index c6ffbb4..0000000 --- a/autonity/abi/Accountability.abi +++ /dev/null @@ -1,678 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address payable", - "name": "_autonity", - "type": "address" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "innocenceProofSubmissionWindow", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "baseSlashingRateLow", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "baseSlashingRateMid", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "collusionFactor", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "historyFactor", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "jailFactor", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "slashingRatePrecision", - "type": "uint256" - } - ], - "internalType": "struct Accountability.Config", - "name": "_config", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_offender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "InnocenceProven", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_offender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_severity", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "NewAccusation", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_offender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_severity", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "NewFaultProof", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "releaseBlock", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bool", - "name": "isJailbound", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "eventId", - "type": "uint256" - } - ], - "name": "SlashingEvent", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "beneficiaries", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_offender", - "type": "address" - }, - { - "internalType": "enum Accountability.Rule", - "name": "_rule", - "type": "uint8" - }, - { - "internalType": "uint256", - "name": "_block", - "type": "uint256" - } - ], - "name": "canAccuse", - "outputs": [ - { - "internalType": "bool", - "name": "_result", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "_deadline", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_offender", - "type": "address" - }, - { - "internalType": "enum Accountability.Rule", - "name": "_rule", - "type": "uint8" - }, - { - "internalType": "uint256", - "name": "_block", - "type": "uint256" - } - ], - "name": "canSlash", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "config", - "outputs": [ - { - "internalType": "uint256", - "name": "innocenceProofSubmissionWindow", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "baseSlashingRateLow", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "baseSlashingRateMid", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "collusionFactor", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "historyFactor", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "jailFactor", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "slashingRatePrecision", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_ntnReward", - "type": "uint256" - } - ], - "name": "distributeRewards", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "epochPeriod", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "events", - "outputs": [ - { - "internalType": "uint8", - "name": "chunks", - "type": "uint8" - }, - { - "internalType": "uint8", - "name": "chunkId", - "type": "uint8" - }, - { - "internalType": "enum Accountability.EventType", - "name": "eventType", - "type": "uint8" - }, - { - "internalType": "enum Accountability.Rule", - "name": "rule", - "type": "uint8" - }, - { - "internalType": "address", - "name": "reporter", - "type": "address" - }, - { - "internalType": "address", - "name": "offender", - "type": "address" - }, - { - "internalType": "bytes", - "name": "rawProof", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "block", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reportingBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "messageHash", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "_epochEnd", - "type": "bool" - } - ], - "name": "finalize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_val", - "type": "address" - } - ], - "name": "getValidatorAccusation", - "outputs": [ - { - "components": [ - { - "internalType": "uint8", - "name": "chunks", - "type": "uint8" - }, - { - "internalType": "uint8", - "name": "chunkId", - "type": "uint8" - }, - { - "internalType": "enum Accountability.EventType", - "name": "eventType", - "type": "uint8" - }, - { - "internalType": "enum Accountability.Rule", - "name": "rule", - "type": "uint8" - }, - { - "internalType": "address", - "name": "reporter", - "type": "address" - }, - { - "internalType": "address", - "name": "offender", - "type": "address" - }, - { - "internalType": "bytes", - "name": "rawProof", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "block", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reportingBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "messageHash", - "type": "uint256" - } - ], - "internalType": "struct Accountability.Event", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_val", - "type": "address" - } - ], - "name": "getValidatorFaults", - "outputs": [ - { - "components": [ - { - "internalType": "uint8", - "name": "chunks", - "type": "uint8" - }, - { - "internalType": "uint8", - "name": "chunkId", - "type": "uint8" - }, - { - "internalType": "enum Accountability.EventType", - "name": "eventType", - "type": "uint8" - }, - { - "internalType": "enum Accountability.Rule", - "name": "rule", - "type": "uint8" - }, - { - "internalType": "address", - "name": "reporter", - "type": "address" - }, - { - "internalType": "address", - "name": "offender", - "type": "address" - }, - { - "internalType": "bytes", - "name": "rawProof", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "block", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reportingBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "messageHash", - "type": "uint256" - } - ], - "internalType": "struct Accountability.Event[]", - "name": "", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint8", - "name": "chunks", - "type": "uint8" - }, - { - "internalType": "uint8", - "name": "chunkId", - "type": "uint8" - }, - { - "internalType": "enum Accountability.EventType", - "name": "eventType", - "type": "uint8" - }, - { - "internalType": "enum Accountability.Rule", - "name": "rule", - "type": "uint8" - }, - { - "internalType": "address", - "name": "reporter", - "type": "address" - }, - { - "internalType": "address", - "name": "offender", - "type": "address" - }, - { - "internalType": "bytes", - "name": "rawProof", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "block", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reportingBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "messageHash", - "type": "uint256" - } - ], - "internalType": "struct Accountability.Event", - "name": "_event", - "type": "tuple" - } - ], - "name": "handleEvent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_newPeriod", - "type": "uint256" - } - ], - "name": "setEpochPeriod", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "slashingHistory", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/autonity/abi/AccountabilityTest.abi b/autonity/abi/AccountabilityTest.abi deleted file mode 100644 index 06bd8df..0000000 --- a/autonity/abi/AccountabilityTest.abi +++ /dev/null @@ -1,1072 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address payable", - "name": "_autonity", - "type": "address" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "innocenceProofSubmissionWindow", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "baseSlashingRateLow", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "baseSlashingRateMid", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "collusionFactor", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "historyFactor", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "jailFactor", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "slashingRatePrecision", - "type": "uint256" - } - ], - "internalType": "struct Accountability.Config", - "name": "_config", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_offender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "InnocenceProven", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_offender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_severity", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "NewAccusation", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_offender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_severity", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "NewFaultProof", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "releaseBlock", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bool", - "name": "isJailbound", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "eventId", - "type": "uint256" - } - ], - "name": "SlashingEvent", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "beneficiaries", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_offender", - "type": "address" - }, - { - "internalType": "enum Accountability.Rule", - "name": "_rule", - "type": "uint8" - }, - { - "internalType": "uint256", - "name": "_block", - "type": "uint256" - } - ], - "name": "canAccuse", - "outputs": [ - { - "internalType": "bool", - "name": "_result", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "_deadline", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_offender", - "type": "address" - }, - { - "internalType": "enum Accountability.Rule", - "name": "_rule", - "type": "uint8" - }, - { - "internalType": "uint256", - "name": "_block", - "type": "uint256" - } - ], - "name": "canSlash", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "config", - "outputs": [ - { - "internalType": "uint256", - "name": "innocenceProofSubmissionWindow", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "baseSlashingRateLow", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "baseSlashingRateMid", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "collusionFactor", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "historyFactor", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "jailFactor", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "slashingRatePrecision", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_ntnReward", - "type": "uint256" - } - ], - "name": "distributeRewards", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "epochPeriod", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "events", - "outputs": [ - { - "internalType": "uint8", - "name": "chunks", - "type": "uint8" - }, - { - "internalType": "uint8", - "name": "chunkId", - "type": "uint8" - }, - { - "internalType": "enum Accountability.EventType", - "name": "eventType", - "type": "uint8" - }, - { - "internalType": "enum Accountability.Rule", - "name": "rule", - "type": "uint8" - }, - { - "internalType": "address", - "name": "reporter", - "type": "address" - }, - { - "internalType": "address", - "name": "offender", - "type": "address" - }, - { - "internalType": "bytes", - "name": "rawProof", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "block", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reportingBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "messageHash", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "_epochEnd", - "type": "bool" - } - ], - "name": "finalize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "getReporterChunksMap", - "outputs": [ - { - "components": [ - { - "internalType": "uint8", - "name": "chunks", - "type": "uint8" - }, - { - "internalType": "uint8", - "name": "chunkId", - "type": "uint8" - }, - { - "internalType": "enum Accountability.EventType", - "name": "eventType", - "type": "uint8" - }, - { - "internalType": "enum Accountability.Rule", - "name": "rule", - "type": "uint8" - }, - { - "internalType": "address", - "name": "reporter", - "type": "address" - }, - { - "internalType": "address", - "name": "offender", - "type": "address" - }, - { - "internalType": "bytes", - "name": "rawProof", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "block", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reportingBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "messageHash", - "type": "uint256" - } - ], - "internalType": "struct Accountability.Event", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_val", - "type": "address" - } - ], - "name": "getValidatorAccusation", - "outputs": [ - { - "components": [ - { - "internalType": "uint8", - "name": "chunks", - "type": "uint8" - }, - { - "internalType": "uint8", - "name": "chunkId", - "type": "uint8" - }, - { - "internalType": "enum Accountability.EventType", - "name": "eventType", - "type": "uint8" - }, - { - "internalType": "enum Accountability.Rule", - "name": "rule", - "type": "uint8" - }, - { - "internalType": "address", - "name": "reporter", - "type": "address" - }, - { - "internalType": "address", - "name": "offender", - "type": "address" - }, - { - "internalType": "bytes", - "name": "rawProof", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "block", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reportingBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "messageHash", - "type": "uint256" - } - ], - "internalType": "struct Accountability.Event", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_val", - "type": "address" - } - ], - "name": "getValidatorFaults", - "outputs": [ - { - "components": [ - { - "internalType": "uint8", - "name": "chunks", - "type": "uint8" - }, - { - "internalType": "uint8", - "name": "chunkId", - "type": "uint8" - }, - { - "internalType": "enum Accountability.EventType", - "name": "eventType", - "type": "uint8" - }, - { - "internalType": "enum Accountability.Rule", - "name": "rule", - "type": "uint8" - }, - { - "internalType": "address", - "name": "reporter", - "type": "address" - }, - { - "internalType": "address", - "name": "offender", - "type": "address" - }, - { - "internalType": "bytes", - "name": "rawProof", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "block", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reportingBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "messageHash", - "type": "uint256" - } - ], - "internalType": "struct Accountability.Event[]", - "name": "", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint8", - "name": "chunks", - "type": "uint8" - }, - { - "internalType": "uint8", - "name": "chunkId", - "type": "uint8" - }, - { - "internalType": "enum Accountability.EventType", - "name": "eventType", - "type": "uint8" - }, - { - "internalType": "enum Accountability.Rule", - "name": "rule", - "type": "uint8" - }, - { - "internalType": "address", - "name": "reporter", - "type": "address" - }, - { - "internalType": "address", - "name": "offender", - "type": "address" - }, - { - "internalType": "bytes", - "name": "rawProof", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "block", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reportingBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "messageHash", - "type": "uint256" - } - ], - "internalType": "struct Accountability.Event", - "name": "_event", - "type": "tuple" - } - ], - "name": "handleEvent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint8", - "name": "chunks", - "type": "uint8" - }, - { - "internalType": "uint8", - "name": "chunkId", - "type": "uint8" - }, - { - "internalType": "enum Accountability.EventType", - "name": "eventType", - "type": "uint8" - }, - { - "internalType": "enum Accountability.Rule", - "name": "rule", - "type": "uint8" - }, - { - "internalType": "address", - "name": "reporter", - "type": "address" - }, - { - "internalType": "address", - "name": "offender", - "type": "address" - }, - { - "internalType": "bytes", - "name": "rawProof", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "block", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reportingBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "messageHash", - "type": "uint256" - } - ], - "internalType": "struct Accountability.Event", - "name": "_event", - "type": "tuple" - } - ], - "name": "handleValidAccusation", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint8", - "name": "chunks", - "type": "uint8" - }, - { - "internalType": "uint8", - "name": "chunkId", - "type": "uint8" - }, - { - "internalType": "enum Accountability.EventType", - "name": "eventType", - "type": "uint8" - }, - { - "internalType": "enum Accountability.Rule", - "name": "rule", - "type": "uint8" - }, - { - "internalType": "address", - "name": "reporter", - "type": "address" - }, - { - "internalType": "address", - "name": "offender", - "type": "address" - }, - { - "internalType": "bytes", - "name": "rawProof", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "block", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reportingBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "messageHash", - "type": "uint256" - } - ], - "internalType": "struct Accountability.Event", - "name": "_event", - "type": "tuple" - } - ], - "name": "handleValidFaultProof", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint8", - "name": "chunks", - "type": "uint8" - }, - { - "internalType": "uint8", - "name": "chunkId", - "type": "uint8" - }, - { - "internalType": "enum Accountability.EventType", - "name": "eventType", - "type": "uint8" - }, - { - "internalType": "enum Accountability.Rule", - "name": "rule", - "type": "uint8" - }, - { - "internalType": "address", - "name": "reporter", - "type": "address" - }, - { - "internalType": "address", - "name": "offender", - "type": "address" - }, - { - "internalType": "bytes", - "name": "rawProof", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "block", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reportingBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "messageHash", - "type": "uint256" - } - ], - "internalType": "struct Accountability.Event", - "name": "_event", - "type": "tuple" - } - ], - "name": "handleValidInnocenceProof", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "performSlashingTasks", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "promoteGuiltyAccusations", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_newPeriod", - "type": "uint256" - } - ], - "name": "setEpochPeriod", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint8", - "name": "chunks", - "type": "uint8" - }, - { - "internalType": "uint8", - "name": "chunkId", - "type": "uint8" - }, - { - "internalType": "enum Accountability.EventType", - "name": "eventType", - "type": "uint8" - }, - { - "internalType": "enum Accountability.Rule", - "name": "rule", - "type": "uint8" - }, - { - "internalType": "address", - "name": "reporter", - "type": "address" - }, - { - "internalType": "address", - "name": "offender", - "type": "address" - }, - { - "internalType": "bytes", - "name": "rawProof", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "block", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reportingBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "messageHash", - "type": "uint256" - } - ], - "internalType": "struct Accountability.Event", - "name": "_event", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "_epochOffencesCount", - "type": "uint256" - } - ], - "name": "slash", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "slashingHistory", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/autonity/abi/Autonity.abi b/autonity/abi/Autonity.abi deleted file mode 100644 index 8c99c95..0000000 --- a/autonity/abi/Autonity.abi +++ /dev/null @@ -1,2268 +0,0 @@ -[ - { - "inputs": [ - { - "components": [ - { - "internalType": "address payable", - "name": "treasury", - "type": "address" - }, - { - "internalType": "address", - "name": "nodeAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "oracleAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "enode", - "type": "string" - }, - { - "internalType": "uint256", - "name": "commissionRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "bondedStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingShares", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfBondedStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingShares", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingStakeLocked", - "type": "uint256" - }, - { - "internalType": "contract Liquid", - "name": "liquidContract", - "type": "address" - }, - { - "internalType": "uint256", - "name": "liquidSupply", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "registrationBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalSlashed", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "jailReleaseBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "provableFaultCount", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "consensusKey", - "type": "bytes" - }, - { - "internalType": "enum ValidatorState", - "name": "state", - "type": "uint8" - } - ], - "internalType": "struct Autonity.Validator[]", - "name": "_validators", - "type": "tuple[]" - }, - { - "components": [ - { - "components": [ - { - "internalType": "uint256", - "name": "treasuryFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "minBaseFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "delegationRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingPeriod", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "initialInflationReserve", - "type": "uint256" - }, - { - "internalType": "address payable", - "name": "treasuryAccount", - "type": "address" - } - ], - "internalType": "struct Autonity.Policy", - "name": "policy", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "contract IAccountability", - "name": "accountabilityContract", - "type": "address" - }, - { - "internalType": "contract IOracle", - "name": "oracleContract", - "type": "address" - }, - { - "internalType": "contract IACU", - "name": "acuContract", - "type": "address" - }, - { - "internalType": "contract ISupplyControl", - "name": "supplyControlContract", - "type": "address" - }, - { - "internalType": "contract IStabilization", - "name": "stabilizationContract", - "type": "address" - }, - { - "internalType": "contract UpgradeManager", - "name": "upgradeManagerContract", - "type": "address" - }, - { - "internalType": "contract IInflationController", - "name": "inflationControllerContract", - "type": "address" - }, - { - "internalType": "contract INonStakableVestingVault", - "name": "nonStakableVestingContract", - "type": "address" - } - ], - "internalType": "struct Autonity.Contracts", - "name": "contracts", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "address", - "name": "operatorAccount", - "type": "address" - }, - { - "internalType": "uint256", - "name": "epochPeriod", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "blockPeriod", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "committeeSize", - "type": "uint256" - } - ], - "internalType": "struct Autonity.Protocol", - "name": "protocol", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "contractVersion", - "type": "uint256" - } - ], - "internalType": "struct Autonity.Config", - "name": "_config", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "treasury", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "effectiveBlock", - "type": "uint256" - } - ], - "name": "ActivatedValidator", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "selfBonded", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "AppliedUnbondingReverted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "enum ValidatorState", - "name": "state", - "type": "uint8" - } - ], - "name": "BondingRejected", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "BondingReverted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "BurnedStake", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "rate", - "type": "uint256" - } - ], - "name": "CommissionRateChange", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "period", - "type": "uint256" - } - ], - "name": "EpochPeriodUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "gasPrice", - "type": "uint256" - } - ], - "name": "MinimumBaseFeeUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "MintedStake", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "selfBonded", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "NewBondingRequest", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - } - ], - "name": "NewEpoch", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "selfBonded", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "NewUnbondingRequest", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "treasury", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "effectiveBlock", - "type": "uint256" - } - ], - "name": "PausedValidator", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "treasury", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "oracleAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "enode", - "type": "string" - }, - { - "indexed": false, - "internalType": "address", - "name": "liquidContract", - "type": "address" - } - ], - "name": "RegisteredValidator", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "selfBonded", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "ReleasedUnbondingReverted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "atnAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "ntnAmount", - "type": "uint256" - } - ], - "name": "Rewarded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "selfBonded", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "UnbondingRejected", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "epochTime", - "type": "uint256" - } - ], - "name": "UnlockingScheduleFailed", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "COMMISSION_RATE_PRECISION", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_address", - "type": "address" - } - ], - "name": "activateValidator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "atnTotalRedistributed", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_addr", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "bond", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_addr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "burn", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_rate", - "type": "uint256" - } - ], - "name": "changeCommissionRate", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "completeContractUpgrade", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "computeCommittee", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "config", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "treasuryFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "minBaseFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "delegationRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingPeriod", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "initialInflationReserve", - "type": "uint256" - }, - { - "internalType": "address payable", - "name": "treasuryAccount", - "type": "address" - } - ], - "internalType": "struct Autonity.Policy", - "name": "policy", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "contract IAccountability", - "name": "accountabilityContract", - "type": "address" - }, - { - "internalType": "contract IOracle", - "name": "oracleContract", - "type": "address" - }, - { - "internalType": "contract IACU", - "name": "acuContract", - "type": "address" - }, - { - "internalType": "contract ISupplyControl", - "name": "supplyControlContract", - "type": "address" - }, - { - "internalType": "contract IStabilization", - "name": "stabilizationContract", - "type": "address" - }, - { - "internalType": "contract UpgradeManager", - "name": "upgradeManagerContract", - "type": "address" - }, - { - "internalType": "contract IInflationController", - "name": "inflationControllerContract", - "type": "address" - }, - { - "internalType": "contract INonStakableVestingVault", - "name": "nonStakableVestingContract", - "type": "address" - } - ], - "internalType": "struct Autonity.Contracts", - "name": "contracts", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "address", - "name": "operatorAccount", - "type": "address" - }, - { - "internalType": "uint256", - "name": "epochPeriod", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "blockPeriod", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "committeeSize", - "type": "uint256" - } - ], - "internalType": "struct Autonity.Protocol", - "name": "protocol", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "contractVersion", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "deployer", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "epochID", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "epochReward", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "epochTotalBondedStake", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "finalize", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - }, - { - "components": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "votingPower", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "consensusKey", - "type": "bytes" - } - ], - "internalType": "struct Autonity.CommitteeMember[]", - "name": "", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "finalizeInitialization", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "getBlockPeriod", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCommittee", - "outputs": [ - { - "components": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "votingPower", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "consensusKey", - "type": "bytes" - } - ], - "internalType": "struct Autonity.CommitteeMember[]", - "name": "", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCommitteeEnodes", - "outputs": [ - { - "internalType": "string[]", - "name": "", - "type": "string[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_block", - "type": "uint256" - } - ], - "name": "getEpochFromBlock", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getEpochPeriod", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getLastEpochBlock", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getMaxCommitteeSize", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getMinimumBaseFee", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getNewContract", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - }, - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getOperator", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getOracle", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "height", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "round", - "type": "uint256" - } - ], - "name": "getProposer", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_unbondingID", - "type": "uint256" - } - ], - "name": "getRevertingAmount", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getTreasuryAccount", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getTreasuryFee", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getUnbondingPeriod", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_unbondingID", - "type": "uint256" - } - ], - "name": "getUnbondingReleaseState", - "outputs": [ - { - "internalType": "enum Autonity.UnbondingReleaseState", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_addr", - "type": "address" - } - ], - "name": "getValidator", - "outputs": [ - { - "components": [ - { - "internalType": "address payable", - "name": "treasury", - "type": "address" - }, - { - "internalType": "address", - "name": "nodeAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "oracleAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "enode", - "type": "string" - }, - { - "internalType": "uint256", - "name": "commissionRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "bondedStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingShares", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfBondedStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingShares", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingStakeLocked", - "type": "uint256" - }, - { - "internalType": "contract Liquid", - "name": "liquidContract", - "type": "address" - }, - { - "internalType": "uint256", - "name": "liquidSupply", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "registrationBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalSlashed", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "jailReleaseBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "provableFaultCount", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "consensusKey", - "type": "bytes" - }, - { - "internalType": "enum ValidatorState", - "name": "state", - "type": "uint8" - } - ], - "internalType": "struct Autonity.Validator", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getValidators", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getVersion", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "inflationReserve", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "lastEpochBlock", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "lastEpochTime", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maxBondAppliedGas", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maxRewardsDistributionGas", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maxUnbondAppliedGas", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maxUnbondReleasedGas", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_addr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_address", - "type": "address" - } - ], - "name": "pauseValidator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "receiveATN", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "_enode", - "type": "string" - }, - { - "internalType": "address", - "name": "_oracleAddress", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_consensusKey", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "_signatures", - "type": "bytes" - } - ], - "name": "registerValidator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "resetContractUpgrade", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IAccountability", - "name": "_address", - "type": "address" - } - ], - "name": "setAccountabilityContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IACU", - "name": "_address", - "type": "address" - } - ], - "name": "setAcuContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_size", - "type": "uint256" - } - ], - "name": "setCommitteeSize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_period", - "type": "uint256" - } - ], - "name": "setEpochPeriod", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IInflationController", - "name": "_address", - "type": "address" - } - ], - "name": "setInflationControllerContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_gas", - "type": "uint256" - } - ], - "name": "setMaxBondAppliedGas", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_gas", - "type": "uint256" - } - ], - "name": "setMaxRewardsDistributionGas", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_gas", - "type": "uint256" - } - ], - "name": "setMaxUnbondAppliedGas", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_gas", - "type": "uint256" - } - ], - "name": "setMaxUnbondReleasedGas", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_price", - "type": "uint256" - } - ], - "name": "setMinimumBaseFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract INonStakableVestingVault", - "name": "_address", - "type": "address" - } - ], - "name": "setNonStakableVestingContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_account", - "type": "address" - } - ], - "name": "setOperatorAccount", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address payable", - "name": "_address", - "type": "address" - } - ], - "name": "setOracleContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IStabilization", - "name": "_address", - "type": "address" - } - ], - "name": "setStabilizationContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_price", - "type": "uint256" - } - ], - "name": "setStakingGasPrice", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract ISupplyControl", - "name": "_address", - "type": "address" - } - ], - "name": "setSupplyControlContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address payable", - "name": "_account", - "type": "address" - } - ], - "name": "setTreasuryAccount", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_treasuryFee", - "type": "uint256" - } - ], - "name": "setTreasuryFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_period", - "type": "uint256" - } - ], - "name": "setUnbondingPeriod", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract UpgradeManager", - "name": "_address", - "type": "address" - } - ], - "name": "setUpgradeManagerContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "stakingGasPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_sender", - "type": "address" - }, - { - "internalType": "address", - "name": "_recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "unbond", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_nodeAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "_enode", - "type": "string" - } - ], - "name": "updateEnode", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address payable", - "name": "treasury", - "type": "address" - }, - { - "internalType": "address", - "name": "nodeAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "oracleAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "enode", - "type": "string" - }, - { - "internalType": "uint256", - "name": "commissionRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "bondedStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingShares", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfBondedStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingShares", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingStakeLocked", - "type": "uint256" - }, - { - "internalType": "contract Liquid", - "name": "liquidContract", - "type": "address" - }, - { - "internalType": "uint256", - "name": "liquidSupply", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "registrationBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalSlashed", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "jailReleaseBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "provableFaultCount", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "consensusKey", - "type": "bytes" - }, - { - "internalType": "enum ValidatorState", - "name": "state", - "type": "uint8" - } - ], - "internalType": "struct Autonity.Validator", - "name": "_val", - "type": "tuple" - } - ], - "name": "updateValidatorAndTransferSlashedFunds", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "_bytecode", - "type": "bytes" - }, - { - "internalType": "string", - "name": "_abi", - "type": "string" - } - ], - "name": "upgradeContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } -] diff --git a/autonity/abi/AutonityTest.abi b/autonity/abi/AutonityTest.abi deleted file mode 100644 index 4309348..0000000 --- a/autonity/abi/AutonityTest.abi +++ /dev/null @@ -1,2461 +0,0 @@ -[ - { - "inputs": [ - { - "components": [ - { - "internalType": "address payable", - "name": "treasury", - "type": "address" - }, - { - "internalType": "address", - "name": "nodeAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "oracleAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "enode", - "type": "string" - }, - { - "internalType": "uint256", - "name": "commissionRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "bondedStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingShares", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfBondedStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingShares", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingStakeLocked", - "type": "uint256" - }, - { - "internalType": "contract Liquid", - "name": "liquidContract", - "type": "address" - }, - { - "internalType": "uint256", - "name": "liquidSupply", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "registrationBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalSlashed", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "jailReleaseBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "provableFaultCount", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "consensusKey", - "type": "bytes" - }, - { - "internalType": "enum ValidatorState", - "name": "state", - "type": "uint8" - } - ], - "internalType": "struct Autonity.Validator[]", - "name": "_validators", - "type": "tuple[]" - }, - { - "components": [ - { - "components": [ - { - "internalType": "uint256", - "name": "treasuryFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "minBaseFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "delegationRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingPeriod", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "initialInflationReserve", - "type": "uint256" - }, - { - "internalType": "address payable", - "name": "treasuryAccount", - "type": "address" - } - ], - "internalType": "struct Autonity.Policy", - "name": "policy", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "contract IAccountability", - "name": "accountabilityContract", - "type": "address" - }, - { - "internalType": "contract IOracle", - "name": "oracleContract", - "type": "address" - }, - { - "internalType": "contract IACU", - "name": "acuContract", - "type": "address" - }, - { - "internalType": "contract ISupplyControl", - "name": "supplyControlContract", - "type": "address" - }, - { - "internalType": "contract IStabilization", - "name": "stabilizationContract", - "type": "address" - }, - { - "internalType": "contract UpgradeManager", - "name": "upgradeManagerContract", - "type": "address" - }, - { - "internalType": "contract IInflationController", - "name": "inflationControllerContract", - "type": "address" - }, - { - "internalType": "contract INonStakableVestingVault", - "name": "nonStakableVestingContract", - "type": "address" - } - ], - "internalType": "struct Autonity.Contracts", - "name": "contracts", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "address", - "name": "operatorAccount", - "type": "address" - }, - { - "internalType": "uint256", - "name": "epochPeriod", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "blockPeriod", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "committeeSize", - "type": "uint256" - } - ], - "internalType": "struct Autonity.Protocol", - "name": "protocol", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "contractVersion", - "type": "uint256" - } - ], - "internalType": "struct Autonity.Config", - "name": "_config", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "treasury", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "effectiveBlock", - "type": "uint256" - } - ], - "name": "ActivatedValidator", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "selfBonded", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "AppliedUnbondingReverted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "enum ValidatorState", - "name": "state", - "type": "uint8" - } - ], - "name": "BondingRejected", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "BondingReverted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "BurnedStake", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "rate", - "type": "uint256" - } - ], - "name": "CommissionRateChange", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "period", - "type": "uint256" - } - ], - "name": "EpochPeriodUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "gasPrice", - "type": "uint256" - } - ], - "name": "MinimumBaseFeeUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "MintedStake", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "selfBonded", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "NewBondingRequest", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - } - ], - "name": "NewEpoch", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "selfBonded", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "NewUnbondingRequest", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "treasury", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "effectiveBlock", - "type": "uint256" - } - ], - "name": "PausedValidator", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "treasury", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "oracleAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "enode", - "type": "string" - }, - { - "indexed": false, - "internalType": "address", - "name": "liquidContract", - "type": "address" - } - ], - "name": "RegisteredValidator", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "selfBonded", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "ReleasedUnbondingReverted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "atnAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "ntnAmount", - "type": "uint256" - } - ], - "name": "Rewarded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "selfBonded", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "UnbondingRejected", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "epochTime", - "type": "uint256" - } - ], - "name": "UnlockingScheduleFailed", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "COMMISSION_RATE_PRECISION", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_address", - "type": "address" - } - ], - "name": "activateValidator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "applyNewCommissionRates", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "applyStakingOperations", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "atnTotalRedistributed", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_addr", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "bond", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_addr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "burn", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_rate", - "type": "uint256" - } - ], - "name": "changeCommissionRate", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "completeContractUpgrade", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "computeCommittee", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "config", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "treasuryFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "minBaseFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "delegationRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingPeriod", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "initialInflationReserve", - "type": "uint256" - }, - { - "internalType": "address payable", - "name": "treasuryAccount", - "type": "address" - } - ], - "internalType": "struct Autonity.Policy", - "name": "policy", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "contract IAccountability", - "name": "accountabilityContract", - "type": "address" - }, - { - "internalType": "contract IOracle", - "name": "oracleContract", - "type": "address" - }, - { - "internalType": "contract IACU", - "name": "acuContract", - "type": "address" - }, - { - "internalType": "contract ISupplyControl", - "name": "supplyControlContract", - "type": "address" - }, - { - "internalType": "contract IStabilization", - "name": "stabilizationContract", - "type": "address" - }, - { - "internalType": "contract UpgradeManager", - "name": "upgradeManagerContract", - "type": "address" - }, - { - "internalType": "contract IInflationController", - "name": "inflationControllerContract", - "type": "address" - }, - { - "internalType": "contract INonStakableVestingVault", - "name": "nonStakableVestingContract", - "type": "address" - } - ], - "internalType": "struct Autonity.Contracts", - "name": "contracts", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "address", - "name": "operatorAccount", - "type": "address" - }, - { - "internalType": "uint256", - "name": "epochPeriod", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "blockPeriod", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "committeeSize", - "type": "uint256" - } - ], - "internalType": "struct Autonity.Protocol", - "name": "protocol", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "contractVersion", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "deployer", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "epochID", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "epochReward", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "epochTotalBondedStake", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "finalize", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - }, - { - "components": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "votingPower", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "consensusKey", - "type": "bytes" - } - ], - "internalType": "struct Autonity.CommitteeMember[]", - "name": "", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "finalizeInitialization", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "getBlockPeriod", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "getBondingRequest", - "outputs": [ - { - "components": [ - { - "internalType": "address payable", - "name": "delegator", - "type": "address" - }, - { - "internalType": "address", - "name": "delegatee", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "requestBlock", - "type": "uint256" - } - ], - "internalType": "struct Autonity.BondingRequest", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCommittee", - "outputs": [ - { - "components": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "votingPower", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "consensusKey", - "type": "bytes" - } - ], - "internalType": "struct Autonity.CommitteeMember[]", - "name": "", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCommitteeEnodes", - "outputs": [ - { - "internalType": "string[]", - "name": "", - "type": "string[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_block", - "type": "uint256" - } - ], - "name": "getEpochFromBlock", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getEpochPeriod", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getEpochTotalBondedStake", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getHeadBondingID", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getHeadUnbondingID", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getLastEpochBlock", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getLastUnlockedUnbonding", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getMaxCommitteeSize", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getMinimumBaseFee", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getNewContract", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - }, - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getOperator", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getOracle", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "height", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "round", - "type": "uint256" - } - ], - "name": "getProposer", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_unbondingID", - "type": "uint256" - } - ], - "name": "getRevertingAmount", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getTailBondingID", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getTreasuryAccount", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getTreasuryFee", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getUnbondingPeriod", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_unbondingID", - "type": "uint256" - } - ], - "name": "getUnbondingReleaseState", - "outputs": [ - { - "internalType": "enum Autonity.UnbondingReleaseState", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "getUnbondingRequest", - "outputs": [ - { - "components": [ - { - "internalType": "address payable", - "name": "delegator", - "type": "address" - }, - { - "internalType": "address", - "name": "delegatee", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingShare", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "requestBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "revertingAmount", - "type": "uint256" - }, - { - "internalType": "enum Autonity.UnbondingReleaseState", - "name": "state", - "type": "uint8" - }, - { - "internalType": "bool", - "name": "unlocked", - "type": "bool" - }, - { - "internalType": "bool", - "name": "selfDelegation", - "type": "bool" - } - ], - "internalType": "struct Autonity.UnbondingRequest", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_addr", - "type": "address" - } - ], - "name": "getValidator", - "outputs": [ - { - "components": [ - { - "internalType": "address payable", - "name": "treasury", - "type": "address" - }, - { - "internalType": "address", - "name": "nodeAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "oracleAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "enode", - "type": "string" - }, - { - "internalType": "uint256", - "name": "commissionRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "bondedStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingShares", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfBondedStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingShares", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingStakeLocked", - "type": "uint256" - }, - { - "internalType": "contract Liquid", - "name": "liquidContract", - "type": "address" - }, - { - "internalType": "uint256", - "name": "liquidSupply", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "registrationBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalSlashed", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "jailReleaseBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "provableFaultCount", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "consensusKey", - "type": "bytes" - }, - { - "internalType": "enum ValidatorState", - "name": "state", - "type": "uint8" - } - ], - "internalType": "struct Autonity.Validator", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getValidators", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getVersion", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "inflationReserve", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "lastEpochBlock", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "lastEpochTime", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maxBondAppliedGas", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maxRewardsDistributionGas", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maxUnbondAppliedGas", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maxUnbondReleasedGas", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_addr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_address", - "type": "address" - } - ], - "name": "pauseValidator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "receiveATN", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "_enode", - "type": "string" - }, - { - "internalType": "address", - "name": "_oracleAddress", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_consensusKey", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "_signatures", - "type": "bytes" - } - ], - "name": "registerValidator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "resetContractUpgrade", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IAccountability", - "name": "_address", - "type": "address" - } - ], - "name": "setAccountabilityContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IACU", - "name": "_address", - "type": "address" - } - ], - "name": "setAcuContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_size", - "type": "uint256" - } - ], - "name": "setCommitteeSize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_period", - "type": "uint256" - } - ], - "name": "setEpochPeriod", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IInflationController", - "name": "_address", - "type": "address" - } - ], - "name": "setInflationControllerContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_gas", - "type": "uint256" - } - ], - "name": "setMaxBondAppliedGas", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_gas", - "type": "uint256" - } - ], - "name": "setMaxRewardsDistributionGas", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_gas", - "type": "uint256" - } - ], - "name": "setMaxUnbondAppliedGas", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_gas", - "type": "uint256" - } - ], - "name": "setMaxUnbondReleasedGas", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_price", - "type": "uint256" - } - ], - "name": "setMinimumBaseFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract INonStakableVestingVault", - "name": "_address", - "type": "address" - } - ], - "name": "setNonStakableVestingContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_account", - "type": "address" - } - ], - "name": "setOperatorAccount", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address payable", - "name": "_address", - "type": "address" - } - ], - "name": "setOracleContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IStabilization", - "name": "_address", - "type": "address" - } - ], - "name": "setStabilizationContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_price", - "type": "uint256" - } - ], - "name": "setStakingGasPrice", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract ISupplyControl", - "name": "_address", - "type": "address" - } - ], - "name": "setSupplyControlContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address payable", - "name": "_account", - "type": "address" - } - ], - "name": "setTreasuryAccount", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_treasuryFee", - "type": "uint256" - } - ], - "name": "setTreasuryFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_period", - "type": "uint256" - } - ], - "name": "setUnbondingPeriod", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract UpgradeManager", - "name": "_address", - "type": "address" - } - ], - "name": "setUpgradeManagerContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "stakingGasPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "testComputeCommittee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_sender", - "type": "address" - }, - { - "internalType": "address", - "name": "_recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "unbond", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_nodeAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "_enode", - "type": "string" - } - ], - "name": "updateEnode", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address payable", - "name": "treasury", - "type": "address" - }, - { - "internalType": "address", - "name": "nodeAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "oracleAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "enode", - "type": "string" - }, - { - "internalType": "uint256", - "name": "commissionRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "bondedStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingShares", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfBondedStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingShares", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingStakeLocked", - "type": "uint256" - }, - { - "internalType": "contract Liquid", - "name": "liquidContract", - "type": "address" - }, - { - "internalType": "uint256", - "name": "liquidSupply", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "registrationBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalSlashed", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "jailReleaseBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "provableFaultCount", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "consensusKey", - "type": "bytes" - }, - { - "internalType": "enum ValidatorState", - "name": "state", - "type": "uint8" - } - ], - "internalType": "struct Autonity.Validator", - "name": "_val", - "type": "tuple" - } - ], - "name": "updateValidatorAndTransferSlashedFunds", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "_bytecode", - "type": "bytes" - }, - { - "internalType": "string", - "name": "_abi", - "type": "string" - } - ], - "name": "upgradeContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } -] diff --git a/autonity/abi/AutonityUpgradeTest.abi b/autonity/abi/AutonityUpgradeTest.abi deleted file mode 100644 index 3a96ba8..0000000 --- a/autonity/abi/AutonityUpgradeTest.abi +++ /dev/null @@ -1,2037 +0,0 @@ -[ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "treasury", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "effectiveBlock", - "type": "uint256" - } - ], - "name": "ActivatedValidator", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "selfBonded", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "AppliedUnbondingReverted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "enum ValidatorState", - "name": "state", - "type": "uint8" - } - ], - "name": "BondingRejected", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "BondingReverted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "BurnedStake", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "rate", - "type": "uint256" - } - ], - "name": "CommissionRateChange", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "period", - "type": "uint256" - } - ], - "name": "EpochPeriodUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "gasPrice", - "type": "uint256" - } - ], - "name": "MinimumBaseFeeUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "MintedStake", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "selfBonded", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "NewBondingRequest", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - } - ], - "name": "NewEpoch", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "selfBonded", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "NewUnbondingRequest", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "treasury", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "effectiveBlock", - "type": "uint256" - } - ], - "name": "PausedValidator", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "treasury", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "oracleAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "enode", - "type": "string" - }, - { - "indexed": false, - "internalType": "address", - "name": "liquidContract", - "type": "address" - } - ], - "name": "RegisteredValidator", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "selfBonded", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "ReleasedUnbondingReverted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "atnAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "ntnAmount", - "type": "uint256" - } - ], - "name": "Rewarded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "selfBonded", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "UnbondingRejected", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "epochTime", - "type": "uint256" - } - ], - "name": "UnlockingScheduleFailed", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "COMMISSION_RATE_PRECISION", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_address", - "type": "address" - } - ], - "name": "activateValidator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "atnTotalRedistributed", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_addr", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "bond", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_addr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "burn", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_rate", - "type": "uint256" - } - ], - "name": "changeCommissionRate", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "completeContractUpgrade", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "computeCommittee", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "config", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "treasuryFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "minBaseFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "delegationRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingPeriod", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "initialInflationReserve", - "type": "uint256" - }, - { - "internalType": "address payable", - "name": "treasuryAccount", - "type": "address" - } - ], - "internalType": "struct Autonity.Policy", - "name": "policy", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "contract IAccountability", - "name": "accountabilityContract", - "type": "address" - }, - { - "internalType": "contract IOracle", - "name": "oracleContract", - "type": "address" - }, - { - "internalType": "contract IACU", - "name": "acuContract", - "type": "address" - }, - { - "internalType": "contract ISupplyControl", - "name": "supplyControlContract", - "type": "address" - }, - { - "internalType": "contract IStabilization", - "name": "stabilizationContract", - "type": "address" - }, - { - "internalType": "contract UpgradeManager", - "name": "upgradeManagerContract", - "type": "address" - }, - { - "internalType": "contract IInflationController", - "name": "inflationControllerContract", - "type": "address" - }, - { - "internalType": "contract INonStakableVestingVault", - "name": "nonStakableVestingContract", - "type": "address" - } - ], - "internalType": "struct Autonity.Contracts", - "name": "contracts", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "address", - "name": "operatorAccount", - "type": "address" - }, - { - "internalType": "uint256", - "name": "epochPeriod", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "blockPeriod", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "committeeSize", - "type": "uint256" - } - ], - "internalType": "struct Autonity.Protocol", - "name": "protocol", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "contractVersion", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "deployer", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "epochID", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "epochReward", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "epochTotalBondedStake", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "finalize", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - }, - { - "components": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "votingPower", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "consensusKey", - "type": "bytes" - } - ], - "internalType": "struct Autonity.CommitteeMember[]", - "name": "", - "type": "tuple[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "finalizeInitialization", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "getBlockPeriod", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCommittee", - "outputs": [ - { - "components": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "votingPower", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "consensusKey", - "type": "bytes" - } - ], - "internalType": "struct Autonity.CommitteeMember[]", - "name": "", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCommitteeEnodes", - "outputs": [ - { - "internalType": "string[]", - "name": "", - "type": "string[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_block", - "type": "uint256" - } - ], - "name": "getEpochFromBlock", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getEpochPeriod", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getLastEpochBlock", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getMaxCommitteeSize", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getMinimumBaseFee", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getNewContract", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - }, - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getOperator", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getOracle", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "height", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "round", - "type": "uint256" - } - ], - "name": "getProposer", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_unbondingID", - "type": "uint256" - } - ], - "name": "getRevertingAmount", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getTreasuryAccount", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getTreasuryFee", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getUnbondingPeriod", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_unbondingID", - "type": "uint256" - } - ], - "name": "getUnbondingReleaseState", - "outputs": [ - { - "internalType": "enum Autonity.UnbondingReleaseState", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_addr", - "type": "address" - } - ], - "name": "getValidator", - "outputs": [ - { - "components": [ - { - "internalType": "address payable", - "name": "treasury", - "type": "address" - }, - { - "internalType": "address", - "name": "nodeAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "oracleAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "enode", - "type": "string" - }, - { - "internalType": "uint256", - "name": "commissionRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "bondedStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingShares", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfBondedStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingShares", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingStakeLocked", - "type": "uint256" - }, - { - "internalType": "contract Liquid", - "name": "liquidContract", - "type": "address" - }, - { - "internalType": "uint256", - "name": "liquidSupply", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "registrationBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalSlashed", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "jailReleaseBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "provableFaultCount", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "consensusKey", - "type": "bytes" - }, - { - "internalType": "enum ValidatorState", - "name": "state", - "type": "uint8" - } - ], - "internalType": "struct Autonity.Validator", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getValidators", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getVersion", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "inflationReserve", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "lastEpochBlock", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "lastEpochTime", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maxBondAppliedGas", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maxRewardsDistributionGas", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maxUnbondAppliedGas", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maxUnbondReleasedGas", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_addr", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_address", - "type": "address" - } - ], - "name": "pauseValidator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "receiveATN", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "_enode", - "type": "string" - }, - { - "internalType": "address", - "name": "_oracleAddress", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_consensusKey", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "_signatures", - "type": "bytes" - } - ], - "name": "registerValidator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "resetContractUpgrade", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IAccountability", - "name": "_address", - "type": "address" - } - ], - "name": "setAccountabilityContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IACU", - "name": "_address", - "type": "address" - } - ], - "name": "setAcuContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_size", - "type": "uint256" - } - ], - "name": "setCommitteeSize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_period", - "type": "uint256" - } - ], - "name": "setEpochPeriod", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IInflationController", - "name": "_address", - "type": "address" - } - ], - "name": "setInflationControllerContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_gas", - "type": "uint256" - } - ], - "name": "setMaxBondAppliedGas", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_gas", - "type": "uint256" - } - ], - "name": "setMaxRewardsDistributionGas", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_gas", - "type": "uint256" - } - ], - "name": "setMaxUnbondAppliedGas", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_gas", - "type": "uint256" - } - ], - "name": "setMaxUnbondReleasedGas", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_price", - "type": "uint256" - } - ], - "name": "setMinimumBaseFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract INonStakableVestingVault", - "name": "_address", - "type": "address" - } - ], - "name": "setNonStakableVestingContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_account", - "type": "address" - } - ], - "name": "setOperatorAccount", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address payable", - "name": "_address", - "type": "address" - } - ], - "name": "setOracleContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IStabilization", - "name": "_address", - "type": "address" - } - ], - "name": "setStabilizationContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_price", - "type": "uint256" - } - ], - "name": "setStakingGasPrice", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract ISupplyControl", - "name": "_address", - "type": "address" - } - ], - "name": "setSupplyControlContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address payable", - "name": "_account", - "type": "address" - } - ], - "name": "setTreasuryAccount", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_treasuryFee", - "type": "uint256" - } - ], - "name": "setTreasuryFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_period", - "type": "uint256" - } - ], - "name": "setUnbondingPeriod", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract UpgradeManager", - "name": "_address", - "type": "address" - } - ], - "name": "setUpgradeManagerContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "stakingGasPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_sender", - "type": "address" - }, - { - "internalType": "address", - "name": "_recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "unbond", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_nodeAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "_enode", - "type": "string" - } - ], - "name": "updateEnode", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address payable", - "name": "treasury", - "type": "address" - }, - { - "internalType": "address", - "name": "nodeAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "oracleAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "enode", - "type": "string" - }, - { - "internalType": "uint256", - "name": "commissionRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "bondedStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unbondingShares", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfBondedStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingStake", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingShares", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "selfUnbondingStakeLocked", - "type": "uint256" - }, - { - "internalType": "contract Liquid", - "name": "liquidContract", - "type": "address" - }, - { - "internalType": "uint256", - "name": "liquidSupply", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "registrationBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalSlashed", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "jailReleaseBlock", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "provableFaultCount", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "consensusKey", - "type": "bytes" - }, - { - "internalType": "enum ValidatorState", - "name": "state", - "type": "uint8" - } - ], - "internalType": "struct Autonity.Validator", - "name": "_val", - "type": "tuple" - } - ], - "name": "updateValidatorAndTransferSlashedFunds", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "_bytecode", - "type": "bytes" - }, - { - "internalType": "string", - "name": "_abi", - "type": "string" - } - ], - "name": "upgradeContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } -] diff --git a/autonity/abi/BytesLib.abi b/autonity/abi/BytesLib.abi deleted file mode 100644 index fe51488..0000000 --- a/autonity/abi/BytesLib.abi +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/autonity/abi/ContractBase.abi b/autonity/abi/ContractBase.abi deleted file mode 100644 index 187fe5d..0000000 --- a/autonity/abi/ContractBase.abi +++ /dev/null @@ -1,168 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address payable", - "name": "_autonity", - "type": "address" - }, - { - "internalType": "address", - "name": "_operator", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "canStake", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "getContract", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "currentNTNAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "withdrawnValue", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "start", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "cliffDuration", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalDuration", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "canStake", - "type": "bool" - } - ], - "internalType": "struct ContractBase.Contract", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - } - ], - "name": "getContracts", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "currentNTNAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "withdrawnValue", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "start", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "cliffDuration", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalDuration", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "canStake", - "type": "bool" - } - ], - "internalType": "struct ContractBase.Contract[]", - "name": "", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - } - ], - "name": "totalContracts", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/autonity/abi/Helpers.abi b/autonity/abi/Helpers.abi deleted file mode 100644 index fe51488..0000000 --- a/autonity/abi/Helpers.abi +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/autonity/abi/IACU.abi b/autonity/abi/IACU.abi deleted file mode 100644 index fc6c6ab..0000000 --- a/autonity/abi/IACU.abi +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address", - "name": "operator", - "type": "address" - } - ], - "name": "setOperator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "oracle", - "type": "address" - } - ], - "name": "setOracle", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "update", - "outputs": [ - { - "internalType": "bool", - "name": "status", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/autonity/abi/IAccountability.abi b/autonity/abi/IAccountability.abi deleted file mode 100644 index 6bbd842..0000000 --- a/autonity/abi/IAccountability.abi +++ /dev/null @@ -1,152 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_offender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "InnocenceProven", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_offender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_severity", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "NewAccusation", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_offender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_severity", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "NewFaultProof", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "validator", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "releaseBlock", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bool", - "name": "isJailbound", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "eventId", - "type": "uint256" - } - ], - "name": "SlashingEvent", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_ntnReward", - "type": "uint256" - } - ], - "name": "distributeRewards", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "_epochEnd", - "type": "bool" - } - ], - "name": "finalize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_newPeriod", - "type": "uint256" - } - ], - "name": "setEpochPeriod", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/autonity/abi/IAutonity.abi b/autonity/abi/IAutonity.abi deleted file mode 100644 index 5f0e202..0000000 --- a/autonity/abi/IAutonity.abi +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "inputs": [], - "name": "getOperator", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getOracle", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/autonity/abi/IERC20.abi b/autonity/abi/IERC20.abi deleted file mode 100644 index ea3bb35..0000000 --- a/autonity/abi/IERC20.abi +++ /dev/null @@ -1,185 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/autonity/abi/IInflationController.abi b/autonity/abi/IInflationController.abi deleted file mode 100644 index a40b96d..0000000 --- a/autonity/abi/IInflationController.abi +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "uint256", - "name": "_currentSupply", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_inflationReserve", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_lastEpochTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_currentEpochTime", - "type": "uint256" - } - ], - "name": "calculateSupplyDelta", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/autonity/abi/INonStakableVestingVault.abi b/autonity/abi/INonStakableVestingVault.abi deleted file mode 100644 index b01f2c5..0000000 --- a/autonity/abi/INonStakableVestingVault.abi +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - "inputs": [], - "name": "unlockTokens", - "outputs": [ - { - "internalType": "uint256", - "name": "_newUnlockedSubscribed", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_newUnlockedUnsubscribed", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/autonity/abi/IOracle.abi b/autonity/abi/IOracle.abi deleted file mode 100644 index ee019fc..0000000 --- a/autonity/abi/IOracle.abi +++ /dev/null @@ -1,298 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "_round", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_height", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_timestamp", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_votePeriod", - "type": "uint256" - } - ], - "name": "NewRound", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string[]", - "name": "_symbols", - "type": "string[]" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_round", - "type": "uint256" - } - ], - "name": "NewSymbols", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_voter", - "type": "address" - }, - { - "indexed": false, - "internalType": "int256[]", - "name": "_votes", - "type": "int256[]" - } - ], - "name": "Voted", - "type": "event" - }, - { - "inputs": [], - "name": "finalize", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "getPrecision", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getRound", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_round", - "type": "uint256" - }, - { - "internalType": "string", - "name": "_symbol", - "type": "string" - } - ], - "name": "getRoundData", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "round", - "type": "uint256" - }, - { - "internalType": "int256", - "name": "price", - "type": "int256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "success", - "type": "bool" - } - ], - "internalType": "struct IOracle.RoundData", - "name": "data", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getSymbols", - "outputs": [ - { - "internalType": "string[]", - "name": "_symbols", - "type": "string[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getVotePeriod", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getVoters", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "_symbol", - "type": "string" - } - ], - "name": "latestRoundData", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "round", - "type": "uint256" - }, - { - "internalType": "int256", - "name": "price", - "type": "int256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "success", - "type": "bool" - } - ], - "internalType": "struct IOracle.RoundData", - "name": "data", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_operator", - "type": "address" - } - ], - "name": "setOperator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string[]", - "name": "_symbols", - "type": "string[]" - } - ], - "name": "setSymbols", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "_newVoters", - "type": "address[]" - } - ], - "name": "setVoters", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_commit", - "type": "uint256" - }, - { - "internalType": "int256[]", - "name": "_reports", - "type": "int256[]" - }, - { - "internalType": "uint256", - "name": "_salt", - "type": "uint256" - } - ], - "name": "vote", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/autonity/abi/IStabilization.abi b/autonity/abi/IStabilization.abi deleted file mode 100644 index da73fd7..0000000 --- a/autonity/abi/IStabilization.abi +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address", - "name": "operator", - "type": "address" - } - ], - "name": "setOperator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "oracle", - "type": "address" - } - ], - "name": "setOracle", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/autonity/abi/IStakeProxy.abi b/autonity/abi/IStakeProxy.abi deleted file mode 100644 index 9f67ad8..0000000 --- a/autonity/abi/IStakeProxy.abi +++ /dev/null @@ -1,101 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "uint256", - "name": "_bondingID", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_liquid", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "_selfDelegation", - "type": "bool" - }, - { - "internalType": "bool", - "name": "_rejected", - "type": "bool" - } - ], - "name": "bondingApplied", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "receiveATN", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "_validators", - "type": "address[]" - } - ], - "name": "rewardsDistributed", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_unbondingID", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "bool", - "name": "_rejected", - "type": "bool" - } - ], - "name": "unbondingApplied", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_unbondingID", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "_rejected", - "type": "bool" - } - ], - "name": "unbondingReleased", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/autonity/abi/ISupplyControl.abi b/autonity/abi/ISupplyControl.abi deleted file mode 100644 index 8cb19a1..0000000 --- a/autonity/abi/ISupplyControl.abi +++ /dev/null @@ -1,124 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Burn", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Mint", - "type": "event" - }, - { - "inputs": [], - "name": "availableSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "burn", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "operator", - "type": "address" - } - ], - "name": "setOperator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "stabilizer_", - "type": "address" - } - ], - "name": "setStabilizer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "stabilizer", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/autonity/abi/InflationController.abi b/autonity/abi/InflationController.abi deleted file mode 100644 index ee45413..0000000 --- a/autonity/abi/InflationController.abi +++ /dev/null @@ -1,230 +0,0 @@ -[ - { - "inputs": [ - { - "components": [ - { - "internalType": "SD59x18", - "name": "inflationRateInitial", - "type": "int256" - }, - { - "internalType": "SD59x18", - "name": "inflationRateTransition", - "type": "int256" - }, - { - "internalType": "SD59x18", - "name": "inflationCurveConvexity", - "type": "int256" - }, - { - "internalType": "SD59x18", - "name": "inflationTransitionPeriod", - "type": "int256" - }, - { - "internalType": "SD59x18", - "name": "inflationReserveDecayRate", - "type": "int256" - } - ], - "internalType": "struct InflationController.Params", - "name": "_params", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "x", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "y", - "type": "uint256" - } - ], - "name": "PRBMath_MulDiv18_Overflow", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "x", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "y", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "denominator", - "type": "uint256" - } - ], - "name": "PRBMath_MulDiv_Overflow", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "int256", - "name": "x", - "type": "int256" - } - ], - "name": "PRBMath_SD59x18_Convert_Overflow", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "int256", - "name": "x", - "type": "int256" - } - ], - "name": "PRBMath_SD59x18_Convert_Underflow", - "type": "error" - }, - { - "inputs": [], - "name": "PRBMath_SD59x18_Div_InputTooSmall", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "SD59x18", - "name": "x", - "type": "int256" - }, - { - "internalType": "SD59x18", - "name": "y", - "type": "int256" - } - ], - "name": "PRBMath_SD59x18_Div_Overflow", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "SD59x18", - "name": "x", - "type": "int256" - } - ], - "name": "PRBMath_SD59x18_Exp2_InputTooBig", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "SD59x18", - "name": "x", - "type": "int256" - } - ], - "name": "PRBMath_SD59x18_Exp_InputTooBig", - "type": "error" - }, - { - "inputs": [], - "name": "PRBMath_SD59x18_Mul_InputTooSmall", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "SD59x18", - "name": "x", - "type": "int256" - }, - { - "internalType": "SD59x18", - "name": "y", - "type": "int256" - } - ], - "name": "PRBMath_SD59x18_Mul_Overflow", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_currentSupply", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_inflationReserve", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_lastEpochTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_currentEpochTime", - "type": "uint256" - } - ], - "name": "calculateSupplyDelta", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "params", - "outputs": [ - { - "internalType": "SD59x18", - "name": "inflationRateInitial", - "type": "int256" - }, - { - "internalType": "SD59x18", - "name": "inflationRateTransition", - "type": "int256" - }, - { - "internalType": "SD59x18", - "name": "inflationCurveConvexity", - "type": "int256" - }, - { - "internalType": "SD59x18", - "name": "inflationTransitionPeriod", - "type": "int256" - }, - { - "internalType": "SD59x18", - "name": "inflationReserveDecayRate", - "type": "int256" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/autonity/abi/Liquid.abi b/autonity/abi/Liquid.abi deleted file mode 100644 index e299b73..0000000 --- a/autonity/abi/Liquid.abi +++ /dev/null @@ -1,493 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "address payable", - "name": "_treasury", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_commissionRate", - "type": "uint256" - }, - { - "internalType": "string", - "name": "_index", - "type": "string" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "inputs": [], - "name": "COMMISSION_RATE_PRECISION", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "FEE_FACTOR_UNIT_RECIP", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_owner", - "type": "address" - }, - { - "internalType": "address", - "name": "_spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_delegator", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_account", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "burn", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "claimRewards", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "commissionRate", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_account", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "lock", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_delegator", - "type": "address" - } - ], - "name": "lockedBalanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_account", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_ntnReward", - "type": "uint256" - } - ], - "name": "redistribute", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_rate", - "type": "uint256" - } - ], - "name": "setCommissionRate", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "_success", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_sender", - "type": "address" - }, - { - "internalType": "address", - "name": "_recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "_success", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "treasury", - "outputs": [ - { - "internalType": "address payable", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_account", - "type": "address" - } - ], - "name": "unclaimedRewards", - "outputs": [ - { - "internalType": "uint256", - "name": "_unclaimedATN", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_unclaimedNTN", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_account", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "unlock", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_delegator", - "type": "address" - } - ], - "name": "unlockedBalanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "validator", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/autonity/abi/LiquidRewardManager.abi b/autonity/abi/LiquidRewardManager.abi deleted file mode 100644 index ede1074..0000000 --- a/autonity/abi/LiquidRewardManager.abi +++ /dev/null @@ -1,26 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address payable", - "name": "_autonity", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "FEE_FACTOR_UNIT_RECIP", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/autonity/abi/NonStakableVesting.abi b/autonity/abi/NonStakableVesting.abi deleted file mode 100644 index 8be63ff..0000000 --- a/autonity/abi/NonStakableVesting.abi +++ /dev/null @@ -1,428 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address payable", - "name": "_autonity", - "type": "address" - }, - { - "internalType": "address", - "name": "_operator", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "canStake", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_recipient", - "type": "address" - } - ], - "name": "changeContractBeneficiary", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_startTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_cliffDuration", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_totalDuration", - "type": "uint256" - } - ], - "name": "createSchedule", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "getContract", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "currentNTNAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "withdrawnValue", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "start", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "cliffDuration", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalDuration", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "canStake", - "type": "bool" - } - ], - "internalType": "struct ContractBase.Contract", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - } - ], - "name": "getContracts", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "currentNTNAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "withdrawnValue", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "start", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "cliffDuration", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalDuration", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "canStake", - "type": "bool" - } - ], - "internalType": "struct ContractBase.Contract[]", - "name": "", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "getSchedule", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "start", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "cliffDuration", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalDuration", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "unsubscribedAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalUnlocked", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalUnlockedUnsubscribed", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "lastUnlockTime", - "type": "uint256" - } - ], - "internalType": "struct NonStakableVesting.Schedule", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maxAllowedDuration", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_scheduleID", - "type": "uint256" - } - ], - "name": "newContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "releaseAllFunds", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "releaseFund", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_newMaxDuration", - "type": "uint256" - } - ], - "name": "setMaxAllowedDuration", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_totalNominal", - "type": "uint256" - } - ], - "name": "setTotalNominal", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - } - ], - "name": "totalContracts", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalNominal", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "unlockTokens", - "outputs": [ - { - "internalType": "uint256", - "name": "_newUnlockedSubscribed", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_newUnlockedUnsubscribed", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "unlockedFunds", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/autonity/abi/Oracle.abi b/autonity/abi/Oracle.abi deleted file mode 100644 index c857d32..0000000 --- a/autonity/abi/Oracle.abi +++ /dev/null @@ -1,493 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address[]", - "name": "_voters", - "type": "address[]" - }, - { - "internalType": "address", - "name": "_autonity", - "type": "address" - }, - { - "internalType": "address", - "name": "_operator", - "type": "address" - }, - { - "internalType": "string[]", - "name": "_symbols", - "type": "string[]" - }, - { - "internalType": "uint256", - "name": "_votePeriod", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "_round", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_height", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_timestamp", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_votePeriod", - "type": "uint256" - } - ], - "name": "NewRound", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string[]", - "name": "_symbols", - "type": "string[]" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_round", - "type": "uint256" - } - ], - "name": "NewSymbols", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_voter", - "type": "address" - }, - { - "indexed": false, - "internalType": "int256[]", - "name": "_votes", - "type": "int256[]" - } - ], - "name": "Voted", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "finalize", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "getPrecision", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "getRound", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_round", - "type": "uint256" - }, - { - "internalType": "string", - "name": "_symbol", - "type": "string" - } - ], - "name": "getRoundData", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "round", - "type": "uint256" - }, - { - "internalType": "int256", - "name": "price", - "type": "int256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "success", - "type": "bool" - } - ], - "internalType": "struct IOracle.RoundData", - "name": "data", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getSymbols", - "outputs": [ - { - "internalType": "string[]", - "name": "", - "type": "string[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getVotePeriod", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getVoters", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "lastRoundBlock", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "lastVoterUpdateRound", - "outputs": [ - { - "internalType": "int256", - "name": "", - "type": "int256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "_symbol", - "type": "string" - } - ], - "name": "latestRoundData", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "round", - "type": "uint256" - }, - { - "internalType": "int256", - "name": "price", - "type": "int256" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "success", - "type": "bool" - } - ], - "internalType": "struct IOracle.RoundData", - "name": "data", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "newSymbols", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - }, - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "reports", - "outputs": [ - { - "internalType": "int256", - "name": "", - "type": "int256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "round", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_operator", - "type": "address" - } - ], - "name": "setOperator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string[]", - "name": "_symbols", - "type": "string[]" - } - ], - "name": "setSymbols", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "_newVoters", - "type": "address[]" - } - ], - "name": "setVoters", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "symbolUpdatedRound", - "outputs": [ - { - "internalType": "int256", - "name": "", - "type": "int256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "symbols", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_commit", - "type": "uint256" - }, - { - "internalType": "int256[]", - "name": "_reports", - "type": "int256[]" - }, - { - "internalType": "uint256", - "name": "_salt", - "type": "uint256" - } - ], - "name": "vote", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "votePeriod", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "votingInfo", - "outputs": [ - { - "internalType": "uint256", - "name": "round", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "commit", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "isVoter", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } -] diff --git a/autonity/abi/Precompiled.abi b/autonity/abi/Precompiled.abi deleted file mode 100644 index bcbf775..0000000 --- a/autonity/abi/Precompiled.abi +++ /dev/null @@ -1,106 +0,0 @@ -[ - { - "inputs": [], - "name": "ACCUSATION_CONTRACT", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "COMPUTE_COMMITTEE_CONTRACT", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "ENODE_VERIFIER_CONTRACT", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "INNOCENCE_CONTRACT", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "MISBEHAVIOUR_CONTRACT", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "POP_VERIFIER_CONTRACT", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "SUCCESS", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "UPGRADER_CONTRACT", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/autonity/abi/ReentrancyGuard.abi b/autonity/abi/ReentrancyGuard.abi deleted file mode 100644 index fe51488..0000000 --- a/autonity/abi/ReentrancyGuard.abi +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/autonity/abi/Stabilization.abi b/autonity/abi/Stabilization.abi deleted file mode 100644 index cc19543..0000000 --- a/autonity/abi/Stabilization.abi +++ /dev/null @@ -1,751 +0,0 @@ -[ - { - "inputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "borrowInterestRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "liquidationRatio", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "minCollateralizationRatio", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "minDebtRequirement", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "targetPrice", - "type": "uint256" - } - ], - "internalType": "struct Stabilization.Config", - "name": "config_", - "type": "tuple" - }, - { - "internalType": "address", - "name": "autonity", - "type": "address" - }, - { - "internalType": "address", - "name": "operator", - "type": "address" - }, - { - "internalType": "address", - "name": "oracle", - "type": "address" - }, - { - "internalType": "address", - "name": "supplyControl", - "type": "address" - }, - { - "internalType": "contract IERC20", - "name": "collateralToken", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "InsufficientAllowance", - "type": "error" - }, - { - "inputs": [], - "name": "InsufficientCollateral", - "type": "error" - }, - { - "inputs": [], - "name": "InsufficientPayment", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidAmount", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidDebtPosition", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidParameter", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidPrice", - "type": "error" - }, - { - "inputs": [], - "name": "Liquidatable", - "type": "error" - }, - { - "inputs": [], - "name": "NoDebtPosition", - "type": "error" - }, - { - "inputs": [], - "name": "NotLiquidatable", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "x", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "y", - "type": "uint256" - } - ], - "name": "PRBMath_MulDiv18_Overflow", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "x", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "y", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "denominator", - "type": "uint256" - } - ], - "name": "PRBMath_MulDiv_Overflow", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "UD60x18", - "name": "x", - "type": "uint256" - } - ], - "name": "PRBMath_UD60x18_Exp2_InputTooBig", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "UD60x18", - "name": "x", - "type": "uint256" - } - ], - "name": "PRBMath_UD60x18_Exp_InputTooBig", - "type": "error" - }, - { - "inputs": [], - "name": "PriceUnavailable", - "type": "error" - }, - { - "inputs": [], - "name": "TransferFailed", - "type": "error" - }, - { - "inputs": [], - "name": "Unauthorized", - "type": "error" - }, - { - "inputs": [], - "name": "ZeroValue", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Borrow", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Deposit", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "liquidator", - "type": "address" - } - ], - "name": "Liquidate", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Repay", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Withdraw", - "type": "event" - }, - { - "inputs": [], - "name": "SCALE", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "SCALE_FACTOR", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "SECONDS_IN_YEAR", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "accounts", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "borrow", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "collateral", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "price", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "targetPrice", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "mcr", - "type": "uint256" - } - ], - "name": "borrowLimit", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "cdps", - "outputs": [ - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "collateral", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "principal", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "interest", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "collateralPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "price", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "config", - "outputs": [ - { - "internalType": "uint256", - "name": "borrowInterestRate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "liquidationRatio", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "minCollateralizationRatio", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "minDebtRequirement", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "targetPrice", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - } - ], - "name": "debtAmount", - "outputs": [ - { - "internalType": "uint256", - "name": "debt", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "debtAmount", - "outputs": [ - { - "internalType": "uint256", - "name": "debt", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "deposit", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "debt", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "rate", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timeBorrow", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "timeDue", - "type": "uint256" - } - ], - "name": "interestDue", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "isLiquidatable", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "liquidate", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "principal", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "price", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "mcr", - "type": "uint256" - } - ], - "name": "minimumCollateral", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "repay", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "ratio", - "type": "uint256" - } - ], - "name": "setLiquidationRatio", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "ratio", - "type": "uint256" - } - ], - "name": "setMinCollateralizationRatio", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "setMinDebtRequirement", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "operator", - "type": "address" - } - ], - "name": "setOperator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "oracle", - "type": "address" - } - ], - "name": "setOracle", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "supplyControl", - "type": "address" - } - ], - "name": "setSupplyControl", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "collateral", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "price", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "debt", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "liquidationRatio", - "type": "uint256" - } - ], - "name": "underCollateralized", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "withdraw", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/autonity/abi/StakableVesting.abi b/autonity/abi/StakableVesting.abi deleted file mode 100644 index f2edcad..0000000 --- a/autonity/abi/StakableVesting.abi +++ /dev/null @@ -1,867 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address payable", - "name": "_autonity", - "type": "address" - }, - { - "internalType": "address", - "name": "_operator", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "FEE_FACTOR_UNIT_RECIP", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "bond", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_bondingID", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_liquid", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "_selfDelegation", - "type": "bool" - }, - { - "internalType": "bool", - "name": "_rejected", - "type": "bool" - } - ], - "name": "bondingApplied", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "canStake", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_recipient", - "type": "address" - } - ], - "name": "changeContractBeneficiary", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "claimRewards", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "claimRewards", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_validator", - "type": "address" - } - ], - "name": "claimRewards", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "contractTotalValue", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "contractVersion", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "getBondedValidators", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "getContract", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "currentNTNAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "withdrawnValue", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "start", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "cliffDuration", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalDuration", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "canStake", - "type": "bool" - } - ], - "internalType": "struct ContractBase.Contract", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - } - ], - "name": "getContracts", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "currentNTNAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "withdrawnValue", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "start", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "cliffDuration", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "totalDuration", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "canStake", - "type": "bool" - } - ], - "internalType": "struct ContractBase.Contract[]", - "name": "", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_validator", - "type": "address" - } - ], - "name": "liquidBalanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_validator", - "type": "address" - } - ], - "name": "lockedLiquidBalanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_startTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_cliffDuration", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_totalDuration", - "type": "uint256" - } - ], - "name": "newContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "receiveATN", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "releaseAllLNTN", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "releaseAllNTN", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "releaseFunds", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "releaseLNTN", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "releaseNTN", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "requiredBondingGasCost", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "requiredUnbondingGasCost", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "_validators", - "type": "address[]" - } - ], - "name": "rewardsDistributed", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_gas", - "type": "uint256" - } - ], - "name": "setRequiredGasBond", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_gas", - "type": "uint256" - } - ], - "name": "setRequiredGasUnbond", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_newTotalNominal", - "type": "uint256" - } - ], - "name": "setTotalNominal", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - } - ], - "name": "totalContracts", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalNominal", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "unbond", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_unbondingID", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "bool", - "name": "_rejected", - "type": "bool" - } - ], - "name": "unbondingApplied", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_unbondingID", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "_rejected", - "type": "bool" - } - ], - "name": "unbondingReleased", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_validator", - "type": "address" - } - ], - "name": "unclaimedRewards", - "outputs": [ - { - "internalType": "uint256", - "name": "_atnFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_ntnFee", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - } - ], - "name": "unclaimedRewards", - "outputs": [ - { - "internalType": "uint256", - "name": "_atnTotalFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_ntnTotalFee", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "unclaimedRewards", - "outputs": [ - { - "internalType": "uint256", - "name": "_atnFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_ntnFee", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "unlockedFunds", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_validator", - "type": "address" - } - ], - "name": "unlockedLiquidBalanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_beneficiary", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "updateFunds", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/autonity/abi/SupplyControl.abi b/autonity/abi/SupplyControl.abi deleted file mode 100644 index 30a06db..0000000 --- a/autonity/abi/SupplyControl.abi +++ /dev/null @@ -1,165 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address", - "name": "autonity", - "type": "address" - }, - { - "internalType": "address", - "name": "operator", - "type": "address" - }, - { - "internalType": "address", - "name": "stabilizer_", - "type": "address" - } - ], - "stateMutability": "payable", - "type": "constructor" - }, - { - "inputs": [], - "name": "InvalidAmount", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidRecipient", - "type": "error" - }, - { - "inputs": [], - "name": "Unauthorized", - "type": "error" - }, - { - "inputs": [], - "name": "ZeroValue", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Burn", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Mint", - "type": "event" - }, - { - "inputs": [], - "name": "availableSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "burn", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "operator", - "type": "address" - } - ], - "name": "setOperator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "stabilizer_", - "type": "address" - } - ], - "name": "setStabilizer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "stabilizer", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/autonity/abi/UpgradeManager.abi b/autonity/abi/UpgradeManager.abi deleted file mode 100644 index 5eb9aa6..0000000 --- a/autonity/abi/UpgradeManager.abi +++ /dev/null @@ -1,75 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address", - "name": "_autonity", - "type": "address" - }, - { - "internalType": "address", - "name": "_operator", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "autonity", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "operator", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_account", - "type": "address" - } - ], - "name": "setOperator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_target", - "type": "address" - }, - { - "internalType": "string", - "name": "_data", - "type": "string" - } - ], - "name": "upgrade", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/autonity/abi/Upgradeable.abi b/autonity/abi/Upgradeable.abi deleted file mode 100644 index a090f04..0000000 --- a/autonity/abi/Upgradeable.abi +++ /dev/null @@ -1,52 +0,0 @@ -[ - { - "inputs": [], - "name": "completeContractUpgrade", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "getNewContract", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - }, - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "resetContractUpgrade", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "_bytecode", - "type": "bytes" - }, - { - "internalType": "string", - "name": "_abi", - "type": "string" - } - ], - "name": "upgradeContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/autonity/abi/__init__.py b/autonity/abi/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/autonity/abi/autonity-commit.txt b/autonity/abi/autonity-commit.txt deleted file mode 100644 index bc1230f..0000000 --- a/autonity/abi/autonity-commit.txt +++ /dev/null @@ -1 +0,0 @@ -15cd01644a4b19d70c654bc334f04fab851f2466 \ No newline at end of file diff --git a/autonity/abi_manager.py b/autonity/abi_manager.py deleted file mode 100644 index d7836cf..0000000 --- a/autonity/abi_manager.py +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Access to bundled contract ABIs -""" - -import json -import warnings -from os import path -from typing import Dict - -from web3.contract.contract import ABI - -_CACHE: Dict[str, ABI] = {} - - -def load_abi(contract_name: str) -> ABI: - """ - Load (and cache) the ABI for a protocol contract. - """ - if contract_name not in _CACHE: - _CACHE[contract_name] = load_abi_file( - path.join(path.dirname(__file__), "abi", f"{contract_name}.abi") - ) - - return _CACHE[contract_name] - - -def load_abi_file(file_name: str) -> ABI: - """ - Load an ABI from a file. - """ - with open(file_name, "r", encoding="utf8") as abi_f: - return json.load(abi_f) - - -class ABIManager: - """ - Deprecated class kept for backwards compatibility. - """ - - @staticmethod - def load_abi(contract_name: str) -> ABI: - warnings.warn( - "abi_manager.ABIManager.load_abi has been replaced with " - "abi_manager.load_abi and will be removed in a future release", - DeprecationWarning, - ) - return load_abi(contract_name) - - @staticmethod - def load_abi_file(file_name: str) -> ABI: - warnings.warn( - "abi_manager.ABIManager.load_abi_file has been replaced with " - "abi_manager.load_abi_file and will be removed in a future release", - DeprecationWarning, - ) - return load_abi_file(file_name) diff --git a/autonity/abi_parser.py b/autonity/abi_parser.py deleted file mode 100644 index 9c3de43..0000000 --- a/autonity/abi_parser.py +++ /dev/null @@ -1,213 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Functions for working with contract ABIs. -""" - -from __future__ import annotations - -import json -from typing import Any, Callable, Dict, List, Sequence, Tuple, Union, cast - -from web3 import Web3 -from web3.types import ( - ABI, - ABIFunction, - ABIFunctionParams, -) - - -def find_abi_constructor(abi: ABI) -> ABIFunction: - """ - Given an ABI and function name, find the ABIFunction element. - """ - - for element in abi: - if element["type"] == "constructor" and "name" not in element: - return cast(ABIFunction, element) - - raise ValueError("constructor not found in ABI") - - -def find_abi_function(abi: ABI, function_name: str) -> ABIFunction: - """ - Given an ABI and function name, find the ABIFunction element. - """ - - for element in abi: - if element["type"] == "function" and element["name"] == function_name: - return cast(ABIFunction, element) - - raise ValueError(f"function {function_name} not found in ABI") - - -def parse_arguments(abi_function: ABIFunction, arguments: List[str]) -> List[Any]: - """ - Given an ABI, a function name and a list of string parameters, - parse the parameters to suitable types to call the function on a - contract with the given ABI. - """ - - inputs = abi_function["inputs"] - parsers = _argument_parsers_for_params(inputs) - if len(parsers) != len(arguments): - raise ValueError(f"function requires {len(parsers)}, received {len(arguments)}") - - return [parse(arg) for parse, arg in zip(parsers, arguments)] - - -def parse_return_value(abi_function: ABIFunction, return_value: Any) -> Any: - """ - Given the function ABI and the return values, matches the return values - with their names from the ABI spec. - - Supports void types, and flattening a one-element tuple to a raw type. - """ - - outputs = abi_function["outputs"] - if len(outputs) == 0: - return None - - if len(outputs) == 1: - # Single return value (including an array) - return _parse_return_value_from_type( - outputs[0]["type"], outputs[0], return_value - ) - - return_value_tuple = tuple(return_value) - return _parse_return_value_tuple(outputs, return_value_tuple) - - -ParamType = Union[str, int, float, bool] -""" -A native type which can be passed as an argument to a ContractFunction -""" - -ParamParser = Callable[[str], ParamType] -""" -Function to parse a string to a ParamType -""" - - -def _parse_string(value: str) -> str: - """ - Identity parser. - """ - return value - - -def _parse_bool(bool_str: str) -> bool: - """ - Boolean parser. - """ - if bool_str in ["False", "false", "0", ""]: - return False - - return True - - -def _parse_complex(value: str) -> Any: - """ - Parse a complex type, such as an array or tuple. - """ - return json.loads(value) - - -def _string_to_argument_fn_for_type(arg_type: str) -> ParamParser: - """ - Return a function which parses a string into a type suitable for - function arguments. - """ - if arg_type.endswith("[]") or arg_type == "tuple": - return _parse_complex - if arg_type.startswith("uint") or arg_type.startswith("int"): - return int - if arg_type == "bool": - return _parse_bool - if arg_type == "address": - return Web3.to_checksum_address - if arg_type.startswith("bytes") or arg_type == "string": - return _parse_string - if arg_type.startswith("fixed") or arg_type.startswith("ufixed"): - return float - raise ValueError(f"cannot convert '{arg_type}' from string") - - -def _argument_parsers_for_params( - outputs: Sequence[ABIFunctionParams], -) -> List[ParamParser]: - """ - Given the ABIFunctionParams object representing the output types - of a specific function, return a list of string-to-paramtype - converters. - """ - - out_types: List[ParamParser] = [] - for output in outputs: - out_types.append(_string_to_argument_fn_for_type(output["type"])) - - return out_types - - -def _parse_return_value_from_type( - type_name: str, output: ABIFunctionParams, value: Any -) -> Any: - """ - Parse a single value from an ABIFunctionParams. - """ - - # Check for array types - if type_name.endswith("[]"): - assert isinstance(value, list) - element_type = type_name[:-2] - return [_parse_return_value_from_type(element_type, output, v) for v in value] - - # Check for tuples - if type_name == "tuple": - assert isinstance(value, tuple) - assert "components" in output - return _parse_return_value_tuple(output["components"], value) - - return value - - -def _parse_return_value_as_anonymous_tuple( - outputs: Sequence[ABIFunctionParams], values: Tuple -) -> Tuple: - """ - Parse a list of unnamed ABIFunctionParams and a tuple, to a tuple. - """ - assert len(values) == len(outputs) - return tuple( - _parse_return_value_from_type(out["type"], out, val) - for val, out in zip(values, outputs) - ) - - -def _parse_return_value_as_named_tuple( - outputs: Sequence[ABIFunctionParams], values: Tuple -) -> Dict[str, Any]: - """ - Parse a list of named ABIFunctionParams and a tuple, to a dict. - """ - - assert len(values) == len(outputs) - value_dict: Dict[str, Any] = {} - for val, out in zip(values, outputs): - value_dict[out["name"]] = _parse_return_value_from_type(out["type"], out, val) - - return value_dict - - -def _parse_return_value_tuple( - outputs: Sequence[ABIFunctionParams], values: Tuple -) -> Any: - """ - Anonymous tuples to tuples, named tuples to dictionaries. - """ - - assert len(values) == len(outputs) - if outputs[0]["name"] == "": - return _parse_return_value_as_anonymous_tuple(outputs, values) - - return _parse_return_value_as_named_tuple(outputs, values) diff --git a/autonity/autonity.py b/autonity/autonity.py deleted file mode 100644 index be3a8f5..0000000 --- a/autonity/autonity.py +++ /dev/null @@ -1,594 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Python module holding the Autonity Web3.py external module -""" - -from __future__ import annotations - -import os -from enum import IntEnum -from typing import Sequence, Tuple, TypedDict, cast - -from eth_typing import ChecksumAddress -from hexbytes import HexBytes -from web3 import Web3 -from web3.contract.contract import ContractFunction -from web3.types import Wei - -from autonity.abi_manager import load_abi -from autonity.committee_member import CommitteeMember, committee_member_from_tuple -from autonity.config import Config, config_from_tuple -from autonity.erc20 import ERC20 -from autonity.validator import ( - NodeAddress, - OracleAddress, - ValidatorDescriptor, - validator_descriptor_from_tuple, -) - -# pylint: disable=too-many-public-methods -# pylint: disable=too-many-arguments - -AUTONITY_CONTRACT_ADDRESS = "0xBd770416a3345F91E4B34576cb804a576fa48EB1" -""" -The default autonity contract address. -see https://docs.autonity.org/concepts/architecture/#autonity-protocol-contract -""" - - -def get_autonity_contract_version() -> str: - """ - Returns the version of the Autonity contract which this library is aligned with, - and that is bundled with the library. - """ - version_path = os.path.join(os.path.dirname(__file__), "abi", "autonity-commit.txt") - if not os.path.exists(version_path): - return "N/A" - with open(version_path, "r", encoding="utf-8") as file: - return file.read().strip() - - -def get_autonity_contract_abi_path() -> str: - """ - Returns the Autonity contract ABI path bundled with the library. - This can be used in to load the ABI from a 3rd party app or library - """ - return os.path.abspath( - os.path.join(os.path.dirname(__file__), "abi", "Autonity.abi") - ) - - -class UnbondingReleaseState(IntEnum): - NOT_RELEASED = 0 - RELEASED = 1 - REJECTED = 2 - REVERTED = 3 - - -class Staking(TypedDict): - """ - Queued staking operations - """ - - delegator: ChecksumAddress - delegatee: ChecksumAddress - amount: int - start_block: int - - -def staking_from_tuple(value: Tuple[str, str, int, int]) -> Staking: - """ - Create Staking object from a Web3 tuple. - """ - assert len(value) == 4 - assert isinstance(value[0], str) - assert isinstance(value[1], str) - assert isinstance(value[2], int) - assert isinstance(value[3], int) - return Staking( - { - "delegator": cast(ChecksumAddress, value[0]), - "delegatee": cast(ChecksumAddress, value[1]), - "amount": value[2], - "start_block": value[3], - } - ) - - -class Autonity(ERC20): - """ - Web3 module representing Autonity-specific API. - """ - - def __init__(self, web3: Web3): - super().__init__( - web3, - web3.to_checksum_address(AUTONITY_CONTRACT_ADDRESS), - load_abi("Autonity"), - ) - - # TODO: What contract version checks can be performed here? - - @staticmethod - def address() -> ChecksumAddress: - """ - Return the deterministic address of the Autonity contract. - """ - return Web3.to_checksum_address(AUTONITY_CONTRACT_ADDRESS) - - def commission_rate_precision(self) -> int: - """ - See `COMMISSION_RATE_PRECISION` on the Autonity contract. - """ - return self.contract.functions.COMMISSION_RATE_PRECISION().call() - - def max_bond_applied_gas(self) -> int: - """ - See `maxBondAppliedGas` on the Autonity contract. - """ - return self.contract.functions.maxBondAppliedGas().call() - - def max_unbond_applied_gas(self) -> int: - """ - See `maxUnbondAppliedGas` on the Autonity contract. - """ - return self.contract.functions.maxUnbondAppliedGas().call() - - def max_unbond_released_gas(self) -> int: - """ - See `maxUnbondReleasedGas` on the Autonity contract. - """ - return self.contract.functions.maxUnbondReleasedGas().call() - - def max_rewards_distribution_gas(self) -> int: - """ - See `maxRewardsDistributionGas` on the Autonity contract. - """ - return self.contract.functions.maxRewardsDistributionGas().call() - - def config(self) -> Config: - """ - See `config` on the Autonity contract. - """ - return config_from_tuple(self.contract.functions.config().call()) - - def epoch_id(self) -> int: - """ - See `epochID` on the Autonity contract. - """ - return self.contract.functions.epochID().call() - - def last_epoch_block(self) -> int: - """ - See `lastEpochBlock` on the Autonity contract. - """ - return self.contract.functions.lastEpochBlock().call() - - def last_epoch_time(self) -> int: - """ - See `lastEpochTime` on the Autonity contract. - """ - return self.contract.functions.lastEpochTime().call() - - def epoch_total_bonded_stake(self) -> int: - """ - See `epochTotalBondedStake` on the Autonity contract. - """ - return self.contract.functions.epochTotalBondedStake().call() - - def atn_total_redistributed(self) -> int: - """ - See `atnTotalRedistributed` on the Autonity contract. - """ - return self.contract.functions.atnTotalRedistributed().call() - - def epoch_reward(self) -> int: - """ - See `epochReward` on the Autonity contract. - """ - return self.contract.functions.epochReward().call() - - def staking_gas_price(self) -> int: - """ - See `stakingGasPrice` on the Autonity contract. - """ - return self.contract.functions.stakingGasPrice().call() - - def inflation_reserve(self) -> int: - """ - See `inflationReserve` on the Autonity contract. - """ - return self.contract.functions.inflationReserve().call() - - def deployer(self) -> ChecksumAddress: - """ - See `deployer` on the Autonity contract. - """ - return self.contract.functions.deployer().call() - - def get_epoch_period(self) -> int: - """ - See `getEpochPeriod` on the Autonity contract. - """ - return self.contract.functions.getEpochPeriod().call() - - def get_block_period(self) -> int: - """ - See `getBlockPeriod` on the Autonity contract. - """ - return self.contract.functions.getBlockPeriod().call() - - def get_unbonding_period(self) -> int: - """ - See `getUnbondingPeriod` on the Autonity contract. - """ - return self.contract.functions.getUnbondingPeriod().call() - - def get_last_epoch_block(self) -> int: - """ - See `getLastEpochBlock` on the Autonity contract. - """ - return self.contract.functions.getLastEpochBlock().call() - - def get_version(self) -> int: - """ - See `getVersion` on the Autonity contract. - """ - return self.contract.functions.getVersion().call() - - def get_committee(self) -> Sequence[CommitteeMember]: - """ - See `getCommittee` on the Autonity contract. - """ - cms = self.contract.functions.getCommittee().call() - return [committee_member_from_tuple(cm) for cm in cms] - - def get_validators(self) -> Sequence[NodeAddress]: - """ - See `getValidators` on the Autonity contract. - """ - return self.contract.functions.getValidators().call() - - def get_treasury_account(self) -> ChecksumAddress: - """ - See `getTreasuryAccount` on the Autonity contract. - """ - return self.contract.functions.getTreasuryAccount().call() - - def get_treasury_fee(self) -> int: - """ - See `getTreasuryFee` on the Autonity contract. - """ - return self.contract.functions.getTreasuryFee().call() - - def get_validator(self, addr: ChecksumAddress) -> ValidatorDescriptor: - """ - See `getValidator` on the Autonity contract. To interact with - validators, construct a `Validator` object from the returned - ValidatorDescription. - """ - assert isinstance(addr, str) - value = self.contract.functions.getValidator(addr).call() - return validator_descriptor_from_tuple(value) - - def get_max_committee_size(self) -> int: - """ - See `getMaxCommitteeSize` on the Autonity contract. - """ - return self.contract.functions.getMaxCommitteeSize().call() - - def get_committee_enodes(self) -> Sequence[str]: - """ - See `getCommitteeEnodes` on the Autonity contract. - """ - return self.contract.functions.getCommitteeEnodes().call() - - def get_minimum_base_fee(self) -> int: - """ - See `getMinimumBaseFee` on the Autonity contract. - """ - return self.contract.functions.getMinimumBaseFee().call() - - def get_operator(self) -> ChecksumAddress: - """ - See `getOperator` on the Autonity contract. - """ - return self.contract.functions.getOperator().call() - - def get_oracle(self) -> ChecksumAddress: - """ - See `getOracle` on the Autonity contract. - """ - return self.contract.functions.getOracle().call() - - def get_proposer(self, height: int, round_idx: int) -> ChecksumAddress: - """ - See `getProposer` on the Autonity contract. - """ - return self.contract.functions.getProposer(height, round_idx).call() - - def get_unbonding_release_state(self, unbonding_id: int) -> int: - """ - See `getUnbondingReleaseState` on the Autonity contract. - """ - return UnbondingReleaseState( - self.contract.functions.getUnbondingReleaseState(unbonding_id).call() - ) - - def get_reverting_amount(self, unbonding_id: int) -> int: - """ - See `getRevertingAmount` on the Autonity contract. - """ - return self.contract.functions.getRevertingAmount(unbonding_id).call() - - def get_epoch_from_block(self, block: int) -> int: - """ - See `getEpochFromBlock` on the Autonity contract. - """ - return self.contract.functions.getEpochFromBlock(block).call() - - def bond( - self, - validator_addr: NodeAddress, - amount: int, - ) -> ContractFunction: - """ - Create a TxParams calling the `bond` method. See `bond` on the - Autonity contract. - """ - return self.contract.functions.bond(validator_addr, amount) - - def unbond( - self, - validator_addr: NodeAddress, - amount: int, - ) -> ContractFunction: - """ - Create a TxParams calling the `unbond` method. See `unbond` on - the Autonity contract. - """ - return self.contract.functions.unbond(validator_addr, amount) - - def register_validator( - self, - enode: str, - oracle: OracleAddress, - consensus_key: HexBytes, - proof: HexBytes, - ) -> ContractFunction: - """ - Create a TxParams calling the `registerValidator` method. See - `registerValidator` on the Autonity contract. - """ - return self.contract.functions.registerValidator( - enode, oracle, consensus_key, proof - ) - - def pause_validator( - self, - validator_addr: NodeAddress, - ) -> ContractFunction: - """ - Create a TxParams calling the `pauseValidator` method. See - `pauseValidator` on the Autonity contract. - """ - return self.contract.functions.pauseValidator(validator_addr) - - def activate_validator( - self, - validator_addr: NodeAddress, - ) -> ContractFunction: - """ - Create a TxParams calling the `activateValidator` method. See - `activateValidator` on the Autonity contract. - """ - return self.contract.functions.activateValidator(validator_addr) - - def update_enode(self, validator: NodeAddress, enode: str) -> ContractFunction: - """ - Update enode of a registered validator. - """ - return self.contract.functions.updateEnode(validator, enode) - - # Functions below here are operatorOnly - - def set_max_bond_applied_gas(self, gas: int) -> ContractFunction: - """ - Set the maximum bond applied gas. Restricted to the operator account. - See `setMaxBondAppliedGas` on the Autonity contract. - """ - return self.contract.functions.setMaxBondAppliedGas(gas) - - def set_max_unbond_applied_gas(self, gas: int) -> ContractFunction: - """ - Set the maximum unbond applied gas. Restricted to the operator account. - See `setMaxUnbondAppliedGas` on the Autonity contract. - """ - return self.contract.functions.setMaxUnbondAppliedGas(gas) - - def set_max_unbond_released_gas(self, gas: int) -> ContractFunction: - """ - Set the maximum unbond released gas. Restricted to the operator account. - See `setMaxUnbondReleasedGas` on the Autonity contract. - """ - return self.contract.functions.setMaxUnbondReleasedGas(gas) - - def set_max_rewards_distribution_gas(self, gas: int) -> ContractFunction: - """ - Set the maximum rewards distrbution gas. Restricted to the operator account. - See `setMaxRewardsDistributionGas` on the Autonity contract. - """ - return self.contract.functions.setMaxRewardsDistributionGas(gas) - - def set_staking_gas_price(self, price: int) -> ContractFunction: - """ - Set the gas price for notification on staking operation. Restricted to the - operator account. See `setStakingGasPrice` on the Autonity contract. - """ - return self.contract.functions.setStakingGasPrice(price) - - def set_minimum_base_fee(self, base_fee: Wei) -> ContractFunction: - """ - Set the minimum gas price. Restricted to the operator account. - See `setMinimumBaseFee` on the Autonity contract. - """ - return self.contract.functions.setMinimumBaseFee(base_fee) - - def set_committee_size(self, committee_size: int) -> ContractFunction: - """ - Set the maximum size of the consensus committee. Restricted to the - Operator account. See `setCommitteeSize` on Autonity contract. - """ - return self.contract.functions.setCommitteeSize(committee_size) - - def set_unbonding_period(self, period: int) -> ContractFunction: - """ - Set the unbonding period. Restricted to the Operator account. See - `setUnbondingPeriod` on Autonity contract. - """ - return self.contract.functions.setUnbondingPeriod(period) - - def set_epoch_period(self, period: int) -> ContractFunction: - """ - Set the epoch period. Restricted to the Operator account. See - `setEpochPeriod` on Autonity contract. - """ - return self.contract.functions.setEpochPeriod(period) - - def set_operator_account(self, address: ChecksumAddress) -> ContractFunction: - """ - Set the Operator account. Restricted to the Operator account. See - `setOperatorAccount` on Autonity contract. - """ - return self.contract.functions.setOperatorAccount(address) - - # def set_block_period(period: int) -> ContractFunction: - # """ - # Currently not supported. Set the block period. Restricted to the - # Operator account. - # """ - # return self.contract.setBlockPeriod(period) - - def set_treasury_account(self, address: ChecksumAddress) -> ContractFunction: - """ - Set the global treasury account. Restricted to the Operator - account. See `setTreasuryAccount` on Autonity contract. - """ - return self.contract.functions.setTreasuryAccount(address) - - def set_treasury_fee(self, treasury_fee: int) -> ContractFunction: - """ - Set the treasury fee. Restricted to the Operator account. See - `setTreasuryFee` on Autonity contract. - """ - return self.contract.functions.setTreasuryFee(treasury_fee) - - def set_accountability_contract(self, address: ChecksumAddress) -> ContractFunction: - """ - Set the accountability contract address. Restricted to the Operator - account. See `setAccountabilityContract` on Autonity contract. - """ - return self.contract.functions.setAccountabilityContract(address) - - def set_oracle_contract(self, address: ChecksumAddress) -> ContractFunction: - """ - Set the oracle contract address. Restricted to the Operator - account. See `setOracleContract` on Autonity contract. - """ - return self.contract.functions.setOracleContract(address) - - def set_acu_contract(self, address: ChecksumAddress) -> ContractFunction: - """ - Set the acu contract address. Restricted to the Operator - account. See `setAcuContract` on Autonity contract. - """ - return self.contract.functions.setAcuContract(address) - - def set_supply_control_contract(self, address: ChecksumAddress) -> ContractFunction: - """ - Set the supply control contract address. Restricted to the Operator - account. See `setSupplyControlContract` on Autonity contract. - """ - return self.contract.functions.setSupplyControlContract(address) - - def set_stabilization_contract(self, address: ChecksumAddress) -> ContractFunction: - """ - Set the stabilization contract address. Restricted to the Operator - account. See `setStabilizationContract` on Autonity contract. - """ - return self.contract.functions.setStabilizationContract(address) - - def set_inflation_controller_contract( - self, address: ChecksumAddress - ) -> ContractFunction: - """ - Set the inflation controller contract address. Restricted to the Operator - account. See `setInflationControllerContract` on Autonity contract. - """ - return self.contract.functions.setInflationControllerContract(address) - - def set_upgrade_manager_contract( - self, address: ChecksumAddress - ) -> ContractFunction: - """ - Set the upgrade manager contract address. Restricted to the Operator account. - See `setUpgradeManagerContract` on Autonity contract. - """ - return self.contract.functions.setStabilizationContract(address) - - def set_non_stakable_vesting_contract( - self, address: ChecksumAddress - ) -> ContractFunction: - """ - Set the non stakable vesting contract address. Restricted to the Operator - account. See `setNonStakableVestingContract` on Autonity contract. - """ - return self.contract.functions.setNonStakableVestingContract(address) - - def mint(self, address: ChecksumAddress, amount: int) -> ContractFunction: - """ - Mint new stake token (NTN) and add it to the recipient - balance. Restricted to the Operator account. See `mint` on - Autonity contract. - """ - return self.contract.functions.mint(address, amount) - - def burn(self, address: ChecksumAddress, amount: int) -> ContractFunction: - """ - Burn the specified amount of NTN stake token from an - account. Restricted to the Operator account. This won't burn - associated Liquid tokens. See `burn` on Autonity contract. - """ - return self.contract.functions.burn(address, amount) - - def change_commission_rate( - self, - validator: NodeAddress, - rate: int, - ) -> ContractFunction: - """ - Create a TxParams calling the `changeCommissionRate` method. See - `changeCommissionRate` on the Autonity contract. - """ - return self.contract.functions.changeCommissionRate(validator, rate) - - # TODO: events - # event ActivatedValidator(address indexed treasury, address indexed addr, uint256 effectiveBlock); - # event AppliedUnbondingReverted(address indexed validator, address indexed delegator, bool selfBonded, uint256 amount); - # event BondingRejected(address indexed validator, address indexed delegator, uint256 amount, ValidatorState state); - # event BondingReverted(address indexed validator, address indexed delegator, uint256 amount); - # event BurnedStake(address addr, uint256 amount); - # event CommissionRateChange(address validator, uint256 rate); - # event EpochPeriodUpdated(uint256 period); - # event MinimumBaseFeeUpdated(uint256 gasPrice); - # event MintedStake(address addr, uint256 amount); - # event NewBondingRequest(address indexed validator, address indexed delegator, bool selfBonded, uint256 amount); - # event NewEpoch(uint256 epoch); - # event NewUnbondingRequest(address indexed validator, address indexed delegator, bool selfBonded, uint256 amount); - # event PausedValidator(address indexed treasury, address indexed addr, uint256 effectiveBlock); - # event RegisteredValidator(address treasury, address addr, address oracleAddress, string enode, address liquidContract); - # event ReleasedUnbondingReverted(address indexed validator, address indexed delegator, bool selfBonded, uint256 amount); - # event Rewarded(address indexed addr, uint256 atnAmount, uint256 ntnAmount); - # event UnbondingRejected(address indexed validator, address indexed delegator, bool selfBonded, uint256 amount); - # event UnlockingScheduleFailed(uint256 epochTime); diff --git a/autonity/committee_member.py b/autonity/committee_member.py deleted file mode 100644 index 6a5a833..0000000 --- a/autonity/committee_member.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Committee member model class -""" - -from __future__ import annotations - -from typing import Tuple, TypedDict - -from eth_typing import ChecksumAddress -from hexbytes import HexBytes - - -class CommitteeMember(TypedDict): - """ - Dictionary representing a member of the consensus committee. - """ - - address: ChecksumAddress - voting_power: int - consensus_key: str - - -def committee_member_from_tuple( - value: Tuple[ChecksumAddress, int, bytes] -) -> CommitteeMember: - """ - From Web3 tuple - """ - assert len(value) == 3 - assert isinstance(value[0], str) - assert isinstance(value[1], int) - assert isinstance(value[2], bytes) - return CommitteeMember( - { - "address": value[0], - "voting_power": value[1], - "consensus_key": HexBytes(value[2]).hex(), - } - ) diff --git a/autonity/config.py b/autonity/config.py deleted file mode 100644 index 0b1452b..0000000 --- a/autonity/config.py +++ /dev/null @@ -1,125 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Models for Autonity contract configuration -""" - -from __future__ import annotations - -from typing import Tuple, TypedDict - -from web3.types import ChecksumAddress - - -class Contracts(TypedDict): - accountability_contract: ChecksumAddress - oracle_contract: ChecksumAddress - acu_contract: ChecksumAddress - supply_control_contract: ChecksumAddress - stabilization_contract: ChecksumAddress - upgrade_manager_contract: ChecksumAddress - inflation_controller_contract: ChecksumAddress - non_stakable_vesting_contract: ChecksumAddress - - -class Policy(TypedDict): - treasury_fee: int - min_basefee: int - delegation_rate: int - unbonding_period: int - initial_inflation_reserve: int - treasury_account: ChecksumAddress - - -class Protocol(TypedDict): - operator_account: ChecksumAddress - epoch_period: int - block_period: int - committee_size: int - - -class Config(TypedDict): - """ - Autonity configuration. - """ - - policy: Policy - contracts: Contracts - protocol: Protocol - contract_version: int - - -def config_from_tuple( - value: Tuple[ - Tuple[int, int, int, int, int, ChecksumAddress], - Tuple[ - ChecksumAddress, - ChecksumAddress, - ChecksumAddress, - ChecksumAddress, - ChecksumAddress, - ChecksumAddress, - ChecksumAddress, - ChecksumAddress, - ], - Tuple[ChecksumAddress, int, int, int], - int, - ] -) -> Config: - """ - Create from a Web3 tuple. - """ - assert isinstance(value[0][0], int) - assert isinstance(value[0][1], int) - assert isinstance(value[0][2], int) - assert isinstance(value[0][3], int) - assert isinstance(value[0][4], int) - assert isinstance(value[0][5], str) - assert isinstance(value[1][0], str) - assert isinstance(value[1][1], str) - assert isinstance(value[1][2], str) - assert isinstance(value[1][3], str) - assert isinstance(value[1][4], str) - assert isinstance(value[1][5], str) - assert isinstance(value[1][6], str) - assert isinstance(value[1][7], str) - assert isinstance(value[2][0], str) - assert isinstance(value[2][1], int) - assert isinstance(value[2][2], int) - assert isinstance(value[2][3], int) - assert isinstance(value[3], int) - return Config( - { - "policy": Policy( - { - "treasury_fee": value[0][0], - "min_basefee": value[0][1], - "delegation_rate": value[0][2], - "unbonding_period": value[0][3], - "initial_inflation_reserve": value[0][4], - "treasury_account": value[0][5], - } - ), - "contracts": Contracts( - { - "accountability_contract": value[1][0], - "oracle_contract": value[1][1], - "acu_contract": value[1][2], - "supply_control_contract": value[1][3], - "stabilization_contract": value[1][4], - "upgrade_manager_contract": value[1][5], - "inflation_controller_contract": value[1][6], - "non_stakable_vesting_contract": value[1][7], - } - ), - "protocol": Protocol( - { - "operator_account": value[2][0], - "epoch_period": value[2][1], - "block_period": value[2][2], - "committee_size": value[2][3], - } - ), - "contract_version": value[3], - } - ) diff --git a/autonity/constants.py b/autonity/constants.py new file mode 100644 index 0000000..682a0ba --- /dev/null +++ b/autonity/constants.py @@ -0,0 +1,13 @@ +"""Protocol parameters.""" + +from typing import cast + +from eth_typing import ChecksumAddress + +AUTONITY_CONTRACT_ADDRESS = cast( + ChecksumAddress, "0xBd770416a3345F91E4B34576cb804a576fa48EB1" +) +AUTONITY_CONTRACT_VERSION = 1 + +NATIVE_TOKEN_SYMBOL = "ATN" +NATIVE_TOKEN_DECIMALS = 18 diff --git a/autonity/contracts/accountability.py b/autonity/contracts/accountability.py new file mode 100644 index 0000000..9b07417 --- /dev/null +++ b/autonity/contracts/accountability.py @@ -0,0 +1,806 @@ +"""Accountability contract binding and data structures.""" + +# This module has been generated using pyabigen v0.2.9 + +import enum +import typing + +import eth_typing +import hexbytes +import web3 +from dataclasses import dataclass +from web3.contract import base_contract, contract + +__version__ = "v0.14.0" + + +class Rule(enum.IntEnum): + """Port of `enum Rule` on the Accountability contract.""" + + PN = 0 + PO = 1 + PVN = 2 + PVO = 3 + PVO12 = 4 + C = 5 + C1 = 6 + INVALID_PROPOSAL = 7 + INVALID_PROPOSER = 8 + EQUIVOCATION = 9 + + +class EventType(enum.IntEnum): + """Port of `enum EventType` on the Accountability contract.""" + + FAULT_PROOF = 0 + ACCUSATION = 1 + INNOCENCE_PROOF = 2 + + +@dataclass +class Config: + """Port of `struct Config` on the Accountability contract.""" + + innocence_proof_submission_window: int + base_slashing_rate_low: int + base_slashing_rate_mid: int + collusion_factor: int + history_factor: int + jail_factor: int + slashing_rate_precision: int + + +@dataclass +class Event: + """Port of `struct Event` on the Accountability contract.""" + + chunks: int + chunk_id: int + event_type: EventType + rule: Rule + reporter: eth_typing.ChecksumAddress + offender: eth_typing.ChecksumAddress + raw_proof: hexbytes.HexBytes + id: int + block: int + epoch: int + reporting_block: int + message_hash: int + + +class Accountability: + """Accountability contract binding. + + Parameters + ---------- + w3 : web3.Web3 + address : eth_typing.ChecksumAddress + The address of a deployed Accountability contract. + """ + + _contract: contract.Contract + + def __init__( + self, + w3: web3.Web3, + address: eth_typing.ChecksumAddress, + ): + self._contract = w3.eth.contract( + address=address, + abi=ABI, + ) + + @property + def InnocenceProven(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event InnocenceProven` on the Accountability contract.""" + return self._contract.events.InnocenceProven + + @property + def NewAccusation(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event NewAccusation` on the Accountability contract.""" + return self._contract.events.NewAccusation + + @property + def NewFaultProof(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event NewFaultProof` on the Accountability contract.""" + return self._contract.events.NewFaultProof + + @property + def SlashingEvent(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event SlashingEvent` on the Accountability contract.""" + return self._contract.events.SlashingEvent + + def beneficiaries( + self, + key0: eth_typing.ChecksumAddress, + ) -> eth_typing.ChecksumAddress: + """Binding for `beneficiaries` on the Accountability contract. + + Parameters + ---------- + key0 : eth_typing.ChecksumAddress + + Returns + ------- + eth_typing.ChecksumAddress + """ + return_value = self._contract.functions.beneficiaries( + key0, + ).call() + return eth_typing.ChecksumAddress(return_value) + + def can_accuse( + self, + _offender: eth_typing.ChecksumAddress, + _rule: Rule, + _block: int, + ) -> typing.Tuple[bool, int]: + """Binding for `canAccuse` on the Accountability contract. + + Parameters + ---------- + _offender : eth_typing.ChecksumAddress + _rule : Rule + _block : int + + Returns + ------- + bool + int + """ + return_value = self._contract.functions.canAccuse( + _offender, + int(_rule), + _block, + ).call() + return ( + bool(return_value[0]), + int(return_value[1]), + ) + + def can_slash( + self, + _offender: eth_typing.ChecksumAddress, + _rule: Rule, + _block: int, + ) -> bool: + """Binding for `canSlash` on the Accountability contract. + + Parameters + ---------- + _offender : eth_typing.ChecksumAddress + _rule : Rule + _block : int + + Returns + ------- + bool + """ + return_value = self._contract.functions.canSlash( + _offender, + int(_rule), + _block, + ).call() + return bool(return_value) + + def config( + self, + ) -> Config: + """Binding for `config` on the Accountability contract. + + Returns + ------- + Config + """ + return_value = self._contract.functions.config().call() + return Config( + int(return_value[0]), + int(return_value[1]), + int(return_value[2]), + int(return_value[3]), + int(return_value[4]), + int(return_value[5]), + int(return_value[6]), + ) + + def epoch_period( + self, + ) -> int: + """Binding for `epochPeriod` on the Accountability contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.epochPeriod().call() + return int(return_value) + + def events( + self, + key0: int, + ) -> Event: + """Binding for `events` on the Accountability contract. + + Parameters + ---------- + key0 : int + + Returns + ------- + Event + """ + return_value = self._contract.functions.events( + key0, + ).call() + return Event( + int(return_value[0]), + int(return_value[1]), + EventType(return_value[2]), + Rule(return_value[3]), + eth_typing.ChecksumAddress(return_value[4]), + eth_typing.ChecksumAddress(return_value[5]), + hexbytes.HexBytes(return_value[6]), + int(return_value[7]), + int(return_value[8]), + int(return_value[9]), + int(return_value[10]), + int(return_value[11]), + ) + + def get_validator_accusation( + self, + _val: eth_typing.ChecksumAddress, + ) -> Event: + """Binding for `getValidatorAccusation` on the Accountability contract. + + Parameters + ---------- + _val : eth_typing.ChecksumAddress + + Returns + ------- + Event + """ + return_value = self._contract.functions.getValidatorAccusation( + _val, + ).call() + return Event( + int(return_value[0]), + int(return_value[1]), + EventType(return_value[2]), + Rule(return_value[3]), + eth_typing.ChecksumAddress(return_value[4]), + eth_typing.ChecksumAddress(return_value[5]), + hexbytes.HexBytes(return_value[6]), + int(return_value[7]), + int(return_value[8]), + int(return_value[9]), + int(return_value[10]), + int(return_value[11]), + ) + + def get_validator_faults( + self, + _val: eth_typing.ChecksumAddress, + ) -> typing.List[Event]: + """Binding for `getValidatorFaults` on the Accountability contract. + + Parameters + ---------- + _val : eth_typing.ChecksumAddress + + Returns + ------- + typing.List[Event] + """ + return_value = self._contract.functions.getValidatorFaults( + _val, + ).call() + return [ + Event( + int(elem[0]), + int(elem[1]), + EventType(elem[2]), + Rule(elem[3]), + eth_typing.ChecksumAddress(elem[4]), + eth_typing.ChecksumAddress(elem[5]), + hexbytes.HexBytes(elem[6]), + int(elem[7]), + int(elem[8]), + int(elem[9]), + int(elem[10]), + int(elem[11]), + ) + for elem in return_value + ] + + def slashing_history( + self, + key0: eth_typing.ChecksumAddress, + key1: int, + ) -> int: + """Binding for `slashingHistory` on the Accountability contract. + + Parameters + ---------- + key0 : eth_typing.ChecksumAddress + key1 : int + + Returns + ------- + int + """ + return_value = self._contract.functions.slashingHistory( + key0, + key1, + ).call() + return int(return_value) + + +ABI = typing.cast( + eth_typing.ABI, + [ + { + "inputs": [ + { + "internalType": "address payable", + "name": "_autonity", + "type": "address", + }, + { + "components": [ + { + "internalType": "uint256", + "name": "innocenceProofSubmissionWindow", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "baseSlashingRateLow", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "baseSlashingRateMid", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "collusionFactor", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "historyFactor", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "jailFactor", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "slashingRatePrecision", + "type": "uint256", + }, + ], + "internalType": "struct Accountability.Config", + "name": "_config", + "type": "tuple", + }, + ], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "_offender", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "_id", + "type": "uint256", + }, + ], + "name": "InnocenceProven", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "_offender", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "_severity", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "_id", + "type": "uint256", + }, + ], + "name": "NewAccusation", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "_offender", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "_severity", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "_id", + "type": "uint256", + }, + ], + "name": "NewFaultProof", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "address", + "name": "validator", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "releaseBlock", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "bool", + "name": "isJailbound", + "type": "bool", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "eventId", + "type": "uint256", + }, + ], + "name": "SlashingEvent", + "type": "event", + }, + { + "inputs": [{"internalType": "address", "name": "", "type": "address"}], + "name": "beneficiaries", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_offender", "type": "address"}, + { + "internalType": "enum Accountability.Rule", + "name": "_rule", + "type": "uint8", + }, + {"internalType": "uint256", "name": "_block", "type": "uint256"}, + ], + "name": "canAccuse", + "outputs": [ + {"internalType": "bool", "name": "_result", "type": "bool"}, + {"internalType": "uint256", "name": "_deadline", "type": "uint256"}, + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_offender", "type": "address"}, + { + "internalType": "enum Accountability.Rule", + "name": "_rule", + "type": "uint8", + }, + {"internalType": "uint256", "name": "_block", "type": "uint256"}, + ], + "name": "canSlash", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "config", + "outputs": [ + { + "internalType": "uint256", + "name": "innocenceProofSubmissionWindow", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "baseSlashingRateLow", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "baseSlashingRateMid", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "collusionFactor", + "type": "uint256", + }, + {"internalType": "uint256", "name": "historyFactor", "type": "uint256"}, + {"internalType": "uint256", "name": "jailFactor", "type": "uint256"}, + { + "internalType": "uint256", + "name": "slashingRatePrecision", + "type": "uint256", + }, + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_validator", "type": "address"}, + {"internalType": "uint256", "name": "_ntnReward", "type": "uint256"}, + ], + "name": "distributeRewards", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [], + "name": "epochPeriod", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "events", + "outputs": [ + {"internalType": "uint8", "name": "chunks", "type": "uint8"}, + {"internalType": "uint8", "name": "chunkId", "type": "uint8"}, + { + "internalType": "enum Accountability.EventType", + "name": "eventType", + "type": "uint8", + }, + { + "internalType": "enum Accountability.Rule", + "name": "rule", + "type": "uint8", + }, + {"internalType": "address", "name": "reporter", "type": "address"}, + {"internalType": "address", "name": "offender", "type": "address"}, + {"internalType": "bytes", "name": "rawProof", "type": "bytes"}, + {"internalType": "uint256", "name": "id", "type": "uint256"}, + {"internalType": "uint256", "name": "block", "type": "uint256"}, + {"internalType": "uint256", "name": "epoch", "type": "uint256"}, + { + "internalType": "uint256", + "name": "reportingBlock", + "type": "uint256", + }, + {"internalType": "uint256", "name": "messageHash", "type": "uint256"}, + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "bool", "name": "_epochEnd", "type": "bool"}], + "name": "finalize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [{"internalType": "address", "name": "_val", "type": "address"}], + "name": "getValidatorAccusation", + "outputs": [ + { + "components": [ + {"internalType": "uint8", "name": "chunks", "type": "uint8"}, + {"internalType": "uint8", "name": "chunkId", "type": "uint8"}, + { + "internalType": "enum Accountability.EventType", + "name": "eventType", + "type": "uint8", + }, + { + "internalType": "enum Accountability.Rule", + "name": "rule", + "type": "uint8", + }, + { + "internalType": "address", + "name": "reporter", + "type": "address", + }, + { + "internalType": "address", + "name": "offender", + "type": "address", + }, + {"internalType": "bytes", "name": "rawProof", "type": "bytes"}, + {"internalType": "uint256", "name": "id", "type": "uint256"}, + {"internalType": "uint256", "name": "block", "type": "uint256"}, + {"internalType": "uint256", "name": "epoch", "type": "uint256"}, + { + "internalType": "uint256", + "name": "reportingBlock", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "messageHash", + "type": "uint256", + }, + ], + "internalType": "struct Accountability.Event", + "name": "", + "type": "tuple", + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "address", "name": "_val", "type": "address"}], + "name": "getValidatorFaults", + "outputs": [ + { + "components": [ + {"internalType": "uint8", "name": "chunks", "type": "uint8"}, + {"internalType": "uint8", "name": "chunkId", "type": "uint8"}, + { + "internalType": "enum Accountability.EventType", + "name": "eventType", + "type": "uint8", + }, + { + "internalType": "enum Accountability.Rule", + "name": "rule", + "type": "uint8", + }, + { + "internalType": "address", + "name": "reporter", + "type": "address", + }, + { + "internalType": "address", + "name": "offender", + "type": "address", + }, + {"internalType": "bytes", "name": "rawProof", "type": "bytes"}, + {"internalType": "uint256", "name": "id", "type": "uint256"}, + {"internalType": "uint256", "name": "block", "type": "uint256"}, + {"internalType": "uint256", "name": "epoch", "type": "uint256"}, + { + "internalType": "uint256", + "name": "reportingBlock", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "messageHash", + "type": "uint256", + }, + ], + "internalType": "struct Accountability.Event[]", + "name": "", + "type": "tuple[]", + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + { + "components": [ + {"internalType": "uint8", "name": "chunks", "type": "uint8"}, + {"internalType": "uint8", "name": "chunkId", "type": "uint8"}, + { + "internalType": "enum Accountability.EventType", + "name": "eventType", + "type": "uint8", + }, + { + "internalType": "enum Accountability.Rule", + "name": "rule", + "type": "uint8", + }, + { + "internalType": "address", + "name": "reporter", + "type": "address", + }, + { + "internalType": "address", + "name": "offender", + "type": "address", + }, + {"internalType": "bytes", "name": "rawProof", "type": "bytes"}, + {"internalType": "uint256", "name": "id", "type": "uint256"}, + {"internalType": "uint256", "name": "block", "type": "uint256"}, + {"internalType": "uint256", "name": "epoch", "type": "uint256"}, + { + "internalType": "uint256", + "name": "reportingBlock", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "messageHash", + "type": "uint256", + }, + ], + "internalType": "struct Accountability.Event", + "name": "_event", + "type": "tuple", + } + ], + "name": "handleEvent", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "_newPeriod", "type": "uint256"} + ], + "name": "setEpochPeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "", "type": "address"}, + {"internalType": "uint256", "name": "", "type": "uint256"}, + ], + "name": "slashingHistory", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + ], +) diff --git a/autonity/contracts/acu.py b/autonity/contracts/acu.py new file mode 100644 index 0000000..1735394 --- /dev/null +++ b/autonity/contracts/acu.py @@ -0,0 +1,335 @@ +"""ACU contract binding and data structures.""" + +# This module has been generated using pyabigen v0.2.9 + +import typing + +import eth_typing +import web3 +from web3.contract import base_contract, contract + +__version__ = "v0.14.0" + + +class ACU: + """ACU contract binding. + + Computes the value of the ACU, an optimal currency basket of 7 free-floating fiat + currencies. + + Parameters + ---------- + w3 : web3.Web3 + address : eth_typing.ChecksumAddress + The address of a deployed ACU contract. + """ + + _contract: contract.Contract + + def __init__( + self, + w3: web3.Web3, + address: eth_typing.ChecksumAddress, + ): + self._contract = w3.eth.contract( + address=address, + abi=ABI, + ) + + @property + def BasketModified(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event BasketModified` on the ACU contract. + + The ACU symbols, quantites, or scale were modified. + """ + return self._contract.events.BasketModified + + @property + def Updated(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event Updated` on the ACU contract. + + The ACU value was updated. + """ + return self._contract.events.Updated + + def modify_basket( + self, + symbols_: typing.List[str], + quantities_: typing.List[int], + scale_: int, + ) -> contract.ContractFunction: + """Binding for `modifyBasket` on the ACU contract. + + Modify the ACU symbols, quantites, or scale. + + Parameters + ---------- + symbols_ : typing.List[str] + The symbols used to retrieve prices + quantities_ : typing.List[int] + The basket quantity corresponding to each symbol + scale_ : int + The scale for quantities and the ACU value + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.modifyBasket( + symbols_, + quantities_, + scale_, + ) + + def quantities( + self, + ) -> typing.List[int]: + """Binding for `quantities` on the ACU contract. + + The basket quantities that are used to compute the ACU. + + Returns + ------- + typing.List[int] + Array of quantities + """ + return_value = self._contract.functions.quantities().call() + return [int(elem) for elem in return_value] + + def round( + self, + ) -> int: + """Binding for `round` on the ACU contract. + + The Oracle round of the current ACU value. + + Returns + ------- + int + """ + return_value = self._contract.functions.round().call() + return int(return_value) + + def scale( + self, + ) -> int: + """Binding for `scale` on the ACU contract. + + The decimal places used to represent the ACU as a fixed-point integer. It is + also the scale used to represent the basket quantities. + + Returns + ------- + int + """ + return_value = self._contract.functions.scale().call() + return int(return_value) + + def scale_factor( + self, + ) -> int: + """Binding for `scaleFactor` on the ACU contract. + + The multiplier for scaling numbers to the ACU scaled representation. + + Returns + ------- + int + """ + return_value = self._contract.functions.scaleFactor().call() + return int(return_value) + + def symbols( + self, + ) -> typing.List[str]: + """Binding for `symbols` on the ACU contract. + + The symbols that are used to compute the ACU. + + Returns + ------- + typing.List[str] + Array of symbols + """ + return_value = self._contract.functions.symbols().call() + return [str(elem) for elem in return_value] + + def value( + self, + ) -> int: + """Binding for `value` on the ACU contract. + + The latest ACU value that was computed. + + Returns + ------- + int + ACU value in fixed-point integer representation + """ + return_value = self._contract.functions.value().call() + return int(return_value) + + +ABI = typing.cast( + eth_typing.ABI, + [ + { + "inputs": [ + {"internalType": "string[]", "name": "symbols_", "type": "string[]"}, + { + "internalType": "uint256[]", + "name": "quantities_", + "type": "uint256[]", + }, + {"internalType": "uint256", "name": "scale_", "type": "uint256"}, + {"internalType": "address", "name": "autonity", "type": "address"}, + {"internalType": "address", "name": "operator", "type": "address"}, + {"internalType": "address", "name": "oracle", "type": "address"}, + ], + "stateMutability": "nonpayable", + "type": "constructor", + }, + {"inputs": [], "name": "InvalidBasket", "type": "error"}, + {"inputs": [], "name": "NoACUValue", "type": "error"}, + {"inputs": [], "name": "Unauthorized", "type": "error"}, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string[]", + "name": "symbols", + "type": "string[]", + }, + { + "indexed": False, + "internalType": "uint256[]", + "name": "quantities", + "type": "uint256[]", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "scale", + "type": "uint256", + }, + ], + "name": "BasketModified", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "height", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "round", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "int256", + "name": "value", + "type": "int256", + }, + ], + "name": "Updated", + "type": "event", + }, + { + "inputs": [ + {"internalType": "string[]", "name": "symbols_", "type": "string[]"}, + { + "internalType": "uint256[]", + "name": "quantities_", + "type": "uint256[]", + }, + {"internalType": "uint256", "name": "scale_", "type": "uint256"}, + ], + "name": "modifyBasket", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "quantities", + "outputs": [{"internalType": "uint256[]", "name": "", "type": "uint256[]"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "round", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "scale", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "scaleFactor", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "operator", "type": "address"} + ], + "name": "setOperator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "oracle", "type": "address"} + ], + "name": "setOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "symbols", + "outputs": [{"internalType": "string[]", "name": "", "type": "string[]"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "update", + "outputs": [{"internalType": "bool", "name": "status", "type": "bool"}], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "value", + "outputs": [{"internalType": "int256", "name": "", "type": "int256"}], + "stateMutability": "view", + "type": "function", + }, + ], +) diff --git a/autonity/contracts/autonity.py b/autonity/contracts/autonity.py new file mode 100644 index 0000000..7564f4d --- /dev/null +++ b/autonity/contracts/autonity.py @@ -0,0 +1,3465 @@ +"""Autonity contract binding and data structures.""" + +# This module has been generated using pyabigen v0.2.9 + +import enum +import typing + +import eth_typing +import hexbytes +import web3 +from dataclasses import dataclass +from web3.contract import base_contract, contract + +__version__ = "v0.14.0" + + +class ValidatorState(enum.IntEnum): + """Port of `enum ValidatorState` on the Autonity contract.""" + + ACTIVE = 0 + PAUSED = 1 + JAILED = 2 + JAILBOUND = 3 + + +class UnbondingReleaseState(enum.IntEnum): + """Port of `enum UnbondingReleaseState` on the Autonity contract.""" + + NOT_RELEASED = 0 + RELEASED = 1 + REJECTED = 2 + REVERTED = 3 + + +@dataclass +class Validator: + """Port of `struct Validator` on the Autonity contract.""" + + treasury: eth_typing.ChecksumAddress + node_address: eth_typing.ChecksumAddress + oracle_address: eth_typing.ChecksumAddress + enode: str + commission_rate: int + bonded_stake: int + unbonding_stake: int + unbonding_shares: int + self_bonded_stake: int + self_unbonding_stake: int + self_unbonding_shares: int + self_unbonding_stake_locked: int + liquid_contract: eth_typing.ChecksumAddress + liquid_supply: int + registration_block: int + total_slashed: int + jail_release_block: int + provable_fault_count: int + consensus_key: hexbytes.HexBytes + state: ValidatorState + + +@dataclass +class Policy: + """Port of `struct Policy` on the Autonity contract.""" + + treasury_fee: int + min_base_fee: int + delegation_rate: int + unbonding_period: int + initial_inflation_reserve: int + treasury_account: eth_typing.ChecksumAddress + + +@dataclass +class Contracts: + """Port of `struct Contracts` on the Autonity contract.""" + + accountability_contract: eth_typing.ChecksumAddress + oracle_contract: eth_typing.ChecksumAddress + acu_contract: eth_typing.ChecksumAddress + supply_control_contract: eth_typing.ChecksumAddress + stabilization_contract: eth_typing.ChecksumAddress + upgrade_manager_contract: eth_typing.ChecksumAddress + inflation_controller_contract: eth_typing.ChecksumAddress + non_stakable_vesting_contract: eth_typing.ChecksumAddress + + +@dataclass +class Protocol: + """Port of `struct Protocol` on the Autonity contract.""" + + operator_account: eth_typing.ChecksumAddress + epoch_period: int + block_period: int + committee_size: int + + +@dataclass +class Config: + """Port of `struct Config` on the Autonity contract.""" + + policy: Policy + contracts: Contracts + protocol: Protocol + contract_version: int + + +@dataclass +class CommitteeMember: + """Port of `struct CommitteeMember` on the Autonity contract.""" + + addr: eth_typing.ChecksumAddress + voting_power: int + consensus_key: hexbytes.HexBytes + + +class Autonity: + """Autonity contract binding. + + Parameters + ---------- + w3 : web3.Web3 + address : eth_typing.ChecksumAddress + The address of a deployed Autonity contract. + """ + + _contract: contract.Contract + + def __init__( + self, + w3: web3.Web3, + address: eth_typing.ChecksumAddress, + ): + self._contract = w3.eth.contract( + address=address, + abi=ABI, + ) + + @property + def ActivatedValidator(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event ActivatedValidator` on the Autonity contract.""" + return self._contract.events.ActivatedValidator + + @property + def AppliedUnbondingReverted(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event AppliedUnbondingReverted` on the Autonity contract.""" + return self._contract.events.AppliedUnbondingReverted + + @property + def Approval(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event Approval` on the Autonity contract.""" + return self._contract.events.Approval + + @property + def BondingRejected(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event BondingRejected` on the Autonity contract.""" + return self._contract.events.BondingRejected + + @property + def BondingReverted(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event BondingReverted` on the Autonity contract.""" + return self._contract.events.BondingReverted + + @property + def BurnedStake(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event BurnedStake` on the Autonity contract.""" + return self._contract.events.BurnedStake + + @property + def CommissionRateChange(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event CommissionRateChange` on the Autonity contract.""" + return self._contract.events.CommissionRateChange + + @property + def EpochPeriodUpdated(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event EpochPeriodUpdated` on the Autonity contract.""" + return self._contract.events.EpochPeriodUpdated + + @property + def MinimumBaseFeeUpdated(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event MinimumBaseFeeUpdated` on the Autonity contract.""" + return self._contract.events.MinimumBaseFeeUpdated + + @property + def MintedStake(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event MintedStake` on the Autonity contract.""" + return self._contract.events.MintedStake + + @property + def NewBondingRequest(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event NewBondingRequest` on the Autonity contract. + + This event is emitted when a bonding request to a validator node has been + registered. This request will only be effective at the end of the current epoch + however the stake will be put in custody immediately from the delegator's + account. + """ + return self._contract.events.NewBondingRequest + + @property + def NewEpoch(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event NewEpoch` on the Autonity contract.""" + return self._contract.events.NewEpoch + + @property + def NewUnbondingRequest(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event NewUnbondingRequest` on the Autonity contract. + + This event is emitted when an unbonding request to a validator node has been + registered. This request will only be effective after the unbonding period, + rounded to the next epoch. Please note that because of potential slashing events + during this delay period, the released amount may or may not be correspond to + the amount requested. + """ + return self._contract.events.NewUnbondingRequest + + @property + def PausedValidator(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event PausedValidator` on the Autonity contract.""" + return self._contract.events.PausedValidator + + @property + def RegisteredValidator(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event RegisteredValidator` on the Autonity contract.""" + return self._contract.events.RegisteredValidator + + @property + def ReleasedUnbondingReverted(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event ReleasedUnbondingReverted` on the Autonity contract.""" + return self._contract.events.ReleasedUnbondingReverted + + @property + def Rewarded(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event Rewarded` on the Autonity contract.""" + return self._contract.events.Rewarded + + @property + def Transfer(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event Transfer` on the Autonity contract.""" + return self._contract.events.Transfer + + @property + def UnbondingRejected(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event UnbondingRejected` on the Autonity contract.""" + return self._contract.events.UnbondingRejected + + @property + def UnlockingScheduleFailed(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event UnlockingScheduleFailed` on the Autonity contract.""" + return self._contract.events.UnlockingScheduleFailed + + def commission_rate_precision( + self, + ) -> int: + """Binding for `COMMISSION_RATE_PRECISION` on the Autonity contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.COMMISSION_RATE_PRECISION().call() + return int(return_value) + + def activate_validator( + self, + _address: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `activateValidator` on the Autonity contract. + + Re-activate the specified validator. + + Parameters + ---------- + _address : eth_typing.ChecksumAddress + address to be enabled. + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.activateValidator( + _address, + ) + + def allowance( + self, + owner: eth_typing.ChecksumAddress, + spender: eth_typing.ChecksumAddress, + ) -> int: + """Binding for `allowance` on the Autonity contract. + + Parameters + ---------- + owner : eth_typing.ChecksumAddress + spender : eth_typing.ChecksumAddress + + Returns + ------- + int + """ + return_value = self._contract.functions.allowance( + owner, + spender, + ).call() + return int(return_value) + + def approve( + self, + spender: eth_typing.ChecksumAddress, + amount: int, + ) -> contract.ContractFunction: + """Binding for `approve` on the Autonity contract. + + Parameters + ---------- + spender : eth_typing.ChecksumAddress + amount : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.approve( + spender, + amount, + ) + + def atn_total_redistributed( + self, + ) -> int: + """Binding for `atnTotalRedistributed` on the Autonity contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.atnTotalRedistributed().call() + return int(return_value) + + def balance_of( + self, + _addr: eth_typing.ChecksumAddress, + ) -> int: + """Binding for `balanceOf` on the Autonity contract. + + Returns the amount of unbonded Newton token held by the account (ERC-20). + + Parameters + ---------- + _addr : eth_typing.ChecksumAddress + + Returns + ------- + int + """ + return_value = self._contract.functions.balanceOf( + _addr, + ).call() + return int(return_value) + + def bond( + self, + _validator: eth_typing.ChecksumAddress, + _amount: int, + ) -> contract.ContractFunction: + """Binding for `bond` on the Autonity contract. + + Create a bonding(delegation) request with the caller as delegator. In case the + caller is a contract, it needs to send some gas so autonity can notify the + caller about staking operations. In case autonity fails to notify the caller + (contract), the applied request is reverted. + + Parameters + ---------- + _validator : eth_typing.ChecksumAddress + address of the validator to delegate stake to. + _amount : int + total amount of NTN to bond. + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.bond( + _validator, + _amount, + ) + + def burn( + self, + _addr: eth_typing.ChecksumAddress, + _amount: int, + ) -> contract.ContractFunction: + """Binding for `burn` on the Autonity contract. + + Burn the specified amount of NTN stake token from an account. Restricted to the + Operator account. This won't burn associated Liquid tokens. + + Parameters + ---------- + _addr : eth_typing.ChecksumAddress + _amount : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.burn( + _addr, + _amount, + ) + + def change_commission_rate( + self, + _validator: eth_typing.ChecksumAddress, + _rate: int, + ) -> contract.ContractFunction: + """Binding for `changeCommissionRate` on the Autonity contract. + + Change commission rate for the specified validator. + + Parameters + ---------- + _validator : eth_typing.ChecksumAddress + address to be enabled. _rate new commission rate, ranging between 0-10000 + (10000 = 100%). + _rate : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.changeCommissionRate( + _validator, + _rate, + ) + + def complete_contract_upgrade( + self, + ) -> contract.ContractFunction: + """Binding for `completeContractUpgrade` on the Autonity contract. + + Finalize the contract upgrade. To be called once the storage buffer for the new + contract are filled using {upgradeContract} The protocol will then update the + bytecode of the autonity contract at block finalization phase. + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.completeContractUpgrade() + + def config( + self, + ) -> Config: + """Binding for `config` on the Autonity contract. + + Returns + ------- + Config + """ + return_value = self._contract.functions.config().call() + return Config( + Policy( + int(return_value[0][0]), + int(return_value[0][1]), + int(return_value[0][2]), + int(return_value[0][3]), + int(return_value[0][4]), + eth_typing.ChecksumAddress(return_value[0][5]), + ), + Contracts( + eth_typing.ChecksumAddress(return_value[1][0]), + eth_typing.ChecksumAddress(return_value[1][1]), + eth_typing.ChecksumAddress(return_value[1][2]), + eth_typing.ChecksumAddress(return_value[1][3]), + eth_typing.ChecksumAddress(return_value[1][4]), + eth_typing.ChecksumAddress(return_value[1][5]), + eth_typing.ChecksumAddress(return_value[1][6]), + eth_typing.ChecksumAddress(return_value[1][7]), + ), + Protocol( + eth_typing.ChecksumAddress(return_value[2][0]), + int(return_value[2][1]), + int(return_value[2][2]), + int(return_value[2][3]), + ), + int(return_value[3]), + ) + + def decimals( + self, + ) -> int: + """Binding for `decimals` on the Autonity contract. + + Returns + ------- + int + the number of decimals the NTN token uses. + """ + return_value = self._contract.functions.decimals().call() + return int(return_value) + + def deployer( + self, + ) -> eth_typing.ChecksumAddress: + """Binding for `deployer` on the Autonity contract. + + Returns + ------- + eth_typing.ChecksumAddress + """ + return_value = self._contract.functions.deployer().call() + return eth_typing.ChecksumAddress(return_value) + + def epoch_id( + self, + ) -> int: + """Binding for `epochID` on the Autonity contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.epochID().call() + return int(return_value) + + def epoch_reward( + self, + ) -> int: + """Binding for `epochReward` on the Autonity contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.epochReward().call() + return int(return_value) + + def epoch_total_bonded_stake( + self, + ) -> int: + """Binding for `epochTotalBondedStake` on the Autonity contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.epochTotalBondedStake().call() + return int(return_value) + + def get_block_period( + self, + ) -> int: + """Binding for `getBlockPeriod` on the Autonity contract. + + Returns the block period. + + Returns + ------- + int + """ + return_value = self._contract.functions.getBlockPeriod().call() + return int(return_value) + + def get_committee( + self, + ) -> typing.List[CommitteeMember]: + """Binding for `getCommittee` on the Autonity contract. + + Returns the block committee. + + Returns + ------- + typing.List[CommitteeMember] + """ + return_value = self._contract.functions.getCommittee().call() + return [ + CommitteeMember( + eth_typing.ChecksumAddress(elem[0]), + int(elem[1]), + hexbytes.HexBytes(elem[2]), + ) + for elem in return_value + ] + + def get_committee_enodes( + self, + ) -> typing.List[str]: + """Binding for `getCommitteeEnodes` on the Autonity contract. + + Returns + ------- + typing.List[str] + Returns the consensus committee enodes. + """ + return_value = self._contract.functions.getCommitteeEnodes().call() + return [str(elem) for elem in return_value] + + def get_epoch_from_block( + self, + _block: int, + ) -> int: + """Binding for `getEpochFromBlock` on the Autonity contract. + + Returns epoch associated to the block number. + + Parameters + ---------- + _block : int + the input block number. + + Returns + ------- + int + """ + return_value = self._contract.functions.getEpochFromBlock( + _block, + ).call() + return int(return_value) + + def get_epoch_period( + self, + ) -> int: + """Binding for `getEpochPeriod` on the Autonity contract. + + Returns the epoch period. + + Returns + ------- + int + """ + return_value = self._contract.functions.getEpochPeriod().call() + return int(return_value) + + def get_last_epoch_block( + self, + ) -> int: + """Binding for `getLastEpochBlock` on the Autonity contract. + + Returns the last epoch's end block height. + + Returns + ------- + int + """ + return_value = self._contract.functions.getLastEpochBlock().call() + return int(return_value) + + def get_max_committee_size( + self, + ) -> int: + """Binding for `getMaxCommitteeSize` on the Autonity contract. + + Returns + ------- + int + Returns the maximum size of the consensus committee. + """ + return_value = self._contract.functions.getMaxCommitteeSize().call() + return int(return_value) + + def get_minimum_base_fee( + self, + ) -> int: + """Binding for `getMinimumBaseFee` on the Autonity contract. + + Returns + ------- + int + Returns the minimum gas price. + """ + return_value = self._contract.functions.getMinimumBaseFee().call() + return int(return_value) + + def get_new_contract( + self, + ) -> typing.Tuple[hexbytes.HexBytes, str]: + """Binding for `getNewContract` on the Autonity contract. + + Getter to retrieve a new Autonity contract bytecode and ABI when an upgrade is + initiated. + + Returns + ------- + hexbytes.HexBytes + `bytecode` the new contract bytecode. + str + `contractAbi` the new contract ABI. + """ + return_value = self._contract.functions.getNewContract().call() + return ( + hexbytes.HexBytes(return_value[0]), + str(return_value[1]), + ) + + def get_operator( + self, + ) -> eth_typing.ChecksumAddress: + """Binding for `getOperator` on the Autonity contract. + + Returns the current operator account. + + Returns + ------- + eth_typing.ChecksumAddress + """ + return_value = self._contract.functions.getOperator().call() + return eth_typing.ChecksumAddress(return_value) + + def get_oracle( + self, + ) -> eth_typing.ChecksumAddress: + """Binding for `getOracle` on the Autonity contract. + + Returns the current Oracle account. + + Returns + ------- + eth_typing.ChecksumAddress + """ + return_value = self._contract.functions.getOracle().call() + return eth_typing.ChecksumAddress(return_value) + + def get_proposer( + self, + height: int, + round: int, + ) -> eth_typing.ChecksumAddress: + """Binding for `getProposer` on the Autonity contract. + + getProposer returns the address of the proposer for the given height and round. + The proposer is selected from the committee via weighted random sampling, with + selection probability determined by the voting power of each committee member. + The selection mechanism is deterministic and will always select the same + address, given the same height, round and contract state. + + Parameters + ---------- + height : int + round : int + + Returns + ------- + eth_typing.ChecksumAddress + """ + return_value = self._contract.functions.getProposer( + height, + round, + ).call() + return eth_typing.ChecksumAddress(return_value) + + def get_reverting_amount( + self, + _unbonding_id: int, + ) -> int: + """Binding for `getRevertingAmount` on the Autonity contract. + + Returns the amount of LNTN or NTN bonded when the released unbonding was + reverted + + Parameters + ---------- + _unbonding_id : int + + Returns + ------- + int + """ + return_value = self._contract.functions.getRevertingAmount( + _unbonding_id, + ).call() + return int(return_value) + + def get_treasury_account( + self, + ) -> eth_typing.ChecksumAddress: + """Binding for `getTreasuryAccount` on the Autonity contract. + + Returns the current treasury account. + + Returns + ------- + eth_typing.ChecksumAddress + """ + return_value = self._contract.functions.getTreasuryAccount().call() + return eth_typing.ChecksumAddress(return_value) + + def get_treasury_fee( + self, + ) -> int: + """Binding for `getTreasuryFee` on the Autonity contract. + + Returns the current treasury fee. + + Returns + ------- + int + """ + return_value = self._contract.functions.getTreasuryFee().call() + return int(return_value) + + def get_unbonding_period( + self, + ) -> int: + """Binding for `getUnbondingPeriod` on the Autonity contract. + + Returns the un-bonding period. + + Returns + ------- + int + """ + return_value = self._contract.functions.getUnbondingPeriod().call() + return int(return_value) + + def get_unbonding_release_state( + self, + _unbonding_id: int, + ) -> UnbondingReleaseState: + """Binding for `getUnbondingReleaseState` on the Autonity contract. + + Returns the release state of the unbonding request + + Parameters + ---------- + _unbonding_id : int + + Returns + ------- + UnbondingReleaseState + """ + return_value = self._contract.functions.getUnbondingReleaseState( + _unbonding_id, + ).call() + return UnbondingReleaseState(return_value) + + def get_validator( + self, + _addr: eth_typing.ChecksumAddress, + ) -> Validator: + """Binding for `getValidator` on the Autonity contract. + + Parameters + ---------- + _addr : eth_typing.ChecksumAddress + + Returns + ------- + Validator + Returns a user object with the `_account` parameter. The returned data + object might be empty if there is no user associated. + """ + return_value = self._contract.functions.getValidator( + _addr, + ).call() + return Validator( + eth_typing.ChecksumAddress(return_value[0]), + eth_typing.ChecksumAddress(return_value[1]), + eth_typing.ChecksumAddress(return_value[2]), + str(return_value[3]), + int(return_value[4]), + int(return_value[5]), + int(return_value[6]), + int(return_value[7]), + int(return_value[8]), + int(return_value[9]), + int(return_value[10]), + int(return_value[11]), + eth_typing.ChecksumAddress(return_value[12]), + int(return_value[13]), + int(return_value[14]), + int(return_value[15]), + int(return_value[16]), + int(return_value[17]), + hexbytes.HexBytes(return_value[18]), + ValidatorState(return_value[19]), + ) + + def get_validators( + self, + ) -> typing.List[eth_typing.ChecksumAddress]: + """Binding for `getValidators` on the Autonity contract. + + Returns the current list of validators. + + Returns + ------- + typing.List[eth_typing.ChecksumAddress] + """ + return_value = self._contract.functions.getValidators().call() + return [eth_typing.ChecksumAddress(elem) for elem in return_value] + + def get_version( + self, + ) -> int: + """Binding for `getVersion` on the Autonity contract. + + Returns the current contract version. + + Returns + ------- + int + """ + return_value = self._contract.functions.getVersion().call() + return int(return_value) + + def inflation_reserve( + self, + ) -> int: + """Binding for `inflationReserve` on the Autonity contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.inflationReserve().call() + return int(return_value) + + def last_epoch_block( + self, + ) -> int: + """Binding for `lastEpochBlock` on the Autonity contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.lastEpochBlock().call() + return int(return_value) + + def last_epoch_time( + self, + ) -> int: + """Binding for `lastEpochTime` on the Autonity contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.lastEpochTime().call() + return int(return_value) + + def max_bond_applied_gas( + self, + ) -> int: + """Binding for `maxBondAppliedGas` on the Autonity contract. + + max allowed gas for notifying delegator (contract) about staking operations + + Returns + ------- + int + """ + return_value = self._contract.functions.maxBondAppliedGas().call() + return int(return_value) + + def max_rewards_distribution_gas( + self, + ) -> int: + """Binding for `maxRewardsDistributionGas` on the Autonity contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.maxRewardsDistributionGas().call() + return int(return_value) + + def max_unbond_applied_gas( + self, + ) -> int: + """Binding for `maxUnbondAppliedGas` on the Autonity contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.maxUnbondAppliedGas().call() + return int(return_value) + + def max_unbond_released_gas( + self, + ) -> int: + """Binding for `maxUnbondReleasedGas` on the Autonity contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.maxUnbondReleasedGas().call() + return int(return_value) + + def mint( + self, + _addr: eth_typing.ChecksumAddress, + _amount: int, + ) -> contract.ContractFunction: + """Binding for `mint` on the Autonity contract. + + Parameters + ---------- + _addr : eth_typing.ChecksumAddress + _amount : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.mint( + _addr, + _amount, + ) + + def name( + self, + ) -> str: + """Binding for `name` on the Autonity contract. + + Returns + ------- + str + the name of the stake token. + """ + return_value = self._contract.functions.name().call() + return str(return_value) + + def pause_validator( + self, + _address: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `pauseValidator` on the Autonity contract. + + Pause the validator and stop it accepting delegations. + + Parameters + ---------- + _address : eth_typing.ChecksumAddress + address to be disabled. + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.pauseValidator( + _address, + ) + + def receive_atn( + self, + ) -> contract.ContractFunction: + """Binding for `receiveATN` on the Autonity contract. + + can be used to send AUT to the contract + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.receiveATN() + + def register_validator( + self, + _enode: str, + _oracle_address: eth_typing.ChecksumAddress, + _consensus_key: hexbytes.HexBytes, + _signatures: hexbytes.HexBytes, + ) -> contract.ContractFunction: + """Binding for `registerValidator` on the Autonity contract. + + Register a new validator in the system. The validator might be selected to be + part of consensus. This validator will have assigned to its treasury account the + caller of this function. A new token "Liquid Stake" is deployed at this phase. + + Parameters + ---------- + _enode : str + enode identifying the validator node. + _oracle_address : eth_typing.ChecksumAddress + _consensus_key : hexbytes.HexBytes + _signatures : hexbytes.HexBytes + is a combination of two ecdsa signatures, and a bls signature as the + ownership proof of the validator key appended sequentially. The 1st two + ecdsa signatures are in below order: 1. a message containing treasury + account and signed by validator account private key . 2. a message + containing treasury account and signed by Oracle account private key . + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.registerValidator( + _enode, + _oracle_address, + _consensus_key, + _signatures, + ) + + def reset_contract_upgrade( + self, + ) -> contract.ContractFunction: + """Binding for `resetContractUpgrade` on the Autonity contract. + + Reset internal storage contract-upgrade buffers in case of issue. + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.resetContractUpgrade() + + def set_accountability_contract( + self, + _address: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `setAccountabilityContract` on the Autonity contract. + + Parameters + ---------- + _address : eth_typing.ChecksumAddress + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setAccountabilityContract( + _address, + ) + + def set_acu_contract( + self, + _address: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `setAcuContract` on the Autonity contract. + + Parameters + ---------- + _address : eth_typing.ChecksumAddress + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setAcuContract( + _address, + ) + + def set_committee_size( + self, + _size: int, + ) -> contract.ContractFunction: + """Binding for `setCommitteeSize` on the Autonity contract. + + Parameters + ---------- + _size : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setCommitteeSize( + _size, + ) + + def set_epoch_period( + self, + _period: int, + ) -> contract.ContractFunction: + """Binding for `setEpochPeriod` on the Autonity contract. + + Parameters + ---------- + _period : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setEpochPeriod( + _period, + ) + + def set_inflation_controller_contract( + self, + _address: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `setInflationControllerContract` on the Autonity contract. + + Parameters + ---------- + _address : eth_typing.ChecksumAddress + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setInflationControllerContract( + _address, + ) + + def set_max_bond_applied_gas( + self, + _gas: int, + ) -> contract.ContractFunction: + """Binding for `setMaxBondAppliedGas` on the Autonity contract. + + sets the value of max allowed gas for notifying delegator about staking + operations NOTE: before updating, please check if the updated value works. It + can be checked by updatting the hardcoded value of requiredGasBond and then + compiling the contracts and running the tests in stakable_vesting_test.go + + Parameters + ---------- + _gas : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setMaxBondAppliedGas( + _gas, + ) + + def set_max_rewards_distribution_gas( + self, + _gas: int, + ) -> contract.ContractFunction: + """Binding for `setMaxRewardsDistributionGas` on the Autonity contract. + + Parameters + ---------- + _gas : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setMaxRewardsDistributionGas( + _gas, + ) + + def set_max_unbond_applied_gas( + self, + _gas: int, + ) -> contract.ContractFunction: + """Binding for `setMaxUnbondAppliedGas` on the Autonity contract. + + Parameters + ---------- + _gas : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setMaxUnbondAppliedGas( + _gas, + ) + + def set_max_unbond_released_gas( + self, + _gas: int, + ) -> contract.ContractFunction: + """Binding for `setMaxUnbondReleasedGas` on the Autonity contract. + + Parameters + ---------- + _gas : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setMaxUnbondReleasedGas( + _gas, + ) + + def set_minimum_base_fee( + self, + _price: int, + ) -> contract.ContractFunction: + """Binding for `setMinimumBaseFee` on the Autonity contract. + + Set the minimum gas price. Restricted to the operator account. + + Parameters + ---------- + _price : int + Positive integer. + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setMinimumBaseFee( + _price, + ) + + def set_non_stakable_vesting_contract( + self, + _address: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `setNonStakableVestingContract` on the Autonity contract. + + Set the Non-stakable Vesting contract address. + + Parameters + ---------- + _address : eth_typing.ChecksumAddress + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setNonStakableVestingContract( + _address, + ) + + def set_operator_account( + self, + _account: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `setOperatorAccount` on the Autonity contract. + + Parameters + ---------- + _account : eth_typing.ChecksumAddress + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setOperatorAccount( + _account, + ) + + def set_oracle_contract( + self, + _address: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `setOracleContract` on the Autonity contract. + + Parameters + ---------- + _address : eth_typing.ChecksumAddress + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setOracleContract( + _address, + ) + + def set_stabilization_contract( + self, + _address: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `setStabilizationContract` on the Autonity contract. + + Parameters + ---------- + _address : eth_typing.ChecksumAddress + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setStabilizationContract( + _address, + ) + + def set_staking_gas_price( + self, + _price: int, + ) -> contract.ContractFunction: + """Binding for `setStakingGasPrice` on the Autonity contract. + + Set gas price for notification on staking operation + + Parameters + ---------- + _price : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setStakingGasPrice( + _price, + ) + + def set_supply_control_contract( + self, + _address: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `setSupplyControlContract` on the Autonity contract. + + Parameters + ---------- + _address : eth_typing.ChecksumAddress + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setSupplyControlContract( + _address, + ) + + def set_treasury_account( + self, + _account: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `setTreasuryAccount` on the Autonity contract. + + Parameters + ---------- + _account : eth_typing.ChecksumAddress + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setTreasuryAccount( + _account, + ) + + def set_treasury_fee( + self, + _treasury_fee: int, + ) -> contract.ContractFunction: + """Binding for `setTreasuryFee` on the Autonity contract. + + Parameters + ---------- + _treasury_fee : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setTreasuryFee( + _treasury_fee, + ) + + def set_unbonding_period( + self, + _period: int, + ) -> contract.ContractFunction: + """Binding for `setUnbondingPeriod` on the Autonity contract. + + Parameters + ---------- + _period : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setUnbondingPeriod( + _period, + ) + + def set_upgrade_manager_contract( + self, + _address: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `setUpgradeManagerContract` on the Autonity contract. + + Parameters + ---------- + _address : eth_typing.ChecksumAddress + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setUpgradeManagerContract( + _address, + ) + + def staking_gas_price( + self, + ) -> int: + """Binding for `stakingGasPrice` on the Autonity contract. + + the gas price to notify the delegator (only if contract) about the staking + operation at epoch end + + Returns + ------- + int + """ + return_value = self._contract.functions.stakingGasPrice().call() + return int(return_value) + + def symbol( + self, + ) -> str: + """Binding for `symbol` on the Autonity contract. + + Returns + ------- + str + the Stake token's symbol. + """ + return_value = self._contract.functions.symbol().call() + return str(return_value) + + def total_supply( + self, + ) -> int: + """Binding for `totalSupply` on the Autonity contract. + + Returns the total amount of stake token issued. + + Returns + ------- + int + """ + return_value = self._contract.functions.totalSupply().call() + return int(return_value) + + def transfer( + self, + _recipient: eth_typing.ChecksumAddress, + _amount: int, + ) -> contract.ContractFunction: + """Binding for `transfer` on the Autonity contract. + + Moves `amount` NTN stake tokens from the caller's account to `recipient`. + + Parameters + ---------- + _recipient : eth_typing.ChecksumAddress + _amount : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.transfer( + _recipient, + _amount, + ) + + def transfer_from( + self, + _sender: eth_typing.ChecksumAddress, + _recipient: eth_typing.ChecksumAddress, + _amount: int, + ) -> contract.ContractFunction: + """Binding for `transferFrom` on the Autonity contract. + + Parameters + ---------- + _sender : eth_typing.ChecksumAddress + _recipient : eth_typing.ChecksumAddress + _amount : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.transferFrom( + _sender, + _recipient, + _amount, + ) + + def unbond( + self, + _validator: eth_typing.ChecksumAddress, + _amount: int, + ) -> contract.ContractFunction: + """Binding for `unbond` on the Autonity contract. + + Create an unbonding request with the caller as delegator. In case the caller is + a contract, it needs to send some gas so autonity can notify the caller about + staking operations. In case autonity fails to notify the caller (contract), the + applied request is reverted. + + Parameters + ---------- + _validator : eth_typing.ChecksumAddress + address of the validator to unbond stake to. + _amount : int + total amount of LNTN (or NTN if self delegated) to unbond. + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.unbond( + _validator, + _amount, + ) + + def update_enode( + self, + _node_address: eth_typing.ChecksumAddress, + _enode: str, + ) -> contract.ContractFunction: + """Binding for `updateEnode` on the Autonity contract. + + Update enode of a registered validator. This function updates the network + connection information (IP or/and port) of a registered validator. you cannot + change the validator's address (pubkey part of the enode) + + Parameters + ---------- + _node_address : eth_typing.ChecksumAddress + _enode : str + new enode to be updated + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.updateEnode( + _node_address, + _enode, + ) + + def upgrade_contract( + self, + _bytecode: hexbytes.HexBytes, + _abi: str, + ) -> contract.ContractFunction: + """Binding for `upgradeContract` on the Autonity contract. + + Append to the contract storage buffer the new contract bytecode and abi. Should + be called as many times as required. + + Parameters + ---------- + _bytecode : hexbytes.HexBytes + _abi : str + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.upgradeContract( + _bytecode, + _abi, + ) + + +ABI = typing.cast( + eth_typing.ABI, + [ + { + "inputs": [ + { + "components": [ + { + "internalType": "address payable", + "name": "treasury", + "type": "address", + }, + { + "internalType": "address", + "name": "nodeAddress", + "type": "address", + }, + { + "internalType": "address", + "name": "oracleAddress", + "type": "address", + }, + {"internalType": "string", "name": "enode", "type": "string"}, + { + "internalType": "uint256", + "name": "commissionRate", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "bondedStake", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "unbondingStake", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "unbondingShares", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "selfBondedStake", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "selfUnbondingStake", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "selfUnbondingShares", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "selfUnbondingStakeLocked", + "type": "uint256", + }, + { + "internalType": "contract Liquid", + "name": "liquidContract", + "type": "address", + }, + { + "internalType": "uint256", + "name": "liquidSupply", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "registrationBlock", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "totalSlashed", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "jailReleaseBlock", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "provableFaultCount", + "type": "uint256", + }, + { + "internalType": "bytes", + "name": "consensusKey", + "type": "bytes", + }, + { + "internalType": "enum ValidatorState", + "name": "state", + "type": "uint8", + }, + ], + "internalType": "struct Autonity.Validator[]", + "name": "_validators", + "type": "tuple[]", + }, + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "treasuryFee", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "minBaseFee", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "delegationRate", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "unbondingPeriod", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "initialInflationReserve", + "type": "uint256", + }, + { + "internalType": "address payable", + "name": "treasuryAccount", + "type": "address", + }, + ], + "internalType": "struct Autonity.Policy", + "name": "policy", + "type": "tuple", + }, + { + "components": [ + { + "internalType": "contract IAccountability", + "name": "accountabilityContract", + "type": "address", + }, + { + "internalType": "contract IOracle", + "name": "oracleContract", + "type": "address", + }, + { + "internalType": "contract IACU", + "name": "acuContract", + "type": "address", + }, + { + "internalType": "contract ISupplyControl", + "name": "supplyControlContract", + "type": "address", + }, + { + "internalType": "contract IStabilization", + "name": "stabilizationContract", + "type": "address", + }, + { + "internalType": "contract UpgradeManager", + "name": "upgradeManagerContract", + "type": "address", + }, + { + "internalType": "contract IInflationController", + "name": "inflationControllerContract", + "type": "address", + }, + { + "internalType": "contract INonStakableVestingVault", + "name": "nonStakableVestingContract", + "type": "address", + }, + ], + "internalType": "struct Autonity.Contracts", + "name": "contracts", + "type": "tuple", + }, + { + "components": [ + { + "internalType": "address", + "name": "operatorAccount", + "type": "address", + }, + { + "internalType": "uint256", + "name": "epochPeriod", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "blockPeriod", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "committeeSize", + "type": "uint256", + }, + ], + "internalType": "struct Autonity.Protocol", + "name": "protocol", + "type": "tuple", + }, + { + "internalType": "uint256", + "name": "contractVersion", + "type": "uint256", + }, + ], + "internalType": "struct Autonity.Config", + "name": "_config", + "type": "tuple", + }, + ], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "treasury", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "addr", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "effectiveBlock", + "type": "uint256", + }, + ], + "name": "ActivatedValidator", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "validator", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "delegator", + "type": "address", + }, + { + "indexed": False, + "internalType": "bool", + "name": "selfBonded", + "type": "bool", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + ], + "name": "AppliedUnbondingReverted", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "owner", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "spender", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "value", + "type": "uint256", + }, + ], + "name": "Approval", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "validator", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "delegator", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "enum ValidatorState", + "name": "state", + "type": "uint8", + }, + ], + "name": "BondingRejected", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "validator", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "delegator", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + ], + "name": "BondingReverted", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "addr", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + ], + "name": "BurnedStake", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "validator", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "rate", + "type": "uint256", + }, + ], + "name": "CommissionRateChange", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "period", + "type": "uint256", + } + ], + "name": "EpochPeriodUpdated", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "gasPrice", + "type": "uint256", + } + ], + "name": "MinimumBaseFeeUpdated", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "addr", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + ], + "name": "MintedStake", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "validator", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "delegator", + "type": "address", + }, + { + "indexed": False, + "internalType": "bool", + "name": "selfBonded", + "type": "bool", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + ], + "name": "NewBondingRequest", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "epoch", + "type": "uint256", + } + ], + "name": "NewEpoch", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "validator", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "delegator", + "type": "address", + }, + { + "indexed": False, + "internalType": "bool", + "name": "selfBonded", + "type": "bool", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + ], + "name": "NewUnbondingRequest", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "treasury", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "addr", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "effectiveBlock", + "type": "uint256", + }, + ], + "name": "PausedValidator", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "address", + "name": "treasury", + "type": "address", + }, + { + "indexed": False, + "internalType": "address", + "name": "addr", + "type": "address", + }, + { + "indexed": False, + "internalType": "address", + "name": "oracleAddress", + "type": "address", + }, + { + "indexed": False, + "internalType": "string", + "name": "enode", + "type": "string", + }, + { + "indexed": False, + "internalType": "address", + "name": "liquidContract", + "type": "address", + }, + ], + "name": "RegisteredValidator", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "validator", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "delegator", + "type": "address", + }, + { + "indexed": False, + "internalType": "bool", + "name": "selfBonded", + "type": "bool", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + ], + "name": "ReleasedUnbondingReverted", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "addr", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "atnAmount", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "ntnAmount", + "type": "uint256", + }, + ], + "name": "Rewarded", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "from", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "value", + "type": "uint256", + }, + ], + "name": "Transfer", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "validator", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "delegator", + "type": "address", + }, + { + "indexed": False, + "internalType": "bool", + "name": "selfBonded", + "type": "bool", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + ], + "name": "UnbondingRejected", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "epochTime", + "type": "uint256", + } + ], + "name": "UnlockingScheduleFailed", + "type": "event", + }, + {"stateMutability": "payable", "type": "fallback"}, + { + "inputs": [], + "name": "COMMISSION_RATE_PRECISION", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_address", "type": "address"} + ], + "name": "activateValidator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "owner", "type": "address"}, + {"internalType": "address", "name": "spender", "type": "address"}, + ], + "name": "allowance", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "spender", "type": "address"}, + {"internalType": "uint256", "name": "amount", "type": "uint256"}, + ], + "name": "approve", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "atnTotalRedistributed", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "address", "name": "_addr", "type": "address"}], + "name": "balanceOf", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_validator", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "bond", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_addr", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_validator", "type": "address"}, + {"internalType": "uint256", "name": "_rate", "type": "uint256"}, + ], + "name": "changeCommissionRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "completeContractUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "computeCommittee", + "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "config", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "treasuryFee", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "minBaseFee", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "delegationRate", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "unbondingPeriod", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "initialInflationReserve", + "type": "uint256", + }, + { + "internalType": "address payable", + "name": "treasuryAccount", + "type": "address", + }, + ], + "internalType": "struct Autonity.Policy", + "name": "policy", + "type": "tuple", + }, + { + "components": [ + { + "internalType": "contract IAccountability", + "name": "accountabilityContract", + "type": "address", + }, + { + "internalType": "contract IOracle", + "name": "oracleContract", + "type": "address", + }, + { + "internalType": "contract IACU", + "name": "acuContract", + "type": "address", + }, + { + "internalType": "contract ISupplyControl", + "name": "supplyControlContract", + "type": "address", + }, + { + "internalType": "contract IStabilization", + "name": "stabilizationContract", + "type": "address", + }, + { + "internalType": "contract UpgradeManager", + "name": "upgradeManagerContract", + "type": "address", + }, + { + "internalType": "contract IInflationController", + "name": "inflationControllerContract", + "type": "address", + }, + { + "internalType": "contract INonStakableVestingVault", + "name": "nonStakableVestingContract", + "type": "address", + }, + ], + "internalType": "struct Autonity.Contracts", + "name": "contracts", + "type": "tuple", + }, + { + "components": [ + { + "internalType": "address", + "name": "operatorAccount", + "type": "address", + }, + { + "internalType": "uint256", + "name": "epochPeriod", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "blockPeriod", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "committeeSize", + "type": "uint256", + }, + ], + "internalType": "struct Autonity.Protocol", + "name": "protocol", + "type": "tuple", + }, + { + "internalType": "uint256", + "name": "contractVersion", + "type": "uint256", + }, + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "decimals", + "outputs": [{"internalType": "uint8", "name": "", "type": "uint8"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [], + "name": "deployer", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "epochID", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "epochReward", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "epochTotalBondedStake", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "finalize", + "outputs": [ + {"internalType": "bool", "name": "", "type": "bool"}, + { + "components": [ + {"internalType": "address", "name": "addr", "type": "address"}, + { + "internalType": "uint256", + "name": "votingPower", + "type": "uint256", + }, + { + "internalType": "bytes", + "name": "consensusKey", + "type": "bytes", + }, + ], + "internalType": "struct Autonity.CommitteeMember[]", + "name": "", + "type": "tuple[]", + }, + ], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "finalizeInitialization", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "getBlockPeriod", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getCommittee", + "outputs": [ + { + "components": [ + {"internalType": "address", "name": "addr", "type": "address"}, + { + "internalType": "uint256", + "name": "votingPower", + "type": "uint256", + }, + { + "internalType": "bytes", + "name": "consensusKey", + "type": "bytes", + }, + ], + "internalType": "struct Autonity.CommitteeMember[]", + "name": "", + "type": "tuple[]", + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getCommitteeEnodes", + "outputs": [{"internalType": "string[]", "name": "", "type": "string[]"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "_block", "type": "uint256"} + ], + "name": "getEpochFromBlock", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getEpochPeriod", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getLastEpochBlock", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getMaxCommitteeSize", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getMinimumBaseFee", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getNewContract", + "outputs": [ + {"internalType": "bytes", "name": "", "type": "bytes"}, + {"internalType": "string", "name": "", "type": "string"}, + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getOperator", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getOracle", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "height", "type": "uint256"}, + {"internalType": "uint256", "name": "round", "type": "uint256"}, + ], + "name": "getProposer", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "_unbondingID", "type": "uint256"} + ], + "name": "getRevertingAmount", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getTreasuryAccount", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getTreasuryFee", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getUnbondingPeriod", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "_unbondingID", "type": "uint256"} + ], + "name": "getUnbondingReleaseState", + "outputs": [ + { + "internalType": "enum Autonity.UnbondingReleaseState", + "name": "", + "type": "uint8", + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "address", "name": "_addr", "type": "address"}], + "name": "getValidator", + "outputs": [ + { + "components": [ + { + "internalType": "address payable", + "name": "treasury", + "type": "address", + }, + { + "internalType": "address", + "name": "nodeAddress", + "type": "address", + }, + { + "internalType": "address", + "name": "oracleAddress", + "type": "address", + }, + {"internalType": "string", "name": "enode", "type": "string"}, + { + "internalType": "uint256", + "name": "commissionRate", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "bondedStake", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "unbondingStake", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "unbondingShares", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "selfBondedStake", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "selfUnbondingStake", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "selfUnbondingShares", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "selfUnbondingStakeLocked", + "type": "uint256", + }, + { + "internalType": "contract Liquid", + "name": "liquidContract", + "type": "address", + }, + { + "internalType": "uint256", + "name": "liquidSupply", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "registrationBlock", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "totalSlashed", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "jailReleaseBlock", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "provableFaultCount", + "type": "uint256", + }, + { + "internalType": "bytes", + "name": "consensusKey", + "type": "bytes", + }, + { + "internalType": "enum ValidatorState", + "name": "state", + "type": "uint8", + }, + ], + "internalType": "struct Autonity.Validator", + "name": "", + "type": "tuple", + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getValidators", + "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getVersion", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "inflationReserve", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "lastEpochBlock", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "lastEpochTime", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "maxBondAppliedGas", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "maxRewardsDistributionGas", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "maxUnbondAppliedGas", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "maxUnbondReleasedGas", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_addr", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "name", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_address", "type": "address"} + ], + "name": "pauseValidator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "receiveATN", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "string", "name": "_enode", "type": "string"}, + { + "internalType": "address", + "name": "_oracleAddress", + "type": "address", + }, + {"internalType": "bytes", "name": "_consensusKey", "type": "bytes"}, + {"internalType": "bytes", "name": "_signatures", "type": "bytes"}, + ], + "name": "registerValidator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "resetContractUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "contract IAccountability", + "name": "_address", + "type": "address", + } + ], + "name": "setAccountabilityContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "contract IACU", "name": "_address", "type": "address"} + ], + "name": "setAcuContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "_size", "type": "uint256"}], + "name": "setCommitteeSize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "_period", "type": "uint256"} + ], + "name": "setEpochPeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "contract IInflationController", + "name": "_address", + "type": "address", + } + ], + "name": "setInflationControllerContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "_gas", "type": "uint256"}], + "name": "setMaxBondAppliedGas", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "_gas", "type": "uint256"}], + "name": "setMaxRewardsDistributionGas", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "_gas", "type": "uint256"}], + "name": "setMaxUnbondAppliedGas", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "_gas", "type": "uint256"}], + "name": "setMaxUnbondReleasedGas", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "_price", "type": "uint256"} + ], + "name": "setMinimumBaseFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "contract INonStakableVestingVault", + "name": "_address", + "type": "address", + } + ], + "name": "setNonStakableVestingContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_account", "type": "address"} + ], + "name": "setOperatorAccount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_address", + "type": "address", + } + ], + "name": "setOracleContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "contract IStabilization", + "name": "_address", + "type": "address", + } + ], + "name": "setStabilizationContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "_price", "type": "uint256"} + ], + "name": "setStakingGasPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "contract ISupplyControl", + "name": "_address", + "type": "address", + } + ], + "name": "setSupplyControlContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_account", + "type": "address", + } + ], + "name": "setTreasuryAccount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "_treasuryFee", "type": "uint256"} + ], + "name": "setTreasuryFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "_period", "type": "uint256"} + ], + "name": "setUnbondingPeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "contract UpgradeManager", + "name": "_address", + "type": "address", + } + ], + "name": "setUpgradeManagerContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "stakingGasPrice", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "symbol", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_recipient", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "transfer", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_sender", "type": "address"}, + {"internalType": "address", "name": "_recipient", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "transferFrom", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_validator", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "unbond", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_nodeAddress", "type": "address"}, + {"internalType": "string", "name": "_enode", "type": "string"}, + ], + "name": "updateEnode", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address payable", + "name": "treasury", + "type": "address", + }, + { + "internalType": "address", + "name": "nodeAddress", + "type": "address", + }, + { + "internalType": "address", + "name": "oracleAddress", + "type": "address", + }, + {"internalType": "string", "name": "enode", "type": "string"}, + { + "internalType": "uint256", + "name": "commissionRate", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "bondedStake", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "unbondingStake", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "unbondingShares", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "selfBondedStake", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "selfUnbondingStake", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "selfUnbondingShares", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "selfUnbondingStakeLocked", + "type": "uint256", + }, + { + "internalType": "contract Liquid", + "name": "liquidContract", + "type": "address", + }, + { + "internalType": "uint256", + "name": "liquidSupply", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "registrationBlock", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "totalSlashed", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "jailReleaseBlock", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "provableFaultCount", + "type": "uint256", + }, + { + "internalType": "bytes", + "name": "consensusKey", + "type": "bytes", + }, + { + "internalType": "enum ValidatorState", + "name": "state", + "type": "uint8", + }, + ], + "internalType": "struct Autonity.Validator", + "name": "_val", + "type": "tuple", + } + ], + "name": "updateValidatorAndTransferSlashedFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "bytes", "name": "_bytecode", "type": "bytes"}, + {"internalType": "string", "name": "_abi", "type": "string"}, + ], + "name": "upgradeContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + {"stateMutability": "payable", "type": "receive"}, + ], +) diff --git a/autonity/contracts/ierc20.py b/autonity/contracts/ierc20.py new file mode 100644 index 0000000..d1ae4fc --- /dev/null +++ b/autonity/contracts/ierc20.py @@ -0,0 +1,280 @@ +"""IERC20 contract binding and data structures.""" + +# This module has been generated using pyabigen v0.2.9 + +import typing + +import eth_typing +import web3 +from web3.contract import base_contract, contract + +__version__ = "v0.14.0" + + +class IERC20: + """IERC20 contract binding. + + Parameters + ---------- + w3 : web3.Web3 + address : eth_typing.ChecksumAddress + The address of a deployed IERC20 contract. + """ + + _contract: contract.Contract + + def __init__( + self, + w3: web3.Web3, + address: eth_typing.ChecksumAddress, + ): + self._contract = w3.eth.contract( + address=address, + abi=ABI, + ) + + @property + def Approval(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event Approval` on the IERC20 contract.""" + return self._contract.events.Approval + + @property + def Transfer(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event Transfer` on the IERC20 contract.""" + return self._contract.events.Transfer + + def allowance( + self, + owner: eth_typing.ChecksumAddress, + spender: eth_typing.ChecksumAddress, + ) -> int: + """Binding for `allowance` on the IERC20 contract. + + Parameters + ---------- + owner : eth_typing.ChecksumAddress + spender : eth_typing.ChecksumAddress + + Returns + ------- + int + """ + return_value = self._contract.functions.allowance( + owner, + spender, + ).call() + return int(return_value) + + def approve( + self, + spender: eth_typing.ChecksumAddress, + amount: int, + ) -> contract.ContractFunction: + """Binding for `approve` on the IERC20 contract. + + Parameters + ---------- + spender : eth_typing.ChecksumAddress + amount : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.approve( + spender, + amount, + ) + + def balance_of( + self, + account: eth_typing.ChecksumAddress, + ) -> int: + """Binding for `balanceOf` on the IERC20 contract. + + Parameters + ---------- + account : eth_typing.ChecksumAddress + + Returns + ------- + int + """ + return_value = self._contract.functions.balanceOf( + account, + ).call() + return int(return_value) + + def total_supply( + self, + ) -> int: + """Binding for `totalSupply` on the IERC20 contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.totalSupply().call() + return int(return_value) + + def transfer( + self, + recipient: eth_typing.ChecksumAddress, + amount: int, + ) -> contract.ContractFunction: + """Binding for `transfer` on the IERC20 contract. + + Parameters + ---------- + recipient : eth_typing.ChecksumAddress + amount : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.transfer( + recipient, + amount, + ) + + def transfer_from( + self, + sender: eth_typing.ChecksumAddress, + recipient: eth_typing.ChecksumAddress, + amount: int, + ) -> contract.ContractFunction: + """Binding for `transferFrom` on the IERC20 contract. + + Parameters + ---------- + sender : eth_typing.ChecksumAddress + recipient : eth_typing.ChecksumAddress + amount : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.transferFrom( + sender, + recipient, + amount, + ) + + +ABI = typing.cast( + eth_typing.ABI, + [ + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "owner", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "spender", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "value", + "type": "uint256", + }, + ], + "name": "Approval", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "from", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "value", + "type": "uint256", + }, + ], + "name": "Transfer", + "type": "event", + }, + { + "inputs": [ + {"internalType": "address", "name": "owner", "type": "address"}, + {"internalType": "address", "name": "spender", "type": "address"}, + ], + "name": "allowance", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "spender", "type": "address"}, + {"internalType": "uint256", "name": "amount", "type": "uint256"}, + ], + "name": "approve", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "account", "type": "address"} + ], + "name": "balanceOf", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "recipient", "type": "address"}, + {"internalType": "uint256", "name": "amount", "type": "uint256"}, + ], + "name": "transfer", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "sender", "type": "address"}, + {"internalType": "address", "name": "recipient", "type": "address"}, + {"internalType": "uint256", "name": "amount", "type": "uint256"}, + ], + "name": "transferFrom", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "nonpayable", + "type": "function", + }, + ], +) diff --git a/autonity/contracts/inflation_controller.py b/autonity/contracts/inflation_controller.py new file mode 100644 index 0000000..14c3aaf --- /dev/null +++ b/autonity/contracts/inflation_controller.py @@ -0,0 +1,255 @@ +"""InflationController contract binding and data structures.""" + +# This module has been generated using pyabigen v0.2.9 + +import typing + +import eth_typing +import web3 +from dataclasses import dataclass +from web3.contract import contract + +__version__ = "v0.14.0" + + +@dataclass +class Params: + """Port of `struct Params` on the InflationController contract.""" + + inflation_rate_initial: int + inflation_rate_transition: int + inflation_curve_convexity: int + inflation_transition_period: int + inflation_reserve_decay_rate: int + + +class InflationController: + """InflationController contract binding. + + Parameters + ---------- + w3 : web3.Web3 + address : eth_typing.ChecksumAddress + The address of a deployed InflationController contract. + """ + + _contract: contract.Contract + + def __init__( + self, + w3: web3.Web3, + address: eth_typing.ChecksumAddress, + ): + self._contract = w3.eth.contract( + address=address, + abi=ABI, + ) + + def calculate_supply_delta( + self, + _current_supply: int, + _inflation_reserve: int, + _last_epoch_time: int, + _current_epoch_time: int, + ) -> int: + """Binding for `calculateSupplyDelta` on the InflationController contract. + + Main function. Calculate NTN inflation. + + Parameters + ---------- + _current_supply : int + _inflation_reserve : int + _last_epoch_time : int + _current_epoch_time : int + + Returns + ------- + int + """ + return_value = self._contract.functions.calculateSupplyDelta( + _current_supply, + _inflation_reserve, + _last_epoch_time, + _current_epoch_time, + ).call() + return int(return_value) + + def params( + self, + ) -> Params: + """Binding for `params` on the InflationController contract. + + Returns + ------- + Params + """ + return_value = self._contract.functions.params().call() + return Params( + int(return_value[0]), + int(return_value[1]), + int(return_value[2]), + int(return_value[3]), + int(return_value[4]), + ) + + +ABI = typing.cast( + eth_typing.ABI, + [ + { + "inputs": [ + { + "components": [ + { + "internalType": "SD59x18", + "name": "inflationRateInitial", + "type": "int256", + }, + { + "internalType": "SD59x18", + "name": "inflationRateTransition", + "type": "int256", + }, + { + "internalType": "SD59x18", + "name": "inflationCurveConvexity", + "type": "int256", + }, + { + "internalType": "SD59x18", + "name": "inflationTransitionPeriod", + "type": "int256", + }, + { + "internalType": "SD59x18", + "name": "inflationReserveDecayRate", + "type": "int256", + }, + ], + "internalType": "struct InflationController.Params", + "name": "_params", + "type": "tuple", + } + ], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "x", "type": "uint256"}, + {"internalType": "uint256", "name": "y", "type": "uint256"}, + ], + "name": "PRBMath_MulDiv18_Overflow", + "type": "error", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "x", "type": "uint256"}, + {"internalType": "uint256", "name": "y", "type": "uint256"}, + {"internalType": "uint256", "name": "denominator", "type": "uint256"}, + ], + "name": "PRBMath_MulDiv_Overflow", + "type": "error", + }, + { + "inputs": [{"internalType": "int256", "name": "x", "type": "int256"}], + "name": "PRBMath_SD59x18_Convert_Overflow", + "type": "error", + }, + { + "inputs": [{"internalType": "int256", "name": "x", "type": "int256"}], + "name": "PRBMath_SD59x18_Convert_Underflow", + "type": "error", + }, + {"inputs": [], "name": "PRBMath_SD59x18_Div_InputTooSmall", "type": "error"}, + { + "inputs": [ + {"internalType": "SD59x18", "name": "x", "type": "int256"}, + {"internalType": "SD59x18", "name": "y", "type": "int256"}, + ], + "name": "PRBMath_SD59x18_Div_Overflow", + "type": "error", + }, + { + "inputs": [{"internalType": "SD59x18", "name": "x", "type": "int256"}], + "name": "PRBMath_SD59x18_Exp2_InputTooBig", + "type": "error", + }, + { + "inputs": [{"internalType": "SD59x18", "name": "x", "type": "int256"}], + "name": "PRBMath_SD59x18_Exp_InputTooBig", + "type": "error", + }, + {"inputs": [], "name": "PRBMath_SD59x18_Mul_InputTooSmall", "type": "error"}, + { + "inputs": [ + {"internalType": "SD59x18", "name": "x", "type": "int256"}, + {"internalType": "SD59x18", "name": "y", "type": "int256"}, + ], + "name": "PRBMath_SD59x18_Mul_Overflow", + "type": "error", + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_currentSupply", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "_inflationReserve", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "_lastEpochTime", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "_currentEpochTime", + "type": "uint256", + }, + ], + "name": "calculateSupplyDelta", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "params", + "outputs": [ + { + "internalType": "SD59x18", + "name": "inflationRateInitial", + "type": "int256", + }, + { + "internalType": "SD59x18", + "name": "inflationRateTransition", + "type": "int256", + }, + { + "internalType": "SD59x18", + "name": "inflationCurveConvexity", + "type": "int256", + }, + { + "internalType": "SD59x18", + "name": "inflationTransitionPeriod", + "type": "int256", + }, + { + "internalType": "SD59x18", + "name": "inflationReserveDecayRate", + "type": "int256", + }, + ], + "stateMutability": "view", + "type": "function", + }, + ], +) diff --git a/autonity/contracts/liquid.py b/autonity/contracts/liquid.py new file mode 100644 index 0000000..a4c9ceb --- /dev/null +++ b/autonity/contracts/liquid.py @@ -0,0 +1,641 @@ +"""Liquid contract binding and data structures.""" + +# This module has been generated using pyabigen v0.2.9 + +import typing + +import eth_typing +import web3 +from web3.contract import base_contract, contract + +__version__ = "v0.14.0" + + +class Liquid: + """Liquid contract binding. + + Parameters + ---------- + w3 : web3.Web3 + address : eth_typing.ChecksumAddress + The address of a deployed Liquid contract. + """ + + _contract: contract.Contract + + def __init__( + self, + w3: web3.Web3, + address: eth_typing.ChecksumAddress, + ): + self._contract = w3.eth.contract( + address=address, + abi=ABI, + ) + + @property + def Approval(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event Approval` on the Liquid contract.""" + return self._contract.events.Approval + + @property + def Transfer(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event Transfer` on the Liquid contract.""" + return self._contract.events.Transfer + + def commission_rate_precision( + self, + ) -> int: + """Binding for `COMMISSION_RATE_PRECISION` on the Liquid contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.COMMISSION_RATE_PRECISION().call() + return int(return_value) + + def fee_factor_unit_recip( + self, + ) -> int: + """Binding for `FEE_FACTOR_UNIT_RECIP` on the Liquid contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.FEE_FACTOR_UNIT_RECIP().call() + return int(return_value) + + def allowance( + self, + _owner: eth_typing.ChecksumAddress, + _spender: eth_typing.ChecksumAddress, + ) -> int: + """Binding for `allowance` on the Liquid contract. + + Parameters + ---------- + _owner : eth_typing.ChecksumAddress + _spender : eth_typing.ChecksumAddress + + Returns + ------- + int + """ + return_value = self._contract.functions.allowance( + _owner, + _spender, + ).call() + return int(return_value) + + def approve( + self, + _spender: eth_typing.ChecksumAddress, + _amount: int, + ) -> contract.ContractFunction: + """Binding for `approve` on the Liquid contract. + + Parameters + ---------- + _spender : eth_typing.ChecksumAddress + _amount : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.approve( + _spender, + _amount, + ) + + def balance_of( + self, + _delegator: eth_typing.ChecksumAddress, + ) -> int: + """Binding for `balanceOf` on the Liquid contract. + + Returns the amount of liquid newtons held by the account (ERC-20). + + Parameters + ---------- + _delegator : eth_typing.ChecksumAddress + + Returns + ------- + int + """ + return_value = self._contract.functions.balanceOf( + _delegator, + ).call() + return int(return_value) + + def claim_rewards( + self, + ) -> contract.ContractFunction: + """Binding for `claimRewards` on the Liquid contract. + + Withdraws all fees earned so far by the caller. + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.claimRewards() + + def commission_rate( + self, + ) -> int: + """Binding for `commissionRate` on the Liquid contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.commissionRate().call() + return int(return_value) + + def decimals( + self, + ) -> int: + """Binding for `decimals` on the Liquid contract. + + Returns + ------- + int + the number of decimals the LNTN token uses. + """ + return_value = self._contract.functions.decimals().call() + return int(return_value) + + def locked_balance_of( + self, + _delegator: eth_typing.ChecksumAddress, + ) -> int: + """Binding for `lockedBalanceOf` on the Liquid contract. + + Returns the amount of locked liquid newtons held by the account. + + Parameters + ---------- + _delegator : eth_typing.ChecksumAddress + + Returns + ------- + int + """ + return_value = self._contract.functions.lockedBalanceOf( + _delegator, + ).call() + return int(return_value) + + def name( + self, + ) -> str: + """Binding for `name` on the Liquid contract. + + returns the name of this Liquid Newton contract + + Returns + ------- + str + """ + return_value = self._contract.functions.name().call() + return str(return_value) + + def symbol( + self, + ) -> str: + """Binding for `symbol` on the Liquid contract. + + returns the symbol of this Liquid Newton contract + + Returns + ------- + str + """ + return_value = self._contract.functions.symbol().call() + return str(return_value) + + def total_supply( + self, + ) -> int: + """Binding for `totalSupply` on the Liquid contract. + + Returns the total amount of stake token issued. + + Returns + ------- + int + """ + return_value = self._contract.functions.totalSupply().call() + return int(return_value) + + def transfer( + self, + _to: eth_typing.ChecksumAddress, + _amount: int, + ) -> contract.ContractFunction: + """Binding for `transfer` on the Liquid contract. + + Moves `_amount` LNEW tokens from the caller's account to the recipient `_to`. + + Parameters + ---------- + _to : eth_typing.ChecksumAddress + _amount : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.transfer( + _to, + _amount, + ) + + def transfer_from( + self, + _sender: eth_typing.ChecksumAddress, + _recipient: eth_typing.ChecksumAddress, + _amount: int, + ) -> contract.ContractFunction: + """Binding for `transferFrom` on the Liquid contract. + + Parameters + ---------- + _sender : eth_typing.ChecksumAddress + _recipient : eth_typing.ChecksumAddress + _amount : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.transferFrom( + _sender, + _recipient, + _amount, + ) + + def treasury( + self, + ) -> eth_typing.ChecksumAddress: + """Binding for `treasury` on the Liquid contract. + + Returns + ------- + eth_typing.ChecksumAddress + """ + return_value = self._contract.functions.treasury().call() + return eth_typing.ChecksumAddress(return_value) + + def unclaimed_rewards( + self, + _account: eth_typing.ChecksumAddress, + ) -> typing.Tuple[int, int]: + """Binding for `unclaimedRewards` on the Liquid contract. + + Returns the total claimable fees (AUT) earned by the delegator to-date. + + Parameters + ---------- + _account : eth_typing.ChecksumAddress + the delegator account. + + Returns + ------- + int + int + """ + return_value = self._contract.functions.unclaimedRewards( + _account, + ).call() + return ( + int(return_value[0]), + int(return_value[1]), + ) + + def unlocked_balance_of( + self, + _delegator: eth_typing.ChecksumAddress, + ) -> int: + """Binding for `unlockedBalanceOf` on the Liquid contract. + + Returns the amount of unlocked liquid newtons held by the account. + + Parameters + ---------- + _delegator : eth_typing.ChecksumAddress + + Returns + ------- + int + """ + return_value = self._contract.functions.unlockedBalanceOf( + _delegator, + ).call() + return int(return_value) + + def validator( + self, + ) -> eth_typing.ChecksumAddress: + """Binding for `validator` on the Liquid contract. + + Returns + ------- + eth_typing.ChecksumAddress + """ + return_value = self._contract.functions.validator().call() + return eth_typing.ChecksumAddress(return_value) + + +ABI = typing.cast( + eth_typing.ABI, + [ + { + "inputs": [ + {"internalType": "address", "name": "_validator", "type": "address"}, + { + "internalType": "address payable", + "name": "_treasury", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_commissionRate", + "type": "uint256", + }, + {"internalType": "string", "name": "_index", "type": "string"}, + ], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "owner", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "spender", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "value", + "type": "uint256", + }, + ], + "name": "Approval", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "from", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "value", + "type": "uint256", + }, + ], + "name": "Transfer", + "type": "event", + }, + { + "inputs": [], + "name": "COMMISSION_RATE_PRECISION", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "FEE_FACTOR_UNIT_RECIP", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_owner", "type": "address"}, + {"internalType": "address", "name": "_spender", "type": "address"}, + ], + "name": "allowance", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_spender", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "approve", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_delegator", "type": "address"} + ], + "name": "balanceOf", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_account", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "claimRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "commissionRate", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "decimals", + "outputs": [{"internalType": "uint8", "name": "", "type": "uint8"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_account", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "lock", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_delegator", "type": "address"} + ], + "name": "lockedBalanceOf", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_account", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "name", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "_ntnReward", "type": "uint256"} + ], + "name": "redistribute", + "outputs": [ + {"internalType": "uint256", "name": "", "type": "uint256"}, + {"internalType": "uint256", "name": "", "type": "uint256"}, + ], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "_rate", "type": "uint256"}], + "name": "setCommissionRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "symbol", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_to", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "transfer", + "outputs": [{"internalType": "bool", "name": "_success", "type": "bool"}], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_sender", "type": "address"}, + {"internalType": "address", "name": "_recipient", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "transferFrom", + "outputs": [{"internalType": "bool", "name": "_success", "type": "bool"}], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "treasury", + "outputs": [ + {"internalType": "address payable", "name": "", "type": "address"} + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_account", "type": "address"} + ], + "name": "unclaimedRewards", + "outputs": [ + {"internalType": "uint256", "name": "_unclaimedATN", "type": "uint256"}, + {"internalType": "uint256", "name": "_unclaimedNTN", "type": "uint256"}, + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_account", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "unlock", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_delegator", "type": "address"} + ], + "name": "unlockedBalanceOf", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "validator", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, + ], +) diff --git a/autonity/contracts/non_stakable_vesting.py b/autonity/contracts/non_stakable_vesting.py new file mode 100644 index 0000000..bd749b0 --- /dev/null +++ b/autonity/contracts/non_stakable_vesting.py @@ -0,0 +1,740 @@ +"""NonStakableVesting contract binding and data structures.""" + +# This module has been generated using pyabigen v0.2.9 + +import typing + +import eth_typing +import web3 +from dataclasses import dataclass +from web3.contract import contract + +__version__ = "v0.14.0" + + +@dataclass +class Contract: + """Port of `struct Contract` on the ContractBase contract.""" + + current_ntn_amount: int + withdrawn_value: int + start: int + cliff_duration: int + total_duration: int + can_stake: bool + + +@dataclass +class Schedule: + """Port of `struct Schedule` on the NonStakableVesting contract.""" + + start: int + cliff_duration: int + total_duration: int + amount: int + unsubscribed_amount: int + total_unlocked: int + total_unlocked_unsubscribed: int + last_unlock_time: int + + +class NonStakableVesting: + """NonStakableVesting contract binding. + + Parameters + ---------- + w3 : web3.Web3 + address : eth_typing.ChecksumAddress + The address of a deployed NonStakableVesting contract. + """ + + _contract: contract.Contract + + def __init__( + self, + w3: web3.Web3, + address: eth_typing.ChecksumAddress, + ): + self._contract = w3.eth.contract( + address=address, + abi=ABI, + ) + + def can_stake( + self, + _beneficiary: eth_typing.ChecksumAddress, + _id: int, + ) -> bool: + """Binding for `canStake` on the NonStakableVesting contract. + + returns if beneficiary can stake from his contract + + Parameters + ---------- + _beneficiary : eth_typing.ChecksumAddress + beneficiary address + _id : int + + Returns + ------- + bool + """ + return_value = self._contract.functions.canStake( + _beneficiary, + _id, + ).call() + return bool(return_value) + + def change_contract_beneficiary( + self, + _beneficiary: eth_typing.ChecksumAddress, + _id: int, + _recipient: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `changeContractBeneficiary` on the NonStakableVesting contract. + + changes the beneficiary of some contract to the _recipient address. _recipient + can release tokens from the contract only operator is able to call the function + + Parameters + ---------- + _beneficiary : eth_typing.ChecksumAddress + beneficiary address whose contract will be canceled + _id : int + contract id numbered from 0 to (n-1); n = total contracts entitled to the + beneficiary (excluding canceled ones) + _recipient : eth_typing.ChecksumAddress + whome the contract is transferred to + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.changeContractBeneficiary( + _beneficiary, + _id, + _recipient, + ) + + def create_schedule( + self, + _amount: int, + _start_time: int, + _cliff_duration: int, + _total_duration: int, + ) -> contract.ContractFunction: + """Binding for `createSchedule` on the NonStakableVesting contract. + + creates a new schedule, restricted to operator the schedule has totalAmount = 0 + initially. As new contracts are subscribed to the schedule, its totalAmount + increases At any point, totalAmount of schedule is the sum of totalValue all the + contracts that are subscribed to the schedule. totalValue of a contract can be + calculated via _calculateTotalValue function + + Parameters + ---------- + _amount : int + total amount of the schedule + _start_time : int + _cliff_duration : int + _total_duration : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.createSchedule( + _amount, + _start_time, + _cliff_duration, + _total_duration, + ) + + def get_contract( + self, + _beneficiary: eth_typing.ChecksumAddress, + _id: int, + ) -> Contract: + """Binding for `getContract` on the NonStakableVesting contract. + + returns a contract entitled to _beneficiary + + Parameters + ---------- + _beneficiary : eth_typing.ChecksumAddress + beneficiary address + _id : int + contract id numbered from 0 to (n-1); n = total contracts entitled to the + beneficiary (excluding canceled ones) + + Returns + ------- + Contract + """ + return_value = self._contract.functions.getContract( + _beneficiary, + _id, + ).call() + return Contract( + int(return_value[0]), + int(return_value[1]), + int(return_value[2]), + int(return_value[3]), + int(return_value[4]), + bool(return_value[5]), + ) + + def get_contracts( + self, + _beneficiary: eth_typing.ChecksumAddress, + ) -> typing.List[Contract]: + """Binding for `getContracts` on the NonStakableVesting contract. + + returns the list of current contracts assigned to a beneficiary + + Parameters + ---------- + _beneficiary : eth_typing.ChecksumAddress + address of the beneficiary + + Returns + ------- + typing.List[Contract] + """ + return_value = self._contract.functions.getContracts( + _beneficiary, + ).call() + return [ + Contract( + int(elem[0]), + int(elem[1]), + int(elem[2]), + int(elem[3]), + int(elem[4]), + bool(elem[5]), + ) + for elem in return_value + ] + + def get_schedule( + self, + _id: int, + ) -> Schedule: + """Binding for `getSchedule` on the NonStakableVesting contract. + + Parameters + ---------- + _id : int + + Returns + ------- + Schedule + """ + return_value = self._contract.functions.getSchedule( + _id, + ).call() + return Schedule( + int(return_value[0]), + int(return_value[1]), + int(return_value[2]), + int(return_value[3]), + int(return_value[4]), + int(return_value[5]), + int(return_value[6]), + int(return_value[7]), + ) + + def max_allowed_duration( + self, + ) -> int: + """Binding for `maxAllowedDuration` on the NonStakableVesting contract. + + The maximum duration of any schedule or contract + + Returns + ------- + int + """ + return_value = self._contract.functions.maxAllowedDuration().call() + return int(return_value) + + def new_contract( + self, + _beneficiary: eth_typing.ChecksumAddress, + _amount: int, + _schedule_id: int, + ) -> contract.ContractFunction: + """Binding for `newContract` on the NonStakableVesting contract. + + creates a new non-stakable contract, restricted to only operator + + Parameters + ---------- + _beneficiary : eth_typing.ChecksumAddress + address of the beneficiary + _amount : int + total amount of NTN to be vested + _schedule_id : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.newContract( + _beneficiary, + _amount, + _schedule_id, + ) + + def release_all_funds( + self, + _id: int, + ) -> contract.ContractFunction: + """Binding for `releaseAllFunds` on the NonStakableVesting contract. + + used by beneficiary to transfer all unlocked NTN of some contract to his own + address + + Parameters + ---------- + _id : int + id of the contract numbered from 0 to (n-1) where n = total contracts + entitled to the beneficiary (excluding canceled ones). So any beneficiary + can number their contracts from 0 to (n-1). Beneficiary does not need to + know the unique global contract id which can be retrieved via + _getUniqueContractID function + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.releaseAllFunds( + _id, + ) + + def release_fund( + self, + _id: int, + _amount: int, + ) -> contract.ContractFunction: + """Binding for `releaseFund` on the NonStakableVesting contract. + + used by beneficiary to transfer some amount of unlocked NTN of some contract to + his own address + + Parameters + ---------- + _id : int + _amount : int + amount of NTN to release + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.releaseFund( + _id, + _amount, + ) + + def set_max_allowed_duration( + self, + _new_max_duration: int, + ) -> contract.ContractFunction: + """Binding for `setMaxAllowedDuration` on the NonStakableVesting contract. + + Sets the max allowed duration of any schedule or contract + + Parameters + ---------- + _new_max_duration : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setMaxAllowedDuration( + _new_max_duration, + ) + + def set_total_nominal( + self, + _total_nominal: int, + ) -> contract.ContractFunction: + """Binding for `setTotalNominal` on the NonStakableVesting contract. + + Sets the totalNominal to create new contract + + Parameters + ---------- + _total_nominal : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setTotalNominal( + _total_nominal, + ) + + def total_contracts( + self, + _beneficiary: eth_typing.ChecksumAddress, + ) -> int: + """Binding for `totalContracts` on the NonStakableVesting contract. + + returns the number of schudeled entitled to some beneficiary + + Parameters + ---------- + _beneficiary : eth_typing.ChecksumAddress + address of the beneficiary + + Returns + ------- + int + """ + return_value = self._contract.functions.totalContracts( + _beneficiary, + ).call() + return int(return_value) + + def total_nominal( + self, + ) -> int: + """Binding for `totalNominal` on the NonStakableVesting contract. + + The total amount of funds to create new locked non-stakable schedules. The + balance is not immediately available at the vault. Rather the unlocked amount of + schedules is minted at epoch end. The balance tells us the max size of a newly + created schedule. See createSchedule() + + Returns + ------- + int + """ + return_value = self._contract.functions.totalNominal().call() + return int(return_value) + + def unlocked_funds( + self, + _beneficiary: eth_typing.ChecksumAddress, + _id: int, + ) -> int: + """Binding for `unlockedFunds` on the NonStakableVesting contract. + + returns the amount of unlocked but not yet released funds in NTN for some + contract + + Parameters + ---------- + _beneficiary : eth_typing.ChecksumAddress + _id : int + + Returns + ------- + int + """ + return_value = self._contract.functions.unlockedFunds( + _beneficiary, + _id, + ).call() + return int(return_value) + + +ABI = typing.cast( + eth_typing.ABI, + [ + { + "inputs": [ + { + "internalType": "address payable", + "name": "_autonity", + "type": "address", + }, + {"internalType": "address", "name": "_operator", "type": "address"}, + ], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "inputs": [ + {"internalType": "address", "name": "_beneficiary", "type": "address"}, + {"internalType": "uint256", "name": "_id", "type": "uint256"}, + ], + "name": "canStake", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_beneficiary", "type": "address"}, + {"internalType": "uint256", "name": "_id", "type": "uint256"}, + {"internalType": "address", "name": "_recipient", "type": "address"}, + ], + "name": "changeContractBeneficiary", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + {"internalType": "uint256", "name": "_startTime", "type": "uint256"}, + { + "internalType": "uint256", + "name": "_cliffDuration", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "_totalDuration", + "type": "uint256", + }, + ], + "name": "createSchedule", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_beneficiary", "type": "address"}, + {"internalType": "uint256", "name": "_id", "type": "uint256"}, + ], + "name": "getContract", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "currentNTNAmount", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "withdrawnValue", + "type": "uint256", + }, + {"internalType": "uint256", "name": "start", "type": "uint256"}, + { + "internalType": "uint256", + "name": "cliffDuration", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "totalDuration", + "type": "uint256", + }, + {"internalType": "bool", "name": "canStake", "type": "bool"}, + ], + "internalType": "struct ContractBase.Contract", + "name": "", + "type": "tuple", + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_beneficiary", "type": "address"} + ], + "name": "getContracts", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "currentNTNAmount", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "withdrawnValue", + "type": "uint256", + }, + {"internalType": "uint256", "name": "start", "type": "uint256"}, + { + "internalType": "uint256", + "name": "cliffDuration", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "totalDuration", + "type": "uint256", + }, + {"internalType": "bool", "name": "canStake", "type": "bool"}, + ], + "internalType": "struct ContractBase.Contract[]", + "name": "", + "type": "tuple[]", + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "_id", "type": "uint256"}], + "name": "getSchedule", + "outputs": [ + { + "components": [ + {"internalType": "uint256", "name": "start", "type": "uint256"}, + { + "internalType": "uint256", + "name": "cliffDuration", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "totalDuration", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "unsubscribedAmount", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "totalUnlocked", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "totalUnlockedUnsubscribed", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "lastUnlockTime", + "type": "uint256", + }, + ], + "internalType": "struct NonStakableVesting.Schedule", + "name": "", + "type": "tuple", + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "maxAllowedDuration", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_beneficiary", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + {"internalType": "uint256", "name": "_scheduleID", "type": "uint256"}, + ], + "name": "newContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "_id", "type": "uint256"}], + "name": "releaseAllFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "_id", "type": "uint256"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "releaseFund", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_newMaxDuration", + "type": "uint256", + } + ], + "name": "setMaxAllowedDuration", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "_totalNominal", "type": "uint256"} + ], + "name": "setTotalNominal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_beneficiary", "type": "address"} + ], + "name": "totalContracts", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "totalNominal", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "unlockTokens", + "outputs": [ + { + "internalType": "uint256", + "name": "_newUnlockedSubscribed", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "_newUnlockedUnsubscribed", + "type": "uint256", + }, + ], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_beneficiary", "type": "address"}, + {"internalType": "uint256", "name": "_id", "type": "uint256"}, + ], + "name": "unlockedFunds", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + ], +) diff --git a/autonity/contracts/oracle.py b/autonity/contracts/oracle.py new file mode 100644 index 0000000..3ec6d34 --- /dev/null +++ b/autonity/contracts/oracle.py @@ -0,0 +1,644 @@ +"""Oracle contract binding and data structures.""" + +# This module has been generated using pyabigen v0.2.9 + +import typing + +import eth_typing +import web3 +from dataclasses import dataclass +from web3.contract import base_contract, contract + +__version__ = "v0.14.0" + + +@dataclass +class RoundData: + """Port of `struct RoundData` on the IOracle contract.""" + + round: int + price: int + timestamp: int + success: bool + + +class Oracle: + """Oracle contract binding. + + Parameters + ---------- + w3 : web3.Web3 + address : eth_typing.ChecksumAddress + The address of a deployed Oracle contract. + """ + + _contract: contract.Contract + + def __init__( + self, + w3: web3.Web3, + address: eth_typing.ChecksumAddress, + ): + self._contract = w3.eth.contract( + address=address, + abi=ABI, + ) + + @property + def NewRound(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event NewRound` on the Oracle contract.""" + return self._contract.events.NewRound + + @property + def NewSymbols(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event NewSymbols` on the Oracle contract.""" + return self._contract.events.NewSymbols + + @property + def Voted(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event Voted` on the Oracle contract.""" + return self._contract.events.Voted + + def get_precision( + self, + ) -> int: + """Binding for `getPrecision` on the Oracle contract. + + Precision to be used with price reports + + Returns + ------- + int + """ + return_value = self._contract.functions.getPrecision().call() + return int(return_value) + + def get_round( + self, + ) -> int: + """Binding for `getRound` on the Oracle contract. + + Retrieve the current round ID. + + Returns + ------- + int + """ + return_value = self._contract.functions.getRound().call() + return int(return_value) + + def get_round_data( + self, + _round: int, + _symbol: str, + ) -> RoundData: + """Binding for `getRoundData` on the Oracle contract. + + Return price data for a specific round. + + Parameters + ---------- + _round : int + , the round for which the price should be returned. + _symbol : str + , the symbol for which the current price should be returned. + + Returns + ------- + RoundData + """ + return_value = self._contract.functions.getRoundData( + _round, + _symbol, + ).call() + return RoundData( + int(return_value[0]), + int(return_value[1]), + int(return_value[2]), + bool(return_value[3]), + ) + + def get_symbols( + self, + ) -> typing.List[str]: + """Binding for `getSymbols` on the Oracle contract. + + Retrieve the lists of symbols to be voted on. Need to be called by the Oracle + Server as part of the init. + + Returns + ------- + typing.List[str] + """ + return_value = self._contract.functions.getSymbols().call() + return [str(elem) for elem in return_value] + + def get_vote_period( + self, + ) -> int: + """Binding for `getVotePeriod` on the Oracle contract. + + vote period to be used for price voting and aggregation + + Returns + ------- + int + """ + return_value = self._contract.functions.getVotePeriod().call() + return int(return_value) + + def get_voters( + self, + ) -> typing.List[eth_typing.ChecksumAddress]: + """Binding for `getVoters` on the Oracle contract. + + Retrieve the current voters in the committee. + + Returns + ------- + typing.List[eth_typing.ChecksumAddress] + """ + return_value = self._contract.functions.getVoters().call() + return [eth_typing.ChecksumAddress(elem) for elem in return_value] + + def last_round_block( + self, + ) -> int: + """Binding for `lastRoundBlock` on the Oracle contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.lastRoundBlock().call() + return int(return_value) + + def last_voter_update_round( + self, + ) -> int: + """Binding for `lastVoterUpdateRound` on the Oracle contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.lastVoterUpdateRound().call() + return int(return_value) + + def latest_round_data( + self, + _symbol: str, + ) -> RoundData: + """Binding for `latestRoundData` on the Oracle contract. + + Return latest available price data. + + Parameters + ---------- + _symbol : str + , the symbol from which the current price should be returned. + + Returns + ------- + RoundData + """ + return_value = self._contract.functions.latestRoundData( + _symbol, + ).call() + return RoundData( + int(return_value[0]), + int(return_value[1]), + int(return_value[2]), + bool(return_value[3]), + ) + + def new_symbols( + self, + key0: int, + ) -> str: + """Binding for `newSymbols` on the Oracle contract. + + Parameters + ---------- + key0 : int + + Returns + ------- + str + """ + return_value = self._contract.functions.newSymbols( + key0, + ).call() + return str(return_value) + + def reports( + self, + key0: str, + key1: eth_typing.ChecksumAddress, + ) -> int: + """Binding for `reports` on the Oracle contract. + + Parameters + ---------- + key0 : str + key1 : eth_typing.ChecksumAddress + + Returns + ------- + int + """ + return_value = self._contract.functions.reports( + key0, + key1, + ).call() + return int(return_value) + + def round( + self, + ) -> int: + """Binding for `round` on the Oracle contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.round().call() + return int(return_value) + + def set_symbols( + self, + _symbols: typing.List[str], + ) -> contract.ContractFunction: + """Binding for `setSymbols` on the Oracle contract. + + Update the symbols to be requested. Only effective at the next round. Restricted + to the operator account. + + Parameters + ---------- + _symbols : typing.List[str] + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setSymbols( + _symbols, + ) + + def symbol_updated_round( + self, + ) -> int: + """Binding for `symbolUpdatedRound` on the Oracle contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.symbolUpdatedRound().call() + return int(return_value) + + def symbols( + self, + key0: int, + ) -> str: + """Binding for `symbols` on the Oracle contract. + + Parameters + ---------- + key0 : int + + Returns + ------- + str + """ + return_value = self._contract.functions.symbols( + key0, + ).call() + return str(return_value) + + def vote_period( + self, + ) -> int: + """Binding for `votePeriod` on the Oracle contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.votePeriod().call() + return int(return_value) + + def voting_info( + self, + key0: eth_typing.ChecksumAddress, + ) -> typing.Tuple[int, int, bool]: + """Binding for `votingInfo` on the Oracle contract. + + Parameters + ---------- + key0 : eth_typing.ChecksumAddress + + Returns + ------- + int + int + bool + """ + return_value = self._contract.functions.votingInfo( + key0, + ).call() + return ( + int(return_value[0]), + int(return_value[1]), + bool(return_value[2]), + ) + + +ABI = typing.cast( + eth_typing.ABI, + [ + { + "inputs": [ + {"internalType": "address[]", "name": "_voters", "type": "address[]"}, + {"internalType": "address", "name": "_autonity", "type": "address"}, + {"internalType": "address", "name": "_operator", "type": "address"}, + {"internalType": "string[]", "name": "_symbols", "type": "string[]"}, + {"internalType": "uint256", "name": "_votePeriod", "type": "uint256"}, + ], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "_round", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "_height", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "_timestamp", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "_votePeriod", + "type": "uint256", + }, + ], + "name": "NewRound", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string[]", + "name": "_symbols", + "type": "string[]", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "_round", + "type": "uint256", + }, + ], + "name": "NewSymbols", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "_voter", + "type": "address", + }, + { + "indexed": False, + "internalType": "int256[]", + "name": "_votes", + "type": "int256[]", + }, + ], + "name": "Voted", + "type": "event", + }, + {"stateMutability": "payable", "type": "fallback"}, + { + "inputs": [], + "name": "finalize", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "getPrecision", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [], + "name": "getRound", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "_round", "type": "uint256"}, + {"internalType": "string", "name": "_symbol", "type": "string"}, + ], + "name": "getRoundData", + "outputs": [ + { + "components": [ + {"internalType": "uint256", "name": "round", "type": "uint256"}, + {"internalType": "int256", "name": "price", "type": "int256"}, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256", + }, + {"internalType": "bool", "name": "success", "type": "bool"}, + ], + "internalType": "struct IOracle.RoundData", + "name": "data", + "type": "tuple", + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getSymbols", + "outputs": [{"internalType": "string[]", "name": "", "type": "string[]"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getVotePeriod", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getVoters", + "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "lastRoundBlock", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "lastVoterUpdateRound", + "outputs": [{"internalType": "int256", "name": "", "type": "int256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "string", "name": "_symbol", "type": "string"}], + "name": "latestRoundData", + "outputs": [ + { + "components": [ + {"internalType": "uint256", "name": "round", "type": "uint256"}, + {"internalType": "int256", "name": "price", "type": "int256"}, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256", + }, + {"internalType": "bool", "name": "success", "type": "bool"}, + ], + "internalType": "struct IOracle.RoundData", + "name": "data", + "type": "tuple", + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "newSymbols", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "string", "name": "", "type": "string"}, + {"internalType": "address", "name": "", "type": "address"}, + ], + "name": "reports", + "outputs": [{"internalType": "int256", "name": "", "type": "int256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "round", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_operator", "type": "address"} + ], + "name": "setOperator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "string[]", "name": "_symbols", "type": "string[]"} + ], + "name": "setSymbols", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address[]", "name": "_newVoters", "type": "address[]"} + ], + "name": "setVoters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "symbolUpdatedRound", + "outputs": [{"internalType": "int256", "name": "", "type": "int256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "symbols", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "_commit", "type": "uint256"}, + {"internalType": "int256[]", "name": "_reports", "type": "int256[]"}, + {"internalType": "uint256", "name": "_salt", "type": "uint256"}, + ], + "name": "vote", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "votePeriod", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "address", "name": "", "type": "address"}], + "name": "votingInfo", + "outputs": [ + {"internalType": "uint256", "name": "round", "type": "uint256"}, + {"internalType": "uint256", "name": "commit", "type": "uint256"}, + {"internalType": "bool", "name": "isVoter", "type": "bool"}, + ], + "stateMutability": "view", + "type": "function", + }, + {"stateMutability": "payable", "type": "receive"}, + ], +) diff --git a/autonity/contracts/stabilization.py b/autonity/contracts/stabilization.py new file mode 100644 index 0000000..8098341 --- /dev/null +++ b/autonity/contracts/stabilization.py @@ -0,0 +1,1064 @@ +"""Stabilization contract binding and data structures.""" + +# This module has been generated using pyabigen v0.2.9 + +import typing + +import eth_typing +import web3 +from dataclasses import dataclass +from plum import dispatch +from web3.contract import base_contract, contract + +__version__ = "v0.14.0" + + +@dataclass +class Config: + """Port of `struct Config` on the Stabilization contract.""" + + borrow_interest_rate: int + liquidation_ratio: int + min_collateralization_ratio: int + min_debt_requirement: int + target_price: int + + +class Stabilization: + """Stabilization contract binding. + + A CDP-based stabilization mechanism for the Auton. + + Parameters + ---------- + w3 : web3.Web3 + address : eth_typing.ChecksumAddress + The address of a deployed Stabilization contract. + """ + + _contract: contract.Contract + + def __init__( + self, + w3: web3.Web3, + address: eth_typing.ChecksumAddress, + ): + self._contract = w3.eth.contract( + address=address, + abi=ABI, + ) + + @property + def Borrow(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event Borrow` on the Stabilization contract. + + Auton was borrowed from a CDP + """ + return self._contract.events.Borrow + + @property + def Deposit(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event Deposit` on the Stabilization contract. + + Collateral Token was deposited into a CDP + """ + return self._contract.events.Deposit + + @property + def Liquidate(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event Liquidate` on the Stabilization contract. + + A CDP was liquidated + """ + return self._contract.events.Liquidate + + @property + def Repay(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event Repay` on the Stabilization contract. + + Auton debt was paid into a CDP + """ + return self._contract.events.Repay + + @property + def Withdraw(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event Withdraw` on the Stabilization contract. + + Collateral Token was withdrawn from a CDP + """ + return self._contract.events.Withdraw + + def scale( + self, + ) -> int: + """Binding for `SCALE` on the Stabilization contract. + + The decimal places in fixed-point integer representation. + + Returns + ------- + int + """ + return_value = self._contract.functions.SCALE().call() + return int(return_value) + + def scale_factor( + self, + ) -> int: + """Binding for `SCALE_FACTOR` on the Stabilization contract. + + The multiplier for scaling numbers to the required scale. + + Returns + ------- + int + """ + return_value = self._contract.functions.SCALE_FACTOR().call() + return int(return_value) + + def seconds_in_year( + self, + ) -> int: + """Binding for `SECONDS_IN_YEAR` on the Stabilization contract. + + A year is assumed to have 365 days for interest rate calculations. + + Returns + ------- + int + """ + return_value = self._contract.functions.SECONDS_IN_YEAR().call() + return int(return_value) + + def accounts( + self, + ) -> typing.List[eth_typing.ChecksumAddress]: + """Binding for `accounts` on the Stabilization contract. + + Retrieve all the accounts that have opened a CDP. + + Returns + ------- + typing.List[eth_typing.ChecksumAddress] + Array of CDP account addresses + """ + return_value = self._contract.functions.accounts().call() + return [eth_typing.ChecksumAddress(elem) for elem in return_value] + + def borrow( + self, + amount: int, + ) -> contract.ContractFunction: + """Binding for `borrow` on the Stabilization contract. + + Borrow Auton against the CDP Collateral. The CDP must not be liquidatable, the + `amount` must not exceed the borrow limit, the debt after borrowing must satisfy + the minimum debt requirement. + + Parameters + ---------- + amount : int + Auton to borrow + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.borrow( + amount, + ) + + def borrow_limit( + self, + collateral: int, + price: int, + target_price: int, + mcr: int, + ) -> int: + """Binding for `borrowLimit` on the Stabilization contract. + + Calculate the maximum amount of Amount that can be borrowed for the given amount + of Collateral Token. + + Parameters + ---------- + collateral : int + Amount of Collateral Token backing the debt + price : int + The price of Collateral Token in Auton + target_price : int + mcr : int + The minimum collateralization ratio + + Returns + ------- + int + The maximum Auton that can be borrowed + """ + return_value = self._contract.functions.borrowLimit( + collateral, + price, + target_price, + mcr, + ).call() + return int(return_value) + + def cdps( + self, + key0: eth_typing.ChecksumAddress, + ) -> typing.Tuple[int, int, int, int]: + """Binding for `cdps` on the Stabilization contract. + + A mapping to retrieve the CDP for an account address. + + Parameters + ---------- + key0 : eth_typing.ChecksumAddress + + Returns + ------- + int + int + int + int + """ + return_value = self._contract.functions.cdps( + key0, + ).call() + return ( + int(return_value[0]), + int(return_value[1]), + int(return_value[2]), + int(return_value[3]), + ) + + def collateral_price( + self, + ) -> int: + """Binding for `collateralPrice` on the Stabilization contract. + + Price the Collateral Token in Auton. Retrieves the Collateral Token price from + the Oracle Contract and converts it to Auton. + + Returns + ------- + int + Price of Collateral Token + """ + return_value = self._contract.functions.collateralPrice().call() + return int(return_value) + + def config( + self, + ) -> Config: + """Binding for `config` on the Stabilization contract. + + The Config object that stores Stabilization Contract parameters. + + Returns + ------- + Config + """ + return_value = self._contract.functions.config().call() + return Config( + int(return_value[0]), + int(return_value[1]), + int(return_value[2]), + int(return_value[3]), + int(return_value[4]), + ) + + @dispatch # type: ignore + def debt_amount( # type: ignore # noqa: F811 + self, + account: eth_typing.ChecksumAddress, + timestamp: int, + ) -> int: + """Binding for `debtAmount` on the Stabilization contract. + + Calculate the debt amount outstanding for a CDP at the given timestamp. The + timestamp must be equal or later than the time of the CDP last borrow or + repayment. + + Parameters + ---------- + account : eth_typing.ChecksumAddress + The CDP account address + timestamp : int + The timestamp to value the debt + + Returns + ------- + int + The debt amount + """ + return_value = self._contract.functions.debtAmount( + account, + timestamp, + ).call() + return int(return_value) + + @dispatch # type: ignore + def debt_amount( # type: ignore # noqa: F811 + self, + account: eth_typing.ChecksumAddress, + ) -> int: + """Binding for `debtAmount` on the Stabilization contract. + + Calculate the current debt amount outstanding for a CDP. + + Parameters + ---------- + account : eth_typing.ChecksumAddress + The CDP account address + + Returns + ------- + int + The debt amount + """ + return_value = self._contract.functions.debtAmount( + account, + ).call() + return int(return_value) + + def deposit( + self, + amount: int, + ) -> contract.ContractFunction: + """Binding for `deposit` on the Stabilization contract. + + Deposit Collateral Token using the ERC20 allowance mechanism. Before calling + this function, the CDP owner must approve the Stabilization contract to spend + Collateral Token on their behalf for the full amount to be deposited. + + Parameters + ---------- + amount : int + Units of Collateral Token to deposit (non-zero) + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.deposit( + amount, + ) + + def interest_due( + self, + debt: int, + rate: int, + time_borrow: int, + time_due: int, + ) -> int: + """Binding for `interestDue` on the Stabilization contract. + + Calculate the interest due for a given amount of debt. + + Parameters + ---------- + debt : int + The debt amount + rate : int + The borrow interest rate + time_borrow : int + time_due : int + + Returns + ------- + int + @dev Makes use of the prb-math library for natural exponentiation. + """ + return_value = self._contract.functions.interestDue( + debt, + rate, + time_borrow, + time_due, + ).call() + return int(return_value) + + def is_liquidatable( + self, + account: eth_typing.ChecksumAddress, + ) -> bool: + """Binding for `isLiquidatable` on the Stabilization contract. + + Determine if the CDP is currently liquidatable. + + Parameters + ---------- + account : eth_typing.ChecksumAddress + The CDP account address + + Returns + ------- + bool + Whether the CDP is liquidatable + """ + return_value = self._contract.functions.isLiquidatable( + account, + ).call() + return bool(return_value) + + def liquidate( + self, + account: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `liquidate` on the Stabilization contract. + + Liquidate a CDP that is undercollateralized. The liquidator must pay all the CDP + debt outstanding. As a reward, the liquidator will receive the collateral that + is held in the CDP. The transaction value is the payment amount. After covering + the CDP's debt, any surplus is refunded to the liquidator. + + Parameters + ---------- + account : eth_typing.ChecksumAddress + The CDP account address to liquidate + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.liquidate( + account, + ) + + def minimum_collateral( + self, + principal: int, + price: int, + mcr: int, + ) -> int: + """Binding for `minimumCollateral` on the Stabilization contract. + + Calculate the minimum amount of Collateral Token that must be deposited in the + CDP in order to borrow the given amount of Autons. + + Parameters + ---------- + principal : int + Auton amount to borrow + price : int + The price of Collateral Token in Auton + mcr : int + The minimum collateralization ratio + + Returns + ------- + int + The minimum Collateral Token amount required + """ + return_value = self._contract.functions.minimumCollateral( + principal, + price, + mcr, + ).call() + return int(return_value) + + def repay( + self, + ) -> contract.ContractFunction: + """Binding for `repay` on the Stabilization contract. + + Make a payment towards CDP debt. The transaction value is the payment amount. + The debt after payment must satisfy the minimum debt requirement. The payment + first covers the outstanding interest debt before the principal debt. + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.repay() + + def set_liquidation_ratio( + self, + ratio: int, + ) -> contract.ContractFunction: + """Binding for `setLiquidationRatio` on the Stabilization contract. + + Set the liquidation ratio. Must be less than the minimum collateralization + ratio. + + Parameters + ---------- + ratio : int + The liquidation ratio + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setLiquidationRatio( + ratio, + ) + + def set_min_collateralization_ratio( + self, + ratio: int, + ) -> contract.ContractFunction: + """Binding for `setMinCollateralizationRatio` on the Stabilization contract. + + Set the minimum collateralization ratio. Must be positive and greater than the + liquidation ratio. + + Parameters + ---------- + ratio : int + The minimum collateralization ratio + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setMinCollateralizationRatio( + ratio, + ) + + def set_min_debt_requirement( + self, + amount: int, + ) -> contract.ContractFunction: + """Binding for `setMinDebtRequirement` on the Stabilization contract. + + Set the minimum debt requirement. + + Parameters + ---------- + amount : int + The minimum debt amount + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setMinDebtRequirement( + amount, + ) + + def set_supply_control( + self, + supply_control: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `setSupplyControl` on the Stabilization contract. + + Set the SupplyControl Contract address. + + Parameters + ---------- + supply_control : eth_typing.ChecksumAddress + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setSupplyControl( + supply_control, + ) + + def under_collateralized( + self, + collateral: int, + price: int, + debt: int, + liquidation_ratio: int, + ) -> bool: + """Binding for `underCollateralized` on the Stabilization contract. + + Determine if a debt position is undercollateralized. + + Parameters + ---------- + collateral : int + The collateral amount + price : int + The price of Collateral Token in Auton + debt : int + The debt amount + liquidation_ratio : int + + Returns + ------- + bool + Whether the position is liquidatable + """ + return_value = self._contract.functions.underCollateralized( + collateral, + price, + debt, + liquidation_ratio, + ).call() + return bool(return_value) + + def withdraw( + self, + amount: int, + ) -> contract.ContractFunction: + """Binding for `withdraw` on the Stabilization contract. + + Request a withdrawal of Collateral Token. The CDP must not be liquidatable and + the withdrawal must not reduce the remaining Collateral Token amount below the + minimum collateral amount. + + Parameters + ---------- + amount : int + Units of Collateral Token to withdraw + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.withdraw( + amount, + ) + + +ABI = typing.cast( + eth_typing.ABI, + [ + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "borrowInterestRate", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "liquidationRatio", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "minCollateralizationRatio", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "minDebtRequirement", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "targetPrice", + "type": "uint256", + }, + ], + "internalType": "struct Stabilization.Config", + "name": "config_", + "type": "tuple", + }, + {"internalType": "address", "name": "autonity", "type": "address"}, + {"internalType": "address", "name": "operator", "type": "address"}, + {"internalType": "address", "name": "oracle", "type": "address"}, + {"internalType": "address", "name": "supplyControl", "type": "address"}, + { + "internalType": "contract IERC20", + "name": "collateralToken", + "type": "address", + }, + ], + "stateMutability": "nonpayable", + "type": "constructor", + }, + {"inputs": [], "name": "InsufficientAllowance", "type": "error"}, + {"inputs": [], "name": "InsufficientCollateral", "type": "error"}, + {"inputs": [], "name": "InsufficientPayment", "type": "error"}, + {"inputs": [], "name": "InvalidAmount", "type": "error"}, + {"inputs": [], "name": "InvalidDebtPosition", "type": "error"}, + {"inputs": [], "name": "InvalidParameter", "type": "error"}, + {"inputs": [], "name": "InvalidPrice", "type": "error"}, + {"inputs": [], "name": "Liquidatable", "type": "error"}, + {"inputs": [], "name": "NoDebtPosition", "type": "error"}, + {"inputs": [], "name": "NotLiquidatable", "type": "error"}, + { + "inputs": [ + {"internalType": "uint256", "name": "x", "type": "uint256"}, + {"internalType": "uint256", "name": "y", "type": "uint256"}, + ], + "name": "PRBMath_MulDiv18_Overflow", + "type": "error", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "x", "type": "uint256"}, + {"internalType": "uint256", "name": "y", "type": "uint256"}, + {"internalType": "uint256", "name": "denominator", "type": "uint256"}, + ], + "name": "PRBMath_MulDiv_Overflow", + "type": "error", + }, + { + "inputs": [{"internalType": "UD60x18", "name": "x", "type": "uint256"}], + "name": "PRBMath_UD60x18_Exp2_InputTooBig", + "type": "error", + }, + { + "inputs": [{"internalType": "UD60x18", "name": "x", "type": "uint256"}], + "name": "PRBMath_UD60x18_Exp_InputTooBig", + "type": "error", + }, + {"inputs": [], "name": "PriceUnavailable", "type": "error"}, + {"inputs": [], "name": "TransferFailed", "type": "error"}, + {"inputs": [], "name": "Unauthorized", "type": "error"}, + {"inputs": [], "name": "ZeroValue", "type": "error"}, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "account", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + ], + "name": "Borrow", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "account", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + ], + "name": "Deposit", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "account", + "type": "address", + }, + { + "indexed": False, + "internalType": "address", + "name": "liquidator", + "type": "address", + }, + ], + "name": "Liquidate", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "account", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + ], + "name": "Repay", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "account", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + ], + "name": "Withdraw", + "type": "event", + }, + { + "inputs": [], + "name": "SCALE", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "SCALE_FACTOR", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "SECONDS_IN_YEAR", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "accounts", + "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "amount", "type": "uint256"} + ], + "name": "borrow", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "collateral", "type": "uint256"}, + {"internalType": "uint256", "name": "price", "type": "uint256"}, + {"internalType": "uint256", "name": "targetPrice", "type": "uint256"}, + {"internalType": "uint256", "name": "mcr", "type": "uint256"}, + ], + "name": "borrowLimit", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [{"internalType": "address", "name": "", "type": "address"}], + "name": "cdps", + "outputs": [ + {"internalType": "uint256", "name": "timestamp", "type": "uint256"}, + {"internalType": "uint256", "name": "collateral", "type": "uint256"}, + {"internalType": "uint256", "name": "principal", "type": "uint256"}, + {"internalType": "uint256", "name": "interest", "type": "uint256"}, + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "collateralPrice", + "outputs": [ + {"internalType": "uint256", "name": "price", "type": "uint256"} + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "config", + "outputs": [ + { + "internalType": "uint256", + "name": "borrowInterestRate", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "liquidationRatio", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "minCollateralizationRatio", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "minDebtRequirement", + "type": "uint256", + }, + {"internalType": "uint256", "name": "targetPrice", "type": "uint256"}, + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "account", "type": "address"}, + {"internalType": "uint256", "name": "timestamp", "type": "uint256"}, + ], + "name": "debtAmount", + "outputs": [{"internalType": "uint256", "name": "debt", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "account", "type": "address"} + ], + "name": "debtAmount", + "outputs": [{"internalType": "uint256", "name": "debt", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "amount", "type": "uint256"} + ], + "name": "deposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "debt", "type": "uint256"}, + {"internalType": "uint256", "name": "rate", "type": "uint256"}, + {"internalType": "uint256", "name": "timeBorrow", "type": "uint256"}, + {"internalType": "uint256", "name": "timeDue", "type": "uint256"}, + ], + "name": "interestDue", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "account", "type": "address"} + ], + "name": "isLiquidatable", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "account", "type": "address"} + ], + "name": "liquidate", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "principal", "type": "uint256"}, + {"internalType": "uint256", "name": "price", "type": "uint256"}, + {"internalType": "uint256", "name": "mcr", "type": "uint256"}, + ], + "name": "minimumCollateral", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [], + "name": "repay", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "ratio", "type": "uint256"}], + "name": "setLiquidationRatio", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "ratio", "type": "uint256"}], + "name": "setMinCollateralizationRatio", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "amount", "type": "uint256"} + ], + "name": "setMinDebtRequirement", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "operator", "type": "address"} + ], + "name": "setOperator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "oracle", "type": "address"} + ], + "name": "setOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "supplyControl", "type": "address"} + ], + "name": "setSupplyControl", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "collateral", "type": "uint256"}, + {"internalType": "uint256", "name": "price", "type": "uint256"}, + {"internalType": "uint256", "name": "debt", "type": "uint256"}, + { + "internalType": "uint256", + "name": "liquidationRatio", + "type": "uint256", + }, + ], + "name": "underCollateralized", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "amount", "type": "uint256"} + ], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + ], +) diff --git a/autonity/contracts/supply_control.py b/autonity/contracts/supply_control.py new file mode 100644 index 0000000..9969ebf --- /dev/null +++ b/autonity/contracts/supply_control.py @@ -0,0 +1,224 @@ +"""SupplyControl contract binding and data structures.""" + +# This module has been generated using pyabigen v0.2.9 + +import typing + +import eth_typing +import web3 +from web3.contract import base_contract, contract + +__version__ = "v0.14.0" + + +class SupplyControl: + """SupplyControl contract binding. + + Controls the supply of Auton on the network. + + Parameters + ---------- + w3 : web3.Web3 + address : eth_typing.ChecksumAddress + The address of a deployed SupplyControl contract. + """ + + _contract: contract.Contract + + def __init__( + self, + w3: web3.Web3, + address: eth_typing.ChecksumAddress, + ): + self._contract = w3.eth.contract( + address=address, + abi=ABI, + ) + + @property + def Burn(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event Burn` on the SupplyControl contract. + + Auton was burned. + """ + return self._contract.events.Burn + + @property + def Mint(self) -> typing.Type[base_contract.BaseContractEvent]: + """Binding for `event Mint` on the SupplyControl contract. + + Auton was minted. + """ + return self._contract.events.Mint + + def available_supply( + self, + ) -> int: + """Binding for `availableSupply` on the SupplyControl contract. + + The supply of Auton available for minting. + + Returns + ------- + int + """ + return_value = self._contract.functions.availableSupply().call() + return int(return_value) + + def set_stabilizer( + self, + stabilizer_: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `setStabilizer` on the SupplyControl contract. + + Update the stabilizer that is authorized to mint and burn. + + Parameters + ---------- + stabilizer_ : eth_typing.ChecksumAddress + The new stabilizer account + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setStabilizer( + stabilizer_, + ) + + def stabilizer( + self, + ) -> eth_typing.ChecksumAddress: + """Binding for `stabilizer` on the SupplyControl contract. + + The account that is authorized to mint and burn. + + Returns + ------- + eth_typing.ChecksumAddress + """ + return_value = self._contract.functions.stabilizer().call() + return eth_typing.ChecksumAddress(return_value) + + def total_supply( + self, + ) -> int: + """Binding for `totalSupply` on the SupplyControl contract. + + The total supply of Auton under management. + + Returns + ------- + int + """ + return_value = self._contract.functions.totalSupply().call() + return int(return_value) + + +ABI = typing.cast( + eth_typing.ABI, + [ + { + "inputs": [ + {"internalType": "address", "name": "autonity", "type": "address"}, + {"internalType": "address", "name": "operator", "type": "address"}, + {"internalType": "address", "name": "stabilizer_", "type": "address"}, + ], + "stateMutability": "payable", + "type": "constructor", + }, + {"inputs": [], "name": "InvalidAmount", "type": "error"}, + {"inputs": [], "name": "InvalidRecipient", "type": "error"}, + {"inputs": [], "name": "Unauthorized", "type": "error"}, + {"inputs": [], "name": "ZeroValue", "type": "error"}, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + } + ], + "name": "Burn", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "address", + "name": "recipient", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + ], + "name": "Mint", + "type": "event", + }, + { + "inputs": [], + "name": "availableSupply", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "burn", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "recipient", "type": "address"}, + {"internalType": "uint256", "name": "amount", "type": "uint256"}, + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "operator", "type": "address"} + ], + "name": "setOperator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "stabilizer_", "type": "address"} + ], + "name": "setStabilizer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "stabilizer", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + ], +) diff --git a/autonity/contracts/upgrade_manager.py b/autonity/contracts/upgrade_manager.py new file mode 100644 index 0000000..a34bd2d --- /dev/null +++ b/autonity/contracts/upgrade_manager.py @@ -0,0 +1,130 @@ +"""UpgradeManager contract binding and data structures.""" + +# This module has been generated using pyabigen v0.2.9 + +import typing + +import eth_typing +import web3 +from web3.contract import contract + +__version__ = "v0.14.0" + + +class UpgradeManager: + """UpgradeManager contract binding. + + Parameters + ---------- + w3 : web3.Web3 + address : eth_typing.ChecksumAddress + The address of a deployed UpgradeManager contract. + """ + + _contract: contract.Contract + + def __init__( + self, + w3: web3.Web3, + address: eth_typing.ChecksumAddress, + ): + self._contract = w3.eth.contract( + address=address, + abi=ABI, + ) + + def autonity( + self, + ) -> eth_typing.ChecksumAddress: + """Binding for `autonity` on the UpgradeManager contract. + + Returns + ------- + eth_typing.ChecksumAddress + """ + return_value = self._contract.functions.autonity().call() + return eth_typing.ChecksumAddress(return_value) + + def operator( + self, + ) -> eth_typing.ChecksumAddress: + """Binding for `operator` on the UpgradeManager contract. + + Returns + ------- + eth_typing.ChecksumAddress + """ + return_value = self._contract.functions.operator().call() + return eth_typing.ChecksumAddress(return_value) + + def upgrade( + self, + _target: eth_typing.ChecksumAddress, + _data: str, + ) -> contract.ContractFunction: + """Binding for `upgrade` on the UpgradeManager contract. + + Parameters + ---------- + _target : eth_typing.ChecksumAddress + is the target contract address to be updated. + _data : str + is the contract creation code. + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.upgrade( + _target, + _data, + ) + + +ABI = typing.cast( + eth_typing.ABI, + [ + { + "inputs": [ + {"internalType": "address", "name": "_autonity", "type": "address"}, + {"internalType": "address", "name": "_operator", "type": "address"}, + ], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "inputs": [], + "name": "autonity", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "operator", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_account", "type": "address"} + ], + "name": "setOperator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_target", "type": "address"}, + {"internalType": "string", "name": "_data", "type": "string"}, + ], + "name": "upgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + ], +) diff --git a/autonity/erc20.py b/autonity/erc20.py deleted file mode 100644 index 5e88353..0000000 --- a/autonity/erc20.py +++ /dev/null @@ -1,176 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Model for an ERC20 token -""" - -from typing import Optional, Union - -from web3 import Web3 -from web3.contract.contract import ABI, Contract, ContractFunction -from web3.exceptions import BadFunctionCallOutput, ContractLogicError -from web3.types import ABIFunction, Address, ChecksumAddress, Wei - -from autonity.abi_manager import load_abi - -# pylint: disable=too-many-arguments - - -NAME_FUNCTION: ABIFunction = { - "inputs": [], - "name": "name", - "outputs": [ - {"internalType": "string", "name": "", "type": "string"} # type: ignore - ], - "stateMutability": "pure", - "type": "function", -} - -SYMBOL_FUNCTION: ABIFunction = { - "inputs": [], - "name": "symbol", - "outputs": [ - {"internalType": "string", "name": "", "type": "string"} # type: ignore - ], - "stateMutability": "pure", - "type": "function", -} - -DECIMALS_FUNCTION: ABIFunction = { - "inputs": [], - "name": "decimals", - "outputs": [{"internalType": "uint8", "name": "", "type": "uint8"}], # type: ignore - "stateMutability": "pure", - "type": "function", -} - - -def add_missing_erc20_functions(abi: ABI) -> ABI: - """ - The IERC20 ABI doesn't include these optional functions by - default. We add them in to all ERC20 contract ABIs, and check - them at runtime. - """ - function_names = [fn["name"] for fn in abi if fn["type"] == "function"] - abi = list(abi) - if "name" not in function_names: - abi.append(NAME_FUNCTION) - if "symbol" not in function_names: - abi.append(SYMBOL_FUNCTION) - if "decimals" not in function_names: - abi.append(DECIMALS_FUNCTION) - - return abi - - -class ERC20: - """ - Wrapper class for an ERC20 contract - """ - - contract: Contract - - def __init__( - self, - web3: Web3, - address: Union[Address, ChecksumAddress], - abi: Optional[ABI] = None, - ): - if not abi: - abi = add_missing_erc20_functions(load_abi("IERC20")) - self.contract = web3.eth.contract(address, abi=abi) - - def name(self) -> Optional[str]: - """ - Returns the token name (or None if not available). - """ - # TODO try-catch here in case the function is not present. - name_function = getattr(self.contract.functions, "name", None) - try: - return name_function().call() if name_function else None - except (BadFunctionCallOutput, ContractLogicError): - return None - - def symbol(self) -> Optional[str]: - """ - Returns the token symbol (or None if not available). - """ - symbol_function = getattr(self.contract.functions, "symbol", None) - try: - return symbol_function().call() if symbol_function else None - except (BadFunctionCallOutput, ContractLogicError): - return None - - def decimals(self) -> int: - """ - Returns the number of decimals used in the token (or None if not available). - """ - decimals_function = getattr(self.contract.functions, "decimals", None) - try: - return decimals_function().call() if decimals_function else 0 - except (BadFunctionCallOutput, ContractLogicError): - # https://ethereum.stackexchange.com/questions/100039/whats-the-default-erc20-decimals - return 0 - - def total_supply(self) -> int: - """ - Total supply in "token units" (divide by 10^decimals for value in whole tokens). - """ - return self.contract.functions.totalSupply().call() - - def balance_of(self, account: ChecksumAddress) -> Wei: - """ - Returns the balance of a particular address in "token units" - (divide by 10^decimals for value in whole tokens). - """ - return self.contract.functions.balanceOf(account).call() - - def allowance(self, owner: ChecksumAddress, spender: ChecksumAddress) -> Wei: - """ - Returns the quantity that `owner` has granted `spender` permission - to spend. Given in "token units" (divide by 10^decimals for - value in whole tokens). - """ - return self.contract.functions.allowance(owner, spender).call() - - def transfer( - self, - recipient: ChecksumAddress, - amount: int, - ) -> ContractFunction: - """ - Create a transaction transferring `amount` in "token units" - (units of 1/10^decimals) to `recipient`. - """ - return self.contract.functions.transfer(recipient, amount) - - def approve( - self, - spender: ChecksumAddress, - amount: int, - ) -> ContractFunction: - """ - Create a transaction granting `spender` permission to spend - `amount` in "token units" (units of 1/10^decimals) held by - `from_addr`. - """ - return self.contract.functions.approve(spender, amount) - - def transfer_from( - self, - spender: ChecksumAddress, - recipient: ChecksumAddress, - amount: int, - ) -> ContractFunction: - """ - Create a transaction transferring `amount` in "token units" (units - of 1/10^decimals) of the tokens held by `spender` to - `recipient`. `spender` must previously have granted - `from_addr` permission to spend these tokens, via an `approve` - transaction. - """ - return self.contract.functions.transferFrom(spender, recipient, amount) - - # TODO: expose events? - # event Transfer(address indexed from, address indexed to, uint256 value); - # event Approval(address indexed owner, address indexed spender, uint256 value); diff --git a/autonity/factory.py b/autonity/factory.py new file mode 100644 index 0000000..5e8e69e --- /dev/null +++ b/autonity/factory.py @@ -0,0 +1,218 @@ +"""Factory functions that find the addresses of Autonity protocol contracts and return +the contract bindings. +""" + +from functools import lru_cache +from warnings import warn + +from eth_typing import ChecksumAddress +from web3 import Web3 + +from .__version__ import __version__ +from .constants import AUTONITY_CONTRACT_ADDRESS, AUTONITY_CONTRACT_VERSION +from .contracts import ( + accountability, + acu, + autonity, + inflation_controller, + liquid, + non_stakable_vesting, + oracle, + stabilization, + supply_control, + upgrade_manager, +) + + +@lru_cache() +def _config(w3: Web3) -> autonity.Config: + if w3.client_version.split("/")[1] != autonity.__version__: + warn( + f"Protocol version mismatch: autonity.py {__version__} supports " + f"version {autonity.__version__}, the RPC node is running " + f"version {w3.client_version}" + ) + + config = autonity.Autonity(w3, AUTONITY_CONTRACT_ADDRESS).config() + if config.contract_version != AUTONITY_CONTRACT_VERSION: + raise RuntimeError( + f"Contract version mismatch: autonity.py {__version__} supports " + f"version {AUTONITY_CONTRACT_VERSION}, the Autonity contract is " + f"version {config.contract_version}" + ) + + return config + + +def Accountability(w3: Web3) -> accountability.Accountability: + """Accountability contract binding factory. + + Parameters + ---------- + w3 : web3.Web3 + A `web3.Web3` instance with a provider connected to an Autonity network. + + Returns + ------- + autonity.contracts.accountability.Accountability + A contract binding instance. + """ + return accountability.Accountability( + w3, _config(w3).contracts.accountability_contract + ) + + +def ACU(w3: Web3) -> acu.ACU: + """ACU contract binding factory. + + Parameters + ---------- + w3 : web3.Web3 + A `web3.Web3` instance with a provider connected to an Autonity network. + + Returns + ------- + autonity.contracts.acu.ACU + A contract binding instance. + """ + return acu.ACU(w3, _config(w3).contracts.acu_contract) + + +def Autonity(w3: Web3) -> autonity.Autonity: + """Autonity contract binding factory. + + Parameters + ---------- + w3 : web3.Web3 + A `web3.Web3` instance with a provider connected to an Autonity network. + + Returns + ------- + autonity.contracts.autonity.Autonity + A contract binding instance. + """ + assert _config(w3) + return autonity.Autonity(w3, AUTONITY_CONTRACT_ADDRESS) + + +def InflationController(w3: Web3) -> inflation_controller.InflationController: + """InflationController contract binding factory. + + Parameters + ---------- + w3 : web3.Web3 + A `web3.Web3` instance with a provider connected to an Autonity network. + + Returns + ------- + autonity.contracts.inflation_controller.InflationController + A contract binding instance. + """ + return inflation_controller.InflationController( + w3, _config(w3).contracts.inflation_controller_contract + ) + + +def Liquid(w3: Web3, address: ChecksumAddress) -> liquid.Liquid: + """Liquid contract binding factory. + + Parameters + ---------- + w3 : web3.Web3 + A `web3.Web3` instance with a provider connected to an Autonity network. + address : eth_typing.ChecksumAddress + The address of a deployed Liquid contract. + + Returns + ------- + autonity.contracts.liquid.Liquid + A contract binding instance. + """ + assert _config(w3) + return liquid.Liquid(w3, address) + + +def NonStakableVesting(w3: Web3) -> non_stakable_vesting.NonStakableVesting: + """NonStakableVesting contract binding factory. + + Parameters + ---------- + w3 : web3.Web3 + A `web3.Web3` instance with a provider connected to an Autonity network. + + Returns + ------- + autonity.contracts.non_stakable_vesting.NonStakableVesting + A contract binding instance. + """ + return non_stakable_vesting.NonStakableVesting( + w3, _config(w3).contracts.non_stakable_vesting_contract + ) + + +def Oracle(w3: Web3) -> oracle.Oracle: + """Oracle contract binding factory. + + Parameters + ---------- + w3 : web3.Web3 + A `web3.Web3` instance with a provider connected to an Autonity network. + + Returns + ------- + autonity.contracts.oracle.Oracle + A contract binding instance. + """ + return oracle.Oracle(w3, _config(w3).contracts.oracle_contract) + + +def Stabilization(w3: Web3) -> stabilization.Stabilization: + """Stabilization contract binding factory. + + Parameters + ---------- + w3 : web3.Web3 + A `web3.Web3` instance with a provider connected to an Autonity network. + + Returns + ------- + autonity.contracts.stabilization.Stabilization + A contract binding instance. + """ + return stabilization.Stabilization(w3, _config(w3).contracts.stabilization_contract) + + +def SupplyControl(w3: Web3) -> supply_control.SupplyControl: + """SupplyControl contract binding factory. + + Parameters + ---------- + w3 : web3.Web3 + A `web3.Web3` instance with a provider connected to an Autonity network. + + Returns + ------- + autonity.contracts.supply_control.SupplyControl + A contract binding instance. + """ + return supply_control.SupplyControl( + w3, _config(w3).contracts.supply_control_contract + ) + + +def UpgradeManager(w3: Web3) -> upgrade_manager.UpgradeManager: + """UpgradeManager contract binding factory. + + Parameters + ---------- + w3 : web3.Web3 + A `web3.Web3` instance with a provider connected to an Autonity network. + + Returns + ------- + autonity.contracts.upgrade_manager.UpgradeManager + A contract binding instance. + """ + return upgrade_manager.UpgradeManager( + w3, _config(w3).contracts.upgrade_manager_contract + ) diff --git a/autonity/liquid.py b/autonity/liquid.py deleted file mode 100644 index e7f8401..0000000 --- a/autonity/liquid.py +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Models for the Liquid contract for a given validator. Note -that this contract also exposes functionality for claiming fees. -""" - -from typing import Tuple - -from web3 import Web3 -from web3.contract.contract import ContractFunction -from web3.types import ChecksumAddress, Wei - -from autonity.abi_manager import load_abi -from autonity.erc20 import ERC20 - - -class Liquid(ERC20): - """ - The Liquid contract. - - This is intended for internal use only. The naming mirrors - the Liquid contract in the Autonity code, but it's not very - intuitive to have methods such as "claim_rewards" on a Token. - Rather, this is more logically exposed by the Validator class. - """ - - def __init__(self, web3: Web3, address: ChecksumAddress): - super().__init__(web3, address, load_abi("Liquid")) - - def validator(self) -> ChecksumAddress: - """ - Get the validator for this contract. - """ - return self.contract.functions.validator().call() - - def treasury(self) -> ChecksumAddress: - """ - Get the treasury for this contract. - """ - return self.contract.functions.treasury().call() - - def commissionRate(self) -> ChecksumAddress: - """ - Get the commision rate for this contract. - """ - return self.contract.functions.commissionRate().call() - - def unclaimed_rewards(self, account: ChecksumAddress) -> Tuple[Wei, Wei]: - """ - See `unclaimedRewards` on Liquid.sol. - """ - return self.contract.functions.unclaimedRewards(account).call() - - def claim_rewards(self) -> ContractFunction: - """ - Create a ContractFunction to claim rewards. Use - `create_contract_function_transaction` to use this in a - transaction. See function `claimRewards` on LiquidNewton.sol. - """ - return self.contract.functions.claimRewards() - - def locked_balance_of(self, delegator: ChecksumAddress) -> Wei: - """ - See function `lockedBalanceOf` on Liquid.sol - """ - return self.contract.functions.lockedBalanceOf(delegator).call() - - def unlocked_balance_of(self, delegator: ChecksumAddress) -> Wei: - """ - See function `unlockedBalanceOf` on Liquid.sol - """ - return self.contract.functions.unlockedBalanceOf(delegator).call() diff --git a/autonity/liquid_newton.py b/autonity/liquid_newton.py deleted file mode 100644 index 50c27b5..0000000 --- a/autonity/liquid_newton.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Deprecated module left for backwards compatibility. -""" - -import warnings - -from web3 import Web3 -from web3.types import ChecksumAddress - -from .liquid import Liquid - - -class LiquidNewton(Liquid): - def __init__(self, web3: Web3, address: ChecksumAddress): - warnings.warn( - "The liquid_newton.LiquidNewton class has been renamed to liquid.Liquid " - "and will be removed in a future release", - DeprecationWarning, - ) - super().__init__(web3, address) diff --git a/autonity/networks.py b/autonity/networks.py new file mode 100644 index 0000000..fa88ca8 --- /dev/null +++ b/autonity/networks.py @@ -0,0 +1,39 @@ +"""Parameters of the available Autonity networks.""" + +from dataclasses import dataclass + +from web3 import HTTPProvider + + +@dataclass(frozen=True) +class Network: + """A record of parameters of an Autonity network. + + Attributes + ---------- + chain_id : int + The network's chain ID. + network_name : str + The network's name as available on ChainList. + http_provider : web3.HTTPProvider + Web3 provider that connects to the default HTTPS JSON-RPC server on the network. + """ + + chain_id: int + network_name: str + http_provider: HTTPProvider + + +bakerloo = Network( + chain_id=65010003, + network_name="Autonity Bakerloo (Yamuna) Testnet", + http_provider=HTTPProvider("https://rpc1.bakerloo.autonity.org/"), +) +"""Network : Autonity Bakerloo (Yamuna) Testnet parameters.""" + +piccadilly = Network( + chain_id=65100003, + network_name="Autonity Piccadilly (Yamuna) Testnet", + http_provider=HTTPProvider("https://rpc1.piccadilly.autonity.org/"), +) +"""Network : Autonity Piccadilly (Yamuna) Testnet parameters.""" diff --git a/autonity/tendermint.py b/autonity/tendermint.py deleted file mode 100644 index 55258c4..0000000 --- a/autonity/tendermint.py +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Python module containing the Tendermint Web3 external module. -""" - -from __future__ import annotations - -import json -from typing import Any, Sequence, Tuple, cast - -from web3.method import Method -from web3.module import Module -from web3.types import ABI, RPCEndpoint - -from autonity.committee_member import CommitteeMember - - -class Tendermint(Module): - """ - A custom Web3.module.Module that enables a JSON-RPC method call to - `tendermint_getContractABI`. - """ - - def _getCommittee_munger( # pylint: disable=invalid-name - self, block_height: int - ) -> Tuple[str]: - return (("0x" + str(block_height)),) - - def _getCommitteeAtHash_munger( # pylint: disable=invalid-name - self, block_hash: bytes - ) -> Tuple[str]: - return (self.w3.to_hex(block_hash),) - - _getCommittee: Method = Method( - json_rpc_method=RPCEndpoint("tendermint_getCommittee"), - mungers=[_getCommittee_munger], - ) - - _getCommitteeAtHash: Method = Method( - json_rpc_method=RPCEndpoint("tendermint_getCommitteeAtHash"), - mungers=[_getCommitteeAtHash_munger], - ) - - _getContractABI: Method = Method( - json_rpc_method=RPCEndpoint("tendermint_getContractABI") - ) - - _getContractAddress: Method = Method( - json_rpc_method=RPCEndpoint("tendermint_getContractAddress") - ) - - _getCoreState: Method = Method( - json_rpc_method=RPCEndpoint("tendermint_getCoreState") - ) - - _getCommitteeEnodes: Method = Method( - json_rpc_method=RPCEndpoint("tendermint_getCommitteeEnodes") - ) - - def get_committee(self, block_height: int) -> Sequence[CommitteeMember]: - """ - Return the committee at the given block height. - """ - result = self._getCommittee(block_height) - assert isinstance(result, list) - return result - - def get_committee_at_hash(self, block_hash: bytes) -> Sequence[CommitteeMember]: - """ - Return the committee at the given block hash. - """ - result = self._getCommitteeAtHash(block_hash) - print(f"result={result}") - assert isinstance(result, list) - committee_members = cast(Sequence[CommitteeMember], result) - assert isinstance(result[0].address, str) - assert isinstance(result[0].votingPower, int) - return committee_members - - def get_contract_abi(self) -> ABI: - """ - Returns the ABI of the Autonity contract. - """ - abi_str = self._getContractABI() - abi = json.loads(abi_str) - assert isinstance(abi, list), f"ABI type {type(abi)})" - return abi - - def get_contract_address(self) -> str: - """ - Returns the address of the Autonity contract. - """ - addr = self._getContractAddress() - assert isinstance(addr, str) - return self.w3.to_checksum_address(addr) - - def get_core_state(self) -> Any: - """ - Returns the core state of attached node. - """ - core_state = self._getCoreState() - print(f"core_state={core_state}") - return core_state - - def get_committee_enodes(self) -> Sequence[str]: - """ - Returns the set of enodes in the current consensus committee. - """ - committee_enodes = self._getCommitteeEnodes() - print(f"core_state={committee_enodes}") - return committee_enodes diff --git a/autonity/utils/__init__.py b/autonity/utils/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/autonity/utils/denominations.py b/autonity/utils/denominations.py deleted file mode 100644 index b05696b..0000000 --- a/autonity/utils/denominations.py +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Utilities related to formatting token and Auton balances. -Constants related to known token precisions. -""" - -from decimal import Decimal - -from web3.types import Wei - -AUTON_DECIMALS = 18 -NEWTON_DECIMALS = 18 - - -def format_quantity(units: int, decimals: int) -> str: - """ - Given some quantity of atomic "token units" of a currency - (e.g. Attoton for Auton), and the decimals used to represent the - value of such a unit, return a string representation of the number - of tokens. - """ - adjusted = Decimal(units) * pow(Decimal(10), -decimals) - return f"{adjusted:f}" - - -def format_auton_quantity(wei: Wei) -> str: - """ - Format a quantity of Wei as a string representing a quantity of - Auton, with decimal places. - """ - return format_quantity(wei, AUTON_DECIMALS) - - -def format_newton_quantity(units: int) -> str: - """ - Format a quantity of Newton units as a string representing a - quantity of whole Newton, with decimal places. - """ - return format_quantity(units, NEWTON_DECIMALS) diff --git a/autonity/utils/keyfile.py b/autonity/utils/keyfile.py deleted file mode 100644 index 6c3add1..0000000 --- a/autonity/utils/keyfile.py +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Keyfile utility functions -""" - -import json -from typing import Any, Dict, NewType, cast - -from eth_account import Account -from eth_keyfile import create_keyfile_json, decode_keyfile_json -from web3 import Web3 -from web3.types import ChecksumAddress - -EncryptedKeyData = Dict[str, Any] - -PrivateKey = NewType("PrivateKey", bytes) - - -def load_keyfile(filename: str) -> EncryptedKeyData: - """ - Load a keyfile. - """ - with open(filename, "r", encoding="utf8") as keyfile_f: - keyfile_json = json.load(keyfile_f) - # TODO: validate the json - return cast(EncryptedKeyData, keyfile_json) - - -def get_address_from_private_key(private_key: PrivateKey) -> ChecksumAddress: - """ - Return the address associated with a given private key. - """ - account = Account.from_key(private_key) # pylint: disable=no-value-for-parameter - return account.address - - -def create_keyfile_from_private_key( - private_key: PrivateKey, password: str -) -> EncryptedKeyData: - """ - Create a keyfile (with encrypted private key) from a private key. - """ - assert len(private_key) == 32 - return create_keyfile_json(private_key, password.encode("utf8")) # type: ignore - - -def get_address_from_keyfile(encrypted_key: EncryptedKeyData) -> ChecksumAddress: - """ - Given some keyfile data, extract the address. - """ - return Web3.to_checksum_address(encrypted_key["address"]) - - -def decrypt_keyfile(encrypted_key: EncryptedKeyData, password: str) -> PrivateKey: - """ - Decrypt the private key from a keyfile. - """ - private_key = decode_keyfile_json(encrypted_key, password.encode("utf8")) # type: ignore - assert isinstance(private_key, bytes) - return cast(PrivateKey, private_key) diff --git a/autonity/utils/tx.py b/autonity/utils/tx.py deleted file mode 100644 index d264b32..0000000 --- a/autonity/utils/tx.py +++ /dev/null @@ -1,205 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Transaction utility functions -""" - -from typing import Callable, Optional - -from eth_account.account import Account, SignedTransaction # type: ignore -from web3 import Web3 -from web3._utils.transactions import fill_transaction_defaults -from web3.contract.contract import ContractFunction -from web3.types import ChecksumAddress, HexBytes, Nonce, TxParams, TxReceipt, Wei - -from autonity.utils.keyfile import ( - EncryptedKeyData, - PrivateKey, - decrypt_keyfile, -) - -# pylint: disable=too-many-arguments -# pylint: disable=too-many-branches - - -def create_transaction( - from_addr: Optional[ChecksumAddress] = None, - to_addr: Optional[ChecksumAddress] = None, - value: Optional[Wei] = None, - data: Optional[HexBytes] = None, - gas: Optional[Wei] = None, - gas_price: Optional[Wei] = None, - max_fee_per_gas: Optional[Wei] = None, - max_priority_fee_per_gas: Optional[Wei] = None, - nonce: Optional[Nonce] = None, - chain_id: Optional[int] = None, -) -> TxParams: - """ - Optionally set some fields on a TxParams object. This can then be - passed to contract call methods, and then any remaining fields set - with finalize_transaction. - """ - tx: TxParams = {} - - if from_addr: - tx["from"] = from_addr - - if to_addr: - tx["to"] = to_addr - - if value: - tx["value"] = value - - if data: - tx["data"] = data - - if nonce: - tx["nonce"] = nonce - - if gas: - tx["gas"] = gas - - if chain_id: - tx["chainId"] = chain_id - - # Require either gas_price OR max_fee_per_gas, etc - - if gas_price: - if max_fee_per_gas or max_priority_fee_per_gas: - raise ValueError("gas price cannot be used with other fee parameters") - tx["gasPrice"] = gas_price - else: - if max_fee_per_gas: - tx["maxFeePerGas"] = max_fee_per_gas - - if max_priority_fee_per_gas: - tx["maxPriorityFeePerGas"] = max_priority_fee_per_gas - else: - tx["maxPriorityFeePerGas"] = tx["maxFeePerGas"] - - return tx - - -def create_contract_function_transaction( - function: ContractFunction, - from_addr: ChecksumAddress, - value: Optional[Wei] = None, - gas: Optional[Wei] = None, - gas_price: Optional[Wei] = None, - max_fee_per_gas: Optional[Wei] = None, - max_priority_fee_per_gas: Optional[Wei] = None, - nonce: Optional[Nonce] = None, - chain_id: Optional[int] = None, -) -> TxParams: - """ - Given a contract call and other parameters, create an unsigned - transaction (Web3 TxParams object). Any fields not passed in will - be filled out by querying the attached node, if available. - """ - tx = create_transaction( - from_addr=from_addr, - value=value, - gas=gas, - gas_price=gas_price, - max_fee_per_gas=max_fee_per_gas, - max_priority_fee_per_gas=max_priority_fee_per_gas, - nonce=nonce, - chain_id=chain_id, - ) - - return function.build_transaction(tx) - - -def finalize_transaction( - create_w3: Callable[[], Web3], - tx: TxParams, - from_addr: Optional[ChecksumAddress], -) -> TxParams: - """ - Fill in any values not already set. If necessary, a Web3 object - will be created via the create_w3 callback. - """ - - w3: Optional[Web3] = None - - def get_web3() -> Web3: - nonlocal w3 - if not w3: - w3 = create_w3() - return w3 - - if "gas" not in tx: - w3 = get_web3() - tx["gas"] = w3.eth.estimate_gas(tx) - - if "nonce" not in tx: - if not from_addr: - raise ValueError("neither nonce or from-address given") - w3 = get_web3() - tx["nonce"] = w3.eth.get_transaction_count(from_addr) - - if "chainId" not in tx: - w3 = get_web3() - tx["chainId"] = w3.eth.chain_id - - if "gasPrice" not in tx and "maxFeePerGas" not in tx: - tx = fill_transaction_defaults(get_web3(), tx) - - # The code above to fill defaults introduces an (unserializable) - # empty bytes() in the "data" field. - - if "data" in tx: - data = tx["data"] - if len(data) == 0: - del tx["data"] - elif isinstance(data, bytes): - tx["data"] = Web3.to_hex(data) - - return tx - - -def sign_tx_with_private_key( - tx: TxParams, private_key: PrivateKey -) -> SignedTransaction: - """ - For cases where the private key has already been decrypted. (In - general, for signing single transactions `sign_tx` is - recommended.) - """ - return Account.sign_transaction( # pylint: disable=no-value-for-parameter - tx, private_key - ) - - -def sign_tx( - tx: TxParams, key_data: EncryptedKeyData, key_passphrase: str -) -> SignedTransaction: - """ - Sign a transaction using the data from an encrypted keyfile and - password. - """ - private_key = decrypt_keyfile(key_data, key_passphrase) - return sign_tx_with_private_key(tx, private_key) - - -def send_tx(w3: Web3, tx_signed: SignedTransaction) -> HexBytes: - """ - Send raw signed tx bytes provided by 'tx_raw' to an RPC server - to be validated and included in the blockchain. - """ - raw_tx = tx_signed.rawTransaction - tx_hash = w3.eth.send_raw_transaction(raw_tx) - return tx_hash - - -def wait_for_tx(w3: Web3, tx_hash: HexBytes, timeout: Optional[float]) -> TxReceipt: - """ - Wait for a specific transaction. Returns the receipts. - - This simply wraps Web3.eth.wait_for_transaction_receipt, but uses - stricter types (accepts only a HexBytes object). - """ - if timeout is None: - return w3.eth.wait_for_transaction_receipt(tx_hash) - - return w3.eth.wait_for_transaction_receipt(tx_hash, timeout=timeout) diff --git a/autonity/utils/web3.py b/autonity/utils/web3.py deleted file mode 100644 index fd647dd..0000000 --- a/autonity/utils/web3.py +++ /dev/null @@ -1,107 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Web3 utility functions -""" - -import re -from typing import Any, Dict, Optional, Sequence, Type, Union, cast - -from web3 import Web3 -from web3.module import Module -from web3.providers import BaseProvider - -from autonity.tendermint import Tendermint - - -class Web3WithAutonity(Web3): - """ - Web3.py class with Autonity-related modules. Used to inform the - static type checker of the existence and types of the modules. - """ - - tendermint: Tendermint - - -def web3_provider_for_endpoint(endpoint: str) -> BaseProvider: - """ - Given an rpc endpoint, return an appropriate provider (https, ws, - or IPC). If identifier isn't a valid format of one of these three - types, throws an exception. - """ - regex_http = re.compile(r"^(?:http)s?://") - if re.match(regex_http, endpoint) is not None: - return Web3.HTTPProvider(endpoint) - - regex_ws = re.compile(r"^(?:ws)s?://") - if re.match(regex_ws, endpoint) is not None: - return Web3.WebsocketProvider(endpoint) - - regex_ipc = re.compile("([^ !$`&*()+]|(\\[ !$`&*()+]))+\\.ipc") - if re.match(regex_ipc, endpoint) is not None: - return Web3.IPCProvider(endpoint) - - raise ValueError(f"cannot determine provider for: {endpoint}") - - -def create_web3( - provider: Optional[BaseProvider] = None, - external_modules: Optional[Dict[str, Union[Type[Module], Sequence[Any]]]] = None, - ignore_chain_id: bool = True, - **kwArgs: Any, -) -> Web3WithAutonity: - """ - Convenience function to create a Web3 instance with the Autonity - external modules attached. Returns a Web3WithAut type, for static - type checking. - """ - - external_modules = external_modules or {} - external_modules["tendermint"] = Tendermint - w3 = Web3( - provider, - external_modules={ - "tendermint": Tendermint, - }, - **kwArgs, - ) - - # Check the chain ID and ensure it conforms to the Autonity - # standard. - if not ignore_chain_id: - chain_id = w3.eth.chain_id - _ = parse_autonity_chain_id(chain_id) - - return cast(Web3WithAutonity, w3) - - -def create_web3_for_endpoint( - endpoint: str, ignore_chain_id: bool = True, **kwArgs: Any -) -> Web3WithAutonity: - """ - Convenience function to create a Web3 object for a specific - endpoint URL. - """ - return create_web3( - web3_provider_for_endpoint(endpoint, **kwArgs), ignore_chain_id=ignore_chain_id - ) - - -def parse_autonity_chain_id(chain_id: int) -> str: - """ - Parse a chain ID according to the Autonity scheme and return a - human-readable version. Raise an exception if the chain ID is not - recognised. - """ - - # As a decimal: '65xxyyyy' where 'xx' = network type and 'yyyy' = - # identifier. - - digits = str(chain_id) - if len(digits) != 8 or digits[:2] != "65": - raise ValueError("chain ID does not match the Autonity scheme") - - net_type = digits[2:4] - net_id = digits[4:] - - return f"Autonity (type: {net_type}, id: {net_id})" diff --git a/autonity/validator.py b/autonity/validator.py deleted file mode 100644 index 15e8065..0000000 --- a/autonity/validator.py +++ /dev/null @@ -1,212 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Model holding Validator information. -""" - -from __future__ import annotations - -import warnings -from enum import IntEnum -from typing import NewType, Tuple, TypedDict - -from hexbytes import HexBytes -from web3 import Web3 -from web3.contract.contract import ContractFunction -from web3.types import ChecksumAddress, Wei - -from autonity.liquid import Liquid - -# pylint: disable=too-many-instance-attributes - - -NodeAddress = NewType("NodeAddress", ChecksumAddress) -OracleAddress = NewType("OracleAddress", ChecksumAddress) - - -class ValidatorState(IntEnum): - """ - The status of a Validator - """ - - ACTIVE = 0 - PAUSED = 1 - JAILED = 2 - JAILBOUND = 3 - - -class ValidatorDescriptor(TypedDict): - """ - Dictionary representing the description of a Validator - """ - - treasury: ChecksumAddress - node_address: NodeAddress - oracle_address: OracleAddress - enode: str - commission_rate: int - bonded_stake: int - unbonding_stake: int - unbonding_shares: int - self_bonded_stake: int - self_unbonding_stake: int - self_unbonding_shares: int - self_unbonding_stake_locked: int - liquid_contract: ChecksumAddress - liquid_supply: int - registration_block: int - total_slashed: int - jail_release_block: int - provable_fault_count: int - consensus_key: str - state: ValidatorState - - -def validator_descriptor_from_tuple( - value: Tuple[ - ChecksumAddress, - NodeAddress, - OracleAddress, - str, - int, - int, - int, - int, - int, - int, - int, - int, - ChecksumAddress, - int, - int, - int, - int, - int, - bytes, - ValidatorState, - ], -) -> ValidatorDescriptor: - """ - Create an instance from the tuple returned by Web3 contract calls. - """ - assert len(value) == 20 - assert isinstance(value[0], str) - assert isinstance(value[1], str) - assert isinstance(value[2], str) - assert isinstance(value[3], str) - assert isinstance(value[4], int) - assert isinstance(value[5], int) - assert isinstance(value[6], int) - assert isinstance(value[7], int) - assert isinstance(value[8], int) - assert isinstance(value[9], int) - assert isinstance(value[10], int) - assert isinstance(value[11], int) - assert isinstance(value[12], str) - assert isinstance(value[13], int) - assert isinstance(value[14], int) - assert isinstance(value[15], int) - assert isinstance(value[16], int) - assert isinstance(value[17], int) - assert isinstance(value[18], bytes) - assert isinstance(value[19], int) - - return ValidatorDescriptor( - { - "treasury": value[0], - "node_address": value[1], - "oracle_address": value[2], - "enode": value[3], - "commission_rate": value[4], - "bonded_stake": value[5], - "unbonding_stake": value[6], - "unbonding_shares": value[7], - "self_bonded_stake": value[8], - "self_unbonding_stake": value[9], - "self_unbonding_shares": value[10], - "self_unbonding_stake_locked": value[11], - "liquid_contract": value[12], - "liquid_supply": value[13], - "registration_block": value[14], - "total_slashed": value[15], - "jail_release_block": value[16], - "provable_fault_count": value[17], - "consensus_key": HexBytes(value[18]).hex(), - "state": ValidatorState(value[19]), - } - ) - - -class Validator: - """ - Information held about a Validator. - """ - - treasury: ChecksumAddress - node_address: NodeAddress - oracle_address: OracleAddress - enode: str - commission_rate: int - bonded_stake: int - unbonding_stake: int - unbonding_shares: int - self_bonded_stake: int - self_unbonding_stake: int - self_unbonding_shares: int - self_unbonding_stake_locked: int - liquid_contract: Liquid - liquid_supply: int - registration_block: int - total_slashed: int - jail_release_block: int - provable_fault_count: int - consensus_key: str - state: ValidatorState - - """ - Internally this provides access to the extra functions. Publicly, - LNTN is exposed as a plain ERC20 token, via lntn_contract. - """ - - def __init__(self, w3: Web3, vdesc: ValidatorDescriptor): - self.treasury = vdesc["treasury"] - self.node_address = vdesc["node_address"] - self.oracle_address = vdesc["oracle_address"] - self.enode = vdesc["enode"] - self.commission_rate = vdesc["commission_rate"] - self.bonded_stake = vdesc["bonded_stake"] - self.unbonding_stake = vdesc["unbonding_stake"] - self.unbonding_shares = vdesc["unbonding_shares"] - self.self_bonded_stake = vdesc["self_bonded_stake"] - self.self_unbonding_stake = vdesc["self_unbonding_stake"] - self.self_unbonding_shares = vdesc["self_unbonding_shares"] - self.self_unbonding_stake_locked = vdesc["self_unbonding_stake_locked"] - self.liquid_contract = Liquid(w3, vdesc["liquid_contract"]) - self.liquid_supply = vdesc["liquid_supply"] - self.registration_block = vdesc["registration_block"] - self.total_slashed = vdesc["total_slashed"] - self.jail_release_block = vdesc["jail_release_block"] - self.provable_fault_count = vdesc["provable_fault_count"] - self.consensus_key = vdesc["consensus_key"] - self.state = vdesc["state"] - - def unclaimed_rewards(self, account: ChecksumAddress) -> Tuple[Wei, Wei]: - """ - Query the rewards for this validator, claimable by `account`. - """ - return self.liquid_contract.unclaimed_rewards(account) - - def claim_rewards(self) -> ContractFunction: - """ - Create a ContractFunction to claim the rewards due from this validator. - """ - return self.liquid_contract.claim_rewards() - - @property - def lntn_contract(self) -> Liquid: - warnings.warn( - "The Validator.lntn_contract property has been renamed to liquid_contract " - "and will be removed in a future release", - DeprecationWarning, - ) - return self.liquid_contract diff --git a/pyproject.toml b/pyproject.toml index 0e017ed..2d22636 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ license = "MIT" keywords = ["autonity", "web3", "rpc", "client", "library"] dynamic = ["version"] requires-python = ">=3.8" -dependencies = ["typing-extensions", "web3==6.19.0"] +dependencies = ["web3==7.2.0", "plum-dispatch==2.5.2"] classifiers = [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", @@ -34,34 +34,30 @@ include = ["autonity/**"] [tool.hatch.version] path = "autonity/__version__.py" +[tool.hatch.envs.generate] +detached = true +dependencies = ["pyabigen@git+https://github.com/clearmatics/pyabigen@v0.2.9"] + [tool.hatch.envs.test] -dependencies = ["mypy", "python-dotenv"] +dependencies = ["pytest"] [[tool.hatch.envs.test.matrix]] python = ["3.8", "3.9", "3.10", "3.11", "3.12"] [tool.hatch.envs.test.scripts] -main = "python -m unittest discover {args:tests}" -types = "mypy {args:.}" -all = ["main", "types"] +all = "pytest -v {args:tests}" [tool.hatch.envs.lint] -detached = true -dependencies = ["black", "ruff"] +dependencies = ["black", "ruff", "mypy", "pyright"] [tool.hatch.envs.lint.scripts] -check = ["ruff check {args:.}", "black --check {args:.}"] +check = [ + "ruff check {args:.}", + "black --check {args:.}", + "mypy {args:autonity}", + "pyright {args:autonity}", +] format = ["black {args:.}", "ruff check --fix --select I {args:.}"] -[tool.mypy] -check_untyped_defs = true -disallow_incomplete_defs = true -disallow_untyped_calls = true -disallow_untyped_defs = true -exclude = "tests/archive" -scripts_are_modules = true -strict_optional = true - -[[tool.mypy.overrides]] -ignore_missing_imports = false -module = ["requests.*", "six"] +[tool.pyright] +strict = ["autonity"] diff --git a/scripts/update-abi.sh b/scripts/update-abi.sh deleted file mode 100755 index 3a87b7d..0000000 --- a/scripts/update-abi.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/bash -eu - -REPO_DIR="$(realpath "$(dirname "$0")/..")" -ABI_DIR="${REPO_DIR}/autonity/abi" -WORKING_DIR="$(mktemp -d)" - -AUTONITY_COMMIT="${1:-$(cat ${ABI_DIR}/autonity-commit.txt)}" -AUTONITY_REPO_URL='https://github.com/autonity/autonity.git' - -if [[ $# -gt 1 ]]; then - echo "usage: $0 [AUTONITY_COMMIT]" - exit 1 -fi - -git clone ${AUTONITY_REPO_URL} "${WORKING_DIR}" -cd "${WORKING_DIR}" -git checkout ${AUTONITY_COMMIT} -make contracts -for abi_file in ./params/generated/*.abi; do - jq --sort-keys <${abi_file} >"${ABI_DIR}/${abi_file##*/}" -done -git -C ${WORKING_DIR} log --no-decorate --pretty='format:%H' -n 1 >${ABI_DIR}/autonity-commit.txt -rm -rf ${WORKING_DIR} diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/abi/TestTypes.abi b/tests/abi/TestTypes.abi deleted file mode 100644 index d48b243..0000000 --- a/tests/abi/TestTypes.abi +++ /dev/null @@ -1,218 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address", - "name": "x", - "type": "address" - } - ], - "name": "test_address", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string[]", - "name": "x", - "type": "string[]" - } - ], - "name": "test_array", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "x", - "type": "bool" - } - ], - "name": "test_bool", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "x", - "type": "bytes" - } - ], - "name": "test_bytes", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string[]", - "name": "x", - "type": "string[]" - }, - { - "components": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "internalType": "struct TestTypes.Dummy", - "name": "y", - "type": "tuple" - }, - { - "internalType": "address", - "name": "z", - "type": "address" - }, - { - "internalType": "uint256", - "name": "w", - "type": "uint256" - } - ], - "name": "test_combine", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "int256", - "name": "x", - "type": "int256" - } - ], - "name": "test_int", - "outputs": [ - { - "internalType": "int256", - "name": "", - "type": "int256" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "x", - "type": "string" - } - ], - "name": "test_string", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "internalType": "struct TestTypes.Dummy", - "name": "x", - "type": "tuple" - } - ], - "name": "test_tuple", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "pure", - "type": "function" - } -] \ No newline at end of file diff --git a/tests/abi/TestTypes.sol b/tests/abi/TestTypes.sol deleted file mode 100644 index c49302f..0000000 --- a/tests/abi/TestTypes.sol +++ /dev/null @@ -1,54 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0 - -pragma solidity ^0.8.0; - -/** - * @title TestTypes - * @dev Implements a contract to test the different types of parameters - */ -contract TestTypes { - struct Dummy { - address from; // if true, that person already voted - address to; // person delegated to - uint256 amount; // index of the voted proposal - } - - function test_array(string[] calldata x) public pure returns (uint) { - return x.length; - } - - function test_tuple(Dummy calldata x) public pure returns (address) { - return x.from; - } - - function test_string( - string calldata x - ) public pure returns (string memory) { - return x; - } - - function test_int(int x) public pure returns (int) { - return x; - } - - function test_bool(bool x) public pure returns (bool) { - return x; - } - - function test_address(address x) public pure returns (address) { - return x; - } - - function test_bytes(bytes calldata x) public pure returns (bytes memory) { - return x; - } - - function test_combine( - string[] calldata x, - Dummy calldata y, - address z, - uint256 w - ) public pure returns (uint, address, address, uint256) { - return (x.length, y.from, z, w); - } -} diff --git a/tests/common.py b/tests/common.py deleted file mode 100644 index b600dc5..0000000 --- a/tests/common.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Common test functions -""" - - -import os - -from dotenv import load_dotenv # type: ignore - -from autonity.utils.web3 import Web3WithAutonity, create_web3_for_endpoint - -ALICE = "0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf" -""" -Dummy address -""" - -BOB = "0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF" -""" -Dummy address -""" - -CAROL = "0x6813Eb9362372EEF6200f3b1dbC3f819671cBA69" -""" -Dummy address -""" - - -load_dotenv() -TEST_RPC_URL = os.getenv("TEST_RPC_URL", "https://rpc1.piccadilly.autonity.org/") - - -def create_test_web3() -> Web3WithAutonity: - """ - Create a Web3 for testing purposes. - """ - return create_web3_for_endpoint(TEST_RPC_URL) diff --git a/tests/test_abi_parser.py b/tests/test_abi_parser.py deleted file mode 100644 index a7e4780..0000000 --- a/tests/test_abi_parser.py +++ /dev/null @@ -1,264 +0,0 @@ -# mypy: ignore-errors -# This is a test file, skipping type checking in it. -""" -Tests for abi_parser.py -""" - -import os -from json.decoder import JSONDecodeError -from typing import Dict, cast -from unittest import TestCase - -from web3 import Web3 -from web3.types import ABI - -from autonity.abi_manager import load_abi_file -from autonity.abi_parser import find_abi_function, parse_arguments, parse_return_value - -MOCK_ABI = cast( - ABI, - [ - { - "inputs": [{"internalType": "address", "name": "_addr", "type": "address"}], - "name": "getValidator", - "outputs": [ - { - "components": [ - { - "internalType": "address payable", - "name": "treasury", - "type": "address", - }, - {"internalType": "address", "name": "addr", "type": "address"}, - {"internalType": "string", "name": "enode", "type": "string"}, - { - "internalType": "uint256", - "name": "commissionRate", - "type": "uint256", - }, - { - "internalType": "uint256", - "name": "bondedStake", - "type": "uint256", - }, - { - "internalType": "uint256", - "name": "totalSlashed", - "type": "uint256", - }, - { - "internalType": "contract Liquid", - "name": "liquidContract", - "type": "address", - }, - { - "internalType": "uint256", - "name": "liquidSupply", - "type": "uint256", - }, - { - "internalType": "uint256", - "name": "registrationBlock", - "type": "uint256", - }, - { - "internalType": "enum Autonity.ValidatorState", - "name": "state", - "type": "uint8", - }, - ], - "internalType": "struct Autonity.Validator", - "name": "", - "type": "tuple", - } - ], - "stateMutability": "view", - "type": "function", - } - ], -) - -MOCK_RETURN_VALUE = ( - "0x75474aC55768fAb6fE092191eea8016b955072F5", - "0x32F3493Ef14c28419a98Ff20dE8A033cf9e6aB97", - "enode://d4dc137f987e17155a69b31e566494c16edafd228912483cc519a48ce85864781" - "faccc38141cc0eb1df8cdb28b9b3ccd10e1c298bac78ac43bbe5804021c1152@34.142.71.5:30303", - 1000, - 10000000000000000000000, - 0, - "0xf4D9599aFd90B5038b18e3B551Bc21a97ed21c37", - 10000000000000000000000, - 0, - 0, -) - -MOCK_EXPECTED_PARSED_RETURN_VALUE: Dict = { - "treasury": "0x75474aC55768fAb6fE092191eea8016b955072F5", - "addr": "0x32F3493Ef14c28419a98Ff20dE8A033cf9e6aB97", - "enode": "enode://d4dc137f987e17155a69b31e566494c16edafd228912483cc519a48ce85864781" - "faccc38141cc0eb1df8cdb28b9b3ccd10e1c298bac78ac43bbe5804021c1152@34.142.71.5:30303", - "commissionRate": 1000, - "bondedStake": 10000000000000000000000, - "totalSlashed": 0, - "liquidContract": "0xf4D9599aFd90B5038b18e3B551Bc21a97ed21c37", - "liquidSupply": 10000000000000000000000, - "registrationBlock": 0, - "state": 0, -} - - -class TestABIParser(TestCase): - """ - Test the ABI parsing functionality. - """ - - # pylint: disable=line-too-long - def test_arg_encoding(self) -> None: - """ - Test argument encoding. - """ - tests = [ - { - "name": "OK: test for address", - "function": "test_address", - "inputs": ["0x1e9Ee7293bc304A10a0b33D0FCCBDFF78463bE5c"], - "expected": [ - Web3.to_checksum_address( - "0x1e9Ee7293bc304A10a0b33D0FCCBDFF78463bE5c" - ) - ], - }, - { - "name": "OK: for boolean input (1)", - "function": "test_bool", - "inputs": ["true"], - "expected": [True], - }, - { - "name": "OK: for boolean input (2)", - "function": "test_bool", - "inputs": ["1"], - "expected": [True], - }, - { - "name": "OK: for boolean input (3)", - "function": "test_bool", - "inputs": ["True"], - "expected": [True], - }, - { - "name": "OK: for boolean input (4)", - "function": "test_bool", - "inputs": ["non empty string"], - "expected": [True], - }, - { - "name": "OK: for boolean input (5)", - "function": "test_bool", - "inputs": [" "], - "expected": [True], - }, # whitespace is considered True - { - "name": "OK: for boolean input (6)", - "function": "test_bool", - "inputs": ["false"], - "expected": [False], - }, - { - "name": "OK: for boolean input (7)", - "function": "test_bool", - "inputs": ["0"], - "expected": [False], - }, - { - "name": "OK: for boolean input (8)", - "function": "test_bool", - "inputs": ["False"], - "expected": [False], - }, - { - "name": "OK: for boolean input (9)", - "function": "test_bool", - "inputs": [""], - "expected": [False], - }, - { - "name": "OK: for array input", - "function": "test_array", - "inputs": ["[1,2,3,4,5]"], - "expected": [[1, 2, 3, 4, 5]], - }, - { - "name": "OK: for tuple input", - "function": "test_tuple", - "inputs": [ - '["0x1e9Ee7293bc304A10a0b33D0FCCBDFF78463bE5c","0x1e9Ee7293bc304A10a0b33D0FCCBDFF78463bE5c",10]' - ], - "expected": [ - [ - Web3.to_checksum_address( - "0x1e9Ee7293bc304A10a0b33D0FCCBDFF78463bE5c" - ), - Web3.to_checksum_address( - "0x1e9Ee7293bc304A10a0b33D0FCCBDFF78463bE5c" - ), - 10, - ] - ], - }, - { - "name": "OK: test for multiple input types", - "function": "test_combine", - "inputs": [ - '["0x1e9Ee7293bc304A10a0b33D0FCCBDFF78463bE5c","0x1e9Ee7293bc304A10a0b33D0FCCBDFF78463bE5c",10]', - '["a","b","c","d"]', - "0x1e9Ee7293bc304A10a0b33D0FCCBDFF78463bE5c", - "10000", - ], - "expected": [ - [ - Web3.to_checksum_address( - "0x1e9Ee7293bc304A10a0b33D0FCCBDFF78463bE5c" - ), - Web3.to_checksum_address( - "0x1e9Ee7293bc304A10a0b33D0FCCBDFF78463bE5c" - ), - 10, - ], - ["a", "b", "c", "d"], - "0x1e9Ee7293bc304A10a0b33D0FCCBDFF78463bE5c", - 10000, - ], - }, - { - "name": "ERR: test invalid json", - "function": "test_array", - "inputs": ["1,2,3,4,5"], - "error": JSONDecodeError, - }, - ] - # execute tests - abi = load_abi_file( - os.path.join(os.path.dirname(__file__), "abi", "TestTypes.abi") - ) - for test in tests: - abi_function = find_abi_function(abi, test["function"]) - # check for error - if test.get("error") is not None: - self.assertRaises( - JSONDecodeError, parse_arguments, abi_function, test["inputs"] - ) - continue - arguments = parse_arguments(abi_function, test["inputs"]) - self.assertEqual(test["expected"], arguments) - - def test_return_value_decoding(self) -> None: - """ - Test return value decoding. - """ - - abi_function = find_abi_function(MOCK_ABI, "getValidator") - retval = parse_return_value(abi_function, MOCK_RETURN_VALUE) - self.assertEqual(MOCK_EXPECTED_PARSED_RETURN_VALUE, retval) - - # TODO: test more sophisticated cases diff --git a/tests/test_autonity.py b/tests/test_autonity.py deleted file mode 100644 index c2e62ac..0000000 --- a/tests/test_autonity.py +++ /dev/null @@ -1,140 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Autonity contract tests -""" - -import os -from unittest import TestCase - -from web3.types import HexBytes, Wei - -from autonity.autonity import ( - Autonity, - get_autonity_contract_abi_path, - get_autonity_contract_version, -) -from autonity.validator import OracleAddress -from tests.common import create_test_web3 - - -class TestAutonityInfo(TestCase): - """ - Test the autonity info functions. - """ - - def test_info(self) -> None: - """ - Test the version function. - """ - version_path = os.path.abspath( - os.path.join( - os.path.dirname(__file__), - "..", - "autonity", - "abi", - "autonity-commit.txt", - ) - ) - version = get_autonity_contract_version() - - with open(version_path, "r", encoding="utf-8") as file: - expected_version = file.read().strip() - self.assertIsInstance(version, str) - self.assertEqual(version, expected_version) - - self.assertIsInstance(version, str) - print(f"Autonity version: {version}") - - def test_abi_path(self) -> None: - """ - Test the abi path function. - """ - - abs_abi_path = os.path.abspath( - os.path.join( - os.path.dirname(__file__), "..", "autonity", "abi", "Autonity.abi" - ) - ) - abi_path = get_autonity_contract_abi_path() - self.assertIsInstance(abi_path, str) - self.assertEqual(abi_path, abs_abi_path) - print(f"Autonity abi path: {abi_path}") - - -class TestAutonity(TestCase): - """ - Autonity contract tests - """ - - def test_autonity_queries(self) -> None: - """ - Test all query functions. - """ - - w3 = create_test_web3() - autonity = Autonity(w3) - - self.assertIsInstance(autonity.commission_rate_precision(), int) - config = autonity.config() - self.assertIsInstance(config, dict) - print(f"Autonity config: {config}") - - self.assertIsInstance(autonity.epoch_id(), int) - self.assertIsInstance(autonity.last_epoch_block(), int) - self.assertIsInstance(autonity.epoch_total_bonded_stake(), int) - self.assertIsInstance(autonity.atn_total_redistributed(), int) - self.assertIsInstance(autonity.epoch_reward(), int) - - self.assertIsInstance(autonity.deployer(), str) - - self.assertIsInstance(autonity.get_last_epoch_block(), int) - self.assertIsInstance(autonity.get_version(), int) - committee = autonity.get_committee() - self.assertIsInstance(committee, list) - self.assertIsInstance(committee[0], dict) - validators = autonity.get_validators() - self.assertIsInstance(validators, list) - self.assertIsInstance(validators[0], str) - self.assertIsInstance(autonity.get_validator(validators[0]), dict) - - self.assertIsInstance(autonity.get_max_committee_size(), int) - committee_enodes = autonity.get_committee_enodes() - self.assertIsInstance(committee_enodes, list) - self.assertIsInstance(committee_enodes[0], str) - self.assertIsInstance(autonity.get_minimum_base_fee(), int) - self.assertIsInstance(autonity.get_operator(), str) - self.assertIsInstance(autonity.get_proposer(1, 1), str) - - def test_autonity_txs(self) -> None: - """ - Test all tx functions. For now, simply call the methods to ensure - they use contract ABI crreectly. - """ - - w3 = create_test_web3() - autonity = Autonity(w3) - - validators = autonity.get_validators() - validator_addr = validators[0] - oracle_addr = OracleAddress(validators[0]) - enode = "adsf" - - autonity.bond(validator_addr, Wei(1)) - autonity.unbond(validator_addr, Wei(1)) - autonity.register_validator( - enode, oracle_addr, HexBytes("0x1234abc"), HexBytes("0x5678def") - ) - autonity.pause_validator(validator_addr) - autonity.activate_validator(validator_addr) - autonity.set_minimum_base_fee(Wei(1)) - autonity.set_committee_size(3) - autonity.set_unbonding_period(10) - autonity.set_epoch_period(10) - autonity.set_operator_account(validator_addr) - # autonity. set_block_period(12) - autonity.set_treasury_account(validator_addr) - autonity.set_treasury_fee(100000) - autonity.mint(validator_addr, Wei(7)) - autonity.burn(validator_addr, Wei(7)) - autonity.change_commission_rate(validator_addr, Wei(7)) diff --git a/tests/test_denominations.py b/tests/test_denominations.py deleted file mode 100644 index eb5d454..0000000 --- a/tests/test_denominations.py +++ /dev/null @@ -1,30 +0,0 @@ -""" -Tests for autonity.utils.denominations -""" - -from unittest import TestCase - -from web3.types import Wei - -from autonity.utils.denominations import ( - format_auton_quantity, - format_newton_quantity, - format_quantity, -) - - -class TestDenominations(TestCase): - """ - Tests for autonity.utils.denominations - """ - - def test_quantity_formatter(self) -> None: - """ - Test the format_*_quantity functions - """ - self.assertEqual("3", format_quantity(3, 0)) - self.assertEqual("0.0000003", format_quantity(3, 7)) - self.assertEqual("0.000000000000000003", format_quantity(3, 18)) - - self.assertEqual("0.000000000000000012", format_auton_quantity(Wei(12))) - self.assertEqual("0.000000000000000012", format_newton_quantity(12)) diff --git a/tests/test_erc20.py b/tests/test_erc20.py deleted file mode 100644 index efaf7bd..0000000 --- a/tests/test_erc20.py +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -ERC20 token tests -""" - -from unittest import TestCase - -from web3 import Web3 -from web3.types import Wei - -from autonity.autonity import Autonity -from autonity.erc20 import ERC20 -from autonity.utils.tx import create_contract_function_transaction -from tests.common import ALICE, BOB, CAROL, create_test_web3 - - -class TestERC20(TestCase): - """ - ERC20 token tests - """ - - def test_erc20_queries(self) -> None: - """ - Basic queries on the Newton token - """ - - w3 = create_test_web3() - autonity = Autonity(w3) - - # Get some NTN holders - validator_addrs = autonity.get_validators()[:3] - holders = [autonity.get_validator(val)["treasury"] for val in validator_addrs] - print(f"holders={holders}") - - # Use the autonity contract as an ERC20 token (Newton) - token = ERC20(w3, autonity.contract.address) - - name = token.name() - symbol = token.symbol() - decimals = token.decimals() - print(f"Token '{name}' ({symbol}) ({decimals} decimals)") - - supply = token.total_supply() - self.assertNotEqual(0, supply) - - for holder in holders: - balance = token.balance_of(holder) - self.assertTrue(isinstance(balance, int)) - print(f" {holder}: {balance}") - - def test_erc20_txs(self) -> None: - """ - Check calls to transaction creation methods. - """ - - w3 = create_test_web3() - autonity = Autonity(w3) - token = ERC20(w3, autonity.contract.address) - - alice = Web3.to_checksum_address(ALICE) - bob = Web3.to_checksum_address(BOB) - carol = Web3.to_checksum_address(CAROL) - - # Alice to Bob - transfer_tx = create_contract_function_transaction( - function=token.transfer(bob, Wei(1)), - from_addr=alice, - gas=Wei(10000), - gas_price=Wei(10000), - ) - self.assertTrue(transfer_tx) - - # Bob approves Alice to control 1000 - approve_tx = create_contract_function_transaction( - function=token.approve(alice, Wei(1000)), - from_addr=bob, - gas=Wei(50000), - gas_price=Wei(30000), - ) - self.assertTrue(approve_tx) - - # Alice uses 500 of the 1000 approved - transfer_from_tx = create_contract_function_transaction( - function=token.transfer_from(alice, carol, Wei(500)), - from_addr=alice, - gas=Wei(9000), - gas_price=Wei(5000), - ) - self.assertTrue(transfer_from_tx) diff --git a/tests/test_keyfile.py b/tests/test_keyfile.py deleted file mode 100644 index fe6ff71..0000000 --- a/tests/test_keyfile.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Keyfile tests -""" - -from unittest import TestCase - -from web3 import Web3 - -from autonity.utils.keyfile import ( - PrivateKey, - create_keyfile_from_private_key, - decrypt_keyfile, - get_address_from_keyfile, -) - - -class TestKeyfile(TestCase): - """ - Keyfile tests - """ - - def test_keyfile_generation(self) -> None: - """ - Test basic enc / dec - """ - # test pk = 00...01 (32 bytes) - private_key = PrivateKey(bytes([0] * 31 + [1])) - password = "pw" - enc_keyfile = create_keyfile_from_private_key(private_key, password) - - # Check address extraction - self.assertTrue(Web3.is_checksum_address(get_address_from_keyfile(enc_keyfile))) - - # attempt to decrypt - private_key_dec = decrypt_keyfile(enc_keyfile, password) - self.assertEqual(private_key, private_key_dec) diff --git a/tests/test_sanity.py b/tests/test_sanity.py new file mode 100644 index 0000000..5ef0afe --- /dev/null +++ b/tests/test_sanity.py @@ -0,0 +1,93 @@ +# type: ignore + +from enum import IntEnum +from inspect import isclass, signature +from typing import Callable, List + +from eth_typing import ChecksumAddress +from hexbytes import HexBytes +from web3 import Web3 +from web3.exceptions import ContractLogicError, ContractPanicError +from web3.contract.contract import ContractFunction + +import autonity +from autonity.constants import AUTONITY_CONTRACT_ADDRESS +from autonity.contracts import ierc20 + + +FACTORIES = [attr for attr in autonity.__dict__.values() if isinstance(attr, Callable)] +BINDINGS = FACTORIES + [ + ierc20.IERC20, # IERC20 is used internally by aut-cli, not part of the public API +] + +TEST_INPUTS = { + bool: True, + int: 1, + str: "", + ChecksumAddress: "0x0123456789abcDEF0123456789abCDef01234567", + HexBytes: HexBytes(val=""), + List[int]: [1], + List[str]: [""], + List[ChecksumAddress]: ["0x0123456789abcDEF0123456789abCDef01234567"], +} + + +def pytest_generate_tests(metafunc): + if "contract_function" not in metafunc.fixturenames: + return + + functions = [] + ids = [] + + for binding in BINDINGS: + w3 = Web3(autonity.networks.piccadilly.http_provider) + + if binding.__name__ == "Liquid": + aut = autonity.Autonity(w3) + validator = aut.get_validator(aut.get_validators()[0]) + contract = binding(w3, validator.liquid_contract) + elif binding.__name__ == "IERC20": + contract = binding(w3, AUTONITY_CONTRACT_ADDRESS) + else: + contract = binding(w3) + + for attr_name in dir(contract): + if attr_name.startswith("_"): + continue + attr = getattr(contract, attr_name) + if isinstance(attr, Callable): + functions.append(attr) + ids.append(f"{binding.__name__}.{attr_name}") + + metafunc.parametrize("contract_function", functions, ids=ids) + + +def get_input_value(type_): + if isclass(type_): + if issubclass(type_, IntEnum): + return TEST_INPUTS[int] + if issubclass(type_, tuple): + inputs = [ + get_input_value(param.annotation) + for param in signature(type_).parameters.values() + ] + return type_(*inputs) + return TEST_INPUTS[type_] + + +def test_bindings_with_arbitrary_inputs(contract_function): + inputs = {} + if not isclass(contract_function): # Not a ContractEvent + inputs = [ + get_input_value(param.annotation) + for param in signature(contract_function).parameters.values() + ] + try: + return_value = contract_function(*inputs) + assert return_value is not None + if isinstance(return_value, ContractFunction): + assert return_value.build_transaction() + except (ContractLogicError, ContractPanicError): + # The contract execution doesn't have to be successful, + # only creating the Web3.py contract function instance does + pass diff --git a/tests/test_tendermint.py b/tests/test_tendermint.py deleted file mode 100644 index 1b3e8b4..0000000 --- a/tests/test_tendermint.py +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Tendermint module tests -""" - -from unittest import TestCase - -from autonity import Tendermint -from tests.common import create_test_web3 - - -class TestTenderming(TestCase): - """ - Tendermint module tests - """ - - def _test_tendermint_module(self) -> None: - """ - test tendermint module - """ - w3 = create_test_web3() - assert hasattr(w3, "tendermint") - # tendermint = cast(Tendermint, w3.tendermint) # pylint: disable=no-member - tendermint = w3.tendermint - assert isinstance(tendermint, Tendermint) - - commitee_1 = tendermint.get_committee(1) - assert isinstance(commitee_1, list) - - block_1 = w3.eth.get_block(1, False) - commitee_block_1 = tendermint.get_committee_at_hash(block_1["hash"]) - assert commitee_1 == commitee_block_1 - - contract_abi = tendermint.get_contract_abi() - assert isinstance(contract_abi, list) - - contract_address = tendermint.get_contract_address() - assert isinstance(contract_address, str) - - # TODO: test this once the RPC call works - # core_state = tendermint.get_core_state() - - committee_enodes = tendermint.get_committee_enodes() - assert isinstance(committee_enodes, list) - assert isinstance(committee_enodes[0], str) diff --git a/tests/test_validator.py b/tests/test_validator.py deleted file mode 100644 index af2a9ad..0000000 --- a/tests/test_validator.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (C) 2015-2022 Clearmatics Technologies Ltd - All Rights Reserved. - -""" -Liquid contract tests -""" - -from unittest import TestCase - -from autonity import Autonity, Validator -from tests.common import create_test_web3 - - -class TestValidator(TestCase): - """ - Test the Validator contract. - """ - - def test_queries(self) -> None: - """ - Basic queries on the Newton token - """ - - w3 = create_test_web3() - autonity = Autonity(w3) - - # Get some NTN holders - validator_addrs = autonity.get_validators()[:3] - validator_descs = [autonity.get_validator(val) for val in validator_addrs] - validators = [Validator(w3, vdesc) for vdesc in validator_descs] - holders = [val.treasury for val in validators] - - validator = validators[0] - lntn = validator.liquid_contract - lntn_symbol = lntn.symbol() or "LNTN" - print( - f"Validator: {validator.node_address}, {lntn_symbol}: " - f"{lntn.name()} @{lntn.contract.address}" - ) - for account in holders: - lntn_balance = lntn.balance_of(account) - unclaimed_atn, _ = validator.unclaimed_rewards(account) - print( - f" {account}: " - f"balance={lntn_balance} {lntn_symbol}, unclaimed fees={unclaimed_atn}" - )