Skip to content

Commit

Permalink
s/🍠/🐷/g
Browse files Browse the repository at this point in the history
  • Loading branch information
hamburglar1971 committed Aug 13, 2020
1 parent d3973c9 commit 668ece9
Show file tree
Hide file tree
Showing 329 changed files with 3,541 additions and 937,778 deletions.
70 changes: 36 additions & 34 deletions ProtocolLevers.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
# Levers

The expectation is that after the pools receive their YAMs, there is no longer a founding team or any team to speak of. This is a protocol that is being put out there in a decentralized way, then walk away. The writer of these contracts or those connected with its inception, are under no obligation and likely won't continue development once it is deployed.
The expectation is that after the pools receive their HAMs, the forking degenerates are nowhere to be found. This is a protocol that will be launched, and left to the growing community of meat eaters.

That said, it would be helpful for governance to have a well documented set of levers inside the protocol so if the community wishes to govern, they can.
If you do need help or technical support, you can always harass [whoever runs the Yam Finance Twitter](https://twitter.com/YamFinance) or maybe just [Dan Elitzer](https://twitter.com/delitzer) since he seems pretty smart. You might have to pretend you like sweet potatoes though.

## YAM Levers
To help ensure governance by a robust group of degenerate meat eaters, here's a TL;DR

## HAM Levers

#### `gov`/`pendingGov`
##### File: `YAMTokenStorage.sol`
##### File: `HAMTokenStorage.sol`
##### Description
address that controls every permissioned function, or is primed to.
##### Setting
###### File: `YAM.sol`
###### File: `HAM.sol`
`_setPendingGov(address)`: sets `pendingGov` to new address. To complete the change of governance, the new governance contract has to call `_acceptGov()`.

<br />
<br />
<br />

#### `rebaser`
##### File: `YAMTokenStorage.sol`
##### File: `HAMTokenStorage.sol`
##### Description
address that controls the rebasing functionality. This contract is one of two contracts that can `mint`. It also tells how much to change `yamsScalingFactor`.
address that controls the rebasing functionality. This contract is one of two contracts that can `mint`. It also tells how much to change `hamsScalingFactor`.
##### Setting
###### File: `YAM.sol`
###### File: `HAM.sol`
`_setRebaser(address)`: sets `rebaser` to new address.

<br />
<br />
<br />

#### `incentivizer`
##### File: `YAMTokenStorage.sol`
##### File: `HAMTokenStorage.sol`
##### Description
address that controls the incentivizer pool. This contract is one of two contracts that can `mint`. It is there to promote liquidity for the rebasing functionality to work correctly.
##### Setting
###### File: `YAM.sol`
###### File: `HAM.sol`
`_setIncentivizer(address)`: sets `incentivzer` to new address.

<br />
Expand All @@ -45,12 +47,12 @@ address that controls the incentivizer pool. This contract is one of two contrac
## Rebaser Levers

#### `transactions`
##### File: `YAMRebaser.sol`
##### File: `HAMRebaser.sol`
##### Description
Transactions that the rebaser sends after a rebase. Useful for calling `sync()` like functions.
##### init_value: `[]` (empty)
##### Setting
###### File: `YAMRebaser.sol`
###### File: `HAMRebaser.sol`
```
addTransaction(address destination, bytes calldata data)
```
Expand All @@ -73,11 +75,11 @@ enables or disables a tx in the `transactions` list.
<br />

#### `gov`/`pendingGov`
##### File: `YAMRebaser.sol`
##### File: `HAMRebaser.sol`
##### Description
address that controls every permissioned function, or is primed to.
##### Setting
###### File: `YAMRebaser.sol`
###### File: `HAMRebaser.sol`
`_setPendingGov(address)`: sets `pendingGov` to new address. To complete the change of governance, the new governance contract has to call `_acceptGov()`.

<br />
Expand All @@ -86,12 +88,12 @@ address that controls every permissioned function, or is primed to.


#### `rebaseLag`
##### File: `YAMRebaser.sol`
##### File: `HAMRebaser.sol`
##### Description
rebaseLag spreads out the time it takes to reach the peg. i.e. if the supply is suppose to increase 10% in a particular rebase, that 10% is divided by this rebaseLag to slow it down a bit. Since rebases happen twice daily, a value of 10, slows it down to 5 days (if no further price change).
##### init_value: `10`
##### Setting
###### File: `YAMRebaser.sol`
###### File: `HAMRebaser.sol`
```
setRebaseLag(uint256 rebaseLag_)
```
Expand All @@ -101,12 +103,12 @@ setRebaseLag(uint256 rebaseLag_)
<br />

#### `targetRate`
##### File: `YAMRebaser.sol`
##### File: `HAMRebaser.sol`
##### Description
The peg the protocol should aim for relative to the reserveToken. i.e. `1e18` means 1:1 between the reserveToken and YAM.
The peg the protocol should aim for relative to the reserveToken. i.e. `1e18` means 1:1 between the reserveToken and HAM.
##### init_value: `1e18`
##### Setting
###### File: `YAMRebaser.sol`
###### File: `HAMRebaser.sol`
```
setTargetRate(uint256 targetRate_)
```
Expand All @@ -116,12 +118,12 @@ setTargetRate(uint256 targetRate_)
<br />

#### `rebaseMintPerc`
##### File: `YAMRebaser.sol`
##### File: `HAMRebaser.sol`
##### Description
The amount of YAM that the rebaser mints that is sold to build the protocol's treasury. Decimals: 18. i.e. 1e17 == .1, or 10% of the rebase.
The amount of HAM that the rebaser mints that is sold to build the protocol's treasury. Decimals: 18. i.e. 1e17 == .1, or 10% of the rebase.
##### init_value: `1e17` or `10%`
##### Setting
###### File: `YAMRebaser.sol`
###### File: `HAMRebaser.sol`
```
setRebaseMintPerc(uint256 rebaseMintPerc_)
```
Expand All @@ -132,12 +134,12 @@ setRebaseMintPerc(uint256 rebaseMintPerc_)
<br />

#### `deviationThreshold`
##### File: `YAMRebaser.sol`
##### File: `HAMRebaser.sol`
##### Description
The percentage difference between price and peg needed to allow for a change of supply via rebase.
##### init_value: `5*1e16` or `5%`
##### Setting
###### File: `YAMRebaser.sol`
###### File: `HAMRebaser.sol`
```
setDeviationThreshold(uint256 deviationThreshold_)
```
Expand All @@ -148,12 +150,12 @@ setDeviationThreshold(uint256 deviationThreshold_)
<br />

#### `minRebaseTimeIntervalSec`
##### File: `YAMRebaser.sol`
##### File: `HAMRebaser.sol`
##### Description
Amount of time between rebases.
##### init_value: `12 hours`
##### Setting
###### File: `YAMRebaser.sol`
###### File: `HAMRebaser.sol`
```
setRebaseTimingParameters(
uint256 minRebaseTimeIntervalSec_,
Expand All @@ -167,12 +169,12 @@ setRebaseTimingParameters(
<br />

#### `rebaseWindowOffsetSec`
##### File: `YAMRebaser.sol`
##### File: `HAMRebaser.sol`
##### Description
The number of seconds from the beginning of the rebase interval, where the rebase window begins.
##### init_value: `36000`
##### Setting
###### File: `YAMRebaser.sol`
###### File: `HAMRebaser.sol`
```
setRebaseTimingParameters(
uint256 minRebaseTimeIntervalSec_,
Expand All @@ -187,12 +189,12 @@ setRebaseTimingParameters(
<br />

#### `rebaseWindowLengthSec`
##### File: `YAMRebaser.sol`
##### File: `HAMRebaser.sol`
##### Description
The length of the time window where a rebase operation is allowed to execute, in seconds.
##### init_value: `900` or `15 minutes`
##### Setting
###### File: `YAMRebaser.sol`
###### File: `HAMRebaser.sol`
```
setRebaseTimingParameters(
uint256 minRebaseTimeIntervalSec_,
Expand All @@ -207,12 +209,12 @@ setRebaseTimingParameters(
<br />

#### `reservesContract`
##### File: `YAMRebaser.sol`
##### File: `HAMRebaser.sol`
##### Description
Address of the protocol owned reserves (treasury) contract.
##### init_value: `known at deployment`
##### Setting
###### File: `YAMRebaser.sol`
###### File: `HAMRebaser.sol`
```
setReserveContract(address reservesContract_)
```
Expand All @@ -222,12 +224,12 @@ setReserveContract(address reservesContract_)
<br />

#### `maxSlippageFactor`
##### File: `YAMRebaser.sol`
##### File: `HAMRebaser.sol`
##### Description
Max slippage factor when buying reserve token. Magic number based on the fact that uniswap is a constant product. Therefore, targeting a % max slippage can be achieved by using a single precomputed number. i.e. 2.5% slippage is always equal to some f(maxSlippageFactor, reserves)
##### init_value: `5409258 * 10**10`, targeting max slippage of `10%`
##### Setting
###### File: `YAMRebaser.sol`
###### File: `HAMRebaser.sol`
```
setMaxSlippageFactor(uint256 maxSlippageFactor_)
```
83 changes: 42 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,77 +1,76 @@
# 🍠 YAM Protocol 🍠
## The Protocol
Yam is an experimental protocol building upon the most exciting innovations in programmable money and governance. Built by a team of DeFi natives, it seeks to create:
# 🐷 HAM Protocol 🐷

• an elastic supply to seek eventual price stability<br/>
• a governable treasury to further support stability<br/>
• fully on-chain governance to enable decentralized control and evolution from Day 1<br/>
• a fair distribution mechanism that incentivizes key community members to actively take the reins of governance
## The Protocol

At its core, YAM is an elastic supply cryptocurrency, which expands and contracts its supply in response to market conditions, initially targeting 1 USD per YAM. This stability mechanism includes one key addition to existing elastic supply models such as Ampleforth: a portion of each supply expansion is used to buy yCurve (a high-yield USD-denominated stablecoin) and add it to the Yam treasury, which is controlled via Yam community governance.
Ham is an experimental protocol building upon the most exciting innovations in programmable money and governance. Built by a couple degenerates who prefer meat to [sweet potatoes](https://github.com/yam-finance/yam-protocol), it seeks to answer

We have built Yam to be a minimally viable monetary experiment, and at launch there will be zero value in the YAM token. After deployment, it is entirely dependent upon YAM holders to determine its value and future development. We have employed a fork of the Compound governance module, which will ensure all updates to the Yam protocol happen entirely on-chain through community voting.
* how strong is a meme?
* how quickly can a community bootstrap itself?
* wen moon?

## Audits
Built by a team of DeFi natives, it seeks to create:

None. Contributors have given their best efforts to ensure the security of these contracts, but make no guarantees. It has been spot checked by just a few pairs of eyes. It is a probability - not just a possibility - that there are bugs. That said, minimal changes were made to the staking/distribution contracts that have seen hundreds of millions flow through them via SNX, YFI, and YFI derivatives. The reserve contract is excessively simple as well. We prioritized staked assets' security first and foremost.
At its core, HAM is an elastic supply cryptocurrency, which expands and contracts its supply in response to market conditions, initially targeting 4.20 USD per HAM. This stability mechanism includes one key addition to existing elastic supply models such as Ampleforth: a portion of each supply expansion is used to buy assets and add them to the Ham treasury, which is controlled via Ham community governance.

The original devs encourage governance to fund a bug bounty/security audit
We have built Ham to be a minimally viable monetary experiment, and at launch there will be zero value in the HAM token. After deployment, it is entirely dependent upon HAM holders to determine its value and future development. We have employed a fork of the Compound governance module, which will ensure all updates to the Ham protocol happen entirely on-chain through community voting.

The token itself is largely based on COMP and Ampleforth which have undergone audits - but we made non-trivial changes.
## Audits

The rebaser may also have bugs - but has been tested in multiple scenarios. It is restricted to Externally Owned Accounts (EOAs) calling the rebase function for added security. SafeMath is used everywhere.
None. Seriously, look at the commit history, it's just find and replace. You probably shouldn't use this, but not everyone likes sweet potatoes and ham is delicious.

If you feel uncomfortable with these disclousures, don't stake or hold YAM. If the community votes to fund an audit, or the community is gifted an audit, there is no assumption that the original devs will be around to implement fixes, and is entirely at their discretion.
The [original devs](github.com/yam-finance/yam-protocol) and the forking degenerates all encourage governance to fund a bug bounty/security audit. If there's no audit or bounty program, remember, any funds you deposit are basically a bug bounty.

## The Token
The core YAM token uses yCRV as the reserve currency, which is roughly a $1 peg. Each supply expansion (referred to as an inflating rebase), a portion of tokens is minted and used to build up the treasury. This treasury is then in complete ownership of YAM holders via governance.

The core HAM token maintains a reservey. During each supply expansion (referred to as an inflating rebase), a portion of tokens is minted and used to build up the treasury. This treasury is then in complete ownership of HAM holders via governance.

## Distribution
Rather than allocating a portion of the supply to the founding team, YAM is being distributed in the spirit of YFI: no premine, no founder shares, no VC interests — simply equal-opportunity staking distribution to attract a broad and vision-aligned community to steward the future of the protocol and token.

The initial distribution of YAM will be evenly distributed across eight staking pools: WETH, YFI, MKR, LEND, LINK, SNX, COMP, and ETH/APML Uniswap v2 LP tokens. These pools were chosen intentionally to reach a broad swath of the overall DeFi community, as well as specific communities with a proven commitment to active governance and an understanding of complex tokenomics.
Rather than allocating a portion of the supply to the founding team, HAM is being distributed in the spirit of Satoshi, and applied by YFI: no premine, no founder shares, no VC interests — simply equal-opportunity staking distribution to attract a broad and vision-aligned community of meat eaters.

Following the launch of the initial distribution pools, a second distribution wave will be incentivized through a YAM/yCRV Uniswap pool. This pool will allow Uniswap's TWAP-based oracle to provide necessary input as the basis for rebase calculations, as well as provide liquidity for the rebase to purchase yCurve for the treasury.
The initial distribution of HAM will be oddly distributed across as many as 18 different staking pools. These pools have been chosen intentionally to reach a broad swath of the overall degenerate community, many of which [don't like sweet potatoes](https://github.com/gam-finance/yam-protocol).

These pools will be deployed over a 4 to 6 week period.

Following the launch of the initial distribution pools, a second distribution wave will be incentivized through a HAM Uniswap pool. This pool will allow Uniswap's TWAP-based oracle to provide necessary input as the basis for rebase calculations, as well as provide liquidity for the rebase to purchase assets for the treasury.

## Rebases

Rebases are controlled by an external contract called the Rebaser. This is comparable to Ampleforth's `monetaryPolicy` contract. It dictates how large the rebase is and what happens on the rebase. The YAM token just changes the supply based on what this contract provides it.
Rebases are controlled by an external contract called the Rebaser. This is comparable to Ampleforth's `monetaryPolicy` contract. It dictates how large the rebase is and what happens on the rebase. The HAM token just changes the supply based on what this contract provides it.

There are a few requirements before rebases are active:

There are a requirements before rebases are active:
<br />
• Liquid YAM/yCRV market<br/>
`init_twap()`<br/>
`activate_rebasing()`<br/>
1. Liquid HAM market
2. `init_twap()`
3. `activate_rebasing()`

Following the launch of the second pool, rebasing can begin its activation phase. This begins with `init_twap()` on the rebaser contract. Anyone can call this at anytime once there is a YAM/yCRV Uniswap V2 market. The oracle is designed to be 12 hours between checkpoints. Given that, 12 hours after `init_twap()` is called, anyone can call `activate_rebasing()`. This turns rebasing on, permanently. Now anyone can call `rebase()` when `inRebaseWindow() == true;`.
Following the launch of the second pool, rebasing can begin its activation phase. This begins with `init_twap()` on the rebaser contract. Anyone can call this at anytime once there is a HAM Uniswap V2 market. The oracle is designed to be 12 hours between checkpoints. Given that, 12 hours after `init_twap()` is called, anyone can call `activate_rebasing()`. This turns rebasing on, permanently. Now anyone can call `rebase()` when `inRebaseWindow() == true;`.

In a rebase, the order of operations are:
<br />
• ensure in rebase window<br/>
• calculate how far off price is from the peg<br/>
• dampen the rebase by the rebaseLag<br/>
• if positive calculate protocol mint amount<br/>
• change scaling factor, (in/de)flating the supply<br/>
• sync uniswap, mint, sell to uniswap, transfer excess YAM and bought yCRV to reserves<br/>
• call any extra functions governance adds in the future (i.e. Balancer gulps)<br/>

1. ensure in rebase window
2. calculate how far off price is from the peg
3. dampen the rebase by the rebaseLag
4. if positive calculate protocol mint amount
5. change scaling factor, (in/de)flating the supply
6. sync uniswap, mint, sell to uniswap, transfer excess HAM and bought yCRV to reserves
7. call any extra functions governance adds in the future (i.e. Balancer gulps)

## Governance
Governance is entirely dictated by YAM holders from the start. Upon deployment, ownership of all YAM protocol contracts was reliquished to the timelocked Governance contract or removed entirely. At the very least, this can be seen as a reference implementation for a truly decentralized protocol.

Governance is entirely dictated by HAM holders from the start. Upon deployment, ownership of all HAM protocol contracts was reliquished to the timelocked Governance contract or removed entirely. At the very least, this can be seen as a reference implementation for a truly decentralized meat-farming protocol.

# Development

### Building

This repo uses truffle. Ensure that you have truffle installed. Given the composability aspect of this

Then, to build the contracts run:
```
$ truffle compile
```



To run tests, run against a single test package, i.e.:
```
$ sh startBlockchain.sh
Expand All @@ -98,14 +97,16 @@ $ cd jsLib
$ jest governance
```


#### Attributions

Much of this code base is modified from existing works, including:

[Compound](https://compound.finance) - Jumping off point for token code and governance
[YAM](https://yam.finance) - Basically s/YAM/HAM/g

[Compound](https://compound.finance) - Jumping off point for YAM token code and governance

[Ampleforth](https://ampleforth.org) - Initial rebasing mechanism, modified to better suit the YAM protocol
[Ampleforth](https://ampleforth.org) - Initial YAM rebasing mechanism, modified to better suit the YAM protocol

[Synthetix](https://synthetix.io) - Rewards staking contract

[YEarn](https://yearn.finance)/[YFI](https://ygov.finance) - Initial fair distribution implementation
[YEarn](https://yearn.finance)/[YFI](https://ygov.finance) - Initial YAM fair distribution implementation
Loading

0 comments on commit 668ece9

Please sign in to comment.