@t2000/sdk 0.19.22 → 0.19.24
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 +2 -2
- package/dist/adapters/index.cjs +6 -2
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.js +6 -2
- package/dist/adapters/index.js.map +1 -1
- package/dist/browser.js +2 -0
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +40 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +40 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ The complete TypeScript SDK for AI agent bank accounts on Sui. Send USDC, earn y
|
|
|
5
5
|
[](https://www.npmjs.com/package/@t2000/sdk)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
-
**[Website](https://t2000.ai)** · **[GitHub](https://github.com/mission69b/t2000)** · **[CLI](https://www.npmjs.com/package/@t2000/cli)** · **[MPP](https://www.npmjs.com/package/@
|
|
8
|
+
**[Website](https://t2000.ai)** · **[GitHub](https://github.com/mission69b/t2000)** · **[CLI](https://www.npmjs.com/package/@t2000/cli)** · **[MPP](https://www.npmjs.com/package/@mppsui/mpp)** · **[MCP](https://www.npmjs.com/package/@t2000/mcp)**
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
@@ -313,7 +313,7 @@ formatAssetAmount('SUI', 105.26); // "105.260000000" (9 decimals)
|
|
|
313
313
|
|
|
314
314
|
### Advanced: Exposed Internals
|
|
315
315
|
|
|
316
|
-
For integrations (like `@
|
|
316
|
+
For integrations (like `@mppsui/mpp`), the agent exposes:
|
|
317
317
|
|
|
318
318
|
```typescript
|
|
319
319
|
agent.suiClient; // SuiJsonRpcClient instance
|
package/dist/adapters/index.cjs
CHANGED
|
@@ -588,12 +588,16 @@ async function buildRepayTx(client, address, amount, options = {}) {
|
|
|
588
588
|
const asset = options.asset ?? "USDC";
|
|
589
589
|
const assetInfo = resolveAssetInfo(asset);
|
|
590
590
|
const coins = await fetchCoins(client, address, assetInfo.type);
|
|
591
|
-
if (coins.length === 0) throw new T2000Error("INSUFFICIENT_BALANCE", `No ${assetInfo.displayName} coins to repay with
|
|
591
|
+
if (coins.length === 0) throw new T2000Error("INSUFFICIENT_BALANCE", `No ${assetInfo.displayName} coins to repay with. Withdraw some savings first to get cash.`);
|
|
592
592
|
const totalBalance = coins.reduce((sum, c) => sum + BigInt(c.balance), 0n);
|
|
593
|
+
const rawRequested = Number(stableToRaw(amount, assetInfo.decimals));
|
|
594
|
+
if (Number(totalBalance) < rawRequested && Number(totalBalance) < 1e3) {
|
|
595
|
+
throw new T2000Error("INSUFFICIENT_BALANCE", `Not enough ${assetInfo.displayName} to repay (need $${amount.toFixed(2)}, wallet has ~$${(Number(totalBalance) / 10 ** assetInfo.decimals).toFixed(4)}). Withdraw some savings first.`);
|
|
596
|
+
}
|
|
593
597
|
const tx = new transactions.Transaction();
|
|
594
598
|
tx.setSender(address);
|
|
595
599
|
const coinObj = mergeCoins(tx, coins);
|
|
596
|
-
const rawAmount = Math.min(
|
|
600
|
+
const rawAmount = Math.min(rawRequested, Number(totalBalance));
|
|
597
601
|
const [repayCoin] = tx.splitCoins(coinObj, [rawAmount]);
|
|
598
602
|
await refreshOracle(tx, client, address, {
|
|
599
603
|
skipPythUpdate: options.sponsored,
|