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

# Liquid Staking

```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
```
