@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/dist/index.d.cts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Runtime, WalletCapabilities, ContractClient, WalletAdapter } from '@sun-protocol/sun-sdk-runtime';
|
|
2
|
+
import { TronAddress, ContractCallAction, TransactionAction, BigintIsh, Percent, SDKError, Network } from '@sun-protocol/sun-sdk-core';
|
|
3
|
+
import { A as ApprovalMode, P as ProtocolsContext, d as PlanTimingOptions, S as SlippageInput, e as SunSDKCreateOptions } from './common-8VQQ0FSU.cjs';
|
|
4
|
+
export { C as ContractOverrides, E as ExecutedActionResult, f as PlanSummary, g as ProtocolAdapterDependencies, c as ProtocolClientOptions, h as ProtocolClientOverrides, R as RecipientOptions, T as TransactionPlan, a as TransactionPlanExecutionResult, b as TransactionPlanExecutor, i as TransactionPlanFinalResult, j as TransactionPlanKind, k as createContextExecutor, l as createProtocolsContext, m as executeTransactionPlan, r as requireRuntime, n as requireWalletAddress, o as requireWalletSnapshot } from './common-8VQQ0FSU.cjs';
|
|
5
|
+
import { FetchLike, JsonParser } from '@sun-protocol/sun-sdk-api';
|
|
6
|
+
import { ChainConfig } from '@sun-protocol/sun-sdk-chains';
|
|
7
|
+
import { LiquidityClient } from './liquidity/index.cjs';
|
|
8
|
+
export { SUNSWAP_V2_LIQUIDITY_PROTOCOL_ID, SUNSWAP_V3_LIQUIDITY_PROTOCOL_ID, SUNSWAP_V4_LIQUIDITY_PROTOCOL_ID, V2LiquidityClient, V3LiquidityClient, V4LiquidityClient, createLiquidityClient, createV2LiquidityClient, planV2AddLiquidity, planV2RemoveLiquidity } from './liquidity/index.cjs';
|
|
9
|
+
import { PositionsClient } from './positions/index.cjs';
|
|
10
|
+
export { PositionActionOptions, PositionCollectInput, PositionLiquidityInput, PositionRemoveInput, SUNSWAP_V3_POSITION_PROTOCOL_ID, SUNSWAP_V4_POSITION_PROTOCOL_ID, V3PositionCollectInput, V3PositionReadInput, V3PositionRemoveInput, V3PositionSnapshot, V3PositionsClient, V4PositionCollectInput, V4PositionFeesSnapshot, V4PositionReadInput, V4PositionRemoveInput, V4PositionSnapshot, V4PositionsClient, assertV3PositionUsdtTransfer, createPositionsClient, createV3PositionsExecutor } from './positions/index.cjs';
|
|
11
|
+
import { f as PumpClient } from './execute-BNKh6dT6.cjs';
|
|
12
|
+
export { A as AgentTokenLaunchParams, b as PumpBuyClient, c as PumpBuyClientShape, d as PumpBuyExactTokenQuote, P as PumpBuyInput, e as PumpBuyQuote, g as PumpClientShape, h as PumpLaunchClient, i as PumpLaunchClientShape, j as PumpQuoteBuyExactTokenInput, k as PumpQuoteBuyInput, l as PumpQuoteSellInput, m as PumpSellApprovalMode, n as PumpSellClient, o as PumpSellClientShape, a as PumpSellInput, p as PumpSellQuote, q as PumpTokenHttpClient, r as PumpTokenInput, S as SUNPUMP_LAUNCHPAD_PROTOCOL_ID, s as SUNPUMP_V2_PROTOCOL_ID, t as createPumpClient, u as createPumpExecutor } from './execute-BNKh6dT6.cjs';
|
|
13
|
+
import { j as SwapNamespace } from './intents-BSXq1HvW.cjs';
|
|
14
|
+
export { P as PSM_PROTOCOL_ID, b as PsmApprovalMode, c as PsmContractOverrides, d as PsmReadInput, e as PsmSwapClient, f as PsmSwapClientShape, g as PsmSwapInput, h as PsmSwapQuote, R as RouterRouteType, i as RouterSwapQuote, k as SwapPlanOptions, a as SwapQuote, l as SwapQuoteAmounts, S as SwapQuoteInput, m as SwapQuoteKind, n as SwapRouterClient, o as SwapRouterClientShape, p as SwapRouterExecuteInput, q as SwapRouterPlanInput, r as SwapTransactionOptions, U as UNIVERSAL_ROUTER_PROTOCOL_ID, s as V2SwapClient, t as V2SwapClientShape, V as V2SwapDirection, u as V2SwapMode, v as V2SwapQuote, w as V2SwapQuoteInput, x as WTRX_PROTOCOL_ID, y as WtrxSwapAction, W as WtrxSwapQuote, z as WtrxSwapRoute, A as createPsmClient, B as createPsmSwapClient, C as createRouterSwapExecutor, D as createSwapRouterClient, E as createV2Client, F as createV2SwapClient, G as createV2SwapExecutor, H as materializeUniversalRouterAction, I as planPsmSwap, J as planRouterSwap, K as quotePsmSwap, L as readPsm } from './intents-BSXq1HvW.cjs';
|
|
15
|
+
export { L as LiquidityAmountInput, a as LiquidityPlanOptions, V as V2AddLiquidityInput, b as V2RemoveLiquidityInput, c as V3AddLiquidityInput, d as V3IncreaseLiquidityInput, e as V3PoolStateInput, f as V4IncreaseLiquidityInput, g as V4InitializePoolInput, h as V4MintPositionInput, i as V4PoolReadInput, j as V4PoolSnapshot } from './types-BTPdCC7k.cjs';
|
|
16
|
+
export { PsmQuote, PsmSnapshot, PsmSwapDirection, PsmSwapMode } from '@sun-protocol/sun-sdk-psm';
|
|
17
|
+
import '@sun-protocol/sun-sdk-sunswap-v4';
|
|
18
|
+
import '@sun-protocol/sun-sdk-launchpad';
|
|
19
|
+
|
|
20
|
+
type ApprovalAsset = {
|
|
21
|
+
readonly type: 'native';
|
|
22
|
+
} | {
|
|
23
|
+
readonly type: 'token';
|
|
24
|
+
readonly token: TronAddress;
|
|
25
|
+
};
|
|
26
|
+
interface ApprovalRequirement {
|
|
27
|
+
readonly asset: ApprovalAsset;
|
|
28
|
+
readonly owner: TronAddress;
|
|
29
|
+
readonly spender: TronAddress;
|
|
30
|
+
readonly amount: string;
|
|
31
|
+
}
|
|
32
|
+
interface ApprovalPlanOptions {
|
|
33
|
+
readonly mode?: ApprovalMode;
|
|
34
|
+
readonly amount?: 'exact' | 'max';
|
|
35
|
+
readonly feeLimit?: number;
|
|
36
|
+
}
|
|
37
|
+
interface ApprovalPlanResult {
|
|
38
|
+
readonly mode: ApprovalMode;
|
|
39
|
+
readonly requirement: ApprovalRequirement;
|
|
40
|
+
readonly allowance?: string;
|
|
41
|
+
readonly sufficient?: boolean;
|
|
42
|
+
readonly actions: readonly ContractCallAction[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare function readClassicAllowance(runtime: Runtime, requirement: ApprovalRequirement): Promise<string>;
|
|
46
|
+
declare function checkClassicAllowance(runtime: Runtime, requirement: ApprovalRequirement): Promise<{
|
|
47
|
+
allowance: string;
|
|
48
|
+
sufficient: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
|
|
51
|
+
declare function buildClassicApproveAction(requirement: ApprovalRequirement, options?: Pick<ApprovalPlanOptions, 'amount' | 'feeLimit'>): ContractCallAction | undefined;
|
|
52
|
+
|
|
53
|
+
/** Plans a token approval without signing or broadcasting it. */
|
|
54
|
+
declare function planApproval(context: ProtocolsContext, requirement: ApprovalRequirement, options?: ApprovalPlanOptions): Promise<ApprovalPlanResult>;
|
|
55
|
+
|
|
56
|
+
interface RouterPermit2AuthorizationInput {
|
|
57
|
+
readonly owner: TronAddress;
|
|
58
|
+
readonly token: TronAddress;
|
|
59
|
+
readonly spender?: TronAddress;
|
|
60
|
+
readonly amount: string;
|
|
61
|
+
readonly approval: ApprovalMode;
|
|
62
|
+
readonly ttlSeconds?: number;
|
|
63
|
+
readonly deadline?: string | number | bigint;
|
|
64
|
+
readonly walletCapabilities?: WalletCapabilities;
|
|
65
|
+
/** Shared allowance mode for the ERC20 and Permit2 approval steps. Defaults to the requested amount. */
|
|
66
|
+
readonly approveAmountType?: 'exact' | 'max';
|
|
67
|
+
}
|
|
68
|
+
interface RouterPermit2AuthorizationPlan {
|
|
69
|
+
readonly actions: readonly TransactionAction[];
|
|
70
|
+
readonly signatureActionId?: string;
|
|
71
|
+
readonly permitSingle?: unknown;
|
|
72
|
+
readonly mode: 'none' | 'typed-data' | 'on-chain' | 'already-approved';
|
|
73
|
+
}
|
|
74
|
+
declare function planRouterPermit2Authorization(context: ProtocolsContext, input: RouterPermit2AuthorizationInput): Promise<RouterPermit2AuthorizationPlan>;
|
|
75
|
+
|
|
76
|
+
declare function parseSlippage(value: SlippageInput): Percent;
|
|
77
|
+
declare function validateSlippage(value: Percent): void;
|
|
78
|
+
declare function slippageToBips(value: SlippageInput): number;
|
|
79
|
+
declare function applySlippageMin(expected: bigint, slippageBips: number): bigint;
|
|
80
|
+
declare function applySlippageMax(expected: bigint, slippageBips: number): bigint;
|
|
81
|
+
declare function normalizeBaseUnitAmount(value: BigintIsh, label?: string, options?: {
|
|
82
|
+
allowZero?: boolean;
|
|
83
|
+
}): string;
|
|
84
|
+
declare function normalizeDeadline(context: ProtocolsContext, options?: PlanTimingOptions): string;
|
|
85
|
+
declare function normalizeRecipient(context: ProtocolsContext, recipient: TronAddress | string | undefined, operation: string, walletAddress?: TronAddress): Promise<TronAddress>;
|
|
86
|
+
declare function nextPlanId(context: ProtocolsContext, prefix: string): string;
|
|
87
|
+
|
|
88
|
+
declare function normalizeProtocolError(error: unknown, fallbackCode: string, message: string, context?: Record<string, unknown>): SDKError<string>;
|
|
89
|
+
declare function withExecutionContext(error: SDKError<string>, context: {
|
|
90
|
+
readonly actionId: string;
|
|
91
|
+
readonly completedActionIds: readonly string[];
|
|
92
|
+
}): SDKError<string>;
|
|
93
|
+
|
|
94
|
+
declare function executeHttpAction(action: TransactionAction, fetchImpl: FetchLike, jsonParser?: JsonParser): Promise<unknown>;
|
|
95
|
+
|
|
96
|
+
declare class SunSDK {
|
|
97
|
+
readonly network: Network;
|
|
98
|
+
readonly chain: ChainConfig;
|
|
99
|
+
readonly runtime: Runtime | undefined;
|
|
100
|
+
readonly contract: ContractClient | undefined;
|
|
101
|
+
readonly wallet: WalletAdapter | undefined;
|
|
102
|
+
readonly context: ProtocolsContext;
|
|
103
|
+
readonly pump: PumpClient;
|
|
104
|
+
readonly swap: SwapNamespace;
|
|
105
|
+
readonly liquidity: LiquidityClient;
|
|
106
|
+
readonly positions: PositionsClient;
|
|
107
|
+
private constructor();
|
|
108
|
+
static create(options: SunSDKCreateOptions): Promise<SunSDK>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface UsdtReader {
|
|
112
|
+
paused(): Promise<boolean>;
|
|
113
|
+
isBlackListed(address: string): Promise<boolean>;
|
|
114
|
+
}
|
|
115
|
+
interface TransferSource {
|
|
116
|
+
readonly address: string;
|
|
117
|
+
readonly role: 'v3-pool' | 'position-manager';
|
|
118
|
+
}
|
|
119
|
+
type UsdtTransferValidationResult = {
|
|
120
|
+
readonly status: 'allowed';
|
|
121
|
+
} | {
|
|
122
|
+
readonly status: 'blocked';
|
|
123
|
+
readonly reason: 'USDT_PAUSED';
|
|
124
|
+
} | {
|
|
125
|
+
readonly status: 'blocked';
|
|
126
|
+
readonly reason: 'USDT_SOURCE_BLACKLISTED';
|
|
127
|
+
readonly sources: readonly TransferSource[];
|
|
128
|
+
} | {
|
|
129
|
+
readonly status: 'unknown';
|
|
130
|
+
readonly reason: 'MISSING_TRANSFER_SOURCE' | 'CHECK_FAILED';
|
|
131
|
+
};
|
|
132
|
+
/** Applies the USDT paused/blacklist check. Unknown results never authorize submission. */
|
|
133
|
+
declare function usdtValidateTransfer(input: {
|
|
134
|
+
readonly reader: UsdtReader;
|
|
135
|
+
readonly transfersUsdt: boolean;
|
|
136
|
+
readonly sources: readonly TransferSource[];
|
|
137
|
+
}): Promise<UsdtTransferValidationResult>;
|
|
138
|
+
|
|
139
|
+
export { type ApprovalAsset, ApprovalMode, type ApprovalPlanOptions, type ApprovalPlanResult, type ApprovalRequirement, LiquidityClient, PlanTimingOptions, PositionsClient, ProtocolsContext, PumpClient, type RouterPermit2AuthorizationInput, type RouterPermit2AuthorizationPlan, SlippageInput, SunSDK, SunSDKCreateOptions, SwapNamespace, type TransferSource, type UsdtReader, type UsdtTransferValidationResult, applySlippageMax, applySlippageMin, buildClassicApproveAction, checkClassicAllowance, executeHttpAction, nextPlanId, normalizeBaseUnitAmount, normalizeDeadline, normalizeProtocolError, normalizeRecipient, parseSlippage, planApproval, planRouterPermit2Authorization, readClassicAllowance, slippageToBips, usdtValidateTransfer, validateSlippage, withExecutionContext };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Runtime, WalletCapabilities, ContractClient, WalletAdapter } from '@sun-protocol/sun-sdk-runtime';
|
|
2
|
+
import { TronAddress, ContractCallAction, TransactionAction, BigintIsh, Percent, SDKError, Network } from '@sun-protocol/sun-sdk-core';
|
|
3
|
+
import { A as ApprovalMode, P as ProtocolsContext, d as PlanTimingOptions, S as SlippageInput, e as SunSDKCreateOptions } from './common-8VQQ0FSU.js';
|
|
4
|
+
export { C as ContractOverrides, E as ExecutedActionResult, f as PlanSummary, g as ProtocolAdapterDependencies, c as ProtocolClientOptions, h as ProtocolClientOverrides, R as RecipientOptions, T as TransactionPlan, a as TransactionPlanExecutionResult, b as TransactionPlanExecutor, i as TransactionPlanFinalResult, j as TransactionPlanKind, k as createContextExecutor, l as createProtocolsContext, m as executeTransactionPlan, r as requireRuntime, n as requireWalletAddress, o as requireWalletSnapshot } from './common-8VQQ0FSU.js';
|
|
5
|
+
import { FetchLike, JsonParser } from '@sun-protocol/sun-sdk-api';
|
|
6
|
+
import { ChainConfig } from '@sun-protocol/sun-sdk-chains';
|
|
7
|
+
import { LiquidityClient } from './liquidity/index.js';
|
|
8
|
+
export { SUNSWAP_V2_LIQUIDITY_PROTOCOL_ID, SUNSWAP_V3_LIQUIDITY_PROTOCOL_ID, SUNSWAP_V4_LIQUIDITY_PROTOCOL_ID, V2LiquidityClient, V3LiquidityClient, V4LiquidityClient, createLiquidityClient, createV2LiquidityClient, planV2AddLiquidity, planV2RemoveLiquidity } from './liquidity/index.js';
|
|
9
|
+
import { PositionsClient } from './positions/index.js';
|
|
10
|
+
export { PositionActionOptions, PositionCollectInput, PositionLiquidityInput, PositionRemoveInput, SUNSWAP_V3_POSITION_PROTOCOL_ID, SUNSWAP_V4_POSITION_PROTOCOL_ID, V3PositionCollectInput, V3PositionReadInput, V3PositionRemoveInput, V3PositionSnapshot, V3PositionsClient, V4PositionCollectInput, V4PositionFeesSnapshot, V4PositionReadInput, V4PositionRemoveInput, V4PositionSnapshot, V4PositionsClient, assertV3PositionUsdtTransfer, createPositionsClient, createV3PositionsExecutor } from './positions/index.js';
|
|
11
|
+
import { f as PumpClient } from './execute-CVhcKZxF.js';
|
|
12
|
+
export { A as AgentTokenLaunchParams, b as PumpBuyClient, c as PumpBuyClientShape, d as PumpBuyExactTokenQuote, P as PumpBuyInput, e as PumpBuyQuote, g as PumpClientShape, h as PumpLaunchClient, i as PumpLaunchClientShape, j as PumpQuoteBuyExactTokenInput, k as PumpQuoteBuyInput, l as PumpQuoteSellInput, m as PumpSellApprovalMode, n as PumpSellClient, o as PumpSellClientShape, a as PumpSellInput, p as PumpSellQuote, q as PumpTokenHttpClient, r as PumpTokenInput, S as SUNPUMP_LAUNCHPAD_PROTOCOL_ID, s as SUNPUMP_V2_PROTOCOL_ID, t as createPumpClient, u as createPumpExecutor } from './execute-CVhcKZxF.js';
|
|
13
|
+
import { j as SwapNamespace } from './intents-CwOttD75.js';
|
|
14
|
+
export { P as PSM_PROTOCOL_ID, b as PsmApprovalMode, c as PsmContractOverrides, d as PsmReadInput, e as PsmSwapClient, f as PsmSwapClientShape, g as PsmSwapInput, h as PsmSwapQuote, R as RouterRouteType, i as RouterSwapQuote, k as SwapPlanOptions, a as SwapQuote, l as SwapQuoteAmounts, S as SwapQuoteInput, m as SwapQuoteKind, n as SwapRouterClient, o as SwapRouterClientShape, p as SwapRouterExecuteInput, q as SwapRouterPlanInput, r as SwapTransactionOptions, U as UNIVERSAL_ROUTER_PROTOCOL_ID, s as V2SwapClient, t as V2SwapClientShape, V as V2SwapDirection, u as V2SwapMode, v as V2SwapQuote, w as V2SwapQuoteInput, x as WTRX_PROTOCOL_ID, y as WtrxSwapAction, W as WtrxSwapQuote, z as WtrxSwapRoute, A as createPsmClient, B as createPsmSwapClient, C as createRouterSwapExecutor, D as createSwapRouterClient, E as createV2Client, F as createV2SwapClient, G as createV2SwapExecutor, H as materializeUniversalRouterAction, I as planPsmSwap, J as planRouterSwap, K as quotePsmSwap, L as readPsm } from './intents-CwOttD75.js';
|
|
15
|
+
export { L as LiquidityAmountInput, a as LiquidityPlanOptions, V as V2AddLiquidityInput, b as V2RemoveLiquidityInput, c as V3AddLiquidityInput, d as V3IncreaseLiquidityInput, e as V3PoolStateInput, f as V4IncreaseLiquidityInput, g as V4InitializePoolInput, h as V4MintPositionInput, i as V4PoolReadInput, j as V4PoolSnapshot } from './types-BfrouFmO.js';
|
|
16
|
+
export { PsmQuote, PsmSnapshot, PsmSwapDirection, PsmSwapMode } from '@sun-protocol/sun-sdk-psm';
|
|
17
|
+
import '@sun-protocol/sun-sdk-sunswap-v4';
|
|
18
|
+
import '@sun-protocol/sun-sdk-launchpad';
|
|
19
|
+
|
|
20
|
+
type ApprovalAsset = {
|
|
21
|
+
readonly type: 'native';
|
|
22
|
+
} | {
|
|
23
|
+
readonly type: 'token';
|
|
24
|
+
readonly token: TronAddress;
|
|
25
|
+
};
|
|
26
|
+
interface ApprovalRequirement {
|
|
27
|
+
readonly asset: ApprovalAsset;
|
|
28
|
+
readonly owner: TronAddress;
|
|
29
|
+
readonly spender: TronAddress;
|
|
30
|
+
readonly amount: string;
|
|
31
|
+
}
|
|
32
|
+
interface ApprovalPlanOptions {
|
|
33
|
+
readonly mode?: ApprovalMode;
|
|
34
|
+
readonly amount?: 'exact' | 'max';
|
|
35
|
+
readonly feeLimit?: number;
|
|
36
|
+
}
|
|
37
|
+
interface ApprovalPlanResult {
|
|
38
|
+
readonly mode: ApprovalMode;
|
|
39
|
+
readonly requirement: ApprovalRequirement;
|
|
40
|
+
readonly allowance?: string;
|
|
41
|
+
readonly sufficient?: boolean;
|
|
42
|
+
readonly actions: readonly ContractCallAction[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare function readClassicAllowance(runtime: Runtime, requirement: ApprovalRequirement): Promise<string>;
|
|
46
|
+
declare function checkClassicAllowance(runtime: Runtime, requirement: ApprovalRequirement): Promise<{
|
|
47
|
+
allowance: string;
|
|
48
|
+
sufficient: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
|
|
51
|
+
declare function buildClassicApproveAction(requirement: ApprovalRequirement, options?: Pick<ApprovalPlanOptions, 'amount' | 'feeLimit'>): ContractCallAction | undefined;
|
|
52
|
+
|
|
53
|
+
/** Plans a token approval without signing or broadcasting it. */
|
|
54
|
+
declare function planApproval(context: ProtocolsContext, requirement: ApprovalRequirement, options?: ApprovalPlanOptions): Promise<ApprovalPlanResult>;
|
|
55
|
+
|
|
56
|
+
interface RouterPermit2AuthorizationInput {
|
|
57
|
+
readonly owner: TronAddress;
|
|
58
|
+
readonly token: TronAddress;
|
|
59
|
+
readonly spender?: TronAddress;
|
|
60
|
+
readonly amount: string;
|
|
61
|
+
readonly approval: ApprovalMode;
|
|
62
|
+
readonly ttlSeconds?: number;
|
|
63
|
+
readonly deadline?: string | number | bigint;
|
|
64
|
+
readonly walletCapabilities?: WalletCapabilities;
|
|
65
|
+
/** Shared allowance mode for the ERC20 and Permit2 approval steps. Defaults to the requested amount. */
|
|
66
|
+
readonly approveAmountType?: 'exact' | 'max';
|
|
67
|
+
}
|
|
68
|
+
interface RouterPermit2AuthorizationPlan {
|
|
69
|
+
readonly actions: readonly TransactionAction[];
|
|
70
|
+
readonly signatureActionId?: string;
|
|
71
|
+
readonly permitSingle?: unknown;
|
|
72
|
+
readonly mode: 'none' | 'typed-data' | 'on-chain' | 'already-approved';
|
|
73
|
+
}
|
|
74
|
+
declare function planRouterPermit2Authorization(context: ProtocolsContext, input: RouterPermit2AuthorizationInput): Promise<RouterPermit2AuthorizationPlan>;
|
|
75
|
+
|
|
76
|
+
declare function parseSlippage(value: SlippageInput): Percent;
|
|
77
|
+
declare function validateSlippage(value: Percent): void;
|
|
78
|
+
declare function slippageToBips(value: SlippageInput): number;
|
|
79
|
+
declare function applySlippageMin(expected: bigint, slippageBips: number): bigint;
|
|
80
|
+
declare function applySlippageMax(expected: bigint, slippageBips: number): bigint;
|
|
81
|
+
declare function normalizeBaseUnitAmount(value: BigintIsh, label?: string, options?: {
|
|
82
|
+
allowZero?: boolean;
|
|
83
|
+
}): string;
|
|
84
|
+
declare function normalizeDeadline(context: ProtocolsContext, options?: PlanTimingOptions): string;
|
|
85
|
+
declare function normalizeRecipient(context: ProtocolsContext, recipient: TronAddress | string | undefined, operation: string, walletAddress?: TronAddress): Promise<TronAddress>;
|
|
86
|
+
declare function nextPlanId(context: ProtocolsContext, prefix: string): string;
|
|
87
|
+
|
|
88
|
+
declare function normalizeProtocolError(error: unknown, fallbackCode: string, message: string, context?: Record<string, unknown>): SDKError<string>;
|
|
89
|
+
declare function withExecutionContext(error: SDKError<string>, context: {
|
|
90
|
+
readonly actionId: string;
|
|
91
|
+
readonly completedActionIds: readonly string[];
|
|
92
|
+
}): SDKError<string>;
|
|
93
|
+
|
|
94
|
+
declare function executeHttpAction(action: TransactionAction, fetchImpl: FetchLike, jsonParser?: JsonParser): Promise<unknown>;
|
|
95
|
+
|
|
96
|
+
declare class SunSDK {
|
|
97
|
+
readonly network: Network;
|
|
98
|
+
readonly chain: ChainConfig;
|
|
99
|
+
readonly runtime: Runtime | undefined;
|
|
100
|
+
readonly contract: ContractClient | undefined;
|
|
101
|
+
readonly wallet: WalletAdapter | undefined;
|
|
102
|
+
readonly context: ProtocolsContext;
|
|
103
|
+
readonly pump: PumpClient;
|
|
104
|
+
readonly swap: SwapNamespace;
|
|
105
|
+
readonly liquidity: LiquidityClient;
|
|
106
|
+
readonly positions: PositionsClient;
|
|
107
|
+
private constructor();
|
|
108
|
+
static create(options: SunSDKCreateOptions): Promise<SunSDK>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface UsdtReader {
|
|
112
|
+
paused(): Promise<boolean>;
|
|
113
|
+
isBlackListed(address: string): Promise<boolean>;
|
|
114
|
+
}
|
|
115
|
+
interface TransferSource {
|
|
116
|
+
readonly address: string;
|
|
117
|
+
readonly role: 'v3-pool' | 'position-manager';
|
|
118
|
+
}
|
|
119
|
+
type UsdtTransferValidationResult = {
|
|
120
|
+
readonly status: 'allowed';
|
|
121
|
+
} | {
|
|
122
|
+
readonly status: 'blocked';
|
|
123
|
+
readonly reason: 'USDT_PAUSED';
|
|
124
|
+
} | {
|
|
125
|
+
readonly status: 'blocked';
|
|
126
|
+
readonly reason: 'USDT_SOURCE_BLACKLISTED';
|
|
127
|
+
readonly sources: readonly TransferSource[];
|
|
128
|
+
} | {
|
|
129
|
+
readonly status: 'unknown';
|
|
130
|
+
readonly reason: 'MISSING_TRANSFER_SOURCE' | 'CHECK_FAILED';
|
|
131
|
+
};
|
|
132
|
+
/** Applies the USDT paused/blacklist check. Unknown results never authorize submission. */
|
|
133
|
+
declare function usdtValidateTransfer(input: {
|
|
134
|
+
readonly reader: UsdtReader;
|
|
135
|
+
readonly transfersUsdt: boolean;
|
|
136
|
+
readonly sources: readonly TransferSource[];
|
|
137
|
+
}): Promise<UsdtTransferValidationResult>;
|
|
138
|
+
|
|
139
|
+
export { type ApprovalAsset, ApprovalMode, type ApprovalPlanOptions, type ApprovalPlanResult, type ApprovalRequirement, LiquidityClient, PlanTimingOptions, PositionsClient, ProtocolsContext, PumpClient, type RouterPermit2AuthorizationInput, type RouterPermit2AuthorizationPlan, SlippageInput, SunSDK, SunSDKCreateOptions, SwapNamespace, type TransferSource, type UsdtReader, type UsdtTransferValidationResult, applySlippageMax, applySlippageMin, buildClassicApproveAction, checkClassicAllowance, executeHttpAction, nextPlanId, normalizeBaseUnitAmount, normalizeDeadline, normalizeProtocolError, normalizeRecipient, parseSlippage, planApproval, planRouterPermit2Authorization, readClassicAllowance, slippageToBips, usdtValidateTransfer, validateSlippage, withExecutionContext };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LiquidityClient,
|
|
3
|
+
V2LiquidityClient,
|
|
4
|
+
V4LiquidityClient,
|
|
5
|
+
createLiquidityClient,
|
|
6
|
+
createV2LiquidityClient,
|
|
7
|
+
planV2AddLiquidity,
|
|
8
|
+
planV2RemoveLiquidity
|
|
9
|
+
} from "./chunk-YMGZDXI4.js";
|
|
10
|
+
import {
|
|
11
|
+
PositionsClient,
|
|
12
|
+
SUNSWAP_V3_POSITION_PROTOCOL_ID,
|
|
13
|
+
SUNSWAP_V4_POSITION_PROTOCOL_ID,
|
|
14
|
+
V3PositionsClient,
|
|
15
|
+
V4PositionsClient,
|
|
16
|
+
assertV3PositionUsdtTransfer,
|
|
17
|
+
createPositionsClient,
|
|
18
|
+
createV3PositionsExecutor
|
|
19
|
+
} from "./chunk-PEGREDLT.js";
|
|
20
|
+
import {
|
|
21
|
+
SUNSWAP_V2_LIQUIDITY_PROTOCOL_ID,
|
|
22
|
+
SUNSWAP_V3_LIQUIDITY_PROTOCOL_ID,
|
|
23
|
+
SUNSWAP_V4_LIQUIDITY_PROTOCOL_ID,
|
|
24
|
+
V3LiquidityClient
|
|
25
|
+
} from "./chunk-L5TZCDPH.js";
|
|
26
|
+
import {
|
|
27
|
+
PumpBuyClient,
|
|
28
|
+
PumpClient,
|
|
29
|
+
PumpLaunchClient,
|
|
30
|
+
PumpSellClient,
|
|
31
|
+
SUNPUMP_LAUNCHPAD_PROTOCOL_ID,
|
|
32
|
+
SUNPUMP_V2_PROTOCOL_ID,
|
|
33
|
+
createPumpClient,
|
|
34
|
+
createPumpExecutor
|
|
35
|
+
} from "./chunk-HD2S3Q7L.js";
|
|
36
|
+
import {
|
|
37
|
+
PSM_PROTOCOL_ID,
|
|
38
|
+
PsmSwapClient,
|
|
39
|
+
SwapRouterClient,
|
|
40
|
+
UNIVERSAL_ROUTER_PROTOCOL_ID,
|
|
41
|
+
V2SwapClient,
|
|
42
|
+
WTRX_PROTOCOL_ID,
|
|
43
|
+
createPsmClient,
|
|
44
|
+
createPsmSwapClient,
|
|
45
|
+
createRouterSwapExecutor,
|
|
46
|
+
createSwapRouterClient,
|
|
47
|
+
createV2Client,
|
|
48
|
+
createV2SwapClient,
|
|
49
|
+
materializeUniversalRouterAction,
|
|
50
|
+
planPsmSwap,
|
|
51
|
+
planRouterSwap,
|
|
52
|
+
quotePsmSwap,
|
|
53
|
+
readPsm
|
|
54
|
+
} from "./chunk-ECCGOXNA.js";
|
|
55
|
+
import {
|
|
56
|
+
planRouterPermit2Authorization
|
|
57
|
+
} from "./chunk-OM4OW4KB.js";
|
|
58
|
+
import {
|
|
59
|
+
usdtValidateTransfer
|
|
60
|
+
} from "./chunk-5XDX5563.js";
|
|
61
|
+
import {
|
|
62
|
+
buildClassicApproveAction,
|
|
63
|
+
checkClassicAllowance,
|
|
64
|
+
planApproval,
|
|
65
|
+
readClassicAllowance
|
|
66
|
+
} from "./chunk-C2YCVBPI.js";
|
|
67
|
+
import {
|
|
68
|
+
createV2SwapExecutor
|
|
69
|
+
} from "./chunk-TSHXXRH2.js";
|
|
70
|
+
import {
|
|
71
|
+
applySlippageMax,
|
|
72
|
+
applySlippageMin,
|
|
73
|
+
createContextExecutor,
|
|
74
|
+
createProtocolsContext,
|
|
75
|
+
executeHttpAction,
|
|
76
|
+
executeTransactionPlan,
|
|
77
|
+
nextPlanId,
|
|
78
|
+
normalizeBaseUnitAmount,
|
|
79
|
+
normalizeDeadline,
|
|
80
|
+
normalizeProtocolError,
|
|
81
|
+
normalizeRecipient,
|
|
82
|
+
parseSlippage,
|
|
83
|
+
requireRuntime,
|
|
84
|
+
requireWalletAddress,
|
|
85
|
+
requireWalletSnapshot,
|
|
86
|
+
slippageToBips,
|
|
87
|
+
validateSlippage,
|
|
88
|
+
withExecutionContext
|
|
89
|
+
} from "./chunk-VFVKMC4H.js";
|
|
90
|
+
|
|
91
|
+
// src/swap/namespace.ts
|
|
92
|
+
function createSwapNamespace(context) {
|
|
93
|
+
return {
|
|
94
|
+
router: new SwapRouterClient(context),
|
|
95
|
+
v2: createV2SwapClient(context),
|
|
96
|
+
psm: createPsmSwapClient(context)
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// src/sdk.ts
|
|
101
|
+
var SunSDK = class _SunSDK {
|
|
102
|
+
network;
|
|
103
|
+
chain;
|
|
104
|
+
runtime;
|
|
105
|
+
contract;
|
|
106
|
+
wallet;
|
|
107
|
+
context;
|
|
108
|
+
pump;
|
|
109
|
+
swap;
|
|
110
|
+
liquidity;
|
|
111
|
+
positions;
|
|
112
|
+
constructor(context) {
|
|
113
|
+
this.context = context;
|
|
114
|
+
this.network = context.network;
|
|
115
|
+
this.chain = context.chain;
|
|
116
|
+
this.runtime = context.runtime;
|
|
117
|
+
this.contract = context.runtime?.contract;
|
|
118
|
+
this.wallet = context.runtime?.wallet;
|
|
119
|
+
this.pump = createPumpClient(context);
|
|
120
|
+
this.swap = createSwapNamespace(context);
|
|
121
|
+
this.liquidity = createLiquidityClient(context);
|
|
122
|
+
this.positions = createPositionsClient(context);
|
|
123
|
+
}
|
|
124
|
+
static async create(options) {
|
|
125
|
+
return new _SunSDK(createProtocolsContext(options));
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
export {
|
|
129
|
+
LiquidityClient,
|
|
130
|
+
PSM_PROTOCOL_ID,
|
|
131
|
+
PositionsClient,
|
|
132
|
+
PsmSwapClient,
|
|
133
|
+
PumpBuyClient,
|
|
134
|
+
PumpClient,
|
|
135
|
+
PumpLaunchClient,
|
|
136
|
+
PumpSellClient,
|
|
137
|
+
SUNPUMP_LAUNCHPAD_PROTOCOL_ID,
|
|
138
|
+
SUNPUMP_V2_PROTOCOL_ID,
|
|
139
|
+
SUNSWAP_V2_LIQUIDITY_PROTOCOL_ID,
|
|
140
|
+
SUNSWAP_V3_LIQUIDITY_PROTOCOL_ID,
|
|
141
|
+
SUNSWAP_V3_POSITION_PROTOCOL_ID,
|
|
142
|
+
SUNSWAP_V4_LIQUIDITY_PROTOCOL_ID,
|
|
143
|
+
SUNSWAP_V4_POSITION_PROTOCOL_ID,
|
|
144
|
+
SunSDK,
|
|
145
|
+
SwapRouterClient,
|
|
146
|
+
UNIVERSAL_ROUTER_PROTOCOL_ID,
|
|
147
|
+
V2LiquidityClient,
|
|
148
|
+
V2SwapClient,
|
|
149
|
+
V3LiquidityClient,
|
|
150
|
+
V3PositionsClient,
|
|
151
|
+
V4LiquidityClient,
|
|
152
|
+
V4PositionsClient,
|
|
153
|
+
WTRX_PROTOCOL_ID,
|
|
154
|
+
applySlippageMax,
|
|
155
|
+
applySlippageMin,
|
|
156
|
+
assertV3PositionUsdtTransfer,
|
|
157
|
+
buildClassicApproveAction,
|
|
158
|
+
checkClassicAllowance,
|
|
159
|
+
createContextExecutor,
|
|
160
|
+
createLiquidityClient,
|
|
161
|
+
createPositionsClient,
|
|
162
|
+
createProtocolsContext,
|
|
163
|
+
createPsmClient,
|
|
164
|
+
createPsmSwapClient,
|
|
165
|
+
createPumpClient,
|
|
166
|
+
createPumpExecutor,
|
|
167
|
+
createRouterSwapExecutor,
|
|
168
|
+
createSwapRouterClient,
|
|
169
|
+
createV2Client,
|
|
170
|
+
createV2LiquidityClient,
|
|
171
|
+
createV2SwapClient,
|
|
172
|
+
createV2SwapExecutor,
|
|
173
|
+
createV3PositionsExecutor,
|
|
174
|
+
executeHttpAction,
|
|
175
|
+
executeTransactionPlan,
|
|
176
|
+
materializeUniversalRouterAction,
|
|
177
|
+
nextPlanId,
|
|
178
|
+
normalizeBaseUnitAmount,
|
|
179
|
+
normalizeDeadline,
|
|
180
|
+
normalizeProtocolError,
|
|
181
|
+
normalizeRecipient,
|
|
182
|
+
parseSlippage,
|
|
183
|
+
planApproval,
|
|
184
|
+
planPsmSwap,
|
|
185
|
+
planRouterPermit2Authorization,
|
|
186
|
+
planRouterSwap,
|
|
187
|
+
planV2AddLiquidity,
|
|
188
|
+
planV2RemoveLiquidity,
|
|
189
|
+
quotePsmSwap,
|
|
190
|
+
readClassicAllowance,
|
|
191
|
+
readPsm,
|
|
192
|
+
requireRuntime,
|
|
193
|
+
requireWalletAddress,
|
|
194
|
+
requireWalletSnapshot,
|
|
195
|
+
slippageToBips,
|
|
196
|
+
usdtValidateTransfer,
|
|
197
|
+
validateSlippage,
|
|
198
|
+
withExecutionContext
|
|
199
|
+
};
|
|
200
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/swap/namespace.ts","../src/sdk.ts"],"sourcesContent":["import type { ProtocolsContext } from '../context.js'\nimport { createPsmSwapClient } from './psm.js'\nimport { SwapRouterClient } from './router.js'\nimport type { SwapNamespace } from './types.js'\nimport { createV2SwapClient } from './v2.js'\n\nexport function createSwapNamespace(context: ProtocolsContext): SwapNamespace {\n return {\n router: new SwapRouterClient(context),\n v2: createV2SwapClient(context),\n psm: createPsmSwapClient(context),\n }\n}\n","import type { ChainConfig } from '@sun-protocol/sun-sdk-chains'\nimport type { Network } from '@sun-protocol/sun-sdk-core'\nimport type { ContractClient, Runtime, WalletAdapter } from '@sun-protocol/sun-sdk-runtime'\nimport {\n createProtocolsContext,\n type ProtocolsContext,\n} from './context.js'\nimport { createLiquidityClient, type LiquidityClient } from './liquidity/client.js'\nimport { createPositionsClient, type PositionsClient } from './positions/client.js'\nimport { createPumpClient, type PumpClient } from './pump/client.js'\nimport { createSwapNamespace } from './swap/namespace.js'\nimport type { SwapNamespace } from './swap/types.js'\nimport type { SunSDKCreateOptions } from './types/options.js'\n\nexport class SunSDK {\n readonly network: Network\n readonly chain: ChainConfig\n readonly runtime: Runtime | undefined\n readonly contract: ContractClient | undefined\n readonly wallet: WalletAdapter | undefined\n readonly context: ProtocolsContext\n readonly pump: PumpClient\n readonly swap: SwapNamespace\n readonly liquidity: LiquidityClient\n readonly positions: PositionsClient\n\n private constructor(context: ProtocolsContext) {\n this.context = context\n this.network = context.network\n this.chain = context.chain\n this.runtime = context.runtime\n this.contract = context.runtime?.contract\n this.wallet = context.runtime?.wallet\n this.pump = createPumpClient(context)\n this.swap = createSwapNamespace(context)\n this.liquidity = createLiquidityClient(context)\n this.positions = createPositionsClient(context)\n }\n\n static async create(options: SunSDKCreateOptions): Promise<SunSDK> {\n return new SunSDK(createProtocolsContext(options))\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMO,SAAS,oBAAoB,SAA0C;AAC5E,SAAO;AAAA,IACL,QAAQ,IAAI,iBAAiB,OAAO;AAAA,IACpC,IAAI,mBAAmB,OAAO;AAAA,IAC9B,KAAK,oBAAoB,OAAO;AAAA,EAClC;AACF;;;ACEO,IAAM,SAAN,MAAM,QAAO;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAED,YAAY,SAA2B;AAC7C,SAAK,UAAU;AACf,SAAK,UAAU,QAAQ;AACvB,SAAK,QAAQ,QAAQ;AACrB,SAAK,UAAU,QAAQ;AACvB,SAAK,WAAW,QAAQ,SAAS;AACjC,SAAK,SAAS,QAAQ,SAAS;AAC/B,SAAK,OAAO,iBAAiB,OAAO;AACpC,SAAK,OAAO,oBAAoB,OAAO;AACvC,SAAK,YAAY,sBAAsB,OAAO;AAC9C,SAAK,YAAY,sBAAsB,OAAO;AAAA,EAChD;AAAA,EAEA,aAAa,OAAO,SAA+C;AACjE,WAAO,IAAI,QAAO,uBAAuB,OAAO,CAAC;AAAA,EACnD;AACF;","names":[]}
|