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

Wraps the native coin (such as ETH or BNB) into its wrapped token (such as WETH or WBNB), 1:1 without slippage, costing only gas.

exchange.IO(k, amount)

Examples

Wrap 0.01 ETH into WETH.

javascript
function main() { var r = exchange.IO("wrap", "0.01") if (!r) { Log("wrap 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. from and to are the names of the currency before and after the conversion. The call waits only for the transaction to be broadcast, not for it to be confirmed on-chain; use exchange.IO("receipt", ...) to check the on-chain result. Returns a null value and reports an error in cases such as insufficient balance.

Arguments

NameTypeRequiredDescription

k

string

Yes

Fixed as wrap, which means wrapping the native coin.

amount

string / number

Yes

The amount of native coin to wrap, in human-readable units. Passing it as a string is recommended, for example "0.01". all is not supported, because some native coin must be kept to pay for gas.

See Also

Remarks

Calls the deposit() method of the wrapped token contract directly, without going through the swap router or liquidity pools. Orders cannot be placed on trading pairs such as ETH_WETH. To convert between the native coin and the wrapped token, use exchange.IO("wrap", ...) and exchange.IO("unwrap", ...).