Platform: Code4rena
Start Date: 07/08/2023
Pot Size: $36,500 USDC
Total HM: 11
Participants: 125
Period: 3 days
Judge: alcueca
Total Solo HM: 4
Id: 274
League: ETH
Rank: 8/125
Findings: 1
Award: $395.54
🌟 Selected for report: 1
🚀 Solo Findings: 0
🌟 Selected for report: catellatech
Also found by: 0x73696d616f, 0xSmartContract, 0xbrett8571, MrPotatoMagic, RED-LOTUS-REACH, rjs, thekmj
395.5442 USDC - $395.54
veRWA project
veRWA is an incentivization mechanism designed for Real World Assets (RWA) on the Canto platform. It operates similarly to the veCRV system with its liquidity gauge. Users have the option to lock up CANTO tokens for a duration of five years in the VotingEscrow
contract, in exchange for receiving veCANTO tokens.
Subsequently, they can participate in voting activities within the GaugeController
for various credit markets that have been whitelisted by the governance. Users who provide liquidity in these credit markets can claim CANTO
tokens (provided by the CANTO governance) from the LendingLedger
contract, based on their proportional contribution.
To illustrate, let's consider credit markets X, Y, and Z where Alice, Bob, and Charlie contribute liquidity. In the scenario of credit market X, assuming Alice contributes 60% of the liquidity, Bob contributes 30%, and Charlie contributes 10% at a specific time (epoch), and let's assume that credit market X receives 40% of all votes at that epoch. Consequently, the allocations would be:
This mechanism aims to incentivize participation and liquidity provision in credit markets backed by real world assets on the Canto platform.
To begin, we assessed the code's scope, which guided our approach to reviewing and analyzing the project.
GaugeController.sol:
GaugeController
contract is like a translated version of Curve's GaugeController
written in Solidity. It simplifies the gauge types to just one type for veRWA. This leads to other changes in the code. The way gauges (lending markets) are approved is also different from the original design.The controller lets users vote on how much weight a gauge should have in distributing CANTO tokens during a specific period (epoch). It also allows checking the historical relative weights of all gauges.
VotingEscrow.sol:
VotingEscrow
system used here is based on an existing setup from FIAT DAO, which itself was built by modifying Curve's original design. In this version, a few changes were made, like allowing the use of native tokens instead of ERC20 tokens. Additionally, a fixed lock time of 5 years was added, which restarts every time an action is taken.LendingLedger.sol:
With this understanding, we proceeded to scrutinize and audit the code through a series of structured steps:
The GaugeController
contract is a fundamental component of the veRWA project
is responsible for enabling users to vote on the distribution of CANTO tokens and managing information related to weights and changes in "gauges" (credit markets) within the veRWA project
.
The VotingEscrow
contract is responsible for managing users locking and voting power.
The LendingLedger
contract is responsible for tracking balances and rewards in lending markets. Users can synchronize their balances, claim rewards, and the governance can set rewards and control the whitelist of lending markets.
The audit scope of the contracts to be audited is 95% and it should be aimed to be 100%.
What is the overall line coverage percentage provided by your tests?: 95%
While the provided code seems to be functional, there are always areas for improvement to ensure better security, efficiency, and readability in both the contract and the protocol.
Here are some potential areas for improvement:
Code Comments and Documentation:
Access Control:
Error Handling and Assertions:
Code Organization:
Security Audits:
Event Logging:
More Comprehensive Testing:
Users:
Users interact with the veRWA project
through their actions, such as depositing tokens, voting on governance proposals, and participating in lending markets.
VotingEscrow.sol
:
GaugeController.sol
:
GaugeController
contract could manage the "gauges" that influence reward distribution. This contract likely defines how rewards are allocated among different markets or assets based on their relative weights.LendingLedger.sol
:
CANTO
tokens. The contract keeps track of user balances, total balances in each lending market, and other relevant metrics. It also allows users to claim rewards and enables governance to configure rewards.This overview provides a general understanding of how the different components interact within the veRWA project
.
It would be helpful if the Documentation explained how the ecosystem works from a basic contract level so that it is easier to digest for developers, users and auditors looking to integrate into the veRWA project
, it is recommended to add the architectural design to the documents as infographic
I would also recommend adding quality Medium articles, it's a great way to provide an in-depth look at many of the topics in the project and is used by many blockchain projects.
Here's an analysis of potential systemic and centralization risks in the provided contracts:
Epoch-Based System:
Reward Calculations:
Lending Market Whitelist:
Governance Control:
Market Whitelisting:
Reward Settings:
Dependent Contracts:
VotingEscrow
and GaugeController
. If these contracts are compromised or misconfigured, it could impact the overall functionality of the veRWA project
.Rewards Allocation:
GaugeController
could be centralized if the controller's decisions are not well-distributed or transparently managed.It's important to address these risks through careful auditing, community involvement, decentralization measures, and ongoing monitoring. The protocol should strive to minimize centralization, ensure transparency, and have contingency plans for potential disruptions or flaws in the system.
What the project should add in the understanding of Security?
Input Validation:
Access Control:
LendingLedger.sol
contract for certain functions, which suggests some level of access control.External Contract Interaction:
Audits and Testing:
Code Simplicity and Clarity:
Known Vulnerability Mitigation-:
Emergency Measures:
Continuous Monitoring and Response:
Automated Findings: https://github.com/code-423n4/2023-08-verwa/blob/main/bot-report.md
The insights and learnings that could be gained from analyzing the provided smart contracts from the veRWA project
.
Complexity and Design Patterns: - Analyzing these contracts might offer insights into how complex DeFi protocols are designed and implemented. Understanding the interplay of different contracts, data structures, and design patterns could deepen your understanding of decentralized applications.
Governance and Voting:
- By studying the VotingEscrow
contract, you could learn about how decentralized governance and voting mechanisms are implemented. This could be valuable for understanding how community-driven decisions are made in various projects.
Tokenization and Rewards:
In general, the veRWA project
exhibits an interesting and well-developed architecture we believe the team has done a good job regarding the code, but the identified risks need to be addressed, and measures should be implemented to protect the protocol from potential malicious use cases. Additionally, it is recommended to improve the documentation and comments in the code to enhance understanding and collaboration among developers. It is also highly recommended that the team continues to invest in security measures such as mitigation reviews, audits, and bug bounty programs to maintain the security and reliability of the project.
A total of 2 days were spent to cover this audit, broken down into the following:
24 hours
#0 - catellaTech
2023-08-12T18:37:34Z
Hello, while checking if the images in my analysis were uploaded correctly, I realized that I mistakenly placed quotation marks where I shouldn't have, and as a result, the diagram of a contract I worked hard on doesn't open. I kindly request the judge reviewing my analysis to consider this diagram
#1 - c4-pre-sort
2023-08-13T09:32:40Z
141345 marked the issue as high quality report
#2 - OpenCoreCH
2023-08-16T15:20:40Z
Great report! I especially like the diagram
#3 - c4-sponsor
2023-08-16T15:21:19Z
OpenCoreCH marked the issue as sponsor acknowledged
#4 - c4-judge
2023-08-22T06:51:33Z
alcueca marked the issue as selected for report
#5 - c4-judge
2023-08-22T07:08:27Z
alcueca marked the issue as grade-a
#6 - c4-judge
2023-08-22T07:08:31Z
alcueca marked the issue as not selected for report
#7 - catellaTech
2023-08-28T19:53:08Z
Hi, @alcueca!! thanks for the great job... can u please can review again my analisys. All the diagrams now are good and the sponsor found value in my work 🤞
#8 - alcueca
2023-08-30T06:27:04Z
The diagrams in this report are representative of the effort put into it. Additionally, sections 5 (Documents), 6 (Risks) and 7 (Security Approach) complete the report further by providing additional insight.
While the application description in #452 is more thorough and detailed, and should be reviewed by those exploring the codebase, this report offers more value for the sponsor, and is therefore selected for the report.
#9 - c4-judge
2023-08-30T06:27:12Z
alcueca marked the issue as selected for report