> For the complete documentation index, see [llms.txt](https://docs.gnoswap.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gnoswap.io/contracts/gov/staker/staker_delegate.gno.md).

# staker\_delegate.gno

{% embed url="<https://github.com/gnoswap-labs/gnoswap/blob/main/contract/r/gnoswap/gov/staker/v1/staker.gno>" %}

Delegates/Undeleates GNS for governance.

## Delegate

```go
func Delegate(
	cur realm,
	to address,
	amount int64,
	referrer string
) int64
```

Delegate delegates GNS to a delegate.

#### Parameters

| Name       | Type    | Description                               |
| ---------- | ------- | ----------------------------------------- |
| `cur`      | realm   | Pass `cross` as argument.                 |
| `to`       | address | The address to delegate.                  |
| `amount`   | int64   | The amount of GNS.                        |
| `referrer` | string  | The referrer address for reward tracking. |

#### Return Values

| Name           | Type  | Description               |
| -------------- | ----- | ------------------------- |
| `delegationId` | int64 | The ID of the delegation. |

## Undelegate

```go
func Undelegate(
	cur realm,
	from address,
	amount int64
) int64
```

Undelegate undelegates xGNS from the existing delegate.

#### Parameters

| Name     | Type    | Description                |
| -------- | ------- | -------------------------- |
| `cur`    | realm   | Pass `cross` as argument.  |
| `from`   | address | The address to undelegate. |
| `amount` | int64   | The amount of xGNS.        |

#### Return Values

| Name      | Type  | Description             |
| --------- | ----- | ----------------------- |
| `tokenId` | int64 | The ID of the position. |

## Redelegate

```go
func Redelegate(
	cur realm,
	delegatee address,
	newDelegatee address,
	amount int64
) int64

```

Redelegate redelegates xGNS from the existing delegate to another.

#### Parameters

| Name           | Type    | Description                |
| -------------- | ------- | -------------------------- |
| `cur`          | realm   | Pass `cross` as argument.  |
| `delegatee`    | address | The address to undelegate. |
| `newDelegatee` | address | The address to delegate.   |
| `amount`       | int64   | The amount of xGNS.        |

#### Return Values

| Name         | Type  | Description                   |
| ------------ | ----- | ----------------------------- |
| `resultCode` | int64 | The redelegation result code. |

## CollectUndelegatedGns

```go
func CollectUndelegatedGns(
	cur realm
) int64
```

CollectUndelegatedGns collects the amount of the undelegated GNS.

#### Parameters

| Name  | Type  | Description               |
| ----- | ----- | ------------------------- |
| `cur` | realm | Pass `cross` as argument. |

#### Return Values

| Name     | Type  | Description                        |
| -------- | ----- | ---------------------------------- |
| `amount` | int64 | The amount of GNS token collected. |
