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

style: simplify code #7

Merged
merged 15 commits into from
Feb 23, 2024
Merged

style: simplify code #7

merged 15 commits into from
Feb 23, 2024

Conversation

dristpunk
Copy link
Contributor

No description provided.

@dristpunk dristpunk self-assigned this Feb 20, 2024
@dristpunk dristpunk marked this pull request as ready for review February 20, 2024 12:58
function vestedAmount(uint64) public view virtual override returns (uint256 _amount) {
return 0;
constructor(address _owner, uint256 _totalAmount) Ownable(_owner) {
CLIFF = VESTING_START_DATE + VESTING_CLIFF_DURATION;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLIFF is basically VESTING_START_DATE + 1 year no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLIFF is basically VESTING_START_DATE + 1 year no?

VESTING_START_DATE + 1 month. It's used just once so we could replace it with VESTING_START_DATE + VESTING_CLIFF_DURATION in the code

Copy link
Member

@wei3erHase wei3erHase Feb 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh ok, i think is good there, mmmm maybe rename to VESTING_CLIFF ?

Copy link
Contributor Author

@dristpunk dristpunk Feb 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VESTING_CLIFF

I'd remove it at all or moved its declaration to constants. Setting constants in constructor doesn't make sense


/**
* @notice NEXT tokens released
* @param _token The address of the NEXT token
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*of the released ERC20 token

Comment on lines 62 to 67
/**
* @notice Sept 5th 2023 in seconds
* @return _timedelta The timestamp of Sept 5th 2023
*/
function SEPT_05_2023() external view returns (uint64 _timedelta);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a timedelta, unix timestamp!


/**
* @notice Vesting warmup time
* @dev 11 months offset
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure if @dev comments are correct in the interface, because they're talking about the immutable variable that's on the contract, it doesn't make sense to assume in the interface that this will return 11 months offset

i'd move the @dev comments to the contract

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure if @dev comments are correct in the interface, because they're talking about the immutable variable that's on the contract, it doesn't make sense to assume in the interface that this will return 11 months offset

i'd move the @dev comments to the contract

we could remove it because it doesn't make sense to add @dev natspec to constants. Or we can do // comments after them

*/
uint64 public constant VESTING_START_DATE = NEXT_TOKEN_LAUNCH + VESTING_OFFSET;
/// @inheritdoc IConnextVestingWallet
uint64 public constant VESTING_CLIFF = VESTING_START_DATE + VESTING_CLIFF_DURATION;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing // Sept 5th 2024 comment

function VESTING_CLIFF_DURATION() external view returns (uint64 _timedelta);

/**
* @notice Vesting duration including one month of cliff
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*including cliff duration

*/
address public constant NEXT_TOKEN = 0xFE67A4450907459c3e1FFf623aA927dD4e28c67a;
/// @inheritdoc IConnextVestingWallet
address public constant NEXT_TOKEN = 0xFE67A4450907459c3e1FFf623aA927dD4e28c67a; // Mainnet address
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Mainnet NEXT token address

function vestedAmount(uint64 _timestamp) public view returns (uint256 _amount) {
if (_timestamp < VESTING_CLIFF) {
return 0;
} else if (_timestamp >= VESTING_START) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how come this is passing the tests?

Suggested change
} else if (_timestamp >= VESTING_START) {
} else if (_timestamp >= VESTING_END) {


/// @inheritdoc IConnextVestingWallet
uint64 public immutable CLIFF;
uint64 public constant VESTING_START = VESTING_START_DATE + VESTING_DURATION;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WRONG NAMING!!

*/
uint64 public constant VESTING_OFFSET = ONE_YEAR - ONE_MONTH;
/// @inheritdoc IConnextVestingWallet
uint64 public constant VESTING_START = NEXT_TOKEN_LAUNCH + VESTING_OFFSET; // Aug 5th 2024
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the change pal?? it was ok Sept 5th - 1mth

STORAGE
//////////////////////////////////////////////////////////////*/
/// @inheritdoc IConnextVestingWallet
uint64 public constant VESTING_END = VESTING_START + VESTING_DURATION; // Sept 5th 2025
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe we should be talking about UNLOCK instead of VEST, @0xGorilla ?

uint64 public constant VESTING_DURATION = 365 days * 4;
uint64 public constant UNLOCK_DURATION = 365 days * 4;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOOOOOOO!O!O!!O!O!O!O! hahhaha
this is actually the vest that goes into llamapay, it's 4ys, is a VEST

NEXT_TOKEN_ADDRESS, address(_connextVestingWallet), TOTAL_AMOUNT, VESTING_DURATION, AUG_01_2022, 0
NEXT_TOKEN_ADDRESS, address(_connextVestingWallet), TOTAL_AMOUNT, UNLOCK_DURATION, AUG_01_2022, 0
Copy link
Member

@wei3erHase wei3erHase Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong naming ⚠️

wei3erHase
wei3erHase previously approved these changes Feb 21, 2024
Copy link
Member

@wei3erHase wei3erHase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

Copy link
Contributor

@turtlemoji turtlemoji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • please change test pk from env to tests, and random would be better !

Also:

Encountered 1 failing test in solidity/test/integration/LlamaVesting.t.sol:IntegrationLlamaVesting
[FAIL. Reason: setup failed: environment variable "DEPLOYER_PRIVATE_KEY" not found] setUp() (gas: 0)
  • It seems it needs DEPLOYER_PRIVATE_KEY (the same you are setting on the action rn), but its not implemented on the .env.example so it fails locally. Adding it to the env fixes it tho.

  • Just to confirm recheck coverage for solidity/contracts/ConnextVestingWallet.sol. Are we ok with that %?

  • Also why MAX_DELTA is so high? (1 ether)
    I would use just assertEq on all the cases. Only LlamaVesting tests error without delta.

  • Recheck all constants, like PAY_PER_SECOND. Some are not used anymore. Also the LlamaVesting.t.sol could use more comments explaining VestAndUnlock test numbers (Like in the other test)

Overall is pretty clean and secure, amazing job!

assertApproxEqAbs(
_connextVestingWallet.vestedAmount(NEXT_TOKEN_ADDRESS, _firstMilestoneTimestamp + MONTH), 2 ether, MAX_DELTA
);
assertApproxEqAbs(_connextVestingWallet.vestedAmount(_firstMilestoneTimestamp + MONTH), 2 ether, MAX_DELTA);
Copy link
Contributor

@turtlemoji turtlemoji Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why MAX_DELTA is so high? (1 ether)
I would use just assertEq on this case and all this file cases

Copy link
Contributor Author

@dristpunk dristpunk Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why MAX_DELTA is so high? (1 ether) I would use just assertEq on this case and all this file cases

mostly because we use approximate datatimes, like 30 days = 1 month, but 1 month also = 1/12 year, which is 365 days.

Copy link
Contributor

@turtlemoji turtlemoji Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in this case I mean.
assertApproxEqAbs(_connextVestingWallet.vestedAmount(_firstMilestoneTimestamp + MONTH), 2 ether, MAX_DELTA);

You are comparing the vestedAmount, to 2 ether. With a delta of 1 ether. In this specific case it is wrong. If you use assertEq it will work just fine without delta

0xGorilla
0xGorilla previously approved these changes Feb 23, 2024
@gas1cent gas1cent dismissed turtlemoji’s stale review February 23, 2024 16:18

The feedback has been addressed 🐢

@gas1cent gas1cent merged commit 7a8e283 into dev Feb 23, 2024
3 checks passed
@gas1cent gas1cent deleted the style/simplify-contracts branch February 23, 2024 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants