With a custodial gateway, a shutdown means your money is stuck in their wallet until someone releases it. With Stablevoy, a payment that has not reached you yet sits on a contract that can pay only your wallet, and you can move it there yourself with one public function call, using values you already have from the webhook.

This post shows where those values are, how to check them before you send anything, and the call itself, run on a local chain with its real output.

Where an unswept payment waits

On the EVM networks (Base, Arbitrum, OP Mainnet, Polygon, BNB Smart Chain, Avalanche) every invoice has its own deposit address. The buyer pays it, and Stablevoy then calls sweep on the factory contract, which forwards the balance to your payout wallet minus the fee. Most of the time a payment spends only a few minutes there.

Two cases leave money on a deposit address for longer. If the service is down, nobody calls sweep. And balances under $1 are not swept automatically, because the gas would cost more than the amount: they wait until the next payment to the same address. In both cases the funds are not lost and not in anyone's custody. The address is a contract (or will become one on the first sweep) that knows exactly two destinations: your payout wallet and a fee recipient fixed when the factory was deployed. How that address is built is covered in One deposit address per invoice with CREATE2.

Tron works differently. There the buyer pays your own wallet directly, and an invoice is matched by the exact amount. Nothing ever waits on a Stablevoy address, so there is nothing to recover.

What you need

sweep takes four arguments:

function sweep(bytes32 invoiceSalt, address merchant, uint16 feeBps, IERC20 token) external returns (address forwarder); 

Three of them come with every invoice. The API returns them when you create or fetch an invoice, and every payment webhook carries them in data.invoice:

{ "id": "3f2a1b4c-5d6e-4f70-8192-a3b4c5d6e7f8", "type": "invoice.paid", "data": { "invoice": { "feeBps": 50, "invoiceSalt": "0x8f3a1c2b4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f708192a3b4c5d6e7f8", "depositAddresses": [ { "network": "base", "address": "0x1234...abcd", "payoutAddress": "0x5678...ef01", "amountDueUsdCents": 2500 } ] } } } 
Argument Where it comes from
invoiceSalt data.invoice.invoiceSalt
merchant payoutAddress of the deposit address on that network
feeBps data.invoice.feeBps, the fee in basis points (50 is 0.5%)
token the USDC or USDT contract of that network

The factory and token addresses are public and do not change: the networks list and the API at /v1/networks give them, and they are the same contracts linked from the security page. The factory has the same address on all six EVM networks.

The one value you cannot look up anywhere else is invoiceSalt of an address that was never swept. It is 32 random bytes chosen when the invoice was made, and until the first sweep it exists only in Stablevoy's database and in what your shop received. Save invoiceSalt, feeBps and the deposit addresses with the order, the same way you save the invoice id. After the first sweep the salt is also on the chain, in the ForwarderDeployed event of the factory.

Check the values first

computeAddress is a read-only function of the same factory. It takes the first three arguments and returns the deposit address they produce. If it returns the address the buyer paid, the values are right. If it returns anything else, one of them is wrong.

Recovery in three steps: take the invoice values from a saved webhook, check them with computeAddress, then call sweep, which pays the merchant and the fee recipient

Check with a free read, then send one transaction.

A wrong value cannot send your money to someone else, but it still costs you gas: sweep with a wrong fee deploys an empty contract at some other address and forwards nothing. The check takes a second and saves that transaction.

Sweep from a block explorer

No code is needed. On the explorer of the network (BaseScan for Base, Arbiscan for Arbitrum and so on):

  1. Open the factory address and the Contract tab. The source is verified, so the explorer shows its functions.
  2. Under Read Contract, call computeAddress with the salt, your payout address and the fee. Compare the result with the deposit address.
  3. Under Write Contract, connect any wallet that has a little of the network's coin for gas, and call sweep with the same three values and the token address.

The transaction can come from your payout wallet, from another wallet of yours, or from anyone you ask to help. The caller pays the gas and has no say in where the tokens go.

The same steps from a terminal

With Foundry's cast the whole recovery is two commands. The values below are placeholders, take yours from the webhook:

RPC=https://mainnet.base.org FACTORY=0xf470c701b0338069bc9e84352f7c44ee9d207e0e USDC=0x833589fcd6edb6e08f4c7c32d4f71b54bda02913 SALT=0x... # data.invoice.invoiceSalt PAYOUT=0x... # payoutAddress of the Base deposit address FEE_BPS=50 # data.invoice.feeBps cast call $FACTORY 'computeAddress(bytes32,address,uint16)(address)' $SALT $PAYOUT $FEE_BPS --rpc-url $RPC cast send $FACTORY 'sweep(bytes32,address,uint16,address)' $SALT $PAYOUT $FEE_BPS $USDC --rpc-url $RPC --interactive 

To see it work without real money, the same contracts run on a local Anvil chain. A buyer pays 25 USDC to an invoice address that has no code yet, the gateway never sweeps it, and the merchant does it alone. Then 0.40 USDC more arrives late on the same address, the kind of balance that is never swept automatically, and the same call forwards it too:

deposit address 0x5585c7611cb259576736DfE5e8b7777DD14184FE holds 25.000000 USDC, code size 0 bytes computeAddress, fee 50: 0x5585c7611cb259576736DfE5e8b7777DD14184FE computeAddress, fee 100: 0xf23F5b2E5d9557d9a41ebc706eCf33E999d7Fb96 after sweep: merchant 24.875000, fee recipient 0.125000, deposit address 0.000000 after a late 0.40 and a second sweep: merchant 25.273000, fee recipient 0.127000, deposit address 0.000000 

The second line is the check passing. The third shows what a wrong fee gives: a different address, which is why the check comes first. The fee is rounded down, so on the late 0.40 the fee recipient got 0.002 and the merchant the rest.

Why nobody can redirect the funds

The destinations are not arguments the caller controls. The deposit address is derived from the salt, the payout address and the fee together, so the only way to reach the contract that holds your payment is to pass your own payout address. Any other address leads to a different, empty contract. The fee recipient is an immutable value of the factory, and the factory refuses a fee above its cap of 2%.

The contracts have no owner, no upgrade function and no pause. Stablevoy has no key that can stop a sweep or change where it pays, which is also why this recovery works when Stablevoy is not there.

The recovery guide has the same steps in short form, and the webhooks docs list every field an invoice event carries.

Questions

What happens to my money if a crypto payment gateway shuts down?

It depends on custody. A custodial gateway holds your balance in its own wallet, so you wait for whoever controls it. With a non-custodial one like Stablevoy, paid funds are already in your wallet or on a contract that can pay only your wallet, and you can call it yourself.

Do I need Stablevoy's API to recover a payment?

No. You need the invoice salt, the fee and your payout address from your saved invoice data or webhooks, and any wallet with gas on that network.

Can someone else sweep my deposit address?

Yes, and it is safe. Anyone can call sweep, but the tokens can only go to your payout wallet and the fixed fee recipient. A stranger who calls it pays the gas and receives nothing.

What about payments on Tron?

They need no recovery. On Tron the buyer pays your wallet directly, so the money never waits on a Stablevoy address.