Skip to content

Commit 7f5fc6b

Browse files
committed
Merge remote-tracking branch 'origin/feat--update-and-re-org-yETH' into pr/rossgalloway/33
2 parents 9fecf30 + a238273 commit 7f5fc6b

37 files changed

+1943
-152
lines changed

docs/developers/addresses/v3-contracts.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# yVaults v3 Contract Addresses
22

3+
34
<AddressCheck contractType='v3'/>
45

6+
57
:::info
68

79
Deployments are done using create2 factories and should be stable across all EVM chains the protocol has been deployed on.

docs/developers/addresses/veyfi-contracts.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@
3434
| 13 | `yG-yvcrvUSD-2` | yGauge crvUSD-2 yVault | [`0x71c3223D6f836f84cAA7ab5a68AAb6ECe21A9f3b`](https://etherscan.io/address/0x71c3223D6f836f84cAA7ab5a68AAb6ECe21A9f3b) |
3535
| 14| `yG-yvUSDS-1` | yGauge USDS-1 yVault | [`0xd57aEa3686d623dA2dCEbc87010a4F2F38Ac7B15`](https://etherscan.io/address/0xd57aEa3686d623dA2dCEbc87010a4F2F38Ac7B15) |
3636

37+
3738
The above Gauges can be verified using the [YFI Gauge Registry](https://etherscan.io/address/0x1D0fdCb628b2f8c0e22354d45B3B2D4cE9936F8B#readContract) contract and querying the `gauges()` function with the index listed above.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# yPools Contract Addresses
2+
3+
A list of all the current yPool contract addresses.
4+
5+
## yETH contract Addresses
6+
7+
| Name | Address |
8+
|--------------------------------------------------|-------------------------------------|
9+
| yETH | [`0x1BED97CBC3c24A4fb5C069C6E311a967386131f7`](https://etherscan.io/address/0x1BED97CBC3c24A4fb5C069C6E311a967386131f7) |
10+
| st-yETH | [`0x583019fF0f430721aDa9cfb4fac8F06cA104d0B4`](https://etherscan.io/address/0x583019fF0f430721aDa9cfb4fac8F06cA104d0B4) |
11+
| Pool | [`0x2cced4ffA804ADbe1269cDFc22D7904471aBdE63`](https://etherscan.io/address/0x2cced4ffA804ADbe1269cDFc22D7904471aBdE63) |
12+
| | |
13+
| Management | [`0xbBBBBbbB6B942883EAd4976882C99201108c784d`](https://etherscan.io/address/0xbBBBBbbB6B942883EAd4976882C99201108c784d) |
14+
| Guardian | [`0xDC775e813cDB38a4f02c4BAd3942319088018eFA`](https://etherscan.io/address/0xDC775e813cDB38a4f02c4BAd3942319088018eFA) |
15+
| | |
16+
| Protocol Owned Liquidity | [`0x929401e30Aab6bd648dEf2d30FF44952BaB04478`](https://etherscan.io/address/0x929401e30Aab6bd648dEf2d30FF44952BaB04478) |
17+
| Bootstrap: Deposit, Vote, Claim Incentives | [`0x41B994C192183793bB9cc35bAAb8bD9C6885c6bf`](https://etherscan.io/address/0x41B994C192183793bB9cc35bAAb8bD9C6885c6bf) |
18+
| Bootstrap: Claim st-yETH | [`0x7cf484D9d16BA26aB3bCdc8EC4a73aC50136d491`](https://etherscan.io/address/0x7cf484D9d16BA26aB3bCdc8EC4a73aC50136d491) |
19+
| Rate Providers | [`0x4e322aeAf355dFf8fb9Fd5D18F3D87667E8f8316`](https://etherscan.io/address/0x4e322aeAf355dFf8fb9Fd5D18F3D87667E8f8316) |
20+
| | |
21+
| Inclusion Vote | ['0x6bc0878939669339e82dbFa13d260c89230f2c31'](https://etherscan.io/address/0x6bc0878939669339e82dbFa13d260c89230f2c31) |
22+
| Executor | ['0x71258Ee726644f1D52d6A9F5E11C21d1E38c2bF1'](https://etherscan.io/address/0x71258Ee726644f1D52d6A9F5E11C21d1E38c2bF1) |
23+
| GenericGovernor | ['0xB7a528CF6D36F736Fa678A629b98A427d43E5ba5'](https://etherscan.io/address/0xB7a528CF6D36F736Fa678A629b98A427d43E5ba5) |
24+
25+
> Due to a redeploy of st-yETH during the bootstrap process the first st-yETH contract has been deprecated, use the `Bootstrap: Claim st-yETH` contract to claim the new version if you participated in the bootstrap phase.
26+
27+
Find more information about the yPools Roles, modes, and privileges [here](/developers/ypools/ypools-roles)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Adding Assets to yPools
2+
3+
Follow these steps to enable the inclusion of new assets into yETH via governance proposal and voting.
4+
5+
:::info[Pre-requisites]
6+
7+
You will need access to the necessary governance contracts and a sufficient voting weight of at least 100 to create proposals. You can check your voting weight [here](https://etherscan.io/address/0x583019fF0f430721aDa9cfb4fac8F06cA104d0B4#readContract#F13).
8+
9+
:::
10+
11+
## Steps
12+
13+
### Step 1: Check Inclusion Vote Status
14+
15+
Since the adoption of [this](https://snapshot.org/#/ylsd.eth/proposal/0x139698bed7752b80a16bb6d2fc0d9e8c82b622916ded2f064022be3c46ec9bb4) proposal, inclusion voting is off by default and needs to be enabled for the next epoch
16+
17+
### Step 2: Enable One-Off Inclusion Vote
18+
19+
To enable a one-off inclusion vote, a governance call must be made to the set_enable_epoch(next_epoch) function on the [InclusionVote contract](https://etherscan.io/address/0x6bc0878939669339e82dbFa13d260c89230f2c31#code).
20+
21+
This step requires crafting and approving a governance proposal. Follow the instructions [here](create-gov-proposal.md) to do that successfully.
22+
23+
### Step 3: Eligible Tokens for Voting
24+
25+
Any token that has applied for inclusion and has a rate provider set by Yearn will be eligible for this inclusion vote.
26+
27+
### Step 4: Outcome
28+
29+
Once the vote is complete, the winner (if any) will be included into yETH.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
rpcCalls:
3+
- name: 'yPools Inclusion'
4+
chain: '1'
5+
address: '0x6bc0878939669339e82dbFa13d260c89230f2c31'
6+
abiName: 'yPoolsInclusionVoteABI'
7+
methods:
8+
- 'epoch'
9+
---
10+
<!-- markdownlint-disable MD037 -->
11+
12+
# Create a Governance Proposal
13+
14+
:::info[Pre-requisites]
15+
16+
You will need access to the necessary governance contracts and a sufficient voting weight of at least 100 to create proposals. You can check your voting weight [here](https://etherscan.io/address/0x583019fF0f430721aDa9cfb4fac8F06cA104d0B4#readContract#F13).
17+
18+
:::
19+
20+
## Step 1: Craft the Proposal Script
21+
22+
1. Generate a script by calling the `script(_to, _data)` view function on the [Executor contract](https://etherscan.io/address/0x71258Ee726644f1D52d6A9F5E11C21d1E38c2bF1#readContract#F1).
23+
24+
In this case, set the `_to(address)` field to the [InclusionVote contract](../../addresses/ypools-contracts.md#yeth-contract-addresses) `0x6bc0878939669339e82dbFa13d260c89230f2c31` and use ABI-encoded data for the function set_enable_epoch(next_epoch) as the calldata (_data).
25+
26+
<AbiEncodingWidget defaultAbi='yPoolsInclusionVoteABI' defaultFunction='set_enable_epoch' functionArg='20'/>
27+
28+
2. To enable multiple calls in a single proposal, concatenate the scripts together.
29+
30+
## Step 2: Submit a Governance Proposal
31+
32+
1. You can create the proposal via the [proposal page](https://yeth.yearn.fi/propose) or directly by calling the propose(ipfs_hash, script) function on the [GenericGovernor contract](https://etherscan.io/address/0xB7a528CF6D36F736Fa678A629b98A427d43E5ba5).
33+
2. The ipfs_hash should point to a document hosted on IPFS with details explaining the proposal and its rationale. You can host your own IPFS document or use a provider like [Piñata](https://pinata.cloud/).
34+
35+
## Step 3: Proposal Approval and Execution
36+
37+
Once the proposal is created, the governance process will need to:
38+
39+
1. Approve the proposal.
40+
2. Execute the set_enable_epoch(next_epoch) function to enable the inclusion vote for the next epoch.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Governance Specification
2+
3+
Contracts for fully on-chain governance, consisting of multiple cooperating components. Each component can be swapped out in the future if our requirements change. The different concepts and contracts are as follows:
4+
5+
```mermaid
6+
graph TD
7+
classDef entity fill:#f9f,stroke:#red,stroke-width:5px;
8+
classDef relationship fill:#bbf,stroke:#green,stroke-width:5px;
9+
10+
yPoolsMultiSig -->|Manages| OwnershipProxy
11+
OwnershipProxy -->|Manages| Executor
12+
Executor -->|Manages| GenericGovernor
13+
Executor -->|Manages| PoolGovernor
14+
15+
GenericGovernor -->|Uses| Measure
16+
PoolGovernor -->|Uses| Measure
17+
18+
Measure -->|Types| LaunchMeasure
19+
Measure -->|Types| DelegateMeasure
20+
21+
DelegateMeasure -->|Delegates Voting Power via| DelegatedStaking
22+
23+
PoolGovernor -->|Uses| InclusionVote
24+
PoolGovernor -->|Uses| WeightVote
25+
26+
InclusionVote -->|Interacts with| InclusionIncentives
27+
WeightVote -->|Interacts with| WeightIncentives
28+
```
29+
30+
- The entire protocol defines a set of management roles, which have powers within the protocol to set variables, rates, add assets etc. With the transition to on-chain governance, the **OwnershipProxy** will become the new owner of all these management roles, including the ones descriped below (excluding the proxy's own). This contract is very simple and is able to execute arbitary contract calls. Note that this is not a delegatecall proxy!
31+
- The proxy has its own management, which will be the **Executor** and has permission to execute calls through the proxy. The executor maintains a list of governors, which are allowed to execute function calls through executor onto the proxy. In addition, the executor has the ability to enable a whitelist or blacklist for combination of address+selector. This allows us to define governors with only limited power.
32+
The executor is self-governing, meaning the proxy is supposed to fulfill its management role.
33+
The two-layer design of proxy and executor allows us to easily replace the executor if desired without having to move all the management permissions over one by one.
34+
- There are two governors: **GenericGovernor** and **PoolGovernor**. They both take governance actions based on on-chain voting procedures.
35+
- On-chain voting is based on 4 week long _epochs_. These coincide with Curve epochs, starting on a Thursday 00:00 GMT.
36+
All voting takes place on the last week of the epoch.
37+
- The voting power of governance participant is measured by a **Measure**. At launch, we used the **LaunchMeasure** on Snapshot (with **SnapshotToken**, which simply provides an ERC20 for the launch measure). The launch measure simply defines the vote weight as the user's st-yETH weight plus the user's share of the bootstrap st-yETH weight.
38+
- With the transition to on-chain governance, a new measure is introduced, the **DelegateMeasure**. By default this returns the same value as the launch measure. But management has the ability to delegate the voting power of an account that deposited into a **DelegatedStaking** contract to another account. This gives some of the st-yETH balance as voting power to the delegator.
39+
- In the first 3 weeks of the epoch, the **GenericGovernor** accepts proposals from anyone with sufficient voting weight. Proposals come in the form of a script, which will be executed on the executor if passed. In the final week of the epoch, users vote in favor or against each proposal. At the end of the epoch, all proposals that pass a threshold of relative votes in favor, will have passed. They become executable by anyone after a delay.
40+
The author of the proposal can retract their proposal, and management can cancel any before it is executed.
41+
- A second voting contract is **InclusionVote**. In the first three weeks, anyone can apply (upon paying a fee) for a token to be whitelisted for the vote.
42+
A special role, the operator, has the task of setting rate providers for each of the applicants. An application with a rate provider automatically becomes whitelisted, meaning they can be voted on.
43+
The voting takes place in the last week of the epoch. The asset with the largest number of votes will be added to the pool.
44+
One of the vote options is a 'blank' vote. If that option has the most votes, no new asset will be added to the pool this epoch.
45+
- Anyone can post incentives for any asset to be added to the pool in **InclusionIncentives**. If the asset wins the vote and is added, the incentives are paid out to everyone that voted. If the asset does not win, the incentives are refunded.
46+
- The third voting contract is **WeightVote**. This contract is used to vote on the existing assets in the pool, and a 'blank' option. At the end of the epoch, a certain percentage of all weight is redistributed according to the result of this vote.
47+
- The **WeightIncentives** contract is used to post incentives for voting on the assets. The incentives are distributed according to the voting weight dedicated by each user to that specific asset.
48+
- The inclusion voting and weight voting contracts are not governors, instead they are used by the **PoolGovernor**. After the end of the epoch, the pool governor first adds the winning asset (if any) to the pool with a very low weight, through the executor. Immediately after, it starts a weight ramp, redistributing weights according to the vote results, as well as increasing the weight of the new asset.
49+
The pool governor is operated by an operator, which is a role tasked with adding the asset to the pool while minimizing the arb opportunities. This is a trusted role, but has very limited powers as it cannot change weights at will or add arbitrary assets.

docs/developers/ypools/yeth/wp.md

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# yETH Weighted Stableswap
2+
3+
## Author
4+
5+
0xkorin - Yearn Finance (0xkorin@proton.me)
6+
7+
---
8+
9+
## Invariant Derivation
10+
11+
### Constant Sum
12+
13+
$$
14+
\sum_i x_i = c_1
15+
$$
16+
17+
### Constant Weighted Product
18+
19+
$$
20+
\prod_i x_i^{w_i} = c_2 \quad \text{with} \quad \sum_i w_i = 1
21+
$$
22+
23+
Define:
24+
$$
25+
\frac{1}{f} \coloneqq \prod_i w_i^{w_i}, \quad v_i \coloneqq w_i^n
26+
$$
27+
28+
### Balanced Pool
29+
30+
$$
31+
x_i = w_i D \implies c_1 = D \sum_i w_i = D, \quad c_2 = D \prod_i w_i^{w_i} = \frac{D}{f}
32+
$$
33+
34+
$$
35+
x_i = \frac{D}{f^{v_i}}
36+
$$
37+
38+
---
39+
40+
## Leveraged Invariant
41+
42+
$$
43+
\chi D^{n-1} \sum_i x_i + \prod_i x_i^{v_i} = \chi D^n + \frac{D^n}{f^n}
44+
$$
45+
46+
---
47+
48+
## Dynamic Leverage
49+
50+
$$
51+
\chi = A \prod_i x_i^{v_i} \frac{D^n}{f^n}
52+
$$
53+
54+
---
55+
56+
## Weighted Stableswap Invariant
57+
58+
$$
59+
A f^n \sum_i x_i + D = A D f^n + \frac{D^{n+1}}{f^n \prod_i x_i^{v_i}}
60+
$$
61+
62+
This reduces to the original stableswap invariant if we set equal weights $w_i = \frac{1}{n}$.
63+
64+
Define:
65+
$$
66+
\sigma \coloneqq \sum_i x_i, \quad \pi \coloneqq \frac{D^n}{\prod_i w_i x_i^{v_i}}
67+
$$
68+
69+
$$
70+
A f^n \sigma + D = A D f^n + D \pi \tag{1}
71+
$$
72+
73+
---
74+
75+
## Supply Calculation
76+
77+
Given a pool with weights $\{w_i\}$ and virtual balances $\{x_i\}$, the equilibrium supply $D$ can be found by solving Equation (1) iteratively:
78+
79+
$$
80+
D_{m+1} = \frac{A f^n \sigma - D_m \pi_m}{A f^n - 1}
81+
$$
82+
83+
Where:
84+
$$
85+
\pi_m = \frac{D_m^n}{D_{m-1}^n} \pi_{m-1}
86+
$$
87+
88+
Starting with:
89+
$$
90+
\pi_0 = \prod_i \frac{D_0 w_i x_i^{v_i}}{D_0}
91+
$$
92+
93+
The iterative process begins with a good initial guess for $D_0$ (e.g., $\sigma$) and continues until the desired precision is achieved.
94+
95+
---
96+
97+
## Rate Update
98+
99+
$$
100+
x_i = b_i r_i \rightarrow x_i' = b_i r_i'
101+
$$
102+
103+
$$
104+
\sigma \rightarrow \sigma' = \sigma + b_i (r_i' - r_i)
105+
$$
106+
107+
$$
108+
D \rightarrow D', \quad \pi \rightarrow \pi' = \frac{D'^n}{D^n} \frac{r_i}{r_i'} v_i \pi
109+
$$
110+
111+
Equation (2) is used iteratively to find both $D'$ and $\pi'$, starting with $D'_0 = D$ and $\pi'_0 = \pi \frac{r_i}{r_i'} v_i$.
112+
113+
---
114+
115+
## Balance Calculation
116+
117+
Given weights $\{w_i\}$, virtual balances $\{x_i\}_{i \neq j}$, and supply $D$, the balance of a specific asset $j$ can be found by solving Equation (1) for $y \coloneqq x_j$.
118+
119+
Define intermediary variables:
120+
$$
121+
\tilde{\sigma} \coloneqq \sum_{i \neq j} x_i, \quad \tilde{\pi} \coloneqq \frac{D^n w_j^{v_j}}{\prod_{i \neq j} w_i x_i^{v_i}}
122+
$$
123+
124+
Rewriting Equation (1):
125+
$$
126+
A f^n (\tilde{\sigma} + y) + D = A D f^n + D \tilde{\pi} y^{v_j}
127+
$$
128+
129+
Rearranging:
130+
$$
131+
y^{v_j+1} + \tilde{\sigma} y^{v_j} - \frac{D}{A f^n} y - \frac{D}{A f^n} \tilde{\pi} = 0
132+
$$
133+
134+
This root can be found using Newton's method.
135+
136+
---
137+
138+
## Swaps
139+
140+
### Exact Input
141+
142+
Find $\Delta b_l$ given $\Delta b_k$:
143+
$$
144+
\tilde{\sigma} = \sigma + \Delta b_k r_k - x_l, \quad \tilde{\pi} = \frac{x_k}{x_k'} v_k \frac{x_l^{v_l}}{\pi}
145+
$$
146+
147+
$$
148+
\Delta b_l = \frac{x_l - x_l'}{r_l}
149+
$$
150+
151+
---
152+
153+
### Exact Output
154+
155+
Find $\Delta b_k$ given $\Delta b_l$:
156+
$$
157+
\tilde{\sigma} = \sigma - x_k - \Delta b_l r_l, \quad \tilde{\pi} = \frac{x_k^{v_k}}{x_l x_l'} v_l \pi
158+
$$
159+
160+
$$
161+
\Delta b_k = \frac{x_k' - x_k}{r_k}
162+
$$

0 commit comments

Comments
 (0)