Skip to main content

DeFi

To interact with DeFi protocols utilizing shielded funds, actual smart contract calls targeting external smart contracts are routed through burner EIP-7702 smart accounts for maximum compatibilty and frictionlessness.

As common interactions with DeFi protocols can be either of stateless, e.g. swapping on Uniswap, or stateful, e.g.supplying/withdrawing liquidity to/from an Aave pool the SDK provides means to accomodate both scenarios.

Stealth Actions

Use the stealth function in combination with all of the unshield, stealth, and reshield actions for stateless interactions:

// Compose the stealth action(s)
let { payload, signer: burner } = await bermuda.stealth(
{
// A Bermuda account used to derive and fund the burner account
spender: account,
// The index of the burner account to utilize, default: 0
id,
// Optional (W)ETH amount to unshield onto the burner account
gasTank,
unshield: { token: sdk.config.WETH, amount: stealthFunds },
// The payloads returned from the stealth action handler will be
// sandwiched right here inbetween the optional un- and reshield
reshield: { token: sdk.config.WETH, amount: stealthFunds, to: spender.address() }
},
// Within this handler you can compose actions with the burner account
async burner => {
return [/*{ to, data }, { to, data }*/]
}
)

// Execute all actions through a multicall
await burner.sendTransaction(payload)

Vaults

Since ERC-4626 tokenized vaults expose shares that are ERC-20 tokens they are supported in Bermuda out-of-the-box. Just provide the vault's share token address anywhere in the SDK as token parameter.

An example depositing sUSDC:

let payload = await bermuda.deposit({
signer,
token: bermuda.config.sUSDC,
to: '0x...',
amount: 100_000_000n
})

await signer.sendTransaction(payload)