@t2000/sdk 0.56.0 → 1.0.0

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/README.md CHANGED
@@ -53,14 +53,12 @@ await agent.withdraw({ amount: 25 });
53
53
 
54
54
  ### `T2000.init(options)` — Create a new wallet
55
55
 
56
- Creates a new bank account (generates keypair, encrypts, and saves to disk).
56
+ Creates a new bank account (generates keypair, encrypts, and saves to disk). Fund the returned address with a small amount of SUI for gas (Mercuryo: https://exchange.mercuryo.io/?widget_id=89960d1a-8db7-49e5-8823-4c5e01c1cea2) plus USDC to transact.
57
57
 
58
58
  ```typescript
59
- const { agent, address, sponsored } = await T2000.init({
60
- pin: 'my-secret', // Required — encrypts the key
59
+ const { agent, address } = await T2000.init({
60
+ pin: 'my-secret', // Required — encrypts the key
61
61
  keyPath: '~/.t2000/wallet.key', // Optional — custom key file path
62
- name: 'my-agent', // Optional — agent name for sponsor registration
63
- sponsored: true, // Optional — register with gas station (default: true)
64
62
  });
65
63
  ```
66
64
 
@@ -193,14 +191,6 @@ agent.on('yield', (e) => {
193
191
  console.log(`Earned: $${e.earned}, total: $${e.total}`);
194
192
  });
195
193
 
196
- agent.on('gasAutoTopUp', (e) => {
197
- console.log(`Auto-topped up gas: $${e.usdcSpent} USDC → ${e.suiReceived} SUI`);
198
- });
199
-
200
- agent.on('gasStationFallback', (e) => {
201
- console.log(`Gas station fallback: ${e.reason}`);
202
- });
203
-
204
194
  agent.on('error', (e) => {
205
195
  console.error(`Error: ${e.code} — ${e.message}`);
206
196
  });
@@ -236,20 +226,13 @@ agent.suiClient; // SuiJsonRpcClient instance
236
226
  agent.signer; // Ed25519Keypair
237
227
  ```
238
228
 
239
- ## Gas Abstraction
240
-
241
- Every operation (send, save, borrow, repay, withdraw) routes through a 3-step gas resolution chain via `executeWithGas()`. The agent never fails due to low gas if it has USDC or the Gas Station is reachable:
229
+ ## Gas
242
230
 
243
- | Step | Strategy | Condition | How it works |
244
- |------|----------|-----------|--------------|
245
- | 1 | **Self-funded** | SUI ≥ 0.05 | Uses the agent's own SUI for gas |
246
- | 2 | **Auto-topup** | SUI < 0.05, USDC ≥ $2 | Converts $1 USDC → SUI (currently disabled, falls back to step 3) |
247
- | 3 | **Sponsored** | Steps 1 & 2 fail | Gas Station sponsors the full transaction |
248
- | 4 | **Error** | All fail | Throws `INSUFFICIENT_GAS` |
231
+ Every transaction is self-funded by the agent's wallet. Keep at least ~0.05 SUI on hand. If gas runs out the SDK throws `INSUFFICIENT_GAS` — top up via Mercuryo (https://exchange.mercuryo.io/?widget_id=89960d1a-8db7-49e5-8823-4c5e01c1cea2) or any Sui exchange.
249
232
 
250
- Every transaction result includes a `gasMethod` field (`'self-funded'` | `'auto-topup'` | `'sponsored'`) indicating which strategy was used.
233
+ > **Audric web app exception:** Audric web users transact under Enoki gas sponsorship (zkLogin), so `INSUFFICIENT_GAS` is not a user-facing concern there. The SDK itself is sponsorship-agnostic — sponsorship is wired in at the host layer (Audric web), not inside `@t2000/sdk`.
251
234
 
252
- **Architecture:** Each protocol operation (NAVI, send) exposes both `buildXxxTx()` (standalone transaction) and `addXxxToTx()` (composable PTB) functions. Multi-step flows compose multiple protocol calls into a single atomic PTB. `executeWithGas()` handles execution with the gas fallback chain. If any step within a PTB fails, the entire transaction reverts — no funds left in intermediate states.
235
+ **Architecture:** Each protocol operation (NAVI, send) exposes both `buildXxxTx()` (standalone transaction) and `addXxxToTx()` (composable PTB) functions. Multi-step flows compose multiple protocol calls into a single atomic PTB. If any step within a PTB fails, the entire transaction reverts — no funds left in intermediate states.
253
236
 
254
237
  ## Configuration
255
238
 
@@ -311,7 +294,7 @@ try {
311
294
  }
312
295
  ```
313
296
 
314
- Common error codes: `INSUFFICIENT_BALANCE` · `INVALID_ADDRESS` · `INVALID_AMOUNT` · `INVALID_ASSET` · `HEALTH_FACTOR_TOO_LOW` · `NO_COLLATERAL` · `WALLET_NOT_FOUND` · `WALLET_LOCKED` · `WALLET_EXISTS` · `SIMULATION_FAILED` · `TRANSACTION_FAILED` · `PROTOCOL_PAUSED` · `INSUFFICIENT_GAS` · `WITHDRAW_WOULD_LIQUIDATE` · `AUTO_TOPUP_FAILED` · `GAS_STATION_UNAVAILABLE` · `SWAP_NO_ROUTE` · `SWAP_FAILED`
297
+ Common error codes: `INSUFFICIENT_BALANCE` · `INVALID_ADDRESS` · `INVALID_AMOUNT` · `INVALID_ASSET` · `HEALTH_FACTOR_TOO_LOW` · `NO_COLLATERAL` · `WALLET_NOT_FOUND` · `WALLET_LOCKED` · `WALLET_EXISTS` · `SIMULATION_FAILED` · `TRANSACTION_FAILED` · `PROTOCOL_PAUSED` · `INSUFFICIENT_GAS` · `WITHDRAW_WOULD_LIQUIDATE` · `SWAP_NO_ROUTE` · `SWAP_FAILED`
315
298
 
316
299
  ## Protocol Integration
317
300
 
@@ -1,3 +1,3 @@
1
- export { d as ProtocolDescriptor, e as allDescriptors, n as naviDescriptor } from '../descriptors-DkKhitk_.cjs';
1
+ export { d as ProtocolDescriptor, e as allDescriptors, n as naviDescriptor } from '../descriptors-3YmGYl63.cjs';
2
2
  import '@mysten/sui/transactions';
3
3
  import '@mysten/sui/jsonRpc';
@@ -1,3 +1,3 @@
1
- export { d as ProtocolDescriptor, e as allDescriptors, n as naviDescriptor } from '../descriptors-DkKhitk_.js';
1
+ export { d as ProtocolDescriptor, e as allDescriptors, n as naviDescriptor } from '../descriptors-3YmGYl63.js';
2
2
  import '@mysten/sui/transactions';
3
3
  import '@mysten/sui/jsonRpc';
@@ -4277,8 +4277,6 @@ async function refreshOracle(tx, client, address, options) {
4277
4277
  const oracleOpts = {
4278
4278
  ...sdkOptions(client),
4279
4279
  throws: false,
4280
- // Pyth update uses tx.splitCoins(tx.gas, ...) which is incompatible
4281
- // with sponsored transactions where tx.gas belongs to the sponsor.
4282
4280
  updatePythPriceFeeds: !options?.skipPythUpdate
4283
4281
  };
4284
4282
  await mt(tx, address, pools, oracleOpts);
@@ -4469,7 +4467,7 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
4469
4467
  }
4470
4468
  const tx = new transactions.Transaction();
4471
4469
  tx.setSender(address);
4472
- await refreshOracle(tx, client, address, { skipPythUpdate: options.sponsored });
4470
+ await refreshOracle(tx, client, address);
4473
4471
  try {
4474
4472
  const coin = await Qe(tx, assetInfo.type, rawAmount, sdkOptions(client));
4475
4473
  tx.transferObjects([coin], address);
@@ -4481,7 +4479,6 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
4481
4479
  }
4482
4480
  async function addWithdrawToTx(tx, client, address, amount, options = {}) {
4483
4481
  const asset = options.asset ?? "USDC";
4484
- const sponsored = options.sponsored ?? true;
4485
4482
  const assetInfo = resolveAssetInfo(asset);
4486
4483
  const posResult = await getPositions(client, address);
4487
4484
  const supply = posResult.positions.find(
@@ -4499,7 +4496,7 @@ async function addWithdrawToTx(tx, client, address, amount, options = {}) {
4499
4496
  });
4500
4497
  return { coin, effectiveAmount: 0 };
4501
4498
  }
4502
- await refreshOracle(tx, client, address, { skipPythUpdate: sponsored });
4499
+ await refreshOracle(tx, client, address);
4503
4500
  try {
4504
4501
  const coin = await Qe(tx, assetInfo.type, rawAmount, sdkOptions(client));
4505
4502
  return { coin, effectiveAmount };
@@ -4523,9 +4520,8 @@ async function addSaveToTx(tx, _client, _address, coin, options = {}) {
4523
4520
  }
4524
4521
  async function addRepayToTx(tx, client, address, coin, options = {}) {
4525
4522
  const asset = options.asset ?? "USDC";
4526
- const sponsored = options.sponsored ?? true;
4527
4523
  const assetInfo = resolveAssetInfo(asset);
4528
- await refreshOracle(tx, client, address, { skipPythUpdate: sponsored });
4524
+ await refreshOracle(tx, client, address);
4529
4525
  try {
4530
4526
  await xe(tx, assetInfo.type, coin, { env: "prod" });
4531
4527
  } catch (err) {
@@ -4542,7 +4538,7 @@ async function buildBorrowTx(client, address, amount, options = {}) {
4542
4538
  const rawAmount = Number(stableToRaw(amount, assetInfo.decimals));
4543
4539
  const tx = new transactions.Transaction();
4544
4540
  tx.setSender(address);
4545
- await refreshOracle(tx, client, address, { skipPythUpdate: options.sponsored });
4541
+ await refreshOracle(tx, client, address);
4546
4542
  try {
4547
4543
  const borrowedCoin = await Xe(tx, assetInfo.type, rawAmount, sdkOptions(client));
4548
4544
  if (options.collectFee) {
@@ -4573,10 +4569,7 @@ async function buildRepayTx(client, address, amount, options = {}) {
4573
4569
  const coinObj = mergeCoins(tx, coins);
4574
4570
  const rawAmount = Math.min(rawRequested, Number(totalBalance));
4575
4571
  const [repayCoin] = tx.splitCoins(coinObj, [rawAmount]);
4576
- await refreshOracle(tx, client, address, {
4577
- skipPythUpdate: options.sponsored,
4578
- skipOracle: options.skipOracle
4579
- });
4572
+ await refreshOracle(tx, client, address, { skipOracle: options.skipOracle });
4580
4573
  try {
4581
4574
  await xe(tx, assetInfo.type, repayCoin, {
4582
4575
  ...sdkOptions(client),
@@ -4739,9 +4732,9 @@ var NaviAdapter = class {
4739
4732
  const tx = await buildSaveTx(this.client, address, amount, { ...options, asset: normalized });
4740
4733
  return { tx };
4741
4734
  }
4742
- async buildWithdrawTx(address, amount, asset, options) {
4735
+ async buildWithdrawTx(address, amount, asset) {
4743
4736
  const normalized = normalizeAsset(asset);
4744
- const result = await buildWithdrawTx(this.client, address, amount, { asset: normalized, sponsored: options?.sponsored });
4737
+ const result = await buildWithdrawTx(this.client, address, amount, { asset: normalized });
4745
4738
  return { tx: result.tx, effectiveAmount: result.effectiveAmount };
4746
4739
  }
4747
4740
  async buildBorrowTx(address, amount, asset, options) {
@@ -4753,7 +4746,6 @@ var NaviAdapter = class {
4753
4746
  const normalized = normalizeAsset(asset);
4754
4747
  const tx = await buildRepayTx(this.client, address, amount, {
4755
4748
  asset: normalized,
4756
- sponsored: options?.sponsored,
4757
4749
  skipOracle: options?.skipOracle
4758
4750
  });
4759
4751
  return { tx };