/
layouts.ts
102 lines (88 loc) 路 3.01 KB
/
layouts.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import { Uint64Layout } from "@saberhq/token-utils";
import * as BufferLayout from "@solana/buffer-layout";
import type { RawFees } from "../state/layout.js";
import { FeesLayout } from "../state/layout.js";
import type { AdminInstruction } from "./admin.js";
import type { StableSwapInstruction } from "./swap.js";
export const InitializeSwapIXLayout = BufferLayout.struct<{
instruction: StableSwapInstruction.INITIALIZE;
nonce: number;
ampFactor: Uint8Array;
fees: RawFees;
}>([
BufferLayout.u8("instruction"),
BufferLayout.u8("nonce"),
Uint64Layout("ampFactor"),
FeesLayout,
]);
export const SwapIXLayout = BufferLayout.struct<{
instruction: StableSwapInstruction.SWAP;
amountIn: Uint8Array;
minimumAmountOut: Uint8Array;
}>([
BufferLayout.u8("instruction"),
Uint64Layout("amountIn"),
Uint64Layout("minimumAmountOut"),
]);
export const DepositIXLayout = BufferLayout.struct<{
instruction: StableSwapInstruction.DEPOSIT;
tokenAmountA: Uint8Array;
tokenAmountB: Uint8Array;
minimumPoolTokenAmount: Uint8Array;
}>([
BufferLayout.u8("instruction"),
Uint64Layout("tokenAmountA"),
Uint64Layout("tokenAmountB"),
Uint64Layout("minimumPoolTokenAmount"),
]);
export const WithdrawIXLayout = BufferLayout.struct<{
instruction: StableSwapInstruction.WITHDRAW;
poolTokenAmount: Uint8Array;
minimumTokenA: Uint8Array;
minimumTokenB: Uint8Array;
}>([
BufferLayout.u8("instruction"),
Uint64Layout("poolTokenAmount"),
Uint64Layout("minimumTokenA"),
Uint64Layout("minimumTokenB"),
]);
export const WithdrawOneIXLayout = BufferLayout.struct<{
instruction: StableSwapInstruction.WITHDRAW_ONE;
poolTokenAmount: Uint8Array;
minimumTokenAmount: Uint8Array;
}>([
BufferLayout.u8("instruction"),
Uint64Layout("poolTokenAmount"),
Uint64Layout("minimumTokenAmount"),
]);
export const RampAIXLayout = BufferLayout.struct<{
instruction: AdminInstruction.RAMP_A;
targetAmp: Uint8Array;
stopRampTS: number;
}>([
BufferLayout.u8("instruction"),
Uint64Layout("targetAmp"),
BufferLayout.ns64("stopRampTS"),
]);
export const StopRampAIXLayout = BufferLayout.struct<{
instruction: AdminInstruction.STOP_RAMP_A;
}>([BufferLayout.u8("instruction")]);
export const PauseIXLayout = BufferLayout.struct<{
instruction: AdminInstruction.PAUSE;
}>([BufferLayout.u8("instruction")]);
export const UnpauseIXLayout = BufferLayout.struct<{
instruction: AdminInstruction.UNPAUSE;
}>([BufferLayout.u8("instruction")]);
export const SetFeeAccountIXLayout = BufferLayout.struct<{
instruction: AdminInstruction.SET_FEE_ACCOUNT;
}>([BufferLayout.u8("instruction")]);
export const ApplyNewAdminIXLayout = BufferLayout.struct<{
instruction: AdminInstruction.APPLY_NEW_ADMIN;
}>([BufferLayout.u8("instruction")]);
export const CommitNewAdminIXLayout = BufferLayout.struct<{
instruction: AdminInstruction.COMMIT_NEW_ADMIN;
}>([BufferLayout.u8("instruction")]);
export const SetNewFeesIXLayout = BufferLayout.struct<{
instruction: AdminInstruction.SET_NEW_FEES;
fees: RawFees;
}>([BufferLayout.u8("instruction"), FeesLayout]);