> For the complete documentation index, see [llms.txt](https://aftermath-finance-1.gitbook.io/aftermath-finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aftermath-finance-1.gitbook.io/aftermath-finance/aftermath-typescript-sdk/liquid-staking.md).

# Liquid Staking

Stake Sui and receive AfSui to earn a reliable yield, and hold the largest staking derivative on Sui.

```typescript
const staking = new Aftermath("TESTNET").Staking();
```

## Staking Positions

```typescript
const stakingPositions = await staking.getStakingPositions({
	walletAddress: "0x..",
});

console.log(stakingPositions);
/*
[
	// stake position
	{
		state: "SUCCESS",
		suiWrapperId: "0x..",
		staker: "0x..",
		validatorAddress: "0x..",
		epoch: 728n,
		suiStakeAmount: 1_000_000_000n, // 1 Sui
		txnDigest: "0x..",
		
		// optional
		afSuiMintAmount: 1_000_000_000n, // 1 AfSui
		timestamp: 1683834217840, // unix time (milliseconds)
	},
	
	// unstake position
	{
		state: "REQUEST",
		afSuiWrapperId: "0x..",
		staker: "0x..",
		epoch: 728n,
		suiUnstakeAmount: 1_000_000_000n, // 1 Sui
		afSuiAmountGiven: 1_000_000_000n, // 1 AfSui
		txnDigest: "0x..",
		
		// optional
		timestamp: 1683834217840, // unix time (milliseconds)
	},
	...
]
*/
```

## **Transactions**

### Stake

```typescript
const tx = await staking.getStakeTransaction({
	walletAddress: "0x..",
	suiStakeAmount: 1_000_000_000n, // 1 Sui
	validatorAddress: "0x..",
});
```

```typescript
const tx = await staking.getUnstakeTransaction({
	walletAddress: "0x..",
	afSuiUnstakeAmount: 1_000_000_000n, // 1 AfSui
});
```

## **Inspections**

### Staked Sui TVL

```typescript
const suiTvl = await staking.getSuiTvl();

console.log(suiTvl);
// 9_540_200_000n
```

### AfSui Exchange Rate

```typescript
// (1 Sui = x afSui)
const afSuiExchangeRate = await staking.getAfSuiExchangeRate();

console.log(afSuiExchangeRate);
// 0.890349000231
```
