Skip to content

Commit f6261db

Browse files
MakMufticP1sar
andauthored
chore: add fees documentation (#120)
Co-authored-by: Kirill <[email protected]>
1 parent 8546a72 commit f6261db

8 files changed

+96
-0
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Sygma bridge uses [chainbridge-core](https://github.com/ChainSafe/chainbridge-co
1616

1717
1. [Local environment](#local-environment)
1818
2. [Configuration](#configuration)
19+
3. [Technical documentation](#technical-documentation)
1920

2021
&nbsp;
2122

@@ -50,3 +51,8 @@ translate to ENV variable named `SYG_RELAYER_MPCCONFIG_PORT`.
5051

5152
Each `ChainConfig` is defined as one ENV variable, where its content is JSON configuration for one chain/domain.
5253
Variables are named like this: `SYG_DOM_X` where `X` is domain id.
54+
55+
## Technical documentation
56+
Each service has a technical documentation inside its repository under `/docs` directory. [Here](/docs/Home.md) you can find technical documentation for relayers.
57+
58+
Additionally, the [general high-level documentation for the entire Sygma system](/docs/general/Arhitecture.md) can be found in this same repository under the `/docs/general` directory.

docs/Home.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Relayers
2+
3+
_Relayers are entities that ensure bridge decentralization and execute asset bridging._
4+
5+
## Abstract
6+
7+
At the core of Sygma exists a set of relayers that are distributed among several legal entities and operate under a
8+
trusted federation model. Spreading the relayer set across several legal entities creates a distribution of
9+
responsibilities and mitigates risk by disincentivizing relayers in the set to act in an unfair manner.
10+
Each relayer within the set listens to both the source and destination chains that are being bridged by Sygma. Based on
11+
events that are emitted, these relayers then execute relevant actions.
12+
This multi-relayer set is responsible for relaying messages from a source network to a destination network. Relayers are
13+
operating with private key share and execution happens on the destination network with MPC private key.

docs/general/Arhitecture.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Sygma Architecture
2+
3+
![](/docs/resources/sygma-arhitecture.png)
4+
5+
## Components
6+
7+
- **[Fees](/docs/general/Fees.md)** - high-level overview of handling fees
8+
- **[Relayers](/docs/Home.md)** - relayer technical documentation

docs/general/Fees.md

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Fees
2+
3+
Sygma allows granular control of handling fees for each resource. Even though specific implementations differ based on
4+
chain architecture, general functionality is the same. The concept is that each resource is assigned a fee strategy for
5+
every potential destination domain, with this mapping also outlining all potential bridging routes for a given resource.
6+
7+
![](/docs/resources/fee-router-general.png)
8+
9+
## Fee strategies
10+
11+
Fee strategy defines a set of rules on how fees should be charged when executing deposits on the source chain.
12+
13+
### Static fee strategy
14+
15+
This strategy always requires a predefined static fee amount per deposit. **It can only collect fees in the native
16+
currency of the source chain**.
17+
18+
*On the diagram below, we use [Sygma SDK](https://github.com/sygmaprotocol/sygma-sdk) for interaction with all services.*
19+
20+
![](/docs/resources/static-fee-general.png)
21+
22+
#### Deposit flow
23+
24+
1) Calculate the final fee
25+
- Based on resourceID and domainsID, request a final fee amount that will be required to execute the deposit.
26+
2) Execute deposit
27+
- Send the appropriate base currency amount based on the calculated final fee when executing the deposit.
28+
29+
### Dynamic fee strategy
30+
31+
This strategy utilizes the [Sygma Fee Oracle service](https://github.com/sygmaprotocol/sygma-fee-oracle), which issues
32+
fee estimates with details on the gas price for the destination chain. In addition, fee oracle can provide price
33+
information for different tokens, enabling paying bridging fees in the not native currency. Each issued gas estimate has
34+
a limited time validity in which it needs to be executed.
35+
36+
Check out
37+
the [Sygma Fee Oracle technical documentation](https://github.com/sygmaprotocol/sygma-fee-oracle/blob/main/docs/Home.md) for
38+
more details on the service and the format of the issued fee estimates.
39+
40+
*On the diagram below, we use [Sygma SDK](https://github.com/sygmaprotocol/sygma-sdk) for interaction with all services.*
41+
42+
![](/docs/resources/dynamic-fee-general.png)
43+
44+
#### Deposit flow
45+
46+
1) Fetch fee estimate
47+
- Based on resource ID and domains ID, request fee estimate from Fee Oracle service. This fee estimate is valid
48+
until `expiresAt`.
49+
2) Validate fee estimate and calculate the final fee
50+
- Validate the signature on the fee estimate.
51+
- Get the final fee amount that will be collected on deposit.
52+
3) Execute deposit
53+
- Provide fee estimate data as an argument when executing the deposit.
54+
55+
## Implementations
56+
57+
#### EVM
58+
59+
Check out the [solidity documentation](https://github.com/sygmaprotocol/sygma-solidity/blob/main/docs/Home.md) for
60+
details on EVM implementation.
61+
62+
#### Substrate
63+
64+
Check out
65+
the [substrate pallet documentation](https://github.com/sygmaprotocol/sygma-substrate-pallets/blob/main/docs/Home.md)
66+
for details on Substrate implementation.
67+
68+
69+
55.6 KB
Loading

docs/resources/fee-router-general.png

19.2 KB
Loading

docs/resources/static-fee-general.png

39 KB
Loading

docs/resources/sygma-arhitecture.png

136 KB
Loading

0 commit comments

Comments
 (0)