> ## Content Index
> Fetch the complete content index at: https://blog.arbitrum.foundation/llms.txt
> Use this file to discover other available public pages before exploring further.

# Build a USDG Earn App on Arbitrum
- URL: https://blog.arbitrum.foundation/build-a-usdg-earn-app-on-arbitrum/
- Published: 2026-12-01T08:33:08.000Z
- Updated: 2026-12-01T08:33:08.000Z
- Description: Part 2 of the USDG integration series: offer USDG vaults on Arbitrum One to your customers, keep a ledger that matches the chain, and share ARB incentives fairly.
- Author: Ben Greenberg
- Tags: USDG, Arbitrum One, Tutorial, Stablecoins

Fintech apps already hold customer dollars for payments, transfers and everyday spending. With USDG on Arbitrum, those dollars can also earn in vaults run by third parties, while the app keeps the customer relationship and the books.

In [part 1](https://blog.arbitrum.foundation/build-a-usdg-treasury-on-arbitrum/), we built a business treasury that moves dollars in and out of USDG with Paxos. This time, we take that USDG and offer it to customers with the [sample fintech earn](https://github.com/hummusonrails/arbitrum-usdg-examples/tree/main/examples/sample-fintech-earn?ref=blog.arbitrum.foundation) app from my [USDG examples repo](https://github.com/hummusonrails/arbitrum-usdg-examples?ref=blog.arbitrum.foundation). Parts 3 and 4 build a spot DEX and a perp DEX.

![02-earn-at-a-glance.png](https://storage.ghost.io/c/d4/cc/d4cc8040-691e-4dd2-8282-0c08d45fc5a8/content/images/2026/11/02-earn-at-a-glance.png)

## Run the earn app before you sign up for anything

The sample is a simulated fintech app for a fictional company, Acme Money. It's built with Next.js 16, viem 2 and SQLite. Customers supply USDG to vaults on Arbitrum One, and Acme Money tracks which shares belong to whom.

![02-earn-app.png](https://storage.ghost.io/c/d4/cc/d4cc8040-691e-4dd2-8282-0c08d45fc5a8/content/images/2026/11/02-earn-app.png)

You can run the whole flow without an account or funds:

```bash
git clone https://github.com/hummusonrails/arbitrum-usdg-examples
cd arbitrum-usdg-examples
pnpm install
pnpm --filter sample-fintech-earn dev:fork

```

Fork mode starts a fresh Anvil fork of Arbitrum One, so every deposit and withdrawal runs against the real vault contracts. The app opens at `http://127.0.0.1:3000`, with a customer's phone next to Acme Money's operator console. Add demo USDG to a customer, choose a vault and deposit. The ledger updates once the transaction confirms.

Next to the app, a local GMX keeper executes requests with live signed prices from GMX's public API, as GMX's keepers do on mainnet. A local stand in for Merkl accrues simulated ARB rewards and posts real reward roots to the real Merkl Distributor contract on the fork. Vault rates, boosts and liquidity are read live from Arbitrum One, and every rewards figure in fork mode is labeled as simulated.

The app offers the three USDG vaults on Arbitrum One that [DRIP](https://arbitrumdrip.com/opportunities?ref=blog.arbitrum.foundation), Arbitrum's DeFi Renaissance Incentive Program, incentivizes:

| Vault                                                                                                                                  | How it settles                                      |
| -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| [Steakhouse USDG Pro](https://arbiscan.io/address/0xbeeFf72B77e7584a450E887125F25E8D8819016a?ref=blog.arbitrum.foundation) on Morpho   | In the same transaction (ERC-4626)                  |
| [Gauntlet USDG Premium](https://arbiscan.io/address/0x390c1bb01F3F627144a40617e287d4cE3D5aBCfa?ref=blog.arbitrum.foundation) on Morpho | In the same transaction (ERC-4626)                  |
| [GMX Dollar Vault](https://arbiscan.io/address/0x4Cd5A94a30876320ac65F2e192493EE476f13866?ref=blog.arbitrum.foundation) on GMX         | A request a GMX keeper executes a few seconds later |

## One wallet holds the shares

Acme Money uses an omnibus wallet: one wallet holds the vault shares for all customers, and Acme Money's ledger records each customer's part. Custodial apps already treat customer balances this way.

The other option is a wallet per customer, for example through an embedded wallet provider. Then the chain is the ledger and Merkl credits rewards to each customer directly. Customers sign their own deposits, and since USDG supports EIP-2612 permits, a deposit can be one signature and one transaction. Pick the one that matches who holds custody in your product today.

## One adapter covers three vaults

The two Morpho vaults settle in the same transaction. GMX creates a request that a keeper executes later. The app gives both paths one interface in `src/server/vaults/types.ts`:

```typescript
export interface VaultAdapter {
    config: VaultConfig;
    readState(): Promise<VaultChainState>;
    sharesForAssets(assets: bigint): Promise<bigint>;
    assetsForShares(shares: bigint): Promise<bigint>;
    preflight(
        kind: 'deposit' | 'withdraw',
        assets: bigint,
        instantLiquidity?: bigint | null,
    ): Promise<Preflight>;
    deposit(assets: bigint, onSent?: (txHash: Hex) => void): Promise<Submitted>;
    withdraw(shares: bigint, onSent?: (txHash: Hex) => void): Promise<Submitted>;
    settle(sub: Submitted): Promise<Settlement | null>;
    cancel?(sub: Submitted): Promise<void>;
}

```

A deposit returns either a settled result or a pending request. `settle` reads the exact shares the vault minted or burned from the chain, and returns `null` while a request is still pending. `onSent` hands the app the transaction hash as soon as it's broadcast, so the hash is recorded before the app waits for the result.

## Morpho withdrawals depend on liquidity

Morpho Vault V2 is ERC-4626 with a few differences. Its shares have 18 decimals and are worth more than one USDG each, so the app converts with `previewWithdraw` and `previewRedeem`.

`maxDeposit` and `maxWithdraw` always return zero by design, so the app reads withdrawable liquidity from the Morpho API instead. A withdrawal larger than the vault's idle funds plus its liquidity market reverts, so `src/server/vaults/erc4626.ts` checks the amount first:

```typescript
// Morpho Vault V2 pays withdrawals only from idle funds and its
// liquidity market. Anything larger reverts.
if (instantLiquidity != null && assets > instantLiquidity) {
    return {
        ok: false,
        reason: `Only ${usdg(instantLiquidity)} can be withdrawn from this vault right now.`,
        maxNow: instantLiquidity,
    };
}

```

The customer sees how much can come out now, before anything is sent. The same preflight checks that USDG transfers aren't paused and the omnibus wallet isn't frozen.

Gates can switch on at any time, so the adapter reads `canReceiveShares`, `canSendAssets`, `canSendShares` and `canReceiveAssets` before every action. It keeps one standing USDG approval per vault, so a deposit is a single `deposit(assets, omnibus)` call, and a withdrawal is `redeem(shares, omnibus, omnibus)`. The ledger takes the exact shares from the vault's own `Deposit` or `Withdraw` event, decoded from the receipt with viem's `parseEventLogs`.

## GMX deposits wait for a keeper

The GMX Dollar Vault is a GLV, not an ERC-4626 vault. A deposit creates a request, and a keeper executes it with signed oracle prices. The app sends the keeper fee, the USDG and the request in one `GlvRouter.multicall`:

```typescript
const hash = await send(chain, {
    address: GMX.glvRouter,
    abi: glvRouterAbi,
    functionName: 'multicall',
    args: [
        [
            encodeFunctionData({
                abi: glvRouterAbi,
                functionName: 'sendWnt',
                args: [GMX.glvVault, fee],
            }),
            encodeFunctionData({
                abi: glvRouterAbi,
                functionName: 'sendTokens',
                args: [token, GMX.glvVault, amount],
            }),
            create,
        ],
    ],
    value: fee,
});

```

The `create` call is `createGlvDeposit`, with `minGlvTokens` set from the quoted share price less slippage. GMX reports how the request ended through its EventEmitter: `GlvDepositExecuted` carries `receivedGlvTokens`, and `GlvDepositCancelled` carries a reason.

The action stays pending until one of those events arrives, so the customer's balance never changes before the vault does. A cancelled request returns the funds, and the app shows GMX's reason. If a request is still pending after five minutes, GMX lets the app cancel it.

## A deposit settles once

A deposit takes time to land, and the customer's USDG can't be spendable twice in the meantime. In `src/server/money.ts`, the app reserves it in the same database transaction that records the action. The app releases the reservation only if nothing was sent.

On a withdrawal, the shares stay on the customer's books until it executes. Only a pending action can settle, so applying the same settlement twice changes nothing. Customer actions run one at a time, so every change in shares belongs to exactly one customer.

Pending actions are stored and checked on every loop pass and at startup. If a GMX keeper finishes a request while the app is down, the app settles it once when it comes back.

## Rates and boosts stay separate

Each vault shows its own rate and any live DRIP boost as two figures, never one blended number. The Morpho rate is `netApyExcludingRewards` from the Morpho API, and GMX supplies the GLV APY. The boost comes from the live Merkl campaign, with its reward token and end date. When no campaign is live, the vault shows its own rate.

On the Morpho vaults, the boost is ARB that the holder of the vault shares claims from Merkl. On the GMX vault, the boost raises the GLV token price, so there's nothing to claim.

Before their first deposit into each vault, customers accept what they're agreeing to: rates are variable, boosts are temporary third party incentives, the vault is run by a third party rather than Acme Money, withdrawals can be delayed when a vault lacks liquidity, and they can lose money. Morpho screens say "Powered by Morpho", and the GMX disclosure explains that GLV's value moves with traders' profits and losses.

## Share ARB by time in the vault

Merkl credits the Morpho boost to the omnibus wallet. When the operator claims, the app splits the newly claimed ARB across vaults using Merkl's per vault breakdown. Then it splits each vault's part across customers by **share-seconds**: shares held multiplied by time held, from the ledger's share history.

![02-reward-sharing.png](https://storage.ghost.io/c/d4/cc/d4cc8040-691e-4dd2-8282-0c08d45fc5a8/content/images/2026/11/02-reward-sharing.png)

The core of `src/server/rewards.ts` divides each vault's pot by those weights:

```typescript
const total = [...weights.values()].reduce((s, w) => s + w, 0n);
let given = 0n;

if (total > 0n) {
    for (const [customerId, weight] of weights) {
        const amount = (pot * weight) / total;

        if (amount > 0n) {
            allocations.push({ customerId, vaultId, amount });
            given += amount;
        }
    }
}

carry[vaultId] = pot - given;

```

Integer division rounds each customer's part down. What's left carries into that vault's next claim, so no ARB is ever handed out twice.

## Reconcile the books against the chain

Every pass, the operator console checks three rules and shows the ledger and onchain numbers side by side:

1. For each vault, the customers' shares in the ledger add up to the omnibus wallet's shares onchain.
2. The omnibus wallet holds at least the USDG the ledger owes customers, counting USDG reserved for deposits in flight.
3. ARB shared with customers never exceeds ARB claimed, and the wallet still holds it.

The USDG check in `src/server/reconcile.ts` compares what the wallet holds with what the ledger owes:

```typescript
checks.push({
    rule: 'usdg',
    ledger: owed,
    onchain: input.usdg.onchain,
    status: input.usdg.onchain >= owed ? 'matched' : 'drift',
});

```

USDG above what's owed is unassigned, and the operator can assign it to a customer. Each check ends as matched or drift, so when something is off, your operators know which rule broke and by how much.

## From a fork to Arbitrum One

The same app runs on the fork and on Arbitrum One:

|               | Fork mode                                             | Arbitrum One                                            |
| ------------- | ----------------------------------------------------- | ------------------------------------------------------- |
| Chain         | Anvil fork of Arbitrum One                            | Arbitrum One                                            |
| Vaults        | The real vault contracts on the fork                  | The same vaults                                         |
| GMX requests  | A local keeper with live signed prices                | GMX's keepers                                           |
| ARB rewards   | A local Merkl stand in posting real roots (simulated) | The Merkl API                                           |
| What you need | Nothing                                               | A funded omnibus wallet, ETH for gas and a key in a KMS |

In `examples/sample-fintech-earn`, copy `app/.env.example` to `app/.env`, set `OMNIBUS_PRIVATE_KEY` and `RPC_URL`, then run:

```bash
pnpm --filter sample-fintech-earn build
pnpm --filter sample-fintech-earn start

```

Send USDG to the omnibus wallet, then use **Assign** in the console to credit it to a customer. The [business treasury from part 1](https://blog.arbitrum.foundation/build-a-usdg-treasury-on-arbitrum/) shows how to mint that USDG from dollars with Paxos. The omnibus wallet also needs a little ETH for gas and GMX keeper fees.

For production, keep the omnibus key in a key management service or custody provider, put the app behind your own authentication and customer onboarding, and read the vault and DRIP terms before offering them to customers.

## Earn on the dollars you already hold

A fintech holds customer dollars because customers need them close for payments and transfers. With USDG, those balances can earn in vaults on Arbitrum. If you're building a stablecoin product on top of this, such as lending, yield, an AMM or payments, the Arbitrum Stablecoin Growth Program adds performance based incentives from the Arbitrum Foundation.

The first 10 teams to reach $10 million in TVL share 2 million ARB in prizes, and approved teams get access to perks and programs across the ecosystem.

Applying takes a few minutes, and the Arbitrum Foundation team works directly with each approved team on next steps.

[Apply to the Arbitrum Stablecoin Growth Program](https://arbitrum.io/products/usdg-on-arbitrum?ref=blog.arbitrum.foundation#contact-form)

## Next: trade against USDG

In part 3, we use USDG as the quote asset for swaps on Arbitrum with the spot DEX example.

## Resources

- [USDG examples repo](https://github.com/hummusonrails/arbitrum-usdg-examples?ref=blog.arbitrum.foundation)
- [Sample fintech earn](https://github.com/hummusonrails/arbitrum-usdg-examples/tree/main/examples/sample-fintech-earn?ref=blog.arbitrum.foundation)
- [Part 1: Build a USDG Treasury on Arbitrum](https://blog.arbitrum.foundation/build-a-usdg-treasury-on-arbitrum/)
- [Morpho Vault V2 docs](https://docs.morpho.org/learn/concepts/vault-v2/?ref=blog.arbitrum.foundation)
- [GMX GLV docs](https://docs.gmx.io/docs/providing-liquidity/?ref=blog.arbitrum.foundation#glv-pools)
- [DRIP opportunities](https://arbitrumdrip.com/opportunities?ref=blog.arbitrum.foundation)
- [USDG on Arbitrum](https://arbitrum.io/products/usdg-on-arbitrum?ref=blog.arbitrum.foundation)
- [Arbitrum builder newsletter](https://blog.arbitrum.foundation/#/portal/signup?utm%5Fsource=arbitrum-blog&utm%5Fmedium=blog&utm%5Fcampaign=devrel-content-enterprise-on-arbitrum&utm%5Fcontent=devrel-blog-post)