-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from burns2854/main
Update veLaunchpad documentation
- Loading branch information
Showing
9 changed files
with
189 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: "Risks" | ||
order: 7 | ||
--- | ||
|
||
# veLaunchpad Risks | ||
|
||
When deploying or using a vote escrow system through the Launchpad or via the contracts directly, there are several risks that both deployers (developers) and users (participants) should be aware of. This is autonomous software. See also [Balancer Protocol Risks](https://app.balancer.fi/#/risks). | ||
|
||
## Smart Contract Security | ||
While smart contract factories may offer convenience in deploying new instances of vote escrow systems, they also introduce dependencies on the security and reliability of the factory contracts. If the factory contracts contain vulnerabilities or are compromised, it could affect all instances deployed through them. | ||
|
||
[The new contracts](https://github.com/protofire/ve8020-launchpad) are based on the [existing veBAL system](https://medium.com/balancer-protocol/vebal-is-live-aeda1ae13e20) / [VotingEscrow.vy](https://github.com/balancer/balancer-v2-monorepo/blob/master/pkg/liquidity-mining/contracts/VotingEscrow.vy) that Balancer has employed since March 2022 with the addition of factories and updates developed by [Protofire](https://protofire.io/) that include the ability to set early unlock permissions and penalties. Balancer has taken steps to mitigate these risks through reviews by Protofire and conducting an [audit with Certora that can be read here](https://github.com/protofire/ve8020-launchpad/tree/main). Teams can still fork the original VotingEscrow contracts if preferred and the additional features are not required. | ||
|
||
## Configuration Risks | ||
Deployers need to configure the parameters of the vote escrow system according to the specific requirements and objectives of their DAO/project/protocol. This includes setting parameters such as lock-up periods, voting eligibility criteria, quorum thresholds, and voting power weights. Misconfigurations can lead to unintended consequences or vulnerabilities in the governance process. | ||
|
||
## Integration Risks | ||
Deployers may need to integrate the deployed smart contracts with other components of their infrastructure, such as the front-end interface, wallet integrations, or external services. Integration errors or compatibility issues could disrupt the functioning of the vote escrow system and impact user experience. | ||
|
||
## Monitoring and Maintenance | ||
Deployers are responsible for monitoring the performance and health of the deployed smart contracts over time. They should conduct regular audits, security assessments, and upgrades to address any vulnerabilities, bugs, or changes in the operating environment that may affect the integrity or functionality of the vote escrow system. | ||
|
||
## Reliability of Front-End | ||
The front-end interface provided on this docs site may be subject to downtime, bugs, or security vulnerabilities. Deployers and owners should assess the reliability and security of the front-end and consider implementing backup interfaces or contingency plans such as interacting directly with the deployed contracts in case of disruptions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
--- | ||
title: "Front End Integration" | ||
order: 8 | ||
--- | ||
|
||
## Frontend integration | ||
|
||
### System creation and management | ||
1) Create system using Launchpad contract. | ||
``` | ||
function deploy( | ||
address tokenBptAddr, | ||
string memory name, | ||
string memory symbol, | ||
uint256 maxLockTime, | ||
uint256 rewardDistributorStartTime | ||
) | ||
``` | ||
**Parameters details and constraints:** | ||
`tokenBptAddr` - token or liquidity-token provided by creator | ||
`name` - any name provided by creator | ||
`symbol` - any symbol provided by creator | ||
`maxLockTime` - time in seconds. **Must be >= `604800` (7 days)** | ||
`rewardDistributorStartTime` - unix timestamp. **Must be >= unix-timestamp of next Thursday 00:00** | ||
|
||
After calling the `deploy()` function, contracts VotingEscrow and RewardDistributor will be created for the caller (admin). The addresses of these contracts can be obtained from the `VESystemCreated(address bptToken, address votingEscrow, address rewardDistributor, address admin)` event of the deploy() function. | ||
|
||
2) After creation admin (creator) must add allowed token for the reward distribution. | ||
To do that use following function of the RewardDistributor constract: | ||
``` | ||
function addAllowedRewardTokens(address[] calldata tokens); | ||
``` | ||
|
||
3) To provide rewards into RewardDistributor constract any user can use one of the following functions: | ||
``` | ||
function depositToken(address token, uint256 amount); | ||
function depositTokens(address[] calldata tokens, uint256[] calldata amounts); | ||
``` | ||
**Parameters details and constraints:** | ||
`token` - token address, that already added to allowed list (see point 2), | ||
`amount` - amount for token | ||
Note: | ||
- tokens can be added to the weekly distribution no earlier than `rewardDistributorStartTime`. | ||
- Every Thursday at 00:00 a new week of reward distributions begins. | ||
|
||
4) The Subgraph can be used to track the history of rewards added each week. | ||
``` | ||
{ | ||
weekRewards(where: {rewardDistributor: "<REWARD_DISTRIBUTOR_ADDRESS>"}) { | ||
rewardDistributor | ||
token | ||
totalWeekAmount | ||
weekStart | ||
} | ||
} | ||
``` | ||
|
||
[Here](https://github.com/protofire/balancer_launchpad_subgraph/blob/main/docs/GraphQueries.md) you can find more subgraph examples that can useful for frontend integration | ||
|
||
|
||
|
||
### Users interaction | ||
|
||
#### VotingEscrow | ||
|
||
1) VotingEscrow metadata: | ||
``` | ||
function name() external view returns (string memory); | ||
function symbol() external view returns (string memory); | ||
function token() external view returns (address); | ||
function decimals() external view returns (uint256); | ||
``` | ||
Returns: | ||
- name of the VotingEscrow contract, | ||
- symbol of the VotingEscrow contract, | ||
- address of the token that can be locked, | ||
- decimals of the token that can be locked, | ||
|
||
2) [Create new lock](./2_VotingEscrow.md/#create_lock) | ||
Creates new lock for a user. | ||
|
||
3) [Increase lock amount](./2_VotingEscrow.md/#increase_amount) | ||
Increases lock amount to increase (voting) power of lock. | ||
|
||
4) [Increase unlock time](./2_VotingEscrow.md/#increase_unlock_time) | ||
Increases lock unlock time to increase (voting) power of lock. | ||
|
||
5) To get information when the user's lock amount and lock deadline: | ||
``` | ||
function locked(address account) external view returns (uint256 amount, uint256 deadline); | ||
``` | ||
Returns: | ||
- `amount` of locked tokens; | ||
- `unix-times` of the lock end. | ||
|
||
5) [Withdraw tokens when lock is finished](./2_VotingEscrow.md/#withdraw) | ||
Withdraws tokens to user. | ||
|
||
6) Each VotingEscrow contract has lock-MaxTime value defined in seconds. To check lock-maxtime: | ||
``` | ||
function MAXTIME() external view returns (uint256); | ||
``` | ||
Returns Maxtime value in seconds for current VotingEscrow contract. | ||
|
||
|
||
|
||
|
||
#### RewardDistributor | ||
1) [Add allowed token for the distribution](./3_RewardDistributor.md/#addallowedrewardtokens) | ||
|
||
2) Get list of allowed tokens for a distribution: | ||
``` | ||
function getAllowedRewardTokens() external view returns (address[] memory) | ||
``` | ||
Returns allowed for reward distribution tokens list. | ||
|
||
|
||
3) [Deposit tokens for the week distribution](./3_RewardDistributor.md/#deposittoken) | ||
|
||
4) Use LensReward contracts to check user's pending rewards: | ||
``` | ||
struct ClaimableRewards { | ||
address token; | ||
uint256 claimableAmount; | ||
} | ||
|
||
LensReward.getUserClaimableRewardsAll( | ||
address rewardDistributor, | ||
address user, | ||
address[] calldata allowedRewardTokenList | ||
) external view returns (ClaimableRewards[] memory) | ||
``` | ||
Parameters: | ||
`rewardDistributor` - The address of the RewardDistributor contract | ||
`user` - The user's address to check pending rewards on | ||
`allowedRewardTokenList` - The array of available reward tokens to check rewards | ||
|
||
Returns an array with objects with ClaimableRewards data. | ||
|
||
5) Rewards claiming | ||
[Claim one token](./3_RewardDistributor.md/#claimtoken) | ||
[Claim multiple tokens](./3_RewardDistributor.md/#claimtokens) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters