exchange.IO("wrap", ...)
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
| Type | Description |
object / null value | Returns |
Arguments
| Name | Type | Required | Description |
k | string | Yes | Fixed as |
amount | string / number | Yes | The amount of native coin to wrap, in human-readable units. Passing it as a string is recommended, for example |
See Also
Uniswap / PancakeSwap Aerodrome / Velodrome KyberSwap 1inch exchange.IO exchange.IO("unwrap") exchange.IO("receipt") exchange.IO("transfer")
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", ...).