@t2000/sdk 1.0.1 → 1.1.2
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 +15 -15
- package/dist/adapters/descriptors.d.cts +1 -1
- package/dist/adapters/descriptors.d.ts +1 -1
- package/dist/adapters/index.cjs +28 -42
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +7 -9
- package/dist/adapters/index.d.ts +7 -9
- package/dist/adapters/index.js +28 -42
- package/dist/adapters/index.js.map +1 -1
- package/dist/browser.cjs +192 -77
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +2 -1
- package/dist/browser.d.ts +2 -1
- package/dist/browser.js +184 -74
- package/dist/browser.js.map +1 -1
- package/dist/{descriptors-CDVXo3BM.d.cts → descriptors-BnbL3xN8.d.cts} +11 -7
- package/dist/{descriptors-CDVXo3BM.d.ts → descriptors-BnbL3xN8.d.ts} +11 -7
- package/dist/index.cjs +94 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -52
- package/dist/index.d.ts +8 -52
- package/dist/index.js +91 -94
- package/dist/index.js.map +1 -1
- package/dist/{token-registry-CoTPqCbS.d.ts → types-BhiUiiNs.d.ts} +162 -45
- package/dist/{token-registry-DAHghHh2.d.cts → types-CMVkJNFp.d.cts} +162 -45
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -277,7 +277,7 @@ isSupported(USDT_TYPE); // false (legacy — no tier)
|
|
|
277
277
|
getTier(SUI_TYPE); // 2
|
|
278
278
|
```
|
|
279
279
|
|
|
280
|
-
Swap uses Cetus Aggregator V3
|
|
280
|
+
Swap uses Cetus Aggregator V3. Per-call `overlayFee` is opt-in — the SDK and CLI never charge fees by default. Consumer apps that want to charge an overlay (e.g. Audric) pass `overlayFee: { rate: 10n, receiver: T2000_OVERLAY_FEE_WALLET }` to `findSwapRoute` / `buildSwapTx`. Use `COIN_REGISTRY`, `getDecimalsForCoinType()`, `resolveSymbol()`, and `resolveTokenType()` for token data.
|
|
281
281
|
|
|
282
282
|
## Error Handling
|
|
283
283
|
|
|
@@ -318,20 +318,20 @@ SMOKE=1 pnpm --filter @t2000/sdk test -- src/__smoke__
|
|
|
318
318
|
|
|
319
319
|
## Protocol Fees
|
|
320
320
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
|
326
|
-
|
|
327
|
-
|
|
|
328
|
-
|
|
|
329
|
-
| Swap | 0.10% |
|
|
330
|
-
| Stake (
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
321
|
+
> **The SDK and CLI are fee-free by design (as of `@t2000/sdk@1.1.0`, B5 v2 / 2026-04-30).** Direct SDK / CLI calls — `t2000 save`, `t2000 borrow`, `t2000 swap`, plus `T2000.save()` / `T2000.borrow()` / `swapExecute()` from any third-party integrator — never charge a t2000 protocol fee. The CLI is dev-focused tooling and intentionally has no monetization.
|
|
322
|
+
|
|
323
|
+
Fees only apply when the **Audric** consumer app calls these primitives. Audric layers a fee transfer step (`addFeeTransfer`) inside the same PTB and routes the USDC to `T2000_OVERLAY_FEE_WALLET`.
|
|
324
|
+
|
|
325
|
+
| Operation | Audric fee | SDK / CLI fee | Notes |
|
|
326
|
+
|-----------|-----------|--------------|-------|
|
|
327
|
+
| Save (deposit) | 0.10% | Free | USDC only; USDsui save is free in Audric too |
|
|
328
|
+
| Borrow | 0.05% | Free | USDC only; USDsui borrow is free in Audric too |
|
|
329
|
+
| Swap | 0.10% | Free | Audric passes Cetus `overlayFee`. CLI omits it. Cetus Aggregator network fees still apply both ways. |
|
|
330
|
+
| Withdraw / Repay / Send / Receive / Stake / Unstake / Pay (MPP) | Free | Free | No surcharge anywhere. |
|
|
331
|
+
|
|
332
|
+
How Audric collects fees: `prepare/route.ts` calls `addFeeTransfer(tx, paymentCoin, FEE_BPS, T2000_OVERLAY_FEE_WALLET, amount)` for save/borrow and passes `overlayFee.receiver = T2000_OVERLAY_FEE_WALLET` for swaps. Both flows produce a USDC transfer to the treasury wallet inside the same atomic PTB. The t2000 server-side indexer detects the on-chain USDC inflow and records a `ProtocolFeeLedger` row — no off-chain submission is involved.
|
|
333
|
+
|
|
334
|
+
Need to charge an overlay fee in your own consumer app? Import `addFeeTransfer` and `T2000_OVERLAY_FEE_WALLET` from `@t2000/sdk` (or use your own receiver address — the SDK never assumes the t2000 treasury).
|
|
335
335
|
|
|
336
336
|
## MCP Server
|
|
337
337
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { d as ProtocolDescriptor, e as allDescriptors, n as naviDescriptor } from '../descriptors-
|
|
1
|
+
export { d as ProtocolDescriptor, e as allDescriptors, n as naviDescriptor } from '../descriptors-BnbL3xN8.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-
|
|
1
|
+
export { d as ProtocolDescriptor, e as allDescriptors, n as naviDescriptor } from '../descriptors-BnbL3xN8.js';
|
|
2
2
|
import '@mysten/sui/transactions';
|
|
3
3
|
import '@mysten/sui/jsonRpc';
|
package/dist/adapters/index.cjs
CHANGED
|
@@ -432,8 +432,6 @@ var T2000Error = class extends Error {
|
|
|
432
432
|
};
|
|
433
433
|
|
|
434
434
|
// src/constants.ts
|
|
435
|
-
var SAVE_FEE_BPS = 10n;
|
|
436
|
-
var BORROW_FEE_BPS = 5n;
|
|
437
435
|
var SUPPORTED_ASSETS = {
|
|
438
436
|
USDC: {
|
|
439
437
|
type: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
|
|
@@ -492,9 +490,7 @@ var SUPPORTED_ASSETS = {
|
|
|
492
490
|
};
|
|
493
491
|
var STABLE_ASSETS = ["USDC"];
|
|
494
492
|
var ALL_NAVI_ASSETS = Object.keys(SUPPORTED_ASSETS);
|
|
495
|
-
|
|
496
|
-
var T2000_CONFIG_ID = process.env.T2000_CONFIG_ID ?? "0x08ba26f0d260b5edf6a19c71492b3eb914906a7419baf2df1426765157e5862a";
|
|
497
|
-
var T2000_TREASURY_ID = process.env.T2000_TREASURY_ID ?? "0xf420ec0dcad44433042fb56e1413fb88d3ff65be94fcf425ef9ff750164590e8";
|
|
493
|
+
process.env.T2000_OVERLAY_FEE_WALLET ?? "0x5366efbf2b4fe5767fe2e78eb197aa5f5d138d88ac3333fbf3f80a1927da473a";
|
|
498
494
|
process.env.T2000_API_URL ?? "https://api.t2000.ai";
|
|
499
495
|
|
|
500
496
|
// src/adapters/registry.ts
|
|
@@ -4231,30 +4227,6 @@ async function Ct(e, n, o) {
|
|
|
4231
4227
|
return a;
|
|
4232
4228
|
}
|
|
4233
4229
|
|
|
4234
|
-
// src/protocols/protocolFee.ts
|
|
4235
|
-
var FEE_RATES = {
|
|
4236
|
-
save: SAVE_FEE_BPS,
|
|
4237
|
-
borrow: BORROW_FEE_BPS
|
|
4238
|
-
};
|
|
4239
|
-
var OP_CODES = {
|
|
4240
|
-
save: 0,
|
|
4241
|
-
borrow: 2
|
|
4242
|
-
};
|
|
4243
|
-
function addCollectFeeToTx(tx, paymentCoin, operation) {
|
|
4244
|
-
const bps = FEE_RATES[operation];
|
|
4245
|
-
if (bps <= 0n) return;
|
|
4246
|
-
tx.moveCall({
|
|
4247
|
-
target: `${T2000_PACKAGE_ID}::treasury::collect_fee`,
|
|
4248
|
-
typeArguments: [SUPPORTED_ASSETS.USDC.type],
|
|
4249
|
-
arguments: [
|
|
4250
|
-
tx.object(T2000_TREASURY_ID),
|
|
4251
|
-
tx.object(T2000_CONFIG_ID),
|
|
4252
|
-
paymentCoin,
|
|
4253
|
-
tx.pure.u8(OP_CODES[operation])
|
|
4254
|
-
]
|
|
4255
|
-
});
|
|
4256
|
-
}
|
|
4257
|
-
|
|
4258
4230
|
// src/protocols/navi.ts
|
|
4259
4231
|
var MIN_HEALTH_FACTOR = 1.5;
|
|
4260
4232
|
function sdkOptions(client) {
|
|
@@ -4435,9 +4407,6 @@ async function buildSaveTx(client, address, amount, options = {}) {
|
|
|
4435
4407
|
const tx = new transactions.Transaction();
|
|
4436
4408
|
tx.setSender(address);
|
|
4437
4409
|
const coinObj = mergeCoins(tx, coins);
|
|
4438
|
-
if (options.collectFee) {
|
|
4439
|
-
addCollectFeeToTx(tx, coinObj, "save");
|
|
4440
|
-
}
|
|
4441
4410
|
const rawAmount = Math.min(Number(stableToRaw(amount, assetInfo.decimals)), Number(totalBalance));
|
|
4442
4411
|
try {
|
|
4443
4412
|
await Ce(tx, assetInfo.type, coinObj, {
|
|
@@ -4508,9 +4477,6 @@ async function addWithdrawToTx(tx, client, address, amount, options = {}) {
|
|
|
4508
4477
|
async function addSaveToTx(tx, _client, _address, coin, options = {}) {
|
|
4509
4478
|
const asset = options.asset ?? "USDC";
|
|
4510
4479
|
const assetInfo = resolveAssetInfo(asset);
|
|
4511
|
-
if (options.collectFee) {
|
|
4512
|
-
addCollectFeeToTx(tx, coin, "save");
|
|
4513
|
-
}
|
|
4514
4480
|
try {
|
|
4515
4481
|
await Ce(tx, assetInfo.type, coin, { env: "prod" });
|
|
4516
4482
|
} catch (err) {
|
|
@@ -4541,9 +4507,6 @@ async function buildBorrowTx(client, address, amount, options = {}) {
|
|
|
4541
4507
|
await refreshOracle(tx, client, address, { skipPythUpdate: options.skipPythUpdate });
|
|
4542
4508
|
try {
|
|
4543
4509
|
const borrowedCoin = await Xe(tx, assetInfo.type, rawAmount, sdkOptions(client));
|
|
4544
|
-
if (options.collectFee) {
|
|
4545
|
-
addCollectFeeToTx(tx, borrowedCoin, "borrow");
|
|
4546
|
-
}
|
|
4547
4510
|
tx.transferObjects([borrowedCoin], address);
|
|
4548
4511
|
} catch (err) {
|
|
4549
4512
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -4551,6 +4514,22 @@ async function buildBorrowTx(client, address, amount, options = {}) {
|
|
|
4551
4514
|
}
|
|
4552
4515
|
return tx;
|
|
4553
4516
|
}
|
|
4517
|
+
async function addBorrowToTx(tx, client, address, amount, options = {}) {
|
|
4518
|
+
if (!amount || amount <= 0 || !Number.isFinite(amount)) {
|
|
4519
|
+
throw new T2000Error("INVALID_AMOUNT", "Borrow amount must be a positive number");
|
|
4520
|
+
}
|
|
4521
|
+
const asset = options.asset ?? "USDC";
|
|
4522
|
+
const assetInfo = resolveAssetInfo(asset);
|
|
4523
|
+
const rawAmount = Number(stableToRaw(amount, assetInfo.decimals));
|
|
4524
|
+
await refreshOracle(tx, client, address, { skipPythUpdate: options.skipPythUpdate });
|
|
4525
|
+
try {
|
|
4526
|
+
const borrowedCoin = await Xe(tx, assetInfo.type, rawAmount, sdkOptions(client));
|
|
4527
|
+
return borrowedCoin;
|
|
4528
|
+
} catch (err) {
|
|
4529
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
4530
|
+
throw new T2000Error("PROTOCOL_UNAVAILABLE", `NAVI borrow failed: ${msg}`);
|
|
4531
|
+
}
|
|
4532
|
+
}
|
|
4554
4533
|
async function buildRepayTx(client, address, amount, options = {}) {
|
|
4555
4534
|
if (!amount || amount <= 0 || !Number.isFinite(amount)) {
|
|
4556
4535
|
throw new T2000Error("INVALID_AMOUNT", "Repay amount must be a positive number");
|
|
@@ -4730,9 +4709,9 @@ var NaviAdapter = class {
|
|
|
4730
4709
|
async getHealth(address) {
|
|
4731
4710
|
return getHealthFactor(this.client, address);
|
|
4732
4711
|
}
|
|
4733
|
-
async buildSaveTx(address, amount, asset
|
|
4712
|
+
async buildSaveTx(address, amount, asset) {
|
|
4734
4713
|
const normalized = normalizeAsset(asset);
|
|
4735
|
-
const tx = await buildSaveTx(this.client, address, amount, {
|
|
4714
|
+
const tx = await buildSaveTx(this.client, address, amount, { asset: normalized });
|
|
4736
4715
|
return { tx };
|
|
4737
4716
|
}
|
|
4738
4717
|
async buildWithdrawTx(address, amount, asset, options) {
|
|
@@ -4770,9 +4749,16 @@ var NaviAdapter = class {
|
|
|
4770
4749
|
skipPythUpdate: options?.skipPythUpdate
|
|
4771
4750
|
});
|
|
4772
4751
|
}
|
|
4773
|
-
async addSaveToTx(tx, address, coin, asset
|
|
4752
|
+
async addSaveToTx(tx, address, coin, asset) {
|
|
4753
|
+
const normalized = normalizeAsset(asset);
|
|
4754
|
+
return addSaveToTx(tx, this.client, address, coin, { asset: normalized });
|
|
4755
|
+
}
|
|
4756
|
+
async addBorrowToTx(tx, address, amount, asset, options) {
|
|
4774
4757
|
const normalized = normalizeAsset(asset);
|
|
4775
|
-
return
|
|
4758
|
+
return addBorrowToTx(tx, this.client, address, amount, {
|
|
4759
|
+
asset: normalized,
|
|
4760
|
+
skipPythUpdate: options?.skipPythUpdate
|
|
4761
|
+
});
|
|
4776
4762
|
}
|
|
4777
4763
|
async addRepayToTx(tx, address, coin, asset, options) {
|
|
4778
4764
|
const normalized = normalizeAsset(asset);
|