Skip to content

adds WithdrawablePeriphery base contract for token withdrawals#831

Merged
ezynda3 merged 5 commits intomainfrom
withdrawable-periphery
Oct 15, 2024
Merged

adds WithdrawablePeriphery base contract for token withdrawals#831
ezynda3 merged 5 commits intomainfrom
withdrawable-periphery

Conversation

@0xDEnYO
Copy link
Copy Markdown
Contributor

@0xDEnYO 0xDEnYO commented Oct 10, 2024

Which Jira task belongs to this PR?

https://lifi.atlassian.net/browse/LF-10387

Why did I implement it this way?

Checklist before requesting a review

  • I have performed a self-review of my code
  • This pull request is as small as possible and only tackles one problem
  • I have added tests that cover the functionality / test the bug
  • I have updated any required documentation

Checklist for reviewer (DO NOT DEPLOY and contracts BEFORE CHECKING THIS!!!)

  • I have checked that any arbitrary calls to external contracts are validated and or restricted
  • I have checked that any privileged calls (i.e. storage modifications) are validated and or restricted
  • I have ensured that any new contracts have had AT A MINIMUM 1 preliminary audit conducted on by <company/auditor>

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 10, 2024

Walkthrough

This pull request introduces an abstract contract named WithdrawablePeriphery, which allows the contract owner to withdraw both native assets and ERC20 tokens. It includes an event for logging withdrawal actions and employs secure transfer methods. A corresponding test suite in WithdrawablePeriphery.t.sol has been created to validate the functionality of the contract, covering various scenarios such as successful withdrawals and attempts by unauthorized users. Additionally, an audit entry for the WithdrawablePeriphery contract has been added to the auditLog.json.

Changes

File Change Summary
src/Helpers/WithdrawablePeriphery.sol Added abstract contract WithdrawablePeriphery, event TokensWithdrawn, constructor, and method withdrawToken.
test/solidity/Helpers/WithdrawablePeriphery.t.sol Added test contracts TestContract and WithdrawablePeripheryTest, event TokensWithdrawn, and error UnAuthorized.
audit/auditLog.json Added audit entry for WithdrawablePeriphery with version 1.0.0 and details of the audit.

Possibly related PRs

Suggested labels

AuditNotRequired

Suggested reviewers

  • ezynda3

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 40bf7ee and da4c7b1.

⛔ Files ignored due to path filters (1)
  • audit/reports/2024.10.14_WithdrawablePeriphery.pdf is excluded by !**/*.pdf
📒 Files selected for processing (1)
  • audit/auditLog.json (2 hunks)
🧰 Additional context used
📓 Learnings (1)
📓 Common learnings
Learnt from: 0xDEnYO
PR: lifinance/contracts#782
File: test/solidity/Helpers/WithdrawablePeriphery.t.sol:22-35
Timestamp: 2024-10-10T03:18:20.721Z
Learning: In Solidity tests for withdrawal functions in `test/solidity/Helpers/WithdrawablePeriphery.t.sol`, do not suggest adding tests where the withdrawal amount exceeds the contract's balance, as such tests are unnecessary because any contract will fail in that case.
Learnt from: 0xDEnYO
PR: lifinance/contracts#831
File: src/Helpers/WithdrawablePeriphery.sol:26-30
Timestamp: 2024-10-14T08:23:38.076Z
Learning: In the `WithdrawablePeriphery.sol` contract, when transferring Ether in the `withdrawToken` function, prefer using `SafeTransferLib.safeTransferETH` instead of low-level `call` for safer Ether transfers.
🔇 Additional comments (3)
audit/auditLog.json (3)

17-22: LGTM: New audit entry is correctly structured and consistent.

The new audit entry for "audit20241014" is well-formed and follows the established pattern. All required fields are present, and the information is consistent with previous entries.


31-33: LGTM: New audited contract entry is correctly added and linked.

The new entry for "WithdrawablePeriphery" is properly structured and correctly references the newly added audit. The version number "1.0.0" is appropriate for a first audit.


Line range hint 16-33: Summary: Audit log successfully updated with new contract audit information.

The changes to auditLog.json accurately reflect the addition of a new audit for the "WithdrawablePeriphery" contract. The new entries are consistent with the existing structure and provide all necessary information. This update ensures that the audit history is properly maintained and up-to-date.

Some observations:

  1. The audit was conducted by the same auditor as previous audits, maintaining consistency.
  2. The new contract "WithdrawablePeriphery" is now tracked in the audit log, which aligns with the PR objectives.
  3. The file structure and integrity have been preserved.

These changes contribute to maintaining a clear audit trail for the project.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@lifi-action-bot lifi-action-bot marked this pull request as draft October 10, 2024 02:50
@lifi-action-bot
Copy link
Copy Markdown
Collaborator

lifi-action-bot commented Oct 10, 2024

Test Coverage Report

Line Coverage: 78.44% (1700 / 2167 lines)
Function Coverage: 84.74% ( 361 / 426 functions)
Branch Coverage: 51.53% ( 269 / 522 branches)
Test coverage (78.44%) is above min threshold (74%). Check passed.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fb93afc and b03e658.

📒 Files selected for processing (2)
  • src/Helpers/WithdrawablePeriphery.sol (1 hunks)
  • test/solidity/Helpers/WithdrawablePeriphery.t.sol (1 hunks)
🧰 Additional context used
📓 Learnings (1)
src/Helpers/WithdrawablePeriphery.sol (2)
Learnt from: 0xDEnYO
PR: lifinance/contracts#782
File: src/Helpers/WithdrawablePeriphery.sol:20-34
Timestamp: 2024-10-09T03:47:21.269Z
Learning: In the `WithdrawablePeriphery.sol` contract, for admin-only functions protected by the `onlyOwner` modifier, it's acceptable to omit balance checks and reentrancy protection since admins are trusted to handle these functions appropriately.
Learnt from: 0xDEnYO
PR: lifinance/contracts#782
File: src/Helpers/WithdrawablePeriphery.sol:20-34
Timestamp: 2024-10-07T02:44:36.866Z
Learning: In the `WithdrawablePeriphery.sol` contract, for admin-only functions protected by the `onlyOwner` modifier, it's acceptable to omit balance checks and reentrancy protection since admins are trusted to handle these functions appropriately.

Comment thread src/Helpers/WithdrawablePeriphery.sol
Comment thread test/solidity/Helpers/WithdrawablePeriphery.t.sol
Comment thread test/solidity/Helpers/WithdrawablePeriphery.t.sol
Comment thread test/solidity/Helpers/WithdrawablePeriphery.t.sol
@0xDEnYO 0xDEnYO marked this pull request as ready for review October 14, 2024 08:26
@ezynda3 ezynda3 merged commit a8da0f8 into main Oct 15, 2024
@ezynda3 ezynda3 deleted the withdrawable-periphery branch October 15, 2024 06:31
@coderabbitai coderabbitai Bot mentioned this pull request Aug 20, 2025
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants