Type/to search
Built-in Functions
Structures
Built-in Variables and Constants
Conventions
Exchanges
Capability Matrix
Centralized Exchanges
Decentralized Exchanges (DEX)
Prediction Markets
Securities and Futures
On-chain & Custom

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

TypeDescription

object / null value

Returns {txHash, action, from, to, amount, raw} when the transaction is broadcast successfully. Returns a null value and outputs an error message when the wrapped token balance is insufficient or zero.

Arguments

NameTypeRequiredDescription

k

string

Yes

Fixed as unwrap, which means unwrapping wrapped tokens.

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 all to unwrap the entire wrapped token balance.

See Also

Remarks

Calls the withdraw(uint256) method of the wrapped token contract directly, bypassing both the swap router and the liquidity pools.