> For the complete documentation index, see [llms.txt](https://subunit.gitbook.io/subunit-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://subunit.gitbook.io/subunit-docs/subvault/subvault-technical-docs/core-functions.md).

# Core Functions

#### 1. **Staking (`stake`)**

Users stake USDC and receive STS in return, representing a share of the vault’s USDC balance.

**STS minting logic:**

```solidity
solidityCopyEditstsToMint = (amount * totalSupply()) / vaultBalance;
```

* If `totalSupply() == 0`, STS is minted at a 1:1 ratio scaled by `1e12` to align with USDC decimals (6) vs. STS decimals (18).
* Otherwise, mint proportionally to existing vault state.

**Stake Details:**

* Tracked via `StakeRecord[]`:
  * `stsShares`: Amount of STS minted
  * `durationDays`: Lockup period (0, 90, or 180)
  * `lockEndTime`: Timestamp when the stake becomes redeemable
  * `active`: Whether the stake is still claimable

**Sanctions Check:**

* Uses Chainalysis Oracle via `checkSanctions(msg.sender)`
* If oracle fails or flags the address, the tx is reverted

***

#### 2. **Unstaking (`unstake`)**

* Users burn STS to redeem a share of the vault’s USDC
* Amount returned is based on the **pro-rata share** of current vault balance:

```solidity
solidityCopyEditusdcToReturn = (stsAmountToBurn * vaultBalance) / totalSupply();
```

* Lock period must be expired (`block.timestamp >= lockEndTime`)
* Stake is marked as inactive and shares zeroed out

***

#### 3. **Non-Transferability**

STS is a non-transferable ERC20:

```solidity
solidityCopyEditrequire(from == address(0) || to == address(0), "STS: token is non-transferable");
```

* Transfers are blocked unless minting (`from == 0`) or burning (`to == 0`)
* Prevents secondary market speculation and enforces 1:1 mint/burn lifecycle

***

#### 4. **Acquisition Withdrawals (`withdrawForAcquisition`)**

* Admin-only method to withdraw USDC for real estate purchases
* This directly impacts vault balance → **STS value is diluted**

```solidity
solidityCopyEditusdc.safeTransfer(to, amount);
emit AcquisitionWithdrawal(to, amount);
```

***

#### 5. **Rescuing Mistaken Tokens**

* Recovers any tokens mistakenly sent to vault (except USDC or STS)
* Safeguard against misrouted assets or phishing

```solidity
solidityCopyEditrequire(tokenAddress != address(usdc));
require(tokenAddress != address(this));
```

***

#### 6. **Oracle Management (`setSanctionsOracleAddress`)**

* Updates the sanctions oracle used for address screening
* Emits `SanctionsOracleUpdated`

***

#### 7. **Pause Mechanism**

* `pause()` and `unpause()` let the owner halt operations during threats
* Uses OpenZeppelin’s `Pausable` modifier

### &#x20;View Functions

| Function                                            | Description                                            |
| --------------------------------------------------- | ------------------------------------------------------ |
| `getTotalVaultedUSDC()`                             | Returns the current USDC balance of the vault          |
| `getCurrentValueOfActiveStakes(user)`               | Calculates user’s total USDC share based on active STS |
| `getUserStakeRecordsPaginated(user, cursor, limit)` | Returns paginated view of user's stake records         |
| `getUserStakeCount(user)`                           | Total number of stakes recorded by the user            |
| `getStakeRecord(user, index)`                       | Returns the full struct for a given user stake         |

***
