@t2000/sdk 0.19.2 → 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-D-6pQwzx.d.cts → index-B8LxgOk7.d.cts} +2 -0
- package/dist/{index-D-6pQwzx.d.ts → index-B8LxgOk7.d.ts} +2 -0
- package/dist/index.cjs +103 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +103 -20
- 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
|
@@ -42716,33 +42716,113 @@ async function queryBalance(client, address) {
|
|
|
42716
42716
|
}
|
|
42717
42717
|
|
|
42718
42718
|
// src/wallet/history.ts
|
|
42719
|
+
var SUI_TYPE = "0x2::sui::SUI";
|
|
42720
|
+
var KNOWN_TARGETS = [
|
|
42721
|
+
[/::mpp_charge::/, "mpp payment"],
|
|
42722
|
+
[/::suilend|::obligation/, "lending"],
|
|
42723
|
+
[/::navi|::incentive_v2/, "lending"],
|
|
42724
|
+
[/::cetus|::pool/, "swap"],
|
|
42725
|
+
[/::deepbook/, "swap"],
|
|
42726
|
+
[/::transfer::public_transfer/, "send"]
|
|
42727
|
+
];
|
|
42719
42728
|
async function queryHistory(client, address, limit = 20) {
|
|
42720
42729
|
const txns = await client.queryTransactionBlocks({
|
|
42721
42730
|
filter: { FromAddress: address },
|
|
42722
|
-
options: { showEffects: true, showInput: true },
|
|
42731
|
+
options: { showEffects: true, showInput: true, showBalanceChanges: true },
|
|
42723
42732
|
limit,
|
|
42724
42733
|
order: "descending"
|
|
42725
42734
|
});
|
|
42726
|
-
return txns.data.map((tx) =>
|
|
42727
|
-
|
|
42728
|
-
|
|
42729
|
-
|
|
42730
|
-
|
|
42731
|
-
|
|
42732
|
-
|
|
42733
|
-
|
|
42734
|
-
|
|
42735
|
-
}
|
|
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;
|
|
42768
|
+
}
|
|
42769
|
+
function extractTransferDetails(changes, sender) {
|
|
42770
|
+
if (!changes || changes.length === 0) return {};
|
|
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);
|
|
42773
|
+
const primaryOutflow = outflows.filter((c) => c.coinType !== SUI_TYPE).sort((a, b2) => Number(BigInt(a.amount) - BigInt(b2.amount)))[0] ?? outflows[0];
|
|
42774
|
+
if (!primaryOutflow) return {};
|
|
42775
|
+
const coinType = primaryOutflow.coinType;
|
|
42776
|
+
const decimals = coinType.includes("::usdc::") ? 6 : 9;
|
|
42777
|
+
const amount = Math.abs(Number(BigInt(primaryOutflow.amount))) / 10 ** decimals;
|
|
42778
|
+
const asset = coinType === SUI_TYPE ? "SUI" : coinType.includes("::usdc::") ? "USDC" : coinType.split("::").pop() ?? "unknown";
|
|
42779
|
+
const recipientChange = inflows.find((c) => c.coinType === coinType);
|
|
42780
|
+
const recipient = recipientChange ? resolveOwner(recipientChange.owner) ?? void 0 : void 0;
|
|
42781
|
+
return { amount, asset, recipient };
|
|
42782
|
+
}
|
|
42783
|
+
function extractCommands(txBlock) {
|
|
42784
|
+
const result = { moveCallTargets: [], commandTypes: [] };
|
|
42785
|
+
try {
|
|
42786
|
+
if (!txBlock || typeof txBlock !== "object") return result;
|
|
42787
|
+
const data = "data" in txBlock ? txBlock.data : void 0;
|
|
42788
|
+
if (!data || typeof data !== "object") return result;
|
|
42789
|
+
const inner = "transaction" in data ? data.transaction : void 0;
|
|
42790
|
+
if (!inner || typeof inner !== "object") return result;
|
|
42791
|
+
const commands = "commands" in inner ? inner.commands : void 0;
|
|
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
|
+
}
|
|
42806
|
+
} catch {
|
|
42807
|
+
}
|
|
42808
|
+
return result;
|
|
42736
42809
|
}
|
|
42737
|
-
function
|
|
42738
|
-
|
|
42739
|
-
|
|
42740
|
-
|
|
42741
|
-
|
|
42742
|
-
|
|
42743
|
-
const
|
|
42744
|
-
|
|
42745
|
-
|
|
42810
|
+
function classifyAction(targets, commandTypes, recipient, asset) {
|
|
42811
|
+
for (const target of targets) {
|
|
42812
|
+
for (const [pattern, label] of KNOWN_TARGETS) {
|
|
42813
|
+
if (pattern.test(target)) return label;
|
|
42814
|
+
}
|
|
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";
|
|
42825
|
+
return "transaction";
|
|
42746
42826
|
}
|
|
42747
42827
|
|
|
42748
42828
|
// src/protocols/protocolFee.ts
|
|
@@ -57302,6 +57382,9 @@ To access invested funds: t2000 invest sell ${params.amount} ${asset}`,
|
|
|
57302
57382
|
async history(params) {
|
|
57303
57383
|
return queryHistory(this.client, this._address, params?.limit);
|
|
57304
57384
|
}
|
|
57385
|
+
async transactionDetail(digest) {
|
|
57386
|
+
return queryTransaction(this.client, digest, this._address);
|
|
57387
|
+
}
|
|
57305
57388
|
async deposit() {
|
|
57306
57389
|
return {
|
|
57307
57390
|
address: this._address,
|