|
| 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 | + |
| 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 | + |
| 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 | + |
| 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 | + |
0 commit comments