Skip to main content
Zap converts between USDG and allowlisted assets (USDC, USDT, ETH at launch) around the core. It lets suppliers deposit and withdraw in the asset they hold, and lets borrowers repay or receive loans in that asset. Routes and slippage caps come from RiskRegistry, swaps run through the shared DEX router, and every leftover balance returns to the caller. The core only ever sees USDG. Zap lets you:
  • Deposit any allowlisted token or ETH into the pool and receive sUSDG
  • Repay a book with any allowlisted token or ETH
  • Borrow USDG and receive it as another token or ETH
  • Withdraw sUSDG and receive another token or ETH
Addresses per network. Every address is also on Addresses. The source code is src/periphery/Zap.sol on GitHub. The ABI is /abis/Zap.json.

Write methods

zapSupply

Converts amountIn of token (or the ETH sent as msg.value) to USDG and deposits it into USDGPool for the caller. USDG passes through without a swap. Reverts with ZeroAddress if token is zero and no ETH was sent, ZeroAmount for a zero input, and InvalidRoute if the token is not allowlisted.
For ERC-20 input the caller must approve Zap for amountIn. Slippage is capped by the token’s registry route against the router quote.
Input parameters

zapRepay

Converts amountIn of token (or ETH) to USDG and repays the caller’s debt in bookId. Always live, like Stockline.repay. Excess USDG beyond the debt returns to the caller.
For ERC-20 input the caller must approve Zap for amountIn.
Input parameters

borrowTo

Borrows usdgAmount USDG on the caller’s account, swaps it to token, and sends the output to the caller. The zero address or WETH delivers native ETH; USDG is sent as is. Follows Stockline borrow rules: LIVE, unpaused, caps, and LTV. Reverts with ZeroAmount for a zero amount.
The caller must first set Zap as operator with Stockline.setOperator, because Zap borrows on their behalf.
Uses core.borrow, so LIVE and pause gates apply. Caller must set this Zap as operator.
Input parameters

zapWithdraw

Withdraws usdgAmount USDG from the caller’s sUSDG, swaps it to token, and sends the output to the caller. Subject to pool cash limits and the guardian pause through USDGPool.maxWithdraw.
The caller must approve Zap for the sUSDG shares that the withdrawal burns.
Input parameters

Events

ZappedSupply

Fires after a zapSupply, with the input and the USDG deposited.

ZappedRepay

Fires after a zapRepay, with the USDG applied to the book.

BorrowedTo

Fires after a borrowTo, with the USDG borrowed and the tokens delivered.

ZappedWithdraw

Fires after a zapWithdraw, with the USDG withdrawn and the tokens delivered.

Errors

ZeroAddress

The constructor addresses were zero, or token was zero with no ETH sent.

ZeroAmount

The input amount was zero, or an ETH transfer to the caller failed.

InvalidRoute

The token is not allowlisted or its route does not connect to USDG.