exchange.IO("unwrap", ...)
Unwraps the wrapped token (such as WETH or WBNB) into the native coin (such as ETH or BNB), 1:1 without slippage, costing only gas.
exchange.IO(k, amount)Examples
Unwrap all WETH into ETH.
javascript
function main() {
var r = exchange.IO("unwrap", "all")
if (!r) {
Log("unwrap failed:", GetLastError())
return
}
var rc = exchange.IO("receipt", r.txHash, 120000)
Log(r.from, "→", r.to, r.amount, "status:", rc.status)
}Returns
| Type | Description |
object / null value | Returns |
Arguments
| Name | Type | Required | Description |
k | string | Yes | Fixed as |
amount | string / number | Yes | The amount of wrapped tokens to unwrap, in human-readable units. Passing it as a string is recommended. Set it to |
See Also
Uniswap / PancakeSwap Aerodrome / Velodrome KyberSwap 1inch exchange.IO exchange.IO("wrap") exchange.IO("receipt") exchange.IO("transfer")
Remarks
Calls the withdraw(uint256) method of the wrapped token contract directly, bypassing both the swap router and the liquidity pools.