Skip to content

Conversation

@MatheusFranco99
Copy link
Contributor

Overview

This PR adds an onboarding guide for bApp builders

```go
Risk map[Token]map[Strategy]float64
```
4. **Compute Risk-Aware Weights**: With this information, it can compute the weight of a participant for a certain token by
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think there could be a function on the contract to compute the weight, so some apps could use this data on-chain...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The model described is a proposal by us, not a must. So, a bApp can actually define any weight model it wants. But I see no issue with adding the default one as a function. I think this is more of a product decision

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

@liorrutenberg @mtabasco @GalRogozinski ? Any opinion on this?


where $c_{\text{token}}$ is a normalization constant defined as

$$c_{\text{token}} = \left( \sum_{\text{strategy}} \frac{ObligatedBalance[\text{token}][\text{strategy}]}{TotalBAppBalance[\text{token}]} e^{-\beta_{\text{token}} \times max(1, Risk[\text{token}][\text{strategy}])} \right)^{-1}$$
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not reviewed the math

MatheusFranco99 and others added 8 commits January 30, 2025 09:40
Co-authored-by: Riccardo Persiani <[email protected]>
Co-authored-by: Riccardo Persiani <[email protected]>
Co-authored-by: Riccardo Persiani <[email protected]>
Co-authored-by: Riccardo Persiani <[email protected]>
Co-authored-by: Riccardo Persiani <[email protected]>
Co-authored-by: Riccardo Persiani <[email protected]>
Co-authored-by: Riccardo Persiani <[email protected]>
@liorrutenberg
Copy link

@MatheusFranco99 lets move it to a docs folder or examples

Copy link

@GalRogozinski GalRogozinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a reminder that we need to add the actual contract address once we have it deployed

for strategy in strategies do

# Check if strategy participates in the bApp
if !api.HasStrategyOptedInToBApp(strategy, bApp) then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api hints that we have some SDK in place.
Maybe whoever is writing the SDK can put actual runnable code here that uses the abi

Copy link
Contributor

@mtabasco mtabasco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @MatheusFranco99 !
I added some ideas/suggestions.

@MatheusFranco99
Copy link
Contributor Author

@liorrutenberg
Moved it to a folder "doc".
I think all comments are addressed.
Pls, follow with your review

Copy link

@GalRogozinski GalRogozinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still waiting for a link to the deployed contract on etherscan...
Wonder if we can have runnable code snippets


Once the bApp is registered, strategies can join it and allocate capital to secure it.

### 2.1 Opting in

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are missing how to register operators (accounts) and create strategy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was a guide mainly for the bApp to register itself and understand how others join.
If strategies registering is really necessary, I can add it
Wdyt @liorrutenberg ?

)
```
- `tokens`: List of tokens to obligate to the bApp.
- `obligationPercentages`: The proportion of each token's balance to commit to the bApp.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The encoding format of the obligation percentages is not clear.
We decided on 5000 representing 50.00% right?
It needs to be clear

Maybe @mtabasco or @riccardo-ssvlabs can provide an example of a cli-command that will show examples of how to create the transactions. This will make sure will use proper encoding when creating the txs.

I think clef allows using json as tx data, so maybe a json would be a good idea?
But the contract guys probably know what is the best way to give such examples

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well-spotted.
Because it's a uint32, we could have had far better precision than 2 decimals
But I think that's the current encoding, yes.
I'll add this mention to the encoding

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one simple way to send transactions using a cli-command is with Foundry's cast.

# install foundry
curl -L https://foundry.paradigm.xyz | bash

cast send <CONTRACT_ADDRESS> "optInToBApp(uint256,address,address[],uint32[],bytes)" \
    <STRATEGY_ID> <BAPP_ADDRESS> \
    '["0xTokenAddress1","0xTokenAddress2"]' '[1000,2000]' "0xDataParam" \
    --private-key <YOUR_PRIVATE_KEY> --rpc-url <RPC_URL>

You can use --keystore param to access key store instead of passing raw private key to the cli command.

Comment on lines 91 to 96
$$W^{\text{final}}_{\text{strategy}} = c_{\text{final}} \times \frac{1}{\frac{2/3}{W_{\text{strategy, A}}} + \frac{1/3}{W_{\text{strategy, B}}}}$$

where $c_{\text{final}}$ is a normalization constant computed as

$$c_{\text{final}} = \left( \sum_{\text{strategy}} \frac{1}{\frac{2/3}{W_{\text{strategy, A}}} + \frac{1/3}{W_{\text{strategy, B}}}} \right)^{-1}$$

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still doesn't render well on github

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It renders locally. I'll try a change

Copy link
Contributor

@mtabasco mtabasco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done @MatheusFranco99 !


1. **Define core attributes**:
- `bApp`: a unique 20-byte EVM address that uniquely identifies the bApp.
- `tokens`: A list of ERC-20 tokens to be used in the bApp's security mechanism. For the native ETH token, use the special address [`0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE`](https://github.com/ssvlabs/based-applications/blob/92a5d3d276148604e3fc087c1c121f78b136a741/src/BasedAppManager.sol#L62).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: substitute the links with a specific commit with links with main. E.g.:

https://github.com/ssvlabs/based-applications/blob/main/src/BasedAppManager.sol

Lines links may be broken at first, but when the contract stabilizes, people would not be weirded out by visiting a contract's commit page that is months old.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it was requested to change the links to the ones from etherscan

@liorrutenberg liorrutenberg merged commit 3b9429b into main Feb 3, 2025
3 checks passed
@liorrutenberg liorrutenberg deleted the bapp-onboarding branch February 3, 2025 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants