@keel-fi/svm-alm-controller 1.0.0-rc.1

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 (149) hide show
  1. package/dist/generated/accounts/controller.d.ts +29 -0
  2. package/dist/generated/accounts/controller.d.ts.map +1 -0
  3. package/dist/generated/accounts/index.d.ts +6 -0
  4. package/dist/generated/accounts/index.d.ts.map +1 -0
  5. package/dist/generated/accounts/integration.d.ts +45 -0
  6. package/dist/generated/accounts/integration.d.ts.map +1 -0
  7. package/dist/generated/accounts/oracle.d.ts +39 -0
  8. package/dist/generated/accounts/oracle.d.ts.map +1 -0
  9. package/dist/generated/accounts/permission.d.ts +43 -0
  10. package/dist/generated/accounts/permission.d.ts.map +1 -0
  11. package/dist/generated/accounts/reserve.d.ts +41 -0
  12. package/dist/generated/accounts/reserve.d.ts.map +1 -0
  13. package/dist/generated/index.d.ts +5 -0
  14. package/dist/generated/index.d.ts.map +1 -0
  15. package/dist/generated/instructions/atomicSwapBorrow.d.ts +76 -0
  16. package/dist/generated/instructions/atomicSwapBorrow.d.ts.map +1 -0
  17. package/dist/generated/instructions/atomicSwapRepay.d.ts +78 -0
  18. package/dist/generated/instructions/atomicSwapRepay.d.ts.map +1 -0
  19. package/dist/generated/instructions/emitEvent.d.ts +37 -0
  20. package/dist/generated/instructions/emitEvent.d.ts.map +1 -0
  21. package/dist/generated/instructions/index.d.ts +19 -0
  22. package/dist/generated/instructions/index.d.ts.map +1 -0
  23. package/dist/generated/instructions/initializeController.d.ts +56 -0
  24. package/dist/generated/instructions/initializeController.d.ts.map +1 -0
  25. package/dist/generated/instructions/initializeIntegration.d.ts +74 -0
  26. package/dist/generated/instructions/initializeIntegration.d.ts.map +1 -0
  27. package/dist/generated/instructions/initializeOracle.d.ts +61 -0
  28. package/dist/generated/instructions/initializeOracle.d.ts.map +1 -0
  29. package/dist/generated/instructions/initializeReserve.d.ts +74 -0
  30. package/dist/generated/instructions/initializeReserve.d.ts.map +1 -0
  31. package/dist/generated/instructions/manageController.d.ts +47 -0
  32. package/dist/generated/instructions/manageController.d.ts.map +1 -0
  33. package/dist/generated/instructions/manageIntegration.d.ts +59 -0
  34. package/dist/generated/instructions/manageIntegration.d.ts.map +1 -0
  35. package/dist/generated/instructions/managePermission.d.ts +86 -0
  36. package/dist/generated/instructions/managePermission.d.ts.map +1 -0
  37. package/dist/generated/instructions/manageReserve.d.ts +56 -0
  38. package/dist/generated/instructions/manageReserve.d.ts.map +1 -0
  39. package/dist/generated/instructions/pull.d.ts +56 -0
  40. package/dist/generated/instructions/pull.d.ts.map +1 -0
  41. package/dist/generated/instructions/push.d.ts +56 -0
  42. package/dist/generated/instructions/push.d.ts.map +1 -0
  43. package/dist/generated/instructions/refreshOracle.d.ts +33 -0
  44. package/dist/generated/instructions/refreshOracle.d.ts.map +1 -0
  45. package/dist/generated/instructions/resetLzPushInFlight.d.ts +36 -0
  46. package/dist/generated/instructions/resetLzPushInFlight.d.ts.map +1 -0
  47. package/dist/generated/instructions/sync.d.ts +36 -0
  48. package/dist/generated/instructions/sync.d.ts.map +1 -0
  49. package/dist/generated/instructions/syncReserve.d.ts +39 -0
  50. package/dist/generated/instructions/syncReserve.d.ts.map +1 -0
  51. package/dist/generated/instructions/updateOracle.d.ts +50 -0
  52. package/dist/generated/instructions/updateOracle.d.ts.map +1 -0
  53. package/dist/generated/programs/index.d.ts +2 -0
  54. package/dist/generated/programs/index.d.ts.map +1 -0
  55. package/dist/generated/programs/svmAlmController.d.ts +71 -0
  56. package/dist/generated/programs/svmAlmController.d.ts.map +1 -0
  57. package/dist/generated/shared/index.d.ts +15 -0
  58. package/dist/generated/shared/index.d.ts.map +1 -0
  59. package/dist/generated/types/accountDiscriminators.d.ts +14 -0
  60. package/dist/generated/types/accountDiscriminators.d.ts.map +1 -0
  61. package/dist/generated/types/accountingAction.d.ts +14 -0
  62. package/dist/generated/types/accountingAction.d.ts.map +1 -0
  63. package/dist/generated/types/accountingDirection.d.ts +10 -0
  64. package/dist/generated/types/accountingDirection.d.ts.map +1 -0
  65. package/dist/generated/types/accountingEvent.d.ts +24 -0
  66. package/dist/generated/types/accountingEvent.d.ts.map +1 -0
  67. package/dist/generated/types/atomicSwapConfig.d.ts +29 -0
  68. package/dist/generated/types/atomicSwapConfig.d.ts.map +1 -0
  69. package/dist/generated/types/atomicSwapState.d.ts +21 -0
  70. package/dist/generated/types/atomicSwapState.d.ts.map +1 -0
  71. package/dist/generated/types/cctpBridgeConfig.d.ts +14 -0
  72. package/dist/generated/types/cctpBridgeConfig.d.ts.map +1 -0
  73. package/dist/generated/types/cctpBridgeState.d.ts +9 -0
  74. package/dist/generated/types/cctpBridgeState.d.ts.map +1 -0
  75. package/dist/generated/types/controllerStatus.d.ts +11 -0
  76. package/dist/generated/types/controllerStatus.d.ts.map +1 -0
  77. package/dist/generated/types/controllerUpdateEvent.d.ts +18 -0
  78. package/dist/generated/types/controllerUpdateEvent.d.ts.map +1 -0
  79. package/dist/generated/types/depositForBurnArgs.d.ts +15 -0
  80. package/dist/generated/types/depositForBurnArgs.d.ts.map +1 -0
  81. package/dist/generated/types/depositSingleTokenTypeExactAmountInArgs.d.ts +13 -0
  82. package/dist/generated/types/depositSingleTokenTypeExactAmountInArgs.d.ts.map +1 -0
  83. package/dist/generated/types/feed.d.ts +10 -0
  84. package/dist/generated/types/feed.d.ts.map +1 -0
  85. package/dist/generated/types/feedArgs.d.ts +9 -0
  86. package/dist/generated/types/feedArgs.d.ts.map +1 -0
  87. package/dist/generated/types/index.d.ts +42 -0
  88. package/dist/generated/types/index.d.ts.map +1 -0
  89. package/dist/generated/types/initializeArgs.d.ts +51 -0
  90. package/dist/generated/types/initializeArgs.d.ts.map +1 -0
  91. package/dist/generated/types/integrationConfig.d.ts +53 -0
  92. package/dist/generated/types/integrationConfig.d.ts.map +1 -0
  93. package/dist/generated/types/integrationState.d.ts +53 -0
  94. package/dist/generated/types/integrationState.d.ts.map +1 -0
  95. package/dist/generated/types/integrationStatus.d.ts +10 -0
  96. package/dist/generated/types/integrationStatus.d.ts.map +1 -0
  97. package/dist/generated/types/integrationType.d.ts +13 -0
  98. package/dist/generated/types/integrationType.d.ts.map +1 -0
  99. package/dist/generated/types/integrationUpdateEvent.d.ts +20 -0
  100. package/dist/generated/types/integrationUpdateEvent.d.ts.map +1 -0
  101. package/dist/generated/types/localToken.d.ts +27 -0
  102. package/dist/generated/types/localToken.d.ts.map +1 -0
  103. package/dist/generated/types/lzBridgeConfig.d.ts +16 -0
  104. package/dist/generated/types/lzBridgeConfig.d.ts.map +1 -0
  105. package/dist/generated/types/lzBridgeState.d.ts +10 -0
  106. package/dist/generated/types/lzBridgeState.d.ts.map +1 -0
  107. package/dist/generated/types/oFTStore.d.ts +29 -0
  108. package/dist/generated/types/oFTStore.d.ts.map +1 -0
  109. package/dist/generated/types/oftSendParams.d.ts +15 -0
  110. package/dist/generated/types/oftSendParams.d.ts.map +1 -0
  111. package/dist/generated/types/oracleUpdateEvent.d.ts +20 -0
  112. package/dist/generated/types/oracleUpdateEvent.d.ts.map +1 -0
  113. package/dist/generated/types/peerConfig.d.ts +9 -0
  114. package/dist/generated/types/peerConfig.d.ts.map +1 -0
  115. package/dist/generated/types/permissionStatus.d.ts +10 -0
  116. package/dist/generated/types/permissionStatus.d.ts.map +1 -0
  117. package/dist/generated/types/permissionUpdateEvent.d.ts +20 -0
  118. package/dist/generated/types/permissionUpdateEvent.d.ts.map +1 -0
  119. package/dist/generated/types/pullArgs.d.ts +38 -0
  120. package/dist/generated/types/pullArgs.d.ts.map +1 -0
  121. package/dist/generated/types/pushArgs.d.ts +44 -0
  122. package/dist/generated/types/pushArgs.d.ts.map +1 -0
  123. package/dist/generated/types/remoteTokenMessenger.d.ts +10 -0
  124. package/dist/generated/types/remoteTokenMessenger.d.ts.map +1 -0
  125. package/dist/generated/types/reserveStatus.d.ts +10 -0
  126. package/dist/generated/types/reserveStatus.d.ts.map +1 -0
  127. package/dist/generated/types/reserveUpdateEvent.d.ts +20 -0
  128. package/dist/generated/types/reserveUpdateEvent.d.ts.map +1 -0
  129. package/dist/generated/types/splTokenExternalConfig.d.ts +13 -0
  130. package/dist/generated/types/splTokenExternalConfig.d.ts.map +1 -0
  131. package/dist/generated/types/splTokenExternalState.d.ts +9 -0
  132. package/dist/generated/types/splTokenExternalState.d.ts.map +1 -0
  133. package/dist/generated/types/splTokenSwapConfig.d.ts +15 -0
  134. package/dist/generated/types/splTokenSwapConfig.d.ts.map +1 -0
  135. package/dist/generated/types/splTokenSwapState.d.ts +17 -0
  136. package/dist/generated/types/splTokenSwapState.d.ts.map +1 -0
  137. package/dist/generated/types/svmAlmControllerEvent.d.ts +53 -0
  138. package/dist/generated/types/svmAlmControllerEvent.d.ts.map +1 -0
  139. package/dist/generated/types/swapV1Subset.d.ts +17 -0
  140. package/dist/generated/types/swapV1Subset.d.ts.map +1 -0
  141. package/dist/generated/types/withdrawSingleTokenTypeExactAmountOutArgs.d.ts +13 -0
  142. package/dist/generated/types/withdrawSingleTokenTypeExactAmountOutArgs.d.ts.map +1 -0
  143. package/dist/index.d.ts +3 -0
  144. package/dist/index.d.ts.map +1 -0
  145. package/dist/index.es.js +3067 -0
  146. package/dist/index.js +3382 -0
  147. package/dist/pdas.d.ts +9 -0
  148. package/dist/pdas.d.ts.map +1 -0
  149. package/package.json +24 -0
@@ -0,0 +1,3067 @@
1
+ import { getEnumEncoder, getEnumDecoder, combineCodec, getStructEncoder, getAddressEncoder, getOptionEncoder, getU64Encoder, getStructDecoder, getAddressDecoder, getOptionDecoder, getU64Decoder, getI64Encoder, getU16Encoder, getU8Encoder, getBooleanEncoder, fixEncoderSize, getBytesEncoder, getI64Decoder, getU16Decoder, getU8Decoder, getBooleanDecoder, fixDecoderSize, getBytesDecoder, getU32Encoder, getU32Decoder, getDiscriminatedUnionEncoder, getUnitEncoder, getDiscriminatedUnionDecoder, getUnitDecoder, getTupleEncoder, getTupleDecoder, getU128Encoder, getU128Decoder, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, getI128Encoder, getArrayEncoder, getI128Decoder, getArrayDecoder, containsBytes, AccountRole, upgradeRoleToSigner, isTransactionSigner as isTransactionSigner$1, transformEncoder, addEncoderSizePrefix, addDecoderSizePrefix } from '@solana/kit';
2
+ import { getAddressEncoder as getAddressEncoder$1, getProgramDerivedAddress, address } from '@solana/addresses';
3
+
4
+ var AccountDiscriminators;
5
+ (function (AccountDiscriminators) {
6
+ AccountDiscriminators[AccountDiscriminators["UninitializedDiscriminator"] = 0] = "UninitializedDiscriminator";
7
+ AccountDiscriminators[AccountDiscriminators["ControllerDiscriminator"] = 1] = "ControllerDiscriminator";
8
+ AccountDiscriminators[AccountDiscriminators["PermissionDiscriminator"] = 2] = "PermissionDiscriminator";
9
+ AccountDiscriminators[AccountDiscriminators["IntegrationDiscriminator"] = 3] = "IntegrationDiscriminator";
10
+ AccountDiscriminators[AccountDiscriminators["ReserveDiscriminator"] = 4] = "ReserveDiscriminator";
11
+ AccountDiscriminators[AccountDiscriminators["OracleDiscriminator"] = 5] = "OracleDiscriminator";
12
+ })(AccountDiscriminators || (AccountDiscriminators = {}));
13
+ function getAccountDiscriminatorsEncoder() {
14
+ return getEnumEncoder(AccountDiscriminators);
15
+ }
16
+ function getAccountDiscriminatorsDecoder() {
17
+ return getEnumDecoder(AccountDiscriminators);
18
+ }
19
+ function getAccountDiscriminatorsCodec() {
20
+ return combineCodec(getAccountDiscriminatorsEncoder(), getAccountDiscriminatorsDecoder());
21
+ }
22
+
23
+ var AccountingAction;
24
+ (function (AccountingAction) {
25
+ AccountingAction[AccountingAction["Sync"] = 0] = "Sync";
26
+ AccountingAction[AccountingAction["ExternalTransfer"] = 1] = "ExternalTransfer";
27
+ AccountingAction[AccountingAction["Deposit"] = 2] = "Deposit";
28
+ AccountingAction[AccountingAction["Withdrawal"] = 3] = "Withdrawal";
29
+ AccountingAction[AccountingAction["BridgeSend"] = 4] = "BridgeSend";
30
+ AccountingAction[AccountingAction["Swap"] = 5] = "Swap";
31
+ })(AccountingAction || (AccountingAction = {}));
32
+ function getAccountingActionEncoder() {
33
+ return getEnumEncoder(AccountingAction);
34
+ }
35
+ function getAccountingActionDecoder() {
36
+ return getEnumDecoder(AccountingAction);
37
+ }
38
+ function getAccountingActionCodec() {
39
+ return combineCodec(getAccountingActionEncoder(), getAccountingActionDecoder());
40
+ }
41
+
42
+ var AccountingDirection;
43
+ (function (AccountingDirection) {
44
+ AccountingDirection[AccountingDirection["Debit"] = 0] = "Debit";
45
+ AccountingDirection[AccountingDirection["Credit"] = 1] = "Credit";
46
+ })(AccountingDirection || (AccountingDirection = {}));
47
+ function getAccountingDirectionEncoder() {
48
+ return getEnumEncoder(AccountingDirection);
49
+ }
50
+ function getAccountingDirectionDecoder() {
51
+ return getEnumDecoder(AccountingDirection);
52
+ }
53
+ function getAccountingDirectionCodec() {
54
+ return combineCodec(getAccountingDirectionEncoder(), getAccountingDirectionDecoder());
55
+ }
56
+
57
+ function getAccountingEventEncoder() {
58
+ return getStructEncoder([
59
+ ['controller', getAddressEncoder()],
60
+ ['integration', getOptionEncoder(getAddressEncoder())],
61
+ ['reserve', getOptionEncoder(getAddressEncoder())],
62
+ ['mint', getAddressEncoder()],
63
+ ['action', getAccountingActionEncoder()],
64
+ ['delta', getU64Encoder()],
65
+ ['direction', getAccountingDirectionEncoder()],
66
+ ]);
67
+ }
68
+ function getAccountingEventDecoder() {
69
+ return getStructDecoder([
70
+ ['controller', getAddressDecoder()],
71
+ ['integration', getOptionDecoder(getAddressDecoder())],
72
+ ['reserve', getOptionDecoder(getAddressDecoder())],
73
+ ['mint', getAddressDecoder()],
74
+ ['action', getAccountingActionDecoder()],
75
+ ['delta', getU64Decoder()],
76
+ ['direction', getAccountingDirectionDecoder()],
77
+ ]);
78
+ }
79
+ function getAccountingEventCodec() {
80
+ return combineCodec(getAccountingEventEncoder(), getAccountingEventDecoder());
81
+ }
82
+
83
+ function getAtomicSwapConfigEncoder() {
84
+ return getStructEncoder([
85
+ ['inputToken', getAddressEncoder()],
86
+ ['outputToken', getAddressEncoder()],
87
+ ['oracle', getAddressEncoder()],
88
+ ['maxStaleness', getU64Encoder()],
89
+ ['expiryTimestamp', getI64Encoder()],
90
+ ['maxSlippageBps', getU16Encoder()],
91
+ ['inputMintDecimals', getU8Encoder()],
92
+ ['outputMintDecimals', getU8Encoder()],
93
+ ['oraclePriceInverted', getBooleanEncoder()],
94
+ ['padding', fixEncoderSize(getBytesEncoder(), 107)],
95
+ ]);
96
+ }
97
+ function getAtomicSwapConfigDecoder() {
98
+ return getStructDecoder([
99
+ ['inputToken', getAddressDecoder()],
100
+ ['outputToken', getAddressDecoder()],
101
+ ['oracle', getAddressDecoder()],
102
+ ['maxStaleness', getU64Decoder()],
103
+ ['expiryTimestamp', getI64Decoder()],
104
+ ['maxSlippageBps', getU16Decoder()],
105
+ ['inputMintDecimals', getU8Decoder()],
106
+ ['outputMintDecimals', getU8Decoder()],
107
+ ['oraclePriceInverted', getBooleanDecoder()],
108
+ ['padding', fixDecoderSize(getBytesDecoder(), 107)],
109
+ ]);
110
+ }
111
+ function getAtomicSwapConfigCodec() {
112
+ return combineCodec(getAtomicSwapConfigEncoder(), getAtomicSwapConfigDecoder());
113
+ }
114
+
115
+ function getAtomicSwapStateEncoder() {
116
+ return getStructEncoder([
117
+ ['lastBalanceA', getU64Encoder()],
118
+ ['lastBalanceB', getU64Encoder()],
119
+ ['amountBorrowed', getU64Encoder()],
120
+ ['recipientTokenAPre', getU64Encoder()],
121
+ ['recipientTokenBPre', getU64Encoder()],
122
+ ['padding', fixEncoderSize(getBytesEncoder(), 8)],
123
+ ]);
124
+ }
125
+ function getAtomicSwapStateDecoder() {
126
+ return getStructDecoder([
127
+ ['lastBalanceA', getU64Decoder()],
128
+ ['lastBalanceB', getU64Decoder()],
129
+ ['amountBorrowed', getU64Decoder()],
130
+ ['recipientTokenAPre', getU64Decoder()],
131
+ ['recipientTokenBPre', getU64Decoder()],
132
+ ['padding', fixDecoderSize(getBytesDecoder(), 8)],
133
+ ]);
134
+ }
135
+ function getAtomicSwapStateCodec() {
136
+ return combineCodec(getAtomicSwapStateEncoder(), getAtomicSwapStateDecoder());
137
+ }
138
+
139
+ function getCctpBridgeConfigEncoder() {
140
+ return getStructEncoder([
141
+ ['cctpTokenMessengerMinter', getAddressEncoder()],
142
+ ['cctpMessageTransmitter', getAddressEncoder()],
143
+ ['mint', getAddressEncoder()],
144
+ ['destinationAddress', getAddressEncoder()],
145
+ ['destinationDomain', getU32Encoder()],
146
+ ['padding', fixEncoderSize(getBytesEncoder(), 92)],
147
+ ]);
148
+ }
149
+ function getCctpBridgeConfigDecoder() {
150
+ return getStructDecoder([
151
+ ['cctpTokenMessengerMinter', getAddressDecoder()],
152
+ ['cctpMessageTransmitter', getAddressDecoder()],
153
+ ['mint', getAddressDecoder()],
154
+ ['destinationAddress', getAddressDecoder()],
155
+ ['destinationDomain', getU32Decoder()],
156
+ ['padding', fixDecoderSize(getBytesDecoder(), 92)],
157
+ ]);
158
+ }
159
+ function getCctpBridgeConfigCodec() {
160
+ return combineCodec(getCctpBridgeConfigEncoder(), getCctpBridgeConfigDecoder());
161
+ }
162
+
163
+ function getCctpBridgeStateEncoder() {
164
+ return getStructEncoder([['padding', fixEncoderSize(getBytesEncoder(), 48)]]);
165
+ }
166
+ function getCctpBridgeStateDecoder() {
167
+ return getStructDecoder([['padding', fixDecoderSize(getBytesDecoder(), 48)]]);
168
+ }
169
+ function getCctpBridgeStateCodec() {
170
+ return combineCodec(getCctpBridgeStateEncoder(), getCctpBridgeStateDecoder());
171
+ }
172
+
173
+ var ControllerStatus;
174
+ (function (ControllerStatus) {
175
+ ControllerStatus[ControllerStatus["Frozen"] = 0] = "Frozen";
176
+ ControllerStatus[ControllerStatus["Active"] = 1] = "Active";
177
+ ControllerStatus[ControllerStatus["PushPullFrozen"] = 2] = "PushPullFrozen";
178
+ })(ControllerStatus || (ControllerStatus = {}));
179
+ function getControllerStatusEncoder() {
180
+ return getEnumEncoder(ControllerStatus);
181
+ }
182
+ function getControllerStatusDecoder() {
183
+ return getEnumDecoder(ControllerStatus);
184
+ }
185
+ function getControllerStatusCodec() {
186
+ return combineCodec(getControllerStatusEncoder(), getControllerStatusDecoder());
187
+ }
188
+
189
+ function getControllerUpdateEventEncoder() {
190
+ return getStructEncoder([
191
+ ['authority', getAddressEncoder()],
192
+ ['controller', getAddressEncoder()],
193
+ ['oldState', getOptionEncoder(getControllerEncoder())],
194
+ ['newState', getOptionEncoder(getControllerEncoder())],
195
+ ]);
196
+ }
197
+ function getControllerUpdateEventDecoder() {
198
+ return getStructDecoder([
199
+ ['authority', getAddressDecoder()],
200
+ ['controller', getAddressDecoder()],
201
+ ['oldState', getOptionDecoder(getControllerDecoder())],
202
+ ['newState', getOptionDecoder(getControllerDecoder())],
203
+ ]);
204
+ }
205
+ function getControllerUpdateEventCodec() {
206
+ return combineCodec(getControllerUpdateEventEncoder(), getControllerUpdateEventDecoder());
207
+ }
208
+
209
+ function getDepositForBurnArgsEncoder() {
210
+ return getStructEncoder([
211
+ ['amount', getU64Encoder()],
212
+ ['destinationDomain', getU32Encoder()],
213
+ ['mintRecipient', getAddressEncoder()],
214
+ ]);
215
+ }
216
+ function getDepositForBurnArgsDecoder() {
217
+ return getStructDecoder([
218
+ ['amount', getU64Decoder()],
219
+ ['destinationDomain', getU32Decoder()],
220
+ ['mintRecipient', getAddressDecoder()],
221
+ ]);
222
+ }
223
+ function getDepositForBurnArgsCodec() {
224
+ return combineCodec(getDepositForBurnArgsEncoder(), getDepositForBurnArgsDecoder());
225
+ }
226
+
227
+ function getDepositSingleTokenTypeExactAmountInArgsEncoder() {
228
+ return getStructEncoder([
229
+ ['sourceTokenAmount', getU64Encoder()],
230
+ ['minimumPoolTokenAmount', getU64Encoder()],
231
+ ]);
232
+ }
233
+ function getDepositSingleTokenTypeExactAmountInArgsDecoder() {
234
+ return getStructDecoder([
235
+ ['sourceTokenAmount', getU64Decoder()],
236
+ ['minimumPoolTokenAmount', getU64Decoder()],
237
+ ]);
238
+ }
239
+ function getDepositSingleTokenTypeExactAmountInArgsCodec() {
240
+ return combineCodec(getDepositSingleTokenTypeExactAmountInArgsEncoder(), getDepositSingleTokenTypeExactAmountInArgsDecoder());
241
+ }
242
+
243
+ function getFeedEncoder() {
244
+ return getStructEncoder([
245
+ ['priceFeed', getAddressEncoder()],
246
+ ['oracleType', getU8Encoder()],
247
+ ['reserved', fixEncoderSize(getBytesEncoder(), 63)],
248
+ ]);
249
+ }
250
+ function getFeedDecoder() {
251
+ return getStructDecoder([
252
+ ['priceFeed', getAddressDecoder()],
253
+ ['oracleType', getU8Decoder()],
254
+ ['reserved', fixDecoderSize(getBytesDecoder(), 63)],
255
+ ]);
256
+ }
257
+ function getFeedCodec() {
258
+ return combineCodec(getFeedEncoder(), getFeedDecoder());
259
+ }
260
+
261
+ function getFeedArgsEncoder() {
262
+ return getStructEncoder([['oracleType', getU8Encoder()]]);
263
+ }
264
+ function getFeedArgsDecoder() {
265
+ return getStructDecoder([['oracleType', getU8Decoder()]]);
266
+ }
267
+ function getFeedArgsCodec() {
268
+ return combineCodec(getFeedArgsEncoder(), getFeedArgsDecoder());
269
+ }
270
+
271
+ function getInitializeArgsEncoder() {
272
+ return getDiscriminatedUnionEncoder([
273
+ ['SplTokenExternal', getUnitEncoder()],
274
+ ['SplTokenSwap', getUnitEncoder()],
275
+ [
276
+ 'CctpBridge',
277
+ getStructEncoder([
278
+ ['destinationAddress', getAddressEncoder()],
279
+ ['destinationDomain', getU32Encoder()],
280
+ ]),
281
+ ],
282
+ [
283
+ 'LzBridge',
284
+ getStructEncoder([
285
+ ['destinationAddress', getAddressEncoder()],
286
+ ['destinationEid', getU32Encoder()],
287
+ ]),
288
+ ],
289
+ [
290
+ 'AtomicSwap',
291
+ getStructEncoder([
292
+ ['maxSlippageBps', getU16Encoder()],
293
+ ['maxStaleness', getU64Encoder()],
294
+ ['expiryTimestamp', getI64Encoder()],
295
+ ['oraclePriceInverted', getBooleanEncoder()],
296
+ ]),
297
+ ],
298
+ ]);
299
+ }
300
+ function getInitializeArgsDecoder() {
301
+ return getDiscriminatedUnionDecoder([
302
+ ['SplTokenExternal', getUnitDecoder()],
303
+ ['SplTokenSwap', getUnitDecoder()],
304
+ [
305
+ 'CctpBridge',
306
+ getStructDecoder([
307
+ ['destinationAddress', getAddressDecoder()],
308
+ ['destinationDomain', getU32Decoder()],
309
+ ]),
310
+ ],
311
+ [
312
+ 'LzBridge',
313
+ getStructDecoder([
314
+ ['destinationAddress', getAddressDecoder()],
315
+ ['destinationEid', getU32Decoder()],
316
+ ]),
317
+ ],
318
+ [
319
+ 'AtomicSwap',
320
+ getStructDecoder([
321
+ ['maxSlippageBps', getU16Decoder()],
322
+ ['maxStaleness', getU64Decoder()],
323
+ ['expiryTimestamp', getI64Decoder()],
324
+ ['oraclePriceInverted', getBooleanDecoder()],
325
+ ]),
326
+ ],
327
+ ]);
328
+ }
329
+ function getInitializeArgsCodec() {
330
+ return combineCodec(getInitializeArgsEncoder(), getInitializeArgsDecoder());
331
+ }
332
+ function initializeArgs(kind, data) {
333
+ return Array.isArray(data)
334
+ ? { __kind: kind, fields: data }
335
+ : { __kind: kind, ...(data ?? {}) };
336
+ }
337
+ function isInitializeArgs(kind, value) {
338
+ return value.__kind === kind;
339
+ }
340
+
341
+ function getIntegrationConfigEncoder() {
342
+ return getDiscriminatedUnionEncoder([
343
+ [
344
+ 'Undefined',
345
+ getStructEncoder([['padding', fixEncoderSize(getBytesEncoder(), 224)]]),
346
+ ],
347
+ [
348
+ 'SplTokenExternal',
349
+ getStructEncoder([
350
+ ['fields', getTupleEncoder([getSplTokenExternalConfigEncoder()])],
351
+ ]),
352
+ ],
353
+ [
354
+ 'SplTokenSwap',
355
+ getStructEncoder([
356
+ ['fields', getTupleEncoder([getSplTokenSwapConfigEncoder()])],
357
+ ]),
358
+ ],
359
+ [
360
+ 'CctpBridge',
361
+ getStructEncoder([
362
+ ['fields', getTupleEncoder([getCctpBridgeConfigEncoder()])],
363
+ ]),
364
+ ],
365
+ [
366
+ 'LzBridge',
367
+ getStructEncoder([
368
+ ['fields', getTupleEncoder([getLzBridgeConfigEncoder()])],
369
+ ]),
370
+ ],
371
+ [
372
+ 'AtomicSwap',
373
+ getStructEncoder([
374
+ ['fields', getTupleEncoder([getAtomicSwapConfigEncoder()])],
375
+ ]),
376
+ ],
377
+ ]);
378
+ }
379
+ function getIntegrationConfigDecoder() {
380
+ return getDiscriminatedUnionDecoder([
381
+ [
382
+ 'Undefined',
383
+ getStructDecoder([['padding', fixDecoderSize(getBytesDecoder(), 224)]]),
384
+ ],
385
+ [
386
+ 'SplTokenExternal',
387
+ getStructDecoder([
388
+ ['fields', getTupleDecoder([getSplTokenExternalConfigDecoder()])],
389
+ ]),
390
+ ],
391
+ [
392
+ 'SplTokenSwap',
393
+ getStructDecoder([
394
+ ['fields', getTupleDecoder([getSplTokenSwapConfigDecoder()])],
395
+ ]),
396
+ ],
397
+ [
398
+ 'CctpBridge',
399
+ getStructDecoder([
400
+ ['fields', getTupleDecoder([getCctpBridgeConfigDecoder()])],
401
+ ]),
402
+ ],
403
+ [
404
+ 'LzBridge',
405
+ getStructDecoder([
406
+ ['fields', getTupleDecoder([getLzBridgeConfigDecoder()])],
407
+ ]),
408
+ ],
409
+ [
410
+ 'AtomicSwap',
411
+ getStructDecoder([
412
+ ['fields', getTupleDecoder([getAtomicSwapConfigDecoder()])],
413
+ ]),
414
+ ],
415
+ ]);
416
+ }
417
+ function getIntegrationConfigCodec() {
418
+ return combineCodec(getIntegrationConfigEncoder(), getIntegrationConfigDecoder());
419
+ }
420
+ function integrationConfig(kind, data) {
421
+ return Array.isArray(data)
422
+ ? { __kind: kind, fields: data }
423
+ : { __kind: kind, ...(data ?? {}) };
424
+ }
425
+ function isIntegrationConfig(kind, value) {
426
+ return value.__kind === kind;
427
+ }
428
+
429
+ function getIntegrationStateEncoder() {
430
+ return getDiscriminatedUnionEncoder([
431
+ [
432
+ 'Undefined',
433
+ getStructEncoder([['padding', fixEncoderSize(getBytesEncoder(), 48)]]),
434
+ ],
435
+ [
436
+ 'SplTokenExternal',
437
+ getStructEncoder([
438
+ ['fields', getTupleEncoder([getSplTokenExternalStateEncoder()])],
439
+ ]),
440
+ ],
441
+ [
442
+ 'SplTokenSwap',
443
+ getStructEncoder([
444
+ ['fields', getTupleEncoder([getSplTokenSwapStateEncoder()])],
445
+ ]),
446
+ ],
447
+ [
448
+ 'CctpBridge',
449
+ getStructEncoder([
450
+ ['fields', getTupleEncoder([getCctpBridgeStateEncoder()])],
451
+ ]),
452
+ ],
453
+ [
454
+ 'LzBridge',
455
+ getStructEncoder([
456
+ ['fields', getTupleEncoder([getLzBridgeStateEncoder()])],
457
+ ]),
458
+ ],
459
+ [
460
+ 'AtomicSwap',
461
+ getStructEncoder([
462
+ ['fields', getTupleEncoder([getAtomicSwapStateEncoder()])],
463
+ ]),
464
+ ],
465
+ ]);
466
+ }
467
+ function getIntegrationStateDecoder() {
468
+ return getDiscriminatedUnionDecoder([
469
+ [
470
+ 'Undefined',
471
+ getStructDecoder([['padding', fixDecoderSize(getBytesDecoder(), 48)]]),
472
+ ],
473
+ [
474
+ 'SplTokenExternal',
475
+ getStructDecoder([
476
+ ['fields', getTupleDecoder([getSplTokenExternalStateDecoder()])],
477
+ ]),
478
+ ],
479
+ [
480
+ 'SplTokenSwap',
481
+ getStructDecoder([
482
+ ['fields', getTupleDecoder([getSplTokenSwapStateDecoder()])],
483
+ ]),
484
+ ],
485
+ [
486
+ 'CctpBridge',
487
+ getStructDecoder([
488
+ ['fields', getTupleDecoder([getCctpBridgeStateDecoder()])],
489
+ ]),
490
+ ],
491
+ [
492
+ 'LzBridge',
493
+ getStructDecoder([
494
+ ['fields', getTupleDecoder([getLzBridgeStateDecoder()])],
495
+ ]),
496
+ ],
497
+ [
498
+ 'AtomicSwap',
499
+ getStructDecoder([
500
+ ['fields', getTupleDecoder([getAtomicSwapStateDecoder()])],
501
+ ]),
502
+ ],
503
+ ]);
504
+ }
505
+ function getIntegrationStateCodec() {
506
+ return combineCodec(getIntegrationStateEncoder(), getIntegrationStateDecoder());
507
+ }
508
+ function integrationState(kind, data) {
509
+ return Array.isArray(data)
510
+ ? { __kind: kind, fields: data }
511
+ : { __kind: kind, ...(data ?? {}) };
512
+ }
513
+ function isIntegrationState(kind, value) {
514
+ return value.__kind === kind;
515
+ }
516
+
517
+ var IntegrationStatus;
518
+ (function (IntegrationStatus) {
519
+ IntegrationStatus[IntegrationStatus["Suspended"] = 0] = "Suspended";
520
+ IntegrationStatus[IntegrationStatus["Active"] = 1] = "Active";
521
+ })(IntegrationStatus || (IntegrationStatus = {}));
522
+ function getIntegrationStatusEncoder() {
523
+ return getEnumEncoder(IntegrationStatus);
524
+ }
525
+ function getIntegrationStatusDecoder() {
526
+ return getEnumDecoder(IntegrationStatus);
527
+ }
528
+ function getIntegrationStatusCodec() {
529
+ return combineCodec(getIntegrationStatusEncoder(), getIntegrationStatusDecoder());
530
+ }
531
+
532
+ var IntegrationType;
533
+ (function (IntegrationType) {
534
+ IntegrationType[IntegrationType["SplTokenExternal"] = 0] = "SplTokenExternal";
535
+ IntegrationType[IntegrationType["SplTokenSwap"] = 1] = "SplTokenSwap";
536
+ IntegrationType[IntegrationType["CctpBridge"] = 2] = "CctpBridge";
537
+ IntegrationType[IntegrationType["LzBridge"] = 3] = "LzBridge";
538
+ IntegrationType[IntegrationType["AtomicSwap"] = 4] = "AtomicSwap";
539
+ })(IntegrationType || (IntegrationType = {}));
540
+ function getIntegrationTypeEncoder() {
541
+ return getEnumEncoder(IntegrationType);
542
+ }
543
+ function getIntegrationTypeDecoder() {
544
+ return getEnumDecoder(IntegrationType);
545
+ }
546
+ function getIntegrationTypeCodec() {
547
+ return combineCodec(getIntegrationTypeEncoder(), getIntegrationTypeDecoder());
548
+ }
549
+
550
+ function getIntegrationUpdateEventEncoder() {
551
+ return getStructEncoder([
552
+ ['authority', getAddressEncoder()],
553
+ ['controller', getAddressEncoder()],
554
+ ['integration', getAddressEncoder()],
555
+ ['oldState', getOptionEncoder(getIntegrationEncoder())],
556
+ ['newState', getOptionEncoder(getIntegrationEncoder())],
557
+ ]);
558
+ }
559
+ function getIntegrationUpdateEventDecoder() {
560
+ return getStructDecoder([
561
+ ['authority', getAddressDecoder()],
562
+ ['controller', getAddressDecoder()],
563
+ ['integration', getAddressDecoder()],
564
+ ['oldState', getOptionDecoder(getIntegrationDecoder())],
565
+ ['newState', getOptionDecoder(getIntegrationDecoder())],
566
+ ]);
567
+ }
568
+ function getIntegrationUpdateEventCodec() {
569
+ return combineCodec(getIntegrationUpdateEventEncoder(), getIntegrationUpdateEventDecoder());
570
+ }
571
+
572
+ function getLocalTokenEncoder() {
573
+ return getStructEncoder([
574
+ ['custody', getAddressEncoder()],
575
+ ['mint', getAddressEncoder()],
576
+ ['burnLimitPerMessage', getU64Encoder()],
577
+ ['messagesSent', getU64Encoder()],
578
+ ['messagesReceived', getU64Encoder()],
579
+ ['amountSent', getU128Encoder()],
580
+ ['amountReceived', getU128Encoder()],
581
+ ['bump', getU8Encoder()],
582
+ ['custodyBump', getU8Encoder()],
583
+ ]);
584
+ }
585
+ function getLocalTokenDecoder() {
586
+ return getStructDecoder([
587
+ ['custody', getAddressDecoder()],
588
+ ['mint', getAddressDecoder()],
589
+ ['burnLimitPerMessage', getU64Decoder()],
590
+ ['messagesSent', getU64Decoder()],
591
+ ['messagesReceived', getU64Decoder()],
592
+ ['amountSent', getU128Decoder()],
593
+ ['amountReceived', getU128Decoder()],
594
+ ['bump', getU8Decoder()],
595
+ ['custodyBump', getU8Decoder()],
596
+ ]);
597
+ }
598
+ function getLocalTokenCodec() {
599
+ return combineCodec(getLocalTokenEncoder(), getLocalTokenDecoder());
600
+ }
601
+
602
+ function getLzBridgeConfigEncoder() {
603
+ return getStructEncoder([
604
+ ['program', getAddressEncoder()],
605
+ ['mint', getAddressEncoder()],
606
+ ['oftStore', getAddressEncoder()],
607
+ ['peerConfig', getAddressEncoder()],
608
+ ['oftTokenEscrow', getAddressEncoder()],
609
+ ['destinationAddress', getAddressEncoder()],
610
+ ['destinationEid', getU32Encoder()],
611
+ ['padding', fixEncoderSize(getBytesEncoder(), 28)],
612
+ ]);
613
+ }
614
+ function getLzBridgeConfigDecoder() {
615
+ return getStructDecoder([
616
+ ['program', getAddressDecoder()],
617
+ ['mint', getAddressDecoder()],
618
+ ['oftStore', getAddressDecoder()],
619
+ ['peerConfig', getAddressDecoder()],
620
+ ['oftTokenEscrow', getAddressDecoder()],
621
+ ['destinationAddress', getAddressDecoder()],
622
+ ['destinationEid', getU32Decoder()],
623
+ ['padding', fixDecoderSize(getBytesDecoder(), 28)],
624
+ ]);
625
+ }
626
+ function getLzBridgeConfigCodec() {
627
+ return combineCodec(getLzBridgeConfigEncoder(), getLzBridgeConfigDecoder());
628
+ }
629
+
630
+ function getLzBridgeStateEncoder() {
631
+ return getStructEncoder([
632
+ ['pushInFlight', getBooleanEncoder()],
633
+ ['padding', fixEncoderSize(getBytesEncoder(), 47)],
634
+ ]);
635
+ }
636
+ function getLzBridgeStateDecoder() {
637
+ return getStructDecoder([
638
+ ['pushInFlight', getBooleanDecoder()],
639
+ ['padding', fixDecoderSize(getBytesDecoder(), 47)],
640
+ ]);
641
+ }
642
+ function getLzBridgeStateCodec() {
643
+ return combineCodec(getLzBridgeStateEncoder(), getLzBridgeStateDecoder());
644
+ }
645
+
646
+ function getOftSendParamsEncoder() {
647
+ return getStructEncoder([
648
+ ['dstEid', getU32Encoder()],
649
+ ['to', fixEncoderSize(getBytesEncoder(), 32)],
650
+ ['amountLd', getU64Encoder()],
651
+ ]);
652
+ }
653
+ function getOftSendParamsDecoder() {
654
+ return getStructDecoder([
655
+ ['dstEid', getU32Decoder()],
656
+ ['to', fixDecoderSize(getBytesDecoder(), 32)],
657
+ ['amountLd', getU64Decoder()],
658
+ ]);
659
+ }
660
+ function getOftSendParamsCodec() {
661
+ return combineCodec(getOftSendParamsEncoder(), getOftSendParamsDecoder());
662
+ }
663
+
664
+ function getOFTStoreEncoder() {
665
+ return getStructEncoder([
666
+ ['oftType', getU8Encoder()],
667
+ ['ld2sdRate', getU64Encoder()],
668
+ ['tokenMint', getAddressEncoder()],
669
+ ['tokenEscrow', getAddressEncoder()],
670
+ ['endpointProgram', getAddressEncoder()],
671
+ ['bump', getU8Encoder()],
672
+ ['tvlLd', getU64Encoder()],
673
+ ['admin', getAddressEncoder()],
674
+ ['defaultFeeBps', getU16Encoder()],
675
+ ['paused', getBooleanEncoder()],
676
+ ]);
677
+ }
678
+ function getOFTStoreDecoder() {
679
+ return getStructDecoder([
680
+ ['oftType', getU8Decoder()],
681
+ ['ld2sdRate', getU64Decoder()],
682
+ ['tokenMint', getAddressDecoder()],
683
+ ['tokenEscrow', getAddressDecoder()],
684
+ ['endpointProgram', getAddressDecoder()],
685
+ ['bump', getU8Decoder()],
686
+ ['tvlLd', getU64Decoder()],
687
+ ['admin', getAddressDecoder()],
688
+ ['defaultFeeBps', getU16Decoder()],
689
+ ['paused', getBooleanDecoder()],
690
+ ]);
691
+ }
692
+ function getOFTStoreCodec() {
693
+ return combineCodec(getOFTStoreEncoder(), getOFTStoreDecoder());
694
+ }
695
+
696
+ function getOracleUpdateEventEncoder() {
697
+ return getStructEncoder([
698
+ ['authority', getAddressEncoder()],
699
+ ['controller', getAddressEncoder()],
700
+ ['oracle', getAddressEncoder()],
701
+ ['oldState', getOptionEncoder(getOracleEncoder())],
702
+ ['newState', getOptionEncoder(getOracleEncoder())],
703
+ ]);
704
+ }
705
+ function getOracleUpdateEventDecoder() {
706
+ return getStructDecoder([
707
+ ['authority', getAddressDecoder()],
708
+ ['controller', getAddressDecoder()],
709
+ ['oracle', getAddressDecoder()],
710
+ ['oldState', getOptionDecoder(getOracleDecoder())],
711
+ ['newState', getOptionDecoder(getOracleDecoder())],
712
+ ]);
713
+ }
714
+ function getOracleUpdateEventCodec() {
715
+ return combineCodec(getOracleUpdateEventEncoder(), getOracleUpdateEventDecoder());
716
+ }
717
+
718
+ function getPeerConfigEncoder() {
719
+ return getStructEncoder([
720
+ ['peerAddress', fixEncoderSize(getBytesEncoder(), 32)],
721
+ ]);
722
+ }
723
+ function getPeerConfigDecoder() {
724
+ return getStructDecoder([
725
+ ['peerAddress', fixDecoderSize(getBytesDecoder(), 32)],
726
+ ]);
727
+ }
728
+ function getPeerConfigCodec() {
729
+ return combineCodec(getPeerConfigEncoder(), getPeerConfigDecoder());
730
+ }
731
+
732
+ var PermissionStatus;
733
+ (function (PermissionStatus) {
734
+ PermissionStatus[PermissionStatus["Suspended"] = 0] = "Suspended";
735
+ PermissionStatus[PermissionStatus["Active"] = 1] = "Active";
736
+ })(PermissionStatus || (PermissionStatus = {}));
737
+ function getPermissionStatusEncoder() {
738
+ return getEnumEncoder(PermissionStatus);
739
+ }
740
+ function getPermissionStatusDecoder() {
741
+ return getEnumDecoder(PermissionStatus);
742
+ }
743
+ function getPermissionStatusCodec() {
744
+ return combineCodec(getPermissionStatusEncoder(), getPermissionStatusDecoder());
745
+ }
746
+
747
+ function getPermissionUpdateEventEncoder() {
748
+ return getStructEncoder([
749
+ ['authority', getAddressEncoder()],
750
+ ['controller', getAddressEncoder()],
751
+ ['permission', getAddressEncoder()],
752
+ ['oldState', getOptionEncoder(getPermissionEncoder())],
753
+ ['newState', getOptionEncoder(getPermissionEncoder())],
754
+ ]);
755
+ }
756
+ function getPermissionUpdateEventDecoder() {
757
+ return getStructDecoder([
758
+ ['authority', getAddressDecoder()],
759
+ ['controller', getAddressDecoder()],
760
+ ['permission', getAddressDecoder()],
761
+ ['oldState', getOptionDecoder(getPermissionDecoder())],
762
+ ['newState', getOptionDecoder(getPermissionDecoder())],
763
+ ]);
764
+ }
765
+ function getPermissionUpdateEventCodec() {
766
+ return combineCodec(getPermissionUpdateEventEncoder(), getPermissionUpdateEventDecoder());
767
+ }
768
+
769
+ function getPullArgsEncoder() {
770
+ return getDiscriminatedUnionEncoder([
771
+ ['SplTokenExternal', getUnitEncoder()],
772
+ [
773
+ 'SplTokenSwap',
774
+ getStructEncoder([
775
+ ['amountA', getU64Encoder()],
776
+ ['amountB', getU64Encoder()],
777
+ ['maximumPoolTokenAmountA', getU64Encoder()],
778
+ ['maximumPoolTokenAmountB', getU64Encoder()],
779
+ ]),
780
+ ],
781
+ ['CctpBridge', getUnitEncoder()],
782
+ ['LzBridge', getUnitEncoder()],
783
+ ]);
784
+ }
785
+ function getPullArgsDecoder() {
786
+ return getDiscriminatedUnionDecoder([
787
+ ['SplTokenExternal', getUnitDecoder()],
788
+ [
789
+ 'SplTokenSwap',
790
+ getStructDecoder([
791
+ ['amountA', getU64Decoder()],
792
+ ['amountB', getU64Decoder()],
793
+ ['maximumPoolTokenAmountA', getU64Decoder()],
794
+ ['maximumPoolTokenAmountB', getU64Decoder()],
795
+ ]),
796
+ ],
797
+ ['CctpBridge', getUnitDecoder()],
798
+ ['LzBridge', getUnitDecoder()],
799
+ ]);
800
+ }
801
+ function getPullArgsCodec() {
802
+ return combineCodec(getPullArgsEncoder(), getPullArgsDecoder());
803
+ }
804
+ function pullArgs(kind, data) {
805
+ return Array.isArray(data)
806
+ ? { __kind: kind, fields: data }
807
+ : { __kind: kind, ...(data ?? {}) };
808
+ }
809
+ function isPullArgs(kind, value) {
810
+ return value.__kind === kind;
811
+ }
812
+
813
+ function getPushArgsEncoder() {
814
+ return getDiscriminatedUnionEncoder([
815
+ ['SplTokenExternal', getStructEncoder([['amount', getU64Encoder()]])],
816
+ [
817
+ 'SplTokenSwap',
818
+ getStructEncoder([
819
+ ['amountA', getU64Encoder()],
820
+ ['amountB', getU64Encoder()],
821
+ ['minimumPoolTokenAmountA', getU64Encoder()],
822
+ ['minimumPoolTokenAmountB', getU64Encoder()],
823
+ ]),
824
+ ],
825
+ ['CctpBridge', getStructEncoder([['amount', getU64Encoder()]])],
826
+ ['LzBridge', getStructEncoder([['amount', getU64Encoder()]])],
827
+ ]);
828
+ }
829
+ function getPushArgsDecoder() {
830
+ return getDiscriminatedUnionDecoder([
831
+ ['SplTokenExternal', getStructDecoder([['amount', getU64Decoder()]])],
832
+ [
833
+ 'SplTokenSwap',
834
+ getStructDecoder([
835
+ ['amountA', getU64Decoder()],
836
+ ['amountB', getU64Decoder()],
837
+ ['minimumPoolTokenAmountA', getU64Decoder()],
838
+ ['minimumPoolTokenAmountB', getU64Decoder()],
839
+ ]),
840
+ ],
841
+ ['CctpBridge', getStructDecoder([['amount', getU64Decoder()]])],
842
+ ['LzBridge', getStructDecoder([['amount', getU64Decoder()]])],
843
+ ]);
844
+ }
845
+ function getPushArgsCodec() {
846
+ return combineCodec(getPushArgsEncoder(), getPushArgsDecoder());
847
+ }
848
+ function pushArgs(kind, data) {
849
+ return Array.isArray(data)
850
+ ? { __kind: kind, fields: data }
851
+ : { __kind: kind, ...(data ?? {}) };
852
+ }
853
+ function isPushArgs(kind, value) {
854
+ return value.__kind === kind;
855
+ }
856
+
857
+ function getRemoteTokenMessengerEncoder() {
858
+ return getStructEncoder([
859
+ ['domain', getU32Encoder()],
860
+ ['tokenMessenger', getAddressEncoder()],
861
+ ]);
862
+ }
863
+ function getRemoteTokenMessengerDecoder() {
864
+ return getStructDecoder([
865
+ ['domain', getU32Decoder()],
866
+ ['tokenMessenger', getAddressDecoder()],
867
+ ]);
868
+ }
869
+ function getRemoteTokenMessengerCodec() {
870
+ return combineCodec(getRemoteTokenMessengerEncoder(), getRemoteTokenMessengerDecoder());
871
+ }
872
+
873
+ var ReserveStatus;
874
+ (function (ReserveStatus) {
875
+ ReserveStatus[ReserveStatus["Suspended"] = 0] = "Suspended";
876
+ ReserveStatus[ReserveStatus["Active"] = 1] = "Active";
877
+ })(ReserveStatus || (ReserveStatus = {}));
878
+ function getReserveStatusEncoder() {
879
+ return getEnumEncoder(ReserveStatus);
880
+ }
881
+ function getReserveStatusDecoder() {
882
+ return getEnumDecoder(ReserveStatus);
883
+ }
884
+ function getReserveStatusCodec() {
885
+ return combineCodec(getReserveStatusEncoder(), getReserveStatusDecoder());
886
+ }
887
+
888
+ function getReserveUpdateEventEncoder() {
889
+ return getStructEncoder([
890
+ ['authority', getAddressEncoder()],
891
+ ['controller', getAddressEncoder()],
892
+ ['reserve', getAddressEncoder()],
893
+ ['oldState', getOptionEncoder(getReserveEncoder())],
894
+ ['newState', getOptionEncoder(getReserveEncoder())],
895
+ ]);
896
+ }
897
+ function getReserveUpdateEventDecoder() {
898
+ return getStructDecoder([
899
+ ['authority', getAddressDecoder()],
900
+ ['controller', getAddressDecoder()],
901
+ ['reserve', getAddressDecoder()],
902
+ ['oldState', getOptionDecoder(getReserveDecoder())],
903
+ ['newState', getOptionDecoder(getReserveDecoder())],
904
+ ]);
905
+ }
906
+ function getReserveUpdateEventCodec() {
907
+ return combineCodec(getReserveUpdateEventEncoder(), getReserveUpdateEventDecoder());
908
+ }
909
+
910
+ function getSplTokenExternalConfigEncoder() {
911
+ return getStructEncoder([
912
+ ['program', getAddressEncoder()],
913
+ ['mint', getAddressEncoder()],
914
+ ['recipient', getAddressEncoder()],
915
+ ['tokenAccount', getAddressEncoder()],
916
+ ['padding', fixEncoderSize(getBytesEncoder(), 96)],
917
+ ]);
918
+ }
919
+ function getSplTokenExternalConfigDecoder() {
920
+ return getStructDecoder([
921
+ ['program', getAddressDecoder()],
922
+ ['mint', getAddressDecoder()],
923
+ ['recipient', getAddressDecoder()],
924
+ ['tokenAccount', getAddressDecoder()],
925
+ ['padding', fixDecoderSize(getBytesDecoder(), 96)],
926
+ ]);
927
+ }
928
+ function getSplTokenExternalConfigCodec() {
929
+ return combineCodec(getSplTokenExternalConfigEncoder(), getSplTokenExternalConfigDecoder());
930
+ }
931
+
932
+ function getSplTokenExternalStateEncoder() {
933
+ return getStructEncoder([['padding', fixEncoderSize(getBytesEncoder(), 48)]]);
934
+ }
935
+ function getSplTokenExternalStateDecoder() {
936
+ return getStructDecoder([['padding', fixDecoderSize(getBytesDecoder(), 48)]]);
937
+ }
938
+ function getSplTokenExternalStateCodec() {
939
+ return combineCodec(getSplTokenExternalStateEncoder(), getSplTokenExternalStateDecoder());
940
+ }
941
+
942
+ function getSplTokenSwapConfigEncoder() {
943
+ return getStructEncoder([
944
+ ['program', getAddressEncoder()],
945
+ ['swap', getAddressEncoder()],
946
+ ['mintA', getAddressEncoder()],
947
+ ['mintB', getAddressEncoder()],
948
+ ['lpMint', getAddressEncoder()],
949
+ ['lpTokenAccount', getAddressEncoder()],
950
+ ['padding', fixEncoderSize(getBytesEncoder(), 32)],
951
+ ]);
952
+ }
953
+ function getSplTokenSwapConfigDecoder() {
954
+ return getStructDecoder([
955
+ ['program', getAddressDecoder()],
956
+ ['swap', getAddressDecoder()],
957
+ ['mintA', getAddressDecoder()],
958
+ ['mintB', getAddressDecoder()],
959
+ ['lpMint', getAddressDecoder()],
960
+ ['lpTokenAccount', getAddressDecoder()],
961
+ ['padding', fixDecoderSize(getBytesDecoder(), 32)],
962
+ ]);
963
+ }
964
+ function getSplTokenSwapConfigCodec() {
965
+ return combineCodec(getSplTokenSwapConfigEncoder(), getSplTokenSwapConfigDecoder());
966
+ }
967
+
968
+ function getSplTokenSwapStateEncoder() {
969
+ return getStructEncoder([
970
+ ['lastBalanceA', getU64Encoder()],
971
+ ['lastBalanceB', getU64Encoder()],
972
+ ['lastBalanceLp', getU64Encoder()],
973
+ ['padding', fixEncoderSize(getBytesEncoder(), 24)],
974
+ ]);
975
+ }
976
+ function getSplTokenSwapStateDecoder() {
977
+ return getStructDecoder([
978
+ ['lastBalanceA', getU64Decoder()],
979
+ ['lastBalanceB', getU64Decoder()],
980
+ ['lastBalanceLp', getU64Decoder()],
981
+ ['padding', fixDecoderSize(getBytesDecoder(), 24)],
982
+ ]);
983
+ }
984
+ function getSplTokenSwapStateCodec() {
985
+ return combineCodec(getSplTokenSwapStateEncoder(), getSplTokenSwapStateDecoder());
986
+ }
987
+
988
+ function getSvmAlmControllerEventEncoder() {
989
+ return getDiscriminatedUnionEncoder([
990
+ [
991
+ 'ControllerUpdate',
992
+ getStructEncoder([
993
+ ['fields', getTupleEncoder([getControllerUpdateEventEncoder()])],
994
+ ]),
995
+ ],
996
+ [
997
+ 'PermissionUpdate',
998
+ getStructEncoder([
999
+ ['fields', getTupleEncoder([getPermissionUpdateEventEncoder()])],
1000
+ ]),
1001
+ ],
1002
+ [
1003
+ 'ReserveUpdate',
1004
+ getStructEncoder([
1005
+ ['fields', getTupleEncoder([getReserveUpdateEventEncoder()])],
1006
+ ]),
1007
+ ],
1008
+ [
1009
+ 'IntegrationUpdate',
1010
+ getStructEncoder([
1011
+ ['fields', getTupleEncoder([getIntegrationUpdateEventEncoder()])],
1012
+ ]),
1013
+ ],
1014
+ [
1015
+ 'AccountingEvent',
1016
+ getStructEncoder([
1017
+ ['fields', getTupleEncoder([getAccountingEventEncoder()])],
1018
+ ]),
1019
+ ],
1020
+ [
1021
+ 'OracleUpdate',
1022
+ getStructEncoder([
1023
+ ['fields', getTupleEncoder([getOracleUpdateEventEncoder()])],
1024
+ ]),
1025
+ ],
1026
+ ]);
1027
+ }
1028
+ function getSvmAlmControllerEventDecoder() {
1029
+ return getDiscriminatedUnionDecoder([
1030
+ [
1031
+ 'ControllerUpdate',
1032
+ getStructDecoder([
1033
+ ['fields', getTupleDecoder([getControllerUpdateEventDecoder()])],
1034
+ ]),
1035
+ ],
1036
+ [
1037
+ 'PermissionUpdate',
1038
+ getStructDecoder([
1039
+ ['fields', getTupleDecoder([getPermissionUpdateEventDecoder()])],
1040
+ ]),
1041
+ ],
1042
+ [
1043
+ 'ReserveUpdate',
1044
+ getStructDecoder([
1045
+ ['fields', getTupleDecoder([getReserveUpdateEventDecoder()])],
1046
+ ]),
1047
+ ],
1048
+ [
1049
+ 'IntegrationUpdate',
1050
+ getStructDecoder([
1051
+ ['fields', getTupleDecoder([getIntegrationUpdateEventDecoder()])],
1052
+ ]),
1053
+ ],
1054
+ [
1055
+ 'AccountingEvent',
1056
+ getStructDecoder([
1057
+ ['fields', getTupleDecoder([getAccountingEventDecoder()])],
1058
+ ]),
1059
+ ],
1060
+ [
1061
+ 'OracleUpdate',
1062
+ getStructDecoder([
1063
+ ['fields', getTupleDecoder([getOracleUpdateEventDecoder()])],
1064
+ ]),
1065
+ ],
1066
+ ]);
1067
+ }
1068
+ function getSvmAlmControllerEventCodec() {
1069
+ return combineCodec(getSvmAlmControllerEventEncoder(), getSvmAlmControllerEventDecoder());
1070
+ }
1071
+ function svmAlmControllerEvent(kind, data) {
1072
+ return Array.isArray(data)
1073
+ ? { __kind: kind, fields: data }
1074
+ : { __kind: kind, ...(data ?? {}) };
1075
+ }
1076
+ function isSvmAlmControllerEvent(kind, value) {
1077
+ return value.__kind === kind;
1078
+ }
1079
+
1080
+ function getSwapV1SubsetEncoder() {
1081
+ return getStructEncoder([
1082
+ ['isInitialized', getBooleanEncoder()],
1083
+ ['bumpSeed', getU8Encoder()],
1084
+ ['tokenProgramId', getAddressEncoder()],
1085
+ ['tokenA', getAddressEncoder()],
1086
+ ['tokenB', getAddressEncoder()],
1087
+ ['poolMint', getAddressEncoder()],
1088
+ ['tokenAMint', getAddressEncoder()],
1089
+ ['tokenBMint', getAddressEncoder()],
1090
+ ['poolFeeAccount', getAddressEncoder()],
1091
+ ]);
1092
+ }
1093
+ function getSwapV1SubsetDecoder() {
1094
+ return getStructDecoder([
1095
+ ['isInitialized', getBooleanDecoder()],
1096
+ ['bumpSeed', getU8Decoder()],
1097
+ ['tokenProgramId', getAddressDecoder()],
1098
+ ['tokenA', getAddressDecoder()],
1099
+ ['tokenB', getAddressDecoder()],
1100
+ ['poolMint', getAddressDecoder()],
1101
+ ['tokenAMint', getAddressDecoder()],
1102
+ ['tokenBMint', getAddressDecoder()],
1103
+ ['poolFeeAccount', getAddressDecoder()],
1104
+ ]);
1105
+ }
1106
+ function getSwapV1SubsetCodec() {
1107
+ return combineCodec(getSwapV1SubsetEncoder(), getSwapV1SubsetDecoder());
1108
+ }
1109
+
1110
+ function getWithdrawSingleTokenTypeExactAmountOutArgsEncoder() {
1111
+ return getStructEncoder([
1112
+ ['destinationTokenAmount', getU64Encoder()],
1113
+ ['maximumPoolTokenAmount', getU64Encoder()],
1114
+ ]);
1115
+ }
1116
+ function getWithdrawSingleTokenTypeExactAmountOutArgsDecoder() {
1117
+ return getStructDecoder([
1118
+ ['destinationTokenAmount', getU64Decoder()],
1119
+ ['maximumPoolTokenAmount', getU64Decoder()],
1120
+ ]);
1121
+ }
1122
+ function getWithdrawSingleTokenTypeExactAmountOutArgsCodec() {
1123
+ return combineCodec(getWithdrawSingleTokenTypeExactAmountOutArgsEncoder(), getWithdrawSingleTokenTypeExactAmountOutArgsDecoder());
1124
+ }
1125
+
1126
+ function getControllerEncoder() {
1127
+ return getStructEncoder([
1128
+ ['id', getU16Encoder()],
1129
+ ['bump', getU8Encoder()],
1130
+ ['status', getControllerStatusEncoder()],
1131
+ ['authority', getAddressEncoder()],
1132
+ ['authorityBump', getU8Encoder()],
1133
+ ['padding', fixEncoderSize(getBytesEncoder(), 128)],
1134
+ ]);
1135
+ }
1136
+ function getControllerDecoder() {
1137
+ return getStructDecoder([
1138
+ ['id', getU16Decoder()],
1139
+ ['bump', getU8Decoder()],
1140
+ ['status', getControllerStatusDecoder()],
1141
+ ['authority', getAddressDecoder()],
1142
+ ['authorityBump', getU8Decoder()],
1143
+ ['padding', fixDecoderSize(getBytesDecoder(), 128)],
1144
+ ]);
1145
+ }
1146
+ function getControllerCodec() {
1147
+ return combineCodec(getControllerEncoder(), getControllerDecoder());
1148
+ }
1149
+ function decodeController(encodedAccount) {
1150
+ return decodeAccount(encodedAccount, getControllerDecoder());
1151
+ }
1152
+ async function fetchController(rpc, address, config) {
1153
+ const maybeAccount = await fetchMaybeController(rpc, address, config);
1154
+ assertAccountExists(maybeAccount);
1155
+ return maybeAccount;
1156
+ }
1157
+ async function fetchMaybeController(rpc, address, config) {
1158
+ const maybeAccount = await fetchEncodedAccount(rpc, address, config);
1159
+ return decodeController(maybeAccount);
1160
+ }
1161
+ async function fetchAllController(rpc, addresses, config) {
1162
+ const maybeAccounts = await fetchAllMaybeController(rpc, addresses, config);
1163
+ assertAccountsExist(maybeAccounts);
1164
+ return maybeAccounts;
1165
+ }
1166
+ async function fetchAllMaybeController(rpc, addresses, config) {
1167
+ const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
1168
+ return maybeAccounts.map((maybeAccount) => decodeController(maybeAccount));
1169
+ }
1170
+ function getControllerSize() {
1171
+ return 165;
1172
+ }
1173
+
1174
+ function getIntegrationEncoder() {
1175
+ return getStructEncoder([
1176
+ ['controller', getAddressEncoder()],
1177
+ ['description', fixEncoderSize(getBytesEncoder(), 32)],
1178
+ ['hash', fixEncoderSize(getBytesEncoder(), 32)],
1179
+ ['status', getIntegrationStatusEncoder()],
1180
+ ['rateLimitSlope', getU64Encoder()],
1181
+ ['rateLimitMaxOutflow', getU64Encoder()],
1182
+ ['rateLimitOutflowAmountAvailable', getU64Encoder()],
1183
+ ['rateLimitRemainder', getU64Encoder()],
1184
+ ['lastRefreshTimestamp', getI64Encoder()],
1185
+ ['lastRefreshSlot', getU64Encoder()],
1186
+ ['config', getIntegrationConfigEncoder()],
1187
+ ['state', getIntegrationStateEncoder()],
1188
+ ['permitLiquidation', getBooleanEncoder()],
1189
+ ['padding', fixEncoderSize(getBytesEncoder(), 87)],
1190
+ ]);
1191
+ }
1192
+ function getIntegrationDecoder() {
1193
+ return getStructDecoder([
1194
+ ['controller', getAddressDecoder()],
1195
+ ['description', fixDecoderSize(getBytesDecoder(), 32)],
1196
+ ['hash', fixDecoderSize(getBytesDecoder(), 32)],
1197
+ ['status', getIntegrationStatusDecoder()],
1198
+ ['rateLimitSlope', getU64Decoder()],
1199
+ ['rateLimitMaxOutflow', getU64Decoder()],
1200
+ ['rateLimitOutflowAmountAvailable', getU64Decoder()],
1201
+ ['rateLimitRemainder', getU64Decoder()],
1202
+ ['lastRefreshTimestamp', getI64Decoder()],
1203
+ ['lastRefreshSlot', getU64Decoder()],
1204
+ ['config', getIntegrationConfigDecoder()],
1205
+ ['state', getIntegrationStateDecoder()],
1206
+ ['permitLiquidation', getBooleanDecoder()],
1207
+ ['padding', fixDecoderSize(getBytesDecoder(), 87)],
1208
+ ]);
1209
+ }
1210
+ function getIntegrationCodec() {
1211
+ return combineCodec(getIntegrationEncoder(), getIntegrationDecoder());
1212
+ }
1213
+ function decodeIntegration(encodedAccount) {
1214
+ return decodeAccount(encodedAccount, getIntegrationDecoder());
1215
+ }
1216
+ async function fetchIntegration(rpc, address, config) {
1217
+ const maybeAccount = await fetchMaybeIntegration(rpc, address, config);
1218
+ assertAccountExists(maybeAccount);
1219
+ return maybeAccount;
1220
+ }
1221
+ async function fetchMaybeIntegration(rpc, address, config) {
1222
+ const maybeAccount = await fetchEncodedAccount(rpc, address, config);
1223
+ return decodeIntegration(maybeAccount);
1224
+ }
1225
+ async function fetchAllIntegration(rpc, addresses, config) {
1226
+ const maybeAccounts = await fetchAllMaybeIntegration(rpc, addresses, config);
1227
+ assertAccountsExist(maybeAccounts);
1228
+ return maybeAccounts;
1229
+ }
1230
+ async function fetchAllMaybeIntegration(rpc, addresses, config) {
1231
+ const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
1232
+ return maybeAccounts.map((maybeAccount) => decodeIntegration(maybeAccount));
1233
+ }
1234
+ function getIntegrationSize() {
1235
+ return 507;
1236
+ }
1237
+
1238
+ function getOracleEncoder() {
1239
+ return getStructEncoder([
1240
+ ['version', getU8Encoder()],
1241
+ ['authority', getAddressEncoder()],
1242
+ ['nonce', getAddressEncoder()],
1243
+ ['value', getI128Encoder()],
1244
+ ['precision', getU32Encoder()],
1245
+ ['lastUpdateSlot', getU64Encoder()],
1246
+ ['controller', getAddressEncoder()],
1247
+ ['baseMint', getAddressEncoder()],
1248
+ ['quoteMint', getAddressEncoder()],
1249
+ ['reserved', fixEncoderSize(getBytesEncoder(), 64)],
1250
+ ['feeds', getArrayEncoder(getFeedEncoder(), { size: 1 })],
1251
+ ]);
1252
+ }
1253
+ function getOracleDecoder() {
1254
+ return getStructDecoder([
1255
+ ['version', getU8Decoder()],
1256
+ ['authority', getAddressDecoder()],
1257
+ ['nonce', getAddressDecoder()],
1258
+ ['value', getI128Decoder()],
1259
+ ['precision', getU32Decoder()],
1260
+ ['lastUpdateSlot', getU64Decoder()],
1261
+ ['controller', getAddressDecoder()],
1262
+ ['baseMint', getAddressDecoder()],
1263
+ ['quoteMint', getAddressDecoder()],
1264
+ ['reserved', fixDecoderSize(getBytesDecoder(), 64)],
1265
+ ['feeds', getArrayDecoder(getFeedDecoder(), { size: 1 })],
1266
+ ]);
1267
+ }
1268
+ function getOracleCodec() {
1269
+ return combineCodec(getOracleEncoder(), getOracleDecoder());
1270
+ }
1271
+ function decodeOracle(encodedAccount) {
1272
+ return decodeAccount(encodedAccount, getOracleDecoder());
1273
+ }
1274
+ async function fetchOracle(rpc, address, config) {
1275
+ const maybeAccount = await fetchMaybeOracle(rpc, address, config);
1276
+ assertAccountExists(maybeAccount);
1277
+ return maybeAccount;
1278
+ }
1279
+ async function fetchMaybeOracle(rpc, address, config) {
1280
+ const maybeAccount = await fetchEncodedAccount(rpc, address, config);
1281
+ return decodeOracle(maybeAccount);
1282
+ }
1283
+ async function fetchAllOracle(rpc, addresses, config) {
1284
+ const maybeAccounts = await fetchAllMaybeOracle(rpc, addresses, config);
1285
+ assertAccountsExist(maybeAccounts);
1286
+ return maybeAccounts;
1287
+ }
1288
+ async function fetchAllMaybeOracle(rpc, addresses, config) {
1289
+ const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
1290
+ return maybeAccounts.map((maybeAccount) => decodeOracle(maybeAccount));
1291
+ }
1292
+ function getOracleSize() {
1293
+ return 349;
1294
+ }
1295
+
1296
+ function getPermissionEncoder() {
1297
+ return getStructEncoder([
1298
+ ['controller', getAddressEncoder()],
1299
+ ['authority', getAddressEncoder()],
1300
+ ['status', getPermissionStatusEncoder()],
1301
+ ['canManagePermissions', getBooleanEncoder()],
1302
+ ['canInvokeExternalTransfer', getBooleanEncoder()],
1303
+ ['canExecuteSwap', getBooleanEncoder()],
1304
+ ['canReallocate', getBooleanEncoder()],
1305
+ ['canFreezeController', getBooleanEncoder()],
1306
+ ['canUnfreezeController', getBooleanEncoder()],
1307
+ ['canManageReservesAndIntegrations', getBooleanEncoder()],
1308
+ ['canSuspendPermissions', getBooleanEncoder()],
1309
+ ['canLiquidate', getBooleanEncoder()],
1310
+ ['padding', fixEncoderSize(getBytesEncoder(), 30)],
1311
+ ]);
1312
+ }
1313
+ function getPermissionDecoder() {
1314
+ return getStructDecoder([
1315
+ ['controller', getAddressDecoder()],
1316
+ ['authority', getAddressDecoder()],
1317
+ ['status', getPermissionStatusDecoder()],
1318
+ ['canManagePermissions', getBooleanDecoder()],
1319
+ ['canInvokeExternalTransfer', getBooleanDecoder()],
1320
+ ['canExecuteSwap', getBooleanDecoder()],
1321
+ ['canReallocate', getBooleanDecoder()],
1322
+ ['canFreezeController', getBooleanDecoder()],
1323
+ ['canUnfreezeController', getBooleanDecoder()],
1324
+ ['canManageReservesAndIntegrations', getBooleanDecoder()],
1325
+ ['canSuspendPermissions', getBooleanDecoder()],
1326
+ ['canLiquidate', getBooleanDecoder()],
1327
+ ['padding', fixDecoderSize(getBytesDecoder(), 30)],
1328
+ ]);
1329
+ }
1330
+ function getPermissionCodec() {
1331
+ return combineCodec(getPermissionEncoder(), getPermissionDecoder());
1332
+ }
1333
+ function decodePermission(encodedAccount) {
1334
+ return decodeAccount(encodedAccount, getPermissionDecoder());
1335
+ }
1336
+ async function fetchPermission(rpc, address, config) {
1337
+ const maybeAccount = await fetchMaybePermission(rpc, address, config);
1338
+ assertAccountExists(maybeAccount);
1339
+ return maybeAccount;
1340
+ }
1341
+ async function fetchMaybePermission(rpc, address, config) {
1342
+ const maybeAccount = await fetchEncodedAccount(rpc, address, config);
1343
+ return decodePermission(maybeAccount);
1344
+ }
1345
+ async function fetchAllPermission(rpc, addresses, config) {
1346
+ const maybeAccounts = await fetchAllMaybePermission(rpc, addresses, config);
1347
+ assertAccountsExist(maybeAccounts);
1348
+ return maybeAccounts;
1349
+ }
1350
+ async function fetchAllMaybePermission(rpc, addresses, config) {
1351
+ const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
1352
+ return maybeAccounts.map((maybeAccount) => decodePermission(maybeAccount));
1353
+ }
1354
+ function getPermissionSize() {
1355
+ return 104;
1356
+ }
1357
+
1358
+ function getReserveEncoder() {
1359
+ return getStructEncoder([
1360
+ ['controller', getAddressEncoder()],
1361
+ ['mint', getAddressEncoder()],
1362
+ ['vault', getAddressEncoder()],
1363
+ ['status', getReserveStatusEncoder()],
1364
+ ['rateLimitSlope', getU64Encoder()],
1365
+ ['rateLimitMaxOutflow', getU64Encoder()],
1366
+ ['rateLimitOutflowAmountAvailable', getU64Encoder()],
1367
+ ['rateLimitRemainder', getU64Encoder()],
1368
+ ['lastBalance', getU64Encoder()],
1369
+ ['lastRefreshTimestamp', getI64Encoder()],
1370
+ ['lastRefreshSlot', getU64Encoder()],
1371
+ ['padding', fixEncoderSize(getBytesEncoder(), 120)],
1372
+ ]);
1373
+ }
1374
+ function getReserveDecoder() {
1375
+ return getStructDecoder([
1376
+ ['controller', getAddressDecoder()],
1377
+ ['mint', getAddressDecoder()],
1378
+ ['vault', getAddressDecoder()],
1379
+ ['status', getReserveStatusDecoder()],
1380
+ ['rateLimitSlope', getU64Decoder()],
1381
+ ['rateLimitMaxOutflow', getU64Decoder()],
1382
+ ['rateLimitOutflowAmountAvailable', getU64Decoder()],
1383
+ ['rateLimitRemainder', getU64Decoder()],
1384
+ ['lastBalance', getU64Decoder()],
1385
+ ['lastRefreshTimestamp', getI64Decoder()],
1386
+ ['lastRefreshSlot', getU64Decoder()],
1387
+ ['padding', fixDecoderSize(getBytesDecoder(), 120)],
1388
+ ]);
1389
+ }
1390
+ function getReserveCodec() {
1391
+ return combineCodec(getReserveEncoder(), getReserveDecoder());
1392
+ }
1393
+ function decodeReserve(encodedAccount) {
1394
+ return decodeAccount(encodedAccount, getReserveDecoder());
1395
+ }
1396
+ async function fetchReserve(rpc, address, config) {
1397
+ const maybeAccount = await fetchMaybeReserve(rpc, address, config);
1398
+ assertAccountExists(maybeAccount);
1399
+ return maybeAccount;
1400
+ }
1401
+ async function fetchMaybeReserve(rpc, address, config) {
1402
+ const maybeAccount = await fetchEncodedAccount(rpc, address, config);
1403
+ return decodeReserve(maybeAccount);
1404
+ }
1405
+ async function fetchAllReserve(rpc, addresses, config) {
1406
+ const maybeAccounts = await fetchAllMaybeReserve(rpc, addresses, config);
1407
+ assertAccountsExist(maybeAccounts);
1408
+ return maybeAccounts;
1409
+ }
1410
+ async function fetchAllMaybeReserve(rpc, addresses, config) {
1411
+ const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
1412
+ return maybeAccounts.map((maybeAccount) => decodeReserve(maybeAccount));
1413
+ }
1414
+ function getReserveSize() {
1415
+ return 273;
1416
+ }
1417
+
1418
+ const SVM_ALM_CONTROLLER_PROGRAM_ADDRESS = 'H3BpbuheXwBnfxjb2L66mxZ9nFhRmUentYwQDspd6yJ9';
1419
+ var SvmAlmControllerAccount;
1420
+ (function (SvmAlmControllerAccount) {
1421
+ SvmAlmControllerAccount[SvmAlmControllerAccount["Controller"] = 0] = "Controller";
1422
+ SvmAlmControllerAccount[SvmAlmControllerAccount["Integration"] = 1] = "Integration";
1423
+ SvmAlmControllerAccount[SvmAlmControllerAccount["Oracle"] = 2] = "Oracle";
1424
+ SvmAlmControllerAccount[SvmAlmControllerAccount["Permission"] = 3] = "Permission";
1425
+ SvmAlmControllerAccount[SvmAlmControllerAccount["Reserve"] = 4] = "Reserve";
1426
+ })(SvmAlmControllerAccount || (SvmAlmControllerAccount = {}));
1427
+ var SvmAlmControllerInstruction;
1428
+ (function (SvmAlmControllerInstruction) {
1429
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["EmitEvent"] = 0] = "EmitEvent";
1430
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["InitializeController"] = 1] = "InitializeController";
1431
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["ManageController"] = 2] = "ManageController";
1432
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["ManagePermission"] = 3] = "ManagePermission";
1433
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["InitializeReserve"] = 4] = "InitializeReserve";
1434
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["ManageReserve"] = 5] = "ManageReserve";
1435
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["InitializeIntegration"] = 6] = "InitializeIntegration";
1436
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["ManageIntegration"] = 7] = "ManageIntegration";
1437
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["SyncReserve"] = 8] = "SyncReserve";
1438
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["Sync"] = 9] = "Sync";
1439
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["Push"] = 10] = "Push";
1440
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["Pull"] = 11] = "Pull";
1441
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["InitializeOracle"] = 12] = "InitializeOracle";
1442
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["UpdateOracle"] = 13] = "UpdateOracle";
1443
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["RefreshOracle"] = 14] = "RefreshOracle";
1444
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["AtomicSwapBorrow"] = 15] = "AtomicSwapBorrow";
1445
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["AtomicSwapRepay"] = 16] = "AtomicSwapRepay";
1446
+ SvmAlmControllerInstruction[SvmAlmControllerInstruction["ResetLzPushInFlight"] = 17] = "ResetLzPushInFlight";
1447
+ })(SvmAlmControllerInstruction || (SvmAlmControllerInstruction = {}));
1448
+ function identifySvmAlmControllerInstruction(instruction) {
1449
+ const data = 'data' in instruction ? instruction.data : instruction;
1450
+ if (containsBytes(data, getU8Encoder().encode(0), 0)) {
1451
+ return SvmAlmControllerInstruction.EmitEvent;
1452
+ }
1453
+ if (containsBytes(data, getU8Encoder().encode(1), 0)) {
1454
+ return SvmAlmControllerInstruction.InitializeController;
1455
+ }
1456
+ if (containsBytes(data, getU8Encoder().encode(2), 0)) {
1457
+ return SvmAlmControllerInstruction.ManageController;
1458
+ }
1459
+ if (containsBytes(data, getU8Encoder().encode(3), 0)) {
1460
+ return SvmAlmControllerInstruction.ManagePermission;
1461
+ }
1462
+ if (containsBytes(data, getU8Encoder().encode(4), 0)) {
1463
+ return SvmAlmControllerInstruction.InitializeReserve;
1464
+ }
1465
+ if (containsBytes(data, getU8Encoder().encode(5), 0)) {
1466
+ return SvmAlmControllerInstruction.ManageReserve;
1467
+ }
1468
+ if (containsBytes(data, getU8Encoder().encode(6), 0)) {
1469
+ return SvmAlmControllerInstruction.InitializeIntegration;
1470
+ }
1471
+ if (containsBytes(data, getU8Encoder().encode(7), 0)) {
1472
+ return SvmAlmControllerInstruction.ManageIntegration;
1473
+ }
1474
+ if (containsBytes(data, getU8Encoder().encode(8), 0)) {
1475
+ return SvmAlmControllerInstruction.SyncReserve;
1476
+ }
1477
+ if (containsBytes(data, getU8Encoder().encode(9), 0)) {
1478
+ return SvmAlmControllerInstruction.Sync;
1479
+ }
1480
+ if (containsBytes(data, getU8Encoder().encode(10), 0)) {
1481
+ return SvmAlmControllerInstruction.Push;
1482
+ }
1483
+ if (containsBytes(data, getU8Encoder().encode(11), 0)) {
1484
+ return SvmAlmControllerInstruction.Pull;
1485
+ }
1486
+ if (containsBytes(data, getU8Encoder().encode(12), 0)) {
1487
+ return SvmAlmControllerInstruction.InitializeOracle;
1488
+ }
1489
+ if (containsBytes(data, getU8Encoder().encode(13), 0)) {
1490
+ return SvmAlmControllerInstruction.UpdateOracle;
1491
+ }
1492
+ if (containsBytes(data, getU8Encoder().encode(14), 0)) {
1493
+ return SvmAlmControllerInstruction.RefreshOracle;
1494
+ }
1495
+ if (containsBytes(data, getU8Encoder().encode(15), 0)) {
1496
+ return SvmAlmControllerInstruction.AtomicSwapBorrow;
1497
+ }
1498
+ if (containsBytes(data, getU8Encoder().encode(16), 0)) {
1499
+ return SvmAlmControllerInstruction.AtomicSwapRepay;
1500
+ }
1501
+ if (containsBytes(data, getU8Encoder().encode(17), 0)) {
1502
+ return SvmAlmControllerInstruction.ResetLzPushInFlight;
1503
+ }
1504
+ throw new Error('The provided instruction could not be identified as a svmAlmController instruction.');
1505
+ }
1506
+
1507
+ function expectAddress(value) {
1508
+ if (!value) {
1509
+ throw new Error('Expected a Address.');
1510
+ }
1511
+ if (typeof value === 'object' && 'address' in value) {
1512
+ return value.address;
1513
+ }
1514
+ if (Array.isArray(value)) {
1515
+ return value[0];
1516
+ }
1517
+ return value;
1518
+ }
1519
+ function getAccountMetaFactory(programAddress, optionalAccountStrategy) {
1520
+ return (account) => {
1521
+ if (!account.value) {
1522
+ return Object.freeze({
1523
+ address: programAddress,
1524
+ role: AccountRole.READONLY,
1525
+ });
1526
+ }
1527
+ const writableRole = account.isWritable
1528
+ ? AccountRole.WRITABLE
1529
+ : AccountRole.READONLY;
1530
+ return Object.freeze({
1531
+ address: expectAddress(account.value),
1532
+ role: isTransactionSigner(account.value)
1533
+ ? upgradeRoleToSigner(writableRole)
1534
+ : writableRole,
1535
+ ...(isTransactionSigner(account.value) ? { signer: account.value } : {}),
1536
+ });
1537
+ };
1538
+ }
1539
+ function isTransactionSigner(value) {
1540
+ return (!!value &&
1541
+ typeof value === 'object' &&
1542
+ 'address' in value &&
1543
+ isTransactionSigner$1(value));
1544
+ }
1545
+
1546
+ const ATOMIC_SWAP_BORROW_DISCRIMINATOR = 15;
1547
+ function getAtomicSwapBorrowDiscriminatorBytes() {
1548
+ return getU8Encoder().encode(ATOMIC_SWAP_BORROW_DISCRIMINATOR);
1549
+ }
1550
+ function getAtomicSwapBorrowInstructionDataEncoder() {
1551
+ return transformEncoder(getStructEncoder([
1552
+ ['discriminator', getU8Encoder()],
1553
+ ['amount', getU64Encoder()],
1554
+ ]), (value) => ({ ...value, discriminator: ATOMIC_SWAP_BORROW_DISCRIMINATOR }));
1555
+ }
1556
+ function getAtomicSwapBorrowInstructionDataDecoder() {
1557
+ return getStructDecoder([
1558
+ ['discriminator', getU8Decoder()],
1559
+ ['amount', getU64Decoder()],
1560
+ ]);
1561
+ }
1562
+ function getAtomicSwapBorrowInstructionDataCodec() {
1563
+ return combineCodec(getAtomicSwapBorrowInstructionDataEncoder(), getAtomicSwapBorrowInstructionDataDecoder());
1564
+ }
1565
+ function getAtomicSwapBorrowInstruction(input, config) {
1566
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
1567
+ const originalAccounts = {
1568
+ controller: { value: input.controller ?? null, isWritable: false },
1569
+ controllerAuthority: {
1570
+ value: input.controllerAuthority ?? null,
1571
+ isWritable: false,
1572
+ },
1573
+ authority: { value: input.authority ?? null, isWritable: false },
1574
+ permission: { value: input.permission ?? null, isWritable: false },
1575
+ integration: { value: input.integration ?? null, isWritable: true },
1576
+ reserveA: { value: input.reserveA ?? null, isWritable: true },
1577
+ vaultA: { value: input.vaultA ?? null, isWritable: true },
1578
+ mintA: { value: input.mintA ?? null, isWritable: false },
1579
+ reserveB: { value: input.reserveB ?? null, isWritable: true },
1580
+ vaultB: { value: input.vaultB ?? null, isWritable: false },
1581
+ recipientTokenAccountA: {
1582
+ value: input.recipientTokenAccountA ?? null,
1583
+ isWritable: true,
1584
+ },
1585
+ recipientTokenAccountB: {
1586
+ value: input.recipientTokenAccountB ?? null,
1587
+ isWritable: true,
1588
+ },
1589
+ tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false },
1590
+ sysvarInstruction: {
1591
+ value: input.sysvarInstruction ?? null,
1592
+ isWritable: false,
1593
+ },
1594
+ programId: { value: input.programId ?? null, isWritable: false },
1595
+ };
1596
+ const accounts = originalAccounts;
1597
+ const args = { ...input };
1598
+ if (!accounts.sysvarInstruction.value) {
1599
+ accounts.sysvarInstruction.value =
1600
+ 'Sysvar1nstructions1111111111111111111111111';
1601
+ }
1602
+ if (!accounts.programId.value) {
1603
+ accounts.programId.value = programAddress;
1604
+ accounts.programId.isWritable = false;
1605
+ }
1606
+ const getAccountMeta = getAccountMetaFactory(programAddress);
1607
+ return Object.freeze({
1608
+ accounts: [
1609
+ getAccountMeta(accounts.controller),
1610
+ getAccountMeta(accounts.controllerAuthority),
1611
+ getAccountMeta(accounts.authority),
1612
+ getAccountMeta(accounts.permission),
1613
+ getAccountMeta(accounts.integration),
1614
+ getAccountMeta(accounts.reserveA),
1615
+ getAccountMeta(accounts.vaultA),
1616
+ getAccountMeta(accounts.mintA),
1617
+ getAccountMeta(accounts.reserveB),
1618
+ getAccountMeta(accounts.vaultB),
1619
+ getAccountMeta(accounts.recipientTokenAccountA),
1620
+ getAccountMeta(accounts.recipientTokenAccountB),
1621
+ getAccountMeta(accounts.tokenProgramA),
1622
+ getAccountMeta(accounts.sysvarInstruction),
1623
+ getAccountMeta(accounts.programId),
1624
+ ],
1625
+ data: getAtomicSwapBorrowInstructionDataEncoder().encode(args),
1626
+ programAddress,
1627
+ });
1628
+ }
1629
+ function parseAtomicSwapBorrowInstruction(instruction) {
1630
+ if (instruction.accounts.length < 15) {
1631
+ throw new Error('Not enough accounts');
1632
+ }
1633
+ let accountIndex = 0;
1634
+ const getNextAccount = () => {
1635
+ const accountMeta = instruction.accounts[accountIndex];
1636
+ accountIndex += 1;
1637
+ return accountMeta;
1638
+ };
1639
+ return {
1640
+ programAddress: instruction.programAddress,
1641
+ accounts: {
1642
+ controller: getNextAccount(),
1643
+ controllerAuthority: getNextAccount(),
1644
+ authority: getNextAccount(),
1645
+ permission: getNextAccount(),
1646
+ integration: getNextAccount(),
1647
+ reserveA: getNextAccount(),
1648
+ vaultA: getNextAccount(),
1649
+ mintA: getNextAccount(),
1650
+ reserveB: getNextAccount(),
1651
+ vaultB: getNextAccount(),
1652
+ recipientTokenAccountA: getNextAccount(),
1653
+ recipientTokenAccountB: getNextAccount(),
1654
+ tokenProgramA: getNextAccount(),
1655
+ sysvarInstruction: getNextAccount(),
1656
+ programId: getNextAccount(),
1657
+ },
1658
+ data: getAtomicSwapBorrowInstructionDataDecoder().decode(instruction.data),
1659
+ };
1660
+ }
1661
+
1662
+ const ATOMIC_SWAP_REPAY_DISCRIMINATOR = 16;
1663
+ function getAtomicSwapRepayDiscriminatorBytes() {
1664
+ return getU8Encoder().encode(ATOMIC_SWAP_REPAY_DISCRIMINATOR);
1665
+ }
1666
+ function getAtomicSwapRepayInstructionDataEncoder() {
1667
+ return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({ ...value, discriminator: ATOMIC_SWAP_REPAY_DISCRIMINATOR }));
1668
+ }
1669
+ function getAtomicSwapRepayInstructionDataDecoder() {
1670
+ return getStructDecoder([['discriminator', getU8Decoder()]]);
1671
+ }
1672
+ function getAtomicSwapRepayInstructionDataCodec() {
1673
+ return combineCodec(getAtomicSwapRepayInstructionDataEncoder(), getAtomicSwapRepayInstructionDataDecoder());
1674
+ }
1675
+ function getAtomicSwapRepayInstruction(input, config) {
1676
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
1677
+ const originalAccounts = {
1678
+ payer: { value: input.payer ?? null, isWritable: false },
1679
+ controller: { value: input.controller ?? null, isWritable: false },
1680
+ controllerAuthority: {
1681
+ value: input.controllerAuthority ?? null,
1682
+ isWritable: false,
1683
+ },
1684
+ authority: { value: input.authority ?? null, isWritable: false },
1685
+ permission: { value: input.permission ?? null, isWritable: false },
1686
+ integration: { value: input.integration ?? null, isWritable: true },
1687
+ reserveA: { value: input.reserveA ?? null, isWritable: true },
1688
+ vaultA: { value: input.vaultA ?? null, isWritable: true },
1689
+ mintA: { value: input.mintA ?? null, isWritable: false },
1690
+ reserveB: { value: input.reserveB ?? null, isWritable: true },
1691
+ vaultB: { value: input.vaultB ?? null, isWritable: true },
1692
+ mintB: { value: input.mintB ?? null, isWritable: false },
1693
+ oracle: { value: input.oracle ?? null, isWritable: false },
1694
+ payerAccountA: { value: input.payerAccountA ?? null, isWritable: true },
1695
+ payerAccountB: { value: input.payerAccountB ?? null, isWritable: true },
1696
+ tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false },
1697
+ tokenProgramB: { value: input.tokenProgramB ?? null, isWritable: false },
1698
+ };
1699
+ const accounts = originalAccounts;
1700
+ const getAccountMeta = getAccountMetaFactory(programAddress);
1701
+ return Object.freeze({
1702
+ accounts: [
1703
+ getAccountMeta(accounts.payer),
1704
+ getAccountMeta(accounts.controller),
1705
+ getAccountMeta(accounts.controllerAuthority),
1706
+ getAccountMeta(accounts.authority),
1707
+ getAccountMeta(accounts.permission),
1708
+ getAccountMeta(accounts.integration),
1709
+ getAccountMeta(accounts.reserveA),
1710
+ getAccountMeta(accounts.vaultA),
1711
+ getAccountMeta(accounts.mintA),
1712
+ getAccountMeta(accounts.reserveB),
1713
+ getAccountMeta(accounts.vaultB),
1714
+ getAccountMeta(accounts.mintB),
1715
+ getAccountMeta(accounts.oracle),
1716
+ getAccountMeta(accounts.payerAccountA),
1717
+ getAccountMeta(accounts.payerAccountB),
1718
+ getAccountMeta(accounts.tokenProgramA),
1719
+ getAccountMeta(accounts.tokenProgramB),
1720
+ ],
1721
+ data: getAtomicSwapRepayInstructionDataEncoder().encode({}),
1722
+ programAddress,
1723
+ });
1724
+ }
1725
+ function parseAtomicSwapRepayInstruction(instruction) {
1726
+ if (instruction.accounts.length < 17) {
1727
+ throw new Error('Not enough accounts');
1728
+ }
1729
+ let accountIndex = 0;
1730
+ const getNextAccount = () => {
1731
+ const accountMeta = instruction.accounts[accountIndex];
1732
+ accountIndex += 1;
1733
+ return accountMeta;
1734
+ };
1735
+ return {
1736
+ programAddress: instruction.programAddress,
1737
+ accounts: {
1738
+ payer: getNextAccount(),
1739
+ controller: getNextAccount(),
1740
+ controllerAuthority: getNextAccount(),
1741
+ authority: getNextAccount(),
1742
+ permission: getNextAccount(),
1743
+ integration: getNextAccount(),
1744
+ reserveA: getNextAccount(),
1745
+ vaultA: getNextAccount(),
1746
+ mintA: getNextAccount(),
1747
+ reserveB: getNextAccount(),
1748
+ vaultB: getNextAccount(),
1749
+ mintB: getNextAccount(),
1750
+ oracle: getNextAccount(),
1751
+ payerAccountA: getNextAccount(),
1752
+ payerAccountB: getNextAccount(),
1753
+ tokenProgramA: getNextAccount(),
1754
+ tokenProgramB: getNextAccount(),
1755
+ },
1756
+ data: getAtomicSwapRepayInstructionDataDecoder().decode(instruction.data),
1757
+ };
1758
+ }
1759
+
1760
+ const EMIT_EVENT_DISCRIMINATOR = 0;
1761
+ function getEmitEventDiscriminatorBytes() {
1762
+ return getU8Encoder().encode(EMIT_EVENT_DISCRIMINATOR);
1763
+ }
1764
+ function getEmitEventInstructionDataEncoder() {
1765
+ return transformEncoder(getStructEncoder([
1766
+ ['discriminator', getU8Encoder()],
1767
+ ['controllerId', fixEncoderSize(getBytesEncoder(), 2)],
1768
+ ['data', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())],
1769
+ ]), (value) => ({ ...value, discriminator: EMIT_EVENT_DISCRIMINATOR }));
1770
+ }
1771
+ function getEmitEventInstructionDataDecoder() {
1772
+ return getStructDecoder([
1773
+ ['discriminator', getU8Decoder()],
1774
+ ['controllerId', fixDecoderSize(getBytesDecoder(), 2)],
1775
+ ['data', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())],
1776
+ ]);
1777
+ }
1778
+ function getEmitEventInstructionDataCodec() {
1779
+ return combineCodec(getEmitEventInstructionDataEncoder(), getEmitEventInstructionDataDecoder());
1780
+ }
1781
+ function getEmitEventInstruction(input, config) {
1782
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
1783
+ const originalAccounts = {
1784
+ authority: { value: input.authority ?? null, isWritable: false },
1785
+ };
1786
+ const accounts = originalAccounts;
1787
+ const args = { ...input };
1788
+ const getAccountMeta = getAccountMetaFactory(programAddress);
1789
+ return Object.freeze({
1790
+ accounts: [getAccountMeta(accounts.authority)],
1791
+ data: getEmitEventInstructionDataEncoder().encode(args),
1792
+ programAddress,
1793
+ });
1794
+ }
1795
+ function parseEmitEventInstruction(instruction) {
1796
+ if (instruction.accounts.length < 1) {
1797
+ throw new Error('Not enough accounts');
1798
+ }
1799
+ let accountIndex = 0;
1800
+ const getNextAccount = () => {
1801
+ const accountMeta = instruction.accounts[accountIndex];
1802
+ accountIndex += 1;
1803
+ return accountMeta;
1804
+ };
1805
+ return {
1806
+ programAddress: instruction.programAddress,
1807
+ accounts: { authority: getNextAccount() },
1808
+ data: getEmitEventInstructionDataDecoder().decode(instruction.data),
1809
+ };
1810
+ }
1811
+
1812
+ const INITIALIZE_CONTROLLER_DISCRIMINATOR = 1;
1813
+ function getInitializeControllerDiscriminatorBytes() {
1814
+ return getU8Encoder().encode(INITIALIZE_CONTROLLER_DISCRIMINATOR);
1815
+ }
1816
+ function getInitializeControllerInstructionDataEncoder() {
1817
+ return transformEncoder(getStructEncoder([
1818
+ ['discriminator', getU8Encoder()],
1819
+ ['id', getU16Encoder()],
1820
+ ['status', getControllerStatusEncoder()],
1821
+ ]), (value) => ({
1822
+ ...value,
1823
+ discriminator: INITIALIZE_CONTROLLER_DISCRIMINATOR,
1824
+ }));
1825
+ }
1826
+ function getInitializeControllerInstructionDataDecoder() {
1827
+ return getStructDecoder([
1828
+ ['discriminator', getU8Decoder()],
1829
+ ['id', getU16Decoder()],
1830
+ ['status', getControllerStatusDecoder()],
1831
+ ]);
1832
+ }
1833
+ function getInitializeControllerInstructionDataCodec() {
1834
+ return combineCodec(getInitializeControllerInstructionDataEncoder(), getInitializeControllerInstructionDataDecoder());
1835
+ }
1836
+ function getInitializeControllerInstruction(input, config) {
1837
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
1838
+ const originalAccounts = {
1839
+ payer: { value: input.payer ?? null, isWritable: true },
1840
+ authority: { value: input.authority ?? null, isWritable: false },
1841
+ controller: { value: input.controller ?? null, isWritable: true },
1842
+ controllerAuthority: {
1843
+ value: input.controllerAuthority ?? null,
1844
+ isWritable: false,
1845
+ },
1846
+ permission: { value: input.permission ?? null, isWritable: true },
1847
+ programId: { value: input.programId ?? null, isWritable: false },
1848
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
1849
+ };
1850
+ const accounts = originalAccounts;
1851
+ const args = { ...input };
1852
+ if (!accounts.programId.value) {
1853
+ accounts.programId.value = programAddress;
1854
+ accounts.programId.isWritable = false;
1855
+ }
1856
+ if (!accounts.systemProgram.value) {
1857
+ accounts.systemProgram.value =
1858
+ '11111111111111111111111111111111';
1859
+ }
1860
+ const getAccountMeta = getAccountMetaFactory(programAddress);
1861
+ return Object.freeze({
1862
+ accounts: [
1863
+ getAccountMeta(accounts.payer),
1864
+ getAccountMeta(accounts.authority),
1865
+ getAccountMeta(accounts.controller),
1866
+ getAccountMeta(accounts.controllerAuthority),
1867
+ getAccountMeta(accounts.permission),
1868
+ getAccountMeta(accounts.programId),
1869
+ getAccountMeta(accounts.systemProgram),
1870
+ ],
1871
+ data: getInitializeControllerInstructionDataEncoder().encode(args),
1872
+ programAddress,
1873
+ });
1874
+ }
1875
+ function parseInitializeControllerInstruction(instruction) {
1876
+ if (instruction.accounts.length < 7) {
1877
+ throw new Error('Not enough accounts');
1878
+ }
1879
+ let accountIndex = 0;
1880
+ const getNextAccount = () => {
1881
+ const accountMeta = instruction.accounts[accountIndex];
1882
+ accountIndex += 1;
1883
+ return accountMeta;
1884
+ };
1885
+ return {
1886
+ programAddress: instruction.programAddress,
1887
+ accounts: {
1888
+ payer: getNextAccount(),
1889
+ authority: getNextAccount(),
1890
+ controller: getNextAccount(),
1891
+ controllerAuthority: getNextAccount(),
1892
+ permission: getNextAccount(),
1893
+ programId: getNextAccount(),
1894
+ systemProgram: getNextAccount(),
1895
+ },
1896
+ data: getInitializeControllerInstructionDataDecoder().decode(instruction.data),
1897
+ };
1898
+ }
1899
+
1900
+ const INITIALIZE_INTEGRATION_DISCRIMINATOR = 6;
1901
+ function getInitializeIntegrationDiscriminatorBytes() {
1902
+ return getU8Encoder().encode(INITIALIZE_INTEGRATION_DISCRIMINATOR);
1903
+ }
1904
+ function getInitializeIntegrationInstructionDataEncoder() {
1905
+ return transformEncoder(getStructEncoder([
1906
+ ['discriminator', getU8Encoder()],
1907
+ ['integrationType', getIntegrationTypeEncoder()],
1908
+ ['status', getIntegrationStatusEncoder()],
1909
+ ['description', fixEncoderSize(getBytesEncoder(), 32)],
1910
+ ['rateLimitSlope', getU64Encoder()],
1911
+ ['rateLimitMaxOutflow', getU64Encoder()],
1912
+ ['permitLiquidation', getBooleanEncoder()],
1913
+ ['innerArgs', getInitializeArgsEncoder()],
1914
+ ]), (value) => ({
1915
+ ...value,
1916
+ discriminator: INITIALIZE_INTEGRATION_DISCRIMINATOR,
1917
+ }));
1918
+ }
1919
+ function getInitializeIntegrationInstructionDataDecoder() {
1920
+ return getStructDecoder([
1921
+ ['discriminator', getU8Decoder()],
1922
+ ['integrationType', getIntegrationTypeDecoder()],
1923
+ ['status', getIntegrationStatusDecoder()],
1924
+ ['description', fixDecoderSize(getBytesDecoder(), 32)],
1925
+ ['rateLimitSlope', getU64Decoder()],
1926
+ ['rateLimitMaxOutflow', getU64Decoder()],
1927
+ ['permitLiquidation', getBooleanDecoder()],
1928
+ ['innerArgs', getInitializeArgsDecoder()],
1929
+ ]);
1930
+ }
1931
+ function getInitializeIntegrationInstructionDataCodec() {
1932
+ return combineCodec(getInitializeIntegrationInstructionDataEncoder(), getInitializeIntegrationInstructionDataDecoder());
1933
+ }
1934
+ function getInitializeIntegrationInstruction(input, config) {
1935
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
1936
+ const originalAccounts = {
1937
+ payer: { value: input.payer ?? null, isWritable: true },
1938
+ controller: { value: input.controller ?? null, isWritable: false },
1939
+ controllerAuthority: {
1940
+ value: input.controllerAuthority ?? null,
1941
+ isWritable: false,
1942
+ },
1943
+ authority: { value: input.authority ?? null, isWritable: false },
1944
+ permission: { value: input.permission ?? null, isWritable: false },
1945
+ integration: { value: input.integration ?? null, isWritable: true },
1946
+ programId: { value: input.programId ?? null, isWritable: false },
1947
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
1948
+ };
1949
+ const accounts = originalAccounts;
1950
+ const args = { ...input };
1951
+ if (!accounts.programId.value) {
1952
+ accounts.programId.value = programAddress;
1953
+ accounts.programId.isWritable = false;
1954
+ }
1955
+ if (!accounts.systemProgram.value) {
1956
+ accounts.systemProgram.value =
1957
+ '11111111111111111111111111111111';
1958
+ }
1959
+ const getAccountMeta = getAccountMetaFactory(programAddress);
1960
+ return Object.freeze({
1961
+ accounts: [
1962
+ getAccountMeta(accounts.payer),
1963
+ getAccountMeta(accounts.controller),
1964
+ getAccountMeta(accounts.controllerAuthority),
1965
+ getAccountMeta(accounts.authority),
1966
+ getAccountMeta(accounts.permission),
1967
+ getAccountMeta(accounts.integration),
1968
+ getAccountMeta(accounts.programId),
1969
+ getAccountMeta(accounts.systemProgram),
1970
+ ],
1971
+ data: getInitializeIntegrationInstructionDataEncoder().encode(args),
1972
+ programAddress,
1973
+ });
1974
+ }
1975
+ function parseInitializeIntegrationInstruction(instruction) {
1976
+ if (instruction.accounts.length < 8) {
1977
+ throw new Error('Not enough accounts');
1978
+ }
1979
+ let accountIndex = 0;
1980
+ const getNextAccount = () => {
1981
+ const accountMeta = instruction.accounts[accountIndex];
1982
+ accountIndex += 1;
1983
+ return accountMeta;
1984
+ };
1985
+ return {
1986
+ programAddress: instruction.programAddress,
1987
+ accounts: {
1988
+ payer: getNextAccount(),
1989
+ controller: getNextAccount(),
1990
+ controllerAuthority: getNextAccount(),
1991
+ authority: getNextAccount(),
1992
+ permission: getNextAccount(),
1993
+ integration: getNextAccount(),
1994
+ programId: getNextAccount(),
1995
+ systemProgram: getNextAccount(),
1996
+ },
1997
+ data: getInitializeIntegrationInstructionDataDecoder().decode(instruction.data),
1998
+ };
1999
+ }
2000
+
2001
+ const INITIALIZE_ORACLE_DISCRIMINATOR = 12;
2002
+ function getInitializeOracleDiscriminatorBytes() {
2003
+ return getU8Encoder().encode(INITIALIZE_ORACLE_DISCRIMINATOR);
2004
+ }
2005
+ function getInitializeOracleInstructionDataEncoder() {
2006
+ return transformEncoder(getStructEncoder([
2007
+ ['discriminator', getU8Encoder()],
2008
+ ['oracleType', getU8Encoder()],
2009
+ ['nonce', getAddressEncoder()],
2010
+ ['baseMint', getAddressEncoder()],
2011
+ ['quoteMint', getAddressEncoder()],
2012
+ ]), (value) => ({ ...value, discriminator: INITIALIZE_ORACLE_DISCRIMINATOR }));
2013
+ }
2014
+ function getInitializeOracleInstructionDataDecoder() {
2015
+ return getStructDecoder([
2016
+ ['discriminator', getU8Decoder()],
2017
+ ['oracleType', getU8Decoder()],
2018
+ ['nonce', getAddressDecoder()],
2019
+ ['baseMint', getAddressDecoder()],
2020
+ ['quoteMint', getAddressDecoder()],
2021
+ ]);
2022
+ }
2023
+ function getInitializeOracleInstructionDataCodec() {
2024
+ return combineCodec(getInitializeOracleInstructionDataEncoder(), getInitializeOracleInstructionDataDecoder());
2025
+ }
2026
+ function getInitializeOracleInstruction(input, config) {
2027
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
2028
+ const originalAccounts = {
2029
+ payer: { value: input.payer ?? null, isWritable: true },
2030
+ controller: { value: input.controller ?? null, isWritable: false },
2031
+ controllerAuthority: {
2032
+ value: input.controllerAuthority ?? null,
2033
+ isWritable: false,
2034
+ },
2035
+ authority: { value: input.authority ?? null, isWritable: false },
2036
+ priceFeed: { value: input.priceFeed ?? null, isWritable: false },
2037
+ oracle: { value: input.oracle ?? null, isWritable: true },
2038
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
2039
+ };
2040
+ const accounts = originalAccounts;
2041
+ const args = { ...input };
2042
+ if (!accounts.systemProgram.value) {
2043
+ accounts.systemProgram.value =
2044
+ '11111111111111111111111111111111';
2045
+ }
2046
+ const getAccountMeta = getAccountMetaFactory(programAddress);
2047
+ return Object.freeze({
2048
+ accounts: [
2049
+ getAccountMeta(accounts.payer),
2050
+ getAccountMeta(accounts.controller),
2051
+ getAccountMeta(accounts.controllerAuthority),
2052
+ getAccountMeta(accounts.authority),
2053
+ getAccountMeta(accounts.priceFeed),
2054
+ getAccountMeta(accounts.oracle),
2055
+ getAccountMeta(accounts.systemProgram),
2056
+ ],
2057
+ data: getInitializeOracleInstructionDataEncoder().encode(args),
2058
+ programAddress,
2059
+ });
2060
+ }
2061
+ function parseInitializeOracleInstruction(instruction) {
2062
+ if (instruction.accounts.length < 7) {
2063
+ throw new Error('Not enough accounts');
2064
+ }
2065
+ let accountIndex = 0;
2066
+ const getNextAccount = () => {
2067
+ const accountMeta = instruction.accounts[accountIndex];
2068
+ accountIndex += 1;
2069
+ return accountMeta;
2070
+ };
2071
+ return {
2072
+ programAddress: instruction.programAddress,
2073
+ accounts: {
2074
+ payer: getNextAccount(),
2075
+ controller: getNextAccount(),
2076
+ controllerAuthority: getNextAccount(),
2077
+ authority: getNextAccount(),
2078
+ priceFeed: getNextAccount(),
2079
+ oracle: getNextAccount(),
2080
+ systemProgram: getNextAccount(),
2081
+ },
2082
+ data: getInitializeOracleInstructionDataDecoder().decode(instruction.data),
2083
+ };
2084
+ }
2085
+
2086
+ const INITIALIZE_RESERVE_DISCRIMINATOR = 4;
2087
+ function getInitializeReserveDiscriminatorBytes() {
2088
+ return getU8Encoder().encode(INITIALIZE_RESERVE_DISCRIMINATOR);
2089
+ }
2090
+ function getInitializeReserveInstructionDataEncoder() {
2091
+ return transformEncoder(getStructEncoder([
2092
+ ['discriminator', getU8Encoder()],
2093
+ ['status', getReserveStatusEncoder()],
2094
+ ['rateLimitSlope', getU64Encoder()],
2095
+ ['rateLimitMaxOutflow', getU64Encoder()],
2096
+ ]), (value) => ({ ...value, discriminator: INITIALIZE_RESERVE_DISCRIMINATOR }));
2097
+ }
2098
+ function getInitializeReserveInstructionDataDecoder() {
2099
+ return getStructDecoder([
2100
+ ['discriminator', getU8Decoder()],
2101
+ ['status', getReserveStatusDecoder()],
2102
+ ['rateLimitSlope', getU64Decoder()],
2103
+ ['rateLimitMaxOutflow', getU64Decoder()],
2104
+ ]);
2105
+ }
2106
+ function getInitializeReserveInstructionDataCodec() {
2107
+ return combineCodec(getInitializeReserveInstructionDataEncoder(), getInitializeReserveInstructionDataDecoder());
2108
+ }
2109
+ function getInitializeReserveInstruction(input, config) {
2110
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
2111
+ const originalAccounts = {
2112
+ payer: { value: input.payer ?? null, isWritable: true },
2113
+ controller: { value: input.controller ?? null, isWritable: false },
2114
+ controllerAuthority: {
2115
+ value: input.controllerAuthority ?? null,
2116
+ isWritable: false,
2117
+ },
2118
+ authority: { value: input.authority ?? null, isWritable: false },
2119
+ permission: { value: input.permission ?? null, isWritable: false },
2120
+ reserve: { value: input.reserve ?? null, isWritable: true },
2121
+ mint: { value: input.mint ?? null, isWritable: false },
2122
+ vault: { value: input.vault ?? null, isWritable: true },
2123
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
2124
+ associatedTokenProgram: {
2125
+ value: input.associatedTokenProgram ?? null,
2126
+ isWritable: false,
2127
+ },
2128
+ programId: { value: input.programId ?? null, isWritable: false },
2129
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
2130
+ };
2131
+ const accounts = originalAccounts;
2132
+ const args = { ...input };
2133
+ if (!accounts.tokenProgram.value) {
2134
+ accounts.tokenProgram.value =
2135
+ 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
2136
+ }
2137
+ if (!accounts.programId.value) {
2138
+ accounts.programId.value = programAddress;
2139
+ accounts.programId.isWritable = false;
2140
+ }
2141
+ if (!accounts.systemProgram.value) {
2142
+ accounts.systemProgram.value =
2143
+ '11111111111111111111111111111111';
2144
+ }
2145
+ const getAccountMeta = getAccountMetaFactory(programAddress);
2146
+ return Object.freeze({
2147
+ accounts: [
2148
+ getAccountMeta(accounts.payer),
2149
+ getAccountMeta(accounts.controller),
2150
+ getAccountMeta(accounts.controllerAuthority),
2151
+ getAccountMeta(accounts.authority),
2152
+ getAccountMeta(accounts.permission),
2153
+ getAccountMeta(accounts.reserve),
2154
+ getAccountMeta(accounts.mint),
2155
+ getAccountMeta(accounts.vault),
2156
+ getAccountMeta(accounts.tokenProgram),
2157
+ getAccountMeta(accounts.associatedTokenProgram),
2158
+ getAccountMeta(accounts.programId),
2159
+ getAccountMeta(accounts.systemProgram),
2160
+ ],
2161
+ data: getInitializeReserveInstructionDataEncoder().encode(args),
2162
+ programAddress,
2163
+ });
2164
+ }
2165
+ function parseInitializeReserveInstruction(instruction) {
2166
+ if (instruction.accounts.length < 12) {
2167
+ throw new Error('Not enough accounts');
2168
+ }
2169
+ let accountIndex = 0;
2170
+ const getNextAccount = () => {
2171
+ const accountMeta = instruction.accounts[accountIndex];
2172
+ accountIndex += 1;
2173
+ return accountMeta;
2174
+ };
2175
+ return {
2176
+ programAddress: instruction.programAddress,
2177
+ accounts: {
2178
+ payer: getNextAccount(),
2179
+ controller: getNextAccount(),
2180
+ controllerAuthority: getNextAccount(),
2181
+ authority: getNextAccount(),
2182
+ permission: getNextAccount(),
2183
+ reserve: getNextAccount(),
2184
+ mint: getNextAccount(),
2185
+ vault: getNextAccount(),
2186
+ tokenProgram: getNextAccount(),
2187
+ associatedTokenProgram: getNextAccount(),
2188
+ programId: getNextAccount(),
2189
+ systemProgram: getNextAccount(),
2190
+ },
2191
+ data: getInitializeReserveInstructionDataDecoder().decode(instruction.data),
2192
+ };
2193
+ }
2194
+
2195
+ const MANAGE_CONTROLLER_DISCRIMINATOR = 2;
2196
+ function getManageControllerDiscriminatorBytes() {
2197
+ return getU8Encoder().encode(MANAGE_CONTROLLER_DISCRIMINATOR);
2198
+ }
2199
+ function getManageControllerInstructionDataEncoder() {
2200
+ return transformEncoder(getStructEncoder([
2201
+ ['discriminator', getU8Encoder()],
2202
+ ['status', getControllerStatusEncoder()],
2203
+ ]), (value) => ({ ...value, discriminator: MANAGE_CONTROLLER_DISCRIMINATOR }));
2204
+ }
2205
+ function getManageControllerInstructionDataDecoder() {
2206
+ return getStructDecoder([
2207
+ ['discriminator', getU8Decoder()],
2208
+ ['status', getControllerStatusDecoder()],
2209
+ ]);
2210
+ }
2211
+ function getManageControllerInstructionDataCodec() {
2212
+ return combineCodec(getManageControllerInstructionDataEncoder(), getManageControllerInstructionDataDecoder());
2213
+ }
2214
+ function getManageControllerInstruction(input, config) {
2215
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
2216
+ const originalAccounts = {
2217
+ controller: { value: input.controller ?? null, isWritable: true },
2218
+ controllerAuthority: {
2219
+ value: input.controllerAuthority ?? null,
2220
+ isWritable: false,
2221
+ },
2222
+ authority: { value: input.authority ?? null, isWritable: false },
2223
+ permission: { value: input.permission ?? null, isWritable: false },
2224
+ programId: { value: input.programId ?? null, isWritable: false },
2225
+ };
2226
+ const accounts = originalAccounts;
2227
+ const args = { ...input };
2228
+ if (!accounts.programId.value) {
2229
+ accounts.programId.value = programAddress;
2230
+ accounts.programId.isWritable = false;
2231
+ }
2232
+ const getAccountMeta = getAccountMetaFactory(programAddress);
2233
+ return Object.freeze({
2234
+ accounts: [
2235
+ getAccountMeta(accounts.controller),
2236
+ getAccountMeta(accounts.controllerAuthority),
2237
+ getAccountMeta(accounts.authority),
2238
+ getAccountMeta(accounts.permission),
2239
+ getAccountMeta(accounts.programId),
2240
+ ],
2241
+ data: getManageControllerInstructionDataEncoder().encode(args),
2242
+ programAddress,
2243
+ });
2244
+ }
2245
+ function parseManageControllerInstruction(instruction) {
2246
+ if (instruction.accounts.length < 5) {
2247
+ throw new Error('Not enough accounts');
2248
+ }
2249
+ let accountIndex = 0;
2250
+ const getNextAccount = () => {
2251
+ const accountMeta = instruction.accounts[accountIndex];
2252
+ accountIndex += 1;
2253
+ return accountMeta;
2254
+ };
2255
+ return {
2256
+ programAddress: instruction.programAddress,
2257
+ accounts: {
2258
+ controller: getNextAccount(),
2259
+ controllerAuthority: getNextAccount(),
2260
+ authority: getNextAccount(),
2261
+ permission: getNextAccount(),
2262
+ programId: getNextAccount(),
2263
+ },
2264
+ data: getManageControllerInstructionDataDecoder().decode(instruction.data),
2265
+ };
2266
+ }
2267
+
2268
+ const MANAGE_INTEGRATION_DISCRIMINATOR = 7;
2269
+ function getManageIntegrationDiscriminatorBytes() {
2270
+ return getU8Encoder().encode(MANAGE_INTEGRATION_DISCRIMINATOR);
2271
+ }
2272
+ function getManageIntegrationInstructionDataEncoder() {
2273
+ return transformEncoder(getStructEncoder([
2274
+ ['discriminator', getU8Encoder()],
2275
+ ['status', getOptionEncoder(getIntegrationStatusEncoder())],
2276
+ ['description', getOptionEncoder(fixEncoderSize(getBytesEncoder(), 32))],
2277
+ ['rateLimitSlope', getOptionEncoder(getU64Encoder())],
2278
+ ['rateLimitMaxOutflow', getOptionEncoder(getU64Encoder())],
2279
+ ]), (value) => ({ ...value, discriminator: MANAGE_INTEGRATION_DISCRIMINATOR }));
2280
+ }
2281
+ function getManageIntegrationInstructionDataDecoder() {
2282
+ return getStructDecoder([
2283
+ ['discriminator', getU8Decoder()],
2284
+ ['status', getOptionDecoder(getIntegrationStatusDecoder())],
2285
+ ['description', getOptionDecoder(fixDecoderSize(getBytesDecoder(), 32))],
2286
+ ['rateLimitSlope', getOptionDecoder(getU64Decoder())],
2287
+ ['rateLimitMaxOutflow', getOptionDecoder(getU64Decoder())],
2288
+ ]);
2289
+ }
2290
+ function getManageIntegrationInstructionDataCodec() {
2291
+ return combineCodec(getManageIntegrationInstructionDataEncoder(), getManageIntegrationInstructionDataDecoder());
2292
+ }
2293
+ function getManageIntegrationInstruction(input, config) {
2294
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
2295
+ const originalAccounts = {
2296
+ controller: { value: input.controller ?? null, isWritable: false },
2297
+ controllerAuthority: {
2298
+ value: input.controllerAuthority ?? null,
2299
+ isWritable: false,
2300
+ },
2301
+ authority: { value: input.authority ?? null, isWritable: false },
2302
+ permission: { value: input.permission ?? null, isWritable: false },
2303
+ integration: { value: input.integration ?? null, isWritable: true },
2304
+ programId: { value: input.programId ?? null, isWritable: false },
2305
+ };
2306
+ const accounts = originalAccounts;
2307
+ const args = { ...input };
2308
+ if (!accounts.programId.value) {
2309
+ accounts.programId.value = programAddress;
2310
+ accounts.programId.isWritable = false;
2311
+ }
2312
+ const getAccountMeta = getAccountMetaFactory(programAddress);
2313
+ return Object.freeze({
2314
+ accounts: [
2315
+ getAccountMeta(accounts.controller),
2316
+ getAccountMeta(accounts.controllerAuthority),
2317
+ getAccountMeta(accounts.authority),
2318
+ getAccountMeta(accounts.permission),
2319
+ getAccountMeta(accounts.integration),
2320
+ getAccountMeta(accounts.programId),
2321
+ ],
2322
+ data: getManageIntegrationInstructionDataEncoder().encode(args),
2323
+ programAddress,
2324
+ });
2325
+ }
2326
+ function parseManageIntegrationInstruction(instruction) {
2327
+ if (instruction.accounts.length < 6) {
2328
+ throw new Error('Not enough accounts');
2329
+ }
2330
+ let accountIndex = 0;
2331
+ const getNextAccount = () => {
2332
+ const accountMeta = instruction.accounts[accountIndex];
2333
+ accountIndex += 1;
2334
+ return accountMeta;
2335
+ };
2336
+ return {
2337
+ programAddress: instruction.programAddress,
2338
+ accounts: {
2339
+ controller: getNextAccount(),
2340
+ controllerAuthority: getNextAccount(),
2341
+ authority: getNextAccount(),
2342
+ permission: getNextAccount(),
2343
+ integration: getNextAccount(),
2344
+ programId: getNextAccount(),
2345
+ },
2346
+ data: getManageIntegrationInstructionDataDecoder().decode(instruction.data),
2347
+ };
2348
+ }
2349
+
2350
+ const MANAGE_PERMISSION_DISCRIMINATOR = 3;
2351
+ function getManagePermissionDiscriminatorBytes() {
2352
+ return getU8Encoder().encode(MANAGE_PERMISSION_DISCRIMINATOR);
2353
+ }
2354
+ function getManagePermissionInstructionDataEncoder() {
2355
+ return transformEncoder(getStructEncoder([
2356
+ ['discriminator', getU8Encoder()],
2357
+ ['status', getPermissionStatusEncoder()],
2358
+ ['canManagePermissions', getBooleanEncoder()],
2359
+ ['canInvokeExternalTransfer', getBooleanEncoder()],
2360
+ ['canExecuteSwap', getBooleanEncoder()],
2361
+ ['canReallocate', getBooleanEncoder()],
2362
+ ['canFreezeController', getBooleanEncoder()],
2363
+ ['canUnfreezeController', getBooleanEncoder()],
2364
+ ['canManageReservesAndIntegrations', getBooleanEncoder()],
2365
+ ['canSuspendPermissions', getBooleanEncoder()],
2366
+ ['canLiquidate', getBooleanEncoder()],
2367
+ ]), (value) => ({ ...value, discriminator: MANAGE_PERMISSION_DISCRIMINATOR }));
2368
+ }
2369
+ function getManagePermissionInstructionDataDecoder() {
2370
+ return getStructDecoder([
2371
+ ['discriminator', getU8Decoder()],
2372
+ ['status', getPermissionStatusDecoder()],
2373
+ ['canManagePermissions', getBooleanDecoder()],
2374
+ ['canInvokeExternalTransfer', getBooleanDecoder()],
2375
+ ['canExecuteSwap', getBooleanDecoder()],
2376
+ ['canReallocate', getBooleanDecoder()],
2377
+ ['canFreezeController', getBooleanDecoder()],
2378
+ ['canUnfreezeController', getBooleanDecoder()],
2379
+ ['canManageReservesAndIntegrations', getBooleanDecoder()],
2380
+ ['canSuspendPermissions', getBooleanDecoder()],
2381
+ ['canLiquidate', getBooleanDecoder()],
2382
+ ]);
2383
+ }
2384
+ function getManagePermissionInstructionDataCodec() {
2385
+ return combineCodec(getManagePermissionInstructionDataEncoder(), getManagePermissionInstructionDataDecoder());
2386
+ }
2387
+ function getManagePermissionInstruction(input, config) {
2388
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
2389
+ const originalAccounts = {
2390
+ payer: { value: input.payer ?? null, isWritable: true },
2391
+ controller: { value: input.controller ?? null, isWritable: false },
2392
+ controllerAuthority: {
2393
+ value: input.controllerAuthority ?? null,
2394
+ isWritable: false,
2395
+ },
2396
+ superAuthority: { value: input.superAuthority ?? null, isWritable: false },
2397
+ superPermission: {
2398
+ value: input.superPermission ?? null,
2399
+ isWritable: false,
2400
+ },
2401
+ authority: { value: input.authority ?? null, isWritable: false },
2402
+ permission: { value: input.permission ?? null, isWritable: true },
2403
+ programId: { value: input.programId ?? null, isWritable: false },
2404
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
2405
+ };
2406
+ const accounts = originalAccounts;
2407
+ const args = { ...input };
2408
+ if (!accounts.programId.value) {
2409
+ accounts.programId.value = programAddress;
2410
+ accounts.programId.isWritable = false;
2411
+ }
2412
+ if (!accounts.systemProgram.value) {
2413
+ accounts.systemProgram.value =
2414
+ '11111111111111111111111111111111';
2415
+ }
2416
+ const getAccountMeta = getAccountMetaFactory(programAddress);
2417
+ return Object.freeze({
2418
+ accounts: [
2419
+ getAccountMeta(accounts.payer),
2420
+ getAccountMeta(accounts.controller),
2421
+ getAccountMeta(accounts.controllerAuthority),
2422
+ getAccountMeta(accounts.superAuthority),
2423
+ getAccountMeta(accounts.superPermission),
2424
+ getAccountMeta(accounts.authority),
2425
+ getAccountMeta(accounts.permission),
2426
+ getAccountMeta(accounts.programId),
2427
+ getAccountMeta(accounts.systemProgram),
2428
+ ],
2429
+ data: getManagePermissionInstructionDataEncoder().encode(args),
2430
+ programAddress,
2431
+ });
2432
+ }
2433
+ function parseManagePermissionInstruction(instruction) {
2434
+ if (instruction.accounts.length < 9) {
2435
+ throw new Error('Not enough accounts');
2436
+ }
2437
+ let accountIndex = 0;
2438
+ const getNextAccount = () => {
2439
+ const accountMeta = instruction.accounts[accountIndex];
2440
+ accountIndex += 1;
2441
+ return accountMeta;
2442
+ };
2443
+ return {
2444
+ programAddress: instruction.programAddress,
2445
+ accounts: {
2446
+ payer: getNextAccount(),
2447
+ controller: getNextAccount(),
2448
+ controllerAuthority: getNextAccount(),
2449
+ superAuthority: getNextAccount(),
2450
+ superPermission: getNextAccount(),
2451
+ authority: getNextAccount(),
2452
+ permission: getNextAccount(),
2453
+ programId: getNextAccount(),
2454
+ systemProgram: getNextAccount(),
2455
+ },
2456
+ data: getManagePermissionInstructionDataDecoder().decode(instruction.data),
2457
+ };
2458
+ }
2459
+
2460
+ const MANAGE_RESERVE_DISCRIMINATOR = 5;
2461
+ function getManageReserveDiscriminatorBytes() {
2462
+ return getU8Encoder().encode(MANAGE_RESERVE_DISCRIMINATOR);
2463
+ }
2464
+ function getManageReserveInstructionDataEncoder() {
2465
+ return transformEncoder(getStructEncoder([
2466
+ ['discriminator', getU8Encoder()],
2467
+ ['status', getOptionEncoder(getReserveStatusEncoder())],
2468
+ ['rateLimitSlope', getOptionEncoder(getU64Encoder())],
2469
+ ['rateLimitMaxOutflow', getOptionEncoder(getU64Encoder())],
2470
+ ]), (value) => ({ ...value, discriminator: MANAGE_RESERVE_DISCRIMINATOR }));
2471
+ }
2472
+ function getManageReserveInstructionDataDecoder() {
2473
+ return getStructDecoder([
2474
+ ['discriminator', getU8Decoder()],
2475
+ ['status', getOptionDecoder(getReserveStatusDecoder())],
2476
+ ['rateLimitSlope', getOptionDecoder(getU64Decoder())],
2477
+ ['rateLimitMaxOutflow', getOptionDecoder(getU64Decoder())],
2478
+ ]);
2479
+ }
2480
+ function getManageReserveInstructionDataCodec() {
2481
+ return combineCodec(getManageReserveInstructionDataEncoder(), getManageReserveInstructionDataDecoder());
2482
+ }
2483
+ function getManageReserveInstruction(input, config) {
2484
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
2485
+ const originalAccounts = {
2486
+ controller: { value: input.controller ?? null, isWritable: false },
2487
+ controllerAuthority: {
2488
+ value: input.controllerAuthority ?? null,
2489
+ isWritable: false,
2490
+ },
2491
+ authority: { value: input.authority ?? null, isWritable: false },
2492
+ permission: { value: input.permission ?? null, isWritable: false },
2493
+ reserve: { value: input.reserve ?? null, isWritable: true },
2494
+ programId: { value: input.programId ?? null, isWritable: false },
2495
+ };
2496
+ const accounts = originalAccounts;
2497
+ const args = { ...input };
2498
+ if (!accounts.programId.value) {
2499
+ accounts.programId.value = programAddress;
2500
+ accounts.programId.isWritable = false;
2501
+ }
2502
+ const getAccountMeta = getAccountMetaFactory(programAddress);
2503
+ return Object.freeze({
2504
+ accounts: [
2505
+ getAccountMeta(accounts.controller),
2506
+ getAccountMeta(accounts.controllerAuthority),
2507
+ getAccountMeta(accounts.authority),
2508
+ getAccountMeta(accounts.permission),
2509
+ getAccountMeta(accounts.reserve),
2510
+ getAccountMeta(accounts.programId),
2511
+ ],
2512
+ data: getManageReserveInstructionDataEncoder().encode(args),
2513
+ programAddress,
2514
+ });
2515
+ }
2516
+ function parseManageReserveInstruction(instruction) {
2517
+ if (instruction.accounts.length < 6) {
2518
+ throw new Error('Not enough accounts');
2519
+ }
2520
+ let accountIndex = 0;
2521
+ const getNextAccount = () => {
2522
+ const accountMeta = instruction.accounts[accountIndex];
2523
+ accountIndex += 1;
2524
+ return accountMeta;
2525
+ };
2526
+ return {
2527
+ programAddress: instruction.programAddress,
2528
+ accounts: {
2529
+ controller: getNextAccount(),
2530
+ controllerAuthority: getNextAccount(),
2531
+ authority: getNextAccount(),
2532
+ permission: getNextAccount(),
2533
+ reserve: getNextAccount(),
2534
+ programId: getNextAccount(),
2535
+ },
2536
+ data: getManageReserveInstructionDataDecoder().decode(instruction.data),
2537
+ };
2538
+ }
2539
+
2540
+ const PULL_DISCRIMINATOR = 11;
2541
+ function getPullDiscriminatorBytes() {
2542
+ return getU8Encoder().encode(PULL_DISCRIMINATOR);
2543
+ }
2544
+ function getPullInstructionDataEncoder() {
2545
+ return transformEncoder(getStructEncoder([
2546
+ ['discriminator', getU8Encoder()],
2547
+ ['pullArgs', getPullArgsEncoder()],
2548
+ ]), (value) => ({ ...value, discriminator: PULL_DISCRIMINATOR }));
2549
+ }
2550
+ function getPullInstructionDataDecoder() {
2551
+ return getStructDecoder([
2552
+ ['discriminator', getU8Decoder()],
2553
+ ['pullArgs', getPullArgsDecoder()],
2554
+ ]);
2555
+ }
2556
+ function getPullInstructionDataCodec() {
2557
+ return combineCodec(getPullInstructionDataEncoder(), getPullInstructionDataDecoder());
2558
+ }
2559
+ function getPullInstruction(input, config) {
2560
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
2561
+ const originalAccounts = {
2562
+ controller: { value: input.controller ?? null, isWritable: false },
2563
+ controllerAuthority: {
2564
+ value: input.controllerAuthority ?? null,
2565
+ isWritable: false,
2566
+ },
2567
+ authority: { value: input.authority ?? null, isWritable: false },
2568
+ permission: { value: input.permission ?? null, isWritable: false },
2569
+ integration: { value: input.integration ?? null, isWritable: true },
2570
+ reserveA: { value: input.reserveA ?? null, isWritable: true },
2571
+ reserveB: { value: input.reserveB ?? null, isWritable: true },
2572
+ programId: { value: input.programId ?? null, isWritable: false },
2573
+ };
2574
+ const accounts = originalAccounts;
2575
+ const args = { ...input };
2576
+ if (!accounts.programId.value) {
2577
+ accounts.programId.value = programAddress;
2578
+ accounts.programId.isWritable = false;
2579
+ }
2580
+ const getAccountMeta = getAccountMetaFactory(programAddress);
2581
+ return Object.freeze({
2582
+ accounts: [
2583
+ getAccountMeta(accounts.controller),
2584
+ getAccountMeta(accounts.controllerAuthority),
2585
+ getAccountMeta(accounts.authority),
2586
+ getAccountMeta(accounts.permission),
2587
+ getAccountMeta(accounts.integration),
2588
+ getAccountMeta(accounts.reserveA),
2589
+ getAccountMeta(accounts.reserveB),
2590
+ getAccountMeta(accounts.programId),
2591
+ ],
2592
+ data: getPullInstructionDataEncoder().encode(args),
2593
+ programAddress,
2594
+ });
2595
+ }
2596
+ function parsePullInstruction(instruction) {
2597
+ if (instruction.accounts.length < 8) {
2598
+ throw new Error('Not enough accounts');
2599
+ }
2600
+ let accountIndex = 0;
2601
+ const getNextAccount = () => {
2602
+ const accountMeta = instruction.accounts[accountIndex];
2603
+ accountIndex += 1;
2604
+ return accountMeta;
2605
+ };
2606
+ return {
2607
+ programAddress: instruction.programAddress,
2608
+ accounts: {
2609
+ controller: getNextAccount(),
2610
+ controllerAuthority: getNextAccount(),
2611
+ authority: getNextAccount(),
2612
+ permission: getNextAccount(),
2613
+ integration: getNextAccount(),
2614
+ reserveA: getNextAccount(),
2615
+ reserveB: getNextAccount(),
2616
+ programId: getNextAccount(),
2617
+ },
2618
+ data: getPullInstructionDataDecoder().decode(instruction.data),
2619
+ };
2620
+ }
2621
+
2622
+ const PUSH_DISCRIMINATOR = 10;
2623
+ function getPushDiscriminatorBytes() {
2624
+ return getU8Encoder().encode(PUSH_DISCRIMINATOR);
2625
+ }
2626
+ function getPushInstructionDataEncoder() {
2627
+ return transformEncoder(getStructEncoder([
2628
+ ['discriminator', getU8Encoder()],
2629
+ ['pushArgs', getPushArgsEncoder()],
2630
+ ]), (value) => ({ ...value, discriminator: PUSH_DISCRIMINATOR }));
2631
+ }
2632
+ function getPushInstructionDataDecoder() {
2633
+ return getStructDecoder([
2634
+ ['discriminator', getU8Decoder()],
2635
+ ['pushArgs', getPushArgsDecoder()],
2636
+ ]);
2637
+ }
2638
+ function getPushInstructionDataCodec() {
2639
+ return combineCodec(getPushInstructionDataEncoder(), getPushInstructionDataDecoder());
2640
+ }
2641
+ function getPushInstruction(input, config) {
2642
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
2643
+ const originalAccounts = {
2644
+ controller: { value: input.controller ?? null, isWritable: false },
2645
+ controllerAuthority: {
2646
+ value: input.controllerAuthority ?? null,
2647
+ isWritable: false,
2648
+ },
2649
+ authority: { value: input.authority ?? null, isWritable: false },
2650
+ permission: { value: input.permission ?? null, isWritable: false },
2651
+ integration: { value: input.integration ?? null, isWritable: true },
2652
+ reserveA: { value: input.reserveA ?? null, isWritable: true },
2653
+ reserveB: { value: input.reserveB ?? null, isWritable: true },
2654
+ programId: { value: input.programId ?? null, isWritable: false },
2655
+ };
2656
+ const accounts = originalAccounts;
2657
+ const args = { ...input };
2658
+ if (!accounts.programId.value) {
2659
+ accounts.programId.value = programAddress;
2660
+ accounts.programId.isWritable = false;
2661
+ }
2662
+ const getAccountMeta = getAccountMetaFactory(programAddress);
2663
+ return Object.freeze({
2664
+ accounts: [
2665
+ getAccountMeta(accounts.controller),
2666
+ getAccountMeta(accounts.controllerAuthority),
2667
+ getAccountMeta(accounts.authority),
2668
+ getAccountMeta(accounts.permission),
2669
+ getAccountMeta(accounts.integration),
2670
+ getAccountMeta(accounts.reserveA),
2671
+ getAccountMeta(accounts.reserveB),
2672
+ getAccountMeta(accounts.programId),
2673
+ ],
2674
+ data: getPushInstructionDataEncoder().encode(args),
2675
+ programAddress,
2676
+ });
2677
+ }
2678
+ function parsePushInstruction(instruction) {
2679
+ if (instruction.accounts.length < 8) {
2680
+ throw new Error('Not enough accounts');
2681
+ }
2682
+ let accountIndex = 0;
2683
+ const getNextAccount = () => {
2684
+ const accountMeta = instruction.accounts[accountIndex];
2685
+ accountIndex += 1;
2686
+ return accountMeta;
2687
+ };
2688
+ return {
2689
+ programAddress: instruction.programAddress,
2690
+ accounts: {
2691
+ controller: getNextAccount(),
2692
+ controllerAuthority: getNextAccount(),
2693
+ authority: getNextAccount(),
2694
+ permission: getNextAccount(),
2695
+ integration: getNextAccount(),
2696
+ reserveA: getNextAccount(),
2697
+ reserveB: getNextAccount(),
2698
+ programId: getNextAccount(),
2699
+ },
2700
+ data: getPushInstructionDataDecoder().decode(instruction.data),
2701
+ };
2702
+ }
2703
+
2704
+ const REFRESH_ORACLE_DISCRIMINATOR = 14;
2705
+ function getRefreshOracleDiscriminatorBytes() {
2706
+ return getU8Encoder().encode(REFRESH_ORACLE_DISCRIMINATOR);
2707
+ }
2708
+ function getRefreshOracleInstructionDataEncoder() {
2709
+ return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({ ...value, discriminator: REFRESH_ORACLE_DISCRIMINATOR }));
2710
+ }
2711
+ function getRefreshOracleInstructionDataDecoder() {
2712
+ return getStructDecoder([['discriminator', getU8Decoder()]]);
2713
+ }
2714
+ function getRefreshOracleInstructionDataCodec() {
2715
+ return combineCodec(getRefreshOracleInstructionDataEncoder(), getRefreshOracleInstructionDataDecoder());
2716
+ }
2717
+ function getRefreshOracleInstruction(input, config) {
2718
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
2719
+ const originalAccounts = {
2720
+ priceFeed: { value: input.priceFeed ?? null, isWritable: false },
2721
+ oracle: { value: input.oracle ?? null, isWritable: true },
2722
+ };
2723
+ const accounts = originalAccounts;
2724
+ const getAccountMeta = getAccountMetaFactory(programAddress);
2725
+ return Object.freeze({
2726
+ accounts: [
2727
+ getAccountMeta(accounts.priceFeed),
2728
+ getAccountMeta(accounts.oracle),
2729
+ ],
2730
+ data: getRefreshOracleInstructionDataEncoder().encode({}),
2731
+ programAddress,
2732
+ });
2733
+ }
2734
+ function parseRefreshOracleInstruction(instruction) {
2735
+ if (instruction.accounts.length < 2) {
2736
+ throw new Error('Not enough accounts');
2737
+ }
2738
+ let accountIndex = 0;
2739
+ const getNextAccount = () => {
2740
+ const accountMeta = instruction.accounts[accountIndex];
2741
+ accountIndex += 1;
2742
+ return accountMeta;
2743
+ };
2744
+ return {
2745
+ programAddress: instruction.programAddress,
2746
+ accounts: { priceFeed: getNextAccount(), oracle: getNextAccount() },
2747
+ data: getRefreshOracleInstructionDataDecoder().decode(instruction.data),
2748
+ };
2749
+ }
2750
+
2751
+ const RESET_LZ_PUSH_IN_FLIGHT_DISCRIMINATOR = 17;
2752
+ function getResetLzPushInFlightDiscriminatorBytes() {
2753
+ return getU8Encoder().encode(RESET_LZ_PUSH_IN_FLIGHT_DISCRIMINATOR);
2754
+ }
2755
+ function getResetLzPushInFlightInstructionDataEncoder() {
2756
+ return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({
2757
+ ...value,
2758
+ discriminator: RESET_LZ_PUSH_IN_FLIGHT_DISCRIMINATOR,
2759
+ }));
2760
+ }
2761
+ function getResetLzPushInFlightInstructionDataDecoder() {
2762
+ return getStructDecoder([['discriminator', getU8Decoder()]]);
2763
+ }
2764
+ function getResetLzPushInFlightInstructionDataCodec() {
2765
+ return combineCodec(getResetLzPushInFlightInstructionDataEncoder(), getResetLzPushInFlightInstructionDataDecoder());
2766
+ }
2767
+ function getResetLzPushInFlightInstruction(input, config) {
2768
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
2769
+ const originalAccounts = {
2770
+ controller: { value: input.controller ?? null, isWritable: false },
2771
+ integration: { value: input.integration ?? null, isWritable: true },
2772
+ sysvarInstruction: {
2773
+ value: input.sysvarInstruction ?? null,
2774
+ isWritable: false,
2775
+ },
2776
+ };
2777
+ const accounts = originalAccounts;
2778
+ if (!accounts.sysvarInstruction.value) {
2779
+ accounts.sysvarInstruction.value =
2780
+ 'Sysvar1nstructions1111111111111111111111111';
2781
+ }
2782
+ const getAccountMeta = getAccountMetaFactory(programAddress);
2783
+ return Object.freeze({
2784
+ accounts: [
2785
+ getAccountMeta(accounts.controller),
2786
+ getAccountMeta(accounts.integration),
2787
+ getAccountMeta(accounts.sysvarInstruction),
2788
+ ],
2789
+ data: getResetLzPushInFlightInstructionDataEncoder().encode({}),
2790
+ programAddress,
2791
+ });
2792
+ }
2793
+ function parseResetLzPushInFlightInstruction(instruction) {
2794
+ if (instruction.accounts.length < 3) {
2795
+ throw new Error('Not enough accounts');
2796
+ }
2797
+ let accountIndex = 0;
2798
+ const getNextAccount = () => {
2799
+ const accountMeta = instruction.accounts[accountIndex];
2800
+ accountIndex += 1;
2801
+ return accountMeta;
2802
+ };
2803
+ return {
2804
+ programAddress: instruction.programAddress,
2805
+ accounts: {
2806
+ controller: getNextAccount(),
2807
+ integration: getNextAccount(),
2808
+ sysvarInstruction: getNextAccount(),
2809
+ },
2810
+ data: getResetLzPushInFlightInstructionDataDecoder().decode(instruction.data),
2811
+ };
2812
+ }
2813
+
2814
+ const SYNC_DISCRIMINATOR = 9;
2815
+ function getSyncDiscriminatorBytes() {
2816
+ return getU8Encoder().encode(SYNC_DISCRIMINATOR);
2817
+ }
2818
+ function getSyncInstructionDataEncoder() {
2819
+ return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({ ...value, discriminator: SYNC_DISCRIMINATOR }));
2820
+ }
2821
+ function getSyncInstructionDataDecoder() {
2822
+ return getStructDecoder([['discriminator', getU8Decoder()]]);
2823
+ }
2824
+ function getSyncInstructionDataCodec() {
2825
+ return combineCodec(getSyncInstructionDataEncoder(), getSyncInstructionDataDecoder());
2826
+ }
2827
+ function getSyncInstruction(input, config) {
2828
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
2829
+ const originalAccounts = {
2830
+ controller: { value: input.controller ?? null, isWritable: false },
2831
+ controllerAuthority: {
2832
+ value: input.controllerAuthority ?? null,
2833
+ isWritable: false,
2834
+ },
2835
+ integration: { value: input.integration ?? null, isWritable: true },
2836
+ };
2837
+ const accounts = originalAccounts;
2838
+ const getAccountMeta = getAccountMetaFactory(programAddress);
2839
+ return Object.freeze({
2840
+ accounts: [
2841
+ getAccountMeta(accounts.controller),
2842
+ getAccountMeta(accounts.controllerAuthority),
2843
+ getAccountMeta(accounts.integration),
2844
+ ],
2845
+ data: getSyncInstructionDataEncoder().encode({}),
2846
+ programAddress,
2847
+ });
2848
+ }
2849
+ function parseSyncInstruction(instruction) {
2850
+ if (instruction.accounts.length < 3) {
2851
+ throw new Error('Not enough accounts');
2852
+ }
2853
+ let accountIndex = 0;
2854
+ const getNextAccount = () => {
2855
+ const accountMeta = instruction.accounts[accountIndex];
2856
+ accountIndex += 1;
2857
+ return accountMeta;
2858
+ };
2859
+ return {
2860
+ programAddress: instruction.programAddress,
2861
+ accounts: {
2862
+ controller: getNextAccount(),
2863
+ controllerAuthority: getNextAccount(),
2864
+ integration: getNextAccount(),
2865
+ },
2866
+ data: getSyncInstructionDataDecoder().decode(instruction.data),
2867
+ };
2868
+ }
2869
+
2870
+ const SYNC_RESERVE_DISCRIMINATOR = 8;
2871
+ function getSyncReserveDiscriminatorBytes() {
2872
+ return getU8Encoder().encode(SYNC_RESERVE_DISCRIMINATOR);
2873
+ }
2874
+ function getSyncReserveInstructionDataEncoder() {
2875
+ return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({ ...value, discriminator: SYNC_RESERVE_DISCRIMINATOR }));
2876
+ }
2877
+ function getSyncReserveInstructionDataDecoder() {
2878
+ return getStructDecoder([['discriminator', getU8Decoder()]]);
2879
+ }
2880
+ function getSyncReserveInstructionDataCodec() {
2881
+ return combineCodec(getSyncReserveInstructionDataEncoder(), getSyncReserveInstructionDataDecoder());
2882
+ }
2883
+ function getSyncReserveInstruction(input, config) {
2884
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
2885
+ const originalAccounts = {
2886
+ controller: { value: input.controller ?? null, isWritable: false },
2887
+ controllerAuthority: {
2888
+ value: input.controllerAuthority ?? null,
2889
+ isWritable: false,
2890
+ },
2891
+ reserve: { value: input.reserve ?? null, isWritable: true },
2892
+ vault: { value: input.vault ?? null, isWritable: false },
2893
+ };
2894
+ const accounts = originalAccounts;
2895
+ const getAccountMeta = getAccountMetaFactory(programAddress);
2896
+ return Object.freeze({
2897
+ accounts: [
2898
+ getAccountMeta(accounts.controller),
2899
+ getAccountMeta(accounts.controllerAuthority),
2900
+ getAccountMeta(accounts.reserve),
2901
+ getAccountMeta(accounts.vault),
2902
+ ],
2903
+ data: getSyncReserveInstructionDataEncoder().encode({}),
2904
+ programAddress,
2905
+ });
2906
+ }
2907
+ function parseSyncReserveInstruction(instruction) {
2908
+ if (instruction.accounts.length < 4) {
2909
+ throw new Error('Not enough accounts');
2910
+ }
2911
+ let accountIndex = 0;
2912
+ const getNextAccount = () => {
2913
+ const accountMeta = instruction.accounts[accountIndex];
2914
+ accountIndex += 1;
2915
+ return accountMeta;
2916
+ };
2917
+ return {
2918
+ programAddress: instruction.programAddress,
2919
+ accounts: {
2920
+ controller: getNextAccount(),
2921
+ controllerAuthority: getNextAccount(),
2922
+ reserve: getNextAccount(),
2923
+ vault: getNextAccount(),
2924
+ },
2925
+ data: getSyncReserveInstructionDataDecoder().decode(instruction.data),
2926
+ };
2927
+ }
2928
+
2929
+ const UPDATE_ORACLE_DISCRIMINATOR = 13;
2930
+ function getUpdateOracleDiscriminatorBytes() {
2931
+ return getU8Encoder().encode(UPDATE_ORACLE_DISCRIMINATOR);
2932
+ }
2933
+ function getUpdateOracleInstructionDataEncoder() {
2934
+ return transformEncoder(getStructEncoder([
2935
+ ['discriminator', getU8Encoder()],
2936
+ ['feedArgs', getOptionEncoder(getFeedArgsEncoder())],
2937
+ ]), (value) => ({ ...value, discriminator: UPDATE_ORACLE_DISCRIMINATOR }));
2938
+ }
2939
+ function getUpdateOracleInstructionDataDecoder() {
2940
+ return getStructDecoder([
2941
+ ['discriminator', getU8Decoder()],
2942
+ ['feedArgs', getOptionDecoder(getFeedArgsDecoder())],
2943
+ ]);
2944
+ }
2945
+ function getUpdateOracleInstructionDataCodec() {
2946
+ return combineCodec(getUpdateOracleInstructionDataEncoder(), getUpdateOracleInstructionDataDecoder());
2947
+ }
2948
+ function getUpdateOracleInstruction(input, config) {
2949
+ const programAddress = config?.programAddress ?? SVM_ALM_CONTROLLER_PROGRAM_ADDRESS;
2950
+ const originalAccounts = {
2951
+ controller: { value: input.controller ?? null, isWritable: false },
2952
+ controllerAuthority: {
2953
+ value: input.controllerAuthority ?? null,
2954
+ isWritable: false,
2955
+ },
2956
+ authority: { value: input.authority ?? null, isWritable: false },
2957
+ priceFeed: { value: input.priceFeed ?? null, isWritable: false },
2958
+ oracle: { value: input.oracle ?? null, isWritable: true },
2959
+ newAuthority: { value: input.newAuthority ?? null, isWritable: false },
2960
+ };
2961
+ const accounts = originalAccounts;
2962
+ const args = { ...input };
2963
+ const getAccountMeta = getAccountMetaFactory(programAddress);
2964
+ return Object.freeze({
2965
+ accounts: [
2966
+ getAccountMeta(accounts.controller),
2967
+ getAccountMeta(accounts.controllerAuthority),
2968
+ getAccountMeta(accounts.authority),
2969
+ getAccountMeta(accounts.priceFeed),
2970
+ getAccountMeta(accounts.oracle),
2971
+ getAccountMeta(accounts.newAuthority),
2972
+ ],
2973
+ data: getUpdateOracleInstructionDataEncoder().encode(args),
2974
+ programAddress,
2975
+ });
2976
+ }
2977
+ function parseUpdateOracleInstruction(instruction) {
2978
+ if (instruction.accounts.length < 6) {
2979
+ throw new Error('Not enough accounts');
2980
+ }
2981
+ let accountIndex = 0;
2982
+ const getNextAccount = () => {
2983
+ const accountMeta = instruction.accounts[accountIndex];
2984
+ accountIndex += 1;
2985
+ return accountMeta;
2986
+ };
2987
+ const getNextOptionalAccount = () => {
2988
+ const accountMeta = getNextAccount();
2989
+ return accountMeta.address === SVM_ALM_CONTROLLER_PROGRAM_ADDRESS
2990
+ ? undefined
2991
+ : accountMeta;
2992
+ };
2993
+ return {
2994
+ programAddress: instruction.programAddress,
2995
+ accounts: {
2996
+ controller: getNextAccount(),
2997
+ controllerAuthority: getNextAccount(),
2998
+ authority: getNextAccount(),
2999
+ priceFeed: getNextAccount(),
3000
+ oracle: getNextAccount(),
3001
+ newAuthority: getNextOptionalAccount(),
3002
+ },
3003
+ data: getUpdateOracleInstructionDataDecoder().decode(instruction.data),
3004
+ };
3005
+ }
3006
+
3007
+ const deriveIntegrationPda = async (controller, integrationHash) => {
3008
+ const addressEncoder = getAddressEncoder$1();
3009
+ const [integrationPda] = await getProgramDerivedAddress({
3010
+ programAddress: address(SVM_ALM_CONTROLLER_PROGRAM_ADDRESS),
3011
+ seeds: ["integration", addressEncoder.encode(controller), integrationHash],
3012
+ });
3013
+ return integrationPda;
3014
+ };
3015
+ const deriveControllerPda = async (id) => {
3016
+ const [controllerPda] = await getProgramDerivedAddress({
3017
+ programAddress: address(SVM_ALM_CONTROLLER_PROGRAM_ADDRESS),
3018
+ seeds: ["controller", Buffer.from(new Uint16Array([id]).buffer)],
3019
+ });
3020
+ return controllerPda;
3021
+ };
3022
+ const deriveControllerAuthorityPda = async (controller) => {
3023
+ const addressEncoder = getAddressEncoder$1();
3024
+ const [controllerAuthorityPda] = await getProgramDerivedAddress({
3025
+ programAddress: address(SVM_ALM_CONTROLLER_PROGRAM_ADDRESS),
3026
+ seeds: ["controller_authority", addressEncoder.encode(address(controller))],
3027
+ });
3028
+ return controllerAuthorityPda;
3029
+ };
3030
+ const derivePermissionPda = async (controller, authority) => {
3031
+ const addressEncoder = getAddressEncoder$1();
3032
+ const [permissionPda] = await getProgramDerivedAddress({
3033
+ programAddress: address(SVM_ALM_CONTROLLER_PROGRAM_ADDRESS),
3034
+ seeds: [
3035
+ "permission",
3036
+ addressEncoder.encode(address(controller)),
3037
+ addressEncoder.encode(address(authority)),
3038
+ ],
3039
+ });
3040
+ return permissionPda;
3041
+ };
3042
+ const deriveReservePda = async (controller, mint) => {
3043
+ const addressEncoder = getAddressEncoder$1();
3044
+ const [reservePda] = await getProgramDerivedAddress({
3045
+ programAddress: address(SVM_ALM_CONTROLLER_PROGRAM_ADDRESS),
3046
+ seeds: [
3047
+ "reserve",
3048
+ addressEncoder.encode(address(controller)),
3049
+ addressEncoder.encode(address(mint)),
3050
+ ],
3051
+ });
3052
+ return reservePda;
3053
+ };
3054
+ const deriveSplTokenSwapLpTokenPda = async (controller, lpMintAddress) => {
3055
+ const addressEncoder = getAddressEncoder$1();
3056
+ const [lpTokenPda] = await getProgramDerivedAddress({
3057
+ programAddress: address(SVM_ALM_CONTROLLER_PROGRAM_ADDRESS),
3058
+ seeds: [
3059
+ "spl-swap-lp",
3060
+ addressEncoder.encode(address(controller)),
3061
+ addressEncoder.encode(address(lpMintAddress)),
3062
+ ],
3063
+ });
3064
+ return lpTokenPda;
3065
+ };
3066
+
3067
+ export { ATOMIC_SWAP_BORROW_DISCRIMINATOR, ATOMIC_SWAP_REPAY_DISCRIMINATOR, AccountDiscriminators, AccountingAction, AccountingDirection, ControllerStatus, EMIT_EVENT_DISCRIMINATOR, INITIALIZE_CONTROLLER_DISCRIMINATOR, INITIALIZE_INTEGRATION_DISCRIMINATOR, INITIALIZE_ORACLE_DISCRIMINATOR, INITIALIZE_RESERVE_DISCRIMINATOR, IntegrationStatus, IntegrationType, MANAGE_CONTROLLER_DISCRIMINATOR, MANAGE_INTEGRATION_DISCRIMINATOR, MANAGE_PERMISSION_DISCRIMINATOR, MANAGE_RESERVE_DISCRIMINATOR, PULL_DISCRIMINATOR, PUSH_DISCRIMINATOR, PermissionStatus, REFRESH_ORACLE_DISCRIMINATOR, RESET_LZ_PUSH_IN_FLIGHT_DISCRIMINATOR, ReserveStatus, SVM_ALM_CONTROLLER_PROGRAM_ADDRESS, SYNC_DISCRIMINATOR, SYNC_RESERVE_DISCRIMINATOR, SvmAlmControllerAccount, SvmAlmControllerInstruction, UPDATE_ORACLE_DISCRIMINATOR, decodeController, decodeIntegration, decodeOracle, decodePermission, decodeReserve, deriveControllerAuthorityPda, deriveControllerPda, deriveIntegrationPda, derivePermissionPda, deriveReservePda, deriveSplTokenSwapLpTokenPda, fetchAllController, fetchAllIntegration, fetchAllMaybeController, fetchAllMaybeIntegration, fetchAllMaybeOracle, fetchAllMaybePermission, fetchAllMaybeReserve, fetchAllOracle, fetchAllPermission, fetchAllReserve, fetchController, fetchIntegration, fetchMaybeController, fetchMaybeIntegration, fetchMaybeOracle, fetchMaybePermission, fetchMaybeReserve, fetchOracle, fetchPermission, fetchReserve, getAccountDiscriminatorsCodec, getAccountDiscriminatorsDecoder, getAccountDiscriminatorsEncoder, getAccountingActionCodec, getAccountingActionDecoder, getAccountingActionEncoder, getAccountingDirectionCodec, getAccountingDirectionDecoder, getAccountingDirectionEncoder, getAccountingEventCodec, getAccountingEventDecoder, getAccountingEventEncoder, getAtomicSwapBorrowDiscriminatorBytes, getAtomicSwapBorrowInstruction, getAtomicSwapBorrowInstructionDataCodec, getAtomicSwapBorrowInstructionDataDecoder, getAtomicSwapBorrowInstructionDataEncoder, getAtomicSwapConfigCodec, getAtomicSwapConfigDecoder, getAtomicSwapConfigEncoder, getAtomicSwapRepayDiscriminatorBytes, getAtomicSwapRepayInstruction, getAtomicSwapRepayInstructionDataCodec, getAtomicSwapRepayInstructionDataDecoder, getAtomicSwapRepayInstructionDataEncoder, getAtomicSwapStateCodec, getAtomicSwapStateDecoder, getAtomicSwapStateEncoder, getCctpBridgeConfigCodec, getCctpBridgeConfigDecoder, getCctpBridgeConfigEncoder, getCctpBridgeStateCodec, getCctpBridgeStateDecoder, getCctpBridgeStateEncoder, getControllerCodec, getControllerDecoder, getControllerEncoder, getControllerSize, getControllerStatusCodec, getControllerStatusDecoder, getControllerStatusEncoder, getControllerUpdateEventCodec, getControllerUpdateEventDecoder, getControllerUpdateEventEncoder, getDepositForBurnArgsCodec, getDepositForBurnArgsDecoder, getDepositForBurnArgsEncoder, getDepositSingleTokenTypeExactAmountInArgsCodec, getDepositSingleTokenTypeExactAmountInArgsDecoder, getDepositSingleTokenTypeExactAmountInArgsEncoder, getEmitEventDiscriminatorBytes, getEmitEventInstruction, getEmitEventInstructionDataCodec, getEmitEventInstructionDataDecoder, getEmitEventInstructionDataEncoder, getFeedArgsCodec, getFeedArgsDecoder, getFeedArgsEncoder, getFeedCodec, getFeedDecoder, getFeedEncoder, getInitializeArgsCodec, getInitializeArgsDecoder, getInitializeArgsEncoder, getInitializeControllerDiscriminatorBytes, getInitializeControllerInstruction, getInitializeControllerInstructionDataCodec, getInitializeControllerInstructionDataDecoder, getInitializeControllerInstructionDataEncoder, getInitializeIntegrationDiscriminatorBytes, getInitializeIntegrationInstruction, getInitializeIntegrationInstructionDataCodec, getInitializeIntegrationInstructionDataDecoder, getInitializeIntegrationInstructionDataEncoder, getInitializeOracleDiscriminatorBytes, getInitializeOracleInstruction, getInitializeOracleInstructionDataCodec, getInitializeOracleInstructionDataDecoder, getInitializeOracleInstructionDataEncoder, getInitializeReserveDiscriminatorBytes, getInitializeReserveInstruction, getInitializeReserveInstructionDataCodec, getInitializeReserveInstructionDataDecoder, getInitializeReserveInstructionDataEncoder, getIntegrationCodec, getIntegrationConfigCodec, getIntegrationConfigDecoder, getIntegrationConfigEncoder, getIntegrationDecoder, getIntegrationEncoder, getIntegrationSize, getIntegrationStateCodec, getIntegrationStateDecoder, getIntegrationStateEncoder, getIntegrationStatusCodec, getIntegrationStatusDecoder, getIntegrationStatusEncoder, getIntegrationTypeCodec, getIntegrationTypeDecoder, getIntegrationTypeEncoder, getIntegrationUpdateEventCodec, getIntegrationUpdateEventDecoder, getIntegrationUpdateEventEncoder, getLocalTokenCodec, getLocalTokenDecoder, getLocalTokenEncoder, getLzBridgeConfigCodec, getLzBridgeConfigDecoder, getLzBridgeConfigEncoder, getLzBridgeStateCodec, getLzBridgeStateDecoder, getLzBridgeStateEncoder, getManageControllerDiscriminatorBytes, getManageControllerInstruction, getManageControllerInstructionDataCodec, getManageControllerInstructionDataDecoder, getManageControllerInstructionDataEncoder, getManageIntegrationDiscriminatorBytes, getManageIntegrationInstruction, getManageIntegrationInstructionDataCodec, getManageIntegrationInstructionDataDecoder, getManageIntegrationInstructionDataEncoder, getManagePermissionDiscriminatorBytes, getManagePermissionInstruction, getManagePermissionInstructionDataCodec, getManagePermissionInstructionDataDecoder, getManagePermissionInstructionDataEncoder, getManageReserveDiscriminatorBytes, getManageReserveInstruction, getManageReserveInstructionDataCodec, getManageReserveInstructionDataDecoder, getManageReserveInstructionDataEncoder, getOFTStoreCodec, getOFTStoreDecoder, getOFTStoreEncoder, getOftSendParamsCodec, getOftSendParamsDecoder, getOftSendParamsEncoder, getOracleCodec, getOracleDecoder, getOracleEncoder, getOracleSize, getOracleUpdateEventCodec, getOracleUpdateEventDecoder, getOracleUpdateEventEncoder, getPeerConfigCodec, getPeerConfigDecoder, getPeerConfigEncoder, getPermissionCodec, getPermissionDecoder, getPermissionEncoder, getPermissionSize, getPermissionStatusCodec, getPermissionStatusDecoder, getPermissionStatusEncoder, getPermissionUpdateEventCodec, getPermissionUpdateEventDecoder, getPermissionUpdateEventEncoder, getPullArgsCodec, getPullArgsDecoder, getPullArgsEncoder, getPullDiscriminatorBytes, getPullInstruction, getPullInstructionDataCodec, getPullInstructionDataDecoder, getPullInstructionDataEncoder, getPushArgsCodec, getPushArgsDecoder, getPushArgsEncoder, getPushDiscriminatorBytes, getPushInstruction, getPushInstructionDataCodec, getPushInstructionDataDecoder, getPushInstructionDataEncoder, getRefreshOracleDiscriminatorBytes, getRefreshOracleInstruction, getRefreshOracleInstructionDataCodec, getRefreshOracleInstructionDataDecoder, getRefreshOracleInstructionDataEncoder, getRemoteTokenMessengerCodec, getRemoteTokenMessengerDecoder, getRemoteTokenMessengerEncoder, getReserveCodec, getReserveDecoder, getReserveEncoder, getReserveSize, getReserveStatusCodec, getReserveStatusDecoder, getReserveStatusEncoder, getReserveUpdateEventCodec, getReserveUpdateEventDecoder, getReserveUpdateEventEncoder, getResetLzPushInFlightDiscriminatorBytes, getResetLzPushInFlightInstruction, getResetLzPushInFlightInstructionDataCodec, getResetLzPushInFlightInstructionDataDecoder, getResetLzPushInFlightInstructionDataEncoder, getSplTokenExternalConfigCodec, getSplTokenExternalConfigDecoder, getSplTokenExternalConfigEncoder, getSplTokenExternalStateCodec, getSplTokenExternalStateDecoder, getSplTokenExternalStateEncoder, getSplTokenSwapConfigCodec, getSplTokenSwapConfigDecoder, getSplTokenSwapConfigEncoder, getSplTokenSwapStateCodec, getSplTokenSwapStateDecoder, getSplTokenSwapStateEncoder, getSvmAlmControllerEventCodec, getSvmAlmControllerEventDecoder, getSvmAlmControllerEventEncoder, getSwapV1SubsetCodec, getSwapV1SubsetDecoder, getSwapV1SubsetEncoder, getSyncDiscriminatorBytes, getSyncInstruction, getSyncInstructionDataCodec, getSyncInstructionDataDecoder, getSyncInstructionDataEncoder, getSyncReserveDiscriminatorBytes, getSyncReserveInstruction, getSyncReserveInstructionDataCodec, getSyncReserveInstructionDataDecoder, getSyncReserveInstructionDataEncoder, getUpdateOracleDiscriminatorBytes, getUpdateOracleInstruction, getUpdateOracleInstructionDataCodec, getUpdateOracleInstructionDataDecoder, getUpdateOracleInstructionDataEncoder, getWithdrawSingleTokenTypeExactAmountOutArgsCodec, getWithdrawSingleTokenTypeExactAmountOutArgsDecoder, getWithdrawSingleTokenTypeExactAmountOutArgsEncoder, identifySvmAlmControllerInstruction, initializeArgs, integrationConfig, integrationState, isInitializeArgs, isIntegrationConfig, isIntegrationState, isPullArgs, isPushArgs, isSvmAlmControllerEvent, parseAtomicSwapBorrowInstruction, parseAtomicSwapRepayInstruction, parseEmitEventInstruction, parseInitializeControllerInstruction, parseInitializeIntegrationInstruction, parseInitializeOracleInstruction, parseInitializeReserveInstruction, parseManageControllerInstruction, parseManageIntegrationInstruction, parseManagePermissionInstruction, parseManageReserveInstruction, parsePullInstruction, parsePushInstruction, parseRefreshOracleInstruction, parseResetLzPushInFlightInstruction, parseSyncInstruction, parseSyncReserveInstruction, parseUpdateOracleInstruction, pullArgs, pushArgs, svmAlmControllerEvent };