## API

**Version:** 0.1.0 **Format Version:** 46

## Module `relay_depository`

## Modules

## Module `program`

Module representing the program.

```rust
pub mod program { /* ... */ }
```

### Types

#### Struct `RelayDepository`

Type representing the program.

```rust
pub struct RelayDepository;
```

## Module `relay_depository`

```rust
pub mod relay_depository { /* ... */ }
```

### Functions

#### Function `initialize`

Initialize the relay depository program with owner and allocator. Creates and initializes the relay depository account with the specified owner and allocator.

###### Parameters

- `ctx` - The context containing the accounts

###### Returns

- `Ok(())` on success

```rust
pub fn initialize(ctx: Context<''_, ''_, ''_, ''_, Initialize<''_>>) -> Result<()> { /* ... */ }
```

#### Function `set_allocator`

Update the allocator public key. Allows the owner to change the authorized allocator that can sign transfer requests.

###### Parameters

- `ctx` - The context containing the accounts
- `new_allocator` - The public key of the new allocator

###### Returns

- `Ok(())` on success
- `Err(error)` if not authorized

```rust
pub fn set_allocator(ctx: Context<''_, ''_, ''_, ''_, SetAllocator<''_>>, new_allocator: Pubkey) -> Result<()> { /* ... */ }
```

#### Function `set_owner`

Update the owner public key. Allows the current owner to transfer ownership to a new address.

###### Parameters

- `ctx` - The context containing the accounts
- `new_owner` - The public key of the new owner

###### Returns

- `Ok(())` on success
- `Err(error)` if not authorized

```rust
pub fn set_owner(ctx: Context<''_, ''_, ''_, ''_, SetOwner<''_>>, new_owner: Pubkey) -> Result<()> { /* ... */ }
```

#### Function `deposit_native`

Deposit native SOL tokens into the vault. Transfers SOL from the sender to the vault and emits a deposit event.

###### Parameters

- `ctx` - The context containing the accounts
- `amount` - The amount of SOL to deposit
- `id` - A unique identifier for the deposit

###### Returns

- `Ok(())` on success

```rust
pub fn deposit_native(ctx: Context<''_, ''_, ''_, ''_, DepositNative<''_>>, amount: u64, id: [u8; 32]) -> Result<()> { /* ... */ }
```

#### Function `deposit_token`

Deposit SPL tokens into the vault. Creates the vault’s token account if needed, transfers tokens from the sender, and emits a deposit event.

###### Parameters

- `ctx` - The context containing the accounts
- `amount` - The amount of tokens to deposit
- `id` - A unique identifier for the deposit

###### Returns

- `Ok(())` on success

```rust
pub fn deposit_token(ctx: Context<''_, ''_, ''_, ''_, DepositToken<''_>>, amount: u64, id: [u8; 32]) -> Result<()> { /* ... */ }
```

#### Function `execute_transfer`

Execute a transfer with allocator signature. Verifies the allocator’s signature, transfers tokens to the recipient, and marks the request as used.

###### Parameters

- `ctx` - The context containing the accounts
- `request` - The transfer request details and signature

###### Returns

- `Ok(())` on success
- `Err(error)` if signature is invalid or request can’t be processed

```rust
pub fn execute_transfer(ctx: Context<''_, ''_, ''_, ''_, ExecuteTransfer<''_>>, request: TransferRequest) -> Result<()> { /* ... */ }
```

## Module `instruction`

An Anchor generated module containing the program’s set of instructions, where each method handler in the `#[program]` mod is associated with a struct defining the input arguments to the method. These should be used directly, when one wants to serialize Anchor instruction data, for example, when specifying instructions on a client.

```rust
pub mod instruction { /* ... */ }
```

### Types

#### Struct `Initialize`

Instruction.

```rust
pub struct Initialize;
```

#### Struct `SetAllocator`

Instruction.

```rust
pub struct SetAllocator {
    pub new_allocator: Pubkey,
}
```

##### Fields

| Name          | Type    | Documentation  |
|---------------|---------|----------------|
| `new_allocator` | `Pubkey` |                |

#### Struct `SetOwner`

Instruction.

```rust
pub struct SetOwner {
    pub new_owner: Pubkey,
}
```

##### Fields

| Name          | Type    | Documentation  |
|---------------|---------|----------------|
| `new_owner`  | `Pubkey` |                |

#### Struct `DepositNative`

Instruction.

```rust
pub struct DepositNative {
    pub amount: u64,
    pub id: [u8; 32],
}
```

##### Fields

| Name          | Type    | Documentation  |
|---------------|---------|----------------|
| `amount`     | `u64`  |                |
| `id`         | `[u8; 32]` |              |

#### Struct `DepositToken`

Instruction.

```rust
pub struct DepositToken {
    pub amount: u64,
    pub id: [u8; 32],
}
```

##### Fields

| Name          | Type    | Documentation  |
|---------------|---------|----------------|
| `amount`     | `u64`  |                |
| `id`         | `[u8; 32]` |              |

#### Struct `ExecuteTransfer`

Instruction.

```rust
pub struct ExecuteTransfer {
    pub request: TransferRequest,
}
```

##### Fields

| Name          | Type    | Documentation  |
|---------------|---------|----------------|
| `request`     | `TransferRequest` |              |

### Module `cpi`

**Attributes:**

- `#[<cfg>(feature = "cpi")]`

```rust
pub mod cpi { /* ... */ }
```

### Module `accounts`

An Anchor generated module, providing a set of structs mirroring the structs deriving `Accounts`, where each field is an `AccountInfo`. This is useful for CPI.

```rust
pub mod accounts { /* ... */ }
```

### Re-exports

#### Re-export `crate::__cpi_client_accounts_set_allocator::*`

```rust
pub use crate::__cpi_client_accounts_set_allocator::*;
```

#### Re-export `crate::__cpi_client_accounts_set_owner::*`

```rust
pub use crate::__cpi_client_accounts_set_owner::*;
```

#### Re-export `crate::__cpi_client_accounts_initialize::*`

```rust
pub use crate::__cpi_client_accounts_initialize::*;
```

#### Re-export `crate::__cpi_client_accounts_deposit_token::*`

```rust
pub use crate::__cpi_client_accounts_deposit_token::*;
```

#### Re-export `crate::__cpi_client_accounts_execute_transfer::*`

```rust
pub use crate::__cpi_client_accounts_execute_transfer::*;
```

#### Re-export `crate::__cpi_client_accounts_deposit_native::*`

```rust
pub use crate::__cpi_client_accounts_deposit_native::*;
```

### Types

#### Struct `RelayDepository`

Relay depository account that stores configuration and state. This account is a PDA derived from the `RELAY_DEPOSITORY_SEED` and contains the ownership and allocation information.

```rust
pub struct RelayDepository {
    pub owner: Pubkey,
    pub allocator: Pubkey,
    pub vault_bump: u8,
}
```

##### Fields

| Name          | Type    | Documentation  |
|---------------|---------|----------------|
| `owner`      | `Pubkey` | The owner of the relay depository who can update settings |
| `allocator`  | `Pubkey` | The authorized allocator that can sign transfer requests |
| `vault_bump` | `u8`    | The bump seed for the vault PDA, used for deriving the vault address |

#### Struct `UsedRequest`

Account that tracks whether a transfer request has been used. This account is created for each transfer request to prevent replay attacks.

```rust
pub struct UsedRequest {
    pub is_used: bool,
}
```

##### Fields

| Name          | Type    | Documentation  |
|---------------|---------|----------------|
| `is_used`    | `bool`  | Flag indicating whether the request has been processed |

### Implementation Details

// Further implementation details and explanations on various code implementations follow.
