@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
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import * as _sun_protocol_sun_sdk_core from '@sun-protocol/sun-sdk-core';
|
|
2
|
+
import { TronAddress, TransactionAction, DeferredContractCallAction } from '@sun-protocol/sun-sdk-core';
|
|
3
|
+
import { C as ContractOverrides, T as TransactionPlan, E as ExecutedActionResult, a as TransactionPlanExecutionResult, S as SlippageInput, A as ApprovalMode, P as ProtocolsContext, c as ProtocolClientOptions, b as TransactionPlanExecutor } from './common-8VQQ0FSU.cjs';
|
|
4
|
+
import { PsmSnapshot, PsmSwapMode, PsmQuote } from '@sun-protocol/sun-sdk-psm';
|
|
5
|
+
import { RouterRoute } from '@sun-protocol/sun-sdk-api';
|
|
6
|
+
|
|
7
|
+
type SwapQuoteKind = 'router' | 'wtrx';
|
|
8
|
+
type WtrxSwapAction = 'wrap' | 'unwrap';
|
|
9
|
+
type RouterRouteType = 'SUNSWAP_V1' | 'SUNSWAP_V2' | 'SUNSWAP_V3' | 'SUNSWAP_V4' | 'PSM' | 'CURVE' | 'CURVE_COMBINATION' | 'WTRX' | 'HTX_SUN';
|
|
10
|
+
interface SwapQuoteInput {
|
|
11
|
+
readonly tokenIn: string;
|
|
12
|
+
readonly tokenOut: string;
|
|
13
|
+
readonly amountIn: string;
|
|
14
|
+
readonly routerRouteTypes?: readonly RouterRouteType[];
|
|
15
|
+
readonly typeList?: string;
|
|
16
|
+
readonly includeUnverifiedV4Hook?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** Canonical swap quote amounts, always integer strings in token base units. */
|
|
19
|
+
interface SwapQuoteAmounts {
|
|
20
|
+
readonly amountIn: string;
|
|
21
|
+
readonly amountOut: string;
|
|
22
|
+
}
|
|
23
|
+
interface RouterSwapQuote extends SwapQuoteAmounts {
|
|
24
|
+
readonly kind: 'router';
|
|
25
|
+
readonly source: 'router';
|
|
26
|
+
readonly tokenIn: string;
|
|
27
|
+
readonly tokenOut: string;
|
|
28
|
+
/** Router-provided decimal display value for the best route input. */
|
|
29
|
+
readonly amountInFormatted: string;
|
|
30
|
+
/** Router-provided decimal display value for the best route output. */
|
|
31
|
+
readonly amountOutFormatted: string;
|
|
32
|
+
readonly routes: readonly RouterRoute[];
|
|
33
|
+
readonly bestRoute: RouterRoute;
|
|
34
|
+
}
|
|
35
|
+
interface WtrxSwapRoute extends SwapQuoteAmounts {
|
|
36
|
+
readonly type: 'WTRX_WRAP' | 'WTRX_UNWRAP';
|
|
37
|
+
}
|
|
38
|
+
interface WtrxSwapQuote extends SwapQuoteAmounts {
|
|
39
|
+
readonly kind: 'wtrx';
|
|
40
|
+
readonly source: 'wtrx';
|
|
41
|
+
readonly action: WtrxSwapAction;
|
|
42
|
+
readonly tokenIn: string;
|
|
43
|
+
readonly tokenOut: string;
|
|
44
|
+
readonly route: WtrxSwapRoute;
|
|
45
|
+
}
|
|
46
|
+
type SwapQuote = RouterSwapQuote | WtrxSwapQuote;
|
|
47
|
+
interface SwapPlanOptions {
|
|
48
|
+
readonly slippage?: SlippageInput;
|
|
49
|
+
/**
|
|
50
|
+
* Output recipient for Universal Router swaps. Defaults to the current wallet address.
|
|
51
|
+
*
|
|
52
|
+
* Direct TRX <-> WTRX wrap/unwrap (`quote.kind === 'wtrx'`) does not support
|
|
53
|
+
* a separate recipient: output always goes to the transaction sender.
|
|
54
|
+
* This option is ignored for WTRX quotes; omit it when planning or executing them.
|
|
55
|
+
*/
|
|
56
|
+
readonly recipient?: string;
|
|
57
|
+
readonly approval?: ApprovalMode;
|
|
58
|
+
readonly transactionValidForSeconds?: number;
|
|
59
|
+
/** Maximum energy burn for the swap transaction, in sun. Overrides the protocol default. */
|
|
60
|
+
readonly feeLimit?: number;
|
|
61
|
+
}
|
|
62
|
+
interface SwapRouterPlanInput extends SwapPlanOptions {
|
|
63
|
+
readonly quote: SwapQuote;
|
|
64
|
+
readonly route: RouterRoute | WtrxSwapRoute;
|
|
65
|
+
}
|
|
66
|
+
type SwapRouterExecuteInput = SwapRouterPlanInput;
|
|
67
|
+
interface SwapTransactionOptions {
|
|
68
|
+
/** Permit2 typed-data signature produced by a planned approval action. */
|
|
69
|
+
readonly permitSignature?: string;
|
|
70
|
+
}
|
|
71
|
+
type V2SwapMode = 'exact-in' | 'exact-out';
|
|
72
|
+
type V2SwapDirection = 'trx-to-token' | 'token-to-trx' | 'token-to-token';
|
|
73
|
+
type PsmApprovalMode = 'auto' | 'approve' | 'none';
|
|
74
|
+
type PsmContractOverrides = Pick<ContractOverrides, 'psmUsdt' | 'psmUsdd' | 'psm' | 'psmGemJoin' | 'psmInfoReader'>;
|
|
75
|
+
interface PsmReadInput {
|
|
76
|
+
readonly contracts?: PsmContractOverrides;
|
|
77
|
+
}
|
|
78
|
+
interface PsmSwapInput extends PsmReadInput {
|
|
79
|
+
readonly mode?: PsmSwapMode;
|
|
80
|
+
readonly tokenIn: string;
|
|
81
|
+
readonly tokenOut: string;
|
|
82
|
+
readonly amountIn?: string;
|
|
83
|
+
readonly amountOut?: string;
|
|
84
|
+
readonly recipient?: string;
|
|
85
|
+
readonly approval?: PsmApprovalMode;
|
|
86
|
+
readonly feeLimit?: number;
|
|
87
|
+
}
|
|
88
|
+
interface PsmSwapQuote extends PsmQuote {
|
|
89
|
+
readonly kind: 'psm';
|
|
90
|
+
readonly source: 'psm';
|
|
91
|
+
readonly tokenIn: TronAddress;
|
|
92
|
+
readonly tokenOut: TronAddress;
|
|
93
|
+
}
|
|
94
|
+
interface V2SwapQuoteInput {
|
|
95
|
+
readonly mode?: V2SwapMode;
|
|
96
|
+
readonly tokenIn: string;
|
|
97
|
+
readonly tokenOut: string;
|
|
98
|
+
readonly amountIn?: string;
|
|
99
|
+
readonly amountOut?: string;
|
|
100
|
+
readonly path?: readonly string[];
|
|
101
|
+
readonly recipient?: string;
|
|
102
|
+
readonly slippage?: SlippageInput;
|
|
103
|
+
readonly approval?: ApprovalMode;
|
|
104
|
+
readonly transactionValidForSeconds?: number;
|
|
105
|
+
}
|
|
106
|
+
interface V2SwapQuote extends SwapQuoteAmounts {
|
|
107
|
+
readonly kind: 'v2';
|
|
108
|
+
readonly source: 'v2';
|
|
109
|
+
readonly mode: V2SwapMode;
|
|
110
|
+
readonly direction: V2SwapDirection;
|
|
111
|
+
readonly tokenIn: string;
|
|
112
|
+
readonly tokenOut: string;
|
|
113
|
+
readonly path: readonly TronAddress[];
|
|
114
|
+
}
|
|
115
|
+
interface SwapRouterClientShape {
|
|
116
|
+
quote(input: SwapQuoteInput): Promise<SwapQuote>;
|
|
117
|
+
plan(input: SwapRouterPlanInput): Promise<TransactionPlan>;
|
|
118
|
+
executeAction(action: TransactionAction): Promise<ExecutedActionResult>;
|
|
119
|
+
submit(plan: TransactionPlan, options?: SwapTransactionOptions): Promise<TransactionPlanExecutionResult>;
|
|
120
|
+
execute(input: SwapRouterExecuteInput | TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
121
|
+
}
|
|
122
|
+
interface V2SwapClientShape {
|
|
123
|
+
quote(input: V2SwapQuoteInput): Promise<V2SwapQuote>;
|
|
124
|
+
plan(input: V2SwapQuoteInput): Promise<TransactionPlan>;
|
|
125
|
+
executeAction(action: TransactionAction): Promise<ExecutedActionResult>;
|
|
126
|
+
submit(plan: TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
127
|
+
execute(input: V2SwapQuoteInput | TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
128
|
+
}
|
|
129
|
+
interface PsmSwapClientShape {
|
|
130
|
+
read(input?: PsmReadInput): Promise<PsmSnapshot>;
|
|
131
|
+
quote(input: PsmSwapInput): Promise<PsmSwapQuote>;
|
|
132
|
+
plan(input: PsmSwapInput): Promise<TransactionPlan>;
|
|
133
|
+
executeAction(action: TransactionAction): Promise<ExecutedActionResult>;
|
|
134
|
+
submit(plan: TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
135
|
+
execute(input: PsmSwapInput | TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
136
|
+
}
|
|
137
|
+
interface SwapNamespace {
|
|
138
|
+
readonly router: SwapRouterClientShape;
|
|
139
|
+
readonly v2: V2SwapClientShape;
|
|
140
|
+
readonly psm: PsmSwapClientShape;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Router client for both all-in-one and staged TransactionPlan workflows. */
|
|
144
|
+
declare class SwapRouterClient implements SwapRouterClientShape {
|
|
145
|
+
private readonly context;
|
|
146
|
+
constructor(context: ProtocolsContext);
|
|
147
|
+
quote(input: SwapQuoteInput): Promise<SwapQuote>;
|
|
148
|
+
plan(input: SwapRouterPlanInput): Promise<TransactionPlan>;
|
|
149
|
+
executeAction(action: TransactionAction): Promise<ExecutedActionResult>;
|
|
150
|
+
submit(plan: TransactionPlan, options?: SwapTransactionOptions): Promise<TransactionPlanExecutionResult>;
|
|
151
|
+
execute(input: SwapRouterExecuteInput | TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
152
|
+
}
|
|
153
|
+
declare function createSwapRouterClient(options: ProtocolClientOptions): SwapRouterClient;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Materializes a deferred Universal Router action with results collected by a
|
|
157
|
+
* staged UI, including a Permit2 signature produced by an earlier action.
|
|
158
|
+
*/
|
|
159
|
+
declare function materializeUniversalRouterAction(context: ProtocolsContext, action: DeferredContractCallAction, completedActions: readonly ExecutedActionResult[]): Promise<_sun_protocol_sun_sdk_core.ContractCallAction>;
|
|
160
|
+
/** Creates an executor for Router plans, including approvals and WTRX actions. */
|
|
161
|
+
declare function createRouterSwapExecutor(context: ProtocolsContext, options?: SwapTransactionOptions): TransactionPlanExecutor;
|
|
162
|
+
|
|
163
|
+
/** Creates an executor for standalone V2 swaps. */
|
|
164
|
+
declare function createV2SwapExecutor(context: ProtocolsContext): TransactionPlanExecutor;
|
|
165
|
+
|
|
166
|
+
declare function planRouterSwap(context: ProtocolsContext, input: SwapRouterPlanInput): Promise<TransactionPlan>;
|
|
167
|
+
|
|
168
|
+
declare function readPsm(context: ProtocolsContext, input?: PsmReadInput): Promise<PsmSnapshot>;
|
|
169
|
+
declare function quotePsmSwap(context: ProtocolsContext, input: PsmSwapInput): Promise<PsmSwapQuote>;
|
|
170
|
+
declare function planPsmSwap(context: ProtocolsContext, input: PsmSwapInput): Promise<TransactionPlan>;
|
|
171
|
+
declare class PsmSwapClient implements PsmSwapClientShape {
|
|
172
|
+
private readonly context;
|
|
173
|
+
constructor(context: ProtocolsContext);
|
|
174
|
+
read(input?: PsmReadInput): Promise<PsmSnapshot>;
|
|
175
|
+
quote(input: PsmSwapInput): Promise<PsmSwapQuote>;
|
|
176
|
+
plan(input: PsmSwapInput): Promise<TransactionPlan>;
|
|
177
|
+
executeAction(action: TransactionAction): Promise<ExecutedActionResult>;
|
|
178
|
+
submit(plan: TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
179
|
+
execute(input: PsmSwapInput | TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
180
|
+
}
|
|
181
|
+
declare function createPsmSwapClient(context: ProtocolsContext): PsmSwapClient;
|
|
182
|
+
declare function createPsmClient(options: ProtocolClientOptions): PsmSwapClient;
|
|
183
|
+
|
|
184
|
+
declare class V2SwapClient implements V2SwapClientShape {
|
|
185
|
+
private readonly context;
|
|
186
|
+
constructor(context: ProtocolsContext);
|
|
187
|
+
quote(_input: V2SwapQuoteInput): Promise<V2SwapQuote>;
|
|
188
|
+
plan(input: V2SwapQuoteInput): Promise<TransactionPlan>;
|
|
189
|
+
executeAction(action: TransactionAction): Promise<ExecutedActionResult>;
|
|
190
|
+
submit(plan: TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
191
|
+
execute(input: V2SwapQuoteInput | TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
192
|
+
}
|
|
193
|
+
declare function createV2SwapClient(context: ProtocolsContext): V2SwapClient;
|
|
194
|
+
declare function createV2Client(options: ProtocolClientOptions): V2SwapClient;
|
|
195
|
+
|
|
196
|
+
declare const UNIVERSAL_ROUTER_PROTOCOL_ID = "universal-router";
|
|
197
|
+
declare const PSM_PROTOCOL_ID = "psm";
|
|
198
|
+
declare const WTRX_PROTOCOL_ID = "wtrx";
|
|
199
|
+
|
|
200
|
+
export { createPsmClient as A, createPsmSwapClient as B, createRouterSwapExecutor as C, createSwapRouterClient as D, createV2Client as E, createV2SwapClient as F, createV2SwapExecutor as G, materializeUniversalRouterAction as H, planPsmSwap as I, planRouterSwap as J, quotePsmSwap as K, readPsm as L, PSM_PROTOCOL_ID as P, type RouterRouteType as R, type SwapQuoteInput as S, UNIVERSAL_ROUTER_PROTOCOL_ID as U, type V2SwapDirection as V, type WtrxSwapQuote as W, type SwapQuote as a, type PsmApprovalMode as b, type PsmContractOverrides as c, type PsmReadInput as d, PsmSwapClient as e, type PsmSwapClientShape as f, type PsmSwapInput as g, type PsmSwapQuote as h, type RouterSwapQuote as i, type SwapNamespace as j, type SwapPlanOptions as k, type SwapQuoteAmounts as l, type SwapQuoteKind as m, SwapRouterClient as n, type SwapRouterClientShape as o, type SwapRouterExecuteInput as p, type SwapRouterPlanInput as q, type SwapTransactionOptions as r, V2SwapClient as s, type V2SwapClientShape as t, type V2SwapMode as u, type V2SwapQuote as v, type V2SwapQuoteInput as w, WTRX_PROTOCOL_ID as x, type WtrxSwapAction as y, type WtrxSwapRoute as z };
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import * as _sun_protocol_sun_sdk_core from '@sun-protocol/sun-sdk-core';
|
|
2
|
+
import { TronAddress, TransactionAction, DeferredContractCallAction } from '@sun-protocol/sun-sdk-core';
|
|
3
|
+
import { C as ContractOverrides, T as TransactionPlan, E as ExecutedActionResult, a as TransactionPlanExecutionResult, S as SlippageInput, A as ApprovalMode, P as ProtocolsContext, c as ProtocolClientOptions, b as TransactionPlanExecutor } from './common-8VQQ0FSU.js';
|
|
4
|
+
import { PsmSnapshot, PsmSwapMode, PsmQuote } from '@sun-protocol/sun-sdk-psm';
|
|
5
|
+
import { RouterRoute } from '@sun-protocol/sun-sdk-api';
|
|
6
|
+
|
|
7
|
+
type SwapQuoteKind = 'router' | 'wtrx';
|
|
8
|
+
type WtrxSwapAction = 'wrap' | 'unwrap';
|
|
9
|
+
type RouterRouteType = 'SUNSWAP_V1' | 'SUNSWAP_V2' | 'SUNSWAP_V3' | 'SUNSWAP_V4' | 'PSM' | 'CURVE' | 'CURVE_COMBINATION' | 'WTRX' | 'HTX_SUN';
|
|
10
|
+
interface SwapQuoteInput {
|
|
11
|
+
readonly tokenIn: string;
|
|
12
|
+
readonly tokenOut: string;
|
|
13
|
+
readonly amountIn: string;
|
|
14
|
+
readonly routerRouteTypes?: readonly RouterRouteType[];
|
|
15
|
+
readonly typeList?: string;
|
|
16
|
+
readonly includeUnverifiedV4Hook?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** Canonical swap quote amounts, always integer strings in token base units. */
|
|
19
|
+
interface SwapQuoteAmounts {
|
|
20
|
+
readonly amountIn: string;
|
|
21
|
+
readonly amountOut: string;
|
|
22
|
+
}
|
|
23
|
+
interface RouterSwapQuote extends SwapQuoteAmounts {
|
|
24
|
+
readonly kind: 'router';
|
|
25
|
+
readonly source: 'router';
|
|
26
|
+
readonly tokenIn: string;
|
|
27
|
+
readonly tokenOut: string;
|
|
28
|
+
/** Router-provided decimal display value for the best route input. */
|
|
29
|
+
readonly amountInFormatted: string;
|
|
30
|
+
/** Router-provided decimal display value for the best route output. */
|
|
31
|
+
readonly amountOutFormatted: string;
|
|
32
|
+
readonly routes: readonly RouterRoute[];
|
|
33
|
+
readonly bestRoute: RouterRoute;
|
|
34
|
+
}
|
|
35
|
+
interface WtrxSwapRoute extends SwapQuoteAmounts {
|
|
36
|
+
readonly type: 'WTRX_WRAP' | 'WTRX_UNWRAP';
|
|
37
|
+
}
|
|
38
|
+
interface WtrxSwapQuote extends SwapQuoteAmounts {
|
|
39
|
+
readonly kind: 'wtrx';
|
|
40
|
+
readonly source: 'wtrx';
|
|
41
|
+
readonly action: WtrxSwapAction;
|
|
42
|
+
readonly tokenIn: string;
|
|
43
|
+
readonly tokenOut: string;
|
|
44
|
+
readonly route: WtrxSwapRoute;
|
|
45
|
+
}
|
|
46
|
+
type SwapQuote = RouterSwapQuote | WtrxSwapQuote;
|
|
47
|
+
interface SwapPlanOptions {
|
|
48
|
+
readonly slippage?: SlippageInput;
|
|
49
|
+
/**
|
|
50
|
+
* Output recipient for Universal Router swaps. Defaults to the current wallet address.
|
|
51
|
+
*
|
|
52
|
+
* Direct TRX <-> WTRX wrap/unwrap (`quote.kind === 'wtrx'`) does not support
|
|
53
|
+
* a separate recipient: output always goes to the transaction sender.
|
|
54
|
+
* This option is ignored for WTRX quotes; omit it when planning or executing them.
|
|
55
|
+
*/
|
|
56
|
+
readonly recipient?: string;
|
|
57
|
+
readonly approval?: ApprovalMode;
|
|
58
|
+
readonly transactionValidForSeconds?: number;
|
|
59
|
+
/** Maximum energy burn for the swap transaction, in sun. Overrides the protocol default. */
|
|
60
|
+
readonly feeLimit?: number;
|
|
61
|
+
}
|
|
62
|
+
interface SwapRouterPlanInput extends SwapPlanOptions {
|
|
63
|
+
readonly quote: SwapQuote;
|
|
64
|
+
readonly route: RouterRoute | WtrxSwapRoute;
|
|
65
|
+
}
|
|
66
|
+
type SwapRouterExecuteInput = SwapRouterPlanInput;
|
|
67
|
+
interface SwapTransactionOptions {
|
|
68
|
+
/** Permit2 typed-data signature produced by a planned approval action. */
|
|
69
|
+
readonly permitSignature?: string;
|
|
70
|
+
}
|
|
71
|
+
type V2SwapMode = 'exact-in' | 'exact-out';
|
|
72
|
+
type V2SwapDirection = 'trx-to-token' | 'token-to-trx' | 'token-to-token';
|
|
73
|
+
type PsmApprovalMode = 'auto' | 'approve' | 'none';
|
|
74
|
+
type PsmContractOverrides = Pick<ContractOverrides, 'psmUsdt' | 'psmUsdd' | 'psm' | 'psmGemJoin' | 'psmInfoReader'>;
|
|
75
|
+
interface PsmReadInput {
|
|
76
|
+
readonly contracts?: PsmContractOverrides;
|
|
77
|
+
}
|
|
78
|
+
interface PsmSwapInput extends PsmReadInput {
|
|
79
|
+
readonly mode?: PsmSwapMode;
|
|
80
|
+
readonly tokenIn: string;
|
|
81
|
+
readonly tokenOut: string;
|
|
82
|
+
readonly amountIn?: string;
|
|
83
|
+
readonly amountOut?: string;
|
|
84
|
+
readonly recipient?: string;
|
|
85
|
+
readonly approval?: PsmApprovalMode;
|
|
86
|
+
readonly feeLimit?: number;
|
|
87
|
+
}
|
|
88
|
+
interface PsmSwapQuote extends PsmQuote {
|
|
89
|
+
readonly kind: 'psm';
|
|
90
|
+
readonly source: 'psm';
|
|
91
|
+
readonly tokenIn: TronAddress;
|
|
92
|
+
readonly tokenOut: TronAddress;
|
|
93
|
+
}
|
|
94
|
+
interface V2SwapQuoteInput {
|
|
95
|
+
readonly mode?: V2SwapMode;
|
|
96
|
+
readonly tokenIn: string;
|
|
97
|
+
readonly tokenOut: string;
|
|
98
|
+
readonly amountIn?: string;
|
|
99
|
+
readonly amountOut?: string;
|
|
100
|
+
readonly path?: readonly string[];
|
|
101
|
+
readonly recipient?: string;
|
|
102
|
+
readonly slippage?: SlippageInput;
|
|
103
|
+
readonly approval?: ApprovalMode;
|
|
104
|
+
readonly transactionValidForSeconds?: number;
|
|
105
|
+
}
|
|
106
|
+
interface V2SwapQuote extends SwapQuoteAmounts {
|
|
107
|
+
readonly kind: 'v2';
|
|
108
|
+
readonly source: 'v2';
|
|
109
|
+
readonly mode: V2SwapMode;
|
|
110
|
+
readonly direction: V2SwapDirection;
|
|
111
|
+
readonly tokenIn: string;
|
|
112
|
+
readonly tokenOut: string;
|
|
113
|
+
readonly path: readonly TronAddress[];
|
|
114
|
+
}
|
|
115
|
+
interface SwapRouterClientShape {
|
|
116
|
+
quote(input: SwapQuoteInput): Promise<SwapQuote>;
|
|
117
|
+
plan(input: SwapRouterPlanInput): Promise<TransactionPlan>;
|
|
118
|
+
executeAction(action: TransactionAction): Promise<ExecutedActionResult>;
|
|
119
|
+
submit(plan: TransactionPlan, options?: SwapTransactionOptions): Promise<TransactionPlanExecutionResult>;
|
|
120
|
+
execute(input: SwapRouterExecuteInput | TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
121
|
+
}
|
|
122
|
+
interface V2SwapClientShape {
|
|
123
|
+
quote(input: V2SwapQuoteInput): Promise<V2SwapQuote>;
|
|
124
|
+
plan(input: V2SwapQuoteInput): Promise<TransactionPlan>;
|
|
125
|
+
executeAction(action: TransactionAction): Promise<ExecutedActionResult>;
|
|
126
|
+
submit(plan: TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
127
|
+
execute(input: V2SwapQuoteInput | TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
128
|
+
}
|
|
129
|
+
interface PsmSwapClientShape {
|
|
130
|
+
read(input?: PsmReadInput): Promise<PsmSnapshot>;
|
|
131
|
+
quote(input: PsmSwapInput): Promise<PsmSwapQuote>;
|
|
132
|
+
plan(input: PsmSwapInput): Promise<TransactionPlan>;
|
|
133
|
+
executeAction(action: TransactionAction): Promise<ExecutedActionResult>;
|
|
134
|
+
submit(plan: TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
135
|
+
execute(input: PsmSwapInput | TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
136
|
+
}
|
|
137
|
+
interface SwapNamespace {
|
|
138
|
+
readonly router: SwapRouterClientShape;
|
|
139
|
+
readonly v2: V2SwapClientShape;
|
|
140
|
+
readonly psm: PsmSwapClientShape;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Router client for both all-in-one and staged TransactionPlan workflows. */
|
|
144
|
+
declare class SwapRouterClient implements SwapRouterClientShape {
|
|
145
|
+
private readonly context;
|
|
146
|
+
constructor(context: ProtocolsContext);
|
|
147
|
+
quote(input: SwapQuoteInput): Promise<SwapQuote>;
|
|
148
|
+
plan(input: SwapRouterPlanInput): Promise<TransactionPlan>;
|
|
149
|
+
executeAction(action: TransactionAction): Promise<ExecutedActionResult>;
|
|
150
|
+
submit(plan: TransactionPlan, options?: SwapTransactionOptions): Promise<TransactionPlanExecutionResult>;
|
|
151
|
+
execute(input: SwapRouterExecuteInput | TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
152
|
+
}
|
|
153
|
+
declare function createSwapRouterClient(options: ProtocolClientOptions): SwapRouterClient;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Materializes a deferred Universal Router action with results collected by a
|
|
157
|
+
* staged UI, including a Permit2 signature produced by an earlier action.
|
|
158
|
+
*/
|
|
159
|
+
declare function materializeUniversalRouterAction(context: ProtocolsContext, action: DeferredContractCallAction, completedActions: readonly ExecutedActionResult[]): Promise<_sun_protocol_sun_sdk_core.ContractCallAction>;
|
|
160
|
+
/** Creates an executor for Router plans, including approvals and WTRX actions. */
|
|
161
|
+
declare function createRouterSwapExecutor(context: ProtocolsContext, options?: SwapTransactionOptions): TransactionPlanExecutor;
|
|
162
|
+
|
|
163
|
+
/** Creates an executor for standalone V2 swaps. */
|
|
164
|
+
declare function createV2SwapExecutor(context: ProtocolsContext): TransactionPlanExecutor;
|
|
165
|
+
|
|
166
|
+
declare function planRouterSwap(context: ProtocolsContext, input: SwapRouterPlanInput): Promise<TransactionPlan>;
|
|
167
|
+
|
|
168
|
+
declare function readPsm(context: ProtocolsContext, input?: PsmReadInput): Promise<PsmSnapshot>;
|
|
169
|
+
declare function quotePsmSwap(context: ProtocolsContext, input: PsmSwapInput): Promise<PsmSwapQuote>;
|
|
170
|
+
declare function planPsmSwap(context: ProtocolsContext, input: PsmSwapInput): Promise<TransactionPlan>;
|
|
171
|
+
declare class PsmSwapClient implements PsmSwapClientShape {
|
|
172
|
+
private readonly context;
|
|
173
|
+
constructor(context: ProtocolsContext);
|
|
174
|
+
read(input?: PsmReadInput): Promise<PsmSnapshot>;
|
|
175
|
+
quote(input: PsmSwapInput): Promise<PsmSwapQuote>;
|
|
176
|
+
plan(input: PsmSwapInput): Promise<TransactionPlan>;
|
|
177
|
+
executeAction(action: TransactionAction): Promise<ExecutedActionResult>;
|
|
178
|
+
submit(plan: TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
179
|
+
execute(input: PsmSwapInput | TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
180
|
+
}
|
|
181
|
+
declare function createPsmSwapClient(context: ProtocolsContext): PsmSwapClient;
|
|
182
|
+
declare function createPsmClient(options: ProtocolClientOptions): PsmSwapClient;
|
|
183
|
+
|
|
184
|
+
declare class V2SwapClient implements V2SwapClientShape {
|
|
185
|
+
private readonly context;
|
|
186
|
+
constructor(context: ProtocolsContext);
|
|
187
|
+
quote(_input: V2SwapQuoteInput): Promise<V2SwapQuote>;
|
|
188
|
+
plan(input: V2SwapQuoteInput): Promise<TransactionPlan>;
|
|
189
|
+
executeAction(action: TransactionAction): Promise<ExecutedActionResult>;
|
|
190
|
+
submit(plan: TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
191
|
+
execute(input: V2SwapQuoteInput | TransactionPlan): Promise<TransactionPlanExecutionResult>;
|
|
192
|
+
}
|
|
193
|
+
declare function createV2SwapClient(context: ProtocolsContext): V2SwapClient;
|
|
194
|
+
declare function createV2Client(options: ProtocolClientOptions): V2SwapClient;
|
|
195
|
+
|
|
196
|
+
declare const UNIVERSAL_ROUTER_PROTOCOL_ID = "universal-router";
|
|
197
|
+
declare const PSM_PROTOCOL_ID = "psm";
|
|
198
|
+
declare const WTRX_PROTOCOL_ID = "wtrx";
|
|
199
|
+
|
|
200
|
+
export { createPsmClient as A, createPsmSwapClient as B, createRouterSwapExecutor as C, createSwapRouterClient as D, createV2Client as E, createV2SwapClient as F, createV2SwapExecutor as G, materializeUniversalRouterAction as H, planPsmSwap as I, planRouterSwap as J, quotePsmSwap as K, readPsm as L, PSM_PROTOCOL_ID as P, type RouterRouteType as R, type SwapQuoteInput as S, UNIVERSAL_ROUTER_PROTOCOL_ID as U, type V2SwapDirection as V, type WtrxSwapQuote as W, type SwapQuote as a, type PsmApprovalMode as b, type PsmContractOverrides as c, type PsmReadInput as d, PsmSwapClient as e, type PsmSwapClientShape as f, type PsmSwapInput as g, type PsmSwapQuote as h, type RouterSwapQuote as i, type SwapNamespace as j, type SwapPlanOptions as k, type SwapQuoteAmounts as l, type SwapQuoteKind as m, SwapRouterClient as n, type SwapRouterClientShape as o, type SwapRouterExecuteInput as p, type SwapRouterPlanInput as q, type SwapTransactionOptions as r, V2SwapClient as s, type V2SwapClientShape as t, type V2SwapMode as u, type V2SwapQuote as v, type V2SwapQuoteInput as w, WTRX_PROTOCOL_ID as x, type WtrxSwapAction as y, type WtrxSwapRoute as z };
|