# SelfPermit

**Inherits:** [ISelfPermit](https://docs.mav.xyz/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/paymentbase/iselfpermit)

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>
