Skip to content

Commit

Permalink
Merge pull request #106 from balancer/router-tech
Browse files Browse the repository at this point in the history
Router technical page
  • Loading branch information
danielmkm authored Jul 1, 2024
2 parents 122843b + 5197e7c commit bc40943
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/concepts/router/technical.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The Router and Vault interact in a back and forth manner to achieve the intended

Every user interaction going through the Router follows the same pattern of execution flow. The elegance of `unlock` wrapping the transaction in a Vault context is further explained in the [transient accounting](../vault/transient-accounting.md) section

1. The Router calls `unlock` on the Vault, allowing access to protected state-changing functions that perform token [accounting](../vault/transient-accounting.md) by triggering the `transient` modifier. You can think of this step as the Router opening a tab with the Vault and any operation on the Vault will attribute to that tab.
2. The Router executes a hook function (ie: `swapSingleTokenHook`) which calls the Vault's primitives (ie: `swap`). These operations add debt or credit tab the Vault manages.
3. To finalize the user operation, the outstanding debts & credits need to be settled, which was accrued during `swap`. In the case of the Balancer Router, the Router is the account settling the debt. If debt & credit is not settled, the transaction will revert. This step closes out the tab opened with the Vault in step 1.
1. The Router calls `unlock` on the Vault, allowing access to protected state-changing functions that perform token [accounting](../vault/transient-accounting.md) by triggering the `transient` modifier. You can think of this step as the Router opening a tab with the Vault, after which any debts or credits from subsequent Vault operations accrue to that tab.
2. The Router executes a hook function (ie: `swapSingleTokenHook`) which calls the Vault's primitives (ie: `swap`). These operations incur debt or supply credit to the currently open tab.
3. To finalize the user operation, all outstanding debts and credits accrued during `swap` need to be settled. If the tab is not settled, the transaction will revert. This settlement step (i.e., when `unlock` returns and executes the rest of the `transient` modifier) closes out the tab opened with the Vault in step 1.

0 comments on commit bc40943

Please sign in to comment.