# Smart Wallet

The source code can be found at [SmartWallet.sol](https://github.com/perpfutui/perpetual-limit-orders/blob/main/contracts/SmartWallet.sol)

## Functions

### executeCall

```javascript
function executeCall(
    address target,
    bytes calldata callData
  )
```

**(Advanced)** This function allows smart wallets to execute functions by interacting with other smart contracts. For example, you can interact with the USDC contract in order to transfer funds from your smart wallet to another account.

* `target` the smart contract address - please note, only whitelisted contracts are permitted
* `callData` the input data for a function call as defined by the ABI specification

{% hint style="info" %}
**Please note**: Executing incorrect data can have irreversible consequences. Please be certain that you know what you are doing.
{% endhint %}

###

### executeMarketOrder

```javascript
function executeMarketOrder(
    IAmm _asset,
    SignedDecimal.signedDecimal memory _orderSize,
    Decimal.decimal memory _collateral,
    Decimal.decimal memory _leverage,
    Decimal.decimal memory _slippage
  )
```

This function executes a market order by interact with the perpetual ClearingHouse.

* `_orderSize` represents the size of the position you wish to trade. A positive number represents BUY/LONG whilst a negative number signifies a SELL/SHORT.
* `_collateral` the amount of margin that will be used for this order.
* `_leverage` the maximum amount of leverage that can be used. The transaction will revert if the target leverage is greater than this number.
* `_slippage` the minimum/maximum number of tokens that the user will accept otherwise the transaction will revert.

###

### executeClosePosition

```javascript
function executeClosePosition(
    IAmm _asset,
    Decimal.decimal memory _slippage
  )
```

This function will close the users entire position for a specific asset.&#x20;

* `_slippage` the minimum amount of USDC that the user will accept otherwise the transaction will revert

### Pause

```javascript
function pauseWallet()
function unpauseWallet()
```

A user may choose to freeze their wallet. If their smart wallet is frozen, it will not be possible for them to execute orders. It is still possible for the user to create additional advanced orders - but it will not be possible to execute these orders until the user unfreezes their wallet.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.apex.win/apex-docs/developer-guide/smart-contracts/smart-wallet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
