When inputAmount is set to 0 then the senders' full balance will be sent. This can be used to fully swap tokens that rebase.
Do not modify the calldata provided by the swap endpoint. It could lead to loss of funds. The calldata provided should allow direct execution on-chain.
The structure of the data returned is:
Name
Type
Description
amountOut
uint256
Actual outputToken amount received from swap
The swapTokenInfo struct looks like:
Name
Type
Description
inputToken
address
Token starting the swap, the native token (BERA) is 0x0000000000000000000000000000000000000000
inputAmount
uint256
Amount of inputToken to swap
outputToken
address
Token returning from swap, the native token (BERA) is 0x0000000000000000000000000000000000000000
outputQuote
uint256
Expected amount returned
outputMin
uint256
Minimum amount returned derived from slippage and quote
outputReceiver
address
The destination address to receive output tokens
Events
An event is emitted from any swaps carried out on OBRouter:
The structure of the data within the event emitted looks like this:
Name
Type
Description
sender
address
Address that called the swap
inputAmount
uint256
Amount of inputTokens used
inputToken
address
Token that started the swap. The native token (BERA) is 0x0000000000000000000000000000000000000000
amountOut
uint256
Actual amountOut transferred after potential fees
outputToken
address
Token that returned from the swap. The native token (BERA) is 0x0000000000000000000000000000000000000000
slippage
int256
The difference between the expected outputQuote and actual amountOut returned (slippage = amountOut - outputQuote). When < 0 means negative slippage (swap returned less than expected) and > 0 positive slippage (swap returned more than expected)
referralCode
uint32
Used to identify the source of the swap
Errors
These are the errors that can occur:
Selector
Signature
Description
0x71c4efed
SlippageExceeded(uint256,uint256)
amountOut resulted lower than outputMin during swap execution
0xfa463c69
SameTokenInAndOut(address)
Cannot provide same inputToken and outputToken
0x6da58071
MinimumOutputGreaterThanQuote(uint256,uint256)
outputMin is set greater than outputQuote
0xf067d762
MinimumOutputIsZero()
outputMin is set to 0
0xdb4d141c
NativeDepositValueMismatch(uint256,uint256)
value provided to function call does not match amountIn provided when inputToken is the native token
0x9996b315
AddressEmptyCode(address)
Calling a contract that has no bytecode
0xcd786059
AddressInsufficientBalance(address)
Attempting to send native token with insufficient balance
0xd93c0665
EnforcedPause()
Function can only be called when the contract is unpaused
0x8dfc202b
ExpectedPause()
Function can only be called when the contract is paused
0x1425ea42
FailedInnerCall()
A call to an address target failed. The target may have reverted.