> For the complete documentation index, see [llms.txt](https://spree-finance.gitbook.io/spreefinance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://spree-finance.gitbook.io/spreefinance/developer-guides/stable-points-sp/core-token-operations.md).

# Core Token Operations

### Mint SP from Stablecoins

Deposit stablecoins into the Factory to mint SP tokens. Fee: 0 bps.

```typescript
import { Factory } from '@spree-finance/spree-evm-sdk';

const factory = new Factory({
  rpcUrl: 'https://sepolia.base.org',
  chainId: 84532n,
  contractAddress: '0xFactoryAddress',
  from: '0xYourWallet',
  defaultGasPriceWei: 1_000_000_000n,
  defaultGasLimit: 500_000n,
});

// Mint 100 USDC worth of SP (USDC has 6 decimals)
const unsignedTx = await factory.mint(
  '0xUSDCAddress',   // asset: stablecoin address
  100_000_000n,      // amount: 100 USDC
  '0xReceiver',      // receiver: who gets the SP
  false,             // expectBasketMode
);
```

### Read SP Balance

```typescript
import { Points } from '@spree-finance/spree-evm-sdk';

const points = new Points({
  rpcUrl: 'https://sepolia.base.org',
  chainId: 84532n,
  contractAddress: '0xPointsAddress',
  from: '0xYourWallet',
  defaultGasPriceWei: 1_000_000_000n,
  defaultGasLimit: 500_000n,
});

const balance = await points.readBalanceOf('0xUserAddress');
const totalSupply = await points.readTotalSupply();
const decimals = await points.readDecimals();
const name = await points.readName();
const symbol = await points.readSymbol();
```

### Transfer SP

SP transfers are restricted to whitelisted addresses. See [Whitelist Management](https://github.com/Spree-Finance/spree-docs/blob/main/developer-guides/stable-points-sp/whitelist-management/README.md).

```typescript
// Transfer 50 SP
const tx = await points.transfer('0xRecipient', 50_000_000_000_000_000_000n);

// Approve a spender
const approveTx = await points.approve('0xSpender', 100_000_000_000_000_000_000n);

// Check allowance
const allowance = await points.readAllowance('0xOwner', '0xSpender');
```

### Create a Branded SP Vault

Deploy a new vault for a stablecoin asset:

```typescript
const createTx = await factory.createVault(
  '0xUSDCAddress',    // asset: underlying stablecoin
  1_000_000_000_000_000_000n, // assetToSharesRate: 1:1 (18 decimals)
);
```

### Read Factory State

```typescript
// Number of registered assets
const numAssets = await factory.readNumRegisteredAssets();

// Get registered asset by index
const asset = await factory.readRegisteredAssets(0n);

// Get vault address for an asset
const vaultAddr = await factory.readVaults('0xUSDCAddress');

// Check mint/redeem rates
const mintRate = await factory.readMintRates('0xUSDCAddress');
const redeemRate = await factory.readRedeemRates('0xUSDCAddress');

// Check global cap
const cap = await factory.readGlobalCap();

// Check pause status
const paused = await factory.readPaused();
```

### Set Mint and Redeem Rates

Requires Manager role.

```typescript
// Set mint rate for USDC (in basis points)
const setMintTx = await factory.setMintRate('0xUSDCAddress', 10000n);

// Set redeem rate for USDC
const setRedeemTx = await factory.setRedeemRate('0xUSDCAddress', 9950n);

// Set global supply cap
const setCapTx = await factory.setGlobalCap(1_000_000_000_000_000_000_000_000n);
```
