# TonPoolStaker

## Hierarchy

* `TonBaseStaker`

  ↳ **`TonPoolStaker`**

## Table of contents

### Constructors

* [constructor](#constructor)

### Methods

* [calculateUnstakePoolAmount](#calculateunstakepoolamount)
* [getAddressDerivationFn](#getaddressderivationfn)
* [getMnemonicToSeedFn](#getmnemonictoseedfn)
* [getSeedToKeypairFn](#getseedtokeypairfn)
* [buildStakeTx](#buildstaketx)
* [buildUnstakeTx](#buildunstaketx)
* [getStake](#getstake)
* [getPoolParams](#getpoolparams)
* [getTxStatus](#gettxstatus)
* [getElectionMinStake](#getelectionminstake)
* [getPoolStatus](#getpoolstatus)
* [getPastElections](#getpastelections)
* [init](#init)
* [buildDeployWalletTx](#builddeploywallettx)
* [sign](#sign)
* [broadcast](#broadcast)

## Constructors

### constructor

• **new TonPoolStaker**(`params`): [`TonPoolStaker`](/api-reference/stakers/ton_src.tonpoolstaker.md)

This creates a new TonStaker instance.

#### Parameters

| Name                                     | Type                                                                                     | Description                                                                      |
| ---------------------------------------- | ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| `params`                                 | `Object`                                                                                 | Initialization parameters                                                        |
| `params.rpcUrl`                          | `string`                                                                                 | RPC URL (e.g. <https://toncenter.com/api/v2/jsonRPC>)                            |
| `params.allowSeamlessWalletDeployment?`  | `boolean`                                                                                | (Optional) If enabled, the wallet contract is deployed automatically when needed |
| `params.allowTransferToInactiveAccount?` | `boolean`                                                                                | (Optional) Allow token transfers to inactive accounts                            |
| `params.minimumExistentialBalance?`      | `string`                                                                                 | (Optional) The amount of TON to keep in the wallet                               |
| `params.addressDerivationConfig?`        | [`AddressDerivationConfig`](/api-reference/types/ton/ton_src.addressderivationconfig.md) | (Optional) TON address derivation configuration                                  |

#### Returns

[`TonPoolStaker`](/api-reference/stakers/ton_src.tonpoolstaker.md)

An instance of TonStaker.

#### Inherited from

TonBaseStaker.constructor

## Methods

### calculateUnstakePoolAmount

▸ **calculateUnstakePoolAmount**(`amount`, `minElectionStake`, `«destructured»`, `«destructured»`, `«destructured»`, `«destructured»`): \[`bigint`, `bigint`]

Calculates optimal unstake amounts from two pools. Tries strategies in order: keep both active → keep one active → deactivate both

TODO: Add transaction simulation to catch false negatives thrown by SDK in case of bugs in calculation logic. Consider adding anonymous telemetry/logging.

TODO: Add `getValidUnstakeRanges()` method to help integrators validate amounts upfront by knowing the valid amounts to unstake.

#### Parameters

| Name               | Type                  |
| ------------------ | --------------------- |
| `amount`           | `bigint`              |
| `minElectionStake` | `bigint`              |
| `«destructured»`   | \[`bigint`, `bigint`] |
| `«destructured»`   | \[`bigint`, `bigint`] |
| `«destructured»`   | \[`bigint`, `bigint`] |
| `«destructured»`   | \[`bigint`, `bigint`] |

#### Returns

\[`bigint`, `bigint`]

***

### getAddressDerivationFn

▸ **getAddressDerivationFn**(`params?`): (`publicKey`: `Uint8Array`, `_derivationPath`: `string`) => `Promise`<`string`\[]>

This **static** method is used to derive an address from a public key.

It can be used for signer initialization, e.g. `FireblocksSigner` or `LocalSigner`.

#### Parameters

| Name                             | Type                                                                                     | Description                           |
| -------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------- |
| `params?`                        | `Object`                                                                                 | Parameters for the address derivation |
| `params.addressDerivationConfig` | [`AddressDerivationConfig`](/api-reference/types/ton/ton_src.addressderivationconfig.md) | TON address derivation configuration  |

#### Returns

`fn`

Returns a single address derived from the public key

▸ (`publicKey`, `_derivationPath`): `Promise`<`string`\[]>

**Parameters**

| Name              | Type         |
| ----------------- | ------------ |
| `publicKey`       | `Uint8Array` |
| `_derivationPath` | `string`     |

**Returns**

`Promise`<`string`\[]>

#### Inherited from

TonBaseStaker.getAddressDerivationFn

***

### getMnemonicToSeedFn

▸ **getMnemonicToSeedFn**(`params?`): (`mnemonic`: `string`, `password?`: `string`) => `Promise`<`Uint8Array`>

This **static** method is used to convert BIP39 mnemonic to seed. In TON network the seed is used as a private key.

It can be used for signer initialization, e.g. `FireblocksSigner` or `LocalSigner`.

#### Parameters

| Name                             | Type                                                                                     | Description                          |
| -------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------ |
| `params?`                        | `Object`                                                                                 | -                                    |
| `params.addressDerivationConfig` | [`AddressDerivationConfig`](/api-reference/types/ton/ton_src.addressderivationconfig.md) | TON address derivation configuration |

#### Returns

`fn`

Returns a seed derived from the mnemonic

▸ (`mnemonic`, `password?`): `Promise`<`Uint8Array`>

**Parameters**

| Name        | Type     |
| ----------- | -------- |
| `mnemonic`  | `string` |
| `password?` | `string` |

**Returns**

`Promise`<`Uint8Array`>

#### Inherited from

TonBaseStaker.getMnemonicToSeedFn

***

### getSeedToKeypairFn

▸ **getSeedToKeypairFn**(`params?`): (`seed`: `Uint8Array`, `hdPath?`: `string`) => `Promise`<{ `publicKey`: `Uint8Array` ; `privateKey`: `Uint8Array` }>

This **static** method is used to convert a seed to a keypair. Note that TON network doesn't use BIP44 HD Path for address derivation.

It can be used for signer initialization, e.g. `FireblocksSigner` or `LocalSigner`.

#### Parameters

| Name                             | Type                                                                                     | Description                          |
| -------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------ |
| `params?`                        | `Object`                                                                                 | -                                    |
| `params.addressDerivationConfig` | [`AddressDerivationConfig`](/api-reference/types/ton/ton_src.addressderivationconfig.md) | TON address derivation configuration |

#### Returns

`fn`

Returns a public and private keypair derived from the seed

▸ (`seed`, `hdPath?`): `Promise`<{ `publicKey`: `Uint8Array` ; `privateKey`: `Uint8Array` }>

**Parameters**

| Name      | Type         |
| --------- | ------------ |
| `seed`    | `Uint8Array` |
| `hdPath?` | `string`     |

**Returns**

`Promise`<{ `publicKey`: `Uint8Array` ; `privateKey`: `Uint8Array` }>

#### Inherited from

TonBaseStaker.getSeedToKeypairFn

***

### buildStakeTx

▸ **buildStakeTx**(`params`): `Promise`<{ `tx`: [`UnsignedTx`](/api-reference/types/ton/ton_src.unsignedtx.md) }>

Builds a staking transaction for TON Pool contract. It uses 2 pool solution, and picks the best pool to stake to automatically.

#### Parameters

| Name                          | Type                                    | Description                                                                                                                                                                                                                                                                                 |
| ----------------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `params`                      | `Object`                                | Parameters for building the transaction                                                                                                                                                                                                                                                     |
| `params.delegatorAddress`     | `string`                                | The delegator address                                                                                                                                                                                                                                                                       |
| `params.validatorAddressPair` | \[`string`, `string`]                   | The validator address pair to stake to                                                                                                                                                                                                                                                      |
| `params.amount`               | `string`                                | The amount to stake, specified in `TON`                                                                                                                                                                                                                                                     |
| `params.preferredStrategy?`   | `"split"` \| `"single"` \| `"balanced"` | (Optional) The stake allocation strategy. Default is `balanced`. \* `balanced` - automatically balances the stake between the two pools based on the current pool balances and user stakes \* `split` - splits the stake evenly between the two pools \* `single` - stakes to a single pool |
| `params.referrer?`            | `string`                                | (Optional) The address of the referrer. This is used to track the origin of transactions, providing insights into which sources or campaigns are driving activity. This can be useful for analytics and optimizing user acquisition strategies                                              |
| `params.validUntil?`          | `number`                                | (Optional) The Unix timestamp when the transaction expires                                                                                                                                                                                                                                  |

#### Returns

`Promise`<{ `tx`: [`UnsignedTx`](/api-reference/types/ton/ton_src.unsignedtx.md) }>

Returns a promise that resolves to a TON nominator pool staking transaction.

***

### buildUnstakeTx

▸ **buildUnstakeTx**<`T`>(`params`): `Promise`<{ `tx`: [`UnsignedTx`](/api-reference/types/ton/ton_src.unsignedtx.md) }>

Builds an unstaking transaction for TON Pool contract.

#### Type parameters

| Name | Type                        |
| ---- | --------------------------- |
| `T`  | extends `boolean` = `false` |

#### Parameters

| Name                                 | Type                                                  | Description                                                                                                           |
| ------------------------------------ | ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `params`                             | `Object`                                              | Parameters for building the transaction                                                                               |
| `params.delegatorAddress`            | `string`                                              | The delegator address                                                                                                 |
| `params.validatorAddressPair`        | \[`string`, `string`]                                 | The validator address pair to unstake from                                                                            |
| `params.amount`                      | `T` extends `true` ? \[`string`, `string`] : `string` | The amount to unstake, specified in `TON`. When disableStatefulCalculation is true, must be a tuple \[string, string] |
| `params.disableStatefulCalculation?` | `T`                                                   | (Optional) Disables stateful calculation where validator and user stake is taken into account                         |
| `params.validUntil?`                 | `number`                                              | (Optional) The Unix timestamp when the transaction expires                                                            |

#### Returns

`Promise`<{ `tx`: [`UnsignedTx`](/api-reference/types/ton/ton_src.unsignedtx.md) }>

Returns a promise that resolves to a TON nominator pool unstaking transaction.

***

### getStake

▸ **getStake**(`params`): `Promise`<{ `balance`: `string` ; `pendingDeposit`: `string` ; `pendingWithdraw`: `string` ; `withdraw`: `string` }>

Retrieves the staking information for a specified delegator.

#### Parameters

| Name                      | Type     | Description                                                         |
| ------------------------- | -------- | ------------------------------------------------------------------- |
| `params`                  | `Object` | Parameters for the request                                          |
| `params.delegatorAddress` | `string` | The delegator (wallet) address                                      |
| `params.validatorAddress` | `string` | (Optional) The validator address to gather staking information from |

#### Returns

`Promise`<{ `balance`: `string` ; `pendingDeposit`: `string` ; `pendingWithdraw`: `string` ; `withdraw`: `string` }>

Returns a promise that resolves to the staking information for the specified delegator.

***

### getPoolParams

▸ **getPoolParams**(`params`): `Promise`<{ `minStake`: `string` ; `depositFee`: `string` ; `withdrawFee`: `string` ; `poolFee`: `string` ; `receiptPrice`: `string` }>

Retrieves the staking information for a specified pool, including minStake and fees information.

#### Parameters

| Name                      | Type     | Description                   |
| ------------------------- | -------- | ----------------------------- |
| `params`                  | `Object` | Parameters for the request    |
| `params.validatorAddress` | `string` | The validator (vault) address |

#### Returns

`Promise`<{ `minStake`: `string` ; `depositFee`: `string` ; `withdrawFee`: `string` ; `poolFee`: `string` ; `receiptPrice`: `string` }>

Returns a promise that resolves to the staking information for the specified pool.

***

### getTxStatus

▸ **getTxStatus**(`params`): `Promise`<`TonTxStatus`>

Retrieves the status of a transaction using the transaction hash.

This method is intended to check for transactions made recently (within limit) and not for historical transactions.

#### Parameters

| Name             | Type     | Description                                            |
| ---------------- | -------- | ------------------------------------------------------ |
| `params`         | `Object` | Parameters for the transaction status request          |
| `params.address` | `string` | The account address to query                           |
| `params.txHash`  | `string` | The transaction hash to query                          |
| `params.limit?`  | `number` | (Optional) The maximum number of transactions to fetch |

#### Returns

`Promise`<`TonTxStatus`>

A promise that resolves to an object containing the transaction status.

#### Overrides

TonBaseStaker.getTxStatus

***

### getElectionMinStake

▸ **getElectionMinStake**(): `Promise`<`bigint`>

#### Returns

`Promise`<`bigint`>

***

### getPoolStatus

▸ **getPoolStatus**(`validatorAddress`): `Promise`<`PoolStatus`>

#### Parameters

| Name               | Type     |
| ------------------ | -------- |
| `validatorAddress` | `string` |

#### Returns

`Promise`<`PoolStatus`>

***

### getPastElections

▸ **getPastElections**(`electorContractAddress`): `Promise`<`Election`\[]>

#### Parameters

| Name                     | Type     |
| ------------------------ | -------- |
| `electorContractAddress` | `string` |

#### Returns

`Promise`<`Election`\[]>

***

### init

▸ **init**(): `Promise`<`void`>

Initializes the TonStaker instance and connects to the blockchain.

#### Returns

`Promise`<`void`>

A promise which resolves once the TonStaker instance has been initialized.

#### Inherited from

TonBaseStaker.init

***

### buildDeployWalletTx

▸ **buildDeployWalletTx**(`params`): `Promise`<{ `tx`: [`UnsignedTx`](/api-reference/types/ton/ton_src.unsignedtx.md) }>

Builds a wallet deployment transaction

#### Parameters

| Name                 | Type     | Description                                                |
| -------------------- | -------- | ---------------------------------------------------------- |
| `params`             | `Object` | Parameters for building the transaction                    |
| `params.address`     | `string` | The address to deploy the wallet contract to               |
| `params.validUntil?` | `number` | (Optional) The Unix timestamp when the transaction expires |

#### Returns

`Promise`<{ `tx`: [`UnsignedTx`](/api-reference/types/ton/ton_src.unsignedtx.md) }>

Returns a promise that resolves to a TON wallet deployment transaction.

#### Inherited from

TonBaseStaker.buildDeployWalletTx

***

### sign

▸ **sign**(`params`): `Promise`<[`SignedTx`](/api-reference/types/ton/ton_src.signedtx.md)>

Signs a transaction using the provided signer.

#### Parameters

| Name                   | Type                                                           | Description                        |
| ---------------------- | -------------------------------------------------------------- | ---------------------------------- |
| `params`               | `Object`                                                       | Parameters for the signing process |
| `params.signer`        | `Signer`                                                       | Signer instance                    |
| `params.signerAddress` | `string`                                                       | The address of the signer          |
| `params.tx`            | [`UnsignedTx`](/api-reference/types/ton/ton_src.unsignedtx.md) | The transaction to sign            |

#### Returns

`Promise`<[`SignedTx`](/api-reference/types/ton/ton_src.signedtx.md)>

A promise that resolves to an object containing the signed transaction.

#### Inherited from

TonBaseStaker.sign

***

### broadcast

▸ **broadcast**(`params`): `Promise`<`string`>

This method is used to broadcast a signed transaction to the TON network.

#### Parameters

| Name              | Type                                                       | Description                              |
| ----------------- | ---------------------------------------------------------- | ---------------------------------------- |
| `params`          | `Object`                                                   | Parameters for the broadcast             |
| `params.signedTx` | [`SignedTx`](/api-reference/types/ton/ton_src.signedtx.md) | The signed transaction to be broadcasted |

#### Returns

`Promise`<`string`>

Returns a promise that resolves to the response of the transaction that was broadcast to the network.

#### Inherited from

TonBaseStaker.broadcast


---

# 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://sdk.chorus.one/api-reference/stakers/ton_src.tonpoolstaker.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.
