Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tool to auto-generate solidity documentation for project. #136

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,13 @@ yarn deploy --network <network>
If contracts haven't been built yet or changes occurred, this task will build
the contracts before running the deployment script. This command produces
an `export.json` file containing contract deployment info.


=== Generate contract documentation

To generate documentation for the solidity contracts please run:
```
yarn docgen
```

This produces documentation files in `docs/contracts` for each contract.
64 changes: 64 additions & 0 deletions docs/contracts/BaseTokenholderGovernor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Solidity API

## BaseTokenholderGovernor

### VETO_POWER

```solidity
bytes32 VETO_POWER
```

### constructor

```solidity
constructor(contract T _token, contract IVotesHistory _staking, contract TimelockController _timelock, address _vetoer, uint256 _quorumNumerator, uint256 _proposalThresholdNumerator, uint256 votingDelay, uint256 votingPeriod, uint64 votingExtension) public
```

### cancel

```solidity
function cancel(address[] targets, uint256[] values, bytes[] calldatas, bytes32 descriptionHash) external returns (uint256)
```

### propose

```solidity
function propose(address[] targets, uint256[] values, bytes[] calldatas, string description) public returns (uint256)
```

### quorum

```solidity
function quorum(uint256 blockNumber) public view returns (uint256)
```

### proposalThreshold

```solidity
function proposalThreshold() public view returns (uint256)
```

### getVotes

```solidity
function getVotes(address account, uint256 blockNumber) public view returns (uint256)
```

### state

```solidity
function state(uint256 proposalId) public view returns (enum IGovernor.ProposalState)
```

### supportsInterface

```solidity
function supportsInterface(bytes4 interfaceId) public view returns (bool)
```

### proposalDeadline

```solidity
function proposalDeadline(uint256 proposalId) public view virtual returns (uint256)
```

125 changes: 125 additions & 0 deletions docs/contracts/Checkpoints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Solidity API

## Checkpoints

_Abstract contract to support checkpoints for Compound-like voting and
delegation. This implementation supports token supply up to 2^96 - 1.
This contract keeps a history (checkpoints) of each account's vote
power. Vote power can be delegated either by calling the {delegate}
function directly, or by providing a signature to be used with
{delegateBySig}. Voting power can be publicly queried through
{getVotes} and {getPastVotes}.
NOTE: Extracted from OpenZeppelin ERCVotes.sol.
This contract is upgrade-safe._

### Checkpoint

```solidity
struct Checkpoint {
uint32 fromBlock;
uint96 votes;
}
```

### DelegateChanged

```solidity
event DelegateChanged(address delegator, address fromDelegate, address toDelegate)
```

Emitted when an account changes their delegate.

### DelegateVotesChanged

```solidity
event DelegateVotesChanged(address delegate, uint256 previousBalance, uint256 newBalance)
```

Emitted when a balance or delegate change results in changes
to an account's voting power.

### checkpoints

```solidity
function checkpoints(address account, uint32 pos) public view virtual returns (struct Checkpoints.Checkpoint checkpoint)
```

### numCheckpoints

```solidity
function numCheckpoints(address account) public view virtual returns (uint32)
```

Get number of checkpoints for `account`.

### delegates

```solidity
function delegates(address account) public view virtual returns (address)
```

Get the address `account` is currently delegating to.

### getVotes

```solidity
function getVotes(address account) public view returns (uint96)
```

Gets the current votes balance for `account`.

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| account | address | The address to get votes balance |

#### Return Values

| Name | Type | Description |
| ---- | ---- | ----------- |
| [0] | uint96 | The number of current votes for `account` |

### getPastVotes

```solidity
function getPastVotes(address account, uint256 blockNumber) public view returns (uint96)
```

Determine the prior number of votes for an account as of
a block number.

_Block number must be a finalized block or else this function will
revert to prevent misinformation._

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| account | address | The address of the account to check |
| blockNumber | uint256 | The block number to get the vote balance at |

#### Return Values

| Name | Type | Description |
| ---- | ---- | ----------- |
| [0] | uint96 | The number of votes the account had as of the given block |

### getPastTotalSupply

```solidity
function getPastTotalSupply(uint256 blockNumber) public view returns (uint96)
```

Retrieve the `totalSupply` at the end of `blockNumber`.
Note, this value is the sum of all balances, but it is NOT the
sum of all the delegated votes!

_`blockNumber` must have been already mined_

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| blockNumber | uint256 | The block number to get the total supply at |

148 changes: 148 additions & 0 deletions docs/contracts/GovernorParameters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Solidity API

## GovernorParameters

Abstract contract to handle governance parameters

_Based on `GovernorVotesQuorumFraction`, but without being opinionated
on what's the source of voting power, and extended to handle proposal
thresholds too. See OpenZeppelin's GovernorVotesQuorumFraction,
GovernorVotes and GovernorSettings for reference._

### FRACTION_DENOMINATOR

```solidity
uint256 FRACTION_DENOMINATOR
```

### quorumNumerator

```solidity
uint256 quorumNumerator
```

### proposalThresholdNumerator

```solidity
uint256 proposalThresholdNumerator
```

### QuorumNumeratorUpdated

```solidity
event QuorumNumeratorUpdated(uint256 oldQuorumNumerator, uint256 newQuorumNumerator)
```

### ProposalThresholdNumeratorUpdated

```solidity
event ProposalThresholdNumeratorUpdated(uint256 oldThresholdNumerator, uint256 newThresholdNumerator)
```

### VotingDelaySet

```solidity
event VotingDelaySet(uint256 oldVotingDelay, uint256 newVotingDelay)
```

### VotingPeriodSet

```solidity
event VotingPeriodSet(uint256 oldVotingPeriod, uint256 newVotingPeriod)
```

### updateQuorumNumerator

```solidity
function updateQuorumNumerator(uint256 newQuorumNumerator) external virtual
```

### updateProposalThresholdNumerator

```solidity
function updateProposalThresholdNumerator(uint256 newNumerator) external virtual
```

### setVotingDelay

```solidity
function setVotingDelay(uint256 newVotingDelay) external virtual
```

Update the voting delay. This operation can only be performed
through a governance proposal. Emits a `VotingDelaySet` event.

### setVotingPeriod

```solidity
function setVotingPeriod(uint256 newVotingPeriod) external virtual
```

Update the voting period. This operation can only be performed
through a governance proposal. Emits a `VotingPeriodSet` event.

### quorum

```solidity
function quorum(uint256 blockNumber) public view virtual returns (uint256)
```

Compute the required amount of voting power to reach quorum

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| blockNumber | uint256 | The block number to get the quorum at |

### proposalThreshold

```solidity
function proposalThreshold() public view virtual returns (uint256)
```

Compute the required amount of voting power to create a proposal
at the last block height

_This function is implemented to comply with Governor API but we
we will actually use `proposalThreshold(uint256 blockNumber)`,
as in our DAOs the threshold amount changes according to supply._

### proposalThreshold

```solidity
function proposalThreshold(uint256 blockNumber) public view returns (uint256)
```

Compute the required amount of voting power to create a proposal

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| blockNumber | uint256 | The block number to get the proposal threshold at |

### votingDelay

```solidity
function votingDelay() public view virtual returns (uint256)
```

module:user-config

_Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to
leave time for users to buy voting power, of delegate it, before the voting of a proposal starts._

### votingPeriod

```solidity
function votingPeriod() public view virtual returns (uint256)
```

module:user-config

_Delay, in number of blocks, between the vote start and vote ends.

NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting
duration compared to the voting delay._

Loading