Skip to content

Commit 5aabd2a

Browse files
committed
small fixes
1 parent 3e8534f commit 5aabd2a

File tree

2 files changed

+13
-36
lines changed

2 files changed

+13
-36
lines changed

docs/based-applications/developers/BA-SDK/module-reference/api-module.md

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,6 @@ Example output:
4242
}
4343
```
4444

45-
### `getBappSlashableBalance(string bappAddress)`
46-
47-
Given the address of a Based Application, returns the slashable balance of the Bapp.
48-
49-
Input:
50-
51-
| Input parameter | Input type | Description | Example input |
52-
| ----------------- | ---------- | ----------------------------- | -------------------------------------------- |
53-
| bappId | string | Address of the Based Application | '0x64714cf5db177398729e37627be0fc08f43b17a6' |
54-
55-
Example:
56-
57-
```typescript
58-
const getBappSlashableBalance = await sdk.api.getBappSlashableBalance({
59-
bAppId: "0x64714cf5db177398729e37627be0fc08f43b17a6",
60-
});
61-
```
62-
63-
Example output:
64-
65-
```bash
66-
[
67-
{
68-
token: '0x68a8ddd7a59a900e0657e9f8bbe02b70c947f25f',
69-
balance: 97110000000000000000n
70-
}
71-
]
72-
```
73-
7445
### `getStrategyTokenWeights(string bappAddress)`
7546

7647
Used to calculate the weights of the strategies in a given Bapp.
@@ -116,7 +87,7 @@ Example output:
11687
]
11788
```
11889

119-
### `getDelegatedBalances(string bappAddress)`
90+
### `getDelegatedBalances(string bappAddress)`
12091

12192
Given the address of a Based Application, returns the delegated balances of the Bapp.
12293

docs/based-applications/learn/based-applications/strategy-weights.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,25 @@ To do this manually, follow the steps below and obtain the information by queryi
2020

2121
For all the strategies that opted-in to a given bApp, clients will need to:
2222

23-
1. **Gather Obligated Balances**: Get the obligated balance from each strategy, for each token used by the bApp.
23+
### 1. **Gather Obligated Balances**
24+
Get the obligated balance from each strategy, for each token used by the bApp.
2425
```go
2526
ObligatedBalance mapping(Token -> Strategy -> Amount)
2627
```
2728
This is done by multiplying the `percentage` of obligated tokens by the `balance` of such tokens deposited to the strategy.
2829

29-
2. **Sum Obligations**: From `ObligatedBalance`, bApps should sum all obligations and compute the total amount obligated to the bApp by all strategies.
30+
### 2. **Sum Obligations**
31+
From `ObligatedBalance`, bApps should sum all obligations and compute the total amount obligated to the bApp by all strategies.
3032
```go
3133
TotalBAppBalance mapping(Token -> Amount)
3234
```
33-
3. **Calculate Risk**: For each token, it should get the risk (token-over usage) of each strategy. This is obtained by summing all the `percentages` in all `Obligations` for a given token, and dividing it by `100`.
35+
### 3. **Calculate Risk**
36+
For each token, it should get the risk (token-over usage) of each strategy. This is obtained by summing all the `percentages` in all `Obligations` for a given token, and dividing it by `100`.
3437
```go
3538
Risk mapping(Token -> Strategy -> Float)
3639
```
37-
4. **Compute Risk-Aware Weights**: With this information, bApps can compute the weight of a participant for a certain token by
40+
### 4. **Compute Risk-Aware Weights**
41+
With this information, bApps can compute the weight of a participant for a certain token by
3842

3943
$$
4044
W_{\text{strategy, token}} = c_{\text{token}} \times \dfrac{ObligatedBalance[\text{token}][\text{strategy}]}{TotalBAppBalance[\text{token}]} e^{-\beta_{\text{token}} \times max(1, Risk[\text{token}][\text{strategy}])}
@@ -46,7 +50,8 @@ For all the strategies that opted-in to a given bApp, clients will need to:
4650
c_{\text{token}} = \left( \sum_{\text{strategy}} \dfrac{ObligatedBalance[\text{token}][\text{strategy}]}{TotalBAppBalance[\text{token}]} e^{-\beta_{\text{token}} \times max(1, Risk[\text{token}][\text{strategy}])} \right)^{-1}
4751
$$
4852

49-
5. **If the bApp uses validator balance**, the client should also generate a mapping of `Strategy -> Validator Balance` with the amount from each strategy. Clients will need to do this in a couple of steps:
53+
### 5. **If the bApp uses validator balance**
54+
The client should also generate a mapping of `Strategy -> Validator Balance` with the amount from each strategy. Clients will need to do this in a couple of steps:
5055

5156
a. **Gather Delegated Balances**: Get all the delegations made to the owner of a strategy for all the strategies that opted in to a bApp.
5257

@@ -68,7 +73,8 @@ For all the strategies that opted-in to a given bApp, clients will need to:
6873
W_{\text{strategy, validator balance}} = \dfrac{ObligatedBalance[\text{validator balance}][\text{strategy}]}{TotalBAppBalance[\text{validator balance}]}
6974
$$
7075

71-
6. **Combine into the Final Weight**: With the per-token weights, the final step is to compute a final weight for the participant using a **combination function**. Such function is defined by the bApp and can be tailored to its specific needs. Traditional examples include the arithmetic mean, geometric mean, and harmonic mean.
76+
### 6. **Combine into the Final Weight**
77+
With the per-token weights, the final step is to compute a final weight for the participant using a **combination function**. Such function is defined by the bApp and can be tailored to its specific needs. Traditional examples include the arithmetic mean, geometric mean, and harmonic mean.
7278

7379
**Example**: Let's consider a bApp that uses tokens $A$ and $B$, and considers $A$ to be twice as important as $B$. Then, it could use the following weighted harmonic mean as its combination function:
7480
$$

0 commit comments

Comments
 (0)