@sun-protocol/sun-sdk-protocols 0.1.0-beta.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 +30 -0
- package/dist/chunk-5XDX5563.js +99 -0
- package/dist/chunk-5XDX5563.js.map +1 -0
- package/dist/chunk-C2YCVBPI.js +212 -0
- package/dist/chunk-C2YCVBPI.js.map +1 -0
- package/dist/chunk-ECCGOXNA.js +1317 -0
- package/dist/chunk-ECCGOXNA.js.map +1 -0
- package/dist/chunk-HD2S3Q7L.js +746 -0
- package/dist/chunk-HD2S3Q7L.js.map +1 -0
- package/dist/chunk-L5TZCDPH.js +561 -0
- package/dist/chunk-L5TZCDPH.js.map +1 -0
- package/dist/chunk-OM4OW4KB.js +224 -0
- package/dist/chunk-OM4OW4KB.js.map +1 -0
- package/dist/chunk-PEGREDLT.js +935 -0
- package/dist/chunk-PEGREDLT.js.map +1 -0
- package/dist/chunk-TSHXXRH2.js +103 -0
- package/dist/chunk-TSHXXRH2.js.map +1 -0
- package/dist/chunk-VFVKMC4H.js +521 -0
- package/dist/chunk-VFVKMC4H.js.map +1 -0
- package/dist/chunk-YMGZDXI4.js +1209 -0
- package/dist/chunk-YMGZDXI4.js.map +1 -0
- package/dist/common-8VQQ0FSU.d.cts +146 -0
- package/dist/common-8VQQ0FSU.d.ts +146 -0
- package/dist/execute-BNKh6dT6.d.cts +187 -0
- package/dist/execute-CVhcKZxF.d.ts +187 -0
- package/dist/index.cjs +5619 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +139 -0
- package/dist/index.d.ts +139 -0
- package/dist/index.js +200 -0
- package/dist/index.js.map +1 -0
- package/dist/intents-BSXq1HvW.d.cts +200 -0
- package/dist/intents-CwOttD75.d.ts +200 -0
- package/dist/liquidity/index.cjs +2441 -0
- package/dist/liquidity/index.cjs.map +1 -0
- package/dist/liquidity/index.d.cts +83 -0
- package/dist/liquidity/index.d.ts +83 -0
- package/dist/liquidity/index.js +32 -0
- package/dist/liquidity/index.js.map +1 -0
- package/dist/positions/index.cjs +1544 -0
- package/dist/positions/index.cjs.map +1 -0
- package/dist/positions/index.d.cts +159 -0
- package/dist/positions/index.d.ts +159 -0
- package/dist/positions/index.js +25 -0
- package/dist/positions/index.js.map +1 -0
- package/dist/pump/index.cjs +1178 -0
- package/dist/pump/index.cjs.map +1 -0
- package/dist/pump/index.d.cts +16 -0
- package/dist/pump/index.d.ts +16 -0
- package/dist/pump/index.js +29 -0
- package/dist/pump/index.js.map +1 -0
- package/dist/swap/index.cjs +2259 -0
- package/dist/swap/index.cjs.map +1 -0
- package/dist/swap/index.d.cts +33 -0
- package/dist/swap/index.d.ts +33 -0
- package/dist/swap/index.js +61 -0
- package/dist/swap/index.js.map +1 -0
- package/dist/types-BTPdCC7k.d.cts +160 -0
- package/dist/types-BfrouFmO.d.ts +160 -0
- package/package.json +94 -0
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @sun-protocol/sun-sdk-protocols
|
|
2
|
+
|
|
3
|
+
High-level SUN SDK workflows for swaps, PSM, SunPump, liquidity, and positions.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @sun-protocol/sun-sdk-protocols @sun-protocol/sun-sdk-runtime
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { SunSDK } from '@sun-protocol/sun-sdk-protocols'
|
|
15
|
+
|
|
16
|
+
const sun = await SunSDK.create({ network: 'mainnet' })
|
|
17
|
+
const quote = await sun.swap.router.quote({
|
|
18
|
+
tokenIn: 'TRX',
|
|
19
|
+
tokenOut: token,
|
|
20
|
+
amountIn: '1000000',
|
|
21
|
+
})
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The root entry exports `SunSDK`, protocol contexts, plan executors, approval helpers, and all public workflow types. Subpath entry points are available at `/swap`, `/liquidity`, `/positions`, and `/pump`.
|
|
25
|
+
|
|
26
|
+
This package orchestrates API, runtime, and protocol primitives. It does not discover a global wallet: applications explicitly provide a `TronClient`, a `WalletAdapter`, or a composed runtime when chain access is needed.
|
|
27
|
+
|
|
28
|
+
Requires Node.js 20. HTTP-only operations need `fetch`; chain execution needs a compatible runtime adapter.
|
|
29
|
+
|
|
30
|
+
[Full API documentation](https://github.com/sun-protocol/sun-sdk/blob/main/docs/sdk/api/protocols.md)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeTronAddress
|
|
3
|
+
} from "./chunk-C2YCVBPI.js";
|
|
4
|
+
|
|
5
|
+
// src/usdt-transfer.ts
|
|
6
|
+
import { SDKError } from "@sun-protocol/sun-sdk-core";
|
|
7
|
+
async function usdtValidateTransfer(input) {
|
|
8
|
+
if (input.transfersUsdt === false) return { status: "allowed" };
|
|
9
|
+
if (input.transfersUsdt !== true) return { status: "unknown", reason: "CHECK_FAILED" };
|
|
10
|
+
if (input.sources.length === 0) return { status: "unknown", reason: "MISSING_TRANSFER_SOURCE" };
|
|
11
|
+
try {
|
|
12
|
+
const paused = await input.reader.paused();
|
|
13
|
+
if (typeof paused !== "boolean") throw new Error("Invalid paused result");
|
|
14
|
+
if (paused) return { status: "blocked", reason: "USDT_PAUSED" };
|
|
15
|
+
const sources = /* @__PURE__ */ new Map();
|
|
16
|
+
for (const source of input.sources) {
|
|
17
|
+
const address = normalizeTronAddress(source.address);
|
|
18
|
+
sources.set(address, { ...source, address });
|
|
19
|
+
}
|
|
20
|
+
const checks = await Promise.all([...sources.values()].map(async (source) => {
|
|
21
|
+
const blacklisted = await input.reader.isBlackListed(source.address);
|
|
22
|
+
if (typeof blacklisted !== "boolean") throw new Error("Invalid blacklist result");
|
|
23
|
+
return { source, blacklisted };
|
|
24
|
+
}));
|
|
25
|
+
const blocked = checks.filter((check) => check.blacklisted).map((check) => check.source);
|
|
26
|
+
return blocked.length > 0 ? { status: "blocked", reason: "USDT_SOURCE_BLACKLISTED", sources: blocked } : { status: "allowed" };
|
|
27
|
+
} catch {
|
|
28
|
+
return { status: "unknown", reason: "CHECK_FAILED" };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function parseTransferContext(context, action) {
|
|
32
|
+
const data = action.metadata?.usdtTransfer;
|
|
33
|
+
if (!data) throw new Error("Missing USDT transfer context");
|
|
34
|
+
if (data.network !== context.network || typeof data.transfersUsdt !== "boolean" || !Array.isArray(data.sources)) {
|
|
35
|
+
throw new Error("Invalid USDT transfer context; rebuild the plan");
|
|
36
|
+
}
|
|
37
|
+
const sources = data.sources.map((source) => {
|
|
38
|
+
if (!source || typeof source.address !== "string" || source.role !== "v3-pool" && source.role !== "position-manager") {
|
|
39
|
+
throw new Error("Invalid USDT transfer source");
|
|
40
|
+
}
|
|
41
|
+
const address = normalizeTronAddress(source.address);
|
|
42
|
+
if (source.role === "position-manager" && address !== normalizeTronAddress(action.target)) {
|
|
43
|
+
throw new Error("USDT sweep source does not match the position manager");
|
|
44
|
+
}
|
|
45
|
+
return { address, role: source.role };
|
|
46
|
+
});
|
|
47
|
+
if (!data.transfersUsdt && sources.length > 0) throw new Error("Unexpected USDT sources");
|
|
48
|
+
return { network: context.network, transfersUsdt: data.transfersUsdt, sources };
|
|
49
|
+
}
|
|
50
|
+
function boolRead(target, name, address) {
|
|
51
|
+
return {
|
|
52
|
+
target,
|
|
53
|
+
functionSelector: name === "paused" ? "paused()" : "isBlackListed(address)",
|
|
54
|
+
parameters: address === void 0 ? [] : [{ type: "address", value: address }],
|
|
55
|
+
abiFunction: {
|
|
56
|
+
type: "function",
|
|
57
|
+
name,
|
|
58
|
+
stateMutability: "view",
|
|
59
|
+
inputs: name === "paused" ? [] : [{ name: "_user", type: "address" }],
|
|
60
|
+
outputs: [{ name: "", type: "bool" }]
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async function assertUsdtTransfer(context, action) {
|
|
65
|
+
let result;
|
|
66
|
+
if (!action.metadata?.usdtTransfer) {
|
|
67
|
+
result = { status: "unknown", reason: "MISSING_TRANSFER_SOURCE" };
|
|
68
|
+
} else {
|
|
69
|
+
try {
|
|
70
|
+
const data = parseTransferContext(context, action);
|
|
71
|
+
if (data.transfersUsdt && !data.sources.some((source) => source.role === "v3-pool")) {
|
|
72
|
+
result = { status: "unknown", reason: "MISSING_TRANSFER_SOURCE" };
|
|
73
|
+
} else {
|
|
74
|
+
const read = (name, address) => {
|
|
75
|
+
if (!context.runtime) throw new Error("USDT transfer validation requires a runtime");
|
|
76
|
+
return context.runtime.readContract(boolRead(context.chain.contracts.usdt, name, address));
|
|
77
|
+
};
|
|
78
|
+
result = await usdtValidateTransfer({
|
|
79
|
+
...data,
|
|
80
|
+
reader: { paused: () => read("paused"), isBlackListed: (address) => read("isBlackListed", address) }
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
} catch {
|
|
84
|
+
result = { status: "unknown", reason: "CHECK_FAILED" };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (result.status === "allowed") return;
|
|
88
|
+
throw new SDKError(
|
|
89
|
+
result.status === "blocked" ? "SDK_USDT_TRANSFER_BLOCKED" : "SDK_USDT_TRANSFER_UNKNOWN",
|
|
90
|
+
result.status === "blocked" ? "USDT transfer is currently restricted" : "Unable to verify USDT transfer status",
|
|
91
|
+
{ ...result, usdtAddress: context.chain.contracts.usdt, actionId: action.id }
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export {
|
|
96
|
+
usdtValidateTransfer,
|
|
97
|
+
assertUsdtTransfer
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=chunk-5XDX5563.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/usdt-transfer.ts"],"sourcesContent":["import { SDKError, type ContractCallAction, type Network, type TronAddress } from '@sun-protocol/sun-sdk-core'\nimport type { ContractRead } from '@sun-protocol/sun-sdk-runtime'\nimport type { ProtocolsContext } from './context.js'\nimport { normalizeTronAddress } from './internal/tokens.js'\n\nexport interface UsdtReader {\n paused(): Promise<boolean>\n isBlackListed(address: string): Promise<boolean>\n}\n\nexport interface TransferSource {\n readonly address: string\n readonly role: 'v3-pool' | 'position-manager'\n}\n\nexport type UsdtTransferValidationResult =\n | { readonly status: 'allowed' }\n | { readonly status: 'blocked'; readonly reason: 'USDT_PAUSED' }\n | { readonly status: 'blocked'; readonly reason: 'USDT_SOURCE_BLACKLISTED'; readonly sources: readonly TransferSource[] }\n | { readonly status: 'unknown'; readonly reason: 'MISSING_TRANSFER_SOURCE' | 'CHECK_FAILED' }\n\n/** Applies the USDT paused/blacklist check. Unknown results never authorize submission. */\nexport async function usdtValidateTransfer(input: {\n readonly reader: UsdtReader\n readonly transfersUsdt: boolean\n readonly sources: readonly TransferSource[]\n}): Promise<UsdtTransferValidationResult> {\n if (input.transfersUsdt === false) return { status: 'allowed' }\n if (input.transfersUsdt !== true) return { status: 'unknown', reason: 'CHECK_FAILED' }\n if (input.sources.length === 0) return { status: 'unknown', reason: 'MISSING_TRANSFER_SOURCE' }\n\n try {\n const paused = await input.reader.paused()\n if (typeof paused !== 'boolean') throw new Error('Invalid paused result')\n if (paused) return { status: 'blocked', reason: 'USDT_PAUSED' }\n\n const sources = new Map<string, TransferSource>()\n for (const source of input.sources) {\n const address = normalizeTronAddress(source.address)\n sources.set(address, { ...source, address })\n }\n const checks = await Promise.all([...sources.values()].map(async (source) => {\n const blacklisted = await input.reader.isBlackListed(source.address)\n if (typeof blacklisted !== 'boolean') throw new Error('Invalid blacklist result')\n return { source, blacklisted }\n }))\n const blocked = checks.filter((check) => check.blacklisted).map((check) => check.source)\n return blocked.length > 0\n ? { status: 'blocked', reason: 'USDT_SOURCE_BLACKLISTED', sources: blocked }\n : { status: 'allowed' }\n } catch {\n return { status: 'unknown', reason: 'CHECK_FAILED' }\n }\n}\n\n/** Static facts about an SDK-built action; never stores a previous check result. */\nexport interface UsdtTransferContext {\n readonly network: Network\n readonly transfersUsdt: boolean\n readonly sources: readonly TransferSource[]\n}\n\nfunction parseTransferContext(context: ProtocolsContext, action: ContractCallAction): UsdtTransferContext {\n const data = action.metadata?.usdtTransfer as Partial<UsdtTransferContext> | undefined\n if (!data) throw new Error('Missing USDT transfer context')\n if (data.network !== context.network ||\n typeof data.transfersUsdt !== 'boolean' || !Array.isArray(data.sources)) {\n throw new Error('Invalid USDT transfer context; rebuild the plan')\n }\n const sources = data.sources.map((source: TransferSource) => {\n if (!source || typeof source.address !== 'string' ||\n (source.role !== 'v3-pool' && source.role !== 'position-manager')) {\n throw new Error('Invalid USDT transfer source')\n }\n const address = normalizeTronAddress(source.address)\n if (source.role === 'position-manager' && address !== normalizeTronAddress(action.target)) {\n throw new Error('USDT sweep source does not match the position manager')\n }\n return { address, role: source.role }\n })\n if (!data.transfersUsdt && sources.length > 0) throw new Error('Unexpected USDT sources')\n return { network: context.network, transfersUsdt: data.transfersUsdt, sources }\n}\n\nfunction boolRead(target: TronAddress, name: 'paused' | 'isBlackListed', address?: string): ContractRead {\n return {\n target,\n functionSelector: name === 'paused' ? 'paused()' : 'isBlackListed(address)',\n parameters: address === undefined ? [] : [{ type: 'address', value: address }],\n abiFunction: {\n type: 'function', name, stateMutability: 'view',\n inputs: name === 'paused' ? [] : [{ name: '_user', type: 'address' }],\n outputs: [{ name: '', type: 'bool' }],\n },\n }\n}\n\n/** Internal execution guard, shared by the two protocol-specific executors. */\nexport async function assertUsdtTransfer(context: ProtocolsContext, action: ContractCallAction): Promise<void> {\n let result: UsdtTransferValidationResult\n if (!action.metadata?.usdtTransfer) {\n result = { status: 'unknown', reason: 'MISSING_TRANSFER_SOURCE' }\n } else {\n try {\n const data = parseTransferContext(context, action)\n if (data.transfersUsdt && !data.sources.some((source) => source.role === 'v3-pool')) {\n result = { status: 'unknown', reason: 'MISSING_TRANSFER_SOURCE' }\n } else {\n const read = (name: 'paused' | 'isBlackListed', address?: string) => {\n if (!context.runtime) throw new Error('USDT transfer validation requires a runtime')\n return context.runtime.readContract<boolean>(boolRead(context.chain.contracts.usdt, name, address))\n }\n result = await usdtValidateTransfer({\n ...data,\n reader: { paused: () => read('paused'), isBlackListed: (address) => read('isBlackListed', address) },\n })\n }\n } catch {\n result = { status: 'unknown', reason: 'CHECK_FAILED' }\n }\n }\n if (result.status === 'allowed') return\n throw new SDKError(\n result.status === 'blocked' ? 'SDK_USDT_TRANSFER_BLOCKED' : 'SDK_USDT_TRANSFER_UNKNOWN',\n result.status === 'blocked' ? 'USDT transfer is currently restricted' : 'Unable to verify USDT transfer status',\n { ...result, usdtAddress: context.chain.contracts.usdt, actionId: action.id },\n )\n}\n"],"mappings":";;;;;AAAA,SAAS,gBAAyE;AAsBlF,eAAsB,qBAAqB,OAID;AACxC,MAAI,MAAM,kBAAkB,MAAO,QAAO,EAAE,QAAQ,UAAU;AAC9D,MAAI,MAAM,kBAAkB,KAAM,QAAO,EAAE,QAAQ,WAAW,QAAQ,eAAe;AACrF,MAAI,MAAM,QAAQ,WAAW,EAAG,QAAO,EAAE,QAAQ,WAAW,QAAQ,0BAA0B;AAE9F,MAAI;AACF,UAAM,SAAS,MAAM,MAAM,OAAO,OAAO;AACzC,QAAI,OAAO,WAAW,UAAW,OAAM,IAAI,MAAM,uBAAuB;AACxE,QAAI,OAAQ,QAAO,EAAE,QAAQ,WAAW,QAAQ,cAAc;AAE9D,UAAM,UAAU,oBAAI,IAA4B;AAChD,eAAW,UAAU,MAAM,SAAS;AAClC,YAAM,UAAU,qBAAqB,OAAO,OAAO;AACnD,cAAQ,IAAI,SAAS,EAAE,GAAG,QAAQ,QAAQ,CAAC;AAAA,IAC7C;AACA,UAAM,SAAS,MAAM,QAAQ,IAAI,CAAC,GAAG,QAAQ,OAAO,CAAC,EAAE,IAAI,OAAO,WAAW;AAC3E,YAAM,cAAc,MAAM,MAAM,OAAO,cAAc,OAAO,OAAO;AACnE,UAAI,OAAO,gBAAgB,UAAW,OAAM,IAAI,MAAM,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AAO,WAAW,YAAY,0CAA0C;AAAA,IACxE,EAAE,GAAG,QAAQ,aAAa,QAAQ,MAAM,UAAU,MAAM,UAAU,OAAO,GAAG;AAAA,EAC9E;AACF;","names":[]}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeBaseUnitAmount,
|
|
3
|
+
requireRuntime
|
|
4
|
+
} from "./chunk-VFVKMC4H.js";
|
|
5
|
+
|
|
6
|
+
// src/approval/check.ts
|
|
7
|
+
async function readClassicAllowance(runtime, requirement) {
|
|
8
|
+
if (requirement.asset.type === "native") return "0";
|
|
9
|
+
const result = await runtime.readContract({
|
|
10
|
+
target: requirement.asset.token,
|
|
11
|
+
functionSelector: "allowance(address,address)",
|
|
12
|
+
parameters: [
|
|
13
|
+
{ type: "address", value: requirement.owner },
|
|
14
|
+
{ type: "address", value: requirement.spender }
|
|
15
|
+
],
|
|
16
|
+
outputs: [{ type: "uint256", name: "allowance" }]
|
|
17
|
+
});
|
|
18
|
+
return BigInt(result).toString();
|
|
19
|
+
}
|
|
20
|
+
async function checkClassicAllowance(runtime, requirement) {
|
|
21
|
+
if (requirement.asset.type === "native") {
|
|
22
|
+
return { allowance: requirement.amount, sufficient: true };
|
|
23
|
+
}
|
|
24
|
+
const allowance = await readClassicAllowance(runtime, requirement);
|
|
25
|
+
return {
|
|
26
|
+
allowance,
|
|
27
|
+
sufficient: BigInt(allowance) >= BigInt(requirement.amount)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/approval/classic.ts
|
|
32
|
+
import {
|
|
33
|
+
MaxUint256,
|
|
34
|
+
createApproveAction
|
|
35
|
+
} from "@sun-protocol/sun-sdk-core";
|
|
36
|
+
function buildClassicApproveAction(requirement, options = {}) {
|
|
37
|
+
if (requirement.asset.type === "native") return void 0;
|
|
38
|
+
return createApproveAction({
|
|
39
|
+
id: `approve-${requirement.asset.token}-${requirement.spender}`,
|
|
40
|
+
target: requirement.asset.token,
|
|
41
|
+
spender: requirement.spender,
|
|
42
|
+
amount: options.amount === "exact" ? requirement.amount : MaxUint256.toString(),
|
|
43
|
+
...options.feeLimit !== void 0 ? { feeLimit: options.feeLimit } : {}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/approval/plan.ts
|
|
48
|
+
import { SDKError } from "@sun-protocol/sun-sdk-core";
|
|
49
|
+
async function planApproval(context, requirement, options = {}) {
|
|
50
|
+
const mode = options.mode ?? "auto";
|
|
51
|
+
normalizeBaseUnitAmount(requirement.amount, "approval amount");
|
|
52
|
+
if (requirement.asset.type === "native") {
|
|
53
|
+
return {
|
|
54
|
+
mode,
|
|
55
|
+
requirement,
|
|
56
|
+
allowance: requirement.amount,
|
|
57
|
+
sufficient: true,
|
|
58
|
+
actions: []
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (mode === "none") {
|
|
62
|
+
return { mode, requirement, actions: [] };
|
|
63
|
+
}
|
|
64
|
+
if (mode === "permit2") {
|
|
65
|
+
throw new SDKError(
|
|
66
|
+
"SDK_WALLET_CAPABILITY_ERROR",
|
|
67
|
+
"Permit2 approval is unavailable until a Permit2 adapter is configured",
|
|
68
|
+
{ mode, token: requirement.asset.token }
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
const runtime = requireRuntime(context, "Token allowance check");
|
|
72
|
+
const check = await checkClassicAllowance(runtime, requirement);
|
|
73
|
+
if (check.sufficient) {
|
|
74
|
+
return {
|
|
75
|
+
mode,
|
|
76
|
+
requirement,
|
|
77
|
+
allowance: check.allowance,
|
|
78
|
+
sufficient: true,
|
|
79
|
+
actions: []
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const action = buildClassicApproveAction(requirement, options);
|
|
83
|
+
return {
|
|
84
|
+
mode,
|
|
85
|
+
requirement,
|
|
86
|
+
allowance: check.allowance,
|
|
87
|
+
sufficient: false,
|
|
88
|
+
actions: action ? [action] : []
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/internal/reads.ts
|
|
93
|
+
import { SDKError as SDKError2 } from "@sun-protocol/sun-sdk-core";
|
|
94
|
+
async function readRequiredContract(context, call, operation) {
|
|
95
|
+
const runtime = requireRuntime(context, operation);
|
|
96
|
+
const value = await runtime.readContract(call);
|
|
97
|
+
if (value === void 0 || value === null) {
|
|
98
|
+
throw new SDKError2("SDK_CONTRACT_ERROR", `${operation} returned an empty result`, { call });
|
|
99
|
+
}
|
|
100
|
+
return value;
|
|
101
|
+
}
|
|
102
|
+
async function readMulticallRequired(context, calls, operation) {
|
|
103
|
+
const runtime = requireRuntime(context, operation);
|
|
104
|
+
const results = await runtime.multicall(calls);
|
|
105
|
+
return results.map((result, index) => {
|
|
106
|
+
if (!result.success || result.value === void 0) {
|
|
107
|
+
throw new SDKError2("SDK_CONTRACT_ERROR", `${operation} multicall item failed`, {
|
|
108
|
+
index,
|
|
109
|
+
call: calls[index],
|
|
110
|
+
error: result.error
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return result.value;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/internal/tokens.ts
|
|
118
|
+
import { getWrappedNativeAddress } from "@sun-protocol/sun-sdk-chains";
|
|
119
|
+
import {
|
|
120
|
+
Percent,
|
|
121
|
+
SDKError as SDKError3,
|
|
122
|
+
TRON_ZERO_ADDRESS,
|
|
123
|
+
Token,
|
|
124
|
+
assertTronAddress
|
|
125
|
+
} from "@sun-protocol/sun-sdk-core";
|
|
126
|
+
import {
|
|
127
|
+
evmHexToTronAddress as evmHexToTronAddressV2,
|
|
128
|
+
tronAddressToEvmHex
|
|
129
|
+
} from "@sun-protocol/sun-sdk-sunswap-v2";
|
|
130
|
+
var PERCENT_PATTERN = /^(\d+)(?:\.(\d+))?%$/;
|
|
131
|
+
function isNativeTrxInput(context, token) {
|
|
132
|
+
return token.toUpperCase() === "TRX" || token === context.chain.contracts.trx;
|
|
133
|
+
}
|
|
134
|
+
function evmHexToTronAddress(address, label = "address") {
|
|
135
|
+
const normalized = address.startsWith("0x") ? address.toLowerCase() : `0x${address.toLowerCase()}`;
|
|
136
|
+
return evmHexToTronAddressV2(normalized, label);
|
|
137
|
+
}
|
|
138
|
+
function tronAddressToEvmAddress(address, label = "address") {
|
|
139
|
+
return `0x${tronAddressToEvmHex(assertTronAddress(address, label))}`;
|
|
140
|
+
}
|
|
141
|
+
function normalizeTronAddress(address, label = "address") {
|
|
142
|
+
if (/^41[0-9a-fA-F]{40}$/.test(address)) return evmHexToTronAddress(`0x${address.slice(2)}`, label);
|
|
143
|
+
if (/^0x[0-9a-fA-F]{40}$/.test(address)) return evmHexToTronAddress(address, label);
|
|
144
|
+
return evmHexToTronAddress(tronAddressToEvmAddress(address, label), label);
|
|
145
|
+
}
|
|
146
|
+
function normalizeProtocolToken(context, token, label, metadata = {}) {
|
|
147
|
+
const wrappedContractAddress = getWrappedNativeAddress(context.network);
|
|
148
|
+
const kind = isNativeTrxInput(context, token) ? "native" : "token";
|
|
149
|
+
const contractAddress = kind === "native" ? TRON_ZERO_ADDRESS : assertTronAddress(token, label);
|
|
150
|
+
const mathAddress = kind === "native" ? wrappedContractAddress : contractAddress;
|
|
151
|
+
const evmAddress = `0x${tronAddressToEvmHex(mathAddress)}`.toLowerCase();
|
|
152
|
+
return {
|
|
153
|
+
kind,
|
|
154
|
+
input: token,
|
|
155
|
+
contractAddress,
|
|
156
|
+
wrappedContractAddress,
|
|
157
|
+
token: new Token(
|
|
158
|
+
context.chain.uniswapChainId,
|
|
159
|
+
evmAddress,
|
|
160
|
+
metadata.decimals ?? 6,
|
|
161
|
+
metadata.symbol,
|
|
162
|
+
metadata.name,
|
|
163
|
+
true
|
|
164
|
+
)
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function parseLiquidityPercentageInput(value, label) {
|
|
168
|
+
if (value instanceof Percent) return value;
|
|
169
|
+
const match = PERCENT_PATTERN.exec(value);
|
|
170
|
+
if (!match) {
|
|
171
|
+
throw new SDKError3("SDK_INVALID_ARGUMENT", `${label} must be a percentage string`, {
|
|
172
|
+
label,
|
|
173
|
+
percentage: value
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
const whole = match[1] ?? "0";
|
|
177
|
+
const fraction = match[2] ?? "";
|
|
178
|
+
const scale = 10n ** BigInt(fraction.length);
|
|
179
|
+
const percentageUnits = BigInt(whole) * scale + BigInt(fraction || "0");
|
|
180
|
+
return new Percent(percentageUnits.toString(), (100n * scale).toString());
|
|
181
|
+
}
|
|
182
|
+
function normalizeLiquidityPercentage(value, label) {
|
|
183
|
+
const percent = parseLiquidityPercentageInput(value, label);
|
|
184
|
+
if (percent.equalTo(0)) {
|
|
185
|
+
throw new SDKError3("SDK_INVALID_ARGUMENT", `${label} must be greater than 0%`, {
|
|
186
|
+
label,
|
|
187
|
+
percentage: percent.toSignificant()
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
if (percent.greaterThan(1)) {
|
|
191
|
+
throw new SDKError3("SDK_INVALID_ARGUMENT", `${label} must be at most 100%`, {
|
|
192
|
+
label,
|
|
193
|
+
percentage: percent.toSignificant()
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return percent;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export {
|
|
200
|
+
readClassicAllowance,
|
|
201
|
+
checkClassicAllowance,
|
|
202
|
+
buildClassicApproveAction,
|
|
203
|
+
planApproval,
|
|
204
|
+
readRequiredContract,
|
|
205
|
+
readMulticallRequired,
|
|
206
|
+
evmHexToTronAddress,
|
|
207
|
+
tronAddressToEvmAddress,
|
|
208
|
+
normalizeTronAddress,
|
|
209
|
+
normalizeProtocolToken,
|
|
210
|
+
normalizeLiquidityPercentage
|
|
211
|
+
};
|
|
212
|
+
//# sourceMappingURL=chunk-C2YCVBPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/approval/check.ts","../src/approval/classic.ts","../src/approval/plan.ts","../src/internal/reads.ts","../src/internal/tokens.ts"],"sourcesContent":["import type { Runtime } from '@sun-protocol/sun-sdk-runtime'\nimport type { ApprovalRequirement } from './types.js'\n\nexport async function readClassicAllowance(\n runtime: Runtime,\n requirement: ApprovalRequirement,\n): Promise<string> {\n if (requirement.asset.type === 'native') return '0'\n const result = await runtime.readContract<string | number | bigint>({\n target: requirement.asset.token,\n functionSelector: 'allowance(address,address)',\n parameters: [\n { type: 'address', value: requirement.owner },\n { type: 'address', value: requirement.spender },\n ],\n outputs: [{ type: 'uint256', name: 'allowance' }],\n })\n return BigInt(result).toString()\n}\n\nexport async function checkClassicAllowance(\n runtime: Runtime,\n requirement: ApprovalRequirement,\n): Promise<{ allowance: string; sufficient: boolean }> {\n if (requirement.asset.type === 'native') {\n return { allowance: requirement.amount, sufficient: true }\n }\n const allowance = await readClassicAllowance(runtime, requirement)\n return {\n allowance,\n sufficient: BigInt(allowance) >= BigInt(requirement.amount),\n }\n}\n","import {\n MaxUint256,\n createApproveAction,\n type ContractCallAction,\n} from '@sun-protocol/sun-sdk-core'\nimport type {\n ApprovalPlanOptions,\n ApprovalRequirement,\n} from './types.js'\n\nexport function buildClassicApproveAction(\n requirement: ApprovalRequirement,\n options: Pick<ApprovalPlanOptions, 'amount' | 'feeLimit'> = {},\n): ContractCallAction | undefined {\n if (requirement.asset.type === 'native') return undefined\n return createApproveAction({\n id: `approve-${requirement.asset.token}-${requirement.spender}`,\n target: requirement.asset.token,\n spender: requirement.spender,\n amount: options.amount === 'exact'\n ? requirement.amount\n : MaxUint256.toString(),\n ...(options.feeLimit !== undefined ? { feeLimit: options.feeLimit } : {}),\n })\n}\n","import { SDKError } from '@sun-protocol/sun-sdk-core'\nimport { normalizeBaseUnitAmount } from '../common.js'\nimport {\n requireRuntime,\n type ProtocolsContext,\n} from '../context.js'\nimport { checkClassicAllowance } from './check.js'\nimport { buildClassicApproveAction } from './classic.js'\nimport type {\n ApprovalPlanOptions,\n ApprovalPlanResult,\n ApprovalRequirement,\n} from './types.js'\n\n/** Plans a token approval without signing or broadcasting it. */\nexport async function planApproval(\n context: ProtocolsContext,\n requirement: ApprovalRequirement,\n options: ApprovalPlanOptions = {},\n): Promise<ApprovalPlanResult> {\n const mode = options.mode ?? 'auto'\n normalizeBaseUnitAmount(requirement.amount, 'approval amount')\n\n if (requirement.asset.type === 'native') {\n return {\n mode,\n requirement,\n allowance: requirement.amount,\n sufficient: true,\n actions: [],\n }\n }\n\n if (mode === 'none') {\n return { mode, requirement, actions: [] }\n }\n\n if (mode === 'permit2') {\n throw new SDKError(\n 'SDK_WALLET_CAPABILITY_ERROR',\n 'Permit2 approval is unavailable until a Permit2 adapter is configured',\n { mode, token: requirement.asset.token },\n )\n }\n\n const runtime = requireRuntime(context, 'Token allowance check')\n const check = await checkClassicAllowance(runtime, requirement)\n if (check.sufficient) {\n return {\n mode,\n requirement,\n allowance: check.allowance,\n sufficient: true,\n actions: [],\n }\n }\n\n const action = buildClassicApproveAction(requirement, options)\n return {\n mode,\n requirement,\n allowance: check.allowance,\n sufficient: false,\n actions: action ? [action] : [],\n }\n}\n","import { SDKError } from '@sun-protocol/sun-sdk-core'\nimport type { ContractRead, MulticallResult } from '@sun-protocol/sun-sdk-runtime'\nimport {\n requireRuntime,\n type ProtocolsContext,\n} from '../context.js'\n\nexport async function readRequiredContract<T>(\n context: ProtocolsContext,\n call: ContractRead,\n operation: string,\n): Promise<T> {\n const runtime = requireRuntime(context, operation)\n const value = await runtime.readContract<T>(call)\n if (value === undefined || value === null) {\n throw new SDKError('SDK_CONTRACT_ERROR', `${operation} returned an empty result`, { call })\n }\n return value\n}\n\nexport async function readMulticallRequired<T>(\n context: ProtocolsContext,\n calls: readonly ContractRead[],\n operation: string,\n): Promise<readonly T[]> {\n const runtime = requireRuntime(context, operation)\n const results = await runtime.multicall<T>(calls)\n return results.map((result: MulticallResult<T>, index: number) => {\n if (!result.success || result.value === undefined) {\n throw new SDKError('SDK_CONTRACT_ERROR', `${operation} multicall item failed`, {\n index,\n call: calls[index],\n error: result.error,\n })\n }\n return result.value\n })\n}\n","import { getWrappedNativeAddress } from '@sun-protocol/sun-sdk-chains'\nimport {\n Percent,\n SDKError,\n TRON_ZERO_ADDRESS,\n Token,\n assertTronAddress,\n type TronAddress,\n} from '@sun-protocol/sun-sdk-core'\nimport {\n evmHexToTronAddress as evmHexToTronAddressV2,\n tronAddressToEvmHex,\n} from '@sun-protocol/sun-sdk-sunswap-v2'\nimport type { ProtocolsContext } from '../context.js'\nimport type { SlippageInput } from '../types/common.js'\n\nconst PERCENT_PATTERN = /^(\\d+)(?:\\.(\\d+))?%$/\n\nexport type ProtocolTokenKind = 'native' | 'token'\n\nexport interface ProtocolToken {\n readonly kind: ProtocolTokenKind\n readonly input: string\n readonly contractAddress: TronAddress\n readonly wrappedContractAddress: TronAddress\n readonly token: Token\n}\n\nexport function isNativeTrxInput(context: ProtocolsContext, token: string): boolean {\n return token.toUpperCase() === 'TRX' || token === context.chain.contracts.trx\n}\n\nexport function evmHexToTronAddress(address: string, label = 'address'): TronAddress {\n const normalized = address.startsWith('0x') ? address.toLowerCase() : `0x${address.toLowerCase()}`\n return evmHexToTronAddressV2(normalized, label)\n}\n\nexport function tronAddressToEvmAddress(address: TronAddress | string, label = 'address'): `0x${string}` {\n return `0x${tronAddressToEvmHex(assertTronAddress(address, label))}`\n}\n\n/** Canonical address for comparing configured tokens with decoded contract results. */\nexport function normalizeTronAddress(address: string, label = 'address'): TronAddress {\n if (/^41[0-9a-fA-F]{40}$/.test(address)) return evmHexToTronAddress(`0x${address.slice(2)}`, label)\n if (/^0x[0-9a-fA-F]{40}$/.test(address)) return evmHexToTronAddress(address, label)\n return evmHexToTronAddress(tronAddressToEvmAddress(address, label), label)\n}\n\nexport function normalizeProtocolToken(\n context: ProtocolsContext,\n token: string,\n label: string,\n metadata: { readonly decimals?: number; readonly symbol?: string; readonly name?: string } = {},\n): ProtocolToken {\n const wrappedContractAddress = getWrappedNativeAddress(context.network)\n const kind: ProtocolTokenKind = isNativeTrxInput(context, token) ? 'native' : 'token'\n const contractAddress = kind === 'native' ? TRON_ZERO_ADDRESS : assertTronAddress(token, label)\n const mathAddress = kind === 'native' ? wrappedContractAddress : contractAddress\n const evmAddress = `0x${tronAddressToEvmHex(mathAddress)}`.toLowerCase()\n\n return {\n kind,\n input: token,\n contractAddress,\n wrappedContractAddress,\n token: new Token(\n context.chain.uniswapChainId,\n evmAddress,\n metadata.decimals ?? 6,\n metadata.symbol,\n metadata.name,\n true,\n ),\n }\n}\n\nfunction parseLiquidityPercentageInput(value: SlippageInput | Percent, label: string): Percent {\n if (value instanceof Percent) return value\n\n const match = PERCENT_PATTERN.exec(value)\n if (!match) {\n throw new SDKError('SDK_INVALID_ARGUMENT', `${label} must be a percentage string`, {\n label,\n percentage: value,\n })\n }\n\n const whole = match[1] ?? '0'\n const fraction = match[2] ?? ''\n const scale = 10n ** BigInt(fraction.length)\n const percentageUnits = BigInt(whole) * scale + BigInt(fraction || '0')\n return new Percent(percentageUnits.toString(), (100n * scale).toString())\n}\n\nexport function normalizeLiquidityPercentage(value: SlippageInput | Percent, label: string): Percent {\n const percent = parseLiquidityPercentageInput(value, label)\n if (percent.equalTo(0)) {\n throw new SDKError('SDK_INVALID_ARGUMENT', `${label} must be greater than 0%`, {\n label,\n percentage: percent.toSignificant(),\n })\n }\n if (percent.greaterThan(1)) {\n throw new SDKError('SDK_INVALID_ARGUMENT', `${label} must be at most 100%`, {\n label,\n percentage: percent.toSignificant(),\n })\n }\n return percent\n}\n"],"mappings":";;;;;;AAGA,eAAsB,qBACpB,SACA,aACiB;AACjB,MAAI,YAAY,MAAM,SAAS,SAAU,QAAO;AAChD,QAAM,SAAS,MAAM,QAAQ,aAAuC;AAAA,IAClE,QAAQ,YAAY,MAAM;AAAA,IAC1B,kBAAkB;AAAA,IAClB,YAAY;AAAA,MACV,EAAE,MAAM,WAAW,OAAO,YAAY,MAAM;AAAA,MAC5C,EAAE,MAAM,WAAW,OAAO,YAAY,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