diff --git a/AUTONITY_VERSION b/AUTONITY_VERSION index d0ad59e..fbf0603 100644 --- a/AUTONITY_VERSION +++ b/AUTONITY_VERSION @@ -1 +1 @@ -v1.0.2-alpha +b0e1080d6fce220c9b3daefb57a35835d194695a diff --git a/Makefile b/Makefile index e6eb69e..1846bec 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ gentargets = $(shell find $(SRCDIR) -name $(1).sol) \ all: $(OUTDIR)/accountability.py \ $(OUTDIR)/acu.py \ $(OUTDIR)/autonity.py \ + $(OUTDIR)/auctioneer.py \ $(OUTDIR)/inflation_controller.py \ $(OUTDIR)/liquid_logic.py \ $(OUTDIR)/omission_accountability.py \ @@ -26,11 +27,14 @@ all: $(OUTDIR)/accountability.py \ $(OUTDIR)/upgrade_manager.py $(OUTDIR)/accountability.py: $(call gentargets,Accountability) - $(call abigen,$^) --exclude distributeRewards,finalize,handleAccusation,handleEvent,handleInnocenceProof,handleMisbehaviour,setEpochPeriod >$@ + $(call abigen,$^) --exclude distributeRewards,finalize,handleAccusation,handleEvent,handleInnocenceProof,handleMisbehaviour,setCommittee,setEpochPeriod >$@ $(OUTDIR)/acu.py: $(call gentargets,ACU) $(call abigen,$^) --exclude setOperator,setOracle,update >$@ +$(OUTDIR)/auctioneer.py: $(call gentargets,Auctioneer) + $(call abigen,$^) --exclude paidInterest,setOperator,setOracle,setStabilization >$@ + $(OUTDIR)/autonity.py: $(call gentargets,Autonity) $(call abigen,$^) --exclude autobond,computeCommittee,finalize,finalizeInitialization,jail,jailbound,slash,slashAndJail >$@ @@ -41,16 +45,16 @@ $(OUTDIR)/liquid_logic.py: $(call gentargets,LiquidLogic) $(call abigen,$^) --exclude burn,lock,mint,redistribute,setCommissionRate,unlock >$@ $(OUTDIR)/omission_accountability.py: $(call gentargets,OmissionAccountability) - $(call abigen,$^) --exclude finalize,setCommittee,setEpochBlock,setOperator >$@ + $(call abigen,$^) --exclude distributeProposerRewards,finalize,setCommittee,setEpochBlock,setOperator >$@ $(OUTDIR)/oracle.py: $(call gentargets,Oracle) - $(call abigen,$^) --exclude finalize,setOperator,setVoters,vote >$@ + $(call abigen,$^) --exclude distributeRewards,finalize,setOperator,setVoters,updateVotersAndSymbol,vote >$@ $(OUTDIR)/stabilization.py: $(call gentargets,Stabilization) - $(call abigen,$^) --exclude setOperator,setOracle >$@ + $(call abigen,$^) --exclude liquidate,setACU,setAuctioneer,setOperator,setOracle,setSupplyControl >$@ $(OUTDIR)/supply_control.py: $(call gentargets,SupplyControl) - $(call abigen,$^) --exclude burn,mint,setOperator >$@ + $(call abigen,$^) --exclude burn,mint,setOperator,setStabilizer >$@ $(OUTDIR)/upgrade_manager.py: $(call gentargets,UpgradeManager) $(call abigen,$^) --exclude setOperator >$@ diff --git a/autonity/__init__.py b/autonity/__init__.py index 9dca19b..ea15cb5 100644 --- a/autonity/__init__.py +++ b/autonity/__init__.py @@ -4,6 +4,7 @@ from .factory import ( Accountability, ACU, + Auctioneer, Autonity, InflationController, LiquidLogic, @@ -19,6 +20,7 @@ "contracts", "Accountability", "ACU", + "Auctioneer", "Autonity", "InflationController", "LiquidLogic", diff --git a/autonity/contracts/accountability.py b/autonity/contracts/accountability.py index abbd156..3e8f34c 100644 --- a/autonity/contracts/accountability.py +++ b/autonity/contracts/accountability.py @@ -1,6 +1,6 @@ """Accountability contract binding and data structures.""" -# This module has been generated using pyabigen v0.2.12 +# This module has been generated using pyabigen v0.2.15 import enum import typing @@ -11,11 +11,11 @@ import web3 from web3.contract import contract -__version__ = "v1.0.2-alpha" +__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" class Rule(enum.IntEnum): - """Port of `enum Rule` on the Accountability contract.""" + """Port of `enum Rule` on the IAccountability contract.""" PN = 0 PO = 1 @@ -30,7 +30,7 @@ class Rule(enum.IntEnum): class EventType(enum.IntEnum): - """Port of `enum EventType` on the Accountability contract.""" + """Port of `enum EventType` on the IAccountability contract.""" FAULT_PROOF = 0 ACCUSATION = 1 @@ -39,7 +39,7 @@ class EventType(enum.IntEnum): @dataclass class BaseSlashingRates: - """Port of `struct BaseSlashingRates` on the Accountability contract.""" + """Port of `struct BaseSlashingRates` on the IAccountability contract.""" low: int mid: int @@ -48,7 +48,7 @@ class BaseSlashingRates: @dataclass class Factors: - """Port of `struct Factors` on the Accountability contract.""" + """Port of `struct Factors` on the IAccountability contract.""" collusion: int history: int @@ -57,16 +57,18 @@ class Factors: @dataclass class Config: - """Port of `struct Config` on the Accountability contract.""" + """Port of `struct Config` on the IAccountability contract.""" innocence_proof_submission_window: int + delta: int + range: int base_slashing_rates: BaseSlashingRates factors: Factors @dataclass class Event: - """Port of `struct Event` on the Accountability contract.""" + """Port of `struct Event` on the IAccountability contract.""" event_type: EventType rule: Rule @@ -102,44 +104,106 @@ def __init__( abi=ABI, ) + @property + def AccountabilityFactorsUpdate(self) -> contract.ContractEvent: + """Binding for `event AccountabilityFactorsUpdate` on the Accountability contract. + + Event emitted after accountability factors (collusion, history and jail) are + updated + """ + return self._contract.events.AccountabilityFactorsUpdate + + @property + def BaseSlashingRateUpdate(self) -> contract.ContractEvent: + """Binding for `event BaseSlashingRateUpdate` on the Accountability contract. + + Event emitted after base slashing rates are updated + """ + return self._contract.events.BaseSlashingRateUpdate + + @property + def CallFailed(self) -> contract.ContractEvent: + """Binding for `event CallFailed` on the Accountability contract. + + This event is emitted when a call to an address fails in a protocol function + (like finalize()). + """ + return self._contract.events.CallFailed + + @property + def ConfigUpdateAddress(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateAddress` on the Accountability contract. + + Emitted after updating config parameter of type address + """ + return self._contract.events.ConfigUpdateAddress + + @property + def ConfigUpdateBool(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateBool` on the Accountability contract. + + Emitted after updating config parameter of type boolean + """ + return self._contract.events.ConfigUpdateBool + + @property + def ConfigUpdateInt(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateInt` on the Accountability contract. + + Emitted after updating config parameter of type int + """ + return self._contract.events.ConfigUpdateInt + + @property + def ConfigUpdateUint(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateUint` on the Accountability contract. + + Emitted after updating config parameter of type uint + """ + return self._contract.events.ConfigUpdateUint + @property def InnocenceProven(self) -> contract.ContractEvent: - """Binding for `event InnocenceProven` on the Accountability contract.""" + """Binding for `event InnocenceProven` on the Accountability contract. + + Event emitted after receiving a proof-of-innocence cancelling an accusation. + """ return self._contract.events.InnocenceProven @property def NewAccusation(self) -> contract.ContractEvent: - """Binding for `event NewAccusation` on the Accountability contract.""" + """Binding for `event NewAccusation` on the Accountability contract. + + Event emitted after receiving an accusation, the reported validator has a + certain amount of time to submit a proof-of-innocence, otherwise, he gets + slashed. + """ return self._contract.events.NewAccusation @property def NewFaultProof(self) -> contract.ContractEvent: - """Binding for `event NewFaultProof` on the Accountability contract.""" + """Binding for `event NewFaultProof` on the Accountability contract. + + Event emitted when a fault proof has been submitted. The reported validator will + be silenced and slashed at the end of the current epoch. + """ return self._contract.events.NewFaultProof @property - def SlashingEvent(self) -> contract.ContractEvent: - """Binding for `event SlashingEvent` on the Accountability contract.""" - return self._contract.events.SlashingEvent + def ReporterRewarded(self) -> contract.ContractEvent: + """Binding for `event ReporterRewarded` on the Accountability contract. - def beneficiaries( - self, - key0: eth_typing.ChecksumAddress, - ) -> eth_typing.ChecksumAddress: - """Binding for `beneficiaries` on the Accountability contract. + Event emitted when a reporter is rewarded for submitting a valid proof + """ + return self._contract.events.ReporterRewarded - Parameters - ---------- - key0 : eth_typing.ChecksumAddress + @property + def SlashingEvent(self) -> contract.ContractEvent: + """Binding for `event SlashingEvent` on the Accountability contract. - Returns - ------- - eth_typing.ChecksumAddress + Event emitted after a successful slashing. """ - return_value = self._contract.functions.beneficiaries( - key0, - ).call() - return eth_typing.ChecksumAddress(return_value) + return self._contract.events.SlashingEvent def can_accuse( self, @@ -195,62 +259,158 @@ def can_slash( ).call() return bool(return_value) - def config( + def get_beneficiary( + self, + _offender: eth_typing.ChecksumAddress, + ) -> eth_typing.ChecksumAddress: + """Binding for `getBeneficiary` on the Accountability contract. + + Parameters + ---------- + _offender : eth_typing.ChecksumAddress + , the validator address of the offender + + Returns + ------- + eth_typing.ChecksumAddress + the relative beneficiary which is going to receive the rewards of the + offender + """ + return_value = self._contract.functions.getBeneficiary( + _offender, + ).call() + return eth_typing.ChecksumAddress(return_value) + + def get_config( self, ) -> Config: - """Binding for `config` on the Accountability contract. + """Binding for `getConfig` on the Accountability contract. Returns ------- Config + config, the config of the accountability contract """ - return_value = self._contract.functions.config().call() + return_value = self._contract.functions.getConfig().call() return Config( int(return_value[0]), + int(return_value[1]), + int(return_value[2]), BaseSlashingRates( - int(return_value[1][0]), - int(return_value[1][1]), - int(return_value[1][2]), + int(return_value[3][0]), + int(return_value[3][1]), + int(return_value[3][2]), ), Factors( - int(return_value[2][0]), - int(return_value[2][1]), - int(return_value[2][2]), + int(return_value[4][0]), + int(return_value[4][1]), + int(return_value[4][2]), ), ) - def events( + def get_event( self, - key0: int, - ) -> typing.List[Event]: - """Binding for `events` on the Accountability contract. + _id: int, + ) -> Event: + """Binding for `getEvent` on the Accountability contract. Parameters ---------- - key0 : int + _id : int + , the event id Returns ------- - typing.List[Event] + Event + the relative accountability event """ - return_value = self._contract.functions.events( - key0, + return_value = self._contract.functions.getEvent( + _id, ).call() - return [ - Event( - EventType(return_value_elem[0]), - Rule(return_value_elem[1]), - eth_typing.ChecksumAddress(return_value_elem[2]), - eth_typing.ChecksumAddress(return_value_elem[3]), - hexbytes.HexBytes(return_value_elem[4]), - int(return_value_elem[5]), - int(return_value_elem[6]), - int(return_value_elem[7]), - int(return_value_elem[8]), - int(return_value_elem[9]), - ) - for return_value_elem in return_value - ] + return Event( + EventType(return_value[0]), + Rule(return_value[1]), + eth_typing.ChecksumAddress(return_value[2]), + eth_typing.ChecksumAddress(return_value[3]), + hexbytes.HexBytes(return_value[4]), + int(return_value[5]), + int(return_value[6]), + int(return_value[7]), + int(return_value[8]), + int(return_value[9]), + ) + + def get_events_length( + self, + ) -> int: + """Binding for `getEventsLength` on the Accountability contract. + + Returns + ------- + int + the number of accountability events + """ + return_value = self._contract.functions.getEventsLength().call() + return int(return_value) + + def get_grace_period( + self, + ) -> int: + """Binding for `getGracePeriod` on the Accountability contract. + + Returns + ------- + int + gracePeriod, the current grace period in accountability + """ + return_value = self._contract.functions.getGracePeriod().call() + return int(return_value) + + def get_history( + self, + _validator: eth_typing.ChecksumAddress, + ) -> int: + """Binding for `getHistory` on the Accountability contract. + + Parameters + ---------- + _validator : eth_typing.ChecksumAddress + , the validator address + + Returns + ------- + int + the number of times the validator has been punished in the past + """ + return_value = self._contract.functions.getHistory( + _validator, + ).call() + return int(return_value) + + def get_slashing_history( + self, + _validator: eth_typing.ChecksumAddress, + _epoch: int, + ) -> int: + """Binding for `getSlashingHistory` on the Accountability contract. + + Parameters + ---------- + _validator : eth_typing.ChecksumAddress + , the validator address + _epoch : int + , the epoch id + + Returns + ------- + int + the severity at which the validator was punished in that epoch + """ + return_value = self._contract.functions.getSlashingHistory( + _validator, + _epoch, + ).call() + return int(return_value) def get_validator_accusation( self, @@ -261,10 +421,12 @@ def get_validator_accusation( Parameters ---------- _val : eth_typing.ChecksumAddress + , the validator address Returns ------- Event + the current accusation event against _val (if any) """ return_value = self._contract.functions.getValidatorAccusation( _val, @@ -291,10 +453,12 @@ def get_validator_faults( Parameters ---------- _val : eth_typing.ChecksumAddress + , the validator address Returns ------- typing.List[Event] + the history of faults of this validator """ return_value = self._contract.functions.getValidatorFaults( _val, @@ -315,25 +479,6 @@ def get_validator_faults( for return_value_elem in return_value ] - def history( - self, - key0: eth_typing.ChecksumAddress, - ) -> int: - """Binding for `history` on the Accountability contract. - - Parameters - ---------- - key0 : eth_typing.ChecksumAddress - - Returns - ------- - int - """ - return_value = self._contract.functions.history( - key0, - ).call() - return int(return_value) - def set_base_slashing_rates( self, _rates: BaseSlashingRates, @@ -353,27 +498,23 @@ def set_base_slashing_rates( (_rates.low, _rates.mid, _rates.high), ) - def set_committee( + def set_delta( self, - _new_committee: typing.List[eth_typing.ChecksumAddress], + _delta: int, ) -> contract.ContractFunction: - """Binding for `setCommittee` on the Accountability contract. - - setCommittee, called by the AC at epoch change, it removes stale committee from - the reporter set, then replace the last committee with current committee, and - set the current committee with the input new committee. + """Binding for `setDelta` on the Accountability contract. Parameters ---------- - _new_committee : typing.List[eth_typing.ChecksumAddress] + _delta : int Returns ------- web3.contract.contract.ContractFunction A contract function instance to be sent in a transaction. """ - return self._contract.functions.setCommittee( - _new_committee, + return self._contract.functions.setDelta( + _delta, ) def set_factors( @@ -414,27 +555,24 @@ def set_innocence_proof_submission_window( _window, ) - def slashing_history( + def set_range( self, - key0: eth_typing.ChecksumAddress, - key1: int, - ) -> int: - """Binding for `slashingHistory` on the Accountability contract. + _range: int, + ) -> contract.ContractFunction: + """Binding for `setRange` on the Accountability contract. Parameters ---------- - key0 : eth_typing.ChecksumAddress - key1 : int + _range : int Returns ------- - int + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. """ - return_value = self._contract.functions.slashingHistory( - key0, - key1, - ).call() - return int(return_value) + return self._contract.functions.setRange( + _range, + ) ABI = typing.cast( @@ -443,7 +581,7 @@ def slashing_history( { "inputs": [ { - "internalType": "address payable", + "internalType": "contract IAutonity", "name": "_autonity", "type": "address", }, @@ -454,6 +592,8 @@ def slashing_history( "name": "innocenceProofSubmissionWindow", "type": "uint256", }, + {"internalType": "uint256", "name": "delta", "type": "uint256"}, + {"internalType": "uint256", "name": "range", "type": "uint256"}, { "components": [ { @@ -472,7 +612,7 @@ def slashing_history( "type": "uint256", }, ], - "internalType": "struct Accountability.BaseSlashingRates", + "internalType": "struct IAccountability.BaseSlashingRates", "name": "baseSlashingRates", "type": "tuple", }, @@ -494,18 +634,241 @@ def slashing_history( "type": "uint256", }, ], - "internalType": "struct Accountability.Factors", + "internalType": "struct IAccountability.Factors", "name": "factors", "type": "tuple", }, ], - "internalType": "struct Accountability.Config", + "internalType": "struct IAccountability.Config", "name": "_config", "type": "tuple", }, ], - "stateMutability": "nonpayable", - "type": "constructor", + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "anonymous": False, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "collusion", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "history", + "type": "uint256", + }, + {"internalType": "uint256", "name": "jail", "type": "uint256"}, + ], + "indexed": False, + "internalType": "struct IAccountability.Factors", + "name": "oldFactors", + "type": "tuple", + }, + { + "components": [ + { + "internalType": "uint256", + "name": "collusion", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "history", + "type": "uint256", + }, + {"internalType": "uint256", "name": "jail", "type": "uint256"}, + ], + "indexed": False, + "internalType": "struct IAccountability.Factors", + "name": "newFactors", + "type": "tuple", + }, + ], + "name": "AccountabilityFactorsUpdate", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "components": [ + {"internalType": "uint256", "name": "low", "type": "uint256"}, + {"internalType": "uint256", "name": "mid", "type": "uint256"}, + {"internalType": "uint256", "name": "high", "type": "uint256"}, + ], + "indexed": False, + "internalType": "struct IAccountability.BaseSlashingRates", + "name": "oldRates", + "type": "tuple", + }, + { + "components": [ + {"internalType": "uint256", "name": "low", "type": "uint256"}, + {"internalType": "uint256", "name": "mid", "type": "uint256"}, + {"internalType": "uint256", "name": "high", "type": "uint256"}, + ], + "indexed": False, + "internalType": "struct IAccountability.BaseSlashingRates", + "name": "newRates", + "type": "tuple", + }, + ], + "name": "BaseSlashingRateUpdate", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": False, + "internalType": "string", + "name": "methodSignature", + "type": "string", + }, + { + "indexed": False, + "internalType": "bytes", + "name": "returnData", + "type": "bytes", + }, + ], + "name": "CallFailed", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "address", + "name": "oldValue", + "type": "address", + }, + { + "indexed": False, + "internalType": "address", + "name": "newValue", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateAddress", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "bool", + "name": "oldValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "bool", + "name": "newValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateBool", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "int256", + "name": "oldValue", + "type": "int256", + }, + { + "indexed": False, + "internalType": "int256", + "name": "newValue", + "type": "int256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateInt", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "oldValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "newValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateUint", + "type": "event", }, { "anonymous": False, @@ -582,6 +945,37 @@ def slashing_history( "name": "NewFaultProof", "type": "event", }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "address", + "name": "_reporter", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "_offender", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "_ntnReward", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "_atnReward", + "type": "uint256", + }, + ], + "name": "ReporterRewarded", + "type": "event", + }, { "anonymous": False, "inputs": [ @@ -619,18 +1013,11 @@ def slashing_history( "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", + "internalType": "enum IAccountability.Rule", "name": "_rule", "type": "uint8", }, @@ -648,7 +1035,7 @@ def slashing_history( "inputs": [ {"internalType": "address", "name": "_offender", "type": "address"}, { - "internalType": "enum Accountability.Rule", + "internalType": "enum IAccountability.Rule", "name": "_rule", "type": "uint8", }, @@ -659,92 +1046,182 @@ def slashing_history( "stateMutability": "view", "type": "function", }, + { + "inputs": [ + {"internalType": "address", "name": "_offender", "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": [ + {"internalType": "uint256", "name": "", "type": "uint256"}, + {"internalType": "uint256", "name": "", "type": "uint256"}, + {"internalType": "uint256", "name": "", "type": "uint256"}, + ], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_offender", "type": "address"} + ], + "name": "getBeneficiary", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, { "inputs": [], - "name": "config", + "name": "getConfig", "outputs": [ - { - "internalType": "uint256", - "name": "innocenceProofSubmissionWindow", - "type": "uint256", - }, { "components": [ - {"internalType": "uint256", "name": "low", "type": "uint256"}, - {"internalType": "uint256", "name": "mid", "type": "uint256"}, - {"internalType": "uint256", "name": "high", "type": "uint256"}, + { + "internalType": "uint256", + "name": "innocenceProofSubmissionWindow", + "type": "uint256", + }, + {"internalType": "uint256", "name": "delta", "type": "uint256"}, + {"internalType": "uint256", "name": "range", "type": "uint256"}, + { + "components": [ + { + "internalType": "uint256", + "name": "low", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "mid", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "high", + "type": "uint256", + }, + ], + "internalType": "struct IAccountability.BaseSlashingRates", + "name": "baseSlashingRates", + "type": "tuple", + }, + { + "components": [ + { + "internalType": "uint256", + "name": "collusion", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "history", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "jail", + "type": "uint256", + }, + ], + "internalType": "struct IAccountability.Factors", + "name": "factors", + "type": "tuple", + }, ], - "internalType": "struct Accountability.BaseSlashingRates", - "name": "baseSlashingRates", + "internalType": "struct IAccountability.Config", + "name": "", "type": "tuple", - }, + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "_id", "type": "uint256"}], + "name": "getEvent", + "outputs": [ { "components": [ + { + "internalType": "enum IAccountability.EventType", + "name": "eventType", + "type": "uint8", + }, + { + "internalType": "enum IAccountability.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": "collusion", + "name": "reportingBlock", "type": "uint256", }, { "internalType": "uint256", - "name": "history", + "name": "messageHash", "type": "uint256", }, - {"internalType": "uint256", "name": "jail", "type": "uint256"}, ], - "internalType": "struct Accountability.Factors", - "name": "factors", + "internalType": "struct IAccountability.Event", + "name": "", "type": "tuple", - }, + } ], "stateMutability": "view", "type": "function", }, { - "inputs": [ - {"internalType": "address", "name": "_offender", "type": "address"}, - {"internalType": "uint256", "name": "_ntnReward", "type": "uint256"}, - ], - "name": "distributeRewards", - "outputs": [], - "stateMutability": "payable", + "inputs": [], + "name": "getEventsLength", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", "type": "function", }, { - "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "name": "events", - "outputs": [ - { - "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"}, + "inputs": [], + "name": "getGracePeriod", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_validator", "type": "address"} ], + "name": "getHistory", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, { - "inputs": [{"internalType": "bool", "name": "_epochEnd", "type": "bool"}], - "name": "finalize", - "outputs": [], - "stateMutability": "nonpayable", + "inputs": [ + {"internalType": "address", "name": "_validator", "type": "address"}, + {"internalType": "uint256", "name": "_epoch", "type": "uint256"}, + ], + "name": "getSlashingHistory", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", "type": "function", }, { @@ -754,12 +1231,12 @@ def slashing_history( { "components": [ { - "internalType": "enum Accountability.EventType", + "internalType": "enum IAccountability.EventType", "name": "eventType", "type": "uint8", }, { - "internalType": "enum Accountability.Rule", + "internalType": "enum IAccountability.Rule", "name": "rule", "type": "uint8", }, @@ -788,7 +1265,7 @@ def slashing_history( "type": "uint256", }, ], - "internalType": "struct Accountability.Event", + "internalType": "struct IAccountability.Event", "name": "", "type": "tuple", } @@ -803,12 +1280,12 @@ def slashing_history( { "components": [ { - "internalType": "enum Accountability.EventType", + "internalType": "enum IAccountability.EventType", "name": "eventType", "type": "uint8", }, { - "internalType": "enum Accountability.Rule", + "internalType": "enum IAccountability.Rule", "name": "rule", "type": "uint8", }, @@ -837,7 +1314,7 @@ def slashing_history( "type": "uint256", }, ], - "internalType": "struct Accountability.Event[]", + "internalType": "struct IAccountability.Event[]", "name": "", "type": "tuple[]", } @@ -850,12 +1327,12 @@ def slashing_history( { "components": [ { - "internalType": "enum Accountability.EventType", + "internalType": "enum IAccountability.EventType", "name": "eventType", "type": "uint8", }, { - "internalType": "enum Accountability.Rule", + "internalType": "enum IAccountability.Rule", "name": "rule", "type": "uint8", }, @@ -884,7 +1361,7 @@ def slashing_history( "type": "uint256", }, ], - "internalType": "struct Accountability.Event", + "internalType": "struct IAccountability.Event", "name": "_event", "type": "tuple", } @@ -899,12 +1376,12 @@ def slashing_history( { "components": [ { - "internalType": "enum Accountability.EventType", + "internalType": "enum IAccountability.EventType", "name": "eventType", "type": "uint8", }, { - "internalType": "enum Accountability.Rule", + "internalType": "enum IAccountability.Rule", "name": "rule", "type": "uint8", }, @@ -933,7 +1410,7 @@ def slashing_history( "type": "uint256", }, ], - "internalType": "struct Accountability.Event", + "internalType": "struct IAccountability.Event", "name": "_event", "type": "tuple", } @@ -948,12 +1425,12 @@ def slashing_history( { "components": [ { - "internalType": "enum Accountability.EventType", + "internalType": "enum IAccountability.EventType", "name": "eventType", "type": "uint8", }, { - "internalType": "enum Accountability.Rule", + "internalType": "enum IAccountability.Rule", "name": "rule", "type": "uint8", }, @@ -982,7 +1459,7 @@ def slashing_history( "type": "uint256", }, ], - "internalType": "struct Accountability.Event", + "internalType": "struct IAccountability.Event", "name": "_event", "type": "tuple", } @@ -992,13 +1469,6 @@ def slashing_history( "stateMutability": "nonpayable", "type": "function", }, - { - "inputs": [{"internalType": "address", "name": "", "type": "address"}], - "name": "history", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "stateMutability": "view", - "type": "function", - }, { "inputs": [ { @@ -1007,7 +1477,7 @@ def slashing_history( {"internalType": "uint256", "name": "mid", "type": "uint256"}, {"internalType": "uint256", "name": "high", "type": "uint256"}, ], - "internalType": "struct Accountability.BaseSlashingRates", + "internalType": "struct IAccountability.BaseSlashingRates", "name": "_rates", "type": "tuple", } @@ -1030,6 +1500,15 @@ def slashing_history( "stateMutability": "nonpayable", "type": "function", }, + { + "inputs": [ + {"internalType": "uint256", "name": "_delta", "type": "uint256"} + ], + "name": "setDelta", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, { "inputs": [ { @@ -1046,7 +1525,7 @@ def slashing_history( }, {"internalType": "uint256", "name": "jail", "type": "uint256"}, ], - "internalType": "struct Accountability.Factors", + "internalType": "struct IAccountability.Factors", "name": "_factors", "type": "tuple", } @@ -1067,12 +1546,11 @@ def slashing_history( }, { "inputs": [ - {"internalType": "address", "name": "", "type": "address"}, - {"internalType": "uint256", "name": "", "type": "uint256"}, + {"internalType": "uint256", "name": "_range", "type": "uint256"} ], - "name": "slashingHistory", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "stateMutability": "view", + "name": "setRange", + "outputs": [], + "stateMutability": "nonpayable", "type": "function", }, ], diff --git a/autonity/contracts/acu.py b/autonity/contracts/acu.py index 1fc4163..ee759a4 100644 --- a/autonity/contracts/acu.py +++ b/autonity/contracts/acu.py @@ -1,6 +1,6 @@ """ACU contract binding and data structures.""" -# This module has been generated using pyabigen v0.2.12 +# This module has been generated using pyabigen v0.2.15 import typing @@ -8,7 +8,7 @@ import web3 from web3.contract import contract -__version__ = "v1.0.2-alpha" +__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" class ACU: @@ -44,6 +44,46 @@ def BasketModified(self) -> contract.ContractEvent: """ return self._contract.events.BasketModified + @property + def ConfigUpdateAddress(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateAddress` on the ACU contract. + + Emitted after updating config parameter of type address + """ + return self._contract.events.ConfigUpdateAddress + + @property + def ConfigUpdateBool(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateBool` on the ACU contract. + + Emitted after updating config parameter of type boolean + """ + return self._contract.events.ConfigUpdateBool + + @property + def ConfigUpdateInt(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateInt` on the ACU contract. + + Emitted after updating config parameter of type int + """ + return self._contract.events.ConfigUpdateInt + + @property + def ConfigUpdateUint(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateUint` on the ACU contract. + + Emitted after updating config parameter of type uint + """ + return self._contract.events.ConfigUpdateUint + + @property + def Rescaled(self) -> contract.ContractEvent: + """Binding for `event Rescaled` on the ACU contract. + + The ACU quantity multiplier has been updated + """ + return self._contract.events.Rescaled + @property def Updated(self) -> contract.ContractEvent: """Binding for `event Updated` on the ACU contract. @@ -52,6 +92,45 @@ def Updated(self) -> contract.ContractEvent: """ return self._contract.events.Updated + def get_round( + self, + ) -> int: + """Binding for `getRound` on the ACU contract. + + Returns + ------- + int + The Oracle round of the current ACU value. + """ + return_value = self._contract.functions.getRound().call() + return int(return_value) + + def get_scale( + self, + ) -> int: + """Binding for `getScale` on the ACU contract. + + Returns + ------- + int + The decimal places used to represent the ACU as a fixed-point integer. + """ + return_value = self._contract.functions.getScale().call() + return int(return_value) + + def get_scale_factor( + self, + ) -> int: + """Binding for `getScaleFactor` on the ACU contract. + + Returns + ------- + int + The multiplier for scaling numbers to the ACU scaled representation. + """ + return_value = self._contract.functions.getScaleFactor().call() + return int(return_value) + def modify_basket( self, symbols_: typing.List[str], @@ -82,6 +161,21 @@ def modify_basket( scale_, ) + def multiplier( + self, + ) -> int: + """Binding for `multiplier` on the ACU contract. + + The quantity multiplier that is used to compute the ACU. + + Returns + ------- + int + Quantity multiplier + """ + return_value = self._contract.functions.multiplier().call() + return int(return_value) + def quantities( self, ) -> typing.List[int]: @@ -97,48 +191,41 @@ def quantities( return_value = self._contract.functions.quantities().call() return [int(return_value_elem) for return_value_elem in return_value] - def round( + def rescale( 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) + new_quantity_multiplier: int, + ) -> contract.ContractFunction: + """Binding for `rescale` on the ACU contract. - def scale( - self, - ) -> int: - """Binding for `scale` on the ACU contract. + the quantity multiplier has precision of scaleFactor - The decimal places used to represent the ACU as a fixed-point integer. It is - also the scale used to represent the basket quantities. + Parameters + ---------- + new_quantity_multiplier : int Returns ------- - int + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. """ - return_value = self._contract.functions.scale().call() - return int(return_value) + return self._contract.functions.rescale( + new_quantity_multiplier, + ) - def scale_factor( + def scaled_quantities( self, - ) -> int: - """Binding for `scaleFactor` on the ACU contract. + ) -> typing.List[int]: + """Binding for `scaledQuantities` on the ACU contract. - The multiplier for scaling numbers to the ACU scaled representation. + The scaled quantities used to compute the ACU. Returns ------- - int + typing.List[int] + Array of scaled quantities """ - return_value = self._contract.functions.scaleFactor().call() - return int(return_value) + return_value = self._contract.functions.scaledQuantities().call() + return [int(return_value_elem) for return_value_elem in return_value] def symbols( self, @@ -165,7 +252,8 @@ def value( Returns ------- int - ACU value in fixed-point integer representation + ACU value in fixed-point integer representation rescaled by the quantity + multiplier """ return_value = self._contract.functions.value().call() return int(return_value) @@ -193,6 +281,7 @@ def value( {"inputs": [], "name": "InvalidBasket", "type": "error"}, {"inputs": [], "name": "NoACUValue", "type": "error"}, {"inputs": [], "name": "Unauthorized", "type": "error"}, + {"inputs": [], "name": "ZeroValue", "type": "error"}, { "anonymous": False, "inputs": [ @@ -218,6 +307,149 @@ def value( "name": "BasketModified", "type": "event", }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "address", + "name": "oldValue", + "type": "address", + }, + { + "indexed": False, + "internalType": "address", + "name": "newValue", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateAddress", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "bool", + "name": "oldValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "bool", + "name": "newValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateBool", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "int256", + "name": "oldValue", + "type": "int256", + }, + { + "indexed": False, + "internalType": "int256", + "name": "newValue", + "type": "int256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateInt", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "oldValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "newValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateUint", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "newQuantityMultiplier", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "oldQuantityMultiplier", + "type": "uint256", + }, + ], + "name": "Rescaled", + "type": "event", + }, { "anonymous": False, "inputs": [ @@ -241,14 +473,35 @@ def value( }, { "indexed": False, - "internalType": "int256", + "internalType": "uint256", "name": "value", - "type": "int256", + "type": "uint256", }, ], "name": "Updated", "type": "event", }, + { + "inputs": [], + "name": "getRound", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getScale", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getScaleFactor", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, { "inputs": [ {"internalType": "string[]", "name": "symbols_", "type": "string[]"}, @@ -266,29 +519,35 @@ def value( }, { "inputs": [], - "name": "quantities", - "outputs": [{"internalType": "uint256[]", "name": "", "type": "uint256[]"}], + "name": "multiplier", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, { "inputs": [], - "name": "round", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "quantities", + "outputs": [{"internalType": "uint256[]", "name": "", "type": "uint256[]"}], "stateMutability": "view", "type": "function", }, { - "inputs": [], - "name": "scale", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "stateMutability": "view", + "inputs": [ + { + "internalType": "uint256", + "name": "newQuantityMultiplier", + "type": "uint256", + } + ], + "name": "rescale", + "outputs": [], + "stateMutability": "nonpayable", "type": "function", }, { "inputs": [], - "name": "scaleFactor", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "scaledQuantities", + "outputs": [{"internalType": "uint256[]", "name": "", "type": "uint256[]"}], "stateMutability": "view", "type": "function", }, @@ -327,7 +586,7 @@ def value( { "inputs": [], "name": "value", - "outputs": [{"internalType": "int256", "name": "", "type": "int256"}], + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, diff --git a/autonity/contracts/auctioneer.py b/autonity/contracts/auctioneer.py new file mode 100644 index 0000000..8b79ac9 --- /dev/null +++ b/autonity/contracts/auctioneer.py @@ -0,0 +1,924 @@ +"""Auctioneer contract binding and data structures.""" + +# This module has been generated using pyabigen v0.2.15 + +import typing +from dataclasses import dataclass + +import eth_typing +import web3 +from web3.contract import contract + +__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" + + +@dataclass +class Config: + """Port of `struct Config` on the Auctioneer contract.""" + + liquidation_auction_duration: int + interest_auction_duration: int + interest_auction_discount: int + interest_auction_threshold: int + + +@dataclass +class Auction: + """Port of `struct Auction` on the AuctionLib contract.""" + + id: int + amount: int + start_price: int + start_timestamp: int + + +class Auctioneer: + """Auctioneer contract binding. + + Parameters + ---------- + w3 : web3.Web3 + address : eth_typing.ChecksumAddress + The address of a deployed Auctioneer 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 AuctionedDebt(self) -> contract.ContractEvent: + """Binding for `event AuctionedDebt` on the Auctioneer contract.""" + return self._contract.events.AuctionedDebt + + @property + def AuctionedInterest(self) -> contract.ContractEvent: + """Binding for `event AuctionedInterest` on the Auctioneer contract.""" + return self._contract.events.AuctionedInterest + + @property + def ConfigUpdateAddress(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateAddress` on the Auctioneer contract. + + Emitted after updating config parameter of type address + """ + return self._contract.events.ConfigUpdateAddress + + @property + def ConfigUpdateBool(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateBool` on the Auctioneer contract. + + Emitted after updating config parameter of type boolean + """ + return self._contract.events.ConfigUpdateBool + + @property + def ConfigUpdateInt(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateInt` on the Auctioneer contract. + + Emitted after updating config parameter of type int + """ + return self._contract.events.ConfigUpdateInt + + @property + def ConfigUpdateUint(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateUint` on the Auctioneer contract. + + Emitted after updating config parameter of type uint + """ + return self._contract.events.ConfigUpdateUint + + @property + def NewInterestAuction(self) -> contract.ContractEvent: + """Binding for `event NewInterestAuction` on the Auctioneer contract.""" + return self._contract.events.NewInterestAuction + + @property + def PriceUnavailable(self) -> contract.ContractEvent: + """Binding for `event PriceUnavailable` on the Auctioneer contract.""" + return self._contract.events.PriceUnavailable + + def bid_debt( + self, + debtor: eth_typing.ChecksumAddress, + liquidatable_round: int, + ntn_amount: int, + ) -> contract.ContractFunction: + """Binding for `bidDebt` on the Auctioneer contract. + + Parameters + ---------- + debtor : eth_typing.ChecksumAddress + liquidatable_round : int + ntn_amount : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.bidDebt( + debtor, + liquidatable_round, + ntn_amount, + ) + + def bid_interest( + self, + auction: int, + ntn_amount: int, + ) -> contract.ContractFunction: + """Binding for `bidInterest` on the Auctioneer contract. + + Parameters + ---------- + auction : int + ntn_amount : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.bidInterest( + auction, + ntn_amount, + ) + + def get_auction( + self, + auction: int, + ) -> Auction: + """Binding for `getAuction` on the Auctioneer contract. + + Parameters + ---------- + auction : int + + Returns + ------- + Auction + """ + return_value = self._contract.functions.getAuction( + auction, + ).call() + return Auction( + int(return_value[0]), + int(return_value[1]), + int(return_value[2]), + int(return_value[3]), + ) + + def get_collateral_token( + self, + ) -> eth_typing.ChecksumAddress: + """Binding for `getCollateralToken` on the Auctioneer contract. + + Returns + ------- + eth_typing.ChecksumAddress + """ + return_value = self._contract.functions.getCollateralToken().call() + return eth_typing.ChecksumAddress(return_value) + + def get_config( + self, + ) -> Config: + """Binding for `getConfig` on the Auctioneer contract. + + Returns + ------- + Config + """ + return_value = self._contract.functions.getConfig().call() + return Config( + int(return_value[0]), + int(return_value[1]), + int(return_value[2]), + int(return_value[3]), + ) + + def get_proceed_address( + self, + ) -> eth_typing.ChecksumAddress: + """Binding for `getProceedAddress` on the Auctioneer contract. + + Returns + ------- + eth_typing.ChecksumAddress + """ + return_value = self._contract.functions.getProceedAddress().call() + return eth_typing.ChecksumAddress(return_value) + + def max_liquidation_return( + self, + debtor: eth_typing.ChecksumAddress, + liquidatable_round: int, + ) -> int: + """Binding for `maxLiquidationReturn` on the Auctioneer contract. + + Parameters + ---------- + debtor : eth_typing.ChecksumAddress + liquidatable_round : int + + Returns + ------- + int + """ + return_value = self._contract.functions.maxLiquidationReturn( + debtor, + liquidatable_round, + ).call() + return int(return_value) + + def min_interest_payment( + self, + auction: int, + ) -> int: + """Binding for `minInterestPayment` on the Auctioneer contract. + + Parameters + ---------- + auction : int + + Returns + ------- + int + """ + return_value = self._contract.functions.minInterestPayment( + auction, + ).call() + return int(return_value) + + def open_auctions( + self, + ) -> typing.List[Auction]: + """Binding for `openAuctions` on the Auctioneer contract. + + Returns + ------- + typing.List[Auction] + """ + return_value = self._contract.functions.openAuctions().call() + return [ + Auction( + int(return_value_elem[0]), + int(return_value_elem[1]), + int(return_value_elem[2]), + int(return_value_elem[3]), + ) + for return_value_elem in return_value + ] + + def set_interest_auction_discount( + self, + discount: int, + ) -> contract.ContractFunction: + """Binding for `setInterestAuctionDiscount` on the Auctioneer contract. + + Parameters + ---------- + discount : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setInterestAuctionDiscount( + discount, + ) + + def set_interest_auction_duration( + self, + duration: int, + ) -> contract.ContractFunction: + """Binding for `setInterestAuctionDuration` on the Auctioneer contract. + + Parameters + ---------- + duration : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setInterestAuctionDuration( + duration, + ) + + def set_interest_auction_threshold( + self, + threshold: int, + ) -> contract.ContractFunction: + """Binding for `setInterestAuctionThreshold` on the Auctioneer contract. + + Parameters + ---------- + threshold : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setInterestAuctionThreshold( + threshold, + ) + + def set_liquidation_auction_duration( + self, + duration: int, + ) -> contract.ContractFunction: + """Binding for `setLiquidationAuctionDuration` on the Auctioneer contract. + + Parameters + ---------- + duration : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setLiquidationAuctionDuration( + duration, + ) + + def set_proceed_address( + self, + proceed_address_: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `setProceedAddress` on the Auctioneer contract. + + Parameters + ---------- + proceed_address_ : eth_typing.ChecksumAddress + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setProceedAddress( + proceed_address_, + ) + + +ABI = typing.cast( + eth_typing.ABI, + [ + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "liquidationAuctionDuration", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "interestAuctionDuration", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "interestAuctionDiscount", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "interestAuctionThreshold", + "type": "uint256", + }, + ], + "internalType": "struct Auctioneer.Config", + "name": "config_", + "type": "tuple", + }, + { + "internalType": "address", + "name": "stabilization_", + "type": "address", + }, + {"internalType": "address", "name": "oracle_", "type": "address"}, + { + "internalType": "address", + "name": "collateralToken_", + "type": "address", + }, + {"internalType": "address", "name": "autonity_", "type": "address"}, + {"internalType": "address", "name": "operator_", "type": "address"}, + ], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "minimumBid", "type": "uint256"}, + {"internalType": "uint256", "name": "bid", "type": "uint256"}, + ], + "name": "BidTooLow", + "type": "error", + }, + {"inputs": [], "name": "InsufficientAllowance", "type": "error"}, + {"inputs": [], "name": "InvalidAmount", "type": "error"}, + {"inputs": [], "name": "InvalidAuctionId", "type": "error"}, + { + "inputs": [{"internalType": "string", "name": "message", "type": "string"}], + "name": "InvalidParameter", + "type": "error", + }, + { + "inputs": [{"internalType": "uint256", "name": "round", "type": "uint256"}], + "name": "InvalidRound", + "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_Sqrt_Overflow", + "type": "error", + }, + {"inputs": [], "name": "TransferFailed", "type": "error"}, + {"inputs": [], "name": "Unauthorized", "type": "error"}, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "debtor", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "biddor", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "collateralAmount", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "debtAmount", + "type": "uint256", + }, + ], + "name": "AuctionedDebt", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "biddor", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "interestAmount", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "paymentAmount", + "type": "uint256", + }, + ], + "name": "AuctionedInterest", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "address", + "name": "oldValue", + "type": "address", + }, + { + "indexed": False, + "internalType": "address", + "name": "newValue", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateAddress", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "bool", + "name": "oldValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "bool", + "name": "newValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateBool", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "int256", + "name": "oldValue", + "type": "int256", + }, + { + "indexed": False, + "internalType": "int256", + "name": "newValue", + "type": "int256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateInt", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "oldValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "newValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateUint", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "auctionId", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "startRound", + "type": "uint256", + }, + ], + "name": "NewInterestAuction", + "type": "event", + }, + {"anonymous": False, "inputs": [], "name": "PriceUnavailable", "type": "event"}, + { + "inputs": [ + {"internalType": "address", "name": "debtor", "type": "address"}, + { + "internalType": "uint256", + "name": "liquidatableRound", + "type": "uint256", + }, + {"internalType": "uint256", "name": "ntnAmount", "type": "uint256"}, + ], + "name": "bidDebt", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "auction", "type": "uint256"}, + {"internalType": "uint256", "name": "ntnAmount", "type": "uint256"}, + ], + "name": "bidInterest", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "auction", "type": "uint256"} + ], + "name": "getAuction", + "outputs": [ + { + "components": [ + {"internalType": "uint256", "name": "id", "type": "uint256"}, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "startPrice", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "startTimestamp", + "type": "uint256", + }, + ], + "internalType": "struct AuctionLib.Auction", + "name": "", + "type": "tuple", + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getCollateralToken", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getConfig", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "liquidationAuctionDuration", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "interestAuctionDuration", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "interestAuctionDiscount", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "interestAuctionThreshold", + "type": "uint256", + }, + ], + "internalType": "struct Auctioneer.Config", + "name": "", + "type": "tuple", + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getProceedAddress", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "debtor", "type": "address"}, + { + "internalType": "uint256", + "name": "liquidatableRound", + "type": "uint256", + }, + ], + "name": "maxLiquidationReturn", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "auction", "type": "uint256"} + ], + "name": "minInterestPayment", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "openAuctions", + "outputs": [ + { + "components": [ + {"internalType": "uint256", "name": "id", "type": "uint256"}, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "startPrice", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "startTimestamp", + "type": "uint256", + }, + ], + "internalType": "struct AuctionLib.Auction[]", + "name": "", + "type": "tuple[]", + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "paidInterest", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "discount", "type": "uint256"} + ], + "name": "setInterestAuctionDiscount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "duration", "type": "uint256"} + ], + "name": "setInterestAuctionDuration", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "threshold", "type": "uint256"} + ], + "name": "setInterestAuctionThreshold", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "duration", "type": "uint256"} + ], + "name": "setLiquidationAuctionDuration", + "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": "proceedAddress_", + "type": "address", + } + ], + "name": "setProceedAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "stabilization_", "type": "address"} + ], + "name": "setStabilization", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + ], +) diff --git a/autonity/contracts/autonity.py b/autonity/contracts/autonity.py index 3eecaca..c06393e 100644 --- a/autonity/contracts/autonity.py +++ b/autonity/contracts/autonity.py @@ -1,6 +1,6 @@ """Autonity contract binding and data structures.""" -# This module has been generated using pyabigen v0.2.12 +# This module has been generated using pyabigen v0.2.15 import enum import typing @@ -11,11 +11,11 @@ import web3 from web3.contract import contract -__version__ = "v1.0.2-alpha" +__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" class ValidatorState(enum.IntEnum): - """Port of `enum ValidatorState` on the Autonity contract.""" + """Port of `enum ValidatorState` on the IAutonity contract.""" ACTIVE = 0 PAUSED = 1 @@ -27,7 +27,7 @@ class ValidatorState(enum.IntEnum): @dataclass class Validator: - """Port of `struct Validator` on the Autonity contract.""" + """Port of `struct Validator` on the IAutonity contract.""" treasury: eth_typing.ChecksumAddress node_address: eth_typing.ChecksumAddress @@ -48,11 +48,12 @@ class Validator: jail_release_block: int consensus_key: hexbytes.HexBytes state: ValidatorState + conversion_ratio: int @dataclass class Policy: - """Port of `struct Policy` on the Autonity contract.""" + """Port of `struct Policy` on the IAutonity contract.""" treasury_fee: int min_base_fee: int @@ -64,11 +65,13 @@ class Policy: oracle_reward_rate: int withheld_rewards_pool: eth_typing.ChecksumAddress treasury_account: eth_typing.ChecksumAddress + base_fee_change_denominator: int + elasticity_multiplier: int @dataclass class Contracts: - """Port of `struct Contracts` on the Autonity contract.""" + """Port of `struct Contracts` on the IAutonity contract.""" accountability_contract: eth_typing.ChecksumAddress oracle_contract: eth_typing.ChecksumAddress @@ -78,22 +81,25 @@ class Contracts: upgrade_manager_contract: eth_typing.ChecksumAddress inflation_controller_contract: eth_typing.ChecksumAddress omission_accountability_contract: eth_typing.ChecksumAddress + auctioneer_contract: eth_typing.ChecksumAddress @dataclass class Protocol: - """Port of `struct Protocol` on the Autonity contract.""" + """Port of `struct Protocol` on the IAutonity contract.""" operator_account: eth_typing.ChecksumAddress epoch_period: int block_period: int committee_size: int max_schedule_duration: int + gas_limit: int + gas_limit_bound_divisor: int @dataclass class Config: - """Port of `struct Config` on the Autonity contract.""" + """Port of `struct Config` on the IAutonity contract.""" policy: Policy contracts: Contracts @@ -101,9 +107,49 @@ class Config: contract_version: int +@dataclass +class BondingRequest: + """Port of `struct BondingRequest` on the IAutonity contract.""" + + delegator: eth_typing.ChecksumAddress + delegatee: eth_typing.ChecksumAddress + amount: int + request_block: int + + +@dataclass +class Accountability: + """Port of `struct Accountability` on the IAutonity contract.""" + + range: int + delta: int + grace_period: int + + +@dataclass +class Eip1559: + """Port of `struct Eip1559` on the IAutonity contract.""" + + min_base_fee: int + base_fee_change_denominator: int + elasticity_multiplier: int + gas_limit_bound_divisor: int + + +@dataclass +class ClientAwareConfig: + """Port of `struct ClientAwareConfig` on the IAutonity contract.""" + + epoch_period: int + block_period: int + gas_limit: int + accountability: Accountability + eip1559: Eip1559 + + @dataclass class CommitteeMember: - """Port of `struct CommitteeMember` on the Autonity contract.""" + """Port of `struct CommitteeMember` on the IAutonity contract.""" addr: eth_typing.ChecksumAddress voting_power: int @@ -112,18 +158,19 @@ class CommitteeMember: @dataclass class EpochInfo: - """Port of `struct EpochInfo` on the Autonity contract.""" + """Port of `struct EpochInfo` on the IAutonity contract.""" committee: typing.List[CommitteeMember] previous_epoch_block: int epoch_block: int next_epoch_block: int - delta: int + omission_delta: int + eip1559: Eip1559 @dataclass class Schedule: - """Port of `struct Schedule` on the ScheduleController contract.""" + """Port of `struct Schedule` on the IScheduleController contract.""" total_amount: int unlocked_amount: int @@ -132,6 +179,20 @@ class Schedule: last_unlock_time: int +@dataclass +class UnbondingRequest: + """Port of `struct UnbondingRequest` on the IAutonity contract.""" + + delegator: eth_typing.ChecksumAddress + delegatee: eth_typing.ChecksumAddress + amount: int + unbonding_share: int + request_block: int + unlocked: bool + released: bool + self_delegation: bool + + class Autonity: """Autonity contract binding. @@ -156,7 +217,11 @@ def __init__( @property def ActivatedValidator(self) -> contract.ContractEvent: - """Binding for `event ActivatedValidator` on the Autonity contract.""" + """Binding for `event ActivatedValidator` on the Autonity contract. + + emitted when a validator is activated, validator starts accepting delegation and + becomes eligible for committee inclusion + """ return self._contract.events.ActivatedValidator @property @@ -166,7 +231,11 @@ def Approval(self) -> contract.ContractEvent: @property def BondingRejected(self) -> contract.ContractEvent: - """Binding for `event BondingRejected` on the Autonity contract.""" + """Binding for `event BondingRejected` on the Autonity contract. + + This event is emitted when a registered bonding request to a validator is + rejected + """ return self._contract.events.BondingRejected @property @@ -185,18 +254,68 @@ def CallFailed(self) -> contract.ContractEvent: @property def CommissionRateChange(self) -> contract.ContractEvent: - """Binding for `event CommissionRateChange` on the Autonity contract.""" + """Binding for `event CommissionRateChange` on the Autonity contract. + + Emitted after registering a commission rate change request has been submitted + for the validator + """ return self._contract.events.CommissionRateChange @property - def EpochPeriodUpdated(self) -> contract.ContractEvent: - """Binding for `event EpochPeriodUpdated` on the Autonity contract.""" - return self._contract.events.EpochPeriodUpdated + def ConfigUpdateAddress(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateAddress` on the Autonity contract. + + Emitted after updating config parameter of type address + """ + return self._contract.events.ConfigUpdateAddress + + @property + def ConfigUpdateBool(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateBool` on the Autonity contract. + + Emitted after updating config parameter of type boolean + """ + return self._contract.events.ConfigUpdateBool + + @property + def ConfigUpdateInt(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateInt` on the Autonity contract. + + Emitted after updating config parameter of type int + """ + return self._contract.events.ConfigUpdateInt + + @property + def ConfigUpdateUint(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateUint` on the Autonity contract. + + Emitted after updating config parameter of type uint + """ + return self._contract.events.ConfigUpdateUint + + @property + def Eip1559ParamsUpdate(self) -> contract.ContractEvent: + """Binding for `event Eip1559ParamsUpdate` on the Autonity contract. + + Event emitted after EIP-1559 parameters are updated + """ + return self._contract.events.Eip1559ParamsUpdate + + @property + def EnodeUpdate(self) -> contract.ContractEvent: + """Binding for `event EnodeUpdate` on the Autonity contract. + + Emitted after updating a enode address of a validator + """ + return self._contract.events.EnodeUpdate @property - def MinimumBaseFeeUpdated(self) -> contract.ContractEvent: - """Binding for `event MinimumBaseFeeUpdated` on the Autonity contract.""" - return self._contract.events.MinimumBaseFeeUpdated + def EpochPeriodUpdated(self) -> contract.ContractEvent: + """Binding for `event EpochPeriodUpdated` on the Autonity contract. + + emitted when epoch period is updated + """ + return self._contract.events.EpochPeriodUpdated @property def MintedStake(self) -> contract.ContractEvent: @@ -216,7 +335,10 @@ def NewBondingRequest(self) -> contract.ContractEvent: @property def NewEpoch(self) -> contract.ContractEvent: - """Binding for `event NewEpoch` on the Autonity contract.""" + """Binding for `event NewEpoch` on the Autonity contract. + + emitted when a newEpoch begins + """ return self._contract.events.NewEpoch @property @@ -238,17 +360,28 @@ def NewUnbondingRequest(self) -> contract.ContractEvent: @property def PausedValidator(self) -> contract.ContractEvent: - """Binding for `event PausedValidator` on the Autonity contract.""" + """Binding for `event PausedValidator` on the Autonity contract. + + emitted when a validator is paused, validator stops accepting delegation and + becomes ineligible for committee inclusion + """ return self._contract.events.PausedValidator @property def RegisteredValidator(self) -> contract.ContractEvent: - """Binding for `event RegisteredValidator` on the Autonity contract.""" + """Binding for `event RegisteredValidator` on the Autonity contract. + + emitted when a new validator is registered + """ return self._contract.events.RegisteredValidator @property def Rewarded(self) -> contract.ContractEvent: - """Binding for `event Rewarded` on the Autonity contract.""" + """Binding for `event Rewarded` on the Autonity contract. + + emitted when a validator is rewarded for taking part in block consensus for + committee inclusion + """ return self._contract.events.Rewarded @property @@ -280,27 +413,6 @@ def standard_scale_factor( return_value = self._contract.functions.STANDARD_SCALE_FACTOR().call() return int(return_value) - def set_liquid_logic_contract( - self, - _contract: eth_typing.ChecksumAddress, - ) -> contract.ContractFunction: - """Binding for `SetLiquidLogicContract` on the Autonity contract. - - Set address of the liquid logic contact. - - Parameters - ---------- - _contract : eth_typing.ChecksumAddress - - Returns - ------- - web3.contract.contract.ContractFunction - A contract function instance to be sent in a transaction. - """ - return self._contract.functions.SetLiquidLogicContract( - _contract, - ) - def activate_validator( self, _address: eth_typing.ChecksumAddress, @@ -498,49 +610,6 @@ def complete_contract_upgrade( """ 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]), - int(return_value[0][5]), - int(return_value[0][6]), - int(return_value[0][7]), - eth_typing.ChecksumAddress(return_value[0][8]), - eth_typing.ChecksumAddress(return_value[0][9]), - ), - 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[2][4]), - ), - int(return_value[3]), - ) - def create_schedule( self, _schedule_vault: eth_typing.ChecksumAddress, @@ -585,55 +654,74 @@ def decimals( 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( + def get_block_period( self, ) -> int: - """Binding for `epochID` on the Autonity contract. + """Binding for `getBlockPeriod` on the Autonity contract. + + Returns the block period. Returns ------- int """ - return_value = self._contract.functions.epochID().call() + return_value = self._contract.functions.getBlockPeriod().call() return int(return_value) - def epoch_total_bonded_stake( + def get_bonding_request_by_id( self, - ) -> int: - """Binding for `epochTotalBondedStake` on the Autonity contract. + _id: int, + ) -> BondingRequest: + """Binding for `getBondingRequestByID` on the Autonity contract. + + Returns the bonding request corresponding to bonding ID. + + Parameters + ---------- + _id : int Returns ------- - int + BondingRequest """ - return_value = self._contract.functions.epochTotalBondedStake().call() - return int(return_value) + return_value = self._contract.functions.getBondingRequestByID( + _id, + ).call() + return BondingRequest( + eth_typing.ChecksumAddress(return_value[0]), + eth_typing.ChecksumAddress(return_value[1]), + int(return_value[2]), + int(return_value[3]), + ) - def get_block_period( + def get_client_config( self, - ) -> int: - """Binding for `getBlockPeriod` on the Autonity contract. + ) -> ClientAwareConfig: + """Binding for `getClientConfig` on the Autonity contract. - Returns the block period. + Returns the current client aware config Returns ------- - int + ClientAwareConfig """ - return_value = self._contract.functions.getBlockPeriod().call() - return int(return_value) + return_value = self._contract.functions.getClientConfig().call() + return ClientAwareConfig( + int(return_value[0]), + int(return_value[1]), + int(return_value[2]), + Accountability( + int(return_value[3][0]), + int(return_value[3][1]), + int(return_value[3][2]), + ), + Eip1559( + int(return_value[4][0]), + int(return_value[4][1]), + int(return_value[4][2]), + int(return_value[4][3]), + ), + ) def get_committee( self, @@ -645,8 +733,6 @@ def get_committee( Returns ------- typing.List[CommitteeMember] - Current block committee if called before finalize(), next block committee if - called after. """ return_value = self._contract.functions.getCommittee().call() return [ @@ -663,14 +749,79 @@ def get_committee_enodes( ) -> typing.List[str]: """Binding for `getCommitteeEnodes` on the Autonity contract. + Returns the consensus committee enodes. + Returns ------- typing.List[str] - Returns the consensus committee enodes. """ return_value = self._contract.functions.getCommitteeEnodes().call() return [str(return_value_elem) for return_value_elem in return_value] + def get_config( + self, + ) -> Config: + """Binding for `getConfig` on the Autonity contract. + + Returns the current contract config + + Returns + ------- + Config + """ + return_value = self._contract.functions.getConfig().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]), + int(return_value[0][5]), + int(return_value[0][6]), + int(return_value[0][7]), + eth_typing.ChecksumAddress(return_value[0][8]), + eth_typing.ChecksumAddress(return_value[0][9]), + int(return_value[0][10]), + int(return_value[0][11]), + ), + 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]), + eth_typing.ChecksumAddress(return_value[1][8]), + ), + 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[2][4]), + int(return_value[2][5]), + int(return_value[2][6]), + ), + int(return_value[3]), + ) + + def get_current_committee_size( + self, + ) -> int: + """Binding for `getCurrentCommitteeSize` on the Autonity contract. + + Returns the current size of the consensus committee. + + Returns + ------- + int + """ + return_value = self._contract.functions.getCurrentCommitteeSize().call() + return int(return_value) + def get_current_epoch_period( self, ) -> int: @@ -717,6 +868,12 @@ def get_epoch_by_height( int(return_value[2]), int(return_value[3]), int(return_value[4]), + Eip1559( + int(return_value[5][0]), + int(return_value[5][1]), + int(return_value[5][2]), + int(return_value[5][3]), + ), ) def get_epoch_from_block( @@ -741,6 +898,20 @@ def get_epoch_from_block( ).call() return int(return_value) + def get_epoch_id( + self, + ) -> int: + """Binding for `getEpochID` on the Autonity contract. + + Returns the current epoch ID + + Returns + ------- + int + """ + return_value = self._contract.functions.getEpochID().call() + return int(return_value) + def get_epoch_info( self, ) -> EpochInfo: @@ -766,6 +937,12 @@ def get_epoch_info( int(return_value[2]), int(return_value[3]), int(return_value[4]), + Eip1559( + int(return_value[5][0]), + int(return_value[5][1]), + int(return_value[5][2]), + int(return_value[5][3]), + ), ) def get_epoch_period( @@ -773,8 +950,8 @@ def get_epoch_period( ) -> int: """Binding for `getEpochPeriod` on the Autonity contract. - /**Returns the epoch period. If there will be an update at epoch end, the new - epoch period is returned + Returns the epoch period. If there will be an update at epoch end, the new epoch + period is returned Returns ------- @@ -783,64 +960,122 @@ def get_epoch_period( return_value = self._contract.functions.getEpochPeriod().call() return int(return_value) - def get_last_epoch_block( + def get_epoch_total_bonded_stake( self, ) -> int: - """Binding for `getLastEpochBlock` on the Autonity contract. + """Binding for `getEpochTotalBondedStake` on the Autonity contract. - Returns the last epoch's end block height. + Returns the current epoch total bonded stake Returns ------- int """ - return_value = self._contract.functions.getLastEpochBlock().call() + return_value = self._contract.functions.getEpochTotalBondedStake().call() return int(return_value) - def get_max_committee_size( + def get_inflation_reserve( self, ) -> int: - """Binding for `getMaxCommitteeSize` on the Autonity contract. + """Binding for `getInflationReserve` on the Autonity contract. + + Returns the current inflation reserve Returns ------- int - Returns the maximum size of the consensus committee. """ - return_value = self._contract.functions.getMaxCommitteeSize().call() + return_value = self._contract.functions.getInflationReserve().call() return int(return_value) - def get_max_schedule_duration( + def get_last_epoch_block( self, ) -> int: - """Binding for `getMaxScheduleDuration` on the Autonity contract. + """Binding for `getLastEpochBlock` on the Autonity contract. - Returns the max allowed duration of any schedule or contract. + Returns the last epoch's end block height. Returns ------- int """ - return_value = self._contract.functions.getMaxScheduleDuration().call() + return_value = self._contract.functions.getLastEpochBlock().call() return int(return_value) - def get_minimum_base_fee( + def get_last_epoch_time( self, ) -> int: - """Binding for `getMinimumBaseFee` on the Autonity contract. + """Binding for `getLastEpochTime` on the Autonity contract. + + Returns the last epoch's end block timestamp Returns ------- int - Returns the minimum gas price. """ - return_value = self._contract.functions.getMinimumBaseFee().call() + return_value = self._contract.functions.getLastEpochTime().call() return int(return_value) - def get_new_contract( + def get_liquid_logic_contract( self, - ) -> typing.Tuple[hexbytes.HexBytes, str]: - """Binding for `getNewContract` on the Autonity contract. + ) -> eth_typing.ChecksumAddress: + """Binding for `getLiquidLogicContract` on the Autonity contract. + + Returns the liquid logic contract + + Returns + ------- + eth_typing.ChecksumAddress + """ + return_value = self._contract.functions.getLiquidLogicContract().call() + return eth_typing.ChecksumAddress(return_value) + + def get_max_committee_size( + self, + ) -> int: + """Binding for `getMaxCommitteeSize` on the Autonity contract. + + Returns the maximum size of the consensus committee. + + Returns + ------- + int + """ + return_value = self._contract.functions.getMaxCommitteeSize().call() + return int(return_value) + + def get_max_schedule_duration( + self, + ) -> int: + """Binding for `getMaxScheduleDuration` on the Autonity contract. + + Returns the max allowed duration of any schedule or contract. + + Returns + ------- + int + """ + return_value = self._contract.functions.getMaxScheduleDuration().call() + return int(return_value) + + def get_minimum_base_fee( + self, + ) -> int: + """Binding for `getMinimumBaseFee` on the Autonity contract. + + Returns the minimum gas price. + + Returns + ------- + int + """ + 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. @@ -932,6 +1167,20 @@ def get_schedule( int(return_value[4]), ) + def get_slasher( + self, + ) -> eth_typing.ChecksumAddress: + """Binding for `getSlasher` on the Autonity contract. + + Returns the slasher contract address + + Returns + ------- + eth_typing.ChecksumAddress + """ + return_value = self._contract.functions.getSlasher().call() + return eth_typing.ChecksumAddress(return_value) + def get_total_schedules( self, _vault: eth_typing.ChecksumAddress, @@ -996,12 +1245,44 @@ def get_unbonding_period( return_value = self._contract.functions.getUnbondingPeriod().call() return int(return_value) + def get_unbonding_request_by_id( + self, + _id: int, + ) -> UnbondingRequest: + """Binding for `getUnbondingRequestByID` on the Autonity contract. + + Returns the unbonding request corresponding to unbonding ID. + + Parameters + ---------- + _id : int + + Returns + ------- + UnbondingRequest + """ + return_value = self._contract.functions.getUnbondingRequestByID( + _id, + ).call() + return UnbondingRequest( + eth_typing.ChecksumAddress(return_value[0]), + eth_typing.ChecksumAddress(return_value[1]), + int(return_value[2]), + int(return_value[3]), + int(return_value[4]), + bool(return_value[5]), + bool(return_value[6]), + bool(return_value[7]), + ) + def get_unbonding_share( self, _unbonding_id: int, ) -> int: """Binding for `getUnbondingShare` on the Autonity contract. + Returns the unbonding share after the unbonding request is applied at epoch end. + Parameters ---------- _unbonding_id : int @@ -1021,6 +1302,8 @@ def get_validator( ) -> Validator: """Binding for `getValidator` on the Autonity contract. + Returns the validator object associated with `_addr`. + Parameters ---------- _addr : eth_typing.ChecksumAddress @@ -1028,7 +1311,6 @@ def get_validator( Returns ------- Validator - Returns the validator object associated with `_addr`. """ return_value = self._contract.functions.getValidator( _addr, @@ -1053,6 +1335,7 @@ def get_validator( int(return_value[16]), hexbytes.HexBytes(return_value[17]), ValidatorState(return_value[18]), + int(return_value[19]), ) def get_validator_state( @@ -1061,6 +1344,8 @@ def get_validator_state( ) -> ValidatorState: """Binding for `getValidatorState` on the Autonity contract. + Returns the state of the validator associated with `_addr`. + Parameters ---------- _addr : eth_typing.ChecksumAddress @@ -1068,7 +1353,6 @@ def get_validator_state( Returns ------- ValidatorState - Returns the state of the validator associated with `_addr`. """ return_value = self._contract.functions.getValidatorState( _addr, @@ -1106,18 +1390,6 @@ def get_version( 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 is_unbonding_released( self, _unbonding_id: int, @@ -1139,49 +1411,6 @@ def is_unbonding_released( ).call() return bool(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 last_finalized_block( - self, - ) -> int: - """Binding for `lastFinalizedBlock` on the Autonity contract. - - Returns - ------- - int - """ - return_value = self._contract.functions.lastFinalizedBlock().call() - return int(return_value) - - def liquid_logic_contract( - self, - ) -> eth_typing.ChecksumAddress: - """Binding for `liquidLogicContract` on the Autonity contract. - - Address of the `LiquidLogic` contract. This contract contains all the logic for - liquid newton related operations. The state variables are stored in - `LiquidState` contract which is different for every validator and is deployed - when registering a new validator. To do any operation related to liquid newton, - we call `LiquidState` contract of the related validator and that contract does a - delegate call to `LiquidLogic` contract. - - Returns - ------- - eth_typing.ChecksumAddress - """ - return_value = self._contract.functions.liquidLogicContract().call() - return eth_typing.ChecksumAddress(return_value) - def mint( self, _addr: eth_typing.ChecksumAddress, @@ -1217,18 +1446,6 @@ def name( return_value = self._contract.functions.name().call() return str(return_value) - def new_epoch_period( - self, - ) -> int: - """Binding for `newEpochPeriod` on the Autonity contract. - - Returns - ------- - int - """ - return_value = self._contract.functions.newEpochPeriod().call() - return int(return_value) - def pause_validator( self, _address: eth_typing.ChecksumAddress, @@ -1341,6 +1558,25 @@ def set_acu_contract( _address, ) + def set_auctioneer_contract( + self, + _address: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `setAuctioneerContract` 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.setAuctioneerContract( + _address, + ) + def set_committee_size( self, _size: int, @@ -1360,6 +1596,35 @@ def set_committee_size( _size, ) + def set_eip1559_params( + self, + _params: Eip1559, + ) -> contract.ContractFunction: + """Binding for `setEip1559Params` on the Autonity contract. + + Set the eip1559 parameters for the next epoch. Restricted to the operator + account. + + Parameters + ---------- + _params : Eip1559 + , eip1559 parameters: minBaseFee, gasLimitBoundDivisor, elasticityMultiplier + and baseFeeChangeDenominator + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setEip1559Params( + ( + _params.min_base_fee, + _params.base_fee_change_denominator, + _params.elasticity_multiplier, + _params.gas_limit_bound_divisor, + ), + ) + def set_epoch_period( self, _period: int, @@ -1379,6 +1644,27 @@ def set_epoch_period( _period, ) + def set_gas_limit( + self, + _gas_limit: int, + ) -> contract.ContractFunction: + """Binding for `setGasLimit` on the Autonity contract. + + Sets the gas limit. Restricted to the operator account. + + Parameters + ---------- + _gas_limit : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setGasLimit( + _gas_limit, + ) + def set_inflation_controller_contract( self, _address: eth_typing.ChecksumAddress, @@ -1398,47 +1684,46 @@ def set_inflation_controller_contract( _address, ) - def set_max_schedule_duration( + def set_liquid_logic_contract( self, - _new_max_duration: int, + _contract: eth_typing.ChecksumAddress, ) -> contract.ContractFunction: - """Binding for `setMaxScheduleDuration` on the Autonity contract. + """Binding for `setLiquidLogicContract` on the Autonity contract. - Sets the max allowed duration of any schedule or contract. + Set address of the liquid logic contact. Parameters ---------- - _new_max_duration : int + _contract : eth_typing.ChecksumAddress Returns ------- web3.contract.contract.ContractFunction A contract function instance to be sent in a transaction. """ - return self._contract.functions.setMaxScheduleDuration( - _new_max_duration, + return self._contract.functions.setLiquidLogicContract( + _contract, ) - def set_minimum_base_fee( + def set_max_schedule_duration( self, - _price: int, + _new_max_duration: int, ) -> contract.ContractFunction: - """Binding for `setMinimumBaseFee` on the Autonity contract. + """Binding for `setMaxScheduleDuration` on the Autonity contract. - Set the minimum gas price. Restricted to the operator account. + Sets the max allowed duration of any schedule or contract. Parameters ---------- - _price : int - Positive integer. + _new_max_duration : int Returns ------- web3.contract.contract.ContractFunction A contract function instance to be sent in a transaction. """ - return self._contract.functions.setMinimumBaseFee( - _price, + return self._contract.functions.setMaxScheduleDuration( + _new_max_duration, ) def set_omission_accountability_contract( @@ -1719,18 +2004,6 @@ def set_withholding_threshold( _withholding_threshold, ) - def slasher( - self, - ) -> eth_typing.ChecksumAddress: - """Binding for `slasher` on the Autonity contract. - - Returns - ------- - eth_typing.ChecksumAddress - """ - return_value = self._contract.functions.slasher().call() - return eth_typing.ChecksumAddress(return_value) - def symbol( self, ) -> str: @@ -1983,12 +2256,17 @@ def upgrade_contract( "type": "bytes", }, { - "internalType": "enum ValidatorState", + "internalType": "enum IAutonity.ValidatorState", "name": "state", "type": "uint8", }, + { + "internalType": "uint256", + "name": "conversionRatio", + "type": "uint256", + }, ], - "internalType": "struct Autonity.Validator[]", + "internalType": "struct IAutonity.Validator[]", "name": "_validators", "type": "tuple[]", }, @@ -2046,8 +2324,18 @@ def upgrade_contract( "name": "treasuryAccount", "type": "address", }, + { + "internalType": "uint256", + "name": "baseFeeChangeDenominator", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "elasticityMultiplier", + "type": "uint256", + }, ], - "internalType": "struct Autonity.Policy", + "internalType": "struct IAutonity.Policy", "name": "policy", "type": "tuple", }, @@ -2079,7 +2367,7 @@ def upgrade_contract( "type": "address", }, { - "internalType": "contract UpgradeManager", + "internalType": "contract IUpgradeManager", "name": "upgradeManagerContract", "type": "address", }, @@ -2093,8 +2381,13 @@ def upgrade_contract( "name": "omissionAccountabilityContract", "type": "address", }, + { + "internalType": "contract IAuctioneer", + "name": "auctioneerContract", + "type": "address", + }, ], - "internalType": "struct Autonity.Contracts", + "internalType": "struct IAutonity.Contracts", "name": "contracts", "type": "tuple", }, @@ -2125,8 +2418,18 @@ def upgrade_contract( "name": "maxScheduleDuration", "type": "uint256", }, + { + "internalType": "uint256", + "name": "gasLimit", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "gasLimitBoundDivisor", + "type": "uint256", + }, ], - "internalType": "struct Autonity.Protocol", + "internalType": "struct IAutonity.Protocol", "name": "protocol", "type": "tuple", }, @@ -2136,7 +2439,7 @@ def upgrade_contract( "type": "uint256", }, ], - "internalType": "struct Autonity.Config", + "internalType": "struct IAutonity.Config", "name": "_config", "type": "tuple", }, @@ -2217,7 +2520,7 @@ def upgrade_contract( }, { "indexed": False, - "internalType": "enum ValidatorState", + "internalType": "enum IAutonity.ValidatorState", "name": "state", "type": "uint8", }, @@ -2293,40 +2596,239 @@ def upgrade_contract( "inputs": [ { "indexed": False, - "internalType": "uint256", - "name": "period", - "type": "uint256", + "internalType": "string", + "name": "name", + "type": "string", }, { "indexed": False, - "internalType": "uint256", - "name": "appliedAtBlock", - "type": "uint256", + "internalType": "address", + "name": "oldValue", + "type": "address", + }, + { + "indexed": False, + "internalType": "address", + "name": "newValue", + "type": "address", }, - ], - "name": "EpochPeriodUpdated", - "type": "event", - }, - { - "anonymous": False, - "inputs": [ { "indexed": False, "internalType": "uint256", - "name": "gasPrice", + "name": "appliesAtHeight", "type": "uint256", - } + }, ], - "name": "MinimumBaseFeeUpdated", + "name": "ConfigUpdateAddress", "type": "event", }, { "anonymous": False, "inputs": [ { - "indexed": True, - "internalType": "address", - "name": "addr", + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "bool", + "name": "oldValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "bool", + "name": "newValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateBool", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "int256", + "name": "oldValue", + "type": "int256", + }, + { + "indexed": False, + "internalType": "int256", + "name": "newValue", + "type": "int256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateInt", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "oldValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "newValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateUint", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "minBaseFee", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "baseFeeChangeDenominator", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "elasticityMultiplier", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "gasLimitBoundDivisor", + "type": "uint256", + }, + ], + "indexed": False, + "internalType": "struct IAutonity.Eip1559", + "name": "oldParams", + "type": "tuple", + }, + { + "components": [ + { + "internalType": "uint256", + "name": "minBaseFee", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "baseFeeChangeDenominator", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "elasticityMultiplier", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "gasLimitBoundDivisor", + "type": "uint256", + }, + ], + "indexed": False, + "internalType": "struct IAutonity.Eip1559", + "name": "newParams", + "type": "tuple", + }, + ], + "name": "Eip1559ParamsUpdate", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "address", + "name": "validator", + "type": "address", + }, + { + "indexed": False, + "internalType": "string", + "name": "oldEnode", + "type": "string", + }, + { + "indexed": False, + "internalType": "string", + "name": "newEnode", + "type": "string", + }, + ], + "name": "EnodeUpdate", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "period", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliedAtBlock", + "type": "uint256", + }, + ], + "name": "EpochPeriodUpdated", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "addr", "type": "address", }, { @@ -2366,6 +2868,12 @@ def upgrade_contract( "name": "amount", "type": "uint256", }, + { + "indexed": False, + "internalType": "uint256", + "name": "headBondingID", + "type": "uint256", + }, ], "name": "NewBondingRequest", "type": "event", @@ -2378,7 +2886,19 @@ def upgrade_contract( "internalType": "uint256", "name": "epoch", "type": "uint256", - } + }, + { + "indexed": False, + "internalType": "uint256", + "name": "inflationReserve", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "stakeCirculating", + "type": "uint256", + }, ], "name": "NewEpoch", "type": "event", @@ -2441,6 +2961,12 @@ def upgrade_contract( "name": "amount", "type": "uint256", }, + { + "indexed": False, + "internalType": "uint256", + "name": "headUnbondingID", + "type": "uint256", + }, ], "name": "NewUnbondingRequest", "type": "event", @@ -2519,13 +3045,25 @@ def upgrade_contract( { "indexed": False, "internalType": "uint256", - "name": "atnAmount", + "name": "atnSelfAmount", "type": "uint256", }, { "indexed": False, "internalType": "uint256", - "name": "ntnAmount", + "name": "atnDelegatedAmount", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "ntnSelfAmount", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "ntnDelegatedAmount", "type": "uint256", }, ], @@ -2572,15 +3110,6 @@ def upgrade_contract( "stateMutability": "view", "type": "function", }, - { - "inputs": [ - {"internalType": "address", "name": "_contract", "type": "address"} - ], - "name": "SetLiquidLogicContract", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function", - }, { "inputs": [ {"internalType": "address", "name": "_address", "type": "address"} @@ -2673,131 +3202,257 @@ def upgrade_contract( "type": "function", }, { - "inputs": [], - "name": "computeCommittee", - "outputs": [ - {"internalType": "address[]", "name": "", "type": "address[]"}, - {"internalType": "address[]", "name": "", "type": "address[]"}, - {"internalType": "address[]", "name": "", "type": "address[]"}, + "inputs": [ + { + "internalType": "address", + "name": "_scheduleVault", + "type": "address", + }, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + {"internalType": "uint256", "name": "_startTime", "type": "uint256"}, + { + "internalType": "uint256", + "name": "_totalDuration", + "type": "uint256", + }, ], + "name": "createSchedule", + "outputs": [], "stateMutability": "nonpayable", "type": "function", }, { "inputs": [], - "name": "config", + "name": "decimals", + "outputs": [{"internalType": "uint8", "name": "", "type": "uint8"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [], + "name": "finalize", "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": "bool", + "name": "contractUpgradeReady", + "type": "bool", }, + {"internalType": "bool", "name": "epochEnded", "type": "bool"}, { - "internalType": "uint256", - "name": "withholdingThreshold", - "type": "uint256", - }, - { - "internalType": "uint256", - "name": "proposerRewardRate", - "type": "uint256", - }, - { - "internalType": "uint256", - "name": "oracleRewardRate", - "type": "uint256", - }, - { - "internalType": "address payable", - "name": "withheldRewardsPool", - "type": "address", + "components": [ + { + "components": [ + { + "internalType": "address", + "name": "addr", + "type": "address", + }, + { + "internalType": "uint256", + "name": "votingPower", + "type": "uint256", + }, + { + "internalType": "bytes", + "name": "consensusKey", + "type": "bytes", + }, + ], + "internalType": "struct IAutonity.CommitteeMember[]", + "name": "committee", + "type": "tuple[]", + }, + { + "internalType": "uint256", + "name": "previousEpochBlock", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "epochBlock", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "nextEpochBlock", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "omissionDelta", + "type": "uint256", + }, + { + "components": [ + { + "internalType": "uint256", + "name": "minBaseFee", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "baseFeeChangeDenominator", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "elasticityMultiplier", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "gasLimitBoundDivisor", + "type": "uint256", + }, + ], + "internalType": "struct IAutonity.Eip1559", + "name": "eip1559", + "type": "tuple", + }, + ], + "internalType": "struct IAutonity.EpochInfo", + "name": "epoch", + "type": "tuple", }, { - "internalType": "address payable", - "name": "treasuryAccount", - "type": "address", + "components": [ + { + "internalType": "uint256", + "name": "epochPeriod", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "blockPeriod", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "gasLimit", + "type": "uint256", + }, + { + "components": [ + { + "internalType": "uint256", + "name": "range", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "delta", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "gracePeriod", + "type": "uint256", + }, + ], + "internalType": "struct IAutonity.Accountability", + "name": "accountability", + "type": "tuple", + }, + { + "components": [ + { + "internalType": "uint256", + "name": "minBaseFee", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "baseFeeChangeDenominator", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "elasticityMultiplier", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "gasLimitBoundDivisor", + "type": "uint256", + }, + ], + "internalType": "struct IAutonity.Eip1559", + "name": "eip1559", + "type": "tuple", + }, + ], + "internalType": "struct IAutonity.ClientAwareConfig", + "name": "config", + "type": "tuple", }, ], - "internalType": "struct Autonity.Policy", - "name": "policy", + "internalType": "struct Autonity.FinalizeResult", + "name": "", "type": "tuple", - }, + } + ], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "_omissionDelta", "type": "uint256"} + ], + "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": "getBondingRequestByID", + "outputs": [ { "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", + "internalType": "address payable", + "name": "delegator", "type": "address", }, { - "internalType": "contract UpgradeManager", - "name": "upgradeManagerContract", + "internalType": "address", + "name": "delegatee", "type": "address", }, { - "internalType": "contract IInflationController", - "name": "inflationControllerContract", - "type": "address", + "internalType": "uint256", + "name": "amount", + "type": "uint256", }, { - "internalType": "contract IOmissionAccountability", - "name": "omissionAccountabilityContract", - "type": "address", + "internalType": "uint256", + "name": "requestBlock", + "type": "uint256", }, ], - "internalType": "struct Autonity.Contracts", - "name": "contracts", + "internalType": "struct IAutonity.BondingRequest", + "name": "", "type": "tuple", - }, + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getClientConfig", + "outputs": [ { "components": [ - { - "internalType": "address", - "name": "operatorAccount", - "type": "address", - }, { "internalType": "uint256", "name": "epochPeriod", @@ -2810,82 +3465,71 @@ def upgrade_contract( }, { "internalType": "uint256", - "name": "committeeSize", + "name": "gasLimit", "type": "uint256", }, { - "internalType": "uint256", - "name": "maxScheduleDuration", - "type": "uint256", + "components": [ + { + "internalType": "uint256", + "name": "range", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "delta", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "gracePeriod", + "type": "uint256", + }, + ], + "internalType": "struct IAutonity.Accountability", + "name": "accountability", + "type": "tuple", + }, + { + "components": [ + { + "internalType": "uint256", + "name": "minBaseFee", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "baseFeeChangeDenominator", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "elasticityMultiplier", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "gasLimitBoundDivisor", + "type": "uint256", + }, + ], + "internalType": "struct IAutonity.Eip1559", + "name": "eip1559", + "type": "tuple", }, ], - "internalType": "struct Autonity.Protocol", - "name": "protocol", + "internalType": "struct IAutonity.ClientAwareConfig", + "name": "", "type": "tuple", - }, - { - "internalType": "uint256", - "name": "contractVersion", - "type": "uint256", - }, + } ], "stateMutability": "view", "type": "function", }, - { - "inputs": [ - { - "internalType": "address", - "name": "_scheduleVault", - "type": "address", - }, - {"internalType": "uint256", "name": "_amount", "type": "uint256"}, - {"internalType": "uint256", "name": "_startTime", "type": "uint256"}, - { - "internalType": "uint256", - "name": "_totalDuration", - "type": "uint256", - }, - ], - "name": "createSchedule", - "outputs": [], - "stateMutability": "nonpayable", - "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": "epochTotalBondedStake", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "stateMutability": "view", - "type": "function", - }, - { - "inputs": [], - "name": "finalize", + "name": "getCommittee", "outputs": [ - {"internalType": "bool", "name": "", "type": "bool"}, - {"internalType": "bool", "name": "", "type": "bool"}, { "components": [ {"internalType": "address", "name": "addr", "type": "address"}, @@ -2900,52 +3544,197 @@ def upgrade_contract( "type": "bytes", }, ], - "internalType": "struct Autonity.CommitteeMember[]", + "internalType": "struct IAutonity.CommitteeMember[]", "name": "", "type": "tuple[]", - }, - {"internalType": "uint256", "name": "", "type": "uint256"}, - {"internalType": "uint256", "name": "", "type": "uint256"}, - {"internalType": "uint256", "name": "", "type": "uint256"}, + } ], - "stateMutability": "nonpayable", - "type": "function", - }, - { - "inputs": [{"internalType": "uint256", "name": "delta", "type": "uint256"}], - "name": "finalizeInitialization", - "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function", }, { "inputs": [], - "name": "getBlockPeriod", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "getCommitteeEnodes", + "outputs": [{"internalType": "string[]", "name": "", "type": "string[]"}], "stateMutability": "view", "type": "function", }, { "inputs": [], - "name": "getCommittee", + "name": "getConfig", "outputs": [ { "components": [ - {"internalType": "address", "name": "addr", "type": "address"}, + { + "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": "uint256", + "name": "withholdingThreshold", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "proposerRewardRate", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "oracleRewardRate", + "type": "uint256", + }, + { + "internalType": "address payable", + "name": "withheldRewardsPool", + "type": "address", + }, + { + "internalType": "address payable", + "name": "treasuryAccount", + "type": "address", + }, + { + "internalType": "uint256", + "name": "baseFeeChangeDenominator", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "elasticityMultiplier", + "type": "uint256", + }, + ], + "internalType": "struct IAutonity.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 IUpgradeManager", + "name": "upgradeManagerContract", + "type": "address", + }, + { + "internalType": "contract IInflationController", + "name": "inflationControllerContract", + "type": "address", + }, + { + "internalType": "contract IOmissionAccountability", + "name": "omissionAccountabilityContract", + "type": "address", + }, + { + "internalType": "contract IAuctioneer", + "name": "auctioneerContract", + "type": "address", + }, + ], + "internalType": "struct IAutonity.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": "uint256", + "name": "maxScheduleDuration", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "gasLimit", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "gasLimitBoundDivisor", + "type": "uint256", + }, + ], + "internalType": "struct IAutonity.Protocol", + "name": "protocol", + "type": "tuple", + }, { "internalType": "uint256", - "name": "votingPower", + "name": "contractVersion", "type": "uint256", }, - { - "internalType": "bytes", - "name": "consensusKey", - "type": "bytes", - }, ], - "internalType": "struct Autonity.CommitteeMember[]", + "internalType": "struct IAutonity.Config", "name": "", - "type": "tuple[]", + "type": "tuple", } ], "stateMutability": "view", @@ -2953,8 +3742,8 @@ def upgrade_contract( }, { "inputs": [], - "name": "getCommitteeEnodes", - "outputs": [{"internalType": "string[]", "name": "", "type": "string[]"}], + "name": "getCurrentCommitteeSize", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, @@ -2991,7 +3780,7 @@ def upgrade_contract( "type": "bytes", }, ], - "internalType": "struct Autonity.CommitteeMember[]", + "internalType": "struct IAutonity.CommitteeMember[]", "name": "committee", "type": "tuple[]", }, @@ -3010,9 +3799,40 @@ def upgrade_contract( "name": "nextEpochBlock", "type": "uint256", }, - {"internalType": "uint256", "name": "delta", "type": "uint256"}, + { + "internalType": "uint256", + "name": "omissionDelta", + "type": "uint256", + }, + { + "components": [ + { + "internalType": "uint256", + "name": "minBaseFee", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "baseFeeChangeDenominator", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "elasticityMultiplier", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "gasLimitBoundDivisor", + "type": "uint256", + }, + ], + "internalType": "struct IAutonity.Eip1559", + "name": "eip1559", + "type": "tuple", + }, ], - "internalType": "struct Autonity.EpochInfo", + "internalType": "struct IAutonity.EpochInfo", "name": "", "type": "tuple", } @@ -3029,6 +3849,13 @@ def upgrade_contract( "stateMutability": "view", "type": "function", }, + { + "inputs": [], + "name": "getEpochID", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, { "inputs": [], "name": "getEpochInfo", @@ -3053,7 +3880,7 @@ def upgrade_contract( "type": "bytes", }, ], - "internalType": "struct Autonity.CommitteeMember[]", + "internalType": "struct IAutonity.CommitteeMember[]", "name": "committee", "type": "tuple[]", }, @@ -3072,9 +3899,40 @@ def upgrade_contract( "name": "nextEpochBlock", "type": "uint256", }, - {"internalType": "uint256", "name": "delta", "type": "uint256"}, + { + "internalType": "uint256", + "name": "omissionDelta", + "type": "uint256", + }, + { + "components": [ + { + "internalType": "uint256", + "name": "minBaseFee", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "baseFeeChangeDenominator", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "elasticityMultiplier", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "gasLimitBoundDivisor", + "type": "uint256", + }, + ], + "internalType": "struct IAutonity.Eip1559", + "name": "eip1559", + "type": "tuple", + }, ], - "internalType": "struct Autonity.EpochInfo", + "internalType": "struct IAutonity.EpochInfo", "name": "", "type": "tuple", } @@ -3089,6 +3947,20 @@ def upgrade_contract( "stateMutability": "view", "type": "function", }, + { + "inputs": [], + "name": "getEpochTotalBondedStake", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getInflationReserve", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, { "inputs": [], "name": "getLastEpochBlock", @@ -3096,6 +3968,20 @@ def upgrade_contract( "stateMutability": "view", "type": "function", }, + { + "inputs": [], + "name": "getLastEpochTime", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getLiquidLogicContract", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, { "inputs": [], "name": "getMaxCommitteeSize", @@ -3179,7 +4065,7 @@ def upgrade_contract( "type": "uint256", }, ], - "internalType": "struct ScheduleController.Schedule", + "internalType": "struct IScheduleController.Schedule", "name": "", "type": "tuple", } @@ -3187,6 +4073,13 @@ def upgrade_contract( "stateMutability": "view", "type": "function", }, + { + "inputs": [], + "name": "getSlasher", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, { "inputs": [ {"internalType": "address", "name": "_vault", "type": "address"} @@ -3217,6 +4110,53 @@ def upgrade_contract( "stateMutability": "view", "type": "function", }, + { + "inputs": [{"internalType": "uint256", "name": "_id", "type": "uint256"}], + "name": "getUnbondingRequestByID", + "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": "bool", "name": "unlocked", "type": "bool"}, + {"internalType": "bool", "name": "released", "type": "bool"}, + { + "internalType": "bool", + "name": "selfDelegation", + "type": "bool", + }, + ], + "internalType": "struct IAutonity.UnbondingRequest", + "name": "", + "type": "tuple", + } + ], + "stateMutability": "view", + "type": "function", + }, { "inputs": [ {"internalType": "uint256", "name": "_unbondingID", "type": "uint256"} @@ -3319,12 +4259,17 @@ def upgrade_contract( "type": "bytes", }, { - "internalType": "enum ValidatorState", + "internalType": "enum IAutonity.ValidatorState", "name": "state", "type": "uint8", }, + { + "internalType": "uint256", + "name": "conversionRatio", + "type": "uint256", + }, ], - "internalType": "struct Autonity.Validator", + "internalType": "struct IAutonity.Validator", "name": "", "type": "tuple", } @@ -3336,7 +4281,11 @@ def upgrade_contract( "inputs": [{"internalType": "address", "name": "_addr", "type": "address"}], "name": "getValidatorState", "outputs": [ - {"internalType": "enum ValidatorState", "name": "", "type": "uint8"} + { + "internalType": "enum IAutonity.ValidatorState", + "name": "", + "type": "uint8", + } ], "stateMutability": "view", "type": "function", @@ -3355,13 +4304,6 @@ def upgrade_contract( "stateMutability": "view", "type": "function", }, - { - "inputs": [], - "name": "inflationReserve", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "stateMutability": "view", - "type": "function", - }, { "inputs": [ {"internalType": "uint256", "name": "_unbondingID", "type": "uint256"} @@ -3376,7 +4318,7 @@ def upgrade_contract( {"internalType": "address", "name": "_nodeAddress", "type": "address"}, {"internalType": "uint256", "name": "_jailtime", "type": "uint256"}, { - "internalType": "enum ValidatorState", + "internalType": "enum IAutonity.ValidatorState", "name": "_newJailedState", "type": "uint8", }, @@ -3390,7 +4332,7 @@ def upgrade_contract( "inputs": [ {"internalType": "address", "name": "_nodeAddress", "type": "address"}, { - "internalType": "enum ValidatorState", + "internalType": "enum IAutonity.ValidatorState", "name": "_newJailboundState", "type": "uint8", }, @@ -3400,27 +4342,6 @@ def upgrade_contract( "stateMutability": "nonpayable", "type": "function", }, - { - "inputs": [], - "name": "lastEpochTime", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "stateMutability": "view", - "type": "function", - }, - { - "inputs": [], - "name": "lastFinalizedBlock", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "stateMutability": "view", - "type": "function", - }, - { - "inputs": [], - "name": "liquidLogicContract", - "outputs": [{"internalType": "address", "name": "", "type": "address"}], - "stateMutability": "view", - "type": "function", - }, { "inputs": [ {"internalType": "address", "name": "_addr", "type": "address"}, @@ -3438,13 +4359,6 @@ def upgrade_contract( "stateMutability": "pure", "type": "function", }, - { - "inputs": [], - "name": "newEpochPeriod", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "stateMutability": "view", - "type": "function", - }, { "inputs": [ {"internalType": "address", "name": "_address", "type": "address"} @@ -3492,13 +4406,22 @@ def upgrade_contract( }, { "inputs": [ - {"internalType": "contract IACU", "name": "_address", "type": "address"} + {"internalType": "address", "name": "_address", "type": "address"} ], "name": "setAcuContract", "outputs": [], "stateMutability": "nonpayable", "type": "function", }, + { + "inputs": [ + {"internalType": "address", "name": "_address", "type": "address"} + ], + "name": "setAuctioneerContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, { "inputs": [{"internalType": "uint256", "name": "_size", "type": "uint256"}], "name": "setCommitteeSize", @@ -3506,6 +4429,41 @@ def upgrade_contract( "stateMutability": "nonpayable", "type": "function", }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "minBaseFee", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "baseFeeChangeDenominator", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "elasticityMultiplier", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "gasLimitBoundDivisor", + "type": "uint256", + }, + ], + "internalType": "struct IAutonity.Eip1559", + "name": "_params", + "type": "tuple", + } + ], + "name": "setEip1559Params", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, { "inputs": [ {"internalType": "uint256", "name": "_period", "type": "uint256"} @@ -3515,6 +4473,15 @@ def upgrade_contract( "stateMutability": "nonpayable", "type": "function", }, + { + "inputs": [ + {"internalType": "uint256", "name": "_gasLimit", "type": "uint256"} + ], + "name": "setGasLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, { "inputs": [ { @@ -3530,22 +4497,22 @@ def upgrade_contract( }, { "inputs": [ - { - "internalType": "uint256", - "name": "_newMaxDuration", - "type": "uint256", - } + {"internalType": "address", "name": "_contract", "type": "address"} ], - "name": "setMaxScheduleDuration", + "name": "setLiquidLogicContract", "outputs": [], "stateMutability": "nonpayable", "type": "function", }, { "inputs": [ - {"internalType": "uint256", "name": "_price", "type": "uint256"} + { + "internalType": "uint256", + "name": "_newMaxDuration", + "type": "uint256", + } ], - "name": "setMinimumBaseFee", + "name": "setMaxScheduleDuration", "outputs": [], "stateMutability": "nonpayable", "type": "function", @@ -3622,11 +4589,7 @@ def upgrade_contract( }, { "inputs": [ - { - "internalType": "contract IStabilization", - "name": "_address", - "type": "address", - } + {"internalType": "address", "name": "_address", "type": "address"} ], "name": "setStabilizationContract", "outputs": [], @@ -3635,11 +4598,7 @@ def upgrade_contract( }, { "inputs": [ - { - "internalType": "contract ISupplyControl", - "name": "_address", - "type": "address", - } + {"internalType": "address", "name": "_address", "type": "address"} ], "name": "setSupplyControlContract", "outputs": [], @@ -3730,12 +4689,12 @@ def upgrade_contract( {"internalType": "uint256", "name": "_slashingRate", "type": "uint256"}, {"internalType": "uint256", "name": "_jailtime", "type": "uint256"}, { - "internalType": "enum ValidatorState", + "internalType": "enum IAutonity.ValidatorState", "name": "_newJailedState", "type": "uint8", }, { - "internalType": "enum ValidatorState", + "internalType": "enum IAutonity.ValidatorState", "name": "_newJailboundState", "type": "uint8", }, @@ -3757,15 +4716,6 @@ def upgrade_contract( "stateMutability": "nonpayable", "type": "function", }, - { - "inputs": [], - "name": "slasher", - "outputs": [ - {"internalType": "contract ISlasher", "name": "", "type": "address"} - ], - "stateMutability": "view", - "type": "function", - }, { "inputs": [], "name": "symbol", diff --git a/autonity/contracts/inflation_controller.py b/autonity/contracts/inflation_controller.py index 96c97f0..6414cb6 100644 --- a/autonity/contracts/inflation_controller.py +++ b/autonity/contracts/inflation_controller.py @@ -1,6 +1,6 @@ """InflationController contract binding and data structures.""" -# This module has been generated using pyabigen v0.2.12 +# This module has been generated using pyabigen v0.2.15 import typing from dataclasses import dataclass @@ -9,7 +9,7 @@ import web3 from web3.contract import contract -__version__ = "v1.0.2-alpha" +__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" @dataclass @@ -75,16 +75,17 @@ def calculate_supply_delta( ).call() return int(return_value) - def params( + def get_params( self, ) -> Params: - """Binding for `params` on the InflationController contract. + """Binding for `getParams` on the InflationController contract. Returns ------- Params + the current parameters of the inflation controller """ - return_value = self._contract.functions.params().call() + return_value = self._contract.functions.getParams().call() return Params( int(return_value[0]), int(return_value[1]), @@ -220,33 +221,40 @@ def params( }, { "inputs": [], - "name": "params", + "name": "getParams", "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", - }, + "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": "", + "type": "tuple", + } ], "stateMutability": "view", "type": "function", diff --git a/autonity/contracts/liquid_logic.py b/autonity/contracts/liquid_logic.py index fdb4a26..f73bdb0 100644 --- a/autonity/contracts/liquid_logic.py +++ b/autonity/contracts/liquid_logic.py @@ -1,6 +1,6 @@ """LiquidLogic contract binding and data structures.""" -# This module has been generated using pyabigen v0.2.12 +# This module has been generated using pyabigen v0.2.15 import typing @@ -8,7 +8,7 @@ import web3 from web3.contract import contract -__version__ = "v1.0.2-alpha" +__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" class LiquidLogic: @@ -177,7 +177,7 @@ def claim_treasury_atn( ) -> contract.ContractFunction: """Binding for `claimTreasuryATN` on the LiquidLogic contract. - Send the unclaimed ATN entitled to treasury to treasury account + Send the unclaimed ATN entitled to treasury account Returns ------- @@ -204,6 +204,8 @@ def get_commission_rate( ) -> int: """Binding for `getCommissionRate` on the LiquidLogic contract. + Returns the current commission rate + Returns ------- int @@ -216,6 +218,8 @@ def get_treasury( ) -> eth_typing.ChecksumAddress: """Binding for `getTreasury` on the LiquidLogic contract. + Returns the treasury of the validator associated with this liquid contract + Returns ------- eth_typing.ChecksumAddress @@ -243,6 +247,8 @@ def get_validator( ) -> eth_typing.ChecksumAddress: """Binding for `getValidator` on the LiquidLogic contract. + Returns the validator associated with this liquid contract + Returns ------- eth_typing.ChecksumAddress @@ -276,6 +282,8 @@ def name( ) -> str: """Binding for `name` on the LiquidLogic contract. + Returns the name of this liquid contract token + Returns ------- str @@ -288,6 +296,8 @@ def symbol( ) -> str: """Binding for `symbol` on the LiquidLogic contract. + Returns the symbol of this liquid contract token + Returns ------- str diff --git a/autonity/contracts/omission_accountability.py b/autonity/contracts/omission_accountability.py index a226ba7..817c6f9 100644 --- a/autonity/contracts/omission_accountability.py +++ b/autonity/contracts/omission_accountability.py @@ -1,6 +1,6 @@ """OmissionAccountability contract binding and data structures.""" -# This module has been generated using pyabigen v0.2.12 +# This module has been generated using pyabigen v0.2.15 import typing from dataclasses import dataclass @@ -9,7 +9,7 @@ import web3 from web3.contract import contract -__version__ = "v1.0.2-alpha" +__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" @dataclass @@ -47,6 +47,47 @@ def __init__( abi=ABI, ) + @property + def CallFailed(self) -> contract.ContractEvent: + """Binding for `event CallFailed` on the OmissionAccountability contract. + + This event is emitted when a call to an address fails in a protocol function + (like finalize()). + """ + return self._contract.events.CallFailed + + @property + def ConfigUpdateAddress(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateAddress` on the OmissionAccountability contract. + + Emitted after updating config parameter of type address + """ + return self._contract.events.ConfigUpdateAddress + + @property + def ConfigUpdateBool(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateBool` on the OmissionAccountability contract. + + Emitted after updating config parameter of type boolean + """ + return self._contract.events.ConfigUpdateBool + + @property + def ConfigUpdateInt(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateInt` on the OmissionAccountability contract. + + Emitted after updating config parameter of type int + """ + return self._contract.events.ConfigUpdateInt + + @property + def ConfigUpdateUint(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateUint` on the OmissionAccountability contract. + + Emitted after updating config parameter of type uint + """ + return self._contract.events.ConfigUpdateUint + @property def InactivityJailingEvent(self) -> contract.ContractEvent: """Binding for `event InactivityJailingEvent` on the OmissionAccountability contract.""" @@ -57,6 +98,11 @@ def InactivitySlashingEvent(self) -> contract.ContractEvent: """Binding for `event InactivitySlashingEvent` on the OmissionAccountability contract.""" return self._contract.events.InactivitySlashingEvent + @property + def TotalProposerRewards(self) -> contract.ContractEvent: + """Binding for `event TotalProposerRewards` on the OmissionAccountability contract.""" + return self._contract.events.TotalProposerRewards + def scale_factor( self, ) -> int: @@ -69,16 +115,32 @@ def scale_factor( return_value = self._contract.functions.SCALE_FACTOR().call() return int(return_value) - def config( + def get_absentees_last_height( + self, + ) -> typing.List[eth_typing.ChecksumAddress]: + """Binding for `getAbsenteesLastHeight` on the OmissionAccountability contract. + + Returns + ------- + typing.List[eth_typing.ChecksumAddress] + """ + return_value = self._contract.functions.getAbsenteesLastHeight().call() + return [ + eth_typing.ChecksumAddress(return_value_elem) + for return_value_elem in return_value + ] + + def get_config( self, ) -> Config: - """Binding for `config` on the OmissionAccountability contract. + """Binding for `getConfig` on the OmissionAccountability contract. Returns ------- Config + the current config """ - return_value = self._contract.functions.config().call() + return_value = self._contract.functions.getConfig().call() return Config( int(return_value[0]), int(return_value[1]), @@ -89,291 +151,271 @@ def config( int(return_value[6]), ) - def distribute_proposer_rewards( + def get_delta( self, - _ntn_reward: int, - ) -> contract.ContractFunction: - """Binding for `distributeProposerRewards` on the OmissionAccountability contract. - - Parameters - ---------- - _ntn_reward : int + ) -> int: + """Binding for `getDelta` on the OmissionAccountability contract. Returns ------- - web3.contract.contract.ContractFunction - A contract function instance to be sent in a transaction. + int """ - return self._contract.functions.distributeProposerRewards( - _ntn_reward, - ) + return_value = self._contract.functions.getDelta().call() + return int(return_value) - def epoch_collusion_degree( + def get_epoch_collusion_degree( self, - key0: int, + _epoch_id: int, ) -> int: - """Binding for `epochCollusionDegree` on the OmissionAccountability contract. + """Binding for `getEpochCollusionDegree` on the OmissionAccountability contract. Parameters ---------- - key0 : int + _epoch_id : int Returns ------- int + the collusion degree (number of punished validators) in that epoch """ - return_value = self._contract.functions.epochCollusionDegree( - key0, + return_value = self._contract.functions.getEpochCollusionDegree( + _epoch_id, ).call() return int(return_value) - def faulty_proposers( + def get_epoch_collusion_degree_length( self, - key0: int, + ) -> int: + """Binding for `getEpochCollusionDegreeLength` on the OmissionAccountability contract. + + Returns + ------- + int + length of the collusion degree array + """ + return_value = self._contract.functions.getEpochCollusionDegreeLength().call() + return int(return_value) + + def get_faulty_proposers( + self, + _height: int, ) -> bool: - """Binding for `faultyProposers` on the OmissionAccountability contract. + """Binding for `getFaultyProposers` on the OmissionAccountability contract. Parameters ---------- - key0 : int + _height : int + , height number Returns ------- bool + whether the proposer of that height was faulty or not """ - return_value = self._contract.functions.faultyProposers( - key0, + return_value = self._contract.functions.getFaultyProposers( + _height, ).call() return bool(return_value) - def faulty_proposers_in_window( + def get_faulty_proposers_in_window( self, ) -> int: - """Binding for `faultyProposersInWindow` on the OmissionAccountability contract. + """Binding for `getFaultyProposersInWindow` on the OmissionAccountability contract. Returns ------- int + the number of faulty proposers in the current window """ - return_value = self._contract.functions.faultyProposersInWindow().call() + return_value = self._contract.functions.getFaultyProposersInWindow().call() return int(return_value) - def get_absentees_last_height( + def get_inactive_validators( self, - ) -> typing.List[eth_typing.ChecksumAddress]: - """Binding for `getAbsenteesLastHeight` on the OmissionAccountability contract. + _height: int, + _validator: eth_typing.ChecksumAddress, + ) -> bool: + """Binding for `getInactiveValidators` on the OmissionAccountability contract. - Returns - ------- - typing.List[eth_typing.ChecksumAddress] - """ - return_value = self._contract.functions.getAbsenteesLastHeight().call() - return [ - eth_typing.ChecksumAddress(return_value_elem) - for return_value_elem in return_value - ] + the result of this getter does not take into account the lookback window logic. + It just signals whether the validator was included in the activity proof or not. - def get_delta( - self, - ) -> int: - """Binding for `getDelta` on the OmissionAccountability contract. + Parameters + ---------- + _height : int + , height number + _validator : eth_typing.ChecksumAddress + , validator node address Returns ------- - int + bool + whether the specified validator was inactive at the specified height """ - return_value = self._contract.functions.getDelta().call() - return int(return_value) + return_value = self._contract.functions.getInactiveValidators( + _height, + _validator, + ).call() + return bool(return_value) - def get_inactivity_score( + def get_inactivity_counter( self, _validator: eth_typing.ChecksumAddress, ) -> int: - """Binding for `getInactivityScore` on the OmissionAccountability contract. + """Binding for `getInactivityCounter` on the OmissionAccountability contract. Parameters ---------- _validator : eth_typing.ChecksumAddress + , node address of the validator Returns ------- int + the current inactivity counter of the validator """ - return_value = self._contract.functions.getInactivityScore( + return_value = self._contract.functions.getInactivityCounter( _validator, ).call() return int(return_value) - def get_lookback_window( + def get_inactivity_score( self, + _validator: eth_typing.ChecksumAddress, ) -> int: - """Binding for `getLookbackWindow` on the OmissionAccountability contract. - - Returns - ------- - int - """ - return_value = self._contract.functions.getLookbackWindow().call() - return int(return_value) + """Binding for `getInactivityScore` on the OmissionAccountability contract. - def get_scale_factor( - self, - ) -> int: - """Binding for `getScaleFactor` on the OmissionAccountability contract. + Parameters + ---------- + _validator : eth_typing.ChecksumAddress Returns ------- int """ - return_value = self._contract.functions.getScaleFactor().call() + return_value = self._contract.functions.getInactivityScore( + _validator, + ).call() return int(return_value) - def get_total_effort( + def get_last_active( self, + _validator: eth_typing.ChecksumAddress, ) -> int: - """Binding for `getTotalEffort` on the OmissionAccountability contract. - - Returns - ------- - int - """ - return_value = self._contract.functions.getTotalEffort().call() - return int(return_value) - - def inactive_validators( - self, - key0: int, - key1: eth_typing.ChecksumAddress, - ) -> bool: - """Binding for `inactiveValidators` on the OmissionAccountability contract. + """Binding for `getLastActive` on the OmissionAccountability contract. Parameters ---------- - key0 : int - key1 : eth_typing.ChecksumAddress + _validator : eth_typing.ChecksumAddress + , node address of the validator Returns ------- - bool + int + the last block at which the validator was recorded as active. -1 + means that they are not on an inactivity streak """ - return_value = self._contract.functions.inactiveValidators( - key0, - key1, + return_value = self._contract.functions.getLastActive( + _validator, ).call() - return bool(return_value) + return int(return_value) - def inactivity_counter( + def get_lookback_window( self, - key0: eth_typing.ChecksumAddress, ) -> int: - """Binding for `inactivityCounter` on the OmissionAccountability contract. - - Parameters - ---------- - key0 : eth_typing.ChecksumAddress + """Binding for `getLookbackWindow` on the OmissionAccountability contract. Returns ------- int """ - return_value = self._contract.functions.inactivityCounter( - key0, - ).call() + return_value = self._contract.functions.getLookbackWindow().call() return int(return_value) - def inactivity_scores( + def get_probation_periods( self, - key0: eth_typing.ChecksumAddress, + _validator: eth_typing.ChecksumAddress, ) -> int: - """Binding for `inactivityScores` on the OmissionAccountability contract. + """Binding for `getProbationPeriods` on the OmissionAccountability contract. Parameters ---------- - key0 : eth_typing.ChecksumAddress + _validator : eth_typing.ChecksumAddress + , node address of the validator Returns ------- int + the current probation period of the validator """ - return_value = self._contract.functions.inactivityScores( - key0, + return_value = self._contract.functions.getProbationPeriods( + _validator, ).call() return int(return_value) - def last_active( + def get_proposer_effort( self, - key0: eth_typing.ChecksumAddress, + _node_address: eth_typing.ChecksumAddress, ) -> int: - """Binding for `lastActive` on the OmissionAccountability contract. + """Binding for `getProposerEffort` on the OmissionAccountability contract. Parameters ---------- - key0 : eth_typing.ChecksumAddress + _node_address : eth_typing.ChecksumAddress Returns ------- int + the proposer effort accumulated by the validator up to now """ - return_value = self._contract.functions.lastActive( - key0, + return_value = self._contract.functions.getProposerEffort( + _node_address, ).call() return int(return_value) - def probation_periods( + def get_repeated_offences( self, - key0: eth_typing.ChecksumAddress, + _validator: eth_typing.ChecksumAddress, ) -> int: - """Binding for `probationPeriods` on the OmissionAccountability contract. + """Binding for `getRepeatedOffences` on the OmissionAccountability contract. Parameters ---------- - key0 : eth_typing.ChecksumAddress + _validator : eth_typing.ChecksumAddress + , node address of the validator Returns ------- int + the current number of repeated offences of the validator """ - return_value = self._contract.functions.probationPeriods( - key0, + return_value = self._contract.functions.getRepeatedOffences( + _validator, ).call() return int(return_value) - def proposer_effort( + def get_scale_factor( self, - key0: eth_typing.ChecksumAddress, ) -> int: - """Binding for `proposerEffort` on the OmissionAccountability contract. - - Parameters - ---------- - key0 : eth_typing.ChecksumAddress + """Binding for `getScaleFactor` on the OmissionAccountability contract. Returns ------- int """ - return_value = self._contract.functions.proposerEffort( - key0, - ).call() + return_value = self._contract.functions.getScaleFactor().call() return int(return_value) - def repeated_offences( + def get_total_effort( self, - key0: eth_typing.ChecksumAddress, ) -> int: - """Binding for `repeatedOffences` on the OmissionAccountability contract. - - Parameters - ---------- - key0 : eth_typing.ChecksumAddress + """Binding for `getTotalEffort` on the OmissionAccountability contract. Returns ------- int """ - return_value = self._contract.functions.repeatedOffences( - key0, - ).call() + return_value = self._contract.functions.getTotalEffort().call() return int(return_value) def set_delta( @@ -509,18 +551,6 @@ def set_past_performance_weight( _past_performance_weight, ) - def total_effort( - self, - ) -> int: - """Binding for `totalEffort` on the OmissionAccountability contract. - - Returns - ------- - int - """ - return_value = self._contract.functions.totalEffort().call() - return int(return_value) - ABI = typing.cast( eth_typing.ABI, @@ -533,11 +563,6 @@ def total_effort( "type": "address", }, {"internalType": "address", "name": "_operator", "type": "address"}, - { - "internalType": "address[]", - "name": "_treasuries", - "type": "address[]", - }, { "components": [ { @@ -586,93 +611,222 @@ def total_effort( { "indexed": False, "internalType": "address", - "name": "validator", + "name": "to", "type": "address", }, { "indexed": False, - "internalType": "uint256", - "name": "releaseBlock", - "type": "uint256", + "internalType": "string", + "name": "methodSignature", + "type": "string", + }, + { + "indexed": False, + "internalType": "bytes", + "name": "returnData", + "type": "bytes", }, ], - "name": "InactivityJailingEvent", + "name": "CallFailed", "type": "event", }, { "anonymous": False, "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, { "indexed": False, "internalType": "address", - "name": "validator", + "name": "oldValue", "type": "address", }, { "indexed": False, - "internalType": "uint256", - "name": "amount", - "type": "uint256", + "internalType": "address", + "name": "newValue", + "type": "address", }, { "indexed": False, "internalType": "uint256", - "name": "releaseBlock", + "name": "appliesAtHeight", "type": "uint256", }, + ], + "name": "ConfigUpdateAddress", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, { "indexed": False, "internalType": "bool", - "name": "isJailbound", + "name": "oldValue", "type": "bool", }, + { + "indexed": False, + "internalType": "bool", + "name": "newValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, ], - "name": "InactivitySlashingEvent", + "name": "ConfigUpdateBool", "type": "event", }, { - "inputs": [], - "name": "SCALE_FACTOR", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "stateMutability": "view", - "type": "function", + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "int256", + "name": "oldValue", + "type": "int256", + }, + { + "indexed": False, + "internalType": "int256", + "name": "newValue", + "type": "int256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateInt", + "type": "event", }, { - "inputs": [], - "name": "config", - "outputs": [ + "anonymous": False, + "inputs": [ { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, "internalType": "uint256", - "name": "inactivityThreshold", + "name": "oldValue", "type": "uint256", }, { + "indexed": False, "internalType": "uint256", - "name": "lookbackWindow", + "name": "newValue", "type": "uint256", }, { + "indexed": False, "internalType": "uint256", - "name": "pastPerformanceWeight", + "name": "appliesAtHeight", "type": "uint256", }, + ], + "name": "ConfigUpdateUint", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "address", + "name": "validator", + "type": "address", + }, { + "indexed": False, "internalType": "uint256", - "name": "initialJailingPeriod", + "name": "releaseBlock", "type": "uint256", }, + ], + "name": "InactivityJailingEvent", + "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", + }, + ], + "name": "InactivitySlashingEvent", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ { + "indexed": False, "internalType": "uint256", - "name": "initialProbationPeriod", + "name": "ntnReward", "type": "uint256", }, { + "indexed": False, "internalType": "uint256", - "name": "initialSlashingRate", + "name": "atnReward", "type": "uint256", }, - {"internalType": "uint256", "name": "delta", "type": "uint256"}, ], + "name": "TotalProposerRewards", + "type": "event", + }, + { + "inputs": [], + "name": "SCALE_FACTOR", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, @@ -686,125 +840,185 @@ def total_effort( "type": "function", }, { - "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "name": "epochCollusionDegree", + "inputs": [{"internalType": "bool", "name": "_epochEnded", "type": "bool"}], + "name": "finalize", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function", }, { - "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "name": "faultyProposers", - "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "inputs": [], + "name": "getAbsenteesLastHeight", + "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], "stateMutability": "view", "type": "function", }, { "inputs": [], - "name": "faultyProposersInWindow", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "getConfig", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "inactivityThreshold", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "lookbackWindow", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "pastPerformanceWeight", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "initialJailingPeriod", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "initialProbationPeriod", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "initialSlashingRate", + "type": "uint256", + }, + {"internalType": "uint256", "name": "delta", "type": "uint256"}, + ], + "internalType": "struct OmissionAccountability.Config", + "name": "", + "type": "tuple", + } + ], "stateMutability": "view", "type": "function", }, { - "inputs": [{"internalType": "bool", "name": "_epochEnded", "type": "bool"}], - "name": "finalize", + "inputs": [], + "name": "getDelta", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function", }, { - "inputs": [], - "name": "getAbsenteesLastHeight", - "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], + "inputs": [ + {"internalType": "uint256", "name": "_epochID", "type": "uint256"} + ], + "name": "getEpochCollusionDegree", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, { "inputs": [], - "name": "getDelta", + "name": "getEpochCollusionDegreeLength", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, { "inputs": [ - {"internalType": "address", "name": "_validator", "type": "address"} + {"internalType": "uint256", "name": "_height", "type": "uint256"} ], - "name": "getInactivityScore", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "getFaultyProposers", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function", }, { "inputs": [], - "name": "getLookbackWindow", + "name": "getFaultyProposersInWindow", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, { - "inputs": [], - "name": "getScaleFactor", + "inputs": [ + {"internalType": "uint256", "name": "_height", "type": "uint256"}, + {"internalType": "address", "name": "_validator", "type": "address"}, + ], + "name": "getInactiveValidators", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_validator", "type": "address"} + ], + "name": "getInactivityCounter", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "stateMutability": "pure", + "stateMutability": "view", "type": "function", }, { - "inputs": [], - "name": "getTotalEffort", + "inputs": [ + {"internalType": "address", "name": "_validator", "type": "address"} + ], + "name": "getInactivityScore", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, { "inputs": [ - {"internalType": "uint256", "name": "", "type": "uint256"}, - {"internalType": "address", "name": "", "type": "address"}, + {"internalType": "address", "name": "_validator", "type": "address"} ], - "name": "inactiveValidators", - "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "name": "getLastActive", + "outputs": [{"internalType": "int256", "name": "", "type": "int256"}], "stateMutability": "view", "type": "function", }, { - "inputs": [{"internalType": "address", "name": "", "type": "address"}], - "name": "inactivityCounter", + "inputs": [], + "name": "getLookbackWindow", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, { - "inputs": [{"internalType": "address", "name": "", "type": "address"}], - "name": "inactivityScores", + "inputs": [ + {"internalType": "address", "name": "_validator", "type": "address"} + ], + "name": "getProbationPeriods", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, { - "inputs": [{"internalType": "address", "name": "", "type": "address"}], - "name": "lastActive", - "outputs": [{"internalType": "int256", "name": "", "type": "int256"}], + "inputs": [ + {"internalType": "address", "name": "_nodeAddress", "type": "address"} + ], + "name": "getProposerEffort", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, { - "inputs": [{"internalType": "address", "name": "", "type": "address"}], - "name": "probationPeriods", + "inputs": [ + {"internalType": "address", "name": "_validator", "type": "address"} + ], + "name": "getRepeatedOffences", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, { - "inputs": [{"internalType": "address", "name": "", "type": "address"}], - "name": "proposerEffort", + "inputs": [], + "name": "getScaleFactor", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "stateMutability": "view", + "stateMutability": "pure", "type": "function", }, { - "inputs": [{"internalType": "address", "name": "", "type": "address"}], - "name": "repeatedOffences", + "inputs": [], + "name": "getTotalEffort", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", @@ -825,7 +1039,7 @@ def total_effort( "type": "bytes", }, ], - "internalType": "struct Autonity.CommitteeMember[]", + "internalType": "struct IAutonity.CommitteeMember[]", "name": "_committee", "type": "tuple[]", }, @@ -945,12 +1159,5 @@ def total_effort( "stateMutability": "nonpayable", "type": "function", }, - { - "inputs": [], - "name": "totalEffort", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "stateMutability": "view", - "type": "function", - }, ], ) diff --git a/autonity/contracts/oracle.py b/autonity/contracts/oracle.py index 26eb3c0..25b2260 100644 --- a/autonity/contracts/oracle.py +++ b/autonity/contracts/oracle.py @@ -1,6 +1,6 @@ """Oracle contract binding and data structures.""" -# This module has been generated using pyabigen v0.2.12 +# This module has been generated using pyabigen v0.2.15 import typing from dataclasses import dataclass @@ -9,7 +9,7 @@ import web3 from web3.contract import contract -__version__ = "v1.0.2-alpha" +__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" @dataclass @@ -22,6 +22,17 @@ class Config: outlier_detection_threshold: int outlier_slashing_threshold: int base_slashing_rate: int + non_reveal_threshold: int + reveal_reset_interval: int + slashing_rate_cap: int + + +@dataclass +class Report: + """Port of `struct Report` on the IOracle contract.""" + + price: int + confidence: int @dataclass @@ -34,6 +45,18 @@ class RoundData: success: bool +@dataclass +class VoterInfo: + """Port of `struct VoterInfo` on the Oracle contract.""" + + round: int + commit: int + performance: int + non_reveal_count: int + is_voter: bool + report_available: bool + + class Oracle: """Oracle contract binding. @@ -59,36 +82,140 @@ def __init__( abi=ABI, ) + @property + def CallFailed(self) -> contract.ContractEvent: + """Binding for `event CallFailed` on the Oracle contract. + + This event is emitted when a call to an address fails in a protocol function + (like finalize()). + """ + return self._contract.events.CallFailed + + @property + def CommitRevealMissed(self) -> contract.ContractEvent: + """Binding for `event CommitRevealMissed` on the Oracle contract. + + Emitted when a participant submitted commit in the previous round but did not + submit reveal in the current round. + """ + return self._contract.events.CommitRevealMissed + + @property + def ConfigUpdateAddress(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateAddress` on the Oracle contract. + + Emitted after updating config parameter of type address + """ + return self._contract.events.ConfigUpdateAddress + + @property + def ConfigUpdateBool(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateBool` on the Oracle contract. + + Emitted after updating config parameter of type boolean + """ + return self._contract.events.ConfigUpdateBool + + @property + def ConfigUpdateInt(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateInt` on the Oracle contract. + + Emitted after updating config parameter of type int + """ + return self._contract.events.ConfigUpdateInt + + @property + def ConfigUpdateUint(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateUint` on the Oracle contract. + + Emitted after updating config parameter of type uint + """ + return self._contract.events.ConfigUpdateUint + + @property + def InvalidVote(self) -> contract.ContractEvent: + """Binding for `event InvalidVote` on the Oracle contract. + + Emitted when an invalid report is submitted + """ + return self._contract.events.InvalidVote + @property def NewRound(self) -> contract.ContractEvent: - """Binding for `event NewRound` on the Oracle contract.""" + """Binding for `event NewRound` on the Oracle contract. + + Emitted when a new voting round is started. + """ return self._contract.events.NewRound @property def NewSymbols(self) -> contract.ContractEvent: - """Binding for `event NewSymbols` on the Oracle contract.""" + """Binding for `event NewSymbols` on the Oracle contract. + + Emitted when the oracle symbol list is updated + """ return self._contract.events.NewSymbols + @property + def NewVoter(self) -> contract.ContractEvent: + """Binding for `event NewVoter` on the Oracle contract. + + Emitted when a new reporter submits a report + """ + return self._contract.events.NewVoter + + @property + def NoRevealPenalty(self) -> contract.ContractEvent: + """Binding for `event NoRevealPenalty` on the Oracle contract. + + Emitted when a participant gets penalized for missing too many reveals in a + certain window + """ + return self._contract.events.NoRevealPenalty + @property def Penalized(self) -> contract.ContractEvent: - """Binding for `event Penalized` on the Oracle contract.""" + """Binding for `event Penalized` on the Oracle contract. + + Emitted when a participant gets penalized as an outlier + """ return self._contract.events.Penalized @property - def Voted(self) -> contract.ContractEvent: - """Binding for `event Voted` on the Oracle contract.""" - return self._contract.events.Voted + def PriceUpdated(self) -> contract.ContractEvent: + """Binding for `event PriceUpdated` on the Oracle contract. + + Emitted when a new price is calculated for a symbol + """ + return self._contract.events.PriceUpdated + + @property + def SuccessfulVote(self) -> contract.ContractEvent: + """Binding for `event SuccessfulVote` on the Oracle contract. - def config( + Emitted when a valid report is accepted + """ + return self._contract.events.SuccessfulVote + + @property + def TotalOracleRewards(self) -> contract.ContractEvent: + """Binding for `event TotalOracleRewards` on the Oracle contract. + + Emitted when oracle rewards are distributed + """ + return self._contract.events.TotalOracleRewards + + def get_config( self, ) -> Config: - """Binding for `config` on the Oracle contract. + """Binding for `getConfig` on the Oracle contract. Returns ------- Config + config, the current oracle config """ - return_value = self._contract.functions.config().call() + return_value = self._contract.functions.getConfig().call() return Config( eth_typing.ChecksumAddress(return_value[0]), eth_typing.ChecksumAddress(return_value[1]), @@ -96,39 +223,51 @@ def config( int(return_value[3]), int(return_value[4]), int(return_value[5]), + int(return_value[6]), + int(return_value[7]), + int(return_value[8]), ) - def distribute_rewards( + def get_decimals( self, - _ntn: int, - ) -> contract.ContractFunction: - """Binding for `distributeRewards` on the Oracle contract. + ) -> int: + """Binding for `getDecimals` on the Oracle contract. - Parameters - ---------- - _ntn : int + Decimal places to be used with price reports Returns ------- - web3.contract.contract.ContractFunction - A contract function instance to be sent in a transaction. + int """ - return self._contract.functions.distributeRewards( - _ntn, - ) + return_value = self._contract.functions.getDecimals().call() + return int(return_value) - def get_decimals( + def get_last_round_block( self, ) -> int: - """Binding for `getDecimals` on the Oracle contract. + """Binding for `getLastRoundBlock` on the Oracle contract. - Decimal places to be used with price reports + Returns + ------- + int + the block at which the last completed round ended + """ + return_value = self._contract.functions.getLastRoundBlock().call() + return int(return_value) + + def get_new_vote_period( + self, + ) -> int: + """Binding for `getNewVotePeriod` on the Oracle contract. + + Retrieve the new vote period that is going to be applied at the end of the vote + round. Returns ------- int """ - return_value = self._contract.functions.getDecimals().call() + return_value = self._contract.functions.getNewVotePeriod().call() return int(return_value) def get_new_voters( @@ -148,6 +287,45 @@ def get_new_voters( for return_value_elem in return_value ] + def get_non_reveal_threshold( + self, + ) -> int: + """Binding for `getNonRevealThreshold` on the Oracle contract. + + Returns the tolerance for missed reveal count before the voter gets punished. + + Returns + ------- + int + """ + return_value = self._contract.functions.getNonRevealThreshold().call() + return int(return_value) + + def get_reports( + self, + _symbol: str, + _voter: eth_typing.ChecksumAddress, + ) -> Report: + """Binding for `getReports` on the Oracle contract. + + Parameters + ---------- + _symbol : str + , the target symbol + _voter : eth_typing.ChecksumAddress + , the target voter address + + Returns + ------- + Report + the latest report of that voter for that symbol + """ + return_value = self._contract.functions.getReports( + _symbol, + _voter, + ).call() + return Report(int(return_value[0]), int(return_value[1])) + def get_reward_period_performance( self, _voter: eth_typing.ChecksumAddress, @@ -214,6 +392,19 @@ def get_round_data( bool(return_value[3]), ) + def get_symbol_updated_round( + self, + ) -> int: + """Binding for `getSymbolUpdatedRound` on the Oracle contract. + + Returns + ------- + int + the round at which the symbols got updated + """ + return_value = self._contract.functions.getSymbolUpdatedRound().call() + return int(return_value) + def get_symbols( self, ) -> typing.List[str]: @@ -242,6 +433,74 @@ def get_vote_period( return_value = self._contract.functions.getVotePeriod().call() return int(return_value) + def get_voter_info( + self, + _voter: eth_typing.ChecksumAddress, + ) -> VoterInfo: + """Binding for `getVoterInfo` on the Oracle contract. + + Parameters + ---------- + _voter : eth_typing.ChecksumAddress + , the voter address + + Returns + ------- + VoterInfo + the related voter information + """ + return_value = self._contract.functions.getVoterInfo( + _voter, + ).call() + return VoterInfo( + int(return_value[0]), + int(return_value[1]), + int(return_value[2]), + int(return_value[3]), + bool(return_value[4]), + bool(return_value[5]), + ) + + def get_voter_treasuries( + self, + _oracle_address: eth_typing.ChecksumAddress, + ) -> eth_typing.ChecksumAddress: + """Binding for `getVoterTreasuries` on the Oracle contract. + + Parameters + ---------- + _oracle_address : eth_typing.ChecksumAddress + + Returns + ------- + eth_typing.ChecksumAddress + his treasury address + """ + return_value = self._contract.functions.getVoterTreasuries( + _oracle_address, + ).call() + return eth_typing.ChecksumAddress(return_value) + + def get_voter_validators( + self, + _oracle_address: eth_typing.ChecksumAddress, + ) -> eth_typing.ChecksumAddress: + """Binding for `getVoterValidators` on the Oracle contract. + + Parameters + ---------- + _oracle_address : eth_typing.ChecksumAddress + + Returns + ------- + eth_typing.ChecksumAddress + his node address + """ + return_value = self._contract.functions.getVoterValidators( + _oracle_address, + ).call() + return eth_typing.ChecksumAddress(return_value) + def get_voters( self, ) -> typing.List[eth_typing.ChecksumAddress]: @@ -259,18 +518,6 @@ def get_voters( for return_value_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 latest_round_data( self, _symbol: str, @@ -298,30 +545,28 @@ def latest_round_data( bool(return_value[3]), ) - def reports( + def set_commit_reveal_config( self, - key0: str, - key1: eth_typing.ChecksumAddress, - ) -> typing.Tuple[int, int]: - """Binding for `reports` on the Oracle contract. + _threshold: int, + _reset_interval: int, + ) -> contract.ContractFunction: + """Binding for `setCommitRevealConfig` on the Oracle contract. + + Setter for commit-reveal penalty mechanism configuration. Parameters ---------- - key0 : str - key1 : eth_typing.ChecksumAddress + _threshold : int + _reset_interval : int Returns ------- - int - int + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. """ - return_value = self._contract.functions.reports( - key0, - key1, - ).call() - return ( - int(return_value[0]), - int(return_value[1]), + return self._contract.functions.setCommitRevealConfig( + _threshold, + _reset_interval, ) def set_slashing_config( @@ -329,6 +574,7 @@ def set_slashing_config( _outlier_slashing_threshold: int, _outlier_detection_threshold: int, _base_slashing_rate: int, + _slashing_rate_cap: int, ) -> contract.ContractFunction: """Binding for `setSlashingConfig` on the Oracle contract. @@ -339,6 +585,7 @@ def set_slashing_config( _outlier_slashing_threshold : int _outlier_detection_threshold : int _base_slashing_rate : int + _slashing_rate_cap : int Returns ------- @@ -349,6 +596,7 @@ def set_slashing_config( _outlier_slashing_threshold, _outlier_detection_threshold, _base_slashing_rate, + _slashing_rate_cap, ) def set_symbols( @@ -380,7 +628,8 @@ def set_vote_period( ) -> contract.ContractFunction: """Binding for `setVotePeriod` on the Oracle contract. - Setter for the vote period. + Setter for the vote period, new vote period will be applied at the end of the + round. Parameters ---------- @@ -395,99 +644,6 @@ def set_vote_period( _vote_period, ) - 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 update_voters( - self, - ) -> contract.ContractFunction: - """Binding for `updateVoters` on the Oracle contract. - - Called when the previous round is ended. Updates the voter info for new voters. - - Returns - ------- - web3.contract.contract.ContractFunction - A contract function instance to be sent in a transaction. - """ - return self._contract.functions.updateVoters() - - def voter_info( - self, - key0: eth_typing.ChecksumAddress, - ) -> typing.Tuple[int, int, int, bool, bool]: - """Binding for `voterInfo` on the Oracle contract. - - Parameters - ---------- - key0 : eth_typing.ChecksumAddress - - Returns - ------- - int - int - int - bool - bool - """ - return_value = self._contract.functions.voterInfo( - key0, - ).call() - return ( - int(return_value[0]), - int(return_value[1]), - int(return_value[2]), - bool(return_value[3]), - bool(return_value[4]), - ) - - def voter_treasuries( - self, - key0: eth_typing.ChecksumAddress, - ) -> eth_typing.ChecksumAddress: - """Binding for `voterTreasuries` on the Oracle contract. - - Parameters - ---------- - key0 : eth_typing.ChecksumAddress - - Returns - ------- - eth_typing.ChecksumAddress - """ - return_value = self._contract.functions.voterTreasuries( - key0, - ).call() - return eth_typing.ChecksumAddress(return_value) - - def voter_validators( - self, - key0: eth_typing.ChecksumAddress, - ) -> eth_typing.ChecksumAddress: - """Binding for `voterValidators` on the Oracle contract. - - Parameters - ---------- - key0 : eth_typing.ChecksumAddress - - Returns - ------- - eth_typing.ChecksumAddress - """ - return_value = self._contract.functions.voterValidators( - key0, - ).call() - return eth_typing.ChecksumAddress(return_value) - ABI = typing.cast( eth_typing.ABI, @@ -509,7 +665,7 @@ def voter_validators( { "components": [ { - "internalType": "contract Autonity", + "internalType": "contract IAutonity", "name": "autonity", "type": "address", }, @@ -538,18 +694,64 @@ def voter_validators( "name": "baseSlashingRate", "type": "uint256", }, - ], - "internalType": "struct Oracle.Config", - "name": "_config", - "type": "tuple", - }, - ], + { + "internalType": "uint256", + "name": "nonRevealThreshold", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "revealResetInterval", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "slashingRateCap", + "type": "uint256", + }, + ], + "internalType": "struct Oracle.Config", + "name": "_config", + "type": "tuple", + }, + ], "stateMutability": "nonpayable", "type": "constructor", }, { "anonymous": False, "inputs": [ + { + "indexed": False, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": False, + "internalType": "string", + "name": "methodSignature", + "type": "string", + }, + { + "indexed": False, + "internalType": "bytes", + "name": "returnData", + "type": "bytes", + }, + ], + "name": "CallFailed", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "_voter", + "type": "address", + }, { "indexed": False, "internalType": "uint256", @@ -559,7 +761,181 @@ def voter_validators( { "indexed": False, "internalType": "uint256", - "name": "_height", + "name": "_nonRevealCount", + "type": "uint256", + }, + ], + "name": "CommitRevealMissed", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "address", + "name": "oldValue", + "type": "address", + }, + { + "indexed": False, + "internalType": "address", + "name": "newValue", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateAddress", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "bool", + "name": "oldValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "bool", + "name": "newValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateBool", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "int256", + "name": "oldValue", + "type": "int256", + }, + { + "indexed": False, + "internalType": "int256", + "name": "newValue", + "type": "int256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateInt", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "oldValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "newValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateUint", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "cause", + "type": "string", + }, + { + "indexed": True, + "internalType": "address", + "name": "reporter", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "expValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "actualValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint8", + "name": "extra", + "type": "uint8", + }, + ], + "name": "InvalidVote", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "_round", "type": "uint256", }, { @@ -597,6 +973,50 @@ def voter_validators( "name": "NewSymbols", "type": "event", }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "address", + "name": "reporter", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint8", + "name": "extra", + "type": "uint8", + }, + ], + "name": "NewVoter", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "_voter", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "_round", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "_missedReveal", + "type": "uint256", + }, + ], + "name": "NoRevealPenalty", + "type": "event", + }, { "anonymous": False, "inputs": [ @@ -606,6 +1026,12 @@ def voter_validators( "name": "_participant", "type": "address", }, + { + "indexed": False, + "internalType": "uint256", + "name": "_slashingAmount", + "type": "uint256", + }, { "indexed": False, "internalType": "string", @@ -631,53 +1057,79 @@ def voter_validators( { "anonymous": False, "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "price", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "round", + "type": "uint256", + }, { "indexed": True, - "internalType": "address", - "name": "_voter", - "type": "address", + "internalType": "string", + "name": "symbol", + "type": "string", }, { "indexed": False, - "internalType": "int256[]", - "name": "_votes", - "type": "int256[]", + "internalType": "bool", + "name": "status", + "type": "bool", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256", }, ], - "name": "Voted", + "name": "PriceUpdated", "type": "event", }, - {"stateMutability": "payable", "type": "fallback"}, { - "inputs": [], - "name": "config", - "outputs": [ + "anonymous": False, + "inputs": [ { - "internalType": "contract Autonity", - "name": "autonity", + "indexed": True, + "internalType": "address", + "name": "reporter", "type": "address", }, - {"internalType": "address", "name": "operator", "type": "address"}, - {"internalType": "uint256", "name": "votePeriod", "type": "uint256"}, { - "internalType": "int256", - "name": "outlierDetectionThreshold", - "type": "int256", + "indexed": False, + "internalType": "uint8", + "name": "extra", + "type": "uint8", }, + ], + "name": "SuccessfulVote", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ { - "internalType": "int256", - "name": "outlierSlashingThreshold", - "type": "int256", + "indexed": False, + "internalType": "uint256", + "name": "ntnReward", + "type": "uint256", }, { + "indexed": False, "internalType": "uint256", - "name": "baseSlashingRate", + "name": "atnReward", "type": "uint256", }, ], - "stateMutability": "view", - "type": "function", + "name": "TotalOracleRewards", + "type": "event", }, + {"stateMutability": "payable", "type": "fallback"}, { "inputs": [{"internalType": "uint256", "name": "_ntn", "type": "uint256"}], "name": "distributeRewards", @@ -692,10 +1144,84 @@ def voter_validators( "stateMutability": "nonpayable", "type": "function", }, + { + "inputs": [], + "name": "getConfig", + "outputs": [ + { + "components": [ + { + "internalType": "contract IAutonity", + "name": "autonity", + "type": "address", + }, + { + "internalType": "address", + "name": "operator", + "type": "address", + }, + { + "internalType": "uint256", + "name": "votePeriod", + "type": "uint256", + }, + { + "internalType": "int256", + "name": "outlierDetectionThreshold", + "type": "int256", + }, + { + "internalType": "int256", + "name": "outlierSlashingThreshold", + "type": "int256", + }, + { + "internalType": "uint256", + "name": "baseSlashingRate", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "nonRevealThreshold", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "revealResetInterval", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "slashingRateCap", + "type": "uint256", + }, + ], + "internalType": "struct Oracle.Config", + "name": "", + "type": "tuple", + } + ], + "stateMutability": "view", + "type": "function", + }, { "inputs": [], "name": "getDecimals", "outputs": [{"internalType": "uint8", "name": "", "type": "uint8"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [], + "name": "getLastRoundBlock", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getNewVotePeriod", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, @@ -706,6 +1232,37 @@ def voter_validators( "stateMutability": "view", "type": "function", }, + { + "inputs": [], + "name": "getNonRevealThreshold", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "string", "name": "_symbol", "type": "string"}, + {"internalType": "address", "name": "_voter", "type": "address"}, + ], + "name": "getReports", + "outputs": [ + { + "components": [ + {"internalType": "uint120", "name": "price", "type": "uint120"}, + { + "internalType": "uint8", + "name": "confidence", + "type": "uint8", + }, + ], + "internalType": "struct IOracle.Report", + "name": "", + "type": "tuple", + } + ], + "stateMutability": "view", + "type": "function", + }, { "inputs": [ {"internalType": "address", "name": "_voter", "type": "address"} @@ -748,6 +1305,13 @@ def voter_validators( "stateMutability": "view", "type": "function", }, + { + "inputs": [], + "name": "getSymbolUpdatedRound", + "outputs": [{"internalType": "int256", "name": "", "type": "int256"}], + "stateMutability": "view", + "type": "function", + }, { "inputs": [], "name": "getSymbols", @@ -763,16 +1327,66 @@ def voter_validators( "type": "function", }, { - "inputs": [], - "name": "getVoters", - "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], + "inputs": [ + {"internalType": "address", "name": "_voter", "type": "address"} + ], + "name": "getVoterInfo", + "outputs": [ + { + "components": [ + {"internalType": "uint256", "name": "round", "type": "uint256"}, + { + "internalType": "uint256", + "name": "commit", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "performance", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "nonRevealCount", + "type": "uint256", + }, + {"internalType": "bool", "name": "isVoter", "type": "bool"}, + { + "internalType": "bool", + "name": "reportAvailable", + "type": "bool", + }, + ], + "internalType": "struct Oracle.VoterInfo", + "name": "", + "type": "tuple", + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_oracleAddress", "type": "address"} + ], + "name": "getVoterTreasuries", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_oracleAddress", "type": "address"} + ], + "name": "getVoterValidators", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function", }, { "inputs": [], - "name": "lastRoundBlock", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "getVoters", + "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], "stateMutability": "view", "type": "function", }, @@ -801,15 +1415,16 @@ def voter_validators( }, { "inputs": [ - {"internalType": "string", "name": "", "type": "string"}, - {"internalType": "address", "name": "", "type": "address"}, - ], - "name": "reports", - "outputs": [ - {"internalType": "uint120", "name": "price", "type": "uint120"}, - {"internalType": "uint8", "name": "confidence", "type": "uint8"}, + {"internalType": "uint256", "name": "_threshold", "type": "uint256"}, + { + "internalType": "uint256", + "name": "_resetInterval", + "type": "uint256", + }, ], - "stateMutability": "view", + "name": "setCommitRevealConfig", + "outputs": [], + "stateMutability": "nonpayable", "type": "function", }, { @@ -838,6 +1453,11 @@ def voter_validators( "name": "_baseSlashingRate", "type": "uint256", }, + { + "internalType": "uint256", + "name": "_slashingRateCap", + "type": "uint256", + }, ], "name": "setSlashingConfig", "outputs": [], @@ -883,14 +1503,7 @@ def voter_validators( }, { "inputs": [], - "name": "symbolUpdatedRound", - "outputs": [{"internalType": "int256", "name": "", "type": "int256"}], - "stateMutability": "view", - "type": "function", - }, - { - "inputs": [], - "name": "updateVoters", + "name": "updateVotersAndSymbol", "outputs": [], "stateMutability": "nonpayable", "type": "function", @@ -919,33 +1532,6 @@ def voter_validators( "stateMutability": "nonpayable", "type": "function", }, - { - "inputs": [{"internalType": "address", "name": "", "type": "address"}], - "name": "voterInfo", - "outputs": [ - {"internalType": "uint256", "name": "round", "type": "uint256"}, - {"internalType": "uint256", "name": "commit", "type": "uint256"}, - {"internalType": "uint256", "name": "performance", "type": "uint256"}, - {"internalType": "bool", "name": "isVoter", "type": "bool"}, - {"internalType": "bool", "name": "reportAvailable", "type": "bool"}, - ], - "stateMutability": "view", - "type": "function", - }, - { - "inputs": [{"internalType": "address", "name": "", "type": "address"}], - "name": "voterTreasuries", - "outputs": [{"internalType": "address", "name": "", "type": "address"}], - "stateMutability": "view", - "type": "function", - }, - { - "inputs": [{"internalType": "address", "name": "", "type": "address"}], - "name": "voterValidators", - "outputs": [{"internalType": "address", "name": "", "type": "address"}], - "stateMutability": "view", - "type": "function", - }, {"stateMutability": "payable", "type": "receive"}, ], ) diff --git a/autonity/contracts/stabilization.py b/autonity/contracts/stabilization.py index b9e94df..0cc1e7b 100644 --- a/autonity/contracts/stabilization.py +++ b/autonity/contracts/stabilization.py @@ -1,27 +1,51 @@ """Stabilization contract binding and data structures.""" -# This module has been generated using pyabigen v0.2.12 +# This module has been generated using pyabigen v0.2.15 import typing from dataclasses import dataclass import eth_typing import web3 -from plum import dispatch from web3.contract import contract -__version__ = "v1.0.2-alpha" +__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" @dataclass class Config: - """Port of `struct Config` on the Stabilization contract.""" + """Port of `struct Config` on the IStabilization contract.""" borrow_interest_rate: int + announcement_window: int liquidation_ratio: int min_collateralization_ratio: int min_debt_requirement: int target_price: int + default_ntnatn_price: int + default_ntnusd_price: int + default_acuusd_price: int + + +@dataclass +class CDP: + """Port of `struct CDP` on the IStabilization contract.""" + + timestamp: int + collateral: int + principal: int + interest: int + last_aggregated_interest_exponent: int + + +@dataclass +class LastUpdated: + """Port of `struct LastUpdated` on the IStabilization contract.""" + + borrow_interest_rate_timestamp: int + announcement_window_timestamp: int + liquidation_ratio_timestamp: int + min_collateralization_ratio_timestamp: int class Stabilization: @@ -48,6 +72,14 @@ def __init__( abi=ABI, ) + @property + def AnnouncementWindowUpdateAnnounced(self) -> contract.ContractEvent: + """Binding for `event AnnouncementWindowUpdateAnnounced` on the Stabilization contract. + + Announcement that the announcement window is going to be updated + """ + return self._contract.events.AnnouncementWindowUpdateAnnounced + @property def Borrow(self) -> contract.ContractEvent: """Binding for `event Borrow` on the Stabilization contract. @@ -56,6 +88,38 @@ def Borrow(self) -> contract.ContractEvent: """ return self._contract.events.Borrow + @property + def CDPRestrictionsRemoved(self) -> contract.ContractEvent: + """Binding for `event CDPRestrictionsRemoved` on the Stabilization contract. + + Transition out of the initial CDP restrictions + """ + return self._contract.events.CDPRestrictionsRemoved + + @property + def ConfigUpdateAddress(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateAddress` on the Stabilization contract. + + Emitted after updating config parameter of type address + """ + return self._contract.events.ConfigUpdateAddress + + @property + def ConfigUpdateBool(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateBool` on the Stabilization contract. + + Emitted after updating config parameter of type boolean + """ + return self._contract.events.ConfigUpdateBool + + @property + def ConfigUpdateUint(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateUint` on the Stabilization contract. + + Emitted after updating config parameter of type uint + """ + return self._contract.events.ConfigUpdateUint + @property def Deposit(self) -> contract.ContractEvent: """Binding for `event Deposit` on the Stabilization contract. @@ -64,6 +128,14 @@ def Deposit(self) -> contract.ContractEvent: """ return self._contract.events.Deposit + @property + def InterestRateUpdateAnnounced(self) -> contract.ContractEvent: + """Binding for `event InterestRateUpdateAnnounced` on the Stabilization contract. + + It is announced that borrow interest rate is going to be updated. + """ + return self._contract.events.InterestRateUpdateAnnounced + @property def Liquidate(self) -> contract.ContractEvent: """Binding for `event Liquidate` on the Stabilization contract. @@ -72,6 +144,22 @@ def Liquidate(self) -> contract.ContractEvent: """ return self._contract.events.Liquidate + @property + def LiquidationRatioUpdateAnnounced(self) -> contract.ContractEvent: + """Binding for `event LiquidationRatioUpdateAnnounced` on the Stabilization contract. + + Announcement that the liquidation ratio is going to be updated + """ + return self._contract.events.LiquidationRatioUpdateAnnounced + + @property + def MinCollateralizationRatioUpdateAnnounced(self) -> contract.ContractEvent: + """Binding for `event MinCollateralizationRatioUpdateAnnounced` on the Stabilization contract. + + Announcement that the min collateralization ratio is going to be updated + """ + return self._contract.events.MinCollateralizationRatioUpdateAnnounced + @property def Repay(self) -> contract.ContractEvent: """Binding for `event Repay` on the Stabilization contract. @@ -88,48 +176,6 @@ def Withdraw(self) -> contract.ContractEvent: """ 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]: @@ -148,6 +194,22 @@ def accounts( for return_value_elem in return_value ] + def acu_price( + self, + ) -> int: + """Binding for `acuPrice` on the Stabilization contract. + + Price the ACU value in USD. Retrieves the ACU value from the ACU Contract and + converts it to have StabilizationMath.SCALE_FACTOR precision. + + Returns + ------- + int + Price of ACU value + """ + return_value = self._contract.functions.acuPrice().call() + return int(return_value) + def borrow( self, amount: int, @@ -175,65 +237,58 @@ def borrow( def borrow_limit( self, collateral: int, - price: int, - target_price: int, + collateral_price_acu: int, + target_price_acu: 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 + collateral_price_acu : int + target_price_acu : 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, + collateral_price_acu, + target_price_acu, mcr, ).call() return int(return_value) def cdps( self, - key0: eth_typing.ChecksumAddress, - ) -> typing.Tuple[int, int, int, int]: + owner: eth_typing.ChecksumAddress, + ) -> CDP: """Binding for `cdps` on the Stabilization contract. - A mapping to retrieve the CDP for an account address. + Retrieve the CDP for an account address. Parameters ---------- - key0 : eth_typing.ChecksumAddress + owner : eth_typing.ChecksumAddress + The CDP account address Returns ------- - int - int - int - int + CDP + The CDP object """ return_value = self._contract.functions.cdps( - key0, + owner, ).call() - return ( + return CDP( int(return_value[0]), int(return_value[1]), int(return_value[2]), int(return_value[3]), + int(return_value[4]), ) def collateral_price( @@ -252,16 +307,33 @@ def collateral_price( return_value = self._contract.functions.collateralPrice().call() return int(return_value) + def collateral_price_acu( + self, + ) -> int: + """Binding for `collateralPriceACU` on the Stabilization contract. + + Price the Collateral Token in ACU Retrieves the Collateral Token price from the + Oracle Contract in USD and converts it to ACU + + Returns + ------- + int + price Price of Collateral Token in ACU + """ + return_value = self._contract.functions.collateralPriceACU().call() + return int(return_value) + def config( self, ) -> Config: """Binding for `config` on the Stabilization contract. - The Config object that stores Stabilization Contract parameters. + Retrieve the current Stabilization configuration. Returns ------- Config + The Stabilization configuration """ return_value = self._contract.functions.config().call() return Config( @@ -270,26 +342,24 @@ def config( int(return_value[2]), int(return_value[3]), int(return_value[4]), + int(return_value[5]), + int(return_value[6]), + int(return_value[7]), + int(return_value[8]), ) - @dispatch # type: ignore - def debt_amount( # type: ignore # noqa: F811 + def debt_amount( 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. + Calculate the current debt amount outstanding for a CDP. Parameters ---------- account : eth_typing.ChecksumAddress The CDP account address - timestamp : int - The timestamp to value the debt Returns ------- @@ -298,31 +368,35 @@ def debt_amount( # type: ignore # noqa: F811 """ return_value = self._contract.functions.debtAmount( account, - timestamp, ).call() return int(return_value) - @dispatch # type: ignore - def debt_amount( # type: ignore # noqa: F811 + def debt_amount_at_time( self, account: eth_typing.ChecksumAddress, + timestamp: int, ) -> int: - """Binding for `debtAmount` on the Stabilization contract. + """Binding for `debtAmountAtTime` on the Stabilization contract. - Calculate the current debt amount outstanding for a CDP. + 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( + return_value = self._contract.functions.debtAmountAtTime( account, + timestamp, ).call() return int(return_value) @@ -350,257 +424,455 @@ def deposit( amount, ) - def interest_due( + def get_aggregated_interest_exponent( self, - debt: int, - rate: int, - time_borrow: int, - time_due: int, ) -> int: - """Binding for `interestDue` on the Stabilization contract. + """Binding for `getAggregatedInterestExponent` 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 + Get aggregated interest exponent which is the summation of all interest rate + multiplied by their respective time window (in years). 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_value = self._contract.functions.getAggregatedInterestExponent().call() return int(return_value) - def is_liquidatable( + def get_announcement_window( self, - account: eth_typing.ChecksumAddress, - ) -> bool: - """Binding for `isLiquidatable` on the Stabilization contract. - - Determine if the CDP is currently liquidatable. + ) -> int: + """Binding for `getAnnouncementWindow` on the Stabilization contract. - Parameters - ---------- - account : eth_typing.ChecksumAddress - The CDP account address + Get the announcement window in seconds. Returns ------- - bool - Whether the CDP is liquidatable + int """ - return_value = self._contract.functions.isLiquidatable( - account, - ).call() - return bool(return_value) + return_value = self._contract.functions.getAnnouncementWindow().call() + return int(return_value) - def liquidate( + def get_current_rate( 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. + ) -> int: + """Binding for `getCurrentRate` on the Stabilization contract. - Parameters - ---------- - account : eth_typing.ChecksumAddress - The CDP account address to liquidate + Get the active current rate. Returns ------- - web3.contract.contract.ContractFunction - A contract function instance to be sent in a transaction. + int """ - return self._contract.functions.liquidate( - account, - ) + return_value = self._contract.functions.getCurrentRate().call() + return int(return_value) - def minimum_collateral( + def get_current_rate_active_timestamp( 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. + """Binding for `getCurrentRateActiveTimestamp` on the Stabilization contract. - Parameters - ---------- - principal : int - Auton amount to borrow - price : int - The price of Collateral Token in Auton - mcr : int - The minimum collateralization ratio + Get the timestamp since when the current rate is active. Returns ------- int - The minimum Collateral Token amount required """ - return_value = self._contract.functions.minimumCollateral( - principal, - price, - mcr, - ).call() + return_value = self._contract.functions.getCurrentRateActiveTimestamp().call() return int(return_value) - def remove_cdp_restrictions( + def get_pending_announcement_window_info( self, - ) -> contract.ContractFunction: - """Binding for `removeCDPRestrictions` on the Stabilization contract. + ) -> typing.Tuple[int, int]: + """Binding for `getPendingAnnouncementWindowInfo` on the Stabilization contract. - Transition out of the restricted state. + Get the pending announcement window and since when it will be active. Returns ------- - web3.contract.contract.ContractFunction - A contract function instance to be sent in a transaction. + int + uint256 The pending announcement window + int + uint256 The timestamp since the pending announcement window will be active """ - return self._contract.functions.removeCDPRestrictions() + return_value = ( + self._contract.functions.getPendingAnnouncementWindowInfo().call() + ) + return ( + int(return_value[0]), + int(return_value[1]), + ) - def repay( + def get_pending_interest_rate_info( self, - ) -> contract.ContractFunction: - """Binding for `repay` on the Stabilization contract. + ) -> typing.Tuple[int, int]: + """Binding for `getPendingInterestRateInfo` 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. + Get the pending borrow interest rate and since when it will be active. Returns ------- - web3.contract.contract.ContractFunction - A contract function instance to be sent in a transaction. + int + uint256 The pending rate + int + uint256 The timestamp since it will be active """ - return self._contract.functions.repay() + return_value = self._contract.functions.getPendingInterestRateInfo().call() + return ( + int(return_value[0]), + int(return_value[1]), + ) - def set_atn_supply_operator( + def get_pending_liquidation_ratio_info( self, - atn_supply_operator: eth_typing.ChecksumAddress, - ) -> contract.ContractFunction: - """Binding for `setAtnSupplyOperator` on the Stabilization contract. - - Set the _atnSupplyOperator address. + ) -> typing.Tuple[int, int]: + """Binding for `getPendingLiquidationRatioInfo` on the Stabilization contract. - Parameters - ---------- - atn_supply_operator : eth_typing.ChecksumAddress + Get the pending liquidation ratio and since when it will be active. Returns ------- - web3.contract.contract.ContractFunction - A contract function instance to be sent in a transaction. + int + uint256 The pending liquidation ratio + int + uint256 The timestamp since the pending liquidation ratio will be active """ - return self._contract.functions.setAtnSupplyOperator( - atn_supply_operator, + return_value = self._contract.functions.getPendingLiquidationRatioInfo().call() + return ( + int(return_value[0]), + int(return_value[1]), ) - def set_liquidation_ratio( + def get_pending_min_collateralization_ratio_info( self, - ratio: int, - ) -> contract.ContractFunction: - """Binding for `setLiquidationRatio` on the Stabilization contract. + ) -> typing.Tuple[int, int]: + """Binding for `getPendingMinCollateralizationRatioInfo` on the Stabilization contract. - Set the liquidation ratio. Must be less than the minimum collateralization - ratio. - - Parameters - ---------- - ratio : int - The liquidation ratio + Get the pending min collateralization ratio and since when it will be active. Returns ------- - web3.contract.contract.ContractFunction - A contract function instance to be sent in a transaction. + int + uint256 The pending min collateralization ratio + int + uint256 The timestamp since the pending min collateralization ratio will be + active """ - return self._contract.functions.setLiquidationRatio( - ratio, + return_value = ( + self._contract.functions.getPendingMinCollateralizationRatioInfo().call() + ) + return ( + int(return_value[0]), + int(return_value[1]), ) - def set_min_collateralization_ratio( + def interest_due( 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. + debt: int, + rate_exponent: int, + ) -> int: + """Binding for `interestDue` on the Stabilization contract. Parameters ---------- - ratio : int - The minimum collateralization ratio + debt : int + rate_exponent : int Returns ------- - web3.contract.contract.ContractFunction - A contract function instance to be sent in a transaction. + int """ - return self._contract.functions.setMinCollateralizationRatio( - ratio, - ) + return_value = self._contract.functions.interestDue( + debt, + rate_exponent, + ).call() + return int(return_value) - def set_min_debt_requirement( + def interest_exponent( self, - amount: int, - ) -> contract.ContractFunction: - """Binding for `setMinDebtRequirement` on the Stabilization contract. + interest_rate: int, + start_timestamp: int, + end_timestamp: int, + ) -> int: + """Binding for `interestExponent` on the Stabilization contract. - Set the minimum debt requirement. + Parameters + ---------- + interest_rate : int + start_timestamp : int + end_timestamp : int + + Returns + ------- + int + """ + return_value = self._contract.functions.interestExponent( + interest_rate, + start_timestamp, + end_timestamp, + ).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 ---------- - amount : int - The minimum debt amount + 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 last_updated( + self, + ) -> LastUpdated: + """Binding for `lastUpdated` on the Stabilization contract. + + Get the last updated timestamp of the updatable config parameters + + Returns + ------- + LastUpdated + LastUpdated The last updated timestamps + """ + return_value = self._contract.functions.lastUpdated().call() + return LastUpdated( + int(return_value[0]), + int(return_value[1]), + int(return_value[2]), + int(return_value[3]), + ) + + def liquidation_ratio( + self, + ) -> int: + """Binding for `liquidationRatio` on the Stabilization contract. + + Get the liquidation ratio. + + Returns + ------- + int + uint256 The liquidation ratio + """ + return_value = self._contract.functions.liquidationRatio().call() + return int(return_value) + + def max_borrow( + self, + collateral: int, + ) -> int: + """Binding for `maxBorrow` on the Stabilization contract. + + Calculate the maximum amount that can be borrowed against the collateral. Note + that this takes into account the minimum collateralization ratio or the max + borrow limit, whichever is lower will determine the max borrow + + Parameters + ---------- + collateral : int + The amount of Collateral Token + + Returns + ------- + int + The maximum borrow amount + """ + return_value = self._contract.functions.maxBorrow( + collateral, + ).call() + return int(return_value) + + def min_collateralization_ratio( + self, + ) -> int: + """Binding for `minCollateralizationRatio` on the Stabilization contract. + + Get the min collateralization ratio. + + Returns + ------- + int + uint256 The pending min collateralization ratio + """ + return_value = self._contract.functions.minCollateralizationRatio().call() + return int(return_value) + + def minimum_collateral( + self, + principal: int, + collateral_price_acu: int, + target_price_acu: int, + mcr: int, + ) -> int: + """Binding for `minimumCollateral` on the Stabilization contract. + + Parameters + ---------- + principal : int + collateral_price_acu : int + target_price_acu : int + mcr : int + + Returns + ------- + int + """ + return_value = self._contract.functions.minimumCollateral( + principal, + collateral_price_acu, + target_price_acu, + mcr, + ).call() + return int(return_value) + + def remove_cdp_restrictions( + self, + ) -> contract.ContractFunction: + """Binding for `removeCDPRestrictions` on the Stabilization contract. + + Transition out of the restricted state. Returns ------- web3.contract.contract.ContractFunction A contract function instance to be sent in a transaction. """ - return self._contract.functions.setMinDebtRequirement( - amount, + return self._contract.functions.removeCDPRestrictions() + + 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_atn_supply_operator( + self, + atn_supply_operator: eth_typing.ChecksumAddress, + ) -> contract.ContractFunction: + """Binding for `setAtnSupplyOperator` on the Stabilization contract. + + Set the _atnSupplyOperator address. + + Parameters + ---------- + atn_supply_operator : eth_typing.ChecksumAddress + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setAtnSupplyOperator( + atn_supply_operator, + ) + + def set_default_acuusd_price( + self, + default_acuusd_price: int, + ) -> contract.ContractFunction: + """Binding for `setDefaultACUUSDPrice` on the Stabilization contract. + + Set the default ACU-USD price for use when fixed prices are enabled. + + Parameters + ---------- + default_acuusd_price : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setDefaultACUUSDPrice( + default_acuusd_price, + ) + + def set_default_ntnatn_price( + self, + default_ntnatn_price: int, + ) -> contract.ContractFunction: + """Binding for `setDefaultNTNATNPrice` on the Stabilization contract. + + Set the default NTN-ATN price for use when fixed prices are enabled. + + Parameters + ---------- + default_ntnatn_price : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setDefaultNTNATNPrice( + default_ntnatn_price, + ) + + def set_default_ntnusd_price( + self, + default_ntnusd_price: int, + ) -> contract.ContractFunction: + """Binding for `setDefaultNTNUSDPrice` on the Stabilization contract. + + Set the default NTN-USD price for use when fixed prices are enabled. + + Parameters + ---------- + default_ntnusd_price : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setDefaultNTNUSDPrice( + default_ntnusd_price, ) - def set_supply_control( + def set_min_debt_requirement( self, - supply_control: eth_typing.ChecksumAddress, + amount: int, ) -> contract.ContractFunction: - """Binding for `setSupplyControl` on the Stabilization contract. + """Binding for `setMinDebtRequirement` on the Stabilization contract. - Set the SupplyControl Contract address. + Set the minimum debt requirement. Parameters ---------- - supply_control : eth_typing.ChecksumAddress + 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.setSupplyControl( - supply_control, + return self._contract.functions.setMinDebtRequirement( + amount, ) def under_collateralized( @@ -612,22 +884,16 @@ def under_collateralized( ) -> 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, @@ -637,74 +903,186 @@ def under_collateralized( ).call() return bool(return_value) - def withdraw( + def update_announcement_window( self, - amount: int, + window: int, ) -> contract.ContractFunction: - """Binding for `withdraw` on the Stabilization contract. + """Binding for `updateAnnouncementWindow` 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. + Updates the announcement window. The new window `window` will take affect after + the `config.announcementWindow` (in seconds). It requires that there is no + announcement window in pending. Parameters ---------- - amount : int - Units of Collateral Token to withdraw + window : int Returns ------- web3.contract.contract.ContractFunction A contract function instance to be sent in a transaction. """ - return self._contract.functions.withdraw( - amount, + return self._contract.functions.updateAnnouncementWindow( + window, ) + def update_borrow_interest_rate( + self, + new_interest_rate: int, + ) -> contract.ContractFunction: + """Binding for `updateBorrowInterestRate` on the Stabilization contract. -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", + Updates the borrow interest rate. The new rate `newInterestRate` will take + affect after the `config.announcementWindow` (in seconds). + + Parameters + ---------- + new_interest_rate : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.updateBorrowInterestRate( + new_interest_rate, + ) + + def update_ratios( + self, + new_liquidation_ratio: int, + new_min_collateralization_ratio: int, + ) -> contract.ContractFunction: + """Binding for `updateRatios` on the Stabilization contract. + + Updates min collateralization ratio and liquidation ratio. + + Parameters + ---------- + new_liquidation_ratio : int + new_min_collateralization_ratio : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.updateRatios( + new_liquidation_ratio, + new_min_collateralization_ratio, + ) + + def use_fixed_genesis_prices( + self, + use_fixed: bool, + ) -> contract.ContractFunction: + """Binding for `useFixedGenesisPrices` on the Stabilization contract. + + Toggle the use of the fixed genesis price state. + + Parameters + ---------- + use_fixed : bool + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.useFixedGenesisPrices( + use_fixed, + ) + + 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": "announcementWindow", + "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": "uint256", + "name": "defaultNTNATNPrice", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "defaultNTNUSDPrice", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "defaultACUUSDPrice", + "type": "uint256", + }, + ], + "internalType": "struct IStabilization.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": "address", "name": "auctioneer", "type": "address"}, + {"internalType": "address", "name": "acu", "type": "address"}, + { + "internalType": "contract IERC20", "name": "collateralToken", "type": "address", }, @@ -712,16 +1090,22 @@ def withdraw( "stateMutability": "nonpayable", "type": "constructor", }, + {"inputs": [], "name": "AnnouncementWindowPending", "type": "error"}, {"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": [{"internalType": "string", "name": "message", "type": "string"}], + "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": [], "name": "NotRestricted", "type": "error"}, { "inputs": [ {"internalType": "uint256", "name": "x", "type": "uint256"}, @@ -730,15 +1114,6 @@ def withdraw( "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", @@ -749,10 +1124,39 @@ def withdraw( "name": "PRBMath_UD60x18_Exp_InputTooBig", "type": "error", }, - {"inputs": [], "name": "PriceUnavailable", "type": "error"}, + { + "inputs": [{"internalType": "string", "name": "symbol", "type": "string"}], + "name": "PriceUnavailable", + "type": "error", + }, {"inputs": [], "name": "TransferFailed", "type": "error"}, {"inputs": [], "name": "Unauthorized", "type": "error"}, {"inputs": [], "name": "ZeroValue", "type": "error"}, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "newAnnouncementWindow", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "activeSince", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "bool", + "name": "pendingWindowOverridden", + "type": "bool", + }, + ], + "name": "AnnouncementWindowUpdateAnnounced", + "type": "event", + }, { "anonymous": False, "inputs": [ @@ -772,6 +1176,105 @@ def withdraw( "name": "Borrow", "type": "event", }, + { + "anonymous": False, + "inputs": [], + "name": "CDPRestrictionsRemoved", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "address", + "name": "oldValue", + "type": "address", + }, + { + "indexed": False, + "internalType": "address", + "name": "newValue", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateAddress", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "bool", + "name": "oldValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "bool", + "name": "newValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateBool", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "oldValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "newValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateUint", + "type": "event", + }, { "anonymous": False, "inputs": [ @@ -791,6 +1294,31 @@ def withdraw( "name": "Deposit", "type": "event", }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "newRate", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "activeSince", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "bool", + "name": "pendingRateOverridden", + "type": "bool", + }, + ], + "name": "InterestRateUpdateAnnounced", + "type": "event", + }, { "anonymous": False, "inputs": [ @@ -807,208 +1335,474 @@ def withdraw( "type": "address", }, ], - "name": "Liquidate", - "type": "event", + "name": "Liquidate", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "newRatio", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "activeSince", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "bool", + "name": "pendingRatioOverridden", + "type": "bool", + }, + ], + "name": "LiquidationRatioUpdateAnnounced", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "newRatio", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "activeSince", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "bool", + "name": "pendingRatioOverridden", + "type": "bool", + }, + ], + "name": "MinCollateralizationRatioUpdateAnnounced", + "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": "accounts", + "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "acuPrice", + "outputs": [ + {"internalType": "uint256", "name": "price", "type": "uint256"} + ], + "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": "collateralPriceACU", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "targetPriceACU", + "type": "uint256", + }, + {"internalType": "uint256", "name": "mcr", "type": "uint256"}, + ], + "name": "borrowLimit", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [{"internalType": "address", "name": "owner", "type": "address"}], + "name": "cdps", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "collateral", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "principal", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "interest", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "lastAggregatedInterestExponent", + "type": "uint256", + }, + ], + "internalType": "struct IStabilization.CDP", + "name": "", + "type": "tuple", + } + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "collateralPrice", + "outputs": [ + {"internalType": "uint256", "name": "price", "type": "uint256"} + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "collateralPriceACU", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "config", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "borrowInterestRate", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "announcementWindow", + "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": "uint256", + "name": "defaultNTNATNPrice", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "defaultNTNUSDPrice", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "defaultACUUSDPrice", + "type": "uint256", + }, + ], + "internalType": "struct IStabilization.Config", + "name": "", + "type": "tuple", + } + ], + "stateMutability": "view", + "type": "function", }, { - "anonymous": False, "inputs": [ - { - "indexed": True, - "internalType": "address", - "name": "account", - "type": "address", - }, - { - "indexed": False, - "internalType": "uint256", - "name": "amount", - "type": "uint256", - }, + {"internalType": "address", "name": "account", "type": "address"} ], - "name": "Repay", - "type": "event", + "name": "debtAmount", + "outputs": [{"internalType": "uint256", "name": "debt", "type": "uint256"}], + "stateMutability": "view", + "type": "function", }, { - "anonymous": False, "inputs": [ - { - "indexed": True, - "internalType": "address", - "name": "account", - "type": "address", - }, - { - "indexed": False, - "internalType": "uint256", - "name": "amount", - "type": "uint256", - }, + {"internalType": "address", "name": "account", "type": "address"}, + {"internalType": "uint256", "name": "timestamp", "type": "uint256"}, ], - "name": "Withdraw", - "type": "event", + "name": "debtAmountAtTime", + "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": [], - "name": "SCALE", + "name": "getAggregatedInterestExponent", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, { "inputs": [], - "name": "SCALE_FACTOR", + "name": "getAnnouncementWindow", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, { "inputs": [], - "name": "SECONDS_IN_YEAR", + "name": "getCurrentRate", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, { "inputs": [], - "name": "accounts", - "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], + "name": "getCurrentRateActiveTimestamp", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, { - "inputs": [ - {"internalType": "uint256", "name": "amount", "type": "uint256"} + "inputs": [], + "name": "getPendingAnnouncementWindowInfo", + "outputs": [ + {"internalType": "uint256", "name": "", "type": "uint256"}, + {"internalType": "uint256", "name": "", "type": "uint256"}, ], - "name": "borrow", - "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "view", "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"}, + "inputs": [], + "name": "getPendingInterestRateInfo", + "outputs": [ + {"internalType": "uint256", "name": "", "type": "uint256"}, + {"internalType": "uint256", "name": "", "type": "uint256"}, ], - "name": "borrowLimit", - "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "stateMutability": "pure", + "stateMutability": "view", "type": "function", }, { - "inputs": [{"internalType": "address", "name": "", "type": "address"}], - "name": "cdps", + "inputs": [], + "name": "getPendingLiquidationRatioInfo", "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"}, + {"internalType": "uint256", "name": "", "type": "uint256"}, + {"internalType": "uint256", "name": "", "type": "uint256"}, ], "stateMutability": "view", "type": "function", }, { "inputs": [], - "name": "collateralPrice", + "name": "getPendingMinCollateralizationRatioInfo", "outputs": [ - {"internalType": "uint256", "name": "price", "type": "uint256"} + {"internalType": "uint256", "name": "", "type": "uint256"}, + {"internalType": "uint256", "name": "", "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", - }, + "inputs": [ + {"internalType": "uint256", "name": "debt", "type": "uint256"}, + {"internalType": "uint256", "name": "rateExponent", "type": "uint256"}, + ], + "name": "interestDue", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "interestRate", "type": "uint256"}, { "internalType": "uint256", - "name": "minDebtRequirement", + "name": "startTimestamp", "type": "uint256", }, - {"internalType": "uint256", "name": "targetPrice", "type": "uint256"}, + {"internalType": "uint256", "name": "endTimestamp", "type": "uint256"}, ], - "stateMutability": "view", + "name": "interestExponent", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "pure", "type": "function", }, { "inputs": [ - {"internalType": "address", "name": "account", "type": "address"}, - {"internalType": "uint256", "name": "timestamp", "type": "uint256"}, + {"internalType": "address", "name": "account", "type": "address"} ], - "name": "debtAmount", - "outputs": [{"internalType": "uint256", "name": "debt", "type": "uint256"}], + "name": "isLiquidatable", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function", }, { - "inputs": [ - {"internalType": "address", "name": "account", "type": "address"} + "inputs": [], + "name": "lastUpdated", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "borrowInterestRateTimestamp", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "announcementWindowTimestamp", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "liquidationRatioTimestamp", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "minCollateralizationRatioTimestamp", + "type": "uint256", + }, + ], + "internalType": "struct IStabilization.LastUpdated", + "name": "", + "type": "tuple", + } ], - "name": "debtAmount", - "outputs": [{"internalType": "uint256", "name": "debt", "type": "uint256"}], "stateMutability": "view", "type": "function", }, { "inputs": [ - {"internalType": "uint256", "name": "amount", "type": "uint256"} + {"internalType": "address", "name": "account", "type": "address"}, + { + "internalType": "uint256", + "name": "collateralSold", + "type": "uint256", + }, + {"internalType": "address", "name": "bidder", "type": "address"}, ], - "name": "deposit", + "name": "liquidate", "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "payable", "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", + "inputs": [], + "name": "liquidationRatio", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], - "stateMutability": "pure", + "stateMutability": "view", "type": "function", }, { "inputs": [ - {"internalType": "address", "name": "account", "type": "address"} + {"internalType": "uint256", "name": "collateral", "type": "uint256"} ], - "name": "isLiquidatable", - "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "name": "maxBorrow", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function", }, { - "inputs": [ - {"internalType": "address", "name": "account", "type": "address"} - ], - "name": "liquidate", - "outputs": [], - "stateMutability": "payable", + "inputs": [], + "name": "minCollateralizationRatio", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", "type": "function", }, { "inputs": [ {"internalType": "uint256", "name": "principal", "type": "uint256"}, - {"internalType": "uint256", "name": "price", "type": "uint256"}, + { + "internalType": "uint256", + "name": "collateralPriceACU", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "targetPriceACU", + "type": "uint256", + }, {"internalType": "uint256", "name": "mcr", "type": "uint256"}, ], "name": "minimumCollateral", @@ -1030,6 +1824,13 @@ def withdraw( "stateMutability": "payable", "type": "function", }, + { + "inputs": [{"internalType": "address", "name": "acu", "type": "address"}], + "name": "setACU", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, { "inputs": [ { @@ -1044,15 +1845,49 @@ def withdraw( "type": "function", }, { - "inputs": [{"internalType": "uint256", "name": "ratio", "type": "uint256"}], - "name": "setLiquidationRatio", + "inputs": [ + {"internalType": "address", "name": "auctioneer", "type": "address"} + ], + "name": "setAuctioneer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "defaultACUUSDPrice", + "type": "uint256", + } + ], + "name": "setDefaultACUUSDPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "defaultNTNATNPrice", + "type": "uint256", + } + ], + "name": "setDefaultNTNATNPrice", "outputs": [], "stateMutability": "nonpayable", "type": "function", }, { - "inputs": [{"internalType": "uint256", "name": "ratio", "type": "uint256"}], - "name": "setMinCollateralizationRatio", + "inputs": [ + { + "internalType": "uint256", + "name": "defaultNTNUSDPrice", + "type": "uint256", + } + ], + "name": "setDefaultNTNUSDPrice", "outputs": [], "stateMutability": "nonpayable", "type": "function", @@ -1109,6 +1944,53 @@ def withdraw( "stateMutability": "pure", "type": "function", }, + { + "inputs": [ + {"internalType": "uint256", "name": "window", "type": "uint256"} + ], + "name": "updateAnnouncementWindow", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newInterestRate", + "type": "uint256", + } + ], + "name": "updateBorrowInterestRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newLiquidationRatio", + "type": "uint256", + }, + { + "internalType": "uint256", + "name": "newMinCollateralizationRatio", + "type": "uint256", + }, + ], + "name": "updateRatios", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [{"internalType": "bool", "name": "useFixed", "type": "bool"}], + "name": "useFixedGenesisPrices", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, { "inputs": [ {"internalType": "uint256", "name": "amount", "type": "uint256"} diff --git a/autonity/contracts/supply_control.py b/autonity/contracts/supply_control.py index 8ea01cc..e6691f4 100644 --- a/autonity/contracts/supply_control.py +++ b/autonity/contracts/supply_control.py @@ -1,6 +1,6 @@ """SupplyControl contract binding and data structures.""" -# This module has been generated using pyabigen v0.2.12 +# This module has been generated using pyabigen v0.2.15 import typing @@ -8,7 +8,7 @@ import web3 from web3.contract import contract -__version__ = "v1.0.2-alpha" +__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" class SupplyControl: @@ -43,6 +43,38 @@ def Burn(self) -> contract.ContractEvent: """ return self._contract.events.Burn + @property + def ConfigUpdateAddress(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateAddress` on the SupplyControl contract. + + Emitted after updating config parameter of type address + """ + return self._contract.events.ConfigUpdateAddress + + @property + def ConfigUpdateBool(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateBool` on the SupplyControl contract. + + Emitted after updating config parameter of type boolean + """ + return self._contract.events.ConfigUpdateBool + + @property + def ConfigUpdateInt(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateInt` on the SupplyControl contract. + + Emitted after updating config parameter of type int + """ + return self._contract.events.ConfigUpdateInt + + @property + def ConfigUpdateUint(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateUint` on the SupplyControl contract. + + Emitted after updating config parameter of type uint + """ + return self._contract.events.ConfigUpdateUint + @property def Mint(self) -> contract.ContractEvent: """Binding for `event Mint` on the SupplyControl contract. @@ -56,63 +88,38 @@ def available_supply( ) -> int: """Binding for `availableSupply` on the SupplyControl contract. - The supply of Auton available for minting. - Returns ------- int + The supply of Auton available for minting. """ 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( + def get_stabilizer( self, ) -> eth_typing.ChecksumAddress: - """Binding for `stabilizer` on the SupplyControl contract. - - The account that is authorized to mint and burn. + """Binding for `getStabilizer` on the SupplyControl contract. Returns ------- eth_typing.ChecksumAddress + The address of the stabilizer contract """ - return_value = self._contract.functions.stabilizer().call() + return_value = self._contract.functions.getStabilizer().call() return eth_typing.ChecksumAddress(return_value) - def total_supply( + def get_total_supply( self, ) -> int: - """Binding for `totalSupply` on the SupplyControl contract. - - The total supply of Auton under management. + """Binding for `getTotalSupply` on the SupplyControl contract. Returns ------- int + The initial total supply of Auton """ - return_value = self._contract.functions.totalSupply().call() + return_value = self._contract.functions.getTotalSupply().call() return int(return_value) @@ -145,6 +152,130 @@ def total_supply( "name": "Burn", "type": "event", }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "address", + "name": "oldValue", + "type": "address", + }, + { + "indexed": False, + "internalType": "address", + "name": "newValue", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateAddress", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "bool", + "name": "oldValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "bool", + "name": "newValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateBool", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "int256", + "name": "oldValue", + "type": "int256", + }, + { + "indexed": False, + "internalType": "int256", + "name": "newValue", + "type": "int256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateInt", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "oldValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "newValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateUint", + "type": "event", + }, { "anonymous": False, "inputs": [ @@ -178,6 +309,20 @@ def total_supply( "stateMutability": "payable", "type": "function", }, + { + "inputs": [], + "name": "getStabilizer", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getTotalSupply", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, { "inputs": [ {"internalType": "address", "name": "recipient", "type": "address"}, @@ -206,19 +351,5 @@ def total_supply( "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 index 73c2d08..93c246f 100644 --- a/autonity/contracts/upgrade_manager.py +++ b/autonity/contracts/upgrade_manager.py @@ -1,6 +1,6 @@ """UpgradeManager contract binding and data structures.""" -# This module has been generated using pyabigen v0.2.12 +# This module has been generated using pyabigen v0.2.15 import typing @@ -8,7 +8,7 @@ import web3 from web3.contract import contract -__version__ = "v1.0.2-alpha" +__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" class UpgradeManager: @@ -33,28 +33,67 @@ def __init__( abi=ABI, ) - def autonity( + @property + def ConfigUpdateAddress(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateAddress` on the UpgradeManager contract. + + Emitted after updating config parameter of type address + """ + return self._contract.events.ConfigUpdateAddress + + @property + def ConfigUpdateBool(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateBool` on the UpgradeManager contract. + + Emitted after updating config parameter of type boolean + """ + return self._contract.events.ConfigUpdateBool + + @property + def ConfigUpdateInt(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateInt` on the UpgradeManager contract. + + Emitted after updating config parameter of type int + """ + return self._contract.events.ConfigUpdateInt + + @property + def ConfigUpdateUint(self) -> contract.ContractEvent: + """Binding for `event ConfigUpdateUint` on the UpgradeManager contract. + + Emitted after updating config parameter of type uint + """ + return self._contract.events.ConfigUpdateUint + + @property + def UpgradeResult(self) -> contract.ContractEvent: + """Binding for `event UpgradeResult` on the UpgradeManager contract.""" + return self._contract.events.UpgradeResult + + def get_autonity( self, ) -> eth_typing.ChecksumAddress: - """Binding for `autonity` on the UpgradeManager contract. + """Binding for `getAutonity` on the UpgradeManager contract. Returns ------- eth_typing.ChecksumAddress + returns the autonity contract address """ - return_value = self._contract.functions.autonity().call() + return_value = self._contract.functions.getAutonity().call() return eth_typing.ChecksumAddress(return_value) - def operator( + def get_operator( self, ) -> eth_typing.ChecksumAddress: - """Binding for `operator` on the UpgradeManager contract. + """Binding for `getOperator` on the UpgradeManager contract. Returns ------- eth_typing.ChecksumAddress + returns the operator address """ - return_value = self._contract.functions.operator().call() + return_value = self._contract.functions.getOperator().call() return eth_typing.ChecksumAddress(return_value) def upgrade( @@ -93,16 +132,159 @@ def upgrade( "stateMutability": "nonpayable", "type": "constructor", }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "address", + "name": "oldValue", + "type": "address", + }, + { + "indexed": False, + "internalType": "address", + "name": "newValue", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateAddress", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "bool", + "name": "oldValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "bool", + "name": "newValue", + "type": "bool", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateBool", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "int256", + "name": "oldValue", + "type": "int256", + }, + { + "indexed": False, + "internalType": "int256", + "name": "newValue", + "type": "int256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateInt", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "string", + "name": "name", + "type": "string", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "oldValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "newValue", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "appliesAtHeight", + "type": "uint256", + }, + ], + "name": "ConfigUpdateUint", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "contractAddress", + "type": "address", + }, + { + "indexed": False, + "internalType": "bool", + "name": "success", + "type": "bool", + }, + ], + "name": "UpgradeResult", + "type": "event", + }, { "inputs": [], - "name": "autonity", + "name": "getAutonity", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function", }, { "inputs": [], - "name": "operator", + "name": "getOperator", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function", diff --git a/autonity/factory.py b/autonity/factory.py index bfac24d..0b91c1e 100644 --- a/autonity/factory.py +++ b/autonity/factory.py @@ -19,6 +19,7 @@ from .contracts import ( accountability, acu, + auctioneer, autonity, inflation_controller, liquid_logic, @@ -64,6 +65,22 @@ def ACU(w3: Web3) -> acu.ACU: return acu.ACU(w3, _config(w3).contracts.acu_contract) +def Auctioneer(w3: Web3) -> auctioneer.Auctioneer: + """Auctioneer contract binding factory. + + Parameters + ---------- + w3 : web3.Web3 + A `web3.Web3` instance with a provider connected to an Autonity network. + + Returns + ------- + autonity.contracts.auctioneer.Auctioneer + A contract binding instance. + """ + return auctioneer.Auctioneer(w3, _config(w3).contracts.auctioneer_contract) + + def Autonity(w3: Web3) -> autonity.Autonity: """Autonity contract binding factory. @@ -222,7 +239,7 @@ def _config(w3: Web3) -> autonity.Config: f"version {w3.client_version}" ) - config = autonity.Autonity(w3, AUTONITY_CONTRACT_ADDRESS).config() + config = autonity.Autonity(w3, AUTONITY_CONTRACT_ADDRESS).get_config() if config.contract_version != AUTONITY_CONTRACT_VERSION: raise RuntimeError( f"Contract version mismatch: autonity.py {__version__} supports " diff --git a/pyproject.toml b/pyproject.toml index 283b63a..05dbfc0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ path = "autonity/__version__.py" [tool.hatch.envs.generate] detached = true -dependencies = ["pyabigen@git+https://github.com/clearmatics/pyabigen@v0.2.12"] +dependencies = ["pyabigen@git+https://github.com/clearmatics/pyabigen@v0.2.15"] [tool.hatch.envs.test] dependencies = ["pytest"]