Skip to content

Commit 5de0cee

Browse files
Markus Buhatem Kochgitbook-bot
Markus Buhatem Koch
authored andcommitted
GitBook: [master] 54 pages modified
1 parent ef7ea7c commit 5de0cee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+391
-309
lines changed

api/api.md

+28-26
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# This page has been deprecated. V1 documentation is partially maintained [here](https://docs.balancer.fi/v/v1/api/api)
2-
31
# API Index
42

3+
## This page has been deprecated. V1 documentation is partially maintained [here](https://docs.balancer.fi/v/v1/api/api)
4+
5+
## API Index
6+
57
| Function |
68
| :--- |
79
| [`swapExactAmountIn(tokenIn, tokenAmountIn, tokenOut, minAmountOut, maxPrice)->(tokenAmountOut, spotPriceAfter)`](api.md#swapexactamountin) |
@@ -37,35 +39,35 @@
3739
| [`getController()->address`](api.md#getcontroller) |
3840
| - |
3941

40-
## Functions
42+
### Functions
4143

42-
### Controller and View Functions
44+
#### Controller and View Functions
4345

44-
#### `isBound`
46+
**isBound**
4547

4648
`isBound(address T) -> (bool)`
4749

4850
A bound token has a valid balance and weight. A token cannot be bound without valid parameters which will enable e.g. `getSpotPrice` in terms of other tokens. However, disabling `isSwapPublic` will disable any interaction with this token in practice \(assuming there are no existing tokens in the pool, which can always `exitPool`\).
4951

50-
#### `getNumTokens`
52+
**getNumTokens**
5153

5254
`getNumTokens() -> (uint)`
5355

5456
How many tokens are bound to this pool.
5557

56-
#### `getNormalizedWeight`
58+
**getNormalizedWeight**
5759

5860
`getNormalizedWeight(address token) -> (uint)`
5961

6062
The normalized weight of a token. The combined normalized weights of all tokens will sum up to 1. \(Note: the actual sum may be 1 plus or minus a few wei due to division precision loss\)
6163

62-
#### `getController`
64+
**getController**
6365

6466
`getController() -> (address)`
6567

6668
Get the "controller" address, which can call `CONTROL` functions like `rebind`, `setSwapFee`, or `finalize`.
6769

68-
#### `bind`
70+
**bind**
6971

7072
`bind(address token, uint balance, uint denorm)`
7173

@@ -80,53 +82,53 @@ Possible errors:
8082
* `ERR_MAX_TOKENS` -- Only 8 tokens are allowed per pool
8183
* unspecified error thrown by token
8284

83-
#### `rebind`
85+
**rebind**
8486

8587
`rebind(address token, uint balance, uint denorm)`
8688

8789
Changes the parameters of an already-bound token. Performs the same validation on the parameters.
8890

89-
#### `unbind`
91+
**unbind**
9092

9193
`unbind(address token)`
9294

9395
Unbinds a token, clearing all of its parameters. Exit fee is charged and the remaining balance is sent to caller.
9496

95-
#### `setPublicSwap`
97+
**setPublicSwap**
9698

9799
`setPublicSwap(bool isPublic)`
98100

99101
Makes `isPublicSwap` return `_publicSwap` Requires caller to be controller and pool not to be finalized. Finalized pools always have public swap.
100102

101-
#### `finalize`
103+
**finalize**
102104

103105
`finalize()`
104106

105107
This makes the pool **finalized**. This is a one-way transition. `bind`, `rebind`, `unbind`, `setSwapFee` and `setPublicSwap` will all throw `ERR_IS_FINALIZED` after pool is finalized. This also switches `isSwapPublic` to true.
106108

107-
#### `gulp`
109+
**gulp**
108110

109111
`gulp(address token)`
110112

111113
This syncs the internal `balance` of `token` within a pool with the actual `balance` registered on the ERC20 contract. This is useful to account for airdropped tokens or any tokens sent to the pool without using the `join` or `joinSwap` methods.
112114

113115
As an example, pools that contain `COMP` tokens can have the `COMP` balance [updated with the rewards sent by Compound protocol](https://etherscan.io/tx/0xeccd42bf2b8a180a561c026717707d9024a083059af2f22c197ee511d1010e23). In order for any airdrop balance to be gulped, the token must be bound to the pool. So if a shared pool \(which is immutable\) does not have a given token, any airdrops in that token will be locked in the pool forever.
114116

115-
#### `setSwapFee`
117+
**setSwapFee**
116118

117119
`setSwapFee(uint swapFee)`
118120

119121
Caller must be controller. Pool must NOT be finalized.
120122

121-
#### `isFinalized`
123+
**isFinalized**
122124

123125
`isFinalized() -> (bool)`
124126

125127
The `finalized` state lets users know that the weights, balances, and fees of this pool are immutable. In the `finalized` state, `SWAP`, `JOIN`, and `EXIT` are public. [`CONTROL` capabilities](api.md#access-control) are disabled.
126128

127-
### Trading and Liquidity Functions
129+
#### Trading and Liquidity Functions
128130

129-
#### `swapExactAmountIn`
131+
**swapExactAmountIn**
130132

131133
```text
132134
swapExactAmountIn(
@@ -143,7 +145,7 @@ Trades an exact `tokenAmountIn` of `tokenIn` taken from the caller by the pool,
143145

144146
Returns `(tokenAmountOut, spotPriceAfter)`, where `tokenAmountOut` is the amount of token that came out of the pool, and `spotPriceAfter` is the new marginal spot price, ie, the result of `getSpotPrice` after the call. \(These values are what are limited by the arguments; you are guaranteed `tokenAmountOut >= minAmountOut` and `spotPriceAfter <= maxPrice`\).
145147

146-
#### `swapExactAmountOut`
148+
**swapExactAmountOut**
147149

148150
```text
149151
swapExactAmountOut(
@@ -156,41 +158,41 @@ swapExactAmountOut(
156158
returns (uint tokenAmountIn, uint spotPriceAfter)
157159
```
158160

159-
#### `joinPool`
161+
**joinPool**
160162

161163
`joinPool(uint poolAmountOut, uint[] calldata maxAmountsIn)`
162164

163165
Join the pool, getting `poolAmountOut` pool tokens. This will pull some of each of the currently trading tokens in the pool, meaning you must have called `approve` for each token for this pool. These values are limited by the array of `maxAmountsIn` in the order of the pool tokens.
164166

165167
If the balances you are adding are 10% of the current pool balances, then you should set `poolAmountOut` as 10% of the current `poolSupply`. Bear in mind that the proportions of the different underlying token balances might change until your transaction gets mined: therefore you should have a buffer to avoid the transaction being reverted. We usually suggest 1% if you use high gas prices for fast confirmation. So calculate `poolAmountOut` as described above with 99% of the `maxAmountsIn`.
166168

167-
#### `exitPool`
169+
**exitPool**
168170

169171
`exitPool(uint poolAmountIn, uint[] calldata minAmountsOut)`
170172

171173
Exit the pool, paying `poolAmountIn` pool tokens and getting some of each of the currently trading tokens in return. These values are limited by the array of `minAmountsOut` in the order of the pool tokens.
172174

173-
To define `minAmountsOut`, consider the percentage of the pool liquidity you are withdrawing, which is `poolAmountIn/poolSupply` and multiply that percentage by each of the underlying pool token balances. If you expect to receive say 10 units of each of the underlying tokens in the pool, consider setting `minAmountsOut` as 9.9 to allow for variations in the balances proportions that may happen before your transaction gets mined.
175+
To define `minAmountsOut`, consider the percentage of the pool liquidity you are withdrawing, which is `poolAmountIn/poolSupply` and multiply that percentage by each of the underlying pool token balances. If you expect to receive say 10 units of each of the underlying tokens in the pool, consider setting `minAmountsOut` as 9.9 to allow for variations in the balances proportions that may happen before your transaction gets mined.
174176

175-
#### `joinswapExternAmountIn`
177+
**joinswapExternAmountIn**
176178

177179
`joinswapExternAmountIn(address tokenIn, uint tokenAmountIn, uint minPoolAmountOut) -> (uint poolAmountOut)`
178180

179181
Pay `tokenAmountIn` of token `tokenIn` to join the pool, getting `poolAmountOut` of the pool shares.
180182

181-
#### `exitswapExternAmountOut`
183+
**exitswapExternAmountOut**
182184

183185
`exitswapExternAmountOut(address tokenOut, uint tokenAmountOut, uint maxPoolAmountIn) -> (uint poolAmountIn)`
184186

185187
Specify `tokenAmountOut` of token `tokenOut` that you want to get out of the pool. This costs `poolAmountIn` pool shares \(these went into the pool\).
186188

187-
#### `joinswapPoolAmountOut`
189+
**joinswapPoolAmountOut**
188190

189191
`joinswapPoolAmountOut(address tokenIn, uint poolAmountOut, uint maxAmountIn) -> (uint tokenAmountIn)`
190192

191193
Specify `poolAmountOut` pool shares that you want to get, and a token `tokenIn` to pay with. This costs `tokenAmountIn` tokens \(these went into the pool\).
192194

193-
#### `exitswapPoolAmountIn`
195+
**exitswapPoolAmountIn**
194196

195197
`exitswapPoolAmountIn(address tokenOut, uint poolAmountIn, uint minAmountOut) -> (uint tokenAmountOut)`
196198

api/core-contracts.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# This page has been deprecated. V1 documentation is partially maintained [here](https://docs.balancer.fi/v/v1/api/core-contracts)
2-
31
# Events
42

3+
## This page has been deprecated. V1 documentation is partially maintained [here](https://docs.balancer.fi/v/v1/api/core-contracts)
4+
5+
## Events
6+
57
### Events
68

79
`LOG_CALL` is an anonymous event which uses the function signature as the event signature. It is fired by all stateful functions. The following applies to Balancer Core pools. Smart Pools have similar events and modifiers.
@@ -14,7 +16,7 @@ event LOG_CALL(
1416
) anonymous;
1517
```
1618

17-
`LOG_SWAP` is fired \(along with `LOG_CALL`\) for all [swap variants]().
19+
`LOG_SWAP` is fired \(along with `LOG_CALL`\) for all [swap variants](core-contracts.md).
1820

1921
```text
2022
event LOG_SWAP(

api/migration-to-version-0.4.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
# This page has been deprecated. V1 documentation is partially maintained [here](https://docs.balancer.fi/v/v1/api/migration-to-version-0.4)
2-
31
# Migration to Version 1.0
42

3+
## This page has been deprecated. V1 documentation is partially maintained [here](https://docs.balancer.fi/v/v1/api/migration-to-version-0.4)
4+
5+
## Migration to Version 1.0
6+
57
The SOR Version 1.0.0-0 introduces breaking changes but should be fairly easy to update. Benefits of updating include - support for multihop swaps and an easier to use wrapper interface as well as more efficient/faster processing.
68

7-
## Overview Of Changes
9+
### Overview Of Changes
810

9-
### SOR Library
11+
#### SOR Library
1012

1113
The SOR is now instantiated as an object:
1214

13-
#### `const SOR = new sor.SOR(Provider, GasPrice, MaxPools, ChainId, PoolsUrl)`
15+
**const SOR = new sor.SOR\(Provider, GasPrice, MaxPools, ChainId, PoolsUrl\)**
1416

1517
* Find further details on parameters [here](../smart-contracts/sor/development.md#sor-object).
1618

1719
SOR now has three main functions:
1820

19-
#### `await SOR.setCostOutputToken(tokenOut)`
21+
**await SOR.setCostOutputToken\(tokenOut\)**
2022

2123
* Calculates gas cost for swapping token on Balancer.
2224
* The result is used to make more gas efficient swap recommendations.
2325
* Result is cached for future use but can be updated by re-calling.
2426
* Notice that outputToken is tokenOut if swapType == 'swapExactIn' and tokenIn if swapType == 'swapExactOut'
2527

26-
#### `const isSuccess = await SOR.fetchPools()`
28+
**const isSuccess = await SOR.fetchPools\(\)**
2729

2830
* This fetches all Balancer pool information and on-chain balances.
2931
* Retrieves pool information from static IPFS file rather than Subgraph.
@@ -32,19 +34,19 @@ SOR now has three main functions:
3234
* Information is cached and used for all future processing, this results in fast processing of swaps, i.e. useful when changing swap amounts or types in a UI.
3335
* Accurate/valid swaps rely on upM to date balance information so it is recommended this function is re-called to refresh as needed.
3436

35-
#### `const [swaps, amount] = await SOR.getSwaps(tokenIn, tokenOut, swapType, swapAmount)`
37+
**const \[swaps, amount\] = await SOR.getSwaps\(tokenIn, tokenOut, swapType, swapAmount\)**
3638

3739
* Main function to process trade.
3840
* Will return amount expected and a list of swaps that can be executed on-chain.
3941

40-
### ExchangeProxy Contract
42+
#### ExchangeProxy Contract
4143

4244
A new ExchangeProxy contract that supports multihop swaps has been deployed to the addresses below. For contract details please see [Exchange Proxy](../smart-contracts/exchange-proxy.md).
4345

4446
* Mainnet: `0x3E66B66Fd1d0b02fDa6C811Da9E0547970DB2f21`
4547
* Kovant: `0x4e67bf5bD28Dd4b570FBAFe11D0633eCbA2754Ec`
4648

47-
## Further Information
49+
### Further Information
4850

4951
* For more information on SOR functions and to see code examples \(including using with ExchangeProxy\) please see [Development & Examples](../smart-contracts/sor/development.md).
5052
* For a full example demonstrating use of SOR wrapper please see [here](https://github.com/balancer-labs/balancer-sor/blob/master/test/testScripts/example-simpleSwap.ts).

api/uml-docs.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# This page has been deprecated. V1 documentation is partially maintained [here](https://docs.balancer.fi/v/v1/api/uml-docs)
2-
31
# UML Docs
42

3+
## This page has been deprecated. V1 documentation is partially maintained [here](https://docs.balancer.fi/v/v1/api/uml-docs)
4+
5+
## UML Docs
6+
57
* [BPool](https://drive.google.com/file/d/1qta1KBLRq_8GZJ_dTL0zo2HYPD_dYUrH/view?usp=sharing)
68
* [CRPFactory](https://drive.google.com/file/d/1Aj8N-oE0iQ4Zyv1fWqglC5GIenrvq2EP/view?usp=sharing)
79
* [BadToken](https://drive.google.com/file/d/1y9QqRrk2lms_tcBlhynMaZJk7iFNyz_8/view?usp=sharing) \(used for CRP token vetting\)

core-concepts/bal-balancer-governance-token/README.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# This page has been deprecated. V1 documentation is partially maintained [here](https://docs.balancer.fi/v/v1/core-concepts/bal-balancer-governance-token/)
2-
31
# BAL Governance Token
42

3+
## This page has been deprecated. V1 documentation is partially maintained [here](https://docs.balancer.fi/v/v1/core-concepts/bal-balancer-governance-token/)
4+
5+
## BAL Governance Token
6+
57
Since inception, our goal at Balancer Labs has been to decentralize and diversify governance of the [Balancer Protocol](http://balancer.finance/). We have looked into several approaches and designs, and have landed on an approach we are proud to share: the Balancer Protocol Governance Token \(BAL\).
68

79
We believe alignment between token holders and protocol stakeholders is crucial for successful decentralized governance. More explicitly, we believe BAL tokens are the vehicle to drive alignment and participation in the protocol. BAL tokens are not an investment; BAL token holders should be people who interact with the protocol in some way, are committed to its future development, and want a seat at the governance table.
@@ -24,17 +26,17 @@ We expect token holders to help guide the protocol to its fullest potential thro
2426

2527
### Token Supply and Distribution <a id="14a8"></a>
2628

27-
The total supply of BAL tokens will be capped at 100M. This does NOT mean that this cap will ever be reached. It will be up to governance \(controlled by BAL token holders\) to decide if the distribution should end before this cap is reached.
29+
The total supply of BAL tokens will be capped at 100M. This does NOT mean that this cap will ever be reached. It will be up to governance \(controlled by BAL token holders\) to decide if the distribution should end before this cap is reached.
2830

2931
**25M** BAL tokens were initially allocated to founders, stock options, advisors and investors, all subject to vesting periods.
3032

3133
**5M** were allocated for the [Balancer Ecosystem Fund](https://etherscan.io/token/0xba100000625a3754423978a60c9317c58a424e3d?a=0xb618f903ad1d00d6f7b92f5b0954dcdc056fc533). This fund will be deployed to attract and incentivize strategic partners who will help the Balancer ecosystem grow and thrive. BAL holders will ultimately decide how this fund is used over the coming years.
3234

3335
**5M** were allocated for the [Fundraising Fund](https://etherscan.io/token/0xba100000625a3754423978a60c9317c58a424e3d?a=0xb129f73f1afd3a49c701241f374db17ae63b20eb). Balancer Labs raised a pre-seed and seed round. This fund will be used for future fundraising rounds to support Balancer Labs' operations and growth. BAL tokens will never be sold to retail investors.
3436

35-
The remaining 65M tokens are intended to be mostly distributed to liquidity providers in the coming years.
37+
The remaining 65M tokens are intended to be mostly distributed to liquidity providers in the coming years.
3638

37-
Every week 145,000 BALs, or approximately 7.5M per year, are distributed to liquidity providers. This means that in the first year of BAL’s existence there would be 30% supply inflation from the initial supply of 25M tokens \(here we are not considering the two funds, since they are not yet allocated\).
39+
Every week 145,000 BALs, or approximately 7.5M per year, are distributed to liquidity providers. This means that in the first year of BAL’s existence there would be 30% supply inflation from the initial supply of 25M tokens \(here we are not considering the two funds, since they are not yet allocated\).
3840

3941
This high rate of supply inflation is meant to kickstart the distribution of governance rights of the protocol to those who earn it. At the the current rate of 145,000 BAL per week, it would take 8.666 years to distribute the whole 65M BAL remaining, before reaching the 100M cap.
4042

core-concepts/bal-balancer-governance-token/bal-for-gas.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# This page has been deprecated. V1 documentation is partially maintained [here](https://docs.balancer.fi/v/v1/core-concepts/bal-balancer-governance-token/bal-for-gas)
2-
31
# BAL for Gas
42

3+
## This page has been deprecated. V1 documentation is partially maintained [here](https://docs.balancer.fi/v/v1/core-concepts/bal-balancer-governance-token/bal-for-gas)
4+
5+
## BAL for Gas
6+
57
Following a 6 week pilot, on March 7th 2021 the Balancer community approved a campaign to increase BAL distribution. To ensure lasting robustness of the governance process, both liquidity providers and traders should have a say in how the protocol evolves.
68

79
While liquidity providers receive BAL as a function of the amount of liquidity provided in the system, traders earn BAL for swapping tokens on the Balancer Exchange dApp.
@@ -28,11 +30,11 @@ Because this program only partially covers gas costs \(with very specific caps t
2830

2931
80,000 BAL from the Ecosystem Fund have been allocated to the “BAL for Gas’’ campaign, starting on March 8th 2021. There is no fixed time period; the budget is consumed on a first-come, first-served basis. When the budget is exhausted, the campaign is suspended until it is replenished by BAL governance.
3032

31-
## Notes
33+
### Notes
3234

3335
\[1\] Transactions sent by the miner of the block or having a gas price of 10 Gwei or less are not considered for the purposes of determining the median gas price of the block
3436

35-
## References
37+
### References
3638

3739
* [BAL for Gas proposal](https://forum.balancer.finance/t/proposal-bal-for-gas/1437)
3840
* [Original pilot](https://forum.balancer.finance/t/proposal-balancer-exchange-gas-reimbursement/705) and [Expansion of the list of eligible tokens](https://forum.balancer.finance/t/proposal-expand-the-exchange-gas-reimbursement-to-all-whitelisted-tokens/799)

core-concepts/bal-liquidity-mining/README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# This page has been deprecated. V1 documentation is partially maintained [here](https://docs.balancer.fi/v/v1/core-concepts/bal-liquidity-mining/)
2-
31
# Liquidity Mining
42

5-
## BAL Distribution Proportional to Liquidity on Balancer <a id="353e"></a>
3+
## This page has been deprecated. V1 documentation is partially maintained [here](https://docs.balancer.fi/v/v1/core-concepts/bal-liquidity-mining/)
4+
5+
## Liquidity Mining
6+
7+
### BAL Distribution Proportional to Liquidity on Balancer <a id="353e"></a>
68

79
To make the token distribution as fair as possible, we distribute BAL tokens proportional to the amount of liquidity each address contributed, relative to the total liquidity on Balancer. Since there is liquidity in several different tokens, we use the USD value as the common measure.
810

@@ -51,7 +53,7 @@ The constant, `k`, was initially set to 0.5, but beginning in week 8 \(July 20th
5153

5254
All the calculations described above depend exclusively on on-chain data and historical token prices openly accessible on CoinGecko. This whole calculation process is fully auditable via an [open source script](https://github.com/balancer-labs/bal-mining-scripts/).
5355

54-
## Token Whitelist and Eligible Pools for Liquidity Mining <a id="84fc"></a>
56+
### Token Whitelist and Eligible Pools for Liquidity Mining <a id="84fc"></a>
5557

5658
**UPDATED for week 9** \(starting June 29th 00:00 UTC\): All tokens present in the whitelist created by the community \(see whitelist proposal\) are eligible for BAL liquidity mining. The [most up to date list](https://github.com/balancer-labs/assets/blob/master/lists/eligible.json) is maintained on Balancer's Github. All tokens listed under the `"homestead"` list in the json file linked are eligible. This list will evolve over time with input from the community.
5759

core-concepts/bal-liquidity-mining/exchange-and-reward-listing.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# This page has been deprecated. V1 documentation is partially maintained [here](https://docs.balancer.fi/v/v1/core-concepts/bal-liquidity-mining/exchange-and-reward-listing)
2-
31
# Exchange and BAL Mining Listing
42

3+
## This page has been deprecated. V1 documentation is partially maintained [here](https://docs.balancer.fi/v/v1/core-concepts/bal-liquidity-mining/exchange-and-reward-listing)
4+
5+
## Exchange and BAL Mining Listing
6+
57
Token listings are managed in [this repository](https://github.com/balancer-labs/assets), with the following categories:
68

79
* `eligible.json`: assets eligible for BAL mining as per weekly proposals

0 commit comments

Comments
 (0)