Skip to content

Commit 6d638ca

Browse files
Markus Buhatem Kochgitbook-bot
Markus Buhatem Koch
authored andcommitted
GitBook: [master] 3 pages and 2 assets modified
1 parent 51b1106 commit 6d638ca

File tree

3 files changed

+83
-224
lines changed

3 files changed

+83
-224
lines changed

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

+13-16
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,39 @@
22

33
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.
44

5-
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.
5+
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.
66

77
Every eligible trade made through the Balancer Exchange Proxy results in some BAL being allocated to the address \(EOAs only\) that sent the transaction. An eligible trade is a trade containing one or more eligible swaps, where an eligible swap is one between any two tokens on the [whitelist](https://github.com/balancer-labs/assets/blob/master/lists/eligible.json). Claims are made available at the [BAL claims interface](https://claim.balancer.finance/) on Wednesday \(UTC time\) following the end \(00:00 UTC Monday\) of the weekly period in which the trade occurred.
88

99
The amount of BAL awarded to a trade is a function of:
10+
1011
* the number of eligible swaps in the trade \(N\), which determines a number of gas units \(G\):
11-
* trades on Balancer V1:
12-
* 1 swap: `G=130000` gas units
13-
* 2 swaps: `G=220000` gas units
14-
* 3 swaps: `G=300000` gas units
15-
* 4+ swaps: `G=400000` gas units
16-
* trades on Balancer V2:
17-
* 1 swap: `G=90000` gas units
18-
* 2+ swaps: `G=140000` gas units
12+
* trades on Balancer V1:
13+
* 1 swap: `G=130000` gas units
14+
* 2 swaps: `G=220000` gas units
15+
* 3 swaps: `G=300000` gas units
16+
* 4+ swaps: `G=400000` gas units
17+
* trades on Balancer V2:
18+
* 1 swap: `G=90000` gas units
19+
* 2+ swaps: `G=140000` gas units
1920
* the median gas price \[1\] of the block the transaction was included in \(M\); and
2021
* the BAL/ETH price provided by the CoinGecko closest to the block time \(P\).
2122

22-
The amount of BAL to be received by the user for a trade is computed as `G*M/P`
23+
The amount of BAL to be received by the user for a trade is computed as `G*M/P`
2324

2425
Because this program only partially covers gas costs \(with very specific caps to prevent attempts at gaming the system\), and doesn’t cover trading fees, it does not incentivize wash trading or trading any more than a user was initially planning. Estimates are provided on the UI, but actual values are computed off-chain weekly using an [open source script](https://github.com/balancer-labs/bal-mining-scripts/), so that any suspicious activity can be filtered out.
2526

2627
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.
2728

28-
### Notes
29+
## Notes
2930

3031
\[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
3132

32-
### References
33+
## References
3334

3435
* [BAL for Gas proposal](https://forum.balancer.finance/t/proposal-bal-for-gas/1437)
3536
* [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)
3637
* [Extension of the pilot, 30k BAL budget](https://forum.balancer.finance/t/proposal-extend-the-exchange-gas-reimbursement-program-4-weeks/1121)
3738
* [Additional 50k BAL budget](https://forum.balancer.fi/t/proposal-bal-for-gas-replenish-budget-w-50-000-bal/1695)
3839
* [BAL for Gas on V2 params](https://forum.balancer.fi/t/proposal-bal-for-gas-on-balancer-v2/1861)
3940

40-
41-
42-
43-

core-concepts/bal-liquidity-mining/liquidity-mining-estimates-api.md

+70-208
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,28 @@
22

33
## Liquidity Mining Estimates API
44

5-
Estimated BAL earned at each pool and by each liquidity provider can be retrieved via this API. Cumulative estimates for the week in progress are computed every hour, and the velocity with each BAL is accruing is computed from the difference between two consecutive estimates. Clients can then use the velocity to update the estimates retrieved from the API.
5+
This API provides an estimate amount of tokens earned by a liquidity provider at the current week \(and previous week if tokens weren't sent out yet\). Cumulative estimates for the week in progress are computed every hour, and the velocity with each tokens are being accrued is computed from the difference between two consecutive estimates. Clients can then use the velocity to update in real time the estimates retrieved from the API.
66

7-
## Retrieving Pool Data
8-
9-
These endpoints can be used to fetch the aggregate amount of BAL mined by all the liquidity providers of a pool or a set of pools.
7+
## Retrieving Liquidity Provider Data
108

11-
### Single Pool
9+
### Single Liquidity Provider
1210

1311
#### HTTP Request
1412

1513
```jsx
16-
GET https://api.balancer.finance/liquidity-mining/v1/pool/:address
14+
GET https://api.balancer.finance/liquidity-mining/v1/liquidity-provider-multitoken/:address
1715
```
1816

1917
#### URL Parameters
2018

2119
| Param | Description | Required |
2220
| :--- | :--- | :--- |
23-
| address | The address of the pool | TRUE |
21+
| address | The address of the liquidity provider | TRUE |
2422

2523
#### Example Request
2624

2725
```jsx
28-
https://api.balancer.finance/liquidity-mining/v1/pool/0x1eff8af5d577060ba4ac8a29a13525bb0ee2a3d5
26+
https://api.balancer.finance/liquidity-mining/v1/liquidity-provider-multitoken/0xa9F8E7337eBb7982f9f5497BC5Ae98e69e1a39A7
2927
```
3028

3129
#### Example Response
@@ -34,239 +32,103 @@ https://api.balancer.finance/liquidity-mining/v1/pool/0x1eff8af5d577060ba4ac8a29
3432
{
3533
"success": true,
3634
"result": {
37-
"current_timestamp": "2021-03-01T21:05:49.590Z",
38-
"pools": [
35+
"current_timestamp": "2021-08-02T22:11:58.714Z",
36+
"liquidity-providers": [
3937
{
40-
"snapshot_timestamp": "2021-02-28T23:51:04.000Z",
41-
"address": "0x1eff8af5d577060ba4ac8a29a13525bb0ee2a3d5",
42-
"current_estimate": "24891.553499185869441135",
43-
"velocity": "0",
44-
"week": 39
38+
"snapshot_timestamp": "2021-08-02T12:58:05.000Z",
39+
"address": "0xa9F8E7337eBb7982f9f5497BC5Ae98e69e1a39A7",
40+
"token_address": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
41+
"chain_id": 137,
42+
"current_estimate": "52.852122329992465537",
43+
"velocity": "0.000661201814487363",
44+
"week": 62
4545
},
4646
{
47-
"snapshot_timestamp": "2021-03-01T19:50:35.000Z",
48-
"address": "0x1eff8af5d577060ba4ac8a29a13525bb0ee2a3d5",
49-
"current_estimate": "2844.376110032700538769",
50-
"velocity": "0.036697707708281742",
51-
"week": 40
52-
}
53-
]
54-
}
55-
}
56-
```
57-
58-
### List of Pools
59-
60-
#### HTTP Request
61-
62-
```jsx
63-
POST https://api.balancer.finance/liquidity-mining/v1/pools
64-
```
65-
66-
#### Body Parameters
67-
68-
| Param | Description | Required |
69-
| :--- | :--- | :--- |
70-
| addresses | List of pool addresses | TRUE |
71-
72-
#### Example Request
73-
74-
```jsx
75-
https://api.balancer.finance/liquidity-mining/v1/pools
76-
```
77-
78-
#### Example Body
79-
80-
```javascript
81-
{
82-
"addresses": [
83-
"0x1eff8af5d577060ba4ac8a29a13525bb0ee2a3d5",
84-
"0x49ff149d649769033d43783e7456f626862cd160"
85-
]
86-
}
87-
```
88-
89-
#### Example Response
90-
91-
```jsx
92-
{
93-
"success": true,
94-
"result": {
95-
"current_timestamp": "2021-03-01T21:05:51.354Z",
96-
"pools": [
97-
{
98-
"snapshot_timestamp": "2021-02-28T23:51:04.000Z",
99-
"address": "0x49ff149d649769033d43783e7456f626862cd160",
100-
"current_estimate": "940.916868590979561304",
101-
"velocity": "0",
102-
"week": 39
47+
"snapshot_timestamp": "2021-08-02T12:58:05.000Z",
48+
"address": "0xa9F8E7337eBb7982f9f5497BC5Ae98e69e1a39A7",
49+
"token_address": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3",
50+
"chain_id": 137,
51+
"current_estimate": "3.523474821999491233",
52+
"velocity": "0.000044080120965824",
53+
"week": 62
10354
},
10455
{
105-
"snapshot_timestamp": "2021-02-28T23:51:04.000Z",
106-
"address": "0x1eff8af5d577060ba4ac8a29a13525bb0ee2a3d5",
107-
"current_estimate": "24891.553499185869441135",
56+
"snapshot_timestamp": "2021-08-01T23:58:06.000Z",
57+
"address": "0xa9F8E7337eBb7982f9f5497BC5Ae98e69e1a39A7",
58+
"token_address": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
59+
"chain_id": 137,
60+
"current_estimate": "327.477708233340251809",
10861
"velocity": "0",
109-
"week": 39
62+
"week": 61
11063
},
11164
{
112-
"snapshot_timestamp": "2021-03-01T19:50:35.000Z",
113-
"address": "0x49ff149d649769033d43783e7456f626862cd160",
114-
"current_estimate": "117.508925428870877674",
115-
"velocity": "0.001506078239721282",
116-
"week": 40
117-
},
118-
{
119-
"snapshot_timestamp": "2021-03-01T19:50:35.000Z",
120-
"address": "0x1eff8af5d577060ba4ac8a29a13525bb0ee2a3d5",
121-
"current_estimate": "2844.449505448117102253",
122-
"velocity": "0.036697707708281742",
123-
"week": 40
124-
}
125-
]
126-
}
127-
}
128-
```
129-
130-
## Retrieving Liquidity Provider Data
131-
132-
### Single Liquidity Provider
133-
134-
#### HTTP Request
135-
136-
```jsx
137-
GET https://api.balancer.finance/liquidity-mining/v1/liquidity-provider/:address
138-
```
139-
140-
#### URL Parameters
141-
142-
| Param | Description | Required |
143-
| :--- | :--- | :--- |
144-
| address | The address of the liquidity provider | TRUE |
145-
146-
#### Example Request
147-
148-
```jsx
149-
https://api.balancer.finance/liquidity-mining/v1/liquidity-provider/0xAfC2F2D803479A2AF3A72022D54cc0901a0ec0d6
150-
```
151-
152-
#### Example Response
153-
154-
```jsx
155-
{
156-
"success": true,
157-
"result": {
158-
"current_timestamp": "2021-03-01T21:05:52.906Z",
159-
"liquidity-providers": [
160-
{
161-
"snapshot_timestamp": "2021-03-01T19:50:35.000Z",
162-
"address": "0xAfC2F2D803479A2AF3A72022D54cc0901a0ec0d6",
163-
"current_estimate": "412.683708232827449422",
164-
"velocity": "0.005255637365620232",
165-
"week": 40
65+
"snapshot_timestamp": "2021-08-01T23:58:06.000Z",
66+
"address": "0xa9F8E7337eBb7982f9f5497BC5Ae98e69e1a39A7",
67+
"token_address": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3",
68+
"chain_id": 137,
69+
"current_estimate": "21.831847215556017261",
70+
"velocity": "0",
71+
"week": 61
16672
},
16773
{
168-
"snapshot_timestamp": "2021-02-28T23:51:04.000Z",
169-
"address": "0xAfC2F2D803479A2AF3A72022D54cc0901a0ec0d6",
170-
"current_estimate": "2873.562341070192815096",
74+
"snapshot_timestamp": "2021-08-01T23:58:06.000Z",
75+
"address": "0xa9F8E7337eBb7982f9f5497BC5Ae98e69e1a39A7",
76+
"token_address": "0x580a84c73811e1839f75d86d75d88cca0c241ff4",
77+
"chain_id": 137,
78+
"current_estimate": "0",
17179
"velocity": "0",
172-
"week": 39
173-
}
174-
]
175-
}
176-
}
177-
```
178-
179-
### List of Liquidity Providers
180-
181-
#### HTTP Request
182-
183-
```jsx
184-
POST https://api.balancer.finance/liquidity-mining/v1/liquidity-providers/
185-
```
186-
187-
#### Body Parameters
188-
189-
| Param | Description | Required |
190-
| :--- | :--- | :--- |
191-
| addresses | List of liquidity providers addresses | TRUE |
192-
193-
#### Example Request
194-
195-
```jsx
196-
https://api.balancer.finance/liquidity-mining/v1/liquidity-providers/
197-
```
198-
199-
#### Example Body
200-
201-
```javascript
202-
{
203-
"addresses": [
204-
"0xAfC2F2D803479A2AF3A72022D54cc0901a0ec0d6",
205-
"0x49a2DcC237a65Cc1F412ed47E0594602f6141936"
206-
]
207-
}
208-
```
209-
210-
#### Example Response
211-
212-
```jsx
213-
{
214-
"success": true,
215-
"result": {
216-
"current_timestamp": "2021-03-01T21:05:54.532Z",
217-
"liquidity-providers": [
218-
{
219-
"snapshot_timestamp": "2021-03-01T19:50:35.000Z",
220-
"address": "0xAfC2F2D803479A2AF3A72022D54cc0901a0ec0d6",
221-
"current_estimate": "412.694219507558689886",
222-
"velocity": "0.005255637365620232",
223-
"week": 40
80+
"week": 61
22481
},
22582
{
226-
"snapshot_timestamp": "2021-03-01T19:50:35.000Z",
227-
"address": "0x49a2DcC237a65Cc1F412ed47E0594602f6141936",
228-
"current_estimate": "764.231138137508674059",
229-
"velocity": "0.010903977227043695",
230-
"week": 40
83+
"snapshot_timestamp": "2021-08-01T23:58:06.000Z",
84+
"address": "0xa9F8E7337eBb7982f9f5497BC5Ae98e69e1a39A7",
85+
"token_address": "0xF501dd45a1198C2E1b5aEF5314A68B9006D842E0",
86+
"chain_id": 137,
87+
"current_estimate": "0",
88+
"velocity": "0",
89+
"week": 61
23190
},
23291
{
233-
"snapshot_timestamp": "2021-02-28T23:51:04.000Z",
234-
"address": "0xAfC2F2D803479A2AF3A72022D54cc0901a0ec0d6",
235-
"current_estimate": "2873.562341070192815096",
236-
"velocity": "0",
237-
"week": 39
92+
"snapshot_timestamp": "2021-08-02T12:58:05.000Z",
93+
"address": "0xa9F8E7337eBb7982f9f5497BC5Ae98e69e1a39A7",
94+
"token_address": "0x580a84c73811e1839f75d86d75d88cca0c241ff4",
95+
"chain_id": 137,
96+
"current_estimate": "0",
97+
"velocity": "0.000000000000000000",
98+
"week": 62
23899
},
239100
{
240-
"snapshot_timestamp": "2021-02-28T23:51:04.000Z",
241-
"address": "0x49a2DcC237a65Cc1F412ed47E0594602f6141936",
242-
"current_estimate": "6078.915337562162676477",
243-
"velocity": "0",
244-
"week": 39
101+
"snapshot_timestamp": "2021-08-02T12:58:05.000Z",
102+
"address": "0xa9F8E7337eBb7982f9f5497BC5Ae98e69e1a39A7",
103+
"token_address": "0xF501dd45a1198C2E1b5aEF5314A68B9006D842E0",
104+
"chain_id": 137,
105+
"current_estimate": "0",
106+
"velocity": "0.000000000000000000",
107+
"week": 62
245108
}
246109
]
247110
}
248-
}
111+
}Response Definitions
249112
```
250113

251-
## Response Definitions
252-
253114
| Parameter | Definition |
254115
| :--- | :--- |
255116
| success | `false` if an error occurred, `true` otherwise |
256117
| current\_timestamp | The timestamp of when the request was received by the server |
257118
| snapshot\_timestamp | The last time the mining estimator script was executed and velocity was determined |
258-
| address | The address of the pool or the liquidity provider, depending on the endpoint used |
259-
| velocity | The estimated rate, in `BAL/second`, at which BAL was being mined by the address last time the estimator script was run |
260-
| current\_estimate | The estimated total BAL mined in the `week` up to time `current_timestamp` |
119+
| address | The address of the liquidity provider |
120+
| token\_address | The address of the token received as incentive for liquidity provided |
121+
| chain\_id | The ID of the chain in which liquidity was provided |
122+
| velocity | The estimated rate, in`tokens/second`, at which tokens were being mined by the address at the last time the estimator script was run |
123+
| current\_estimate | The estimated total amount of `token` mined by `address` in the `week` up to time `current_timestamp` |
261124
| week | The number of the week that the estimates refer to, `1` being the week between `Jun-01-2020 00:00:00` and `Jun-07-2020 23:59:59` |
262125

263126
## Client side updates
264127

265-
Clients can update the real time estimate by increasing the `current_estimate` retrieved from the API by `velocity` every second. The underlying data served by the API is updated every other hour, but it takes about 40 minutes to run the script, so clients should not expect any changes before at least 160 minutes have passed since `snapshot_timestamp`.
128+
Clients can update the real time estimate by increasing the `current_estimate` retrieved from the API by `velocity` every second. The underlying data served by the API is updated every other hour, but it takes about 10 minutes to run the script, so clients should not expect any changes before at least 70 minutes have passed since `snapshot_timestamp`.
266129

267130
## Notes
268131

269-
* Estimates are approximate, as the actual mining script relies on a set of snapshot blocks that can only be determined after the end of the week.
270-
* Liquidity providers estimates take into account the govFactor; pools estimates do not.
132+
* Estimates are approximate, as they do not account for liquidity added/removed since the last time the script was run.
271133
* The API only provides estimates for weeks that have not yet been finalized; as soon as the estimator script detects that the previous weeks claims have been [made available](https://ipfs.fleek.co/ipns/balancer-team-bucket.storage.fleek.co/balancer-claim/snapshot), the estimates for that week are removed from the underlying dataset.
272134

0 commit comments

Comments
 (0)