torchsdk 4.0.1 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +1 -6
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +7 -7
- package/dist/constants.js.map +1 -1
- package/dist/ephemeral.d.ts +3 -3
- package/dist/ephemeral.d.ts.map +1 -1
- package/dist/ephemeral.js +6 -1
- package/dist/ephemeral.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/quotes.d.ts +5 -0
- package/dist/quotes.d.ts.map +1 -1
- package/dist/quotes.js +79 -2
- package/dist/quotes.js.map +1 -1
- package/dist/transactions.d.ts +26 -13
- package/dist/transactions.d.ts.map +1 -1
- package/dist/transactions.js +246 -176
- package/dist/transactions.js.map +1 -1
- package/dist/types.d.ts +27 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/readme.md +99 -295
package/readme.md
CHANGED
|
@@ -1,370 +1,174 @@
|
|
|
1
1
|
# Torch SDK
|
|
2
2
|
|
|
3
|
-
TypeScript SDK for [Torch Market](https://torch.market)
|
|
3
|
+
TypeScript SDK for [Torch Market](https://torch.market).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Every token launched on Torch gets a bonding curve for price discovery, a community treasury funded by trading, and a lending market that activates after migration to Raydium. The SDK is the primary way to interact with the protocol — it builds transactions locally from the on-chain Anchor IDL, reads all state directly from Solana RPC, and handles routing between bonding curves and DEX pools automatically. No API server. No middleman.
|
|
6
6
|
|
|
7
|
-
##
|
|
8
|
-
|
|
9
|
-
for in depth sdk design, refer to [design.md](./design.md).
|
|
10
|
-
|
|
11
|
-
## Audit
|
|
12
|
-
|
|
13
|
-
for sdk audit, refer to [audit.md](./audit.md).
|
|
14
|
-
|
|
15
|
-
## Versioning
|
|
16
|
-
|
|
17
|
-
SDK version tracks the on-chain program IDL version.
|
|
18
|
-
|
|
19
|
-
## v4.0.0 + v4.0.1
|
|
20
|
-
|
|
21
|
-
- **V4.0 Simplified Tiers & Reduced Fees** — Removed 50 SOL (Spark) tier from token creation (existing tokens unaffected). Treasury SOL rate reduced from 20%→5% to 12.5%→4%. Protocol fee reduced from 1% to 0.5%. Constants-only change — no new instructions, no state migration. IDL updated to v4.0.0. 48 Kani proofs all passing.
|
|
22
|
-
|
|
23
|
-
## v3.7.35
|
|
24
|
-
|
|
25
|
-
- **`getBorrowQuote`** — New quote function computes maximum borrowable SOL for a given collateral amount on a migrated token. Returns the binding constraint across LTV cap, pool available liquidity, and per-user cap — plus full breakdown of all three limits. Accounts for Token-2022 transfer fee (4 bps). New type: `BorrowQuoteResult`.
|
|
26
|
-
- **`getMessages` post-migration support** — Now fetches memos from both bonding curve transactions and Raydium pool transactions. Also checks inner instructions (for vault swap memos). Results merged, deduped by signature, and sorted newest-first. No signature or return type changes.
|
|
27
|
-
- **E2E test updates** — Borrow sections in `test_e2e.ts` and `test_devnet_e2e.ts` now use `getBorrowQuote` instead of inline constraint calculations.
|
|
28
|
-
|
|
29
|
-
## v3.7.32
|
|
30
|
-
|
|
31
|
-
- **Post Migration Accounts** export helper.
|
|
32
|
-
|
|
33
|
-
## v3.7.31
|
|
34
|
-
|
|
35
|
-
- **Vault Swap Messages** add token memos to vault swaps post migration.
|
|
36
|
-
|
|
37
|
-
### v3.7.30
|
|
38
|
-
|
|
39
|
-
- **V35 Community Token Option** — Token creators can now choose between **community token** (default: 0% creator fees, entire 0.04% transfer fee proceeds go to treasury) or **creator token** (opt-in: 0.2%→1% bonding SOL share + 15% post-migration fee swap share). Choice is permanent and set at creation via `community_token` parameter on `buildCreateTokenTransaction`. New tokens default to community mode. No new instructions, no new accounts, no state layout changes. Stars unaffected — community token creators can still receive star payouts. IDL updated to v3.7.10. 46 Kani proofs (2 new: community token buy conservation, community token swap fees conservation).
|
|
40
|
-
|
|
41
|
-
### v3.7.29
|
|
42
|
-
|
|
43
|
-
- **V36 Lending Cap** new lending cap on token treasuries per user based on collateral size.
|
|
44
|
-
|
|
45
|
-
### v3.7.24 + v3.7.25
|
|
46
|
-
|
|
47
|
-
- **V35 Optional Account Param On Sells** on bond non-voting accounts can sell.
|
|
48
|
-
|
|
49
|
-
### v3.7.23
|
|
50
|
-
|
|
51
|
-
- **V34 Creator Fee Structure** creator rewards have been introduced, with pre and post migration rewards designed to reward good creators.
|
|
52
|
-
|
|
53
|
-
### v3.7.22
|
|
7
|
+
## Install
|
|
54
8
|
|
|
55
|
-
|
|
56
|
-
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add torchsdk
|
|
11
|
+
```
|
|
57
12
|
|
|
58
|
-
|
|
13
|
+
Peer dependency: `@solana/web3.js ^1.98.0`
|
|
59
14
|
|
|
60
|
-
|
|
15
|
+
## How It Works
|
|
61
16
|
|
|
62
|
-
|
|
17
|
+
```
|
|
18
|
+
1. Get a quote → getBuyQuote / getSellQuote
|
|
19
|
+
2. Build a tx → buildBuyTransaction / buildSellTransaction
|
|
20
|
+
3. Sign and send → your wallet / keypair
|
|
21
|
+
```
|
|
63
22
|
|
|
64
|
-
|
|
23
|
+
The SDK is VersionedTransaction-native. All transaction builders return v0 transactions compressed with Address Lookup Tables for smaller tx sizes and more headroom.
|
|
65
24
|
|
|
66
|
-
|
|
25
|
+
| Network | ALT Address |
|
|
26
|
+
|---------|-------------|
|
|
27
|
+
| Mainnet | `GQzbU32oN3znZa3uWFKGc9cBukpQbYYJSirKstMuFF3i` |
|
|
28
|
+
| Devnet | `3umSStZSLJNk5QstxeQB12a2MSDh4o8RgSzT76gigJ8P` |
|
|
67
29
|
|
|
68
|
-
|
|
30
|
+
Quotes work across both bonding curve and DEX — the `source` field tells you which. Pass the quote into the transaction builder and the SDK handles routing and slippage protection automatically.
|
|
69
31
|
|
|
70
|
-
|
|
32
|
+
```typescript
|
|
33
|
+
import { Connection } from "@solana/web3.js";
|
|
34
|
+
import { getBuyQuote, buildBuyTransaction } from "torchsdk";
|
|
71
35
|
|
|
72
|
-
|
|
36
|
+
const connection = new Connection("https://api.mainnet-beta.solana.com");
|
|
73
37
|
|
|
74
|
-
|
|
38
|
+
// Works on any token — bonding or migrated
|
|
39
|
+
const quote = await getBuyQuote(connection, mint, 100_000_000); // 0.1 SOL
|
|
40
|
+
console.log(`${quote.tokens_to_user / 1e6} tokens, source: ${quote.source}`);
|
|
75
41
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
42
|
+
const { transaction } = await buildBuyTransaction(connection, {
|
|
43
|
+
mint,
|
|
44
|
+
buyer: agentWallet,
|
|
45
|
+
amount_sol: 100_000_000,
|
|
46
|
+
slippage_bps: 500, // 5%
|
|
47
|
+
vault: vaultCreator,
|
|
48
|
+
quote, // drives routing + slippage protection
|
|
49
|
+
});
|
|
50
|
+
// sign and send — VersionedTransaction, ALT-compressed
|
|
51
|
+
```
|
|
79
52
|
|
|
53
|
+
## Torch Vault
|
|
80
54
|
|
|
81
|
-
|
|
82
|
-
<summary>Older versions (v3.2.0 – v3.7.4)</summary>
|
|
55
|
+
The vault is a full-custody on-chain escrow for AI agents. It holds all SOL and tokens. The agent wallet is a disposable controller that signs transactions but holds nothing of value.
|
|
83
56
|
|
|
84
|
-
|
|
57
|
+
```
|
|
58
|
+
Human (hardware wallet) Agent (disposable, ~0.01 SOL for gas)
|
|
59
|
+
├── createVault() ├── buy(vault=creator) → vault pays
|
|
60
|
+
├── depositVault(5 SOL) ├── sell(vault=creator) → SOL returns to vault
|
|
61
|
+
├── linkWallet(agentPubkey) ├── borrow(vault=creator) → SOL to vault
|
|
62
|
+
├── withdrawVault() ├── repay(vault=creator) → collateral returns
|
|
63
|
+
└── unlinkWallet(agent) └── star(vault=creator) → vault pays
|
|
64
|
+
```
|
|
85
65
|
|
|
86
|
-
|
|
66
|
+
Seven guarantees: full custody, closed economic loop, authority separation, one link per wallet, permissionless deposits, instant revocation, authority-only withdrawals.
|
|
87
67
|
|
|
88
|
-
##
|
|
68
|
+
## Operations
|
|
89
69
|
|
|
90
|
-
###
|
|
70
|
+
### Queries (no signing)
|
|
91
71
|
|
|
92
72
|
| Function | Description |
|
|
93
73
|
|----------|-------------|
|
|
94
74
|
| `getTokens(connection, params?)` | List tokens with filtering and sorting |
|
|
95
|
-
| `getToken(connection, mint)` |
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `getLoanPosition(connection, mint, wallet)` |
|
|
101
|
-
| `getAllLoanPositions(connection, mint)` |
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
| Function | Description |
|
|
106
|
-
|----------|-------------|
|
|
107
|
-
| `getVault(connection, creator)` | Get vault state by creator pubkey |
|
|
108
|
-
| `getVaultForWallet(connection, wallet)` | Find vault by any linked wallet (reverse lookup) |
|
|
109
|
-
| `getVaultWalletLink(connection, wallet)` | Get link state (which vault, when linked) |
|
|
75
|
+
| `getToken(connection, mint)` | Full token details (price, treasury, votes, status) |
|
|
76
|
+
| `getTokenMetadata(connection, mint)` | On-chain Token-2022 metadata |
|
|
77
|
+
| `getHolders(connection, mint)` | Token holder list |
|
|
78
|
+
| `getMessages(connection, mint, limit?, opts?)` | Trade-bundled memos. `{ enrich: true }` adds SAID verification |
|
|
79
|
+
| `getLendingInfo(connection, mint)` | Lending parameters for migrated tokens |
|
|
80
|
+
| `getLoanPosition(connection, mint, wallet)` | Single loan position |
|
|
81
|
+
| `getAllLoanPositions(connection, mint)` | All positions sorted by liquidation risk |
|
|
82
|
+
| `getVault(connection, creator)` | Vault state |
|
|
83
|
+
| `getVaultForWallet(connection, wallet)` | Reverse lookup — find vault by linked wallet |
|
|
84
|
+
| `getVaultWalletLink(connection, wallet)` | Link state for a wallet |
|
|
110
85
|
|
|
111
86
|
### Quotes
|
|
112
87
|
|
|
113
88
|
| Function | Description |
|
|
114
89
|
|----------|-------------|
|
|
115
|
-
| `getBuyQuote(connection, mint, solAmount)` |
|
|
116
|
-
| `getSellQuote(connection, mint, tokenAmount)` |
|
|
117
|
-
| `getBorrowQuote(connection, mint, collateralAmount)` | Max borrowable SOL
|
|
90
|
+
| `getBuyQuote(connection, mint, solAmount)` | Expected tokens, fees, price impact. Returns `source: 'bonding' \| 'dex'` |
|
|
91
|
+
| `getSellQuote(connection, mint, tokenAmount)` | Expected SOL, price impact. Returns `source: 'bonding' \| 'dex'` |
|
|
92
|
+
| `getBorrowQuote(connection, mint, collateralAmount)` | Max borrowable SOL with breakdown of constraints |
|
|
118
93
|
|
|
119
|
-
###
|
|
94
|
+
### Trading
|
|
120
95
|
|
|
121
|
-
All builders return `{ transaction:
|
|
122
|
-
|
|
123
|
-
#### Trading
|
|
96
|
+
All builders return `{ transaction: VersionedTransaction, message: string }`.
|
|
124
97
|
|
|
125
98
|
| Function | Description |
|
|
126
99
|
|----------|-------------|
|
|
127
|
-
| `buildBuyTransaction(connection, params)` | Buy tokens
|
|
128
|
-
| `buildDirectBuyTransaction(connection, params)` | Buy
|
|
129
|
-
| `buildSellTransaction(connection, params)` | Sell tokens
|
|
130
|
-
| `
|
|
131
|
-
| `
|
|
132
|
-
| `
|
|
133
|
-
| `buildStarTransaction(connection, params)` | Star a token (0.05 SOL, vault-routed) |
|
|
100
|
+
| `buildBuyTransaction(connection, params)` | Buy tokens via vault. Auto-routes bonding curve or DEX based on quote |
|
|
101
|
+
| `buildDirectBuyTransaction(connection, params)` | Buy without vault (human wallets only) |
|
|
102
|
+
| `buildSellTransaction(connection, params)` | Sell tokens via vault. Auto-routes bonding curve or DEX based on quote |
|
|
103
|
+
| `buildCreateTokenTransaction(connection, params)` | Launch a new token with bonding curve + treasury |
|
|
104
|
+
| `buildStarTransaction(connection, params)` | Star a token (0.02 SOL, sybil-resistant) |
|
|
105
|
+
| `buildMigrateTransaction(connection, params)` | Migrate bonding-complete token to Raydium (permissionless) |
|
|
134
106
|
|
|
135
|
-
|
|
107
|
+
### Vault Management
|
|
136
108
|
|
|
137
109
|
| Function | Signer | Description |
|
|
138
110
|
|----------|--------|-------------|
|
|
139
111
|
| `buildCreateVaultTransaction` | creator | Create vault + auto-link creator |
|
|
140
|
-
| `buildDepositVaultTransaction` |
|
|
112
|
+
| `buildDepositVaultTransaction` | anyone | Deposit SOL (permissionless) |
|
|
141
113
|
| `buildWithdrawVaultTransaction` | authority | Withdraw SOL |
|
|
142
|
-
| `buildWithdrawTokensTransaction` | authority | Withdraw tokens from vault
|
|
143
|
-
| `buildLinkWalletTransaction` | authority | Link a wallet
|
|
144
|
-
| `buildUnlinkWalletTransaction` | authority |
|
|
114
|
+
| `buildWithdrawTokensTransaction` | authority | Withdraw tokens from vault |
|
|
115
|
+
| `buildLinkWalletTransaction` | authority | Link a controller wallet |
|
|
116
|
+
| `buildUnlinkWalletTransaction` | authority | Revoke controller access |
|
|
145
117
|
| `buildTransferAuthorityTransaction` | authority | Transfer admin control |
|
|
146
118
|
|
|
147
|
-
|
|
119
|
+
### Lending (post-migration)
|
|
148
120
|
|
|
149
121
|
| Function | Description |
|
|
150
122
|
|----------|-------------|
|
|
151
123
|
| `buildBorrowTransaction(connection, params)` | Borrow SOL against token collateral (vault-routed) |
|
|
152
|
-
| `buildRepayTransaction(connection, params)` | Repay
|
|
153
|
-
| `buildLiquidateTransaction(connection, params)` | Liquidate underwater position (
|
|
154
|
-
| `buildClaimProtocolRewardsTransaction(connection, params)` | Claim
|
|
124
|
+
| `buildRepayTransaction(connection, params)` | Repay debt (vault-routed) |
|
|
125
|
+
| `buildLiquidateTransaction(connection, params)` | Liquidate underwater position (>65% LTV) |
|
|
126
|
+
| `buildClaimProtocolRewardsTransaction(connection, params)` | Claim epoch trading rewards (vault-routed) |
|
|
155
127
|
|
|
156
|
-
|
|
128
|
+
### Treasury Cranks (permissionless)
|
|
157
129
|
|
|
158
130
|
| Function | Description |
|
|
159
131
|
|----------|-------------|
|
|
160
|
-
| `buildHarvestFeesTransaction(connection, params)` | Harvest Token-2022 transfer fees into treasury
|
|
161
|
-
| `buildSwapFeesToSolTransaction(connection, params)` | Swap harvested
|
|
132
|
+
| `buildHarvestFeesTransaction(connection, params)` | Harvest Token-2022 transfer fees into treasury |
|
|
133
|
+
| `buildSwapFeesToSolTransaction(connection, params)` | Swap harvested tokens to SOL via Raydium |
|
|
134
|
+
| `buildReclaimFailedTokenTransaction(connection, params)` | Reclaim tokens inactive 7+ days |
|
|
162
135
|
|
|
163
136
|
### SAID Protocol
|
|
164
137
|
|
|
165
138
|
| Function | Description |
|
|
166
139
|
|----------|-------------|
|
|
167
|
-
| `verifySaid(wallet)` | Check
|
|
168
|
-
| `confirmTransaction(connection,
|
|
169
|
-
|
|
170
|
-
## Install
|
|
171
|
-
|
|
172
|
-
```bash
|
|
173
|
-
pnpm add torchsdk
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
Peer dependency: `@solana/web3.js ^1.98.0`
|
|
177
|
-
|
|
178
|
-
## Quick Start
|
|
179
|
-
|
|
180
|
-
```typescript
|
|
181
|
-
import { Connection } from "@solana/web3.js";
|
|
182
|
-
import {
|
|
183
|
-
getTokens,
|
|
184
|
-
getToken,
|
|
185
|
-
buildBuyTransaction,
|
|
186
|
-
buildDirectBuyTransaction,
|
|
187
|
-
buildSellTransaction,
|
|
188
|
-
buildCreateVaultTransaction,
|
|
189
|
-
buildDepositVaultTransaction,
|
|
190
|
-
buildLinkWalletTransaction,
|
|
191
|
-
getVault,
|
|
192
|
-
confirmTransaction,
|
|
193
|
-
} from "torchsdk";
|
|
194
|
-
|
|
195
|
-
const connection = new Connection("https://api.mainnet-beta.solana.com");
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### Set Up a Vault
|
|
199
|
-
|
|
200
|
-
```typescript
|
|
201
|
-
// 1. Create vault (user wallet)
|
|
202
|
-
const { transaction: createTx } = await buildCreateVaultTransaction(connection, {
|
|
203
|
-
creator: userWallet,
|
|
204
|
-
});
|
|
205
|
-
// sign and send createTx...
|
|
206
|
-
|
|
207
|
-
// 2. Deposit SOL
|
|
208
|
-
const { transaction: depositTx } = await buildDepositVaultTransaction(connection, {
|
|
209
|
-
depositor: userWallet,
|
|
210
|
-
vault_creator: userWallet,
|
|
211
|
-
amount_sol: 5_000_000_000, // 5 SOL
|
|
212
|
-
});
|
|
213
|
-
// sign and send depositTx...
|
|
214
|
-
|
|
215
|
-
// 3. Link an agent wallet
|
|
216
|
-
const { transaction: linkTx } = await buildLinkWalletTransaction(connection, {
|
|
217
|
-
authority: userWallet,
|
|
218
|
-
vault_creator: userWallet,
|
|
219
|
-
wallet_to_link: agentWallet,
|
|
220
|
-
});
|
|
221
|
-
// sign and send linkTx...
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### Trade with Vault
|
|
225
|
-
|
|
226
|
-
```typescript
|
|
227
|
-
// Agent buys tokens — vault pays
|
|
228
|
-
const { transaction, message } = await buildBuyTransaction(connection, {
|
|
229
|
-
mint: "TOKEN_MINT_ADDRESS",
|
|
230
|
-
buyer: agentWallet,
|
|
231
|
-
amount_sol: 100_000_000, // 0.1 SOL (in lamports)
|
|
232
|
-
slippage_bps: 500, // 5% slippage
|
|
233
|
-
vote: "burn", // governance vote on first buy
|
|
234
|
-
vault: userWallet, // vault creator key → vault pays
|
|
235
|
-
});
|
|
236
|
-
// agent signs and sends...
|
|
237
|
-
|
|
238
|
-
// Check vault balance
|
|
239
|
-
const vault = await getVault(connection, userWallet);
|
|
240
|
-
console.log(`Vault: ${vault.sol_balance} SOL, ${vault.linked_wallets} wallets`);
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
### Direct Buy (No Vault — Human Use Only)
|
|
244
|
-
|
|
245
|
-
```typescript
|
|
246
|
-
// Buyer pays directly from their wallet — no vault safety
|
|
247
|
-
const { transaction } = await buildDirectBuyTransaction(connection, {
|
|
248
|
-
mint: "TOKEN_MINT_ADDRESS",
|
|
249
|
-
buyer: walletAddress,
|
|
250
|
-
amount_sol: 100_000_000,
|
|
251
|
-
slippage_bps: 500,
|
|
252
|
-
vote: "burn",
|
|
253
|
-
});
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
## Transaction Params
|
|
257
|
-
|
|
258
|
-
```typescript
|
|
259
|
-
// Buy (vault-funded — recommended for agents)
|
|
260
|
-
{
|
|
261
|
-
mint: string,
|
|
262
|
-
buyer: string,
|
|
263
|
-
amount_sol: number, // lamports
|
|
264
|
-
slippage_bps?: number, // default 100 (1%)
|
|
265
|
-
vote?: "burn" | "return", // required on first buy
|
|
266
|
-
message?: string, // optional SPL Memo (max 500 chars)
|
|
267
|
-
vault: string, // vault creator pubkey (required)
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// Direct Buy (no vault — human use only)
|
|
271
|
-
{
|
|
272
|
-
mint: string,
|
|
273
|
-
buyer: string,
|
|
274
|
-
amount_sol: number, // lamports
|
|
275
|
-
slippage_bps?: number, // default 100 (1%)
|
|
276
|
-
vote?: "burn" | "return", // required on first buy
|
|
277
|
-
message?: string, // optional SPL Memo (max 500 chars)
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// Sell
|
|
281
|
-
{
|
|
282
|
-
mint: string,
|
|
283
|
-
seller: string,
|
|
284
|
-
amount_tokens: number, // raw units (with decimals)
|
|
285
|
-
slippage_bps?: number,
|
|
286
|
-
message?: string,
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// Create Token
|
|
290
|
-
{ creator: string, name: string, symbol: string, metadata_uri: string, sol_target?: number, community_token?: boolean }
|
|
291
|
-
// sol_target: 100_000_000_000 (Flame), 200_000_000_000 (Torch, default). Spark (50 SOL) removed in V4.0.
|
|
292
|
-
// community_token: true (default) = 0% creator fees, false = creator gets 0.2%→1% bonding + 15% fee swap
|
|
293
|
-
|
|
294
|
-
// Star
|
|
295
|
-
{ mint: string, user: string }
|
|
296
|
-
|
|
297
|
-
// Vault
|
|
298
|
-
{ creator: string } // create
|
|
299
|
-
{ depositor: string, vault_creator: string, amount_sol: number } // deposit
|
|
300
|
-
{ authority: string, vault_creator: string, amount_sol: number } // withdraw
|
|
301
|
-
{ authority: string, vault_creator: string, wallet_to_link: string } // link
|
|
302
|
-
{ authority: string, vault_creator: string, wallet_to_unlink: string } // unlink
|
|
303
|
-
{ authority: string, vault_creator: string, new_authority: string } // transfer
|
|
304
|
-
|
|
305
|
-
// Vault Swap (DEX trading for migrated tokens)
|
|
306
|
-
{ mint: string, signer: string, vault_creator: string, amount_in: number, minimum_amount_out: number, is_buy: boolean }
|
|
307
|
-
|
|
308
|
-
// Lending (all support optional vault?: string for vault routing)
|
|
309
|
-
{ mint: string, borrower: string, collateral_amount: number, sol_to_borrow: number, vault?: string }
|
|
310
|
-
{ mint: string, borrower: string, sol_amount: number, vault?: string }
|
|
311
|
-
{ mint: string, liquidator: string, borrower: string, vault?: string }
|
|
312
|
-
|
|
313
|
-
// Migrate (permissionless — anyone can trigger for bonding-complete tokens, treasury reimburses payer)
|
|
314
|
-
{ mint: string, payer: string }
|
|
315
|
-
|
|
316
|
-
// Swap Fees to SOL (permissionless — bundles harvest + swap, treasury reimburses)
|
|
317
|
-
{ mint: string, payer: string, minimum_amount_out?: number, harvest?: boolean, sources?: string[] }
|
|
318
|
-
|
|
319
|
-
// Rewards (optional vault routing)
|
|
320
|
-
{ user: string, vault?: string } // claim protocol rewards
|
|
321
|
-
```
|
|
140
|
+
| `verifySaid(wallet)` | Check verification status and trust tier |
|
|
141
|
+
| `confirmTransaction(connection, sig, wallet)` | Report tx for reputation tracking |
|
|
322
142
|
|
|
323
143
|
## Network Configuration
|
|
324
144
|
|
|
325
|
-
The SDK detects the network at runtime. No rebuild needed to switch between mainnet and devnet.
|
|
326
|
-
|
|
327
145
|
```typescript
|
|
328
|
-
// Browser
|
|
146
|
+
// Browser
|
|
329
147
|
(globalThis as any).__TORCH_NETWORK__ = 'devnet'
|
|
330
148
|
|
|
331
|
-
// Node.js
|
|
149
|
+
// Node.js
|
|
332
150
|
// TORCH_NETWORK=devnet npx tsx your-script.ts
|
|
333
151
|
```
|
|
334
152
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
## Vault Safety Model
|
|
338
|
-
|
|
339
|
-
The Torch Vault provides protocol-level full custody for AI agent interaction:
|
|
340
|
-
|
|
341
|
-
| Property | Guarantee |
|
|
342
|
-
|----------|-----------|
|
|
343
|
-
| **Full custody** | Vault holds all SOL and all tokens. Controller wallet holds nothing. |
|
|
344
|
-
| **Closed loop** | All operations return value to the vault. No leakage to controller. |
|
|
345
|
-
| **Authority separation** | Creator (immutable PDA seed) vs Authority (transferable admin). Agent wallets get *usage* rights, not ownership. |
|
|
346
|
-
| **One link per wallet** | A wallet can only belong to one vault. PDA uniqueness enforces this. |
|
|
347
|
-
| **Permissionless deposits** | Anyone can top up any vault. Hardware wallet deposits, agent spends. |
|
|
348
|
-
| **Instant revocation** | Authority can unlink a wallet at any time. |
|
|
349
|
-
| **Authority-only withdrawals** | Only the vault authority can withdraw SOL or tokens. Controllers cannot extract value. |
|
|
350
|
-
|
|
351
|
-
## Running the E2E Test
|
|
352
|
-
|
|
353
|
-
The test runs the full lifecycle against a [Surfpool](https://github.com/txtx/surfpool) mainnet fork.
|
|
153
|
+
## Testing
|
|
354
154
|
|
|
355
155
|
```bash
|
|
356
|
-
#
|
|
156
|
+
# Mainnet fork (Surfpool)
|
|
357
157
|
surfpool start --network mainnet --no-tui
|
|
358
|
-
|
|
359
|
-
# Run the test
|
|
360
158
|
npx tsx tests/test_e2e.ts
|
|
361
|
-
```
|
|
362
159
|
|
|
363
|
-
|
|
160
|
+
# Devnet
|
|
161
|
+
TORCH_NETWORK=devnet npx tsx tests/test_devnet_e2e.ts
|
|
162
|
+
```
|
|
364
163
|
|
|
365
|
-
|
|
164
|
+
## Links
|
|
366
165
|
|
|
367
|
-
|
|
166
|
+
- [torch.market](https://torch.market)
|
|
167
|
+
- [SDK source](https://github.com/mrsirg97-rgb/torchsdk)
|
|
168
|
+
- [npm](https://www.npmjs.com/package/torchsdk)
|
|
169
|
+
- [Design doc](./design.md)
|
|
170
|
+
- [SDK audit](./audit.md)
|
|
171
|
+
- Program ID: `8hbUkonssSEEtkqzwM7ZcZrD9evacM92TcWSooVF4BeT`
|
|
368
172
|
|
|
369
173
|
## License
|
|
370
174
|
|