# System Design

Lucidly Yields is built on the [boring-vault](https://github.com/veda-Labs/boring-vault/) architecture built and pioneered by Veda Labs.

* Users can mint `syAssets` in a single atomic transaction using whitelisted tokens. Withdrawals are asynchronous and take 6-24 hours to process in the current production setup.
* Underlying deposits are allocated to select strategies by strategist roles and are segregated by risk and liquidity profiles, i.e., a strategist whitelisted to `supply`/`withdraw` USDC from AaveV3 can only do that and nothing else.
* `syAssets` are deployed on multiple networks and can use generic interop protocols - ccip, layerzero, wormhole etc.

The protocol stack consists of 2 components -&#x20;

* onchain - The smart contracts powering syTokens are built on the [boring-vault](https://github.com/veda-Labs/boring-vault/) architecture built and pioneered by Veda Labs.
* offchain - Asset management and relayer services for transaction creation and handling used to interact with the smart contract layer.

#### Onchain Stack

<div align="left" data-full-width="false"><figure><img src="https://1619664631-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy4OOeM9ay0aw5V7glPG%2Fuploads%2F8etFJ3HC02p6Hh7iIsqo%2FScreenshot%202025-10-23%20at%204.53.43%E2%80%AFPM.png?alt=media&#x26;token=5a166a49-187c-4162-8f56-aef603674b28" alt=""><figcaption></figcaption></figure></div>

#### Flow of funds

<figure><img src="https://1619664631-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy4OOeM9ay0aw5V7glPG%2Fuploads%2FYPccIvFp6MrIqFwEwDaM%2FScreenshot%202025-10-23%20at%204.55.41%E2%80%AFPM.png?alt=media&#x26;token=599b9b45-cc02-4133-89af-c5d7cb9e17c1" alt=""><figcaption><p>deposit flow</p></figcaption></figure>

<figure><img src="https://1619664631-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy4OOeM9ay0aw5V7glPG%2Fuploads%2FxnFxjwa9RlAAe0SHB0rb%2FScreenshot%202025-10-23%20at%204.56.04%E2%80%AFPM.png?alt=media&#x26;token=b1cb0e14-5c76-471e-b9b0-703a3045a80f" alt=""><figcaption><p>allocation flow</p></figcaption></figure>

<figure><img src="https://1619664631-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy4OOeM9ay0aw5V7glPG%2Fuploads%2FFeDNKUkXeR0FUGrLmWsc%2FScreenshot%202025-10-23%20at%204.56.22%E2%80%AFPM.png?alt=media&#x26;token=51004cc1-ebc3-4fe5-a538-7e11572b4fe1" alt=""><figcaption><p>redemption flow</p></figcaption></figure>

#### Offchain stack&#x20;

* **AUM service** - Handles accounting for global assets and liabilities using oracles and updates `exchangeRate` on the `Accountant` smart contract.
* **Solver service** - Monitors pending withdrawal requests on the `Queue` smart contract and processes them.
* **Manager service** - The core and the most important part of the stack, is used to create transactions based on offchain algorithms and restricted calldata, prepares merkle proofs and interacts with the `Manager` smart contract.

{% code title="example\_manager\_script.py" %}

```python
for leaf in all_leafs:
    if (leaf.target.lower() == from_token.lower()
        and leaf.signature == "approve(address,uint256)"
        and leaf.argument_addresses[0].lower() == swap_tx["to"].lower()):
        approve_leaf = leaf

    elif (leaf.signature == "swapCompact()"
          and leaf.argument_addresses[1].lower() == to_token.lower()
          and leaf.argument_addresses[2].lower() == self.boring_vault_address.lower()
          and leaf.argument_addresses[3].lower() == odos_executor.lower()):
        swap_leaf = leaf

if not approve_leaf or not swap_leaf:
    raise ValueError("Valid leafs not found in Merkle tree.")

proofs = _get_proofs_using_tree([approve_leaf, swap_leaf], tree)

tx = await self.manager.functions.manageVaultWithMerkleVerification(
    proofs,
    [self.sanitizer_address] * 2,
    [from_token, swap_tx["to"]],
    [self.encode_approve(swap_tx["to"], 2**256 - 1), swap_tx["data"]],
    [0, 0]
).build_transaction({
    "from": self.account.address,
    "nonce": await self.w3.eth.get_transaction_count(self.account.address),
})
```

{% endcode %}

A `sanitizer` parameter is used when creating transactions that restricts addresses included in calldata based on an ADMIN\_ROLE set preset.

Github link - <https://github.com/lucidlylabs/boring-vault>

We welcome new strategists to ideate on novel onchain yield strategies, DM us on X or send an email to <hello@lucidly.finance> for support.
