# Wrapped SD Token

`WrappedSDToken` wraps rebasing liquid staking tokens (such as stLINK) with a normal ERC20 token.

## ERC20 Functions

All standard ERC20 functions are implemented for `WrappedSDToken`

## View Functions

### sdToken

Returns the underlying staking receipt token that this contract wraps

```solidity
function sdToken() external view returns (address)
```

#### Return Values

| Name    | Type    | Description                      |
| ------- | ------- | -------------------------------- |
| sdToken | address | Address of staking receipt token |

### getWrappedByUnderlying

Returns the amount of wrapped tokens that corresponds an amount of unwrapped tokens

```solidity
function getWrappedByUnderlying(uint256 _amount) external view returns (uint256)
```

#### Parameters

| Name     | Type    | Description                |
| -------- | ------- | -------------------------- |
| \_amount | uint256 | Amount of unwrapped tokens |

#### Return Values

| Name          | Type    | Description                            |
| ------------- | ------- | -------------------------------------- |
| wrappedAmount | uint256 | Amount of corresponding wrapped tokens |

### getUnderlyingByWrapped

Returns the amount of unwrapped tokens that corresponds to an amount of wrapped tokens

```solidity
function getUnderlyingByWrapped(uint256 _amount) external view returns (uint256)
```

#### Parameters

| Name     | Type    | Description              |
| -------- | ------- | ------------------------ |
| \_amount | uint256 | Amount of wrapped tokens |

#### Return Values

| Name            | Type    | Description                              |
| --------------- | ------- | ---------------------------------------- |
| unwrappedAmount | uint256 | Corresponding amount of unwrapped tokens |

## Write Functions

### onTokenTransfer

ERC677 implementation that proxies wrapping

```solidity
function onTokenTransfer(address _sender, uint256 _value, bytes) external
```

#### Parameters

| Name     | Type    | Description                  |
| -------- | ------- | ---------------------------- |
| \_sender | address | Sender of the token transfer |
| \_value  | uint256 | Value of the token transfer  |
|          | bytes   |                              |

### wrap

Wraps tokens

```solidity
function wrap(uint256 _amount) external
```

#### Parameters

| Name     | Type    | Description                        |
| -------- | ------- | ---------------------------------- |
| \_amount | uint256 | Amount of unwrapped tokens to wrap |

### unwrap

Unwraps tokens

```solidity
function unwrap(uint256 _amount) external
```

#### Parameters

| Name     | Type    | Description                        |
| -------- | ------- | ---------------------------------- |
| \_amount | uint256 | Amount of wrapped tokens to unwrap |

### transferAndCall

Transfers tokens to an address and calls `onTokenTransfer` with additional data if the recipient is a contract

```solidity
function transferAndCall(address _to, uint256 _value, bytes _data) external returns (bool)
```

#### Parameters

| Name    | Type    | Description                       |
| ------- | ------- | --------------------------------- |
| \_to    | address | Address to send the tokens to     |
| \_value | uint256 | Value of token transfer           |
| \_data  | bytes   | Calldata included in the transfer |


---

# 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://docs.stake.link/core-staking-contracts/wrappedsdtoken.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.
