@reflectmoney/junior 1.0.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.
Files changed (122) hide show
  1. package/README.md +119 -0
  2. package/dist/classes/JuniorTranche.d.ts +201 -0
  3. package/dist/classes/JuniorTranche.js +709 -0
  4. package/dist/classes/PdaClient.d.ts +20 -0
  5. package/dist/classes/PdaClient.js +68 -0
  6. package/dist/classes/index.d.ts +2 -0
  7. package/dist/classes/index.js +18 -0
  8. package/dist/constants/index.d.ts +22 -0
  9. package/dist/constants/index.js +25 -0
  10. package/dist/generated/accounts/asset.d.ts +38 -0
  11. package/dist/generated/accounts/asset.js +74 -0
  12. package/dist/generated/accounts/cooldown.d.ts +40 -0
  13. package/dist/generated/accounts/cooldown.js +79 -0
  14. package/dist/generated/accounts/index.d.ts +12 -0
  15. package/dist/generated/accounts/index.js +28 -0
  16. package/dist/generated/accounts/liquidityPool.d.ts +57 -0
  17. package/dist/generated/accounts/liquidityPool.js +81 -0
  18. package/dist/generated/accounts/settings.d.ts +41 -0
  19. package/dist/generated/accounts/settings.js +80 -0
  20. package/dist/generated/accounts/userPermissions.d.ts +34 -0
  21. package/dist/generated/accounts/userPermissions.js +70 -0
  22. package/dist/generated/errors/index.d.ts +8 -0
  23. package/dist/generated/errors/index.js +24 -0
  24. package/dist/generated/errors/rlp.d.ts +131 -0
  25. package/dist/generated/errors/rlp.js +197 -0
  26. package/dist/generated/index.d.ts +12 -0
  27. package/dist/generated/index.js +28 -0
  28. package/dist/generated/instructions/addAsset.d.ts +80 -0
  29. package/dist/generated/instructions/addAsset.js +188 -0
  30. package/dist/generated/instructions/createPermissionAccount.d.ts +67 -0
  31. package/dist/generated/instructions/createPermissionAccount.js +166 -0
  32. package/dist/generated/instructions/deposit.d.ts +115 -0
  33. package/dist/generated/instructions/deposit.js +294 -0
  34. package/dist/generated/instructions/forceRemoveAsset.d.ts +82 -0
  35. package/dist/generated/instructions/forceRemoveAsset.js +186 -0
  36. package/dist/generated/instructions/freezeFunctionality.d.ts +72 -0
  37. package/dist/generated/instructions/freezeFunctionality.js +175 -0
  38. package/dist/generated/instructions/index.d.ts +23 -0
  39. package/dist/generated/instructions/index.js +39 -0
  40. package/dist/generated/instructions/initializeLp.d.ts +99 -0
  41. package/dist/generated/instructions/initializeLp.js +230 -0
  42. package/dist/generated/instructions/initializePoolReserve.d.ts +83 -0
  43. package/dist/generated/instructions/initializePoolReserve.js +228 -0
  44. package/dist/generated/instructions/initializeRlp.d.ts +67 -0
  45. package/dist/generated/instructions/initializeRlp.js +163 -0
  46. package/dist/generated/instructions/requestWithdrawal.d.ts +99 -0
  47. package/dist/generated/instructions/requestWithdrawal.js +254 -0
  48. package/dist/generated/instructions/slash.d.ts +151 -0
  49. package/dist/generated/instructions/slash.js +212 -0
  50. package/dist/generated/instructions/swap.d.ts +119 -0
  51. package/dist/generated/instructions/swap.js +309 -0
  52. package/dist/generated/instructions/updateActionRole.d.ts +76 -0
  53. package/dist/generated/instructions/updateActionRole.js +174 -0
  54. package/dist/generated/instructions/updateDepositCap.d.ts +71 -0
  55. package/dist/generated/instructions/updateDepositCap.js +156 -0
  56. package/dist/generated/instructions/updateOracle.d.ts +66 -0
  57. package/dist/generated/instructions/updateOracle.js +151 -0
  58. package/dist/generated/instructions/updateRoleHolder.d.ts +80 -0
  59. package/dist/generated/instructions/updateRoleHolder.js +185 -0
  60. package/dist/generated/instructions/withdraw.d.ts +95 -0
  61. package/dist/generated/instructions/withdraw.js +235 -0
  62. package/dist/generated/programs/index.d.ts +8 -0
  63. package/dist/generated/programs/index.js +24 -0
  64. package/dist/generated/programs/rlp.d.ts +75 -0
  65. package/dist/generated/programs/rlp.js +233 -0
  66. package/dist/generated/shared/index.d.ts +49 -0
  67. package/dist/generated/shared/index.js +94 -0
  68. package/dist/generated/types/accessControl.d.ts +20 -0
  69. package/dist/generated/types/accessControl.js +29 -0
  70. package/dist/generated/types/accessLevel.d.ts +16 -0
  71. package/dist/generated/types/accessLevel.js +28 -0
  72. package/dist/generated/types/accessMap.d.ts +20 -0
  73. package/dist/generated/types/accessMap.js +35 -0
  74. package/dist/generated/types/action.d.ts +32 -0
  75. package/dist/generated/types/action.js +44 -0
  76. package/dist/generated/types/actionMapping.d.ts +22 -0
  77. package/dist/generated/types/actionMapping.js +31 -0
  78. package/dist/generated/types/addAssetEvent.d.ts +17 -0
  79. package/dist/generated/types/addAssetEvent.js +30 -0
  80. package/dist/generated/types/createPermissionAccountEvent.d.ts +16 -0
  81. package/dist/generated/types/createPermissionAccountEvent.js +28 -0
  82. package/dist/generated/types/depositEvent.d.ts +27 -0
  83. package/dist/generated/types/depositEvent.js +36 -0
  84. package/dist/generated/types/depositRewardEvent.d.ts +21 -0
  85. package/dist/generated/types/depositRewardEvent.js +30 -0
  86. package/dist/generated/types/forceRemoveAssetEvent.d.ts +18 -0
  87. package/dist/generated/types/forceRemoveAssetEvent.js +32 -0
  88. package/dist/generated/types/freezeProtocolActionEvent.d.ts +20 -0
  89. package/dist/generated/types/freezeProtocolActionEvent.js +29 -0
  90. package/dist/generated/types/index.d.ts +32 -0
  91. package/dist/generated/types/index.js +48 -0
  92. package/dist/generated/types/initializeLiquidityPoolEvent.d.ts +17 -0
  93. package/dist/generated/types/initializeLiquidityPoolEvent.js +30 -0
  94. package/dist/generated/types/initializeRlpEvent.d.ts +15 -0
  95. package/dist/generated/types/initializeRlpEvent.js +22 -0
  96. package/dist/generated/types/killSwitch.d.ts +15 -0
  97. package/dist/generated/types/killSwitch.js +22 -0
  98. package/dist/generated/types/levelRoles.d.ts +18 -0
  99. package/dist/generated/types/levelRoles.js +23 -0
  100. package/dist/generated/types/oracle.d.ts +25 -0
  101. package/dist/generated/types/oracle.js +56 -0
  102. package/dist/generated/types/requestWithdrawEvent.d.ts +21 -0
  103. package/dist/generated/types/requestWithdrawEvent.js +30 -0
  104. package/dist/generated/types/role.d.ts +21 -0
  105. package/dist/generated/types/role.js +33 -0
  106. package/dist/generated/types/slashEvent.d.ts +27 -0
  107. package/dist/generated/types/slashEvent.js +36 -0
  108. package/dist/generated/types/swapEvent.d.ts +23 -0
  109. package/dist/generated/types/swapEvent.js +32 -0
  110. package/dist/generated/types/update.d.ts +16 -0
  111. package/dist/generated/types/update.js +28 -0
  112. package/dist/generated/types/updateActionRoleEvent.d.ts +22 -0
  113. package/dist/generated/types/updateActionRoleEvent.js +31 -0
  114. package/dist/generated/types/updateDepositCapEvent.d.ts +21 -0
  115. package/dist/generated/types/updateDepositCapEvent.js +30 -0
  116. package/dist/generated/types/updateOracleEvent.d.ts +18 -0
  117. package/dist/generated/types/updateOracleEvent.js +32 -0
  118. package/dist/generated/types/updateRoleHolderEvent.d.ts +22 -0
  119. package/dist/generated/types/updateRoleHolderEvent.js +31 -0
  120. package/dist/index.d.ts +3 -0
  121. package/dist/index.js +19 -0
  122. package/package.json +41 -0
@@ -0,0 +1,119 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ import { type AccountMeta, type AccountSignerMeta, type Address, type Codec, type Decoder, type Encoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type Option, type OptionOrNullable, type ReadonlyAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from "@solana/kit";
9
+ import { RLP_PROGRAM_ADDRESS } from "../programs";
10
+ export declare const SWAP_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
11
+ export declare function getSwapDiscriminatorBytes(): ReadonlyUint8Array<ArrayBuffer>;
12
+ export type SwapInstruction<TProgram extends string = typeof RLP_PROGRAM_ADDRESS, TAccountSigner extends string | AccountMeta<string> = string, TAccountAdmin extends string | AccountMeta<string> = string, TAccountSettings extends string | AccountMeta<string> = string, TAccountLiquidityPool extends string | AccountMeta<string> = string, TAccountTokenFrom extends string | AccountMeta<string> = string, TAccountTokenFromAsset extends string | AccountMeta<string> = string, TAccountTokenFromOracle extends string | AccountMeta<string> = string, TAccountTokenTo extends string | AccountMeta<string> = string, TAccountTokenToAsset extends string | AccountMeta<string> = string, TAccountTokenToOracle extends string | AccountMeta<string> = string, TAccountTokenFromPool extends string | AccountMeta<string> = string, TAccountTokenToPool extends string | AccountMeta<string> = string, TAccountTokenFromSignerAccount extends string | AccountMeta<string> = string, TAccountTokenToSignerAccount extends string | AccountMeta<string> = string, TAccountTokenProgram extends string | AccountMeta<string> = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", TAccountAssociatedTokenProgram extends string | AccountMeta<string> = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL", TAccountEventAuthority extends string | AccountMeta<string> = string, TAccountProgram extends string | AccountMeta<string> = string, TRemainingAccounts extends readonly AccountMeta<string>[] = []> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[
13
+ TAccountSigner extends string ? WritableSignerAccount<TAccountSigner> & AccountSignerMeta<TAccountSigner> : TAccountSigner,
14
+ TAccountAdmin extends string ? ReadonlyAccount<TAccountAdmin> : TAccountAdmin,
15
+ TAccountSettings extends string ? ReadonlyAccount<TAccountSettings> : TAccountSettings,
16
+ TAccountLiquidityPool extends string ? ReadonlyAccount<TAccountLiquidityPool> : TAccountLiquidityPool,
17
+ TAccountTokenFrom extends string ? ReadonlyAccount<TAccountTokenFrom> : TAccountTokenFrom,
18
+ TAccountTokenFromAsset extends string ? ReadonlyAccount<TAccountTokenFromAsset> : TAccountTokenFromAsset,
19
+ TAccountTokenFromOracle extends string ? ReadonlyAccount<TAccountTokenFromOracle> : TAccountTokenFromOracle,
20
+ TAccountTokenTo extends string ? ReadonlyAccount<TAccountTokenTo> : TAccountTokenTo,
21
+ TAccountTokenToAsset extends string ? ReadonlyAccount<TAccountTokenToAsset> : TAccountTokenToAsset,
22
+ TAccountTokenToOracle extends string ? ReadonlyAccount<TAccountTokenToOracle> : TAccountTokenToOracle,
23
+ TAccountTokenFromPool extends string ? WritableAccount<TAccountTokenFromPool> : TAccountTokenFromPool,
24
+ TAccountTokenToPool extends string ? WritableAccount<TAccountTokenToPool> : TAccountTokenToPool,
25
+ TAccountTokenFromSignerAccount extends string ? WritableAccount<TAccountTokenFromSignerAccount> : TAccountTokenFromSignerAccount,
26
+ TAccountTokenToSignerAccount extends string ? WritableAccount<TAccountTokenToSignerAccount> : TAccountTokenToSignerAccount,
27
+ TAccountTokenProgram extends string ? ReadonlyAccount<TAccountTokenProgram> : TAccountTokenProgram,
28
+ TAccountAssociatedTokenProgram extends string ? ReadonlyAccount<TAccountAssociatedTokenProgram> : TAccountAssociatedTokenProgram,
29
+ TAccountEventAuthority extends string ? ReadonlyAccount<TAccountEventAuthority> : TAccountEventAuthority,
30
+ TAccountProgram extends string ? ReadonlyAccount<TAccountProgram> : TAccountProgram,
31
+ ...TRemainingAccounts
32
+ ]>;
33
+ export type SwapInstructionData = {
34
+ discriminator: ReadonlyUint8Array;
35
+ amountIn: bigint;
36
+ minOut: Option<bigint>;
37
+ };
38
+ export type SwapInstructionDataArgs = {
39
+ amountIn: number | bigint;
40
+ minOut: OptionOrNullable<number | bigint>;
41
+ };
42
+ export declare function getSwapInstructionDataEncoder(): Encoder<SwapInstructionDataArgs>;
43
+ export declare function getSwapInstructionDataDecoder(): Decoder<SwapInstructionData>;
44
+ export declare function getSwapInstructionDataCodec(): Codec<SwapInstructionDataArgs, SwapInstructionData>;
45
+ export type SwapAsyncInput<TAccountSigner extends string = string, TAccountAdmin extends string = string, TAccountSettings extends string = string, TAccountLiquidityPool extends string = string, TAccountTokenFrom extends string = string, TAccountTokenFromAsset extends string = string, TAccountTokenFromOracle extends string = string, TAccountTokenTo extends string = string, TAccountTokenToAsset extends string = string, TAccountTokenToOracle extends string = string, TAccountTokenFromPool extends string = string, TAccountTokenToPool extends string = string, TAccountTokenFromSignerAccount extends string = string, TAccountTokenToSignerAccount extends string = string, TAccountTokenProgram extends string = string, TAccountAssociatedTokenProgram extends string = string, TAccountEventAuthority extends string = string, TAccountProgram extends string = string> = {
46
+ signer: TransactionSigner<TAccountSigner>;
47
+ admin?: Address<TAccountAdmin>;
48
+ settings?: Address<TAccountSettings>;
49
+ liquidityPool: Address<TAccountLiquidityPool>;
50
+ tokenFrom: Address<TAccountTokenFrom>;
51
+ tokenFromAsset?: Address<TAccountTokenFromAsset>;
52
+ tokenFromOracle: Address<TAccountTokenFromOracle>;
53
+ tokenTo: Address<TAccountTokenTo>;
54
+ tokenToAsset?: Address<TAccountTokenToAsset>;
55
+ tokenToOracle: Address<TAccountTokenToOracle>;
56
+ tokenFromPool?: Address<TAccountTokenFromPool>;
57
+ tokenToPool?: Address<TAccountTokenToPool>;
58
+ tokenFromSignerAccount: Address<TAccountTokenFromSignerAccount>;
59
+ tokenToSignerAccount: Address<TAccountTokenToSignerAccount>;
60
+ tokenProgram?: Address<TAccountTokenProgram>;
61
+ associatedTokenProgram?: Address<TAccountAssociatedTokenProgram>;
62
+ eventAuthority?: Address<TAccountEventAuthority>;
63
+ program: Address<TAccountProgram>;
64
+ amountIn: SwapInstructionDataArgs["amountIn"];
65
+ minOut: SwapInstructionDataArgs["minOut"];
66
+ };
67
+ export declare function getSwapInstructionAsync<TAccountSigner extends string, TAccountAdmin extends string, TAccountSettings extends string, TAccountLiquidityPool extends string, TAccountTokenFrom extends string, TAccountTokenFromAsset extends string, TAccountTokenFromOracle extends string, TAccountTokenTo extends string, TAccountTokenToAsset extends string, TAccountTokenToOracle extends string, TAccountTokenFromPool extends string, TAccountTokenToPool extends string, TAccountTokenFromSignerAccount extends string, TAccountTokenToSignerAccount extends string, TAccountTokenProgram extends string, TAccountAssociatedTokenProgram extends string, TAccountEventAuthority extends string, TAccountProgram extends string, TProgramAddress extends Address = typeof RLP_PROGRAM_ADDRESS>(input: SwapAsyncInput<TAccountSigner, TAccountAdmin, TAccountSettings, TAccountLiquidityPool, TAccountTokenFrom, TAccountTokenFromAsset, TAccountTokenFromOracle, TAccountTokenTo, TAccountTokenToAsset, TAccountTokenToOracle, TAccountTokenFromPool, TAccountTokenToPool, TAccountTokenFromSignerAccount, TAccountTokenToSignerAccount, TAccountTokenProgram, TAccountAssociatedTokenProgram, TAccountEventAuthority, TAccountProgram>, config?: {
68
+ programAddress?: TProgramAddress;
69
+ }): Promise<SwapInstruction<TProgramAddress, TAccountSigner, TAccountAdmin, TAccountSettings, TAccountLiquidityPool, TAccountTokenFrom, TAccountTokenFromAsset, TAccountTokenFromOracle, TAccountTokenTo, TAccountTokenToAsset, TAccountTokenToOracle, TAccountTokenFromPool, TAccountTokenToPool, TAccountTokenFromSignerAccount, TAccountTokenToSignerAccount, TAccountTokenProgram, TAccountAssociatedTokenProgram, TAccountEventAuthority, TAccountProgram>>;
70
+ export type SwapInput<TAccountSigner extends string = string, TAccountAdmin extends string = string, TAccountSettings extends string = string, TAccountLiquidityPool extends string = string, TAccountTokenFrom extends string = string, TAccountTokenFromAsset extends string = string, TAccountTokenFromOracle extends string = string, TAccountTokenTo extends string = string, TAccountTokenToAsset extends string = string, TAccountTokenToOracle extends string = string, TAccountTokenFromPool extends string = string, TAccountTokenToPool extends string = string, TAccountTokenFromSignerAccount extends string = string, TAccountTokenToSignerAccount extends string = string, TAccountTokenProgram extends string = string, TAccountAssociatedTokenProgram extends string = string, TAccountEventAuthority extends string = string, TAccountProgram extends string = string> = {
71
+ signer: TransactionSigner<TAccountSigner>;
72
+ admin?: Address<TAccountAdmin>;
73
+ settings: Address<TAccountSettings>;
74
+ liquidityPool: Address<TAccountLiquidityPool>;
75
+ tokenFrom: Address<TAccountTokenFrom>;
76
+ tokenFromAsset: Address<TAccountTokenFromAsset>;
77
+ tokenFromOracle: Address<TAccountTokenFromOracle>;
78
+ tokenTo: Address<TAccountTokenTo>;
79
+ tokenToAsset: Address<TAccountTokenToAsset>;
80
+ tokenToOracle: Address<TAccountTokenToOracle>;
81
+ tokenFromPool: Address<TAccountTokenFromPool>;
82
+ tokenToPool: Address<TAccountTokenToPool>;
83
+ tokenFromSignerAccount: Address<TAccountTokenFromSignerAccount>;
84
+ tokenToSignerAccount: Address<TAccountTokenToSignerAccount>;
85
+ tokenProgram?: Address<TAccountTokenProgram>;
86
+ associatedTokenProgram?: Address<TAccountAssociatedTokenProgram>;
87
+ eventAuthority: Address<TAccountEventAuthority>;
88
+ program: Address<TAccountProgram>;
89
+ amountIn: SwapInstructionDataArgs["amountIn"];
90
+ minOut: SwapInstructionDataArgs["minOut"];
91
+ };
92
+ export declare function getSwapInstruction<TAccountSigner extends string, TAccountAdmin extends string, TAccountSettings extends string, TAccountLiquidityPool extends string, TAccountTokenFrom extends string, TAccountTokenFromAsset extends string, TAccountTokenFromOracle extends string, TAccountTokenTo extends string, TAccountTokenToAsset extends string, TAccountTokenToOracle extends string, TAccountTokenFromPool extends string, TAccountTokenToPool extends string, TAccountTokenFromSignerAccount extends string, TAccountTokenToSignerAccount extends string, TAccountTokenProgram extends string, TAccountAssociatedTokenProgram extends string, TAccountEventAuthority extends string, TAccountProgram extends string, TProgramAddress extends Address = typeof RLP_PROGRAM_ADDRESS>(input: SwapInput<TAccountSigner, TAccountAdmin, TAccountSettings, TAccountLiquidityPool, TAccountTokenFrom, TAccountTokenFromAsset, TAccountTokenFromOracle, TAccountTokenTo, TAccountTokenToAsset, TAccountTokenToOracle, TAccountTokenFromPool, TAccountTokenToPool, TAccountTokenFromSignerAccount, TAccountTokenToSignerAccount, TAccountTokenProgram, TAccountAssociatedTokenProgram, TAccountEventAuthority, TAccountProgram>, config?: {
93
+ programAddress?: TProgramAddress;
94
+ }): SwapInstruction<TProgramAddress, TAccountSigner, TAccountAdmin, TAccountSettings, TAccountLiquidityPool, TAccountTokenFrom, TAccountTokenFromAsset, TAccountTokenFromOracle, TAccountTokenTo, TAccountTokenToAsset, TAccountTokenToOracle, TAccountTokenFromPool, TAccountTokenToPool, TAccountTokenFromSignerAccount, TAccountTokenToSignerAccount, TAccountTokenProgram, TAccountAssociatedTokenProgram, TAccountEventAuthority, TAccountProgram>;
95
+ export type ParsedSwapInstruction<TProgram extends string = typeof RLP_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = {
96
+ programAddress: Address<TProgram>;
97
+ accounts: {
98
+ signer: TAccountMetas[0];
99
+ admin?: TAccountMetas[1] | undefined;
100
+ settings: TAccountMetas[2];
101
+ liquidityPool: TAccountMetas[3];
102
+ tokenFrom: TAccountMetas[4];
103
+ tokenFromAsset: TAccountMetas[5];
104
+ tokenFromOracle: TAccountMetas[6];
105
+ tokenTo: TAccountMetas[7];
106
+ tokenToAsset: TAccountMetas[8];
107
+ tokenToOracle: TAccountMetas[9];
108
+ tokenFromPool: TAccountMetas[10];
109
+ tokenToPool: TAccountMetas[11];
110
+ tokenFromSignerAccount: TAccountMetas[12];
111
+ tokenToSignerAccount: TAccountMetas[13];
112
+ tokenProgram: TAccountMetas[14];
113
+ associatedTokenProgram: TAccountMetas[15];
114
+ eventAuthority: TAccountMetas[16];
115
+ program: TAccountMetas[17];
116
+ };
117
+ data: SwapInstructionData;
118
+ };
119
+ export declare function parseSwapInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedSwapInstruction<TProgram, TAccountMetas>;
@@ -0,0 +1,309 @@
1
+ "use strict";
2
+ /**
3
+ * This code was AUTOGENERATED using the Codama library.
4
+ * Please DO NOT EDIT THIS FILE, instead use visitors
5
+ * to add features, then rerun Codama to update it.
6
+ *
7
+ * @see https://github.com/codama-idl/codama
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SWAP_DISCRIMINATOR = void 0;
11
+ exports.getSwapDiscriminatorBytes = getSwapDiscriminatorBytes;
12
+ exports.getSwapInstructionDataEncoder = getSwapInstructionDataEncoder;
13
+ exports.getSwapInstructionDataDecoder = getSwapInstructionDataDecoder;
14
+ exports.getSwapInstructionDataCodec = getSwapInstructionDataCodec;
15
+ exports.getSwapInstructionAsync = getSwapInstructionAsync;
16
+ exports.getSwapInstruction = getSwapInstruction;
17
+ exports.parseSwapInstruction = parseSwapInstruction;
18
+ const kit_1 = require("@solana/kit");
19
+ const programs_1 = require("../programs");
20
+ const shared_1 = require("../shared");
21
+ exports.SWAP_DISCRIMINATOR = new Uint8Array([
22
+ 248, 198, 158, 145, 225, 117, 135, 200,
23
+ ]);
24
+ function getSwapDiscriminatorBytes() {
25
+ return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.SWAP_DISCRIMINATOR);
26
+ }
27
+ function getSwapInstructionDataEncoder() {
28
+ return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
29
+ ["discriminator", (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)],
30
+ ["amountIn", (0, kit_1.getU64Encoder)()],
31
+ ["minOut", (0, kit_1.getOptionEncoder)((0, kit_1.getU64Encoder)())],
32
+ ]), (value) => ({ ...value, discriminator: exports.SWAP_DISCRIMINATOR }));
33
+ }
34
+ function getSwapInstructionDataDecoder() {
35
+ return (0, kit_1.getStructDecoder)([
36
+ ["discriminator", (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)],
37
+ ["amountIn", (0, kit_1.getU64Decoder)()],
38
+ ["minOut", (0, kit_1.getOptionDecoder)((0, kit_1.getU64Decoder)())],
39
+ ]);
40
+ }
41
+ function getSwapInstructionDataCodec() {
42
+ return (0, kit_1.combineCodec)(getSwapInstructionDataEncoder(), getSwapInstructionDataDecoder());
43
+ }
44
+ async function getSwapInstructionAsync(input, config) {
45
+ // Program address.
46
+ const programAddress = config?.programAddress ?? programs_1.RLP_PROGRAM_ADDRESS;
47
+ // Original accounts.
48
+ const originalAccounts = {
49
+ signer: { value: input.signer ?? null, isWritable: true },
50
+ admin: { value: input.admin ?? null, isWritable: false },
51
+ settings: { value: input.settings ?? null, isWritable: false },
52
+ liquidityPool: { value: input.liquidityPool ?? null, isWritable: false },
53
+ tokenFrom: { value: input.tokenFrom ?? null, isWritable: false },
54
+ tokenFromAsset: { value: input.tokenFromAsset ?? null, isWritable: false },
55
+ tokenFromOracle: {
56
+ value: input.tokenFromOracle ?? null,
57
+ isWritable: false,
58
+ },
59
+ tokenTo: { value: input.tokenTo ?? null, isWritable: false },
60
+ tokenToAsset: { value: input.tokenToAsset ?? null, isWritable: false },
61
+ tokenToOracle: { value: input.tokenToOracle ?? null, isWritable: false },
62
+ tokenFromPool: { value: input.tokenFromPool ?? null, isWritable: true },
63
+ tokenToPool: { value: input.tokenToPool ?? null, isWritable: true },
64
+ tokenFromSignerAccount: {
65
+ value: input.tokenFromSignerAccount ?? null,
66
+ isWritable: true,
67
+ },
68
+ tokenToSignerAccount: {
69
+ value: input.tokenToSignerAccount ?? null,
70
+ isWritable: true,
71
+ },
72
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
73
+ associatedTokenProgram: {
74
+ value: input.associatedTokenProgram ?? null,
75
+ isWritable: false,
76
+ },
77
+ eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
78
+ program: { value: input.program ?? null, isWritable: false },
79
+ };
80
+ const accounts = originalAccounts;
81
+ // Original args.
82
+ const args = { ...input };
83
+ // Resolve default values.
84
+ if (!accounts.admin.value) {
85
+ accounts.admin.value = await (0, kit_1.getProgramDerivedAddress)({
86
+ programAddress,
87
+ seeds: [
88
+ (0, kit_1.getBytesEncoder)().encode(new Uint8Array([
89
+ 112, 101, 114, 109, 105, 115, 115, 105, 111, 110, 115,
90
+ ])),
91
+ (0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.signer.value)),
92
+ ],
93
+ });
94
+ }
95
+ if (!accounts.settings.value) {
96
+ accounts.settings.value = await (0, kit_1.getProgramDerivedAddress)({
97
+ programAddress,
98
+ seeds: [
99
+ (0, kit_1.getBytesEncoder)().encode(new Uint8Array([115, 101, 116, 116, 105, 110, 103, 115])),
100
+ ],
101
+ });
102
+ }
103
+ if (!accounts.tokenFromAsset.value) {
104
+ accounts.tokenFromAsset.value = await (0, kit_1.getProgramDerivedAddress)({
105
+ programAddress,
106
+ seeds: [
107
+ (0, kit_1.getBytesEncoder)().encode(new Uint8Array([97, 115, 115, 101, 116])),
108
+ (0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.tokenFrom.value)),
109
+ ],
110
+ });
111
+ }
112
+ if (!accounts.tokenToAsset.value) {
113
+ accounts.tokenToAsset.value = await (0, kit_1.getProgramDerivedAddress)({
114
+ programAddress,
115
+ seeds: [
116
+ (0, kit_1.getBytesEncoder)().encode(new Uint8Array([97, 115, 115, 101, 116])),
117
+ (0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.tokenTo.value)),
118
+ ],
119
+ });
120
+ }
121
+ if (!accounts.tokenFromPool.value) {
122
+ accounts.tokenFromPool.value = await (0, kit_1.getProgramDerivedAddress)({
123
+ programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
124
+ seeds: [
125
+ (0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.liquidityPool.value)),
126
+ (0, kit_1.getBytesEncoder)().encode(new Uint8Array([
127
+ 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235,
128
+ 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133,
129
+ 126, 255, 0, 169,
130
+ ])),
131
+ (0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.tokenFrom.value)),
132
+ ],
133
+ });
134
+ }
135
+ if (!accounts.tokenToPool.value) {
136
+ accounts.tokenToPool.value = await (0, kit_1.getProgramDerivedAddress)({
137
+ programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
138
+ seeds: [
139
+ (0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.liquidityPool.value)),
140
+ (0, kit_1.getBytesEncoder)().encode(new Uint8Array([
141
+ 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235,
142
+ 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133,
143
+ 126, 255, 0, 169,
144
+ ])),
145
+ (0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.tokenTo.value)),
146
+ ],
147
+ });
148
+ }
149
+ if (!accounts.tokenProgram.value) {
150
+ accounts.tokenProgram.value =
151
+ "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
152
+ }
153
+ if (!accounts.associatedTokenProgram.value) {
154
+ accounts.associatedTokenProgram.value =
155
+ "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
156
+ }
157
+ if (!accounts.eventAuthority.value) {
158
+ accounts.eventAuthority.value = await (0, kit_1.getProgramDerivedAddress)({
159
+ programAddress,
160
+ seeds: [
161
+ (0, kit_1.getBytesEncoder)().encode(new Uint8Array([
162
+ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114,
163
+ 105, 116, 121,
164
+ ])),
165
+ ],
166
+ });
167
+ }
168
+ const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, "programId");
169
+ return Object.freeze({
170
+ accounts: [
171
+ getAccountMeta(accounts.signer),
172
+ getAccountMeta(accounts.admin),
173
+ getAccountMeta(accounts.settings),
174
+ getAccountMeta(accounts.liquidityPool),
175
+ getAccountMeta(accounts.tokenFrom),
176
+ getAccountMeta(accounts.tokenFromAsset),
177
+ getAccountMeta(accounts.tokenFromOracle),
178
+ getAccountMeta(accounts.tokenTo),
179
+ getAccountMeta(accounts.tokenToAsset),
180
+ getAccountMeta(accounts.tokenToOracle),
181
+ getAccountMeta(accounts.tokenFromPool),
182
+ getAccountMeta(accounts.tokenToPool),
183
+ getAccountMeta(accounts.tokenFromSignerAccount),
184
+ getAccountMeta(accounts.tokenToSignerAccount),
185
+ getAccountMeta(accounts.tokenProgram),
186
+ getAccountMeta(accounts.associatedTokenProgram),
187
+ getAccountMeta(accounts.eventAuthority),
188
+ getAccountMeta(accounts.program),
189
+ ],
190
+ data: getSwapInstructionDataEncoder().encode(args),
191
+ programAddress,
192
+ });
193
+ }
194
+ function getSwapInstruction(input, config) {
195
+ // Program address.
196
+ const programAddress = config?.programAddress ?? programs_1.RLP_PROGRAM_ADDRESS;
197
+ // Original accounts.
198
+ const originalAccounts = {
199
+ signer: { value: input.signer ?? null, isWritable: true },
200
+ admin: { value: input.admin ?? null, isWritable: false },
201
+ settings: { value: input.settings ?? null, isWritable: false },
202
+ liquidityPool: { value: input.liquidityPool ?? null, isWritable: false },
203
+ tokenFrom: { value: input.tokenFrom ?? null, isWritable: false },
204
+ tokenFromAsset: { value: input.tokenFromAsset ?? null, isWritable: false },
205
+ tokenFromOracle: {
206
+ value: input.tokenFromOracle ?? null,
207
+ isWritable: false,
208
+ },
209
+ tokenTo: { value: input.tokenTo ?? null, isWritable: false },
210
+ tokenToAsset: { value: input.tokenToAsset ?? null, isWritable: false },
211
+ tokenToOracle: { value: input.tokenToOracle ?? null, isWritable: false },
212
+ tokenFromPool: { value: input.tokenFromPool ?? null, isWritable: true },
213
+ tokenToPool: { value: input.tokenToPool ?? null, isWritable: true },
214
+ tokenFromSignerAccount: {
215
+ value: input.tokenFromSignerAccount ?? null,
216
+ isWritable: true,
217
+ },
218
+ tokenToSignerAccount: {
219
+ value: input.tokenToSignerAccount ?? null,
220
+ isWritable: true,
221
+ },
222
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
223
+ associatedTokenProgram: {
224
+ value: input.associatedTokenProgram ?? null,
225
+ isWritable: false,
226
+ },
227
+ eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
228
+ program: { value: input.program ?? null, isWritable: false },
229
+ };
230
+ const accounts = originalAccounts;
231
+ // Original args.
232
+ const args = { ...input };
233
+ // Resolve default values.
234
+ if (!accounts.tokenProgram.value) {
235
+ accounts.tokenProgram.value =
236
+ "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
237
+ }
238
+ if (!accounts.associatedTokenProgram.value) {
239
+ accounts.associatedTokenProgram.value =
240
+ "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
241
+ }
242
+ const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, "programId");
243
+ return Object.freeze({
244
+ accounts: [
245
+ getAccountMeta(accounts.signer),
246
+ getAccountMeta(accounts.admin),
247
+ getAccountMeta(accounts.settings),
248
+ getAccountMeta(accounts.liquidityPool),
249
+ getAccountMeta(accounts.tokenFrom),
250
+ getAccountMeta(accounts.tokenFromAsset),
251
+ getAccountMeta(accounts.tokenFromOracle),
252
+ getAccountMeta(accounts.tokenTo),
253
+ getAccountMeta(accounts.tokenToAsset),
254
+ getAccountMeta(accounts.tokenToOracle),
255
+ getAccountMeta(accounts.tokenFromPool),
256
+ getAccountMeta(accounts.tokenToPool),
257
+ getAccountMeta(accounts.tokenFromSignerAccount),
258
+ getAccountMeta(accounts.tokenToSignerAccount),
259
+ getAccountMeta(accounts.tokenProgram),
260
+ getAccountMeta(accounts.associatedTokenProgram),
261
+ getAccountMeta(accounts.eventAuthority),
262
+ getAccountMeta(accounts.program),
263
+ ],
264
+ data: getSwapInstructionDataEncoder().encode(args),
265
+ programAddress,
266
+ });
267
+ }
268
+ function parseSwapInstruction(instruction) {
269
+ if (instruction.accounts.length < 18) {
270
+ // TODO: Coded error.
271
+ throw new Error("Not enough accounts");
272
+ }
273
+ let accountIndex = 0;
274
+ const getNextAccount = () => {
275
+ const accountMeta = instruction.accounts[accountIndex];
276
+ accountIndex += 1;
277
+ return accountMeta;
278
+ };
279
+ const getNextOptionalAccount = () => {
280
+ const accountMeta = getNextAccount();
281
+ return accountMeta.address === programs_1.RLP_PROGRAM_ADDRESS
282
+ ? undefined
283
+ : accountMeta;
284
+ };
285
+ return {
286
+ programAddress: instruction.programAddress,
287
+ accounts: {
288
+ signer: getNextAccount(),
289
+ admin: getNextOptionalAccount(),
290
+ settings: getNextAccount(),
291
+ liquidityPool: getNextAccount(),
292
+ tokenFrom: getNextAccount(),
293
+ tokenFromAsset: getNextAccount(),
294
+ tokenFromOracle: getNextAccount(),
295
+ tokenTo: getNextAccount(),
296
+ tokenToAsset: getNextAccount(),
297
+ tokenToOracle: getNextAccount(),
298
+ tokenFromPool: getNextAccount(),
299
+ tokenToPool: getNextAccount(),
300
+ tokenFromSignerAccount: getNextAccount(),
301
+ tokenToSignerAccount: getNextAccount(),
302
+ tokenProgram: getNextAccount(),
303
+ associatedTokenProgram: getNextAccount(),
304
+ eventAuthority: getNextAccount(),
305
+ program: getNextAccount(),
306
+ },
307
+ data: getSwapInstructionDataDecoder().decode(instruction.data),
308
+ };
309
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ import { type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from "@solana/kit";
9
+ import { RLP_PROGRAM_ADDRESS } from "../programs";
10
+ import { type Action, type ActionArgs, type Role, type RoleArgs, type Update, type UpdateArgs } from "../types";
11
+ export declare const UPDATE_ACTION_ROLE_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
12
+ export declare function getUpdateActionRoleDiscriminatorBytes(): ReadonlyUint8Array<ArrayBuffer>;
13
+ export type UpdateActionRoleInstruction<TProgram extends string = typeof RLP_PROGRAM_ADDRESS, TAccountAdmin extends string | AccountMeta<string> = string, TAccountSettings extends string | AccountMeta<string> = string, TAccountSystemProgram extends string | AccountMeta<string> = "11111111111111111111111111111111", TAccountAdminPermissions extends string | AccountMeta<string> = string, TAccountEventAuthority extends string | AccountMeta<string> = string, TAccountProgram extends string | AccountMeta<string> = string, TRemainingAccounts extends readonly AccountMeta<string>[] = []> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[
14
+ TAccountAdmin extends string ? WritableSignerAccount<TAccountAdmin> & AccountSignerMeta<TAccountAdmin> : TAccountAdmin,
15
+ TAccountSettings extends string ? WritableAccount<TAccountSettings> : TAccountSettings,
16
+ TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram,
17
+ TAccountAdminPermissions extends string ? WritableAccount<TAccountAdminPermissions> : TAccountAdminPermissions,
18
+ TAccountEventAuthority extends string ? ReadonlyAccount<TAccountEventAuthority> : TAccountEventAuthority,
19
+ TAccountProgram extends string ? ReadonlyAccount<TAccountProgram> : TAccountProgram,
20
+ ...TRemainingAccounts
21
+ ]>;
22
+ export type UpdateActionRoleInstructionData = {
23
+ discriminator: ReadonlyUint8Array;
24
+ action: Action;
25
+ role: Role;
26
+ update: Update;
27
+ };
28
+ export type UpdateActionRoleInstructionDataArgs = {
29
+ action: ActionArgs;
30
+ role: RoleArgs;
31
+ update: UpdateArgs;
32
+ };
33
+ export declare function getUpdateActionRoleInstructionDataEncoder(): FixedSizeEncoder<UpdateActionRoleInstructionDataArgs>;
34
+ export declare function getUpdateActionRoleInstructionDataDecoder(): FixedSizeDecoder<UpdateActionRoleInstructionData>;
35
+ export declare function getUpdateActionRoleInstructionDataCodec(): FixedSizeCodec<UpdateActionRoleInstructionDataArgs, UpdateActionRoleInstructionData>;
36
+ export type UpdateActionRoleAsyncInput<TAccountAdmin extends string = string, TAccountSettings extends string = string, TAccountSystemProgram extends string = string, TAccountAdminPermissions extends string = string, TAccountEventAuthority extends string = string, TAccountProgram extends string = string> = {
37
+ admin: TransactionSigner<TAccountAdmin>;
38
+ settings?: Address<TAccountSettings>;
39
+ systemProgram?: Address<TAccountSystemProgram>;
40
+ adminPermissions?: Address<TAccountAdminPermissions>;
41
+ eventAuthority?: Address<TAccountEventAuthority>;
42
+ program: Address<TAccountProgram>;
43
+ action: UpdateActionRoleInstructionDataArgs["action"];
44
+ role: UpdateActionRoleInstructionDataArgs["role"];
45
+ update: UpdateActionRoleInstructionDataArgs["update"];
46
+ };
47
+ export declare function getUpdateActionRoleInstructionAsync<TAccountAdmin extends string, TAccountSettings extends string, TAccountSystemProgram extends string, TAccountAdminPermissions extends string, TAccountEventAuthority extends string, TAccountProgram extends string, TProgramAddress extends Address = typeof RLP_PROGRAM_ADDRESS>(input: UpdateActionRoleAsyncInput<TAccountAdmin, TAccountSettings, TAccountSystemProgram, TAccountAdminPermissions, TAccountEventAuthority, TAccountProgram>, config?: {
48
+ programAddress?: TProgramAddress;
49
+ }): Promise<UpdateActionRoleInstruction<TProgramAddress, TAccountAdmin, TAccountSettings, TAccountSystemProgram, TAccountAdminPermissions, TAccountEventAuthority, TAccountProgram>>;
50
+ export type UpdateActionRoleInput<TAccountAdmin extends string = string, TAccountSettings extends string = string, TAccountSystemProgram extends string = string, TAccountAdminPermissions extends string = string, TAccountEventAuthority extends string = string, TAccountProgram extends string = string> = {
51
+ admin: TransactionSigner<TAccountAdmin>;
52
+ settings: Address<TAccountSettings>;
53
+ systemProgram?: Address<TAccountSystemProgram>;
54
+ adminPermissions: Address<TAccountAdminPermissions>;
55
+ eventAuthority: Address<TAccountEventAuthority>;
56
+ program: Address<TAccountProgram>;
57
+ action: UpdateActionRoleInstructionDataArgs["action"];
58
+ role: UpdateActionRoleInstructionDataArgs["role"];
59
+ update: UpdateActionRoleInstructionDataArgs["update"];
60
+ };
61
+ export declare function getUpdateActionRoleInstruction<TAccountAdmin extends string, TAccountSettings extends string, TAccountSystemProgram extends string, TAccountAdminPermissions extends string, TAccountEventAuthority extends string, TAccountProgram extends string, TProgramAddress extends Address = typeof RLP_PROGRAM_ADDRESS>(input: UpdateActionRoleInput<TAccountAdmin, TAccountSettings, TAccountSystemProgram, TAccountAdminPermissions, TAccountEventAuthority, TAccountProgram>, config?: {
62
+ programAddress?: TProgramAddress;
63
+ }): UpdateActionRoleInstruction<TProgramAddress, TAccountAdmin, TAccountSettings, TAccountSystemProgram, TAccountAdminPermissions, TAccountEventAuthority, TAccountProgram>;
64
+ export type ParsedUpdateActionRoleInstruction<TProgram extends string = typeof RLP_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = {
65
+ programAddress: Address<TProgram>;
66
+ accounts: {
67
+ admin: TAccountMetas[0];
68
+ settings: TAccountMetas[1];
69
+ systemProgram: TAccountMetas[2];
70
+ adminPermissions: TAccountMetas[3];
71
+ eventAuthority: TAccountMetas[4];
72
+ program: TAccountMetas[5];
73
+ };
74
+ data: UpdateActionRoleInstructionData;
75
+ };
76
+ export declare function parseUpdateActionRoleInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedUpdateActionRoleInstruction<TProgram, TAccountMetas>;