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
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, as well as the beacon chain (validator balance), via the `based-apps-sdk`, and returns the Weight for all Strategies that have opted in to a given Based Application. It then combines them with arbitrary logic, defined as a weighted harmonic mean, where validator balance is twice times more impactful than the ERC20 token.
Copy file name to clipboardExpand all lines: docs/based-applications/developers/README.md
+31-18Lines changed: 31 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -6,12 +6,15 @@ sidebar_position: 6
6
6
7
7
# Based Application Development
8
8
9
-
This guide outlines the steps for based applications developers looking to build on the Based Applications platform.
9
+
This guide outlines the steps for based applications developers looking to build on the Based Applications platform. Below is a diagram that summarizes the Based Applications development flow.
10
+
11
+

10
12
11
13
<!-- ## 0. Developing a Based Application Middleware smart contract
12
14
13
15
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. -->
14
16
17
+
15
18
## 1. Configuring and Registering the bApp
16
19
17
20
1. **Define core attributes**:
@@ -73,13 +76,13 @@ Based Application managers need to track the weight of each participant (strateg
73
76
The first step is made fairly easier thanks to the `based-apps-sdk`, which needs to be installed first:
74
77
75
78
```sh
76
-
npm i @ssv-labs/based-apps-sdk
79
+
npm i @ssv-labs/bapps-sdk
77
80
```
78
81
79
82
The SDK provides a function that returns all the risk-adjusted weights for each token, for all the strategies that opted in to a given bApp:
80
83
81
84
```ts
82
-
import { BasedAppsSDK, chains } from "@ssv-labs/based-apps-sdk";
85
+
import { BasedAppsSDK, chains } from "@ssv-labs/bapps-sdk";
83
86
84
87
const sdk = new BasedAppsSDK({
85
88
chain: chains.holesky.id,
@@ -145,22 +148,32 @@ Note: this is a purely fictional scenario, to show the strong impact of the coef
145
148
Below it's reported a code snippet, showing how to combine weights from step 1 using a simple arithmetic weighted average in the described scenario:
146
149
147
150
```ts
148
-
const validatorImportance = 1;
149
-
const ssvTokenImportance = 2;
150
-
151
-
console.info(`Using arithmetic weighted average to calculate Strategy weights.
152
-
Validator Balance is 2 times more important than 0x68a8ddd7a59a900e0657e9f8bbe02b70c947f25f`);
153
-
154
-
let simpleAverageStrategyWeights = new Map();
155
-
for (const strategy of strategyTokenWeights) {
156
-
// calculate the strategy weight, combining token weight and validator balance weight
0 commit comments