DeFi Engine

How our integrations leverage Bundlers and Paymasters.

Overview

One of the main advantages to using Rainmaker is our bundled, sponsored transactions to make DeFi simple. In this section we'll dive into how deposits and withdrawals work for specific strategies and the status of our integrations.

Transacting on Rainmaker

#1 Paymasters

Before we go into bundling we must review how paymaster work and how Rainmaker leverages them to sponsor gas for users.

Paymasters are smart contracts that enable flexible gas policies like allowing decentralized applications to sponsor operations for their users (i.e.pay gas fees in the blockchain’s native currency), or accept gas fee payments in an ERC-20 token (e.g. USDC) in place of the blockchain’s native currency.

Whenever a user transacts on Rainmaker they DO NOT have to pay gas, because we sponsor the transactions they send.

#2 Bundling

If you've used Rainmaker you're probably aware that you can enter any strategy in a single tap, where using a traditional wallet like MetaMask may take several transaction signings across multiple apps. Let's look at how this works for deposits and withdrawals into strategies

One great advantage of smart contract wallets is the ability to execute transactions in batches. That is, you can execute multiple transactions as if it's a single transaction, so you get to save on confirmation time and gas costs. It's also safer because these transactions either all execute or all revert, no in-between, which is a property known as "atomicity."

How does bundling work?

Simply put bundling takes several transactions and commits them onchain atomically. If you're familiar with multicall, this is the same concept. If you're not, please read this paper for more detail.

First an example

To illustrate the power of this, let's take leverage a simple example of depositing into Stargate's USDC bridge liquidity pool given that you have DOGE.

First, without using Rainmaker.

  1. Top up wallet with gas token on the given network by swapping or from CEX.

  2. Search for the cheapest DEX / aggregator and approve the DOGE swap.

  3. Convert DOGE to USDC.

  4. Head to the Stargate "Pool" tab, choose your network and approve adding USDC.

  5. Submit the "add" USDC (for S*USDC LP Token).

  6. Head to the farming tab and approve deposit of your LP Token.

  7. Submit the "deposit" of the LP token in the farm.

Now with Rainmaker we can consolidate and even skip steps. Note that we don't need to get any gas as our paymasters will take care of transaction costs.

  1. Go to the Stargate integration screen and select DOGE as the deposit token + amount.

  2. Click Deposit.

Much simpler.

So what's actually going on here?

In the first example there are 6 transactions happening. In the second there is only a single transaction. But how?

When you tell Raimaker that you want to deposit X,XXX DOGE into Stargate we can generate the entire list of transactions that are needed to do the above step WITHOUT actually executing them. We do this by assembling un-signed "calls". We then take these calls and send them to the bundler which executes a multi-call function and this is what atomically writes them on-chain as one transaction.

If you're curious a list of calls looks like this:

[
    {
        to: "0x1234...", // where the txn is going
        data: "0x...", // the unsigned txn data let's say "approve DOGE spend"
        value: "0" // depends on if this is payable or not
    },
    {
        to: "0x1234...",
        data: "0x...", // let's say "swap DOGE for USDC"
        value: "0"
    }
]

All Rainmaker native integrations leverage this to drastically simplify the user experience.

Want to learn more? Join our Discord and follow us on Twitter (X)! We love to chat.

Last updated