PositionRouter lets you:
- Supply collateral and borrow USDG in one transaction, with an optional permit
- Repay and withdraw in one transaction, using max sentinels for full close
- Sell collateral and repay debt atomically
The source code is
src/periphery/PositionRouter.sol on GitHub. The ABI is /abis/PositionRouter.json.
Write methods
openPosition
supplyAmount collateral from the caller, supplies it to the caller’s account, and borrows borrowAmount USDG to the caller if non-zero. Reverts with ZeroAmount for a zero supply. Borrow reverts follow Stockline rules (LIVE, unpaused, caps, LTV).
Input parameters
closePosition
repayAmount USDG from the caller and repays their book, then withdraws withdrawAmount collateral to them. Passing the maximum uint256 for either value uses the full debt or full collateral. Reverts with ZeroAmount when both are 0.
Input parameters
deleverage
Stockline.deleverage with this router as callee. The router sells amount of fromBook collateral for USDG along the token’s zap route and the proceeds repay repayBook. Leftover collateral and USDG return to the caller. Works in every regime and while paused because it only reduces risk.
Input parameters
onDeleverage
deleverage. Sells the received collateral for USDG along its zap route, sends the USDG back to Stockline, and returns any collateral dust to the account. Reverts with NotCore for any other caller and InvalidRoute if the token has no allowed route ending in USDG.
Input parameters