# @symmetry-hq/overpass

TypeScript SDK for the Overpass program — wrap Solana lending positions as transferable SPL tokens.

## Install

```sh
npm install @symmetry-hq/overpass
```

Peer dependencies: `@solana/web3.js`, `@solana/spl-token`.

## Supported protocols

| Protocol | Deposit | Withdraw |
|---|---|---|
| Kamino Lend (klend) | ✓ | ✓ |
| Save (Solend fork) | ✓ | ✓ |
| Kamino Vault (kvault) | ✓ | ✓ |
| MarginFi v2 | ✓ | ✓ |
| Lulo (FlexLend v2, protected pools) | ✓ | ✓ |

## Quick start

### Build a deposit/withdraw transaction

```ts
import { buildOverpassSwap } from "@symmetry-hq/overpass";
import { Connection, PublicKey } from "@solana/web3.js";

const connection = new Connection("https://api.mainnet-beta.solana.com");

const { ixs, lookupTables, suggestedComputeUnits } = await buildOverpassSwap(connection, {
  user: walletPublicKey,
  wrapperMint: new PublicKey("..."),
  amount: 1_000_000n,        // 1 USDC for a 6-decimal underlying
  direction: "deposit",       // or "withdraw"
  minOut: 0n,                 // slippage protection
});
```

### Quote without building a transaction

```ts
import { Overpass, OverpassLoader } from "@symmetry-hq/overpass";

const ov = Overpass.fromAccount(wrapperVaultPda, accountData);
const loader = new OverpassLoader();
await loader.refreshMany(connection, [ov]);

const ctx = ov.getQuoteContext(currentSlot, unixTimestamp);
const quote = ov.quote({ inAmount: 1_000_000n, swapMode: SwapMode.ExactIn, ... });
console.log(quote.outAmount, quote.warnings);
```

### Discover all wrappers

```ts
import { OverpassLoader, fetchAllPools } from "@symmetry-hq/overpass";

const loader = new OverpassLoader();
const wrappers = await loader.loadAll(connection, OVERPASS_PROGRAM_ID);
const pools = await fetchAllPools(connection);
```

### Create a wrapper with wallet-first signing

```ts
const result = await createWrapper(connection, {
  creator: walletPublicKey,
  source: new PublicKey("SOURCE_POOL_ADDRESS"),
  underlyingMint: new PublicKey("UNDERLYING_MINT"),
  name: "Wrapped USDC",
  symbol: "wUSDC",
  uri: "ipfs://...",
  creatorDepositFeeBps: 0,
  deferMintSignature: true,
});

const signed = await wallet.signTransaction(result.tx);
result.signWrapperMint(signed);
const sig = await connection.sendTransaction(signed);
```

## Status

Active development. Mainnet program ID: `WRAPdXmxrH37RKUbH1QMnYrKdNe8w4Kz44t1cXmYeum`.

Account-meta layout, byte offsets, and math are byte-exact verified against the upstream source protocols.

## License

MIT
