Skip to content

Commit df726c4

Browse files
authored
L1 Native Tokenomics: copying over distribution + governance chapters (#2793)
* cherry-picking structure * layout * layout precompiles * layout native minter * copied contents from tokenomics og course
1 parent caa13b3 commit df726c4

File tree

17 files changed

+925
-1
lines changed

17 files changed

+925
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Introduction
3+
description: ...
4+
updated: 2025-08-21
5+
authors: [nicolasarnedo]
6+
icon: Book
7+
---
8+
9+
bla bla
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Introduction
3+
description: ...
4+
updated: 2025-08-21
5+
authors: [nicolasarnedo]
6+
icon: Book
7+
---
8+
9+
bla bla
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Introduction
3+
description: ...
4+
updated: 2025-08-21
5+
authors: [nicolasarnedo]
6+
icon: Book
7+
---
8+
9+
bla bla
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Introduction
3+
description: ...
4+
updated: 2025-08-21
5+
authors: [nicolasarnedo]
6+
icon: Book
7+
---
8+
9+
bla bla
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: Initial Allocation
3+
description: Considerations for the initial token allocation on an Avalanche L1
4+
updated: 2024-09-03
5+
authors: [0xstt]
6+
icon: Book
7+
---
8+
9+
The creator of an Avalanche L1 can pre-allocate native tokens during the chain genesis event. This **initial token allocation** refers to the distribution of tokens or digital assets when a new blockchain network is launched, which is a crucial aspect of the network's design.
10+
11+
> **Note:** Initial token allocation determines how tokens are distributed among stakeholders and participants.
12+
13+
### Key Considerations for Initial Token Allocation
14+
15+
There are several factors to consider when allocating tokens:
16+
17+
#### Founders and Development Team
18+
19+
A portion of the initial token supply is often allocated to the founders and the development team as a reward for their efforts in creating the blockchain protocol. This serves as an incentive for continued development and network maintenance.
20+
21+
#### Early Investors and Backers
22+
23+
Another portion of the token supply may be allocated to early investors and backers who provided funding or support during the project's early stages. These entities take on early risk and are rewarded with tokens that may increase in value as the network grows.
24+
25+
#### Community
26+
27+
A significant portion of tokens may be allocated to the community through mechanisms such as token sales, airdrops, or other distribution methods. This ensures widespread ownership and participation in the network, fostering decentralization and security.
28+
29+
#### Reserve
30+
31+
Some tokens may be allocated to a reserve or treasury to fund ongoing development, marketing, and ecosystem growth initiatives. This reserve can be managed by a DAO or another entity tasked with allocating funds for the network's benefit.
32+
33+
> **Tip:** Transparent and equitable token allocation mechanisms are essential for fostering trust and confidence in the network among its stakeholders.
34+
35+
<Quiz quizId="212" />
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
title: Vesting Schedules
3+
description: Learn about vesting schedules and how to implement them in Solidity.
4+
updated: 2024-10-08
5+
authors: [owenwahlgren]
6+
icon: Book
7+
---
8+
9+
**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.
10+
11+
---
12+
13+
## Understanding Vesting Schedules
14+
15+
A vesting schedule dictates how and when tokens are released to a recipient. Common elements include:
16+
17+
- **Cliff Period**: An initial period during which no tokens are vested.
18+
- **Vesting Period**: The total duration over which tokens are gradually released.
19+
- **Release Interval**: The frequency at which tokens are released (e.g., monthly, quarterly).
20+
- **Total Allocation**: The total number of tokens to be vested.
21+
22+
### Types of Vesting Schedules
23+
24+
1. **Linear Vesting**: Tokens are released uniformly over the vesting period.
25+
2. **Graded Vesting**: Tokens vest in portions at different intervals.
26+
3. **Cliff Vesting**: All or a significant portion of tokens vest after the cliff period.
27+
28+
---
29+
30+
## Implementing Vesting Schedules in Solidity
31+
32+
Smart contracts can automate vesting schedules, ensuring transparency and trustlessness. Below is an example of a simple Solidity contract implementing a linear vesting schedule.
33+
34+
### Example Solidity Contract
35+
36+
```solidity
37+
// SPDX-License-Identifier: MIT
38+
pragma solidity ^0.8.0;
39+
40+
contract TokenVesting {
41+
address public beneficiary;
42+
uint256 public start;
43+
uint256 public duration;
44+
uint256 public cliff;
45+
uint256 public totalTokens;
46+
uint256 public released;
47+
48+
IERC20 public token;
49+
50+
constructor(
51+
address _token,
52+
address _beneficiary,
53+
uint256 _start,
54+
uint256 _cliffDuration,
55+
uint256 _duration,
56+
uint256 _totalTokens
57+
) {
58+
require(_beneficiary != address(0), "Invalid beneficiary");
59+
require(_cliffDuration <= _duration, "Cliff longer than duration");
60+
require(_duration > 0, "Duration must be > 0");
61+
62+
token = IERC20(_token);
63+
beneficiary = _beneficiary;
64+
start = _start;
65+
cliff = _start + _cliffDuration;
66+
duration = _duration;
67+
totalTokens = _totalTokens;
68+
}
69+
70+
function release() public {
71+
require(block.timestamp >= cliff, "Cliff period not reached");
72+
uint256 unreleased = releasableAmount();
73+
require(unreleased > 0, "No tokens to release");
74+
75+
released += unreleased;
76+
token.transfer(beneficiary, unreleased);
77+
}
78+
79+
function releasableAmount() public view returns (uint256) {
80+
return vestedAmount() - released;
81+
}
82+
83+
function vestedAmount() public view returns (uint256) {
84+
if (block.timestamp < cliff) {
85+
return 0;
86+
} else if (block.timestamp >= start + duration) {
87+
return totalTokens;
88+
} else {
89+
return (totalTokens * (block.timestamp - start)) / duration;
90+
}
91+
}
92+
}
93+
94+
interface IERC20 {
95+
function transfer(address recipient, uint256 amount) external returns (bool);
96+
}
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
---
2+
title: Bonding Curves
3+
description: Learn about bonding curves and their role in token economics.
4+
updated: 2024-10-08
5+
authors: [owenwahlgren]
6+
icon: Book
7+
---
8+
9+
**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.
10+
11+
---
12+
13+
## Understanding Bonding Curves
14+
15+
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.
16+
17+
### Key Concepts
18+
19+
- **Automated Market Maker (AMM)**: A system that provides liquidity and facilitates trading by automatically adjusting prices based on supply and demand.
20+
- **Price Function**: A mathematical formula that defines how the token price changes with supply.
21+
- **Liquidity Pool**: A reserve of tokens used to facilitate buying and selling without requiring counterparties.
22+
23+
---
24+
25+
## How Bonding Curves Work
26+
27+
### Price Functions
28+
29+
The bonding curve relies on a price function `P(S)`, where:
30+
31+
- `P` is the price per token.
32+
- `S` is the current supply of tokens.
33+
34+
Common price functions include linear, exponential, and sigmoid curves.
35+
36+
#### Linear Bonding Curve
37+
38+
A simple linear function:
39+
40+
```
41+
P(S) = a * S + b
42+
```
43+
44+
- `a` and `b` are constants defining the slope and intercept.
45+
46+
#### Exponential Bonding Curve
47+
48+
An exponential function:
49+
50+
```
51+
P(S) = e^(k * S)
52+
```
53+
54+
- `e` is the base of the natural logarithm.
55+
- `k` is a constant determining the rate of price increase.
56+
57+
### Buying and Selling Tokens
58+
59+
- **Buying Tokens**: To purchase tokens, a user pays an amount calculated by integrating the price function over the desired increase in supply.
60+
- **Selling Tokens**: To sell tokens, a user receives an amount calculated by integrating the price function over the desired decrease in supply.
61+
62+
---
63+
64+
## Applications of Bonding Curves
65+
66+
### Token Launch Mechanisms
67+
68+
Bonding curves enable projects to launch tokens without initial liquidity or listing on exchanges.
69+
70+
- **Continuous Token Issuance**: Tokens can be minted on-demand as users buy them.
71+
- **Fair Price Discovery**: Prices adjust automatically based on demand.
72+
73+
### Decentralized Finance (DeFi)
74+
75+
Used in AMMs and liquidity pools to facilitate decentralized trading.
76+
77+
- **Uniswap**: Utilizes bonding curves for token swaps.
78+
- **Balancer**: Manages portfolios using bonding curves.
79+
80+
### Fundraising and DAOs
81+
82+
Facilitate fundraising by allowing investors to buy tokens that represent shares or voting rights.
83+
84+
- **Continuous Organizations**: Organizations that continuously raise funds through token sales governed by bonding curves.
85+
- **DAO Membership**: Tokens purchased via bonding curves grant access and voting power.
86+
87+
---
88+
89+
## Implementing Bonding Curves in Smart Contracts
90+
91+
### Solidity Example
92+
93+
Below is a simplified example of implementing a linear bonding curve in Solidity.
94+
95+
```solidity
96+
// SPDX-License-Identifier: MIT
97+
pragma solidity ^0.8.0;
98+
99+
contract BondingCurve {
100+
uint256 public totalSupply;
101+
uint256 public constant a = 1e18; // Slope
102+
uint256 public constant b = 1e18; // Intercept
103+
mapping(address => uint256) public balances;
104+
105+
function buy() external payable {
106+
uint256 tokensToMint = calculateTokensToMint(msg.value);
107+
balances[msg.sender] += tokensToMint;
108+
totalSupply += tokensToMint;
109+
}
110+
111+
function sell(uint256 tokenAmount) external {
112+
require(balances[msg.sender] >= tokenAmount, "Insufficient balance");
113+
uint256 ethToReturn = calculateEthToReturn(tokenAmount);
114+
balances[msg.sender] -= tokenAmount;
115+
totalSupply -= tokenAmount;
116+
payable(msg.sender).transfer(ethToReturn);
117+
}
118+
119+
function calculatePrice(uint256 supply) public pure returns (uint256) {
120+
return a * supply + b;
121+
}
122+
123+
function calculateTokensToMint(uint256 ethAmount) public view returns (uint256) {
124+
// Simplified calculation for demonstration purposes
125+
uint256 tokens = ethAmount / calculatePrice(totalSupply);
126+
return tokens;
127+
}
128+
129+
function calculateEthToReturn(uint256 tokenAmount) public view returns (uint256) {
130+
// Simplified calculation for demonstration purposes
131+
uint256 ethAmount = tokenAmount * calculatePrice(totalSupply);
132+
return ethAmount;
133+
}
134+
}
135+
```
136+
137+
Explanation
138+
139+
- **`buy()`:** Users send ETH to buy tokens. The number of tokens minted is calculated based on the bonding curve.
140+
- **`sell()`:** Users can sell their tokens back for ETH. The amount of ETH returned is calculated based on the current supply.
141+
- **`calculatePrice()`:** Determines the price per token based on the total supply.
142+
143+
<Callout>This is a simplified example and not suitable for production. Proper handling of floating-point arithmetic and security considerations is necessary.</Callout>
144+
145+
### Considerations and Risks
146+
147+
**Price Volatility**
148+
149+
- **Speculation**: Prices can become volatile due to speculative trading.
150+
- **Market Manipulation**: Large trades may influence prices significantly.
151+
152+
**Smart Contract Risks**
153+
154+
- **Security Vulnerabilities**: Bugs in the contract can lead to loss of funds.
155+
- **Complexity**: Implementing accurate bonding curves requires careful mathematical and technical design.
156+
157+
**Liquidity Concerns**
158+
159+
- **Slippage**: Large trades may experience significant price slippage.
160+
- **Liquidity Pools**: Adequate reserves are necessary to handle buy and sell orders.
161+
162+
## Conclusion
163+
164+
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.
165+
166+
By carefully designing bonding curve parameters and smart contracts, projects can align incentives, promote fair participation, and foster sustainable growth within their ecosystems.
167+
<Quiz quizId="213"/>

0 commit comments

Comments
 (0)