Build a USDG Treasury on Arbitrum

Part 1 of the USDG integration series: mint, redeem, automate and reconcile a business treasury on Arbitrum One with the Paxos API.

Share this article:
Build a USDG Treasury on Arbitrum

About $4 billion of stablecoins already sit on Arbitrum, pricing trades and backing loans. USDG, the Global Dollar, is the dollar the Arbitrum ecosystem has aligned around. Paxos holds the reserves behind USDG in Treasury bills, money market funds and cash, and the Global Dollar Network passes the income from those reserves to its partners based on the USDG they hold, mint and accept. Arbitrum is one of those partners, and most of Arbitrum's share is sent back into builder growth and adoption.

Paxos mints USDG natively on Arbitrum One, backed 1:1 by US dollar reserves and redeemable for US dollars, so there's no bridge in the path. A bank wire becomes USDG in your Arbitrum wallet, and USDG becomes dollars in your bank account.

This is part 1 of a four part series that walks through my USDG examples repo one integration at a time. We start with the sample business treasury, because every later part (fintech earn, a spot DEX and a perp DEX) needs USDG to get in and out first.

01-treasury-at-a-glance.png

Run the treasury before you sign up for anything

The sample is a treasury app for a fictional company, Acme Co. It's a Next.js 16 app with server routes, viem 2 for chain reads and USDG transfers, SQLite through node:sqlite, and a typed Paxos v2 client generated from the Paxos OpenAPI spec. It lives in the USDG examples repo, a pnpm monorepo with all four examples from this series.

01-treasury-dashboard.png

You can run the whole flow without an account:

git clone https://github.com/hummusonrails/arbitrum-usdg-examples
cd arbitrum-usdg-examples
pnpm install
pnpm --filter sample-business-treasury dev:mock

Mock mode starts a fresh Anvil fork of Arbitrum One, so balances and transfers use the real USDG contract at 0x004B506865409877C9fA29bfb1ebA929984B9bbC. Next to it runs a local stand in for the Paxos API that moves real USDG on the fork. A setup step prepares the wallet, the deposit address, the auto mint rule and a bank account, and the app comes up at http://127.0.0.1:3000.

The treasury policy starts paused, so you can mint and redeem by hand before you let the app make decisions on its own.

One call turns dollars into USDG

A mint is a single Paxos orchestration. It names the asset to take from your Paxos profile, the asset to deliver, and the Arbitrum wallet to deliver it to:

function mintBody(ctx: Ctx, refId: string, units: bigint) {
    return {
        ref_id: refId,
        source_asset: 'USD',
        source_amount: fromUnits(units),
        destination_asset: 'USDG',
        source: { profile: { profile_id: ctx.config.paxos.profileId } },
        destination: { crypto: { address: ctx.chain.wallet, network: 'ARBITRUM_ONE' } },
    };
}

The app sends it with paxos.createOrchestration(body), and the USDG lands in the wallet the treasury manages.

The ref_id is what makes this safe to retry. If the app crashes after sending the request but before saving the response, it sends the same request again. Paxos answers a repeated ref_id with a 409, and the app takes the existing orchestration from the error body (or lists orchestrations by ref_id) instead of minting a second time.

Let wires mint on their own

Manual mints are good for learning the flow. For regular inflows, such as customer payments and invoice settlements that arrive by wire, setup creates an orchestration rule once:

await paxos.createOrchestrationRule({
    ref_id: `treasury-auto-mint-${Date.now()}`,
    nickname: 'Auto mint USDG to the treasury wallet',
    profile_id: config.paxos.profileId,
    source_asset: 'USD',
    destination_asset: 'USDG',
    source: { fiat: { network: 'WIRE', account_type: 'ABA' } },
    destination: { crypto: { address: account.address, network: 'ARBITRUM_ONE' } },
});

Paxos returns a memo ID with the rule. Any wire that arrives carrying that memo becomes USDG in the treasury wallet, with no code of yours in the loop.

Setup also registers the wallet as a destination your business owns. It calls putCryptoDestinationAddress with travel rule details that mark the beneficiary as yourself and the custodian type as PRIVATE, then proves control of the wallet by signing the message Paxos returns from POST /v2/addresses/verifications.

The way back to the bank

Redeeming takes two steps. The wallet sends USDG on Arbitrum to your Paxos deposit address. When the deposit lands, the app creates a USDG to USD orchestration that pays your bank account:

destination: { fiat: { bank_account_id: bankId, memo: action.ref_id } },

Paxos asks who sent a deposit from a new address. The treasury wallet belongs to your business, so the app answers with your organization:

await paxos.updateCryptoDeposit(deposit.id, {
    identity_id: identityId,
    originator_address_info: {
        institution_info: { institution_name: institutionName },
    },
});

The onchain transfer needs its own retry story. If the app broadcasts a transfer and restarts before it records the result, building a fresh transfer could send the funds twice. So the app signs the Arbitrum transaction and stores it before broadcasting. After a restart it rebroadcasts that same signed transaction, and USDG never leaves the wallet twice.

A treasury that manages itself

01-treasury-policy-band.png

The sample keeps the wallet inside a band you set with POLICY_MIN, POLICY_TARGET and POLICY_MAX. The whole decision is one function:

export function decide(s: PolicyState): PolicyDecision {
    if (s.paused) return { kind: 'none', reason: 'paused' };
    if (s.stuck) return { kind: 'none', reason: 'stuck' };
    if (s.pending) return { kind: 'none', reason: 'pending' };

    const effective = s.walletUnits + s.inFlightUnits;

    if (effective < s.band.min) {
        return { kind: 'mint', amountUnits: s.band.target - effective };
    }

    if (effective > s.band.max) {
        const excess = effective - s.band.target;
        return { kind: 'redeem', amountUnits: excess < s.walletUnits ? excess : s.walletUnits };
    }

    return { kind: 'none', reason: 'in_band' };
}

Below the minimum, it mints back up to the target. Above the maximum, it redeems the excess down to the target, never more than the wallet actually holds. Inside the band, it does nothing.

The balance it checks is walletUnits + inFlightUnits, so USDG already on its way in or out counts. And the early returns mean that while any action is pending or stuck, the loop waits instead of acting twice on the same gap.

Reconcile against the chain

An orchestration starts a process. The treasury still has to find out how it ended.

Paxos webhooks carry only an event ID and a type, so the app treats each one as a hint. It records the ID, fetches the event and the current orchestration or transfer from the API, and acts on what it fetched. It also polls GET /v2/events, which means it works without a public URL and catches anything a webhook missed. Either way, each event is applied once.

Then it checks the money itself. Every mint, redeem and wire inflow becomes a ledger row. The app reads the Arbitrum receipt, decodes the USDG Transfer log with viem's parseEventLogs, and compares the recipient and amount with the Paxos transfer record:

export function reconcileRow(
    expected: { to: Address; units: bigint },
    onchain: { to: Address; value: bigint } | null,
): 'pending' | 'matched' | 'mismatch' {
    if (!onchain) return 'pending';
    return onchain.to.toLowerCase() === expected.to.toLowerCase() &&
        onchain.value === expected.units
        ? 'matched'
        : 'mismatch';
}

A row ends as matched, mismatch, stuck or failed. When something needs attention, your operators get one specific record to look at instead of a balance that doesn't add up.

From a fork to the sandbox to production

The same app runs in three places, and only the configuration changes between them:

Mock mode Paxos sandbox Production
Chain Anvil fork of Arbitrum One Arbitrum Sepolia Arbitrum One
Paxos API Local stand in Sandbox API Paxos v2 API
USDG The real contract on the fork Test USDG from the faucet USDG
What you need Nothing A sandbox account and API credentials A Paxos account and a key in a KMS

Once the flow makes sense on the fork, move to the sandbox. Create a Paxos sandbox account and API credentials, and get test USDG from the Paxos faucet. In examples/sample-business-treasury/app, copy .env.example to .env and run:

pnpm run setup
pnpm dev

To receive webhooks, point Paxos at https://<your host>/api/webhooks/paxos with the x-api-key header. Without a webhook, the app keeps polling for events.

For production, keep the treasury key in a key management service or custody provider, and put the app behind your own authentication. The code path stays the same: register the wallet, mint, follow the events, reconcile against Arbitrum.

Earn on the dollars you already hold

A treasury holds dollars because the business needs them close for payouts and fees. With USDG, that balance can earn. Global Dollar Network partners register their wallets with Paxos, which snapshots each balance daily and pays rewards in USDG, so the treasury earns in dollars it would hold anyway. 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

Next: put the treasury to work

In part 2, we take the USDG sitting in this treasury and offer it to customers through vaults on Arbitrum with the fintech earn example.

Resources

Read more