@t2000/sdk 0.19.3 → 0.19.4
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 +1 -1
- package/dist/adapters/index.d.cts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/{index-CcTPxTBs.d.cts → index-B8LxgOk7.d.cts} +1 -0
- package/dist/{index-CcTPxTBs.d.ts → index-B8LxgOk7.d.ts} +1 -0
- package/dist/index.cjs +70 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +70 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -443,7 +443,7 @@ Fees are collected by the t2000 protocol treasury on-chain.
|
|
|
443
443
|
|
|
444
444
|
## MCP Server
|
|
445
445
|
|
|
446
|
-
The SDK powers the [`@t2000/mcp`](https://www.npmjs.com/package/@t2000/mcp) server —
|
|
446
|
+
The SDK powers the [`@t2000/mcp`](https://www.npmjs.com/package/@t2000/mcp) server — 35 tools and 20 prompts for Claude Desktop, Cursor, and any MCP-compatible AI platform. Run `t2000 mcp` to start.
|
|
447
447
|
|
|
448
448
|
## License
|
|
449
449
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { J as AdapterCapability, K as AdapterPositions, N as AdapterTxResult, Q as CetusAdapter, V as HealthInfo, L as LendingAdapter, w as LendingRates, Y as NaviAdapter, Z as PerpsAdapter, a1 as ProtocolDescriptor, a2 as ProtocolRegistry, a5 as SuilendAdapter, e as SwapAdapter, a6 as SwapQuote, a9 as allDescriptors, aa as cetusDescriptor, ad as naviDescriptor, ag as sentinelDescriptor, aj as suilendDescriptor } from '../index-
|
|
1
|
+
export { J as AdapterCapability, K as AdapterPositions, N as AdapterTxResult, Q as CetusAdapter, V as HealthInfo, L as LendingAdapter, w as LendingRates, Y as NaviAdapter, Z as PerpsAdapter, a1 as ProtocolDescriptor, a2 as ProtocolRegistry, a5 as SuilendAdapter, e as SwapAdapter, a6 as SwapQuote, a9 as allDescriptors, aa as cetusDescriptor, ad as naviDescriptor, ag as sentinelDescriptor, aj as suilendDescriptor } from '../index-B8LxgOk7.cjs';
|
|
2
2
|
import '@mysten/sui/transactions';
|
|
3
3
|
import '@mysten/sui/jsonRpc';
|
|
4
4
|
import '@mysten/sui/keypairs/ed25519';
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { J as AdapterCapability, K as AdapterPositions, N as AdapterTxResult, Q as CetusAdapter, V as HealthInfo, L as LendingAdapter, w as LendingRates, Y as NaviAdapter, Z as PerpsAdapter, a1 as ProtocolDescriptor, a2 as ProtocolRegistry, a5 as SuilendAdapter, e as SwapAdapter, a6 as SwapQuote, a9 as allDescriptors, aa as cetusDescriptor, ad as naviDescriptor, ag as sentinelDescriptor, aj as suilendDescriptor } from '../index-
|
|
1
|
+
export { J as AdapterCapability, K as AdapterPositions, N as AdapterTxResult, Q as CetusAdapter, V as HealthInfo, L as LendingAdapter, w as LendingRates, Y as NaviAdapter, Z as PerpsAdapter, a1 as ProtocolDescriptor, a2 as ProtocolRegistry, a5 as SuilendAdapter, e as SwapAdapter, a6 as SwapQuote, a9 as allDescriptors, aa as cetusDescriptor, ad as naviDescriptor, ag as sentinelDescriptor, aj as suilendDescriptor } from '../index-B8LxgOk7.js';
|
|
2
2
|
import '@mysten/sui/transactions';
|
|
3
3
|
import '@mysten/sui/jsonRpc';
|
|
4
4
|
import '@mysten/sui/keypairs/ed25519';
|
package/dist/index.cjs
CHANGED
|
@@ -42723,8 +42723,7 @@ var KNOWN_TARGETS = [
|
|
|
42723
42723
|
[/::navi|::incentive_v2/, "lending"],
|
|
42724
42724
|
[/::cetus|::pool/, "swap"],
|
|
42725
42725
|
[/::deepbook/, "swap"],
|
|
42726
|
-
[/::transfer::public_transfer/, "send"]
|
|
42727
|
-
[/::coin::split/, "split"]
|
|
42726
|
+
[/::transfer::public_transfer/, "send"]
|
|
42728
42727
|
];
|
|
42729
42728
|
async function queryHistory(client, address, limit = 20) {
|
|
42730
42729
|
const txns = await client.queryTransactionBlocks({
|
|
@@ -42733,36 +42732,44 @@ async function queryHistory(client, address, limit = 20) {
|
|
|
42733
42732
|
limit,
|
|
42734
42733
|
order: "descending"
|
|
42735
42734
|
});
|
|
42736
|
-
return txns.data.map((tx) =>
|
|
42737
|
-
|
|
42738
|
-
|
|
42739
|
-
|
|
42740
|
-
const
|
|
42741
|
-
|
|
42742
|
-
|
|
42743
|
-
|
|
42744
|
-
);
|
|
42745
|
-
|
|
42746
|
-
|
|
42747
|
-
|
|
42748
|
-
|
|
42749
|
-
|
|
42750
|
-
|
|
42751
|
-
|
|
42752
|
-
|
|
42753
|
-
|
|
42754
|
-
|
|
42735
|
+
return txns.data.map((tx) => parseTxRecord(tx, address));
|
|
42736
|
+
}
|
|
42737
|
+
async function queryTransaction(client, digest, senderAddress) {
|
|
42738
|
+
try {
|
|
42739
|
+
const tx = await client.getTransactionBlock({
|
|
42740
|
+
digest,
|
|
42741
|
+
options: { showEffects: true, showInput: true, showBalanceChanges: true }
|
|
42742
|
+
});
|
|
42743
|
+
return parseTxRecord(tx, senderAddress);
|
|
42744
|
+
} catch {
|
|
42745
|
+
return null;
|
|
42746
|
+
}
|
|
42747
|
+
}
|
|
42748
|
+
function parseTxRecord(tx, address) {
|
|
42749
|
+
const gasUsed = tx.effects?.gasUsed;
|
|
42750
|
+
const gasCost = gasUsed ? (Number(gasUsed.computationCost) + Number(gasUsed.storageCost) - Number(gasUsed.storageRebate)) / 1e9 : void 0;
|
|
42751
|
+
const { moveCallTargets, commandTypes } = extractCommands(tx.transaction);
|
|
42752
|
+
const { amount, asset, recipient } = extractTransferDetails(tx.balanceChanges, address);
|
|
42753
|
+
const action = classifyAction(moveCallTargets, commandTypes, recipient, asset);
|
|
42754
|
+
return {
|
|
42755
|
+
digest: tx.digest,
|
|
42756
|
+
action,
|
|
42757
|
+
amount,
|
|
42758
|
+
asset,
|
|
42759
|
+
recipient,
|
|
42760
|
+
timestamp: Number(tx.timestampMs ?? 0),
|
|
42761
|
+
gasCost
|
|
42762
|
+
};
|
|
42763
|
+
}
|
|
42764
|
+
function resolveOwner(owner) {
|
|
42765
|
+
if (typeof owner === "object" && owner.AddressOwner) return owner.AddressOwner;
|
|
42766
|
+
if (typeof owner === "string") return owner;
|
|
42767
|
+
return null;
|
|
42755
42768
|
}
|
|
42756
42769
|
function extractTransferDetails(changes, sender) {
|
|
42757
42770
|
if (!changes || changes.length === 0) return {};
|
|
42758
|
-
const outflows = changes.filter((c) =>
|
|
42759
|
-
|
|
42760
|
-
return owner === sender && BigInt(c.amount) < 0n;
|
|
42761
|
-
});
|
|
42762
|
-
const inflows = changes.filter((c) => {
|
|
42763
|
-
const owner = typeof c.owner === "object" && c.owner.AddressOwner ? c.owner.AddressOwner : typeof c.owner === "string" ? c.owner : null;
|
|
42764
|
-
return owner !== sender && BigInt(c.amount) > 0n;
|
|
42765
|
-
});
|
|
42771
|
+
const outflows = changes.filter((c) => resolveOwner(c.owner) === sender && BigInt(c.amount) < 0n);
|
|
42772
|
+
const inflows = changes.filter((c) => resolveOwner(c.owner) !== sender && BigInt(c.amount) > 0n);
|
|
42766
42773
|
const primaryOutflow = outflows.filter((c) => c.coinType !== SUI_TYPE).sort((a, b2) => Number(BigInt(a.amount) - BigInt(b2.amount)))[0] ?? outflows[0];
|
|
42767
42774
|
if (!primaryOutflow) return {};
|
|
42768
42775
|
const coinType = primaryOutflow.coinType;
|
|
@@ -42770,33 +42777,51 @@ function extractTransferDetails(changes, sender) {
|
|
|
42770
42777
|
const amount = Math.abs(Number(BigInt(primaryOutflow.amount))) / 10 ** decimals;
|
|
42771
42778
|
const asset = coinType === SUI_TYPE ? "SUI" : coinType.includes("::usdc::") ? "USDC" : coinType.split("::").pop() ?? "unknown";
|
|
42772
42779
|
const recipientChange = inflows.find((c) => c.coinType === coinType);
|
|
42773
|
-
const recipient = recipientChange ?
|
|
42780
|
+
const recipient = recipientChange ? resolveOwner(recipientChange.owner) ?? void 0 : void 0;
|
|
42774
42781
|
return { amount, asset, recipient };
|
|
42775
42782
|
}
|
|
42776
|
-
function
|
|
42783
|
+
function extractCommands(txBlock) {
|
|
42784
|
+
const result = { moveCallTargets: [], commandTypes: [] };
|
|
42777
42785
|
try {
|
|
42778
|
-
if (!txBlock || typeof txBlock !== "object") return
|
|
42786
|
+
if (!txBlock || typeof txBlock !== "object") return result;
|
|
42779
42787
|
const data = "data" in txBlock ? txBlock.data : void 0;
|
|
42780
|
-
if (!data || typeof data !== "object") return
|
|
42788
|
+
if (!data || typeof data !== "object") return result;
|
|
42781
42789
|
const inner = "transaction" in data ? data.transaction : void 0;
|
|
42782
|
-
if (!inner || typeof inner !== "object") return
|
|
42790
|
+
if (!inner || typeof inner !== "object") return result;
|
|
42783
42791
|
const commands = "commands" in inner ? inner.commands : void 0;
|
|
42784
|
-
if (!Array.isArray(commands)) return
|
|
42785
|
-
|
|
42786
|
-
|
|
42787
|
-
|
|
42788
|
-
|
|
42792
|
+
if (!Array.isArray(commands)) return result;
|
|
42793
|
+
for (const cmd of commands) {
|
|
42794
|
+
if (cmd.MoveCall) {
|
|
42795
|
+
const mc = cmd.MoveCall;
|
|
42796
|
+
result.moveCallTargets.push(`${mc.package}::${mc.module}::${mc.function}`);
|
|
42797
|
+
result.commandTypes.push("MoveCall");
|
|
42798
|
+
} else if (cmd.TransferObjects) {
|
|
42799
|
+
result.commandTypes.push("TransferObjects");
|
|
42800
|
+
} else if (cmd.SplitCoins) {
|
|
42801
|
+
result.commandTypes.push("SplitCoins");
|
|
42802
|
+
} else if (cmd.MergeCoins) {
|
|
42803
|
+
result.commandTypes.push("MergeCoins");
|
|
42804
|
+
}
|
|
42805
|
+
}
|
|
42789
42806
|
} catch {
|
|
42790
|
-
return [];
|
|
42791
42807
|
}
|
|
42808
|
+
return result;
|
|
42792
42809
|
}
|
|
42793
|
-
function classifyAction(targets) {
|
|
42794
|
-
if (targets.length === 0) return "transaction";
|
|
42810
|
+
function classifyAction(targets, commandTypes, recipient, asset) {
|
|
42795
42811
|
for (const target of targets) {
|
|
42796
42812
|
for (const [pattern, label] of KNOWN_TARGETS) {
|
|
42797
42813
|
if (pattern.test(target)) return label;
|
|
42798
42814
|
}
|
|
42799
42815
|
}
|
|
42816
|
+
const hasTransfer = commandTypes.includes("TransferObjects");
|
|
42817
|
+
const hasSplit = commandTypes.includes("SplitCoins");
|
|
42818
|
+
const hasMoveCall = commandTypes.includes("MoveCall");
|
|
42819
|
+
if (hasTransfer && !hasMoveCall && recipient) {
|
|
42820
|
+
if (asset === "USDC" && hasSplit) return "send";
|
|
42821
|
+
return "send";
|
|
42822
|
+
}
|
|
42823
|
+
if (hasMoveCall) return "transaction";
|
|
42824
|
+
if (hasTransfer) return "send";
|
|
42800
42825
|
return "transaction";
|
|
42801
42826
|
}
|
|
42802
42827
|
|
|
@@ -57357,6 +57382,9 @@ To access invested funds: t2000 invest sell ${params.amount} ${asset}`,
|
|
|
57357
57382
|
async history(params) {
|
|
57358
57383
|
return queryHistory(this.client, this._address, params?.limit);
|
|
57359
57384
|
}
|
|
57385
|
+
async transactionDetail(digest) {
|
|
57386
|
+
return queryTransaction(this.client, digest, this._address);
|
|
57387
|
+
}
|
|
57360
57388
|
async deposit() {
|
|
57361
57389
|
return {
|
|
57362
57390
|
address: this._address,
|