Skip to content

Commit 2ba4e23

Browse files
authored
Merge pull request #50 from ssvlabs/testnet-release
Testnet release
2 parents 16aa1e5 + 9a8dd7d commit 2ba4e23

27 files changed

+531
-285
lines changed

docs/based-applications/developers/smart-contracts/SSVBasedApps.md

Lines changed: 74 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Description: Delegates a percentage of the caller's validator balance to another
2727
| percentage | uint32 | The percentage of balance to delegate (scaled by 1e4, so 100% = 10000) |
2828

2929
Events:
30-
* `DelegationCreated(address indexed delegator, address indexed account, uint32 percentage)`
30+
* `DelegationCreated(address indexed delegator, address indexed receiver, uint32 percentage)`
3131

3232
### **`updateDelegatedBalance(account, percentage)`**
3333

@@ -39,7 +39,7 @@ Description: Updates an existing delegation percentage for an account.
3939
| percentage | uint32 | The new percentage to delegate (scaled by 1e4) |
4040

4141
Events:
42-
* `DelegationUpdated(address indexed delegator, address indexed account, uint32 percentage)`
42+
* `DelegationUpdated(address indexed delegator, address indexed receiver, uint32 percentage)`
4343

4444
### **`removeDelegatedBalance(account)`**
4545

@@ -50,17 +50,16 @@ Description: Removes delegation from an account.
5050
| account | address | The address of the account whose delegation is being removed |
5151

5252
Events:
53-
* `DelegationRemoved(address indexed delegator, address indexed account)`
53+
* `DelegationRemoved(address indexed delegator, address indexed receiver)`
5454

5555
## bApps
5656

57-
### **`registerBApp(bApp, tokens, sharedRiskLevels, metadataURI)`**
57+
### **`registerBApp(tokens, sharedRiskLevels, metadataURI)`**
5858

5959
Description: Registers a new Based Application (bApp) with specified tokens and risk levels.
6060

6161
| **Parameter** | **Type** | **Description** |
6262
| ------------ | -------- | --------------- |
63-
| bApp | address | The address of the bApp to register |
6463
| tokens | address[] | List of token addresses the bApp accepts |
6564
| sharedRiskLevels | uint32[] | New risk levels for each token (max 100000) (scaled by 1e4, so 2.5 = 25000) |
6665
| metadataURI | string | metadata URI of the bApp, which is a link (e.g., http://example.com) to a JSON file containing metadata such as the name, description, logo, etc. |
@@ -93,15 +92,22 @@ Description: Adds new tokens to an existing bApp.
9392
Events:
9493
* `TokensAddedToBApp(address indexed bApp, address[] tokens, uint32[] sharedRiskLevels)`
9594

96-
### **`updateBAppTokens(bApp, tokens, sharedRiskLevels)`**
95+
### **`updateBAppsTokens(tokenConfigs)`**
9796

98-
Description: Updates the shared risk levels for existing tokens in a bApp. Can only be called by the bApp owner. Fails if any token is not already supported by the bApp or if the new risk level is the same as the current one.
97+
Description: Updates the token configurations for multiple bApps. Can only be called by the bApp owner.
9998

10099
| **Parameter** | **Type** | **Description** |
101100
| ------------ | -------- | --------------- |
102-
| bApp | address | The address of the bApp |
103-
| tokens | address[] | List of token addresses to update |
104-
| sharedRiskLevels | uint32[] | New risk levels for each token (max 100000) (scaled by 1e4, so 2.5 = 25000) |
101+
| tokenConfigs | ICore.TokenConfig[] | Array of token configurations to update |
102+
103+
The TokenConfig data struct is as follows:
104+
105+
```solidity
106+
struct TokenConfig {
107+
address token;
108+
uint32 sharedRiskLevel;
109+
}
110+
```
105111

106112
Events:
107113
* `BAppTokensUpdated(address indexed bApp, address[] tokens, uint32[] sharedRiskLevels)`
@@ -154,11 +160,11 @@ Description: Deposits ERC20 tokens into a strategy.
154160
| **Parameter** | **Type** | **Description** |
155161
| ------------ | -------- | --------------- |
156162
| strategyId | uint32 | The ID of the strategy to deposit into |
157-
| token | address | The address of the ERC20 token |
163+
| token | IERC20 | The address of the ERC20 token |
158164
| amount | uint256 | The amount of tokens to deposit |
159165

160166
Events:
161-
* `StrategyDeposit(uint32 indexed strategyId, address indexed account, address indexed token, uint256 amount)`
167+
* `StrategyDeposit(uint32 indexed strategyId, address indexed account, address token, uint256 amount)`
162168

163169
### **`depositETH(strategyId)`**
164170

@@ -171,29 +177,6 @@ Description: Deposits ETH into a strategy.
171177
Events:
172178
* `StrategyDeposit(uint32 indexed strategyId, address indexed account, address indexed token, uint256 amount)`
173179

174-
### **`fastWithdrawERC20(strategyId, token)`**
175-
176-
Description: Performs a fast withdrawal of ERC20 tokens from a strategy if the token is not used in any obligations.
177-
178-
| **Parameter** | **Type** | **Description** |
179-
| ------------ | -------- | --------------- |
180-
| strategyId | uint32 | The ID of the strategy to withdraw from |
181-
| token | address | The address of the ERC20 token to withdraw |
182-
183-
Events:
184-
* `StrategyWithdrawal(uint32 indexed strategyId, address indexed account, address indexed token, uint256 amount, bool isFast)`
185-
186-
### **`fastWithdrawETH(strategyId)`**
187-
188-
Description: Performs a fast withdrawal of ETH from a strategy if the token is not used in any obligations.
189-
190-
| **Parameter** | **Type** | **Description** |
191-
| ------------ | -------- | --------------- |
192-
| strategyId | uint32 | The ID of the strategy to withdraw from |
193-
194-
Events:
195-
* `StrategyWithdrawal(uint32 indexed strategyId, address indexed account, address indexed token, uint256 amount, bool isFast)`
196-
197180
### **`proposeWithdrawal(strategyId, token, amount)`**
198181

199182
Description: Proposes a withdrawal of ERC20 tokens from a strategy, initiating the timelock period. Cannot be used for ETH withdrawals (use proposeWithdrawalETH instead). The amount must be greater than 0 and not exceed the user's balance in the strategy.
@@ -205,7 +188,7 @@ Description: Proposes a withdrawal of ERC20 tokens from a strategy, initiating t
205188
| amount | uint256 | The amount of tokens to withdraw |
206189

207190
Events:
208-
* `StrategyWithdrawalProposed(uint32 indexed strategyId, address indexed account, address indexed token, uint256 amount)`
191+
* `StrategyWithdrawalProposed(uint32 indexed strategyId, address indexed account, address token, uint256 amount)`
209192

210193
### **`finalizeWithdrawal(strategyId, token)`**
211194

@@ -217,7 +200,7 @@ Description: Finalizes an ERC20 token withdrawal after the timelock period has e
217200
| token | IERC20 | The ERC20 token contract to withdraw |
218201

219202
Events:
220-
* `StrategyWithdrawal(uint32 indexed strategyId, address indexed account, address indexed token, uint256 amount, bool isFast)`
203+
* `StrategyWithdrawal(uint32 indexed strategyId, address indexed account, address token, uint256 amount, bool isFast)`
221204

222205
### **`proposeWithdrawalETH(strategyId, amount)`**
223206

@@ -254,7 +237,7 @@ Description: Creates a single obligation for a bApp.
254237
| obligationPercentage | uint32 | Percentage to obligate (scaled by 1e4) |
255238

256239
Events:
257-
* `ObligationCreated(uint32 indexed strategyId, address indexed bApp, address indexed token, uint32 percentage)`
240+
* `ObligationCreated(uint32 indexed strategyId, address indexed bApp, address token, uint32 percentage)`
258241

259242
### **`fastUpdateObligation(strategyId, bApp, token, obligationPercentage)`**
260243

@@ -268,7 +251,7 @@ Description: Quickly updates an obligation percentage higher for a bApp (can onl
268251
| obligationPercentage | uint32 | New percentage to obligate (must be higher than current) |
269252

270253
Events:
271-
* `ObligationUpdated(uint32 indexed strategyId, address indexed bApp, address indexed token, uint32 percentage, bool isFast)`
254+
* `ObligationUpdated(uint32 indexed strategyId, address indexed bApp, address token, uint32 percentage)`
272255

273256
### **`proposeUpdateObligation(strategyId, bApp, token, obligationPercentage)`**
274257

@@ -282,7 +265,7 @@ Description: Proposes an update to an obligation percentage, initiating the time
282265
| obligationPercentage | uint32 | New percentage to obligate |
283266

284267
Events:
285-
* `ObligationUpdateProposed(uint32 indexed strategyId, address indexed sender, address indexed token, uint32 percentage, uint32 unlockTime)`
268+
* `ObligationUpdateProposed(uint32 indexed strategyId, address indexed bApp, address token, uint32 percentage)`
286269

287270
### **`finalizeUpdateObligation(strategyId, bApp, token)`**
288271

@@ -307,7 +290,7 @@ Description: Proposes a new fee for a strategy, initiating the timelock period.
307290
| proposedFee | uint32 | The proposed new fee (scaled by 1e4) |
308291

309292
Events:
310-
* `StrategyFeeUpdateProposed(uint32 indexed strategyId, address indexed sender, uint32 proposedFee, uint32 currentFee)`
293+
* `StrategyFeeUpdateProposed(uint32 indexed strategyId, address owner, uint32 proposedFee)`
311294

312295
### **`finalizeFeeUpdate(strategyId)`**
313296

@@ -317,9 +300,59 @@ Description: Finalizes a fee update after the timelock period has elapsed. Must
317300
| ------------ | -------- | --------------- |
318301
| strategyId | uint32 | The ID of the strategy |
319302

303+
Events:
304+
* `StrategyFeeUpdated((uint32 indexed strategyId, address owner, uint32 newFee, bool isFast)`
305+
306+
### **`reduceFee(strategyId, proposedFee)`**
307+
308+
Description: Reduces the fee for a strategy. This function allows strategy owners to decrease their fee percentage.
309+
310+
| **Parameter** | **Type** | **Description** |
311+
| ------------ | -------- | --------------- |
312+
| strategyId | uint32 | The ID of the strategy |
313+
| proposedFee | uint32 | The new proposed fee percentage (scaled by 1e4) |
314+
320315
Events:
321316
* `StrategyFeeUpdated(uint32 indexed strategyId, address indexed sender, uint32 newFee, uint32 oldFee)`
322317

318+
### **`slash(strategyId, bApp, token, percentage, data)`**
319+
320+
Description: Slashes a strategy's balance for a specific bApp and token. This function is used to penalize strategies that fail to meet their obligations.
321+
322+
| **Parameter** | **Type** | **Description** |
323+
| ------------ | -------- | --------------- |
324+
| strategyId | uint32 | The ID of the strategy to slash |
325+
| bApp | address | The address of the bApp |
326+
| token | address | The token address to slash |
327+
| percentage | uint32 | The percentage of the balance to slash (scaled by 1e4) |
328+
| data | bytes | Additional data required for the slashing operation |
329+
330+
Events:
331+
* `StrategySlashed(uint32 indexed strategyId, address indexed bApp, address token, uint32 percentage, address receiver)`
332+
333+
### **`withdrawSlashingFund(token, amount)`**
334+
335+
Description: Withdraws slashing funds for a specific token from the slashing fund.
336+
337+
| **Parameter** | **Type** | **Description** |
338+
| ------------ | -------- | --------------- |
339+
| token | address | The address of the token to withdraw |
340+
| amount | uint256 | The amount of tokens to withdraw |
341+
342+
Events:
343+
* `SlashingFundWithdrawn(address token, uint256 amount)`
344+
345+
### **`withdrawETHSlashingFund(amount)`**
346+
347+
Description: Withdraws ETH from the slashing fund.
348+
349+
| **Parameter** | **Type** | **Description** |
350+
| ------------ | -------- | --------------- |
351+
| amount | uint256 | The amount of ETH to withdraw (in wei) |
352+
353+
Events:
354+
* `ETHSlashingFundWithdrawn(uint256 amount)`
355+
323356
## Account
324357

325358
### **`updateAccountMetadataURI(metadataURI)`**
Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,55 @@
11
---
2-
sidebar_label: 'Metadata Schema'
2+
sidebar_label: 'Metadata Schemas'
33
sidebar_position: 5
44
---
55

6-
# Metadata Schema
6+
# Metadata Schemas
77

8-
The metadata schema is used to store the metadata of the bApp.
8+
Metadata schemas are used to store the metadata of a bApp, strategy, and account.
99

10-
It is stored in the Based App Manager smart contract, as `metadataURI` for a bapp. It is a link (e.g., `http://example.com`) to a JSON file containing metadata such as the name, description, logo, etc. You can set the URI when [registering a bApp](./SSVBasedApps#registerbappbapp-tokens-sharedrisklevels-metadatauri) or [update the URI at any point in the future](./SSVBasedApps#updatebappmetadatauribapp-metadatauri).
10+
They should be saved at a URL that can be accessed freely, such as [this.](https://raw.githubusercontent.com/taylorferran/bapp-metadata/refs/heads/main/metadata.json)
11+
12+
## Bapp
13+
14+
Stored in the Based App Manager smart contract, as `metadataURI` for a bapp. It is a link (e.g., `http://example.com`) to a JSON file containing metadata such as the name, description, logo, etc. You can set the URI when [registering a bApp](./SSVBasedApps#registerbappbapp-tokens-sharedrisklevels-metadatauri) or [update the URI at any point in the future](./SSVBasedApps#updatebappmetadatauribapp-metadatauri).
1115

1216
:::info
1317
It is important to set this correctly, as it is used to identify the bApp on interfaces such as the SSV Based App website.
1418
:::
1519

16-
It is a JSON object that contains the following fields:
20+
### Bapp schema
1721

1822
```json
1923
{
20-
"name": "J-Oracle",
21-
"description": "J-Oracle delivers secure data feeds and real-world connectivity for blockchains and beyond.",
22-
"logo": "https://raw.githubusercontent.com/jordanssv/metadata/refs/heads/main/JO.png"
23-
"website": "https://www.joracle.io/",
24+
"name": "My bApp Name",
25+
"description": "A description for my first bApp.",
26+
"logo": "https://your-hosted-content.com/image.png",
27+
"website": "https://www.my-bapp-address.com/"
2428
}
2529
```
2630

27-
## Fields
31+
### Fields
2832

2933
- `name`: The name of the bApp.
3034
- `description`: The description of the bApp.
3135
- `logo`: The logo of the bApp.
32-
- `website`: The website of the bApp.
36+
- `website`: The website of the bApp.
37+
38+
39+
## Strategy schema
40+
41+
```json
42+
{
43+
"name": "My Strategy",
44+
"description": "A description about my strategy."
45+
}
46+
```
47+
48+
## Account
49+
50+
```json
51+
{
52+
"name": "My Account",
53+
"logo": "https://my-hosted-account.com/image.png"
54+
}
55+
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
sidebar_label: 'User Guides'
3+
sidebar_position: 3
4+
---
5+
6+
# User Guides
7+
8+
This section contains a number of guides which will teach a user how to interact with Based Applications.
9+
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
sidebar_label: 'Create a Strategy'
3+
sidebar_position: 1
4+
---
5+
6+
# How to Create a Strategy
7+
8+
Strategies are used to secure Based Applications, the most common use cases of bApps [are described on this page](../learn/based-applications/use-cases.md).
9+
10+
Strategies are often created by node operators (not necessarily SSV node operators) that want to engage with bApps and earn rewards for securing them. You can read more [about the Rewards for securing bApps](../learn/ssv2.0-a-based-applications-protocol/ultra-sound-ssv/rewards.md).
11+
12+
## 1. Go to Strategies page
13+
14+
Navigate to the [SSV Webapp](https://app.stage.ssv.network/account/my-delegations), login with your chosen wallet and click on Strategies.
15+
16+
This page will display a list of the Strategies you already created.
17+
18+
<div style={{ textAlign: 'center' }}>
19+
<img src="/img/create-strategy-1.png" alt="" />
20+
</div>
21+
22+
## 2. Create Strategy
23+
24+
Once you clicked on "Create Strategy" you will see a list of available bApps you can choose from.
25+
26+
In this example, we will skip this step and choose "I'll do it later" on the bottom of the page.
27+
28+
<div style={{ textAlign: 'center' }}>
29+
<img src="/img/create-strategy-2.png" alt="" />
30+
</div>
31+
32+
## 3. Set Fee and Obligations
33+
34+
You will be prompted to set the Obligations and the Fees for your strategy. If you did not choose any bApp on the previous step, the Obligations step will be skipped and you will go to the "Set Fee" stage.
35+
36+
Enter an amount for your Fee, and click the Continue button.
37+
38+
<div style={{ textAlign: 'center', width: '60%', margin: '0 auto' }}>
39+
<img src="/img/create-strategy-3.png" alt="" />
40+
</div>
41+
42+
## 4. Provide Metadata
43+
44+
Metadata for your Strategy and your Account will have to be set with `.json` files.
45+
46+
Here is how the example metadata file for Strategy looks like:
47+
```json
48+
{
49+
"name": "My Strategy",
50+
"description": "A description about my strategy."
51+
}
52+
```
53+
54+
And for the Account metadata we used:
55+
```json
56+
{
57+
"name": "My Account",
58+
"logo": "https://my-hosted-account.com/image.png"
59+
}
60+
```
61+
62+
Once you provided URI to those files, you will see that information on the page.
63+
64+
<div style={{ textAlign: 'center', width: '100%', margin: '0 auto' }}>
65+
<img src="/img/create-strategy-4.png" alt="" />
66+
</div>
67+
68+
After you verified the information, click on Continue.
69+
70+
## 5. Sign transactions
71+
72+
To create your Strategy you will need to sign 2 transactions.
73+
74+
The first one is to register your Strategy.
75+
76+
<div style={{ textAlign: 'center', width: '60%', margin: '0 auto' }}>
77+
<img src="/img/create-strategy-5.png" alt="" />
78+
</div>
79+
80+
After the first one is completed, another pop-up will appear to sign Registration of your Account Metadata.
81+
82+
<div style={{ textAlign: 'center', width: '60%', margin: '0 auto' }}>
83+
<img src="/img/create-strategy-6.png" alt="" />
84+
</div>
85+
86+
87+
## 6. Check the created Strategy
88+
89+
Once both of the transactions are completed, you will be redirected to the page of your newly created Strategy.
90+
91+
You can now [Deposit Funds to your strategy](./deposit-to-strategy.md).

0 commit comments

Comments
 (0)