> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# deposit

> Resolves a yield, builds the enter action, and signs and submits every transaction in one call.

**Function Signature**

```swift theme={null}
public func deposit(params: YieldDepositParams, options: YieldSubmitOptions?) async throws -> YieldDepositResult
```

A convenience overload drops the options argument:

```swift theme={null}
public func deposit(params: YieldDepositParams) async throws -> YieldDepositResult
```

**Description**

Runs a complete deposit into a yield opportunity: resolves the yield, builds the enter action, then for each returned transaction signs it, submits it, waits for on-chain confirmation, and reports the hash back to Yield.xyz.

Transactions execute sequentially. If one is confirmed as failed on-chain, execution stops immediately and the result carries `.failed`. If a confirmation times out, execution stops and the result carries `.partialSuccess`.

The wallet address is resolved from your `Portal` instance for the chain the yield resolves to — there is no `address` parameter.

**Parameters**

`YieldDepositParams`:

| Parameter   | Type                      | Required | Description                                                                              |
| ----------- | ------------------------- | -------- | ---------------------------------------------------------------------------------------- |
| `target`    | `YieldActionTarget`       | Yes      | `.yieldId(String)`, or `.chainAndToken(chain:token:)` where `chain` is a full CAIP-2 id. |
| `amount`    | `String`                  | Yes      | Amount to deposit. Merged into the action arguments.                                     |
| `arguments` | `YieldXyzEnterArguments?` | No       | Protocol-specific inputs such as `validatorAddress` for native staking.                  |

`YieldSubmitOptions`:

| Option                | Type                               | Default | Description                                                                                      |
| --------------------- | ---------------------------------- | ------- | ------------------------------------------------------------------------------------------------ |
| `onProgress`          | `((YieldSubmitProgress) -> Void)?` | `nil`   | Fired per transaction with `.signing`, `.submitted`, `.confirming`, `.confirmed`.                |
| `pollIntervalSeconds` | `Int`                              | `4`     | Seconds between confirmation polls. Clamped to a minimum of `1`.                                 |
| `timeoutSeconds`      | `Int`                              | `900`   | Seconds before a transaction is treated as uncertain. Clamped to at least `pollIntervalSeconds`. |

<Note>
  These are seconds. The Android SDK uses milliseconds for the same two options.
</Note>

**Returns**

**`YieldDepositResult`**:

| Property                  | Type                      | Description                                                                                        |
| ------------------------- | ------------------------- | -------------------------------------------------------------------------------------------------- |
| `hashes`                  | `[String]`                | Submitted transaction hashes, in order. Present regardless of outcome.                             |
| `yieldId`                 | `String`                  | The resolved yield id.                                                                             |
| `status`                  | `YieldSubmitResultStatus` | `.success`, `.partialSuccess`, or `.failed`.                                                       |
| `chain`                   | `String?`                 | Set only when resolved via `.chainAndToken`.                                                       |
| `token`                   | `String?`                 | Set only when resolved via `.chainAndToken`.                                                       |
| `yieldOpportunityDetails` | `YieldOpportunityDetails` | Action metadata: `yieldId`, `intent`, `type`, `executionPattern`, `status`, `amount`, `amountUsd`. |

<Warning>
  A non-empty `hashes` array does not mean success — hashes are recorded at submission, before the outcome is known. Always branch on `status`.
</Warning>

**Throws**

Throws `YieldXyzError`. The cases most likely here:

| Case                              | When                                                                  |
| --------------------------------- | --------------------------------------------------------------------- |
| `invalidChainId(String)`          | `chain` was not a full CAIP-2 id.                                     |
| `noYieldForChainToken(String)`    | No default yield matches that chain and token.                        |
| `yieldNotFound(String)`           | The yield id does not exist.                                          |
| `addressUnavailable(String)`      | No wallet address for the resolved chain.                             |
| `noTransactions`                  | The action response contained no transactions.                        |
| `missingTransactionField(String)` | A transaction was missing a required field.                           |
| `unsupportedNetwork(String)`      | The action resolved to a network the high-level flow cannot sign for. |
| `invalidSignResponse`             | Signing returned an unusable response.                                |
| `transactionFailed(String)`       | A transaction failed on-chain. Carries the hash.                      |
| `apiError(String)`                | The backend returned an error payload.                                |

**Example Usage**

```swift theme={null}
import PortalSwift

do {
    let result = try await portal.yield.yieldxyz.deposit(
        params: YieldDepositParams(
            target: .yieldId("ethereum-sepolia-link-aave-v3-lending"),
            amount: "0.001"
        ),
        options: YieldSubmitOptions(
            onProgress: { progress in
                print("[deposit] \(progress.step.rawValue) \(progress.index + 1)/\(progress.total)")
            },
            pollIntervalSeconds: 4,
            timeoutSeconds: 300
        )
    )

    switch result.status {
    case .success:
        print("Confirmed: \(result.hashes)")
    case .partialSuccess:
        print("Stopped early: \(result.hashes) — check the yield balance")
    case .failed:
        print("Failed on-chain: \(result.hashes.last ?? "none")")
    }
} catch let error as YieldXyzError {
    print("Deposit failed: \(error.errorDescription ?? "unknown")")
}
```

**Related Documentation**

* [Earn with Yield.xyz](../guide/yield-xyz)
* [withdraw](./yieldwithdraw)
* [getValidators](./yieldgetvalidators)
* [Yield.xyz Integration](/integrations/Yield/yield-xyz)
