Skip to content

Commit

Permalink
add: liquid staking, distribution section, governance section (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
owenwahlgren authored Oct 8, 2024
2 parents ee7cb34 + 59d6ba4 commit 5e7dad2
Show file tree
Hide file tree
Showing 10 changed files with 848 additions and 36 deletions.
87 changes: 83 additions & 4 deletions content/course/l1-tokenomics/04-staking/02-liquid-staking.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,88 @@
---
title: Liquid Staking
description: Enter description
updated: 2024-09-03
authors: [0xstt]
description: Learn about Liquid Staking and its role in the Avalanche ecosystem.
updated: 2024-10-08
authors: [owenwahlgren]
icon: Book
---

TBD
**Liquid Staking** is an innovative mechanism in blockchain networks that allows users to stake their tokens to secure the network while maintaining liquidity. In the Avalanche ecosystem, liquid staking enables participants to earn staking rewards without locking up their assets entirely, providing flexibility and additional opportunities for yield.

---

## Understanding Liquid Staking

In traditional staking, users lock up their tokens to support network operations like block validation and consensus. While staked, these tokens are illiquid and cannot be used for other purposes until the staking period ends. Liquid staking addresses this limitation by issuing **staking derivatives** or **liquid tokens** that represent the staked assets.

### How It Works

- **Stake Tokens**: Users stake their AVAX or other supported tokens through a liquid staking provider.
- **Receive Liquid Tokens**: In return, they receive liquid tokens equivalent to their staked amount.
- **Earn Rewards**: Users continue to earn staking rewards over time.
- **Maintain Liquidity**: Liquid tokens can be traded, transferred, or used in decentralized finance (**DeFi**) applications.
- **Redeem Staked Assets**: At any time, users can redeem their liquid tokens for the original staked assets, subject to network protocols.

---

## Benefits of Liquid Staking

### Enhanced Liquidity

- **Flexibility**: Users can participate in staking without sacrificing access to their assets.
- **DeFi Integration**: Liquid tokens can be used in lending, borrowing, or yield farming platforms, maximizing potential returns.

### Increased Capital Efficiency

- **Dual Rewards**: Earn staking rewards and additional yields from DeFi activities simultaneously.
- **Portfolio Diversification**: Utilize staked assets in various financial strategies without unstaking.

### Network Security

- **Higher Participation**: Lower barriers encourage more users to stake, enhancing network security and decentralization.
- **Economic Incentives**: Aligns individual incentives with network health by rewarding active participation.

---

## Liquid Staking Providers on Avalanche

### Gogopool

[Gogopool](https://gogopool.com) is a prominent liquid staking provider in the Avalanche ecosystem. It offers a user-friendly platform for staking AVAX tokens while retaining liquidity through their liquid staking token.

#### Features of Gogopool

- **Secure Staking**: Utilizes robust smart contracts audited for security.
- **Competitive Rewards**: Offers attractive staking yields.
- **Easy Integration**: Provides seamless integration with popular DeFi platforms on Avalanche.
- **Community Support**: Active support channels and resources for users.

---

## Considerations and Risks

While liquid staking offers numerous benefits, users should be aware of potential risks:

### Smart Contract Risk

- **Vulnerabilities**: Liquid staking relies on smart contracts that may have undiscovered bugs or vulnerabilities.
- **Mitigation**: Choose providers like Gogopool that have undergone thorough security audits.

### Market Risk

- **Price Volatility**: The value of liquid tokens may fluctuate based on market conditions.
- **Liquidity**: Ensure there is sufficient market liquidity to trade liquid tokens without significant slippage.

### Protocol Risk

- **Slashing Penalties**: In cases of validator misconduct, staked assets may be slashed, affecting the value of liquid tokens.
- **Validator Selection**: Use reputable providers that delegate stakes to trustworthy validators.

---

## Conclusion

Liquid staking enhances the staking experience on Avalanche by combining the benefits of network participation with the flexibility of liquidity. Providers like [Gogopool](https://gogopool.com) make it accessible and secure for users to maximize their asset utility.

By understanding the mechanics and benefits of liquid staking, participants can make informed decisions that align with their investment strategies and contribute to the overall health and decentralization of the Avalanche network.

---
Original file line number Diff line number Diff line change
@@ -1,9 +1,96 @@
---
title: Vesting Schedules
description: Enter description
updated: 2024-09-03
authors: [0xstt]
description: Learn about vesting schedules and how to implement them in Solidity.
updated: 2024-10-08
authors: [owenwahlgren]
icon: Book
---

TBD
**Vesting schedules** are mechanisms used in blockchain projects to release tokens to team members, investors, or other stakeholders over a specified period. This approach helps align incentives, prevent immediate sell-offs, and promote long-term commitment to the project.

---

## Understanding Vesting Schedules

A vesting schedule dictates how and when tokens are released to a recipient. Common elements include:

- **Cliff Period**: An initial period during which no tokens are vested.
- **Vesting Period**: The total duration over which tokens are gradually released.
- **Release Interval**: The frequency at which tokens are released (e.g., monthly, quarterly).
- **Total Allocation**: The total number of tokens to be vested.

### Types of Vesting Schedules

1. **Linear Vesting**: Tokens are released uniformly over the vesting period.
2. **Graded Vesting**: Tokens vest in portions at different intervals.
3. **Cliff Vesting**: All or a significant portion of tokens vest after the cliff period.

---

## Implementing Vesting Schedules in Solidity

Smart contracts can automate vesting schedules, ensuring transparency and trustlessness. Below is an example of a simple Solidity contract implementing a linear vesting schedule.

### Example Solidity Contract

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract TokenVesting {
address public beneficiary;
uint256 public start;
uint256 public duration;
uint256 public cliff;
uint256 public totalTokens;
uint256 public released;
IERC20 public token;
constructor(
address _token,
address _beneficiary,
uint256 _start,
uint256 _cliffDuration,
uint256 _duration,
uint256 _totalTokens
) {
require(_beneficiary != address(0), "Invalid beneficiary");
require(_cliffDuration <= _duration, "Cliff longer than duration");
require(_duration > 0, "Duration must be > 0");
token = IERC20(_token);
beneficiary = _beneficiary;
start = _start;
cliff = _start + _cliffDuration;
duration = _duration;
totalTokens = _totalTokens;
}
function release() public {
require(block.timestamp >= cliff, "Cliff period not reached");
uint256 unreleased = releasableAmount();
require(unreleased > 0, "No tokens to release");
released += unreleased;
token.transfer(beneficiary, unreleased);
}
function releasableAmount() public view returns (uint256) {
return vestedAmount() - released;
}
function vestedAmount() public view returns (uint256) {
if (block.timestamp < cliff) {
return 0;
} else if (block.timestamp >= start + duration) {
return totalTokens;
} else {
return (totalTokens * (block.timestamp - start)) / duration;
}
}
}
interface IERC20 {
function transfer(address recipient, uint256 amount) external returns (bool);
}
165 changes: 161 additions & 4 deletions content/course/l1-tokenomics/06-distribution/03-bonding-curves.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,166 @@
---
title: Bonding Curves
description: Enter description
updated: 2024-09-03
authors: [0xstt]
description: Learn about bonding curves and their role in token economics.
updated: 2024-10-08
authors: [owenwahlgren]
icon: Book
---

TBD
**Bonding curves** are mathematical formulas used in blockchain and token economics to define the relationship between a token's price and its supply. They provide a mechanism for automated price discovery and liquidity, enabling decentralized issuance and trading of tokens without relying on traditional market makers or exchanges.

---

## Understanding Bonding Curves

A bonding curve is a continuous token model where the price of a token is determined by a predefined mathematical function based on the total supply in circulation. As more tokens are purchased and the supply increases, the price per token rises according to the curve. Conversely, selling tokens decreases the supply and lowers the price.

### Key Concepts

- **Automated Market Maker (AMM)**: A system that provides liquidity and facilitates trading by automatically adjusting prices based on supply and demand.
- **Price Function**: A mathematical formula that defines how the token price changes with supply.
- **Liquidity Pool**: A reserve of tokens used to facilitate buying and selling without requiring counterparties.

---

## How Bonding Curves Work

### Price Functions

The bonding curve relies on a price function `P(S)`, where:

- `P` is the price per token.
- `S` is the current supply of tokens.

Common price functions include linear, exponential, and sigmoid curves.

#### Linear Bonding Curve

A simple linear function:

```
P(S) = a * S + b
```

- `a` and `b` are constants defining the slope and intercept.

#### Exponential Bonding Curve

An exponential function:

```
P(S) = e^(k * S)
```

- `e` is the base of the natural logarithm.
- `k` is a constant determining the rate of price increase.

### Buying and Selling Tokens

- **Buying Tokens**: To purchase tokens, a user pays an amount calculated by integrating the price function over the desired increase in supply.
- **Selling Tokens**: To sell tokens, a user receives an amount calculated by integrating the price function over the desired decrease in supply.

---

## Applications of Bonding Curves

### Token Launch Mechanisms

Bonding curves enable projects to launch tokens without initial liquidity or listing on exchanges.

- **Continuous Token Issuance**: Tokens can be minted on-demand as users buy them.
- **Fair Price Discovery**: Prices adjust automatically based on demand.

### Decentralized Finance (DeFi)

Used in AMMs and liquidity pools to facilitate decentralized trading.

- **Uniswap**: Utilizes bonding curves for token swaps.
- **Balancer**: Manages portfolios using bonding curves.

### Fundraising and DAOs

Facilitate fundraising by allowing investors to buy tokens that represent shares or voting rights.

- **Continuous Organizations**: Organizations that continuously raise funds through token sales governed by bonding curves.
- **DAO Membership**: Tokens purchased via bonding curves grant access and voting power.

---

## Implementing Bonding Curves in Smart Contracts

### Solidity Example

Below is a simplified example of implementing a linear bonding curve in Solidity.

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract BondingCurve {
uint256 public totalSupply;
uint256 public constant a = 1e18; // Slope
uint256 public constant b = 1e18; // Intercept
mapping(address => uint256) public balances;
function buy() external payable {
uint256 tokensToMint = calculateTokensToMint(msg.value);
balances[msg.sender] += tokensToMint;
totalSupply += tokensToMint;
}
function sell(uint256 tokenAmount) external {
require(balances[msg.sender] >= tokenAmount, "Insufficient balance");
uint256 ethToReturn = calculateEthToReturn(tokenAmount);
balances[msg.sender] -= tokenAmount;
totalSupply -= tokenAmount;
payable(msg.sender).transfer(ethToReturn);
}
function calculatePrice(uint256 supply) public pure returns (uint256) {
return a * supply + b;
}
function calculateTokensToMint(uint256 ethAmount) public view returns (uint256) {
// Simplified calculation for demonstration purposes
uint256 tokens = ethAmount / calculatePrice(totalSupply);
return tokens;
}
function calculateEthToReturn(uint256 tokenAmount) public view returns (uint256) {
// Simplified calculation for demonstration purposes
uint256 ethAmount = tokenAmount * calculatePrice(totalSupply);
return ethAmount;
}
}
```

Explanation

- **`buy()`:** Users send ETH to buy tokens. The number of tokens minted is calculated based on the bonding curve.
- **`sell()`:** Users can sell their tokens back for ETH. The amount of ETH returned is calculated based on the current supply.
- **`calculatePrice()`:** Determines the price per token based on the total supply.

<Callout>This is a simplified example and not suitable for production. Proper handling of floating-point arithmetic and security considerations is necessary.</Callout>

### Considerations and Risks

**Price Volatility**

- **Speculation**: Prices can become volatile due to speculative trading.
- **Market Manipulation**: Large trades may influence prices significantly.

**Smart Contract Risks**

- **Security Vulnerabilities**: Bugs in the contract can lead to loss of funds.
- **Complexity**: Implementing accurate bonding curves requires careful mathematical and technical design.

**Liquidity Concerns**

- **Slippage**: Large trades may experience significant price slippage.
- **Liquidity Pools**: Adequate reserves are necessary to handle buy and sell orders.

## Conclusion

Bonding curves offer a powerful tool for automated price discovery and token issuance in decentralized networks like Avalanche. They enable projects to create self-sustaining economies with built-in liquidity and dynamic pricing. Understanding bonding curves is essential for developers and stakeholders involved in tokenomics and decentralized finance.

By carefully designing bonding curve parameters and smart contracts, projects can align incentives, promote fair participation, and foster sustainable growth within their ecosystems.
Loading

0 comments on commit 5e7dad2

Please sign in to comment.