# SelfPermit

**Inherits:** [ISelfPermit](/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/paymentbase/iselfpermit.md)

Functionality to call permit on any EIP-2612-compliant token for use in the route.

These functions are expected to be embedded in multicalls to allow EOAs to approve a contract and call a function that requires an approval in a single transaction.

### Functions <a href="#functions" id="functions"></a>

#### selfPermit <a href="#selfpermit-1" id="selfpermit-1"></a>

Allows the contract to call the permit function on the specified token.

```solidity
function selfPermit(address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
    public
    payable
    override;
```

**Parameters**

| Name       | Type      | Description                            |
| ---------- | --------- | -------------------------------------- |
| `token`    | `address` | The address of the token to permit.    |
| `value`    | `uint256` | The amount to permit.                  |
| `deadline` | `uint256` | The deadline for the permit.           |
| `v`        | `uint8`   | The v value from the permit signature. |
| `r`        | `bytes32` | The r value from the permit signature. |
| `s`        | `bytes32` | The s value from the permit signature. |

#### selfPermitIfNecessary <a href="#selfpermitifnecessary" id="selfpermitifnecessary"></a>

Allows the contract to call selfPermit if necessary based on the token's allowance.

```solidity
function selfPermitIfNecessary(address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
    external
    payable
    override;
```

**Parameters**

| Name       | Type      | Description                            |
| ---------- | --------- | -------------------------------------- |
| `token`    | `address` | The address of the token to permit.    |
| `value`    | `uint256` | The amount to permit.                  |
| `deadline` | `uint256` | The deadline for the permit.           |
| `v`        | `uint8`   | The v value from the permit signature. |
| `r`        | `bytes32` | The r value from the permit signature. |
| `s`        | `bytes32` | The s value from the permit signature. |

#### selfPermitAllowed <a href="#selfpermitallowed" id="selfpermitallowed"></a>

Allows the contract to call the permit function with unlimited allowance on the specified token.

```solidity
function selfPermitAllowed(address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s)
    public
    payable
    override;
```

**Parameters**

| Name     | Type      | Description                            |
| -------- | --------- | -------------------------------------- |
| `token`  | `address` | The address of the token to permit.    |
| `nonce`  | `uint256` | The nonce for the permit.              |
| `expiry` | `uint256` | The expiry time for the permit.        |
| `v`      | `uint8`   | The v value from the permit signature. |
| `r`      | `bytes32` | The r value from the permit signature. |
| `s`      | `bytes32` | The s value from the permit signature. |

#### selfPermitAllowedIfNecessary <a href="#selfpermitallowedifnecessary" id="selfpermitallowedifnecessary"></a>

Allows the contract to call selfPermitAllowed if necessary based on the token's allowance.

```solidity
function selfPermitAllowedIfNecessary(address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s)
    external
    payable
    override;
```

**Parameters**

| Name     | Type      | Description                            |
| -------- | --------- | -------------------------------------- |
| `token`  | `address` | The address of the token to permit.    |
| `nonce`  | `uint256` | The nonce for the permit.              |
| `expiry` | `uint256` | The expiry time for the permit.        |
| `v`      | `uint8`   | The v value from the permit signature. |
| `r`      | `bytes32` | The r value from the permit signature. |
| `s`      | `bytes32` | The s value from the permit signature. |

<br>


---

# 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.mav.xyz/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/paymentbase/selfpermit.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.
