Skip to content

Commit c2ed8ce

Browse files
committed
Add/improve comments
1 parent 5381219 commit c2ed8ce

4 files changed

Lines changed: 67 additions & 12 deletions

File tree

packages/convenience/contracts/Convenience.sol

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ contract Convenience is Ownable {
1616
/// @notice Staking pool of the DAO
1717
IApi3PoolExtended public immutable api3Pool;
1818
/// @notice List of ERC20 addresses that will be displayed in the DAO
19-
/// treasury
19+
/// treasury. The ETH balance will also be displayed by default.
2020
/// @dev These are set by the owner of this contract
2121
address[] public erc20Addresses;
2222
/// @notice Links to the discussion venues for each vote
@@ -74,6 +74,26 @@ contract Convenience is Ownable {
7474

7575
/// @notice Used by the DAO dashboard client to retrieve user staking data
7676
/// @param userAddress User address
77+
/// @return apr Staking reward APR
78+
/// @return api3Supply API3 total supply
79+
/// @return totalStake Total amount staked at the pool
80+
/// @return totalShares Total pool shares (also represents total voting
81+
/// power)
82+
/// @return stakeTarget Pool stake target in percentages
83+
/// @return userApi3Balance User API3 balance
84+
/// @return userStaked Amount of staked tokens the user has at the pool
85+
/// @return userUnstaked Amount of non-staked tokens the user has at the
86+
/// pool
87+
/// @return userVesting Amount of tokens not yet vested to the user (it is
88+
/// not withdrawable, similar to `userLocked`)
89+
/// @return userUnstakeAmount Amount of tokens the user scheduled to
90+
/// unstake
91+
/// @return userUnstakeShares Amount of shares the user gave up to schedule
92+
/// the unstaking
93+
/// @return userUnstakeScheduledFor Time when the scheduled unstake will
94+
/// mature
95+
/// @return userLocked Amount of rewards the user has received that are not
96+
/// withdrawable yet
7797
function getUserStakingData(address userAddress)
7898
external
7999
view
@@ -114,7 +134,24 @@ contract Convenience is Ownable {
114134

115135
/// @notice Used by the DAO dashboard client to retrieve the treasury and
116136
/// user delegation data
137+
/// @dev In addition to the ERC20 tokens, it returns the ETH balances of
138+
/// the treasuries
117139
/// @param userAddress User address
140+
/// @return names ERC20 (+ Ethereum) names
141+
/// @return symbols ERC20 (+ Ethereum) symbols
142+
/// @return decimals ERC20 (+ Ethereum) decimals
143+
/// @return balancesOfPrimaryAgent ERC20 (+ Ethereum) balances of the
144+
/// primary agent
145+
/// @return balancesOfSecondaryAgent ERC20 (+ Ethereum) balances of the
146+
/// secondary agent
147+
/// @return proposalVotingPowerThreshold Proposal voting power threshold in
148+
/// percentages
149+
/// @return userVotingPower Voting power of the user, including delegations
150+
/// @return delegatedToUser Voting power delegated to user
151+
/// @return delegate Address that the user has delegated to
152+
/// @return lastDelegationUpdateTimestamp When the user has last updated
153+
/// their delegation
154+
/// @return lastProposalTimestamp When the user has last made a proposal
118155
function getTreasuryAndUserDelegationData(address userAddress)
119156
external
120157
view
@@ -171,6 +208,17 @@ contract Convenience is Ownable {
171208
/// @param votingAppType Enumerated voting app type (primary or secondary)
172209
/// @param userAddress User address
173210
/// @param voteIds Array of vote IDs for which data will be retrieved
211+
/// @return startDate Start date of the vote
212+
/// @return supportRequired Support required for the vote to pass in
213+
/// percentages
214+
/// @return minAcceptQuorum Minimum acceptance quorum required for the vote
215+
/// to pass in percentages
216+
/// @return votingPower Total voting power at the time the vote was created
217+
/// @return script The EVMScript that will be run if the vote passes
218+
/// @return userVotingPowerAt User's voting power at the time the vote was
219+
/// created
220+
/// @return discussionUrl Discussion URL set for the vote by the contract
221+
/// owner
174222
function getStaticVoteData(
175223
VotingAppType votingAppType,
176224
address userAddress,
@@ -230,6 +278,13 @@ contract Convenience is Ownable {
230278
/// @param votingAppType Enumerated voting app type (primary or secondary)
231279
/// @param userAddress User address
232280
/// @param voteIds Array of vote IDs for which data will be retrieved
281+
/// @return executed If the vote has been executed
282+
/// @return yea Total voting power voted for "For"
283+
/// @return nay Total voting power voted for "Against"
284+
/// @return voterState Vote cast by the user
285+
/// @return delegateAt Address the user has delegated to at the time the
286+
/// vote was created
287+
/// @return delegateState Vote cast by the delegate of the user
233288
function getDynamicVoteData(
234289
VotingAppType votingAppType,
235290
address userAddress,

packages/pool/contracts/StakeUtils.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,8 @@ abstract contract StakeUtils is TransferUtils, IStakeUtils {
105105
}
106106

107107
/// @notice Called to execute a pre-scheduled unstake
108-
/// @dev Note that anyone can execute a matured unstake. This is to allow
109-
/// the user to use bots, etc. to execute their unstaking as soon as
110-
/// possible.
108+
/// @dev Anyone can execute a matured unstake. This is to allow the user to
109+
/// use bots, etc. to execute their unstaking as soon as possible.
111110
/// @param userAddress User address
112111
/// @return Amount of tokens that are unstaked
113112
function unstake(address userAddress)
@@ -128,8 +127,9 @@ abstract contract StakeUtils is TransferUtils, IStakeUtils {
128127
uint256 totalShares = totalShares();
129128
uint256 unstakeAmount = user.unstakeAmount;
130129
uint256 unstakeAmountByShares = user.unstakeShares * totalStake / totalShares;
131-
// If there was a claim payout in between the scheduling and the actual unstake
132-
// then the amount might be lower than expected at scheduling time
130+
// If there was a claim payout in between the scheduling and the actual
131+
// unstake then the amount might be lower than expected at scheduling
132+
// time
133133
if (unstakeAmount > unstakeAmountByShares)
134134
{
135135
unstakeAmount = unstakeAmountByShares;
@@ -151,8 +151,8 @@ abstract contract StakeUtils is TransferUtils, IStakeUtils {
151151

152152
/// @notice Convenience method to execute an unstake and withdraw to the
153153
/// user's wallet in a single transaction
154-
/// @dev Note that the withdrawal may revert because the user may have less
155-
/// than `unstaked` tokens that are withdrawable
154+
/// @dev The withdrawal will revert if the user has less than
155+
/// `unstakeAmount` tokens that are withdrawable
156156
function unstakeAndWithdraw()
157157
external
158158
override

packages/pool/contracts/StateUtils.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ contract StateUtils is IStateUtils {
5353
uint256 public constant EPOCH_LENGTH = 1 weeks;
5454

5555
/// @notice Number of epochs before the staking rewards get unlocked.
56-
/// Hardcoded as 52 epochs, which corresponds to a year with an
57-
/// `EPOCH_LENGTH` of 1 week.
56+
/// Hardcoded as 52 epochs, which approximately corresponds to a year with
57+
/// an `EPOCH_LENGTH` of 1 week.
5858
uint256 public constant REWARD_VESTING_PERIOD = 52;
5959

6060
// All percentage values are represented as 1e18 = 100%

packages/pool/contracts/TimelockUtils.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import "./interfaces/ITimelockUtils.sol";
66

77
/// @title Contract that implements vesting functionality
88
/// @dev The TimelockManager contract interfaces with this contract to transfer
9-
/// API3 tokens that are locked under a vesting schedule
9+
/// API3 tokens that are locked under a vesting schedule.
1010
/// This contract keeps its own type definitions, event declarations and state
1111
/// variables for them to be easier to remove for a subDAO where they will
1212
/// likely not be used.
@@ -28,7 +28,7 @@ abstract contract TimelockUtils is ClaimUtils, ITimelockUtils {
2828
/// @notice Called by the TimelockManager contract to deposit tokens on
2929
/// behalf of a user
3030
/// @dev This method is only usable by `TimelockManager.sol`.
31-
/// It is named as `deposit()` and not `depositByTimelockManager()` for
31+
/// It is named as `deposit()` and not `depositAsTimelockManager()` for
3232
/// example, because the TimelockManager is already deployed and expects
3333
/// the `deposit(address,uint256,address)` interface.
3434
/// @param source Token transfer source

0 commit comments

Comments
 (0)