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
The source code is
src/periphery/Zap.sol on GitHub. The ABI is /abis/Zap.json.
Write methods
zapSupply
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.
Input parameters
zapRepay
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.
Input parameters
borrowTo
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.
Uses core.borrow, so LIVE and pause gates apply. Caller must set this Zap as operator.
zapWithdraw
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.
Input parameters
Events
ZappedSupply
ZappedRepay
BorrowedTo
ZappedWithdraw
Errors
ZeroAddress
token was zero with no ETH sent.