You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generated new unlisted participants weight example page
Added Google Tag plugin and related config
Removed mainnet mentions from smart contracts page
Fixed address in Troubleshooting page
Copy file name to clipboardExpand all lines: docs/based-applications/developers/based-application-depvelopment.md
+33-48Lines changed: 33 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
1
---
2
2
sidebar_label: 'Based App Development'
3
-
sidebar_position: 1
3
+
sidebar_position: 2
4
4
---
5
5
6
6
# Based Application Development
7
7
8
8
This guide outlines the steps for based applications developers looking to build on the Based Applications platform.
9
9
10
-
## 0. Developing a Based Application Middleware smart contract
10
+
<!--## 0. Developing a Based Application Middleware smart contract
11
11
12
-
The `BAppManager` smart contract developed by SSV Labs accepts registrations of BApps that implement a specific interface. This is outlined [in this dedicated page](./smart-contracts/based-app-middleware-example.md), that also provides a simple example.
12
+
The `BAppManager` smart contract developed by SSV Labs accepts registrations of BApps that implement a specific interface. This is outlined [in this dedicated page](./smart-contracts/based-app-middleware-example.md), that also provides a simple example.-->
13
13
14
14
## 1. Configuring and Registering the bApp
15
15
@@ -67,9 +67,8 @@ bApp clients need to track the weight of each participant in the bApp.
67
67
A simple way to do so would be to use the Subgraph and perform a request with this query:
3.**Sum Obligations**: From `ObligatedBalance`, it can sum all obligations and compute the total amount obligated to the bApp by all strategies.
117
+
2.**Sum Obligations**: From `ObligatedBalance`, bApps should sum all obligations and compute the total amount obligated to the bApp by all strategies.
137
118
```go
138
119
TotalBAppBalancemapping(Token -> Amount)
139
120
```
140
-
4.**Calculate Risk**: For each token, it should get the risk (token-over usage) of each strategy.
121
+
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`.
141
122
```go
142
123
Riskmapping(Token -> Strategy -> Float)
143
124
```
144
-
5.**Compute Risk-Aware Weights**: With this information, it can compute the weight of a participant for a certain token by
125
+
4.**Compute Risk-Aware Weights**: With this information, bApps can compute the weight of a participant for a certain token by
If the bApp uses validator balance, the client should also read a `map[Strategy]ValidatorBalance` with the amount from each strategy. As this capital doesn't involve any type of risk, all risk values can be set to 0. Thus, for this capital, this is equivalent to
137
+
5.**If the bApp uses validator balance**, the client should also generate a mapping of `Strategy -> Validator Balance` with the amount from each strategy.
138
+
139
+
This is obtained as *the sum of all the validator balances delegated to the owner of the strategy*. Bear in mind, these are stored as percentages, so the actual *effective validator balance* for a given `delegator` has to be looked up the beacon chain (the [`based-apps-sdk`](https://github.com/ssvlabs/based-apps-sdk) provides a function to do this: `getValidatorsBalance(account)`), and then multiplied by the percentage that is delegated.
140
+
141
+
As this capital doesn't involve any type of risk, all risk values can be set to 0. Thus, for this capital, this is equivalent to:
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.
164
148
165
149
166
-
**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:
150
+
**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:
<!-- [At the following page](./participant-weight-example.md), you can find a coded example of how to combine Subgraph data with the logic described above. -->
The script below uses the logic described in the [related section of the Based Application Development page](based-application-depvelopment.md/#3-participant-weight), fetching the data from the Based Application Subgraph, and returns the Weight for all Strategies that have opted in to a given Based Application
Copy file name to clipboardExpand all lines: docs/based-applications/developers/smart-contracts/troubleshooting.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,5 +12,4 @@ The best way to investigate this issue is to inspect the 4-byte selector for the
12
12
13
13
A useful tool that is able to do this comparison, is [tenderly](https://dashboard.tenderly.co/explorer), thanks to the fact that ssv.network's Smart Contracts have been verified.
14
14
15
-
<!-- TODO fix address -->
16
-
Here is the [SSVNetwork contract, for example](https://dashboard.tenderly.co/contract/holesky/0x).
15
+
Here is the [`BasedAppManager` contract, for example](https://dashboard.tenderly.co/contract/holesky/0x9B3345F3B1Ce2d8655FC4B6e2ed39322d52aA317).
0 commit comments