@crypticdot/defituna-client 2.0.5 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -136,10 +136,12 @@ var AccountsType = /* @__PURE__ */ ((AccountsType2) => {
136
136
  AccountsType2[AccountsType2["SwapTickArrays"] = 0] = "SwapTickArrays";
137
137
  AccountsType2[AccountsType2["TickArrayLower"] = 1] = "TickArrayLower";
138
138
  AccountsType2[AccountsType2["TickArrayUpper"] = 2] = "TickArrayUpper";
139
- AccountsType2[AccountsType2["PoolVaultTokenA"] = 3] = "PoolVaultTokenA";
140
- AccountsType2[AccountsType2["PoolVaultTokenB"] = 4] = "PoolVaultTokenB";
141
- AccountsType2[AccountsType2["WhirlpoolOracle"] = 5] = "WhirlpoolOracle";
142
- AccountsType2[AccountsType2["Rewards"] = 6] = "Rewards";
139
+ AccountsType2[AccountsType2["SecondaryTickArrayLower"] = 3] = "SecondaryTickArrayLower";
140
+ AccountsType2[AccountsType2["SecondaryTickArrayUpper"] = 4] = "SecondaryTickArrayUpper";
141
+ AccountsType2[AccountsType2["PoolVaultTokenA"] = 5] = "PoolVaultTokenA";
142
+ AccountsType2[AccountsType2["PoolVaultTokenB"] = 6] = "PoolVaultTokenB";
143
+ AccountsType2[AccountsType2["WhirlpoolOracle"] = 7] = "WhirlpoolOracle";
144
+ AccountsType2[AccountsType2["Rewards"] = 8] = "Rewards";
143
145
  return AccountsType2;
144
146
  })(AccountsType || {});
145
147
  function getAccountsTypeEncoder() {
@@ -531,7 +533,8 @@ function getTunaPositionEncoder() {
531
533
  ["compoundedYieldB", getU64Encoder3()],
532
534
  ["flags", getU32Encoder3()],
533
535
  ["marketMaker", getMarketMakerEncoder()],
534
- ["reserved", fixEncoderSize4(getBytesEncoder4(), 61)]
536
+ ["rebalanceThresholdTicks", getU32Encoder3()],
537
+ ["reserved", fixEncoderSize4(getBytesEncoder4(), 57)]
535
538
  ]),
536
539
  (value) => ({ ...value, discriminator: TUNA_POSITION_DISCRIMINATOR })
537
540
  );
@@ -564,7 +567,8 @@ function getTunaPositionDecoder() {
564
567
  ["compoundedYieldB", getU64Decoder3()],
565
568
  ["flags", getU32Decoder3()],
566
569
  ["marketMaker", getMarketMakerDecoder()],
567
- ["reserved", fixDecoderSize4(getBytesDecoder4(), 61)]
570
+ ["rebalanceThresholdTicks", getU32Decoder3()],
571
+ ["reserved", fixDecoderSize4(getBytesDecoder4(), 57)]
568
572
  ]);
569
573
  }
570
574
  function getTunaPositionCodec() {
@@ -797,23 +801,26 @@ var TunaInstruction = /* @__PURE__ */ ((TunaInstruction2) => {
797
801
  TunaInstruction2[TunaInstruction2["OpenPositionOrca"] = 17] = "OpenPositionOrca";
798
802
  TunaInstruction2[TunaInstruction2["OpenPositionWithLiquidityFusion"] = 18] = "OpenPositionWithLiquidityFusion";
799
803
  TunaInstruction2[TunaInstruction2["OpenPositionWithLiquidityOrca"] = 19] = "OpenPositionWithLiquidityOrca";
800
- TunaInstruction2[TunaInstruction2["RemoveLiquidityFusion"] = 20] = "RemoveLiquidityFusion";
801
- TunaInstruction2[TunaInstruction2["RemoveLiquidityOrca"] = 21] = "RemoveLiquidityOrca";
802
- TunaInstruction2[TunaInstruction2["RepayBadDebt"] = 22] = "RepayBadDebt";
803
- TunaInstruction2[TunaInstruction2["RepayDebt"] = 23] = "RepayDebt";
804
- TunaInstruction2[TunaInstruction2["SetAdminAuthority"] = 24] = "SetAdminAuthority";
805
- TunaInstruction2[TunaInstruction2["SetDefaultMaxPercentageOfLeftovers"] = 25] = "SetDefaultMaxPercentageOfLeftovers";
806
- TunaInstruction2[TunaInstruction2["SetDefaultMaxSwapSlippage"] = 26] = "SetDefaultMaxSwapSlippage";
807
- TunaInstruction2[TunaInstruction2["SetDefaultOraclePriceDeviationThreshold"] = 27] = "SetDefaultOraclePriceDeviationThreshold";
808
- TunaInstruction2[TunaInstruction2["SetFeeRecipient"] = 28] = "SetFeeRecipient";
809
- TunaInstruction2[TunaInstruction2["SetLimitOrders"] = 29] = "SetLimitOrders";
810
- TunaInstruction2[TunaInstruction2["SetLiquidatorAuthority"] = 30] = "SetLiquidatorAuthority";
811
- TunaInstruction2[TunaInstruction2["SetOwnerAuthority"] = 31] = "SetOwnerAuthority";
812
- TunaInstruction2[TunaInstruction2["SetSuspendedState"] = 32] = "SetSuspendedState";
813
- TunaInstruction2[TunaInstruction2["SetTunaPositionFlags"] = 33] = "SetTunaPositionFlags";
814
- TunaInstruction2[TunaInstruction2["UpdateMarket"] = 34] = "UpdateMarket";
815
- TunaInstruction2[TunaInstruction2["UpdateVault"] = 35] = "UpdateVault";
816
- TunaInstruction2[TunaInstruction2["Withdraw"] = 36] = "Withdraw";
804
+ TunaInstruction2[TunaInstruction2["RebalancePositionFusion"] = 20] = "RebalancePositionFusion";
805
+ TunaInstruction2[TunaInstruction2["RebalancePositionOrca"] = 21] = "RebalancePositionOrca";
806
+ TunaInstruction2[TunaInstruction2["RemoveLiquidityFusion"] = 22] = "RemoveLiquidityFusion";
807
+ TunaInstruction2[TunaInstruction2["RemoveLiquidityOrca"] = 23] = "RemoveLiquidityOrca";
808
+ TunaInstruction2[TunaInstruction2["RepayBadDebt"] = 24] = "RepayBadDebt";
809
+ TunaInstruction2[TunaInstruction2["RepayDebt"] = 25] = "RepayDebt";
810
+ TunaInstruction2[TunaInstruction2["SetAdminAuthority"] = 26] = "SetAdminAuthority";
811
+ TunaInstruction2[TunaInstruction2["SetDefaultMaxPercentageOfLeftovers"] = 27] = "SetDefaultMaxPercentageOfLeftovers";
812
+ TunaInstruction2[TunaInstruction2["SetDefaultMaxSwapSlippage"] = 28] = "SetDefaultMaxSwapSlippage";
813
+ TunaInstruction2[TunaInstruction2["SetDefaultOraclePriceDeviationThreshold"] = 29] = "SetDefaultOraclePriceDeviationThreshold";
814
+ TunaInstruction2[TunaInstruction2["SetFeeRecipient"] = 30] = "SetFeeRecipient";
815
+ TunaInstruction2[TunaInstruction2["SetLimitOrders"] = 31] = "SetLimitOrders";
816
+ TunaInstruction2[TunaInstruction2["SetLiquidatorAuthority"] = 32] = "SetLiquidatorAuthority";
817
+ TunaInstruction2[TunaInstruction2["SetOwnerAuthority"] = 33] = "SetOwnerAuthority";
818
+ TunaInstruction2[TunaInstruction2["SetSuspendedState"] = 34] = "SetSuspendedState";
819
+ TunaInstruction2[TunaInstruction2["SetTunaPositionFlags"] = 35] = "SetTunaPositionFlags";
820
+ TunaInstruction2[TunaInstruction2["SetTunaPositionRebalanceThreshold"] = 36] = "SetTunaPositionRebalanceThreshold";
821
+ TunaInstruction2[TunaInstruction2["UpdateMarket"] = 37] = "UpdateMarket";
822
+ TunaInstruction2[TunaInstruction2["UpdateVault"] = 38] = "UpdateVault";
823
+ TunaInstruction2[TunaInstruction2["Withdraw"] = 39] = "Withdraw";
817
824
  return TunaInstruction2;
818
825
  })(TunaInstruction || {});
819
826
  function identifyTunaInstruction(instruction) {
@@ -998,6 +1005,24 @@ function identifyTunaInstruction(instruction) {
998
1005
  )) {
999
1006
  return 19 /* OpenPositionWithLiquidityOrca */;
1000
1007
  }
1008
+ if (containsBytes(
1009
+ data,
1010
+ fixEncoderSize6(getBytesEncoder6(), 8).encode(
1011
+ new Uint8Array([190, 86, 41, 87, 5, 231, 10, 51])
1012
+ ),
1013
+ 0
1014
+ )) {
1015
+ return 20 /* RebalancePositionFusion */;
1016
+ }
1017
+ if (containsBytes(
1018
+ data,
1019
+ fixEncoderSize6(getBytesEncoder6(), 8).encode(
1020
+ new Uint8Array([124, 212, 164, 128, 31, 143, 101, 231])
1021
+ ),
1022
+ 0
1023
+ )) {
1024
+ return 21 /* RebalancePositionOrca */;
1025
+ }
1001
1026
  if (containsBytes(
1002
1027
  data,
1003
1028
  fixEncoderSize6(getBytesEncoder6(), 8).encode(
@@ -1005,7 +1030,7 @@ function identifyTunaInstruction(instruction) {
1005
1030
  ),
1006
1031
  0
1007
1032
  )) {
1008
- return 20 /* RemoveLiquidityFusion */;
1033
+ return 22 /* RemoveLiquidityFusion */;
1009
1034
  }
1010
1035
  if (containsBytes(
1011
1036
  data,
@@ -1014,7 +1039,7 @@ function identifyTunaInstruction(instruction) {
1014
1039
  ),
1015
1040
  0
1016
1041
  )) {
1017
- return 21 /* RemoveLiquidityOrca */;
1042
+ return 23 /* RemoveLiquidityOrca */;
1018
1043
  }
1019
1044
  if (containsBytes(
1020
1045
  data,
@@ -1023,7 +1048,7 @@ function identifyTunaInstruction(instruction) {
1023
1048
  ),
1024
1049
  0
1025
1050
  )) {
1026
- return 22 /* RepayBadDebt */;
1051
+ return 24 /* RepayBadDebt */;
1027
1052
  }
1028
1053
  if (containsBytes(
1029
1054
  data,
@@ -1032,7 +1057,7 @@ function identifyTunaInstruction(instruction) {
1032
1057
  ),
1033
1058
  0
1034
1059
  )) {
1035
- return 23 /* RepayDebt */;
1060
+ return 25 /* RepayDebt */;
1036
1061
  }
1037
1062
  if (containsBytes(
1038
1063
  data,
@@ -1041,7 +1066,7 @@ function identifyTunaInstruction(instruction) {
1041
1066
  ),
1042
1067
  0
1043
1068
  )) {
1044
- return 24 /* SetAdminAuthority */;
1069
+ return 26 /* SetAdminAuthority */;
1045
1070
  }
1046
1071
  if (containsBytes(
1047
1072
  data,
@@ -1050,7 +1075,7 @@ function identifyTunaInstruction(instruction) {
1050
1075
  ),
1051
1076
  0
1052
1077
  )) {
1053
- return 25 /* SetDefaultMaxPercentageOfLeftovers */;
1078
+ return 27 /* SetDefaultMaxPercentageOfLeftovers */;
1054
1079
  }
1055
1080
  if (containsBytes(
1056
1081
  data,
@@ -1059,7 +1084,7 @@ function identifyTunaInstruction(instruction) {
1059
1084
  ),
1060
1085
  0
1061
1086
  )) {
1062
- return 26 /* SetDefaultMaxSwapSlippage */;
1087
+ return 28 /* SetDefaultMaxSwapSlippage */;
1063
1088
  }
1064
1089
  if (containsBytes(
1065
1090
  data,
@@ -1068,7 +1093,7 @@ function identifyTunaInstruction(instruction) {
1068
1093
  ),
1069
1094
  0
1070
1095
  )) {
1071
- return 27 /* SetDefaultOraclePriceDeviationThreshold */;
1096
+ return 29 /* SetDefaultOraclePriceDeviationThreshold */;
1072
1097
  }
1073
1098
  if (containsBytes(
1074
1099
  data,
@@ -1077,7 +1102,7 @@ function identifyTunaInstruction(instruction) {
1077
1102
  ),
1078
1103
  0
1079
1104
  )) {
1080
- return 28 /* SetFeeRecipient */;
1105
+ return 30 /* SetFeeRecipient */;
1081
1106
  }
1082
1107
  if (containsBytes(
1083
1108
  data,
@@ -1086,7 +1111,7 @@ function identifyTunaInstruction(instruction) {
1086
1111
  ),
1087
1112
  0
1088
1113
  )) {
1089
- return 29 /* SetLimitOrders */;
1114
+ return 31 /* SetLimitOrders */;
1090
1115
  }
1091
1116
  if (containsBytes(
1092
1117
  data,
@@ -1095,7 +1120,7 @@ function identifyTunaInstruction(instruction) {
1095
1120
  ),
1096
1121
  0
1097
1122
  )) {
1098
- return 30 /* SetLiquidatorAuthority */;
1123
+ return 32 /* SetLiquidatorAuthority */;
1099
1124
  }
1100
1125
  if (containsBytes(
1101
1126
  data,
@@ -1104,7 +1129,7 @@ function identifyTunaInstruction(instruction) {
1104
1129
  ),
1105
1130
  0
1106
1131
  )) {
1107
- return 31 /* SetOwnerAuthority */;
1132
+ return 33 /* SetOwnerAuthority */;
1108
1133
  }
1109
1134
  if (containsBytes(
1110
1135
  data,
@@ -1113,7 +1138,7 @@ function identifyTunaInstruction(instruction) {
1113
1138
  ),
1114
1139
  0
1115
1140
  )) {
1116
- return 32 /* SetSuspendedState */;
1141
+ return 34 /* SetSuspendedState */;
1117
1142
  }
1118
1143
  if (containsBytes(
1119
1144
  data,
@@ -1122,7 +1147,16 @@ function identifyTunaInstruction(instruction) {
1122
1147
  ),
1123
1148
  0
1124
1149
  )) {
1125
- return 33 /* SetTunaPositionFlags */;
1150
+ return 35 /* SetTunaPositionFlags */;
1151
+ }
1152
+ if (containsBytes(
1153
+ data,
1154
+ fixEncoderSize6(getBytesEncoder6(), 8).encode(
1155
+ new Uint8Array([108, 170, 86, 159, 171, 164, 28, 51])
1156
+ ),
1157
+ 0
1158
+ )) {
1159
+ return 36 /* SetTunaPositionRebalanceThreshold */;
1126
1160
  }
1127
1161
  if (containsBytes(
1128
1162
  data,
@@ -1131,7 +1165,7 @@ function identifyTunaInstruction(instruction) {
1131
1165
  ),
1132
1166
  0
1133
1167
  )) {
1134
- return 34 /* UpdateMarket */;
1168
+ return 37 /* UpdateMarket */;
1135
1169
  }
1136
1170
  if (containsBytes(
1137
1171
  data,
@@ -1140,7 +1174,7 @@ function identifyTunaInstruction(instruction) {
1140
1174
  ),
1141
1175
  0
1142
1176
  )) {
1143
- return 35 /* UpdateVault */;
1177
+ return 38 /* UpdateVault */;
1144
1178
  }
1145
1179
  if (containsBytes(
1146
1180
  data,
@@ -1149,7 +1183,7 @@ function identifyTunaInstruction(instruction) {
1149
1183
  ),
1150
1184
  0
1151
1185
  )) {
1152
- return 36 /* Withdraw */;
1186
+ return 39 /* Withdraw */;
1153
1187
  }
1154
1188
  throw new Error(
1155
1189
  "The provided instruction could not be identified as a tuna instruction."
@@ -1160,34 +1194,34 @@ function identifyTunaInstruction(instruction) {
1160
1194
  var TUNA_ERROR__AMOUNT_SLIPPAGE_EXCEEDED = 6e3;
1161
1195
  var TUNA_ERROR__BAD_DEBT = 6001;
1162
1196
  var TUNA_ERROR__INVALID_REMAINING_ACCOUNTS_LENGTH = 6002;
1163
- var TUNA_ERROR__INVALID_TICK_ARRAY_ACCOUNTS = 6003;
1164
- var TUNA_ERROR__INVALID_ACCOUNT_OWNER = 6004;
1165
- var TUNA_ERROR__INVALID_INSTRUCTION_ARGUMENTS = 6005;
1166
- var TUNA_ERROR__INVALID_MARKET_MAKER = 6006;
1167
- var TUNA_ERROR__INVALID_SQRT_PRICE_LIMIT_DIRECTION = 6007;
1168
- var TUNA_ERROR__INVALID_TICK_ARRAY_SEQUENCE = 6008;
1169
- var TUNA_ERROR__INSUFFICIENT_LIQUIDITY = 6009;
1170
- var TUNA_ERROR__INTEREST_RATE_IS_OUT_OF_RANGE = 6010;
1171
- var TUNA_ERROR__LEVERAGE_IS_OUT_OF_RANGE = 6011;
1172
- var TUNA_ERROR__LEFTOVERS_EXCEEDED = 6012;
1173
- var TUNA_ERROR__LIMIT_ORDER_EXECUTION_FEE_IS_OUT_OF_RANGE = 6013;
1174
- var TUNA_ERROR__LIQUIDATION_FEE_IS_OUT_OF_RANGE = 6014;
1175
- var TUNA_ERROR__LIQUIDATION_THRESHOLD_IS_OUT_OF_RANGE = 6015;
1176
- var TUNA_ERROR__LIQUIDITY_ZERO = 6016;
1177
- var TUNA_ERROR__MARKET_DISABLED = 6017;
1178
- var TUNA_ERROR__MARKET_DEBT_LIMIT_EXCEEDED = 6018;
1179
- var TUNA_ERROR__MATH_OVERFLOW = 6019;
1180
- var TUNA_ERROR__MATH_UNDERFLOW = 6020;
1181
- var TUNA_ERROR__NO_EXTRA_ACCOUNTS_FOR_TRANSFER_HOOK = 6021;
1182
- var TUNA_ERROR__ORACLE_STALE_PRICE = 6022;
1183
- var TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_EXCEEDED = 6023;
1184
- var TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_OUT_OF_RANGE = 6024;
1185
- var TUNA_ERROR__PARTIAL_FILL_ERROR = 6025;
1186
- var TUNA_ERROR__POSITION_IS_HEALTHY = 6026;
1187
- var TUNA_ERROR__POSITION_IS_LIQUIDATED = 6027;
1188
- var TUNA_ERROR__POSITION_IS_UNHEALTHY = 6028;
1189
- var TUNA_ERROR__POSITION_NOT_EMPTY = 6029;
1190
- var TUNA_ERROR__PROTOCOL_FEE_IS_OUT_OF_RANGE = 6030;
1197
+ var TUNA_ERROR__INVALID_ACCOUNT_OWNER = 6003;
1198
+ var TUNA_ERROR__INVALID_INSTRUCTION_ARGUMENTS = 6004;
1199
+ var TUNA_ERROR__INVALID_MARKET_MAKER = 6005;
1200
+ var TUNA_ERROR__INVALID_SQRT_PRICE_LIMIT_DIRECTION = 6006;
1201
+ var TUNA_ERROR__INVALID_TICK_ARRAY_SEQUENCE = 6007;
1202
+ var TUNA_ERROR__INSUFFICIENT_LIQUIDITY = 6008;
1203
+ var TUNA_ERROR__INTEREST_RATE_IS_OUT_OF_RANGE = 6009;
1204
+ var TUNA_ERROR__LEVERAGE_IS_OUT_OF_RANGE = 6010;
1205
+ var TUNA_ERROR__LEFTOVERS_EXCEEDED = 6011;
1206
+ var TUNA_ERROR__LIMIT_ORDER_EXECUTION_FEE_IS_OUT_OF_RANGE = 6012;
1207
+ var TUNA_ERROR__LIQUIDATION_FEE_IS_OUT_OF_RANGE = 6013;
1208
+ var TUNA_ERROR__LIQUIDATION_THRESHOLD_IS_OUT_OF_RANGE = 6014;
1209
+ var TUNA_ERROR__LIQUIDITY_ZERO = 6015;
1210
+ var TUNA_ERROR__MARKET_DISABLED = 6016;
1211
+ var TUNA_ERROR__MARKET_DEBT_LIMIT_EXCEEDED = 6017;
1212
+ var TUNA_ERROR__MATH_OVERFLOW = 6018;
1213
+ var TUNA_ERROR__MATH_UNDERFLOW = 6019;
1214
+ var TUNA_ERROR__NO_EXTRA_ACCOUNTS_FOR_TRANSFER_HOOK = 6020;
1215
+ var TUNA_ERROR__ORACLE_STALE_PRICE = 6021;
1216
+ var TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_EXCEEDED = 6022;
1217
+ var TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_OUT_OF_RANGE = 6023;
1218
+ var TUNA_ERROR__PARTIAL_FILL_ERROR = 6024;
1219
+ var TUNA_ERROR__POSITION_IS_HEALTHY = 6025;
1220
+ var TUNA_ERROR__POSITION_IS_LIQUIDATED = 6026;
1221
+ var TUNA_ERROR__POSITION_IS_UNHEALTHY = 6027;
1222
+ var TUNA_ERROR__POSITION_NOT_EMPTY = 6028;
1223
+ var TUNA_ERROR__PROTOCOL_FEE_IS_OUT_OF_RANGE = 6029;
1224
+ var TUNA_ERROR__REBALANCE_CONDITIONS_NOT_MET = 6030;
1191
1225
  var TUNA_ERROR__REMAINING_ACCOUNTS_DUPLICATED_ACCOUNTS_TYPE = 6031;
1192
1226
  var TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE = 6032;
1193
1227
  var TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE_LENGTH = 6033;
@@ -1199,59 +1233,60 @@ var TUNA_ERROR__SUPPLY_LIMIT_EXCEEDED = 6038;
1199
1233
  var TUNA_ERROR__SUSPENDED = 6039;
1200
1234
  var TUNA_ERROR__SWAP_SLIPPAGE_EXCEEDED = 6040;
1201
1235
  var TUNA_ERROR__SWAP_SLIPPAGE_IS_OUT_OF_RANGE = 6041;
1202
- var TUNA_ERROR__TICK_INDEX_OF_BOUNDS = 6042;
1203
- var TUNA_ERROR__TRANSFER_FEE_CALCULATION_ERROR = 6043;
1204
- var TUNA_ERROR__TYPE_CAST_OVERFLOW = 6044;
1205
- var TUNA_ERROR__UNEXPECTED_VALUE = 6045;
1206
- var TUNA_ERROR__UNSUPPORTED_TOKEN_MINT = 6046;
1207
- var TUNA_ERROR__VAULT_NOT_INITIALIZED = 6047;
1208
- var TUNA_ERROR__WITHDRAW_REQUEST_EXCEEDS_USER_BALANCE = 6048;
1209
- var TUNA_ERROR__ZERO_PRICE_RANGE = 6049;
1210
- var TUNA_ERROR__ZERO_TRADABLE_AMOUNT = 6050;
1211
- var TUNA_ERROR__ZERO_YIELD = 6051;
1212
- var TUNA_ERROR__RAYDIUM_INVALID_FIRST_TICK_ARRAY_ACCOUNT = 6052;
1213
- var TUNA_ERROR__RAYDIUM_INVALID_TICK_ARRAY = 6053;
1214
- var TUNA_ERROR__RAYDIUM_INVAILD_TICK_INDEX = 6054;
1215
- var TUNA_ERROR__RAYDIUM_MAX_TOKEN_OVERFLOW = 6055;
1216
- var TUNA_ERROR__RAYDIUM_NOT_ENOUGH_TICK_ARRAY_ACCOUNT = 6056;
1217
- var TUNA_ERROR__RAYDIUM_SQRT_PRICE_LIMIT_OVERFLOW = 6057;
1218
- var TUNA_ERROR__RAYDIUM_ZERO_AMOUNT_SPECIFIED = 6058;
1219
- var TUNA_ERROR__UNABLE_TO_LOAD_ACCOUNT_DATA = 6059;
1220
- var TUNA_ERROR__UNABLE_TO_DESERIALIZE_ACCOUNT_DATA = 6060;
1236
+ var TUNA_ERROR__SWAP_TO_POSITION_RATIO_ESTIMATION_FAILED = 6042;
1237
+ var TUNA_ERROR__SWAP_QUOTE_NOT_EQUAL_TO_ACTUAL_SWAP_AMOUNT = 6043;
1238
+ var TUNA_ERROR__TICK_INDEX_OF_BOUNDS = 6044;
1239
+ var TUNA_ERROR__TRANSFER_FEE_CALCULATION_ERROR = 6045;
1240
+ var TUNA_ERROR__TYPE_CAST_OVERFLOW = 6046;
1241
+ var TUNA_ERROR__UNABLE_TO_LOAD_ACCOUNT_DATA = 6047;
1242
+ var TUNA_ERROR__UNABLE_TO_DESERIALIZE_ACCOUNT_DATA = 6048;
1243
+ var TUNA_ERROR__UNEXPECTED_VALUE = 6049;
1244
+ var TUNA_ERROR__UNSUPPORTED_TOKEN_MINT = 6050;
1245
+ var TUNA_ERROR__VAULT_NOT_INITIALIZED = 6051;
1246
+ var TUNA_ERROR__WITHDRAW_REQUEST_EXCEEDS_USER_BALANCE = 6052;
1247
+ var TUNA_ERROR__ZERO_PRICE_RANGE = 6053;
1248
+ var TUNA_ERROR__ZERO_TRADABLE_AMOUNT = 6054;
1249
+ var TUNA_ERROR__ZERO_YIELD = 6055;
1250
+ var TUNA_ERROR__RAYDIUM_INVALID_FIRST_TICK_ARRAY_ACCOUNT = 6056;
1251
+ var TUNA_ERROR__RAYDIUM_INVALID_TICK_ARRAY = 6057;
1252
+ var TUNA_ERROR__RAYDIUM_INVAILD_TICK_INDEX = 6058;
1253
+ var TUNA_ERROR__RAYDIUM_MAX_TOKEN_OVERFLOW = 6059;
1254
+ var TUNA_ERROR__RAYDIUM_NOT_ENOUGH_TICK_ARRAY_ACCOUNT = 6060;
1255
+ var TUNA_ERROR__RAYDIUM_SQRT_PRICE_LIMIT_OVERFLOW = 6061;
1256
+ var TUNA_ERROR__RAYDIUM_ZERO_AMOUNT_SPECIFIED = 6062;
1221
1257
  var tunaErrorMessages;
1222
1258
  if (process.env.NODE_ENV !== "production") {
1223
1259
  tunaErrorMessages = {
1224
- [TUNA_ERROR__AMOUNT_SLIPPAGE_EXCEEDED]: `AmountSlippageExceeded`,
1225
- [TUNA_ERROR__BAD_DEBT]: `BadDebt`,
1226
- [TUNA_ERROR__INSUFFICIENT_LIQUIDITY]: `InsufficientLiquidity`,
1227
- [TUNA_ERROR__INTEREST_RATE_IS_OUT_OF_RANGE]: `InterestRateIsOutOfRange`,
1228
- [TUNA_ERROR__INVALID_ACCOUNT_OWNER]: `InvalidAccountOwner`,
1229
- [TUNA_ERROR__INVALID_INSTRUCTION_ARGUMENTS]: `InvalidInstructionArguments`,
1230
- [TUNA_ERROR__INVALID_MARKET_MAKER]: `InvalidMarketMaker`,
1231
- [TUNA_ERROR__INVALID_REMAINING_ACCOUNTS_LENGTH]: `InvalidRemainingAccountsLength`,
1260
+ [TUNA_ERROR__AMOUNT_SLIPPAGE_EXCEEDED]: `Amount slippage exceeded`,
1261
+ [TUNA_ERROR__BAD_DEBT]: `Bad debt is not allowed for the executed instruction`,
1262
+ [TUNA_ERROR__INSUFFICIENT_LIQUIDITY]: `Insufficient liquidity`,
1263
+ [TUNA_ERROR__INTEREST_RATE_IS_OUT_OF_RANGE]: `Interest rate is out of range`,
1264
+ [TUNA_ERROR__INVALID_ACCOUNT_OWNER]: `Invalid account owner`,
1265
+ [TUNA_ERROR__INVALID_INSTRUCTION_ARGUMENTS]: `Invalid instruction arguments`,
1266
+ [TUNA_ERROR__INVALID_MARKET_MAKER]: `Invalid market maker`,
1267
+ [TUNA_ERROR__INVALID_REMAINING_ACCOUNTS_LENGTH]: `Invalid number of remaining accounts`,
1232
1268
  [TUNA_ERROR__INVALID_SQRT_PRICE_LIMIT_DIRECTION]: `Provided SqrtPriceLimit not in the same direction as the swap.`,
1233
- [TUNA_ERROR__INVALID_TICK_ARRAY_ACCOUNTS]: `InvalidAccounts`,
1234
- [TUNA_ERROR__INVALID_TICK_ARRAY_SEQUENCE]: `InvalidTickArraySequence`,
1235
- [TUNA_ERROR__LEFTOVERS_EXCEEDED]: `LeftoversExceeded`,
1236
- [TUNA_ERROR__LEVERAGE_IS_OUT_OF_RANGE]: `LeverageIsOutOfRange`,
1237
- [TUNA_ERROR__LIMIT_ORDER_EXECUTION_FEE_IS_OUT_OF_RANGE]: `LimitOrderExecutionFeeIsOutOfRange`,
1238
- [TUNA_ERROR__LIQUIDATION_FEE_IS_OUT_OF_RANGE]: `LiquidationFeeIsOutOfRange`,
1239
- [TUNA_ERROR__LIQUIDATION_THRESHOLD_IS_OUT_OF_RANGE]: `LiquidationThresholdIsOutOfRange`,
1269
+ [TUNA_ERROR__INVALID_TICK_ARRAY_SEQUENCE]: `Invalid tick array sequence provided for instruction`,
1270
+ [TUNA_ERROR__LEFTOVERS_EXCEEDED]: `Leftovers percentage exceeded the maximum allowed value`,
1271
+ [TUNA_ERROR__LEVERAGE_IS_OUT_OF_RANGE]: `Leverage is out or range`,
1272
+ [TUNA_ERROR__LIMIT_ORDER_EXECUTION_FEE_IS_OUT_OF_RANGE]: `Limit order execution fee is out of range`,
1273
+ [TUNA_ERROR__LIQUIDATION_FEE_IS_OUT_OF_RANGE]: `Liquidation fee is out of range`,
1274
+ [TUNA_ERROR__LIQUIDATION_THRESHOLD_IS_OUT_OF_RANGE]: `Liquidation threshold is out of range`,
1240
1275
  [TUNA_ERROR__LIQUIDITY_ZERO]: `Liquidity amount must be greater than zero.`,
1241
- [TUNA_ERROR__MARKET_DEBT_LIMIT_EXCEEDED]: `MarketDebtLimitExceeded`,
1242
- [TUNA_ERROR__MARKET_DISABLED]: `MarketDisabled`,
1243
- [TUNA_ERROR__MATH_OVERFLOW]: `MathOverflow`,
1244
- [TUNA_ERROR__MATH_UNDERFLOW]: `MathUnderflow`,
1276
+ [TUNA_ERROR__MARKET_DEBT_LIMIT_EXCEEDED]: `Exceed the maximum allowed debt for the market`,
1277
+ [TUNA_ERROR__MARKET_DISABLED]: `Market is disabled`,
1278
+ [TUNA_ERROR__MATH_OVERFLOW]: `Math overflow`,
1279
+ [TUNA_ERROR__MATH_UNDERFLOW]: `Math underflow`,
1245
1280
  [TUNA_ERROR__NO_EXTRA_ACCOUNTS_FOR_TRANSFER_HOOK]: `Unable to call transfer hook without extra accounts`,
1246
1281
  [TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_EXCEEDED]: `OraclePriceDeviationThresholdExceeded`,
1247
1282
  [TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_OUT_OF_RANGE]: `OraclePriceDeviationThresholdOutOfRange`,
1248
- [TUNA_ERROR__ORACLE_STALE_PRICE]: `OracleStalePrice`,
1283
+ [TUNA_ERROR__ORACLE_STALE_PRICE]: `Oracle price is stale`,
1249
1284
  [TUNA_ERROR__PARTIAL_FILL_ERROR]: `Trade resulted in partial fill`,
1250
- [TUNA_ERROR__POSITION_IS_HEALTHY]: `PositionIsHealthy`,
1251
- [TUNA_ERROR__POSITION_IS_LIQUIDATED]: `PositionIsLiquidated`,
1252
- [TUNA_ERROR__POSITION_IS_UNHEALTHY]: `PositionIsUnhealthy`,
1253
- [TUNA_ERROR__POSITION_NOT_EMPTY]: `PositionNotEmpty`,
1254
- [TUNA_ERROR__PROTOCOL_FEE_IS_OUT_OF_RANGE]: `ProtocolFeeIsOutOfRange`,
1285
+ [TUNA_ERROR__POSITION_IS_HEALTHY]: `Position is healthy`,
1286
+ [TUNA_ERROR__POSITION_IS_LIQUIDATED]: `Position is already liquidated`,
1287
+ [TUNA_ERROR__POSITION_IS_UNHEALTHY]: `Position is unhealthy`,
1288
+ [TUNA_ERROR__POSITION_NOT_EMPTY]: `Position is not empty`,
1289
+ [TUNA_ERROR__PROTOCOL_FEE_IS_OUT_OF_RANGE]: `Protocol fee is out of range`,
1255
1290
  [TUNA_ERROR__RAYDIUM_INVAILD_TICK_INDEX]: `RaydiumInvaildTickIndex`,
1256
1291
  [TUNA_ERROR__RAYDIUM_INVALID_FIRST_TICK_ARRAY_ACCOUNT]: `RaydiumInvalidFirstTickArrayAccount`,
1257
1292
  [TUNA_ERROR__RAYDIUM_INVALID_TICK_ARRAY]: `RaydiumInvalidTickArray`,
@@ -1259,29 +1294,32 @@ if (process.env.NODE_ENV !== "production") {
1259
1294
  [TUNA_ERROR__RAYDIUM_NOT_ENOUGH_TICK_ARRAY_ACCOUNT]: `RaydiumNotEnoughTickArrayAccount`,
1260
1295
  [TUNA_ERROR__RAYDIUM_SQRT_PRICE_LIMIT_OVERFLOW]: `RaydiumSqrtPriceLimitOverflow`,
1261
1296
  [TUNA_ERROR__RAYDIUM_ZERO_AMOUNT_SPECIFIED]: `RaydiumZeroAmountSpecified`,
1297
+ [TUNA_ERROR__REBALANCE_CONDITIONS_NOT_MET]: `Rebalance conditions are not met`,
1262
1298
  [TUNA_ERROR__REMAINING_ACCOUNTS_DUPLICATED_ACCOUNTS_TYPE]: `Same accounts type is provided more than once`,
1263
1299
  [TUNA_ERROR__REMAINING_ACCOUNTS_INSUFFICIENT]: `Insufficient remaining accounts`,
1264
1300
  [TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE]: `Invalid remaining accounts`,
1265
1301
  [TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE_LENGTH]: `Invalid remaining accounts slice length`,
1266
1302
  [TUNA_ERROR__REQUIRED_REMAINING_ACCOUNT_NOT_PROVIDED]: `Required remaining account is not provided`,
1267
- [TUNA_ERROR__SOLVER_FAILED_TO_FIND_ROOT]: `SolverFailedToFindRoot`,
1268
- [TUNA_ERROR__SQRT_PRICE_OUT_OF_BOUNDS]: `SqrtPriceOutOfBounds`,
1269
- [TUNA_ERROR__SUPPLY_LIMIT_EXCEEDED]: `SupplyLimitExceeded`,
1270
- [TUNA_ERROR__SUSPENDED]: `Suspended`,
1271
- [TUNA_ERROR__SWAP_SLIPPAGE_EXCEEDED]: `SwapSlippageExceeded`,
1272
- [TUNA_ERROR__SWAP_SLIPPAGE_IS_OUT_OF_RANGE]: `SwapSlippageIsOutOfRange`,
1273
- [TUNA_ERROR__TICK_INDEX_OF_BOUNDS]: `TickIndexOfBounds`,
1303
+ [TUNA_ERROR__SOLVER_FAILED_TO_FIND_ROOT]: `Swap equation solver failed to t find the root`,
1304
+ [TUNA_ERROR__SQRT_PRICE_OUT_OF_BOUNDS]: `Provided sqrt price out of bounds`,
1305
+ [TUNA_ERROR__SUPPLY_LIMIT_EXCEEDED]: `Lending vault supply limit exceeded`,
1306
+ [TUNA_ERROR__SUSPENDED]: `Instruction is suspended`,
1307
+ [TUNA_ERROR__SWAP_QUOTE_NOT_EQUAL_TO_ACTUAL_SWAP_AMOUNT]: `Swap quote amount is not equal to the actual swap amount`,
1308
+ [TUNA_ERROR__SWAP_SLIPPAGE_EXCEEDED]: `Maximum allowed swap slippage is exceeded`,
1309
+ [TUNA_ERROR__SWAP_SLIPPAGE_IS_OUT_OF_RANGE]: `Provided swap slippage value is out of range`,
1310
+ [TUNA_ERROR__SWAP_TO_POSITION_RATIO_ESTIMATION_FAILED]: `Swap to position ratio estimation failed`,
1311
+ [TUNA_ERROR__TICK_INDEX_OF_BOUNDS]: `Tick index is out of bounds`,
1274
1312
  [TUNA_ERROR__TRANSFER_FEE_CALCULATION_ERROR]: `Transfer fee calculation failed`,
1275
- [TUNA_ERROR__TYPE_CAST_OVERFLOW]: `TypeCastOverflow`,
1276
- [TUNA_ERROR__UNABLE_TO_DESERIALIZE_ACCOUNT_DATA]: `UnableToDeserializeAccountData`,
1277
- [TUNA_ERROR__UNABLE_TO_LOAD_ACCOUNT_DATA]: `UnableToLoadAccountData`,
1278
- [TUNA_ERROR__UNEXPECTED_VALUE]: `UnexpectedValue`,
1313
+ [TUNA_ERROR__TYPE_CAST_OVERFLOW]: `Type cast overflow`,
1314
+ [TUNA_ERROR__UNABLE_TO_DESERIALIZE_ACCOUNT_DATA]: `Unable to deserialize the account data`,
1315
+ [TUNA_ERROR__UNABLE_TO_LOAD_ACCOUNT_DATA]: `Unable to load the account data`,
1316
+ [TUNA_ERROR__UNEXPECTED_VALUE]: `Unexpected value`,
1279
1317
  [TUNA_ERROR__UNSUPPORTED_TOKEN_MINT]: `Token mint has unsupported attributes`,
1280
- [TUNA_ERROR__VAULT_NOT_INITIALIZED]: `VaultNotInitialized`,
1281
- [TUNA_ERROR__WITHDRAW_REQUEST_EXCEEDS_USER_BALANCE]: `WithdrawRequestExceedsUserBalance`,
1282
- [TUNA_ERROR__ZERO_PRICE_RANGE]: `ZeroPriceRange`,
1318
+ [TUNA_ERROR__VAULT_NOT_INITIALIZED]: `Lending vault is not initialized`,
1319
+ [TUNA_ERROR__WITHDRAW_REQUEST_EXCEEDS_USER_BALANCE]: `Withdraw request the exceeds user balance`,
1320
+ [TUNA_ERROR__ZERO_PRICE_RANGE]: `Zero price range: the lower price is equal to upper price)`,
1283
1321
  [TUNA_ERROR__ZERO_TRADABLE_AMOUNT]: `There are no tradable amount to swap.`,
1284
- [TUNA_ERROR__ZERO_YIELD]: `ZeroYield`
1322
+ [TUNA_ERROR__ZERO_YIELD]: `Collected yield is zero`
1285
1323
  };
1286
1324
  }
1287
1325
  function getTunaErrorMessage(code) {
@@ -4585,7 +4623,7 @@ function parseOpenPositionWithLiquidityOrcaInstruction(instruction) {
4585
4623
  };
4586
4624
  }
4587
4625
 
4588
- // src/generated/instructions/removeLiquidityFusion.ts
4626
+ // src/generated/instructions/rebalancePositionFusion.ts
4589
4627
  import {
4590
4628
  combineCodec as combineCodec31,
4591
4629
  fixDecoderSize as fixDecoderSize26,
@@ -4594,64 +4632,48 @@ import {
4594
4632
  getBytesEncoder as getBytesEncoder27,
4595
4633
  getStructDecoder as getStructDecoder28,
4596
4634
  getStructEncoder as getStructEncoder28,
4597
- getU32Decoder as getU32Decoder13,
4598
- getU32Encoder as getU32Encoder13,
4599
- getU64Decoder as getU64Decoder12,
4600
- getU64Encoder as getU64Encoder12,
4601
- getU8Decoder as getU8Decoder5,
4602
- getU8Encoder as getU8Encoder5,
4603
4635
  transformEncoder as transformEncoder26
4604
4636
  } from "@solana/kit";
4605
- var REMOVE_LIQUIDITY_FUSION_DISCRIMINATOR = new Uint8Array([
4606
- 175,
4607
- 74,
4608
- 205,
4609
- 238,
4610
- 4,
4611
- 123,
4612
- 166,
4613
- 35
4637
+ var REBALANCE_POSITION_FUSION_DISCRIMINATOR = new Uint8Array([
4638
+ 190,
4639
+ 86,
4640
+ 41,
4641
+ 87,
4642
+ 5,
4643
+ 231,
4644
+ 10,
4645
+ 51
4614
4646
  ]);
4615
- function getRemoveLiquidityFusionDiscriminatorBytes() {
4647
+ function getRebalancePositionFusionDiscriminatorBytes() {
4616
4648
  return fixEncoderSize27(getBytesEncoder27(), 8).encode(
4617
- REMOVE_LIQUIDITY_FUSION_DISCRIMINATOR
4649
+ REBALANCE_POSITION_FUSION_DISCRIMINATOR
4618
4650
  );
4619
4651
  }
4620
- function getRemoveLiquidityFusionInstructionDataEncoder() {
4652
+ function getRebalancePositionFusionInstructionDataEncoder() {
4621
4653
  return transformEncoder26(
4622
4654
  getStructEncoder28([
4623
4655
  ["discriminator", fixEncoderSize27(getBytesEncoder27(), 8)],
4624
- ["withdrawPercent", getU32Encoder13()],
4625
- ["swapToToken", getU8Encoder5()],
4626
- ["minRemovedAmountA", getU64Encoder12()],
4627
- ["minRemovedAmountB", getU64Encoder12()],
4628
- ["maxSwapSlippage", getU32Encoder13()],
4629
4656
  ["remainingAccountsInfo", getRemainingAccountsInfoEncoder()]
4630
4657
  ]),
4631
4658
  (value) => ({
4632
4659
  ...value,
4633
- discriminator: REMOVE_LIQUIDITY_FUSION_DISCRIMINATOR
4660
+ discriminator: REBALANCE_POSITION_FUSION_DISCRIMINATOR
4634
4661
  })
4635
4662
  );
4636
4663
  }
4637
- function getRemoveLiquidityFusionInstructionDataDecoder() {
4664
+ function getRebalancePositionFusionInstructionDataDecoder() {
4638
4665
  return getStructDecoder28([
4639
4666
  ["discriminator", fixDecoderSize26(getBytesDecoder26(), 8)],
4640
- ["withdrawPercent", getU32Decoder13()],
4641
- ["swapToToken", getU8Decoder5()],
4642
- ["minRemovedAmountA", getU64Decoder12()],
4643
- ["minRemovedAmountB", getU64Decoder12()],
4644
- ["maxSwapSlippage", getU32Decoder13()],
4645
4667
  ["remainingAccountsInfo", getRemainingAccountsInfoDecoder()]
4646
4668
  ]);
4647
4669
  }
4648
- function getRemoveLiquidityFusionInstructionDataCodec() {
4670
+ function getRebalancePositionFusionInstructionDataCodec() {
4649
4671
  return combineCodec31(
4650
- getRemoveLiquidityFusionInstructionDataEncoder(),
4651
- getRemoveLiquidityFusionInstructionDataDecoder()
4672
+ getRebalancePositionFusionInstructionDataEncoder(),
4673
+ getRebalancePositionFusionInstructionDataDecoder()
4652
4674
  );
4653
4675
  }
4654
- function getRemoveLiquidityFusionInstruction(input, config) {
4676
+ function getRebalancePositionFusionInstruction(input, config) {
4655
4677
  const programAddress = config?.programAddress ?? TUNA_PROGRAM_ADDRESS;
4656
4678
  const originalAccounts = {
4657
4679
  authority: { value: input.authority ?? null, isWritable: true },
@@ -4663,8 +4685,6 @@ function getRemoveLiquidityFusionInstruction(input, config) {
4663
4685
  tokenProgramB: { value: input.tokenProgramB ?? null, isWritable: false },
4664
4686
  vaultA: { value: input.vaultA ?? null, isWritable: true },
4665
4687
  vaultB: { value: input.vaultB ?? null, isWritable: true },
4666
- vaultAAta: { value: input.vaultAAta ?? null, isWritable: true },
4667
- vaultBAta: { value: input.vaultBAta ?? null, isWritable: true },
4668
4688
  tunaPosition: { value: input.tunaPosition ?? null, isWritable: true },
4669
4689
  tunaPositionAta: { value: input.tunaPositionAta ?? null, isWritable: true },
4670
4690
  tunaPositionAtaA: {
@@ -4675,12 +4695,12 @@ function getRemoveLiquidityFusionInstruction(input, config) {
4675
4695
  value: input.tunaPositionAtaB ?? null,
4676
4696
  isWritable: true
4677
4697
  },
4678
- tunaPositionOwnerAtaA: {
4679
- value: input.tunaPositionOwnerAtaA ?? null,
4698
+ feeRecipientAtaA: {
4699
+ value: input.feeRecipientAtaA ?? null,
4680
4700
  isWritable: true
4681
4701
  },
4682
- tunaPositionOwnerAtaB: {
4683
- value: input.tunaPositionOwnerAtaB ?? null,
4702
+ feeRecipientAtaB: {
4703
+ value: input.feeRecipientAtaB ?? null,
4684
4704
  isWritable: true
4685
4705
  },
4686
4706
  pythOraclePriceFeedA: {
@@ -4713,14 +4733,12 @@ function getRemoveLiquidityFusionInstruction(input, config) {
4713
4733
  getAccountMeta(accounts.tokenProgramB),
4714
4734
  getAccountMeta(accounts.vaultA),
4715
4735
  getAccountMeta(accounts.vaultB),
4716
- getAccountMeta(accounts.vaultAAta),
4717
- getAccountMeta(accounts.vaultBAta),
4718
4736
  getAccountMeta(accounts.tunaPosition),
4719
4737
  getAccountMeta(accounts.tunaPositionAta),
4720
4738
  getAccountMeta(accounts.tunaPositionAtaA),
4721
4739
  getAccountMeta(accounts.tunaPositionAtaB),
4722
- getAccountMeta(accounts.tunaPositionOwnerAtaA),
4723
- getAccountMeta(accounts.tunaPositionOwnerAtaB),
4740
+ getAccountMeta(accounts.feeRecipientAtaA),
4741
+ getAccountMeta(accounts.feeRecipientAtaB),
4724
4742
  getAccountMeta(accounts.pythOraclePriceFeedA),
4725
4743
  getAccountMeta(accounts.pythOraclePriceFeedB),
4726
4744
  getAccountMeta(accounts.fusionammProgram),
@@ -4729,14 +4747,14 @@ function getRemoveLiquidityFusionInstruction(input, config) {
4729
4747
  getAccountMeta(accounts.memoProgram)
4730
4748
  ],
4731
4749
  programAddress,
4732
- data: getRemoveLiquidityFusionInstructionDataEncoder().encode(
4750
+ data: getRebalancePositionFusionInstructionDataEncoder().encode(
4733
4751
  args
4734
4752
  )
4735
4753
  };
4736
4754
  return instruction;
4737
4755
  }
4738
- function parseRemoveLiquidityFusionInstruction(instruction) {
4739
- if (instruction.accounts.length < 23) {
4756
+ function parseRebalancePositionFusionInstruction(instruction) {
4757
+ if (instruction.accounts.length < 21) {
4740
4758
  throw new Error("Not enough accounts");
4741
4759
  }
4742
4760
  let accountIndex = 0;
@@ -4757,14 +4775,12 @@ function parseRemoveLiquidityFusionInstruction(instruction) {
4757
4775
  tokenProgramB: getNextAccount(),
4758
4776
  vaultA: getNextAccount(),
4759
4777
  vaultB: getNextAccount(),
4760
- vaultAAta: getNextAccount(),
4761
- vaultBAta: getNextAccount(),
4762
4778
  tunaPosition: getNextAccount(),
4763
4779
  tunaPositionAta: getNextAccount(),
4764
4780
  tunaPositionAtaA: getNextAccount(),
4765
4781
  tunaPositionAtaB: getNextAccount(),
4766
- tunaPositionOwnerAtaA: getNextAccount(),
4767
- tunaPositionOwnerAtaB: getNextAccount(),
4782
+ feeRecipientAtaA: getNextAccount(),
4783
+ feeRecipientAtaB: getNextAccount(),
4768
4784
  pythOraclePriceFeedA: getNextAccount(),
4769
4785
  pythOraclePriceFeedB: getNextAccount(),
4770
4786
  fusionammProgram: getNextAccount(),
@@ -4772,13 +4788,13 @@ function parseRemoveLiquidityFusionInstruction(instruction) {
4772
4788
  fusionPosition: getNextAccount(),
4773
4789
  memoProgram: getNextAccount()
4774
4790
  },
4775
- data: getRemoveLiquidityFusionInstructionDataDecoder().decode(
4791
+ data: getRebalancePositionFusionInstructionDataDecoder().decode(
4776
4792
  instruction.data
4777
4793
  )
4778
4794
  };
4779
4795
  }
4780
4796
 
4781
- // src/generated/instructions/removeLiquidityOrca.ts
4797
+ // src/generated/instructions/rebalancePositionOrca.ts
4782
4798
  import {
4783
4799
  combineCodec as combineCodec32,
4784
4800
  fixDecoderSize as fixDecoderSize27,
@@ -4787,75 +4803,57 @@ import {
4787
4803
  getBytesEncoder as getBytesEncoder28,
4788
4804
  getStructDecoder as getStructDecoder29,
4789
4805
  getStructEncoder as getStructEncoder29,
4790
- getU32Decoder as getU32Decoder14,
4791
- getU32Encoder as getU32Encoder14,
4792
- getU64Decoder as getU64Decoder13,
4793
- getU64Encoder as getU64Encoder13,
4794
- getU8Decoder as getU8Decoder6,
4795
- getU8Encoder as getU8Encoder6,
4796
4806
  transformEncoder as transformEncoder27
4797
4807
  } from "@solana/kit";
4798
- var REMOVE_LIQUIDITY_ORCA_DISCRIMINATOR = new Uint8Array([
4799
- 30,
4800
- 69,
4801
- 45,
4802
- 170,
4803
- 183,
4804
- 195,
4805
- 12,
4806
- 119
4808
+ var REBALANCE_POSITION_ORCA_DISCRIMINATOR = new Uint8Array([
4809
+ 124,
4810
+ 212,
4811
+ 164,
4812
+ 128,
4813
+ 31,
4814
+ 143,
4815
+ 101,
4816
+ 231
4807
4817
  ]);
4808
- function getRemoveLiquidityOrcaDiscriminatorBytes() {
4818
+ function getRebalancePositionOrcaDiscriminatorBytes() {
4809
4819
  return fixEncoderSize28(getBytesEncoder28(), 8).encode(
4810
- REMOVE_LIQUIDITY_ORCA_DISCRIMINATOR
4820
+ REBALANCE_POSITION_ORCA_DISCRIMINATOR
4811
4821
  );
4812
4822
  }
4813
- function getRemoveLiquidityOrcaInstructionDataEncoder() {
4823
+ function getRebalancePositionOrcaInstructionDataEncoder() {
4814
4824
  return transformEncoder27(
4815
4825
  getStructEncoder29([
4816
4826
  ["discriminator", fixEncoderSize28(getBytesEncoder28(), 8)],
4817
- ["withdrawPercent", getU32Encoder14()],
4818
- ["swapToToken", getU8Encoder6()],
4819
- ["minRemovedAmountA", getU64Encoder13()],
4820
- ["minRemovedAmountB", getU64Encoder13()],
4821
- ["maxSwapSlippage", getU32Encoder14()],
4822
4827
  ["remainingAccountsInfo", getRemainingAccountsInfoEncoder()]
4823
4828
  ]),
4824
4829
  (value) => ({
4825
4830
  ...value,
4826
- discriminator: REMOVE_LIQUIDITY_ORCA_DISCRIMINATOR
4831
+ discriminator: REBALANCE_POSITION_ORCA_DISCRIMINATOR
4827
4832
  })
4828
4833
  );
4829
4834
  }
4830
- function getRemoveLiquidityOrcaInstructionDataDecoder() {
4835
+ function getRebalancePositionOrcaInstructionDataDecoder() {
4831
4836
  return getStructDecoder29([
4832
4837
  ["discriminator", fixDecoderSize27(getBytesDecoder27(), 8)],
4833
- ["withdrawPercent", getU32Decoder14()],
4834
- ["swapToToken", getU8Decoder6()],
4835
- ["minRemovedAmountA", getU64Decoder13()],
4836
- ["minRemovedAmountB", getU64Decoder13()],
4837
- ["maxSwapSlippage", getU32Decoder14()],
4838
4838
  ["remainingAccountsInfo", getRemainingAccountsInfoDecoder()]
4839
4839
  ]);
4840
4840
  }
4841
- function getRemoveLiquidityOrcaInstructionDataCodec() {
4841
+ function getRebalancePositionOrcaInstructionDataCodec() {
4842
4842
  return combineCodec32(
4843
- getRemoveLiquidityOrcaInstructionDataEncoder(),
4844
- getRemoveLiquidityOrcaInstructionDataDecoder()
4843
+ getRebalancePositionOrcaInstructionDataEncoder(),
4844
+ getRebalancePositionOrcaInstructionDataDecoder()
4845
4845
  );
4846
4846
  }
4847
- function getRemoveLiquidityOrcaInstruction(input, config) {
4847
+ function getRebalancePositionOrcaInstruction(input, config) {
4848
4848
  const programAddress = config?.programAddress ?? TUNA_PROGRAM_ADDRESS;
4849
4849
  const originalAccounts = {
4850
4850
  authority: { value: input.authority ?? null, isWritable: true },
4851
4851
  tunaConfig: { value: input.tunaConfig ?? null, isWritable: false },
4852
- market: { value: input.market ?? null, isWritable: true },
4853
4852
  mintA: { value: input.mintA ?? null, isWritable: false },
4854
4853
  mintB: { value: input.mintB ?? null, isWritable: false },
4854
+ market: { value: input.market ?? null, isWritable: true },
4855
4855
  vaultA: { value: input.vaultA ?? null, isWritable: true },
4856
4856
  vaultB: { value: input.vaultB ?? null, isWritable: true },
4857
- vaultAAta: { value: input.vaultAAta ?? null, isWritable: true },
4858
- vaultBAta: { value: input.vaultBAta ?? null, isWritable: true },
4859
4857
  tunaPosition: { value: input.tunaPosition ?? null, isWritable: true },
4860
4858
  tunaPositionAta: { value: input.tunaPositionAta ?? null, isWritable: true },
4861
4859
  tunaPositionAtaA: {
@@ -4866,12 +4864,12 @@ function getRemoveLiquidityOrcaInstruction(input, config) {
4866
4864
  value: input.tunaPositionAtaB ?? null,
4867
4865
  isWritable: true
4868
4866
  },
4869
- tunaPositionOwnerAtaA: {
4870
- value: input.tunaPositionOwnerAtaA ?? null,
4867
+ feeRecipientAtaA: {
4868
+ value: input.feeRecipientAtaA ?? null,
4871
4869
  isWritable: true
4872
4870
  },
4873
- tunaPositionOwnerAtaB: {
4874
- value: input.tunaPositionOwnerAtaB ?? null,
4871
+ feeRecipientAtaB: {
4872
+ value: input.feeRecipientAtaB ?? null,
4875
4873
  isWritable: true
4876
4874
  },
4877
4875
  pythOraclePriceFeedA: {
@@ -4890,28 +4888,30 @@ function getRemoveLiquidityOrcaInstruction(input, config) {
4890
4888
  orcaPosition: { value: input.orcaPosition ?? null, isWritable: true },
4891
4889
  tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false },
4892
4890
  tokenProgramB: { value: input.tokenProgramB ?? null, isWritable: false },
4891
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
4893
4892
  memoProgram: { value: input.memoProgram ?? null, isWritable: false }
4894
4893
  };
4895
4894
  const accounts = originalAccounts;
4896
4895
  const args = { ...input };
4896
+ if (!accounts.systemProgram.value) {
4897
+ accounts.systemProgram.value = "11111111111111111111111111111111";
4898
+ }
4897
4899
  const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
4898
4900
  const instruction = {
4899
4901
  accounts: [
4900
4902
  getAccountMeta(accounts.authority),
4901
4903
  getAccountMeta(accounts.tunaConfig),
4902
- getAccountMeta(accounts.market),
4903
4904
  getAccountMeta(accounts.mintA),
4904
4905
  getAccountMeta(accounts.mintB),
4906
+ getAccountMeta(accounts.market),
4905
4907
  getAccountMeta(accounts.vaultA),
4906
4908
  getAccountMeta(accounts.vaultB),
4907
- getAccountMeta(accounts.vaultAAta),
4908
- getAccountMeta(accounts.vaultBAta),
4909
4909
  getAccountMeta(accounts.tunaPosition),
4910
4910
  getAccountMeta(accounts.tunaPositionAta),
4911
4911
  getAccountMeta(accounts.tunaPositionAtaA),
4912
4912
  getAccountMeta(accounts.tunaPositionAtaB),
4913
- getAccountMeta(accounts.tunaPositionOwnerAtaA),
4914
- getAccountMeta(accounts.tunaPositionOwnerAtaB),
4913
+ getAccountMeta(accounts.feeRecipientAtaA),
4914
+ getAccountMeta(accounts.feeRecipientAtaB),
4915
4915
  getAccountMeta(accounts.pythOraclePriceFeedA),
4916
4916
  getAccountMeta(accounts.pythOraclePriceFeedB),
4917
4917
  getAccountMeta(accounts.whirlpoolProgram),
@@ -4919,17 +4919,18 @@ function getRemoveLiquidityOrcaInstruction(input, config) {
4919
4919
  getAccountMeta(accounts.orcaPosition),
4920
4920
  getAccountMeta(accounts.tokenProgramA),
4921
4921
  getAccountMeta(accounts.tokenProgramB),
4922
+ getAccountMeta(accounts.systemProgram),
4922
4923
  getAccountMeta(accounts.memoProgram)
4923
4924
  ],
4924
4925
  programAddress,
4925
- data: getRemoveLiquidityOrcaInstructionDataEncoder().encode(
4926
+ data: getRebalancePositionOrcaInstructionDataEncoder().encode(
4926
4927
  args
4927
4928
  )
4928
4929
  };
4929
4930
  return instruction;
4930
4931
  }
4931
- function parseRemoveLiquidityOrcaInstruction(instruction) {
4932
- if (instruction.accounts.length < 23) {
4932
+ function parseRebalancePositionOrcaInstruction(instruction) {
4933
+ if (instruction.accounts.length < 22) {
4933
4934
  throw new Error("Not enough accounts");
4934
4935
  }
4935
4936
  let accountIndex = 0;
@@ -4943,19 +4944,17 @@ function parseRemoveLiquidityOrcaInstruction(instruction) {
4943
4944
  accounts: {
4944
4945
  authority: getNextAccount(),
4945
4946
  tunaConfig: getNextAccount(),
4946
- market: getNextAccount(),
4947
4947
  mintA: getNextAccount(),
4948
4948
  mintB: getNextAccount(),
4949
+ market: getNextAccount(),
4949
4950
  vaultA: getNextAccount(),
4950
4951
  vaultB: getNextAccount(),
4951
- vaultAAta: getNextAccount(),
4952
- vaultBAta: getNextAccount(),
4953
4952
  tunaPosition: getNextAccount(),
4954
4953
  tunaPositionAta: getNextAccount(),
4955
4954
  tunaPositionAtaA: getNextAccount(),
4956
4955
  tunaPositionAtaB: getNextAccount(),
4957
- tunaPositionOwnerAtaA: getNextAccount(),
4958
- tunaPositionOwnerAtaB: getNextAccount(),
4956
+ feeRecipientAtaA: getNextAccount(),
4957
+ feeRecipientAtaB: getNextAccount(),
4959
4958
  pythOraclePriceFeedA: getNextAccount(),
4960
4959
  pythOraclePriceFeedB: getNextAccount(),
4961
4960
  whirlpoolProgram: getNextAccount(),
@@ -4963,15 +4962,16 @@ function parseRemoveLiquidityOrcaInstruction(instruction) {
4963
4962
  orcaPosition: getNextAccount(),
4964
4963
  tokenProgramA: getNextAccount(),
4965
4964
  tokenProgramB: getNextAccount(),
4965
+ systemProgram: getNextAccount(),
4966
4966
  memoProgram: getNextAccount()
4967
4967
  },
4968
- data: getRemoveLiquidityOrcaInstructionDataDecoder().decode(
4968
+ data: getRebalancePositionOrcaInstructionDataDecoder().decode(
4969
4969
  instruction.data
4970
4970
  )
4971
4971
  };
4972
4972
  }
4973
4973
 
4974
- // src/generated/instructions/repayBadDebt.ts
4974
+ // src/generated/instructions/removeLiquidityFusion.ts
4975
4975
  import {
4976
4976
  combineCodec as combineCodec33,
4977
4977
  fixDecoderSize as fixDecoderSize28,
@@ -4980,79 +4980,465 @@ import {
4980
4980
  getBytesEncoder as getBytesEncoder29,
4981
4981
  getStructDecoder as getStructDecoder30,
4982
4982
  getStructEncoder as getStructEncoder30,
4983
- getU64Decoder as getU64Decoder14,
4984
- getU64Encoder as getU64Encoder14,
4983
+ getU32Decoder as getU32Decoder13,
4984
+ getU32Encoder as getU32Encoder13,
4985
+ getU64Decoder as getU64Decoder12,
4986
+ getU64Encoder as getU64Encoder12,
4987
+ getU8Decoder as getU8Decoder5,
4988
+ getU8Encoder as getU8Encoder5,
4985
4989
  transformEncoder as transformEncoder28
4986
4990
  } from "@solana/kit";
4987
- var REPAY_BAD_DEBT_DISCRIMINATOR = new Uint8Array([
4988
- 112,
4989
- 144,
4990
- 188,
4991
- 157,
4992
- 43,
4993
- 106,
4994
- 141,
4995
- 34
4991
+ var REMOVE_LIQUIDITY_FUSION_DISCRIMINATOR = new Uint8Array([
4992
+ 175,
4993
+ 74,
4994
+ 205,
4995
+ 238,
4996
+ 4,
4997
+ 123,
4998
+ 166,
4999
+ 35
4996
5000
  ]);
4997
- function getRepayBadDebtDiscriminatorBytes() {
5001
+ function getRemoveLiquidityFusionDiscriminatorBytes() {
4998
5002
  return fixEncoderSize29(getBytesEncoder29(), 8).encode(
4999
- REPAY_BAD_DEBT_DISCRIMINATOR
5003
+ REMOVE_LIQUIDITY_FUSION_DISCRIMINATOR
5000
5004
  );
5001
5005
  }
5002
- function getRepayBadDebtInstructionDataEncoder() {
5006
+ function getRemoveLiquidityFusionInstructionDataEncoder() {
5003
5007
  return transformEncoder28(
5004
5008
  getStructEncoder30([
5005
5009
  ["discriminator", fixEncoderSize29(getBytesEncoder29(), 8)],
5006
- ["funds", getU64Encoder14()],
5007
- ["shares", getU64Encoder14()]
5010
+ ["withdrawPercent", getU32Encoder13()],
5011
+ ["swapToToken", getU8Encoder5()],
5012
+ ["minRemovedAmountA", getU64Encoder12()],
5013
+ ["minRemovedAmountB", getU64Encoder12()],
5014
+ ["maxSwapSlippage", getU32Encoder13()],
5015
+ ["remainingAccountsInfo", getRemainingAccountsInfoEncoder()]
5008
5016
  ]),
5009
- (value) => ({ ...value, discriminator: REPAY_BAD_DEBT_DISCRIMINATOR })
5017
+ (value) => ({
5018
+ ...value,
5019
+ discriminator: REMOVE_LIQUIDITY_FUSION_DISCRIMINATOR
5020
+ })
5010
5021
  );
5011
5022
  }
5012
- function getRepayBadDebtInstructionDataDecoder() {
5023
+ function getRemoveLiquidityFusionInstructionDataDecoder() {
5013
5024
  return getStructDecoder30([
5014
5025
  ["discriminator", fixDecoderSize28(getBytesDecoder28(), 8)],
5015
- ["funds", getU64Decoder14()],
5016
- ["shares", getU64Decoder14()]
5026
+ ["withdrawPercent", getU32Decoder13()],
5027
+ ["swapToToken", getU8Decoder5()],
5028
+ ["minRemovedAmountA", getU64Decoder12()],
5029
+ ["minRemovedAmountB", getU64Decoder12()],
5030
+ ["maxSwapSlippage", getU32Decoder13()],
5031
+ ["remainingAccountsInfo", getRemainingAccountsInfoDecoder()]
5017
5032
  ]);
5018
5033
  }
5019
- function getRepayBadDebtInstructionDataCodec() {
5034
+ function getRemoveLiquidityFusionInstructionDataCodec() {
5020
5035
  return combineCodec33(
5021
- getRepayBadDebtInstructionDataEncoder(),
5022
- getRepayBadDebtInstructionDataDecoder()
5036
+ getRemoveLiquidityFusionInstructionDataEncoder(),
5037
+ getRemoveLiquidityFusionInstructionDataDecoder()
5023
5038
  );
5024
5039
  }
5025
- function getRepayBadDebtInstruction(input, config) {
5040
+ function getRemoveLiquidityFusionInstruction(input, config) {
5026
5041
  const programAddress = config?.programAddress ?? TUNA_PROGRAM_ADDRESS;
5027
5042
  const originalAccounts = {
5028
- authority: { value: input.authority ?? null, isWritable: false },
5029
- mint: { value: input.mint ?? null, isWritable: false },
5043
+ authority: { value: input.authority ?? null, isWritable: true },
5030
5044
  tunaConfig: { value: input.tunaConfig ?? null, isWritable: false },
5031
- vault: { value: input.vault ?? null, isWritable: true },
5032
- vaultAta: { value: input.vaultAta ?? null, isWritable: true },
5033
- authorityAta: { value: input.authorityAta ?? null, isWritable: true },
5034
- tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
5035
- memoProgram: { value: input.memoProgram ?? null, isWritable: false }
5036
- };
5037
- const accounts = originalAccounts;
5038
- const args = { ...input };
5039
- if (!accounts.tokenProgram.value) {
5040
- accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
5041
- }
5042
- const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
5043
- const instruction = {
5044
- accounts: [
5045
- getAccountMeta(accounts.authority),
5046
- getAccountMeta(accounts.mint),
5047
- getAccountMeta(accounts.tunaConfig),
5048
- getAccountMeta(accounts.vault),
5049
- getAccountMeta(accounts.vaultAta),
5050
- getAccountMeta(accounts.authorityAta),
5051
- getAccountMeta(accounts.tokenProgram),
5052
- getAccountMeta(accounts.memoProgram)
5053
- ],
5054
- programAddress,
5055
- data: getRepayBadDebtInstructionDataEncoder().encode(
5045
+ market: { value: input.market ?? null, isWritable: true },
5046
+ mintA: { value: input.mintA ?? null, isWritable: false },
5047
+ mintB: { value: input.mintB ?? null, isWritable: false },
5048
+ tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false },
5049
+ tokenProgramB: { value: input.tokenProgramB ?? null, isWritable: false },
5050
+ vaultA: { value: input.vaultA ?? null, isWritable: true },
5051
+ vaultB: { value: input.vaultB ?? null, isWritable: true },
5052
+ vaultAAta: { value: input.vaultAAta ?? null, isWritable: true },
5053
+ vaultBAta: { value: input.vaultBAta ?? null, isWritable: true },
5054
+ tunaPosition: { value: input.tunaPosition ?? null, isWritable: true },
5055
+ tunaPositionAta: { value: input.tunaPositionAta ?? null, isWritable: true },
5056
+ tunaPositionAtaA: {
5057
+ value: input.tunaPositionAtaA ?? null,
5058
+ isWritable: true
5059
+ },
5060
+ tunaPositionAtaB: {
5061
+ value: input.tunaPositionAtaB ?? null,
5062
+ isWritable: true
5063
+ },
5064
+ tunaPositionOwnerAtaA: {
5065
+ value: input.tunaPositionOwnerAtaA ?? null,
5066
+ isWritable: true
5067
+ },
5068
+ tunaPositionOwnerAtaB: {
5069
+ value: input.tunaPositionOwnerAtaB ?? null,
5070
+ isWritable: true
5071
+ },
5072
+ pythOraclePriceFeedA: {
5073
+ value: input.pythOraclePriceFeedA ?? null,
5074
+ isWritable: false
5075
+ },
5076
+ pythOraclePriceFeedB: {
5077
+ value: input.pythOraclePriceFeedB ?? null,
5078
+ isWritable: false
5079
+ },
5080
+ fusionammProgram: {
5081
+ value: input.fusionammProgram ?? null,
5082
+ isWritable: false
5083
+ },
5084
+ fusionPool: { value: input.fusionPool ?? null, isWritable: true },
5085
+ fusionPosition: { value: input.fusionPosition ?? null, isWritable: true },
5086
+ memoProgram: { value: input.memoProgram ?? null, isWritable: false }
5087
+ };
5088
+ const accounts = originalAccounts;
5089
+ const args = { ...input };
5090
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
5091
+ const instruction = {
5092
+ accounts: [
5093
+ getAccountMeta(accounts.authority),
5094
+ getAccountMeta(accounts.tunaConfig),
5095
+ getAccountMeta(accounts.market),
5096
+ getAccountMeta(accounts.mintA),
5097
+ getAccountMeta(accounts.mintB),
5098
+ getAccountMeta(accounts.tokenProgramA),
5099
+ getAccountMeta(accounts.tokenProgramB),
5100
+ getAccountMeta(accounts.vaultA),
5101
+ getAccountMeta(accounts.vaultB),
5102
+ getAccountMeta(accounts.vaultAAta),
5103
+ getAccountMeta(accounts.vaultBAta),
5104
+ getAccountMeta(accounts.tunaPosition),
5105
+ getAccountMeta(accounts.tunaPositionAta),
5106
+ getAccountMeta(accounts.tunaPositionAtaA),
5107
+ getAccountMeta(accounts.tunaPositionAtaB),
5108
+ getAccountMeta(accounts.tunaPositionOwnerAtaA),
5109
+ getAccountMeta(accounts.tunaPositionOwnerAtaB),
5110
+ getAccountMeta(accounts.pythOraclePriceFeedA),
5111
+ getAccountMeta(accounts.pythOraclePriceFeedB),
5112
+ getAccountMeta(accounts.fusionammProgram),
5113
+ getAccountMeta(accounts.fusionPool),
5114
+ getAccountMeta(accounts.fusionPosition),
5115
+ getAccountMeta(accounts.memoProgram)
5116
+ ],
5117
+ programAddress,
5118
+ data: getRemoveLiquidityFusionInstructionDataEncoder().encode(
5119
+ args
5120
+ )
5121
+ };
5122
+ return instruction;
5123
+ }
5124
+ function parseRemoveLiquidityFusionInstruction(instruction) {
5125
+ if (instruction.accounts.length < 23) {
5126
+ throw new Error("Not enough accounts");
5127
+ }
5128
+ let accountIndex = 0;
5129
+ const getNextAccount = () => {
5130
+ const accountMeta = instruction.accounts[accountIndex];
5131
+ accountIndex += 1;
5132
+ return accountMeta;
5133
+ };
5134
+ return {
5135
+ programAddress: instruction.programAddress,
5136
+ accounts: {
5137
+ authority: getNextAccount(),
5138
+ tunaConfig: getNextAccount(),
5139
+ market: getNextAccount(),
5140
+ mintA: getNextAccount(),
5141
+ mintB: getNextAccount(),
5142
+ tokenProgramA: getNextAccount(),
5143
+ tokenProgramB: getNextAccount(),
5144
+ vaultA: getNextAccount(),
5145
+ vaultB: getNextAccount(),
5146
+ vaultAAta: getNextAccount(),
5147
+ vaultBAta: getNextAccount(),
5148
+ tunaPosition: getNextAccount(),
5149
+ tunaPositionAta: getNextAccount(),
5150
+ tunaPositionAtaA: getNextAccount(),
5151
+ tunaPositionAtaB: getNextAccount(),
5152
+ tunaPositionOwnerAtaA: getNextAccount(),
5153
+ tunaPositionOwnerAtaB: getNextAccount(),
5154
+ pythOraclePriceFeedA: getNextAccount(),
5155
+ pythOraclePriceFeedB: getNextAccount(),
5156
+ fusionammProgram: getNextAccount(),
5157
+ fusionPool: getNextAccount(),
5158
+ fusionPosition: getNextAccount(),
5159
+ memoProgram: getNextAccount()
5160
+ },
5161
+ data: getRemoveLiquidityFusionInstructionDataDecoder().decode(
5162
+ instruction.data
5163
+ )
5164
+ };
5165
+ }
5166
+
5167
+ // src/generated/instructions/removeLiquidityOrca.ts
5168
+ import {
5169
+ combineCodec as combineCodec34,
5170
+ fixDecoderSize as fixDecoderSize29,
5171
+ fixEncoderSize as fixEncoderSize30,
5172
+ getBytesDecoder as getBytesDecoder29,
5173
+ getBytesEncoder as getBytesEncoder30,
5174
+ getStructDecoder as getStructDecoder31,
5175
+ getStructEncoder as getStructEncoder31,
5176
+ getU32Decoder as getU32Decoder14,
5177
+ getU32Encoder as getU32Encoder14,
5178
+ getU64Decoder as getU64Decoder13,
5179
+ getU64Encoder as getU64Encoder13,
5180
+ getU8Decoder as getU8Decoder6,
5181
+ getU8Encoder as getU8Encoder6,
5182
+ transformEncoder as transformEncoder29
5183
+ } from "@solana/kit";
5184
+ var REMOVE_LIQUIDITY_ORCA_DISCRIMINATOR = new Uint8Array([
5185
+ 30,
5186
+ 69,
5187
+ 45,
5188
+ 170,
5189
+ 183,
5190
+ 195,
5191
+ 12,
5192
+ 119
5193
+ ]);
5194
+ function getRemoveLiquidityOrcaDiscriminatorBytes() {
5195
+ return fixEncoderSize30(getBytesEncoder30(), 8).encode(
5196
+ REMOVE_LIQUIDITY_ORCA_DISCRIMINATOR
5197
+ );
5198
+ }
5199
+ function getRemoveLiquidityOrcaInstructionDataEncoder() {
5200
+ return transformEncoder29(
5201
+ getStructEncoder31([
5202
+ ["discriminator", fixEncoderSize30(getBytesEncoder30(), 8)],
5203
+ ["withdrawPercent", getU32Encoder14()],
5204
+ ["swapToToken", getU8Encoder6()],
5205
+ ["minRemovedAmountA", getU64Encoder13()],
5206
+ ["minRemovedAmountB", getU64Encoder13()],
5207
+ ["maxSwapSlippage", getU32Encoder14()],
5208
+ ["remainingAccountsInfo", getRemainingAccountsInfoEncoder()]
5209
+ ]),
5210
+ (value) => ({
5211
+ ...value,
5212
+ discriminator: REMOVE_LIQUIDITY_ORCA_DISCRIMINATOR
5213
+ })
5214
+ );
5215
+ }
5216
+ function getRemoveLiquidityOrcaInstructionDataDecoder() {
5217
+ return getStructDecoder31([
5218
+ ["discriminator", fixDecoderSize29(getBytesDecoder29(), 8)],
5219
+ ["withdrawPercent", getU32Decoder14()],
5220
+ ["swapToToken", getU8Decoder6()],
5221
+ ["minRemovedAmountA", getU64Decoder13()],
5222
+ ["minRemovedAmountB", getU64Decoder13()],
5223
+ ["maxSwapSlippage", getU32Decoder14()],
5224
+ ["remainingAccountsInfo", getRemainingAccountsInfoDecoder()]
5225
+ ]);
5226
+ }
5227
+ function getRemoveLiquidityOrcaInstructionDataCodec() {
5228
+ return combineCodec34(
5229
+ getRemoveLiquidityOrcaInstructionDataEncoder(),
5230
+ getRemoveLiquidityOrcaInstructionDataDecoder()
5231
+ );
5232
+ }
5233
+ function getRemoveLiquidityOrcaInstruction(input, config) {
5234
+ const programAddress = config?.programAddress ?? TUNA_PROGRAM_ADDRESS;
5235
+ const originalAccounts = {
5236
+ authority: { value: input.authority ?? null, isWritable: true },
5237
+ tunaConfig: { value: input.tunaConfig ?? null, isWritable: false },
5238
+ market: { value: input.market ?? null, isWritable: true },
5239
+ mintA: { value: input.mintA ?? null, isWritable: false },
5240
+ mintB: { value: input.mintB ?? null, isWritable: false },
5241
+ vaultA: { value: input.vaultA ?? null, isWritable: true },
5242
+ vaultB: { value: input.vaultB ?? null, isWritable: true },
5243
+ vaultAAta: { value: input.vaultAAta ?? null, isWritable: true },
5244
+ vaultBAta: { value: input.vaultBAta ?? null, isWritable: true },
5245
+ tunaPosition: { value: input.tunaPosition ?? null, isWritable: true },
5246
+ tunaPositionAta: { value: input.tunaPositionAta ?? null, isWritable: true },
5247
+ tunaPositionAtaA: {
5248
+ value: input.tunaPositionAtaA ?? null,
5249
+ isWritable: true
5250
+ },
5251
+ tunaPositionAtaB: {
5252
+ value: input.tunaPositionAtaB ?? null,
5253
+ isWritable: true
5254
+ },
5255
+ tunaPositionOwnerAtaA: {
5256
+ value: input.tunaPositionOwnerAtaA ?? null,
5257
+ isWritable: true
5258
+ },
5259
+ tunaPositionOwnerAtaB: {
5260
+ value: input.tunaPositionOwnerAtaB ?? null,
5261
+ isWritable: true
5262
+ },
5263
+ pythOraclePriceFeedA: {
5264
+ value: input.pythOraclePriceFeedA ?? null,
5265
+ isWritable: false
5266
+ },
5267
+ pythOraclePriceFeedB: {
5268
+ value: input.pythOraclePriceFeedB ?? null,
5269
+ isWritable: false
5270
+ },
5271
+ whirlpoolProgram: {
5272
+ value: input.whirlpoolProgram ?? null,
5273
+ isWritable: false
5274
+ },
5275
+ whirlpool: { value: input.whirlpool ?? null, isWritable: true },
5276
+ orcaPosition: { value: input.orcaPosition ?? null, isWritable: true },
5277
+ tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false },
5278
+ tokenProgramB: { value: input.tokenProgramB ?? null, isWritable: false },
5279
+ memoProgram: { value: input.memoProgram ?? null, isWritable: false }
5280
+ };
5281
+ const accounts = originalAccounts;
5282
+ const args = { ...input };
5283
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
5284
+ const instruction = {
5285
+ accounts: [
5286
+ getAccountMeta(accounts.authority),
5287
+ getAccountMeta(accounts.tunaConfig),
5288
+ getAccountMeta(accounts.market),
5289
+ getAccountMeta(accounts.mintA),
5290
+ getAccountMeta(accounts.mintB),
5291
+ getAccountMeta(accounts.vaultA),
5292
+ getAccountMeta(accounts.vaultB),
5293
+ getAccountMeta(accounts.vaultAAta),
5294
+ getAccountMeta(accounts.vaultBAta),
5295
+ getAccountMeta(accounts.tunaPosition),
5296
+ getAccountMeta(accounts.tunaPositionAta),
5297
+ getAccountMeta(accounts.tunaPositionAtaA),
5298
+ getAccountMeta(accounts.tunaPositionAtaB),
5299
+ getAccountMeta(accounts.tunaPositionOwnerAtaA),
5300
+ getAccountMeta(accounts.tunaPositionOwnerAtaB),
5301
+ getAccountMeta(accounts.pythOraclePriceFeedA),
5302
+ getAccountMeta(accounts.pythOraclePriceFeedB),
5303
+ getAccountMeta(accounts.whirlpoolProgram),
5304
+ getAccountMeta(accounts.whirlpool),
5305
+ getAccountMeta(accounts.orcaPosition),
5306
+ getAccountMeta(accounts.tokenProgramA),
5307
+ getAccountMeta(accounts.tokenProgramB),
5308
+ getAccountMeta(accounts.memoProgram)
5309
+ ],
5310
+ programAddress,
5311
+ data: getRemoveLiquidityOrcaInstructionDataEncoder().encode(
5312
+ args
5313
+ )
5314
+ };
5315
+ return instruction;
5316
+ }
5317
+ function parseRemoveLiquidityOrcaInstruction(instruction) {
5318
+ if (instruction.accounts.length < 23) {
5319
+ throw new Error("Not enough accounts");
5320
+ }
5321
+ let accountIndex = 0;
5322
+ const getNextAccount = () => {
5323
+ const accountMeta = instruction.accounts[accountIndex];
5324
+ accountIndex += 1;
5325
+ return accountMeta;
5326
+ };
5327
+ return {
5328
+ programAddress: instruction.programAddress,
5329
+ accounts: {
5330
+ authority: getNextAccount(),
5331
+ tunaConfig: getNextAccount(),
5332
+ market: getNextAccount(),
5333
+ mintA: getNextAccount(),
5334
+ mintB: getNextAccount(),
5335
+ vaultA: getNextAccount(),
5336
+ vaultB: getNextAccount(),
5337
+ vaultAAta: getNextAccount(),
5338
+ vaultBAta: getNextAccount(),
5339
+ tunaPosition: getNextAccount(),
5340
+ tunaPositionAta: getNextAccount(),
5341
+ tunaPositionAtaA: getNextAccount(),
5342
+ tunaPositionAtaB: getNextAccount(),
5343
+ tunaPositionOwnerAtaA: getNextAccount(),
5344
+ tunaPositionOwnerAtaB: getNextAccount(),
5345
+ pythOraclePriceFeedA: getNextAccount(),
5346
+ pythOraclePriceFeedB: getNextAccount(),
5347
+ whirlpoolProgram: getNextAccount(),
5348
+ whirlpool: getNextAccount(),
5349
+ orcaPosition: getNextAccount(),
5350
+ tokenProgramA: getNextAccount(),
5351
+ tokenProgramB: getNextAccount(),
5352
+ memoProgram: getNextAccount()
5353
+ },
5354
+ data: getRemoveLiquidityOrcaInstructionDataDecoder().decode(
5355
+ instruction.data
5356
+ )
5357
+ };
5358
+ }
5359
+
5360
+ // src/generated/instructions/repayBadDebt.ts
5361
+ import {
5362
+ combineCodec as combineCodec35,
5363
+ fixDecoderSize as fixDecoderSize30,
5364
+ fixEncoderSize as fixEncoderSize31,
5365
+ getBytesDecoder as getBytesDecoder30,
5366
+ getBytesEncoder as getBytesEncoder31,
5367
+ getStructDecoder as getStructDecoder32,
5368
+ getStructEncoder as getStructEncoder32,
5369
+ getU64Decoder as getU64Decoder14,
5370
+ getU64Encoder as getU64Encoder14,
5371
+ transformEncoder as transformEncoder30
5372
+ } from "@solana/kit";
5373
+ var REPAY_BAD_DEBT_DISCRIMINATOR = new Uint8Array([
5374
+ 112,
5375
+ 144,
5376
+ 188,
5377
+ 157,
5378
+ 43,
5379
+ 106,
5380
+ 141,
5381
+ 34
5382
+ ]);
5383
+ function getRepayBadDebtDiscriminatorBytes() {
5384
+ return fixEncoderSize31(getBytesEncoder31(), 8).encode(
5385
+ REPAY_BAD_DEBT_DISCRIMINATOR
5386
+ );
5387
+ }
5388
+ function getRepayBadDebtInstructionDataEncoder() {
5389
+ return transformEncoder30(
5390
+ getStructEncoder32([
5391
+ ["discriminator", fixEncoderSize31(getBytesEncoder31(), 8)],
5392
+ ["funds", getU64Encoder14()],
5393
+ ["shares", getU64Encoder14()]
5394
+ ]),
5395
+ (value) => ({ ...value, discriminator: REPAY_BAD_DEBT_DISCRIMINATOR })
5396
+ );
5397
+ }
5398
+ function getRepayBadDebtInstructionDataDecoder() {
5399
+ return getStructDecoder32([
5400
+ ["discriminator", fixDecoderSize30(getBytesDecoder30(), 8)],
5401
+ ["funds", getU64Decoder14()],
5402
+ ["shares", getU64Decoder14()]
5403
+ ]);
5404
+ }
5405
+ function getRepayBadDebtInstructionDataCodec() {
5406
+ return combineCodec35(
5407
+ getRepayBadDebtInstructionDataEncoder(),
5408
+ getRepayBadDebtInstructionDataDecoder()
5409
+ );
5410
+ }
5411
+ function getRepayBadDebtInstruction(input, config) {
5412
+ const programAddress = config?.programAddress ?? TUNA_PROGRAM_ADDRESS;
5413
+ const originalAccounts = {
5414
+ authority: { value: input.authority ?? null, isWritable: false },
5415
+ mint: { value: input.mint ?? null, isWritable: false },
5416
+ tunaConfig: { value: input.tunaConfig ?? null, isWritable: false },
5417
+ vault: { value: input.vault ?? null, isWritable: true },
5418
+ vaultAta: { value: input.vaultAta ?? null, isWritable: true },
5419
+ authorityAta: { value: input.authorityAta ?? null, isWritable: true },
5420
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
5421
+ memoProgram: { value: input.memoProgram ?? null, isWritable: false }
5422
+ };
5423
+ const accounts = originalAccounts;
5424
+ const args = { ...input };
5425
+ if (!accounts.tokenProgram.value) {
5426
+ accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
5427
+ }
5428
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
5429
+ const instruction = {
5430
+ accounts: [
5431
+ getAccountMeta(accounts.authority),
5432
+ getAccountMeta(accounts.mint),
5433
+ getAccountMeta(accounts.tunaConfig),
5434
+ getAccountMeta(accounts.vault),
5435
+ getAccountMeta(accounts.vaultAta),
5436
+ getAccountMeta(accounts.authorityAta),
5437
+ getAccountMeta(accounts.tokenProgram),
5438
+ getAccountMeta(accounts.memoProgram)
5439
+ ],
5440
+ programAddress,
5441
+ data: getRepayBadDebtInstructionDataEncoder().encode(
5056
5442
  args
5057
5443
  )
5058
5444
  };
@@ -5086,16 +5472,16 @@ function parseRepayBadDebtInstruction(instruction) {
5086
5472
 
5087
5473
  // src/generated/instructions/repayDebt.ts
5088
5474
  import {
5089
- combineCodec as combineCodec34,
5090
- fixDecoderSize as fixDecoderSize29,
5091
- fixEncoderSize as fixEncoderSize30,
5092
- getBytesDecoder as getBytesDecoder29,
5093
- getBytesEncoder as getBytesEncoder30,
5094
- getStructDecoder as getStructDecoder31,
5095
- getStructEncoder as getStructEncoder31,
5475
+ combineCodec as combineCodec36,
5476
+ fixDecoderSize as fixDecoderSize31,
5477
+ fixEncoderSize as fixEncoderSize32,
5478
+ getBytesDecoder as getBytesDecoder31,
5479
+ getBytesEncoder as getBytesEncoder32,
5480
+ getStructDecoder as getStructDecoder33,
5481
+ getStructEncoder as getStructEncoder33,
5096
5482
  getU64Decoder as getU64Decoder15,
5097
5483
  getU64Encoder as getU64Encoder15,
5098
- transformEncoder as transformEncoder29
5484
+ transformEncoder as transformEncoder31
5099
5485
  } from "@solana/kit";
5100
5486
  var REPAY_DEBT_DISCRIMINATOR = new Uint8Array([
5101
5487
  79,
@@ -5108,12 +5494,12 @@ var REPAY_DEBT_DISCRIMINATOR = new Uint8Array([
5108
5494
  8
5109
5495
  ]);
5110
5496
  function getRepayDebtDiscriminatorBytes() {
5111
- return fixEncoderSize30(getBytesEncoder30(), 8).encode(REPAY_DEBT_DISCRIMINATOR);
5497
+ return fixEncoderSize32(getBytesEncoder32(), 8).encode(REPAY_DEBT_DISCRIMINATOR);
5112
5498
  }
5113
5499
  function getRepayDebtInstructionDataEncoder() {
5114
- return transformEncoder29(
5115
- getStructEncoder31([
5116
- ["discriminator", fixEncoderSize30(getBytesEncoder30(), 8)],
5500
+ return transformEncoder31(
5501
+ getStructEncoder33([
5502
+ ["discriminator", fixEncoderSize32(getBytesEncoder32(), 8)],
5117
5503
  ["collateralFundsA", getU64Encoder15()],
5118
5504
  ["collateralFundsB", getU64Encoder15()]
5119
5505
  ]),
@@ -5121,14 +5507,14 @@ function getRepayDebtInstructionDataEncoder() {
5121
5507
  );
5122
5508
  }
5123
5509
  function getRepayDebtInstructionDataDecoder() {
5124
- return getStructDecoder31([
5125
- ["discriminator", fixDecoderSize29(getBytesDecoder29(), 8)],
5510
+ return getStructDecoder33([
5511
+ ["discriminator", fixDecoderSize31(getBytesDecoder31(), 8)],
5126
5512
  ["collateralFundsA", getU64Decoder15()],
5127
5513
  ["collateralFundsB", getU64Decoder15()]
5128
5514
  ]);
5129
5515
  }
5130
5516
  function getRepayDebtInstructionDataCodec() {
5131
- return combineCodec34(
5517
+ return combineCodec36(
5132
5518
  getRepayDebtInstructionDataEncoder(),
5133
5519
  getRepayDebtInstructionDataDecoder()
5134
5520
  );
@@ -5230,16 +5616,16 @@ function parseRepayDebtInstruction(instruction) {
5230
5616
 
5231
5617
  // src/generated/instructions/setAdminAuthority.ts
5232
5618
  import {
5233
- combineCodec as combineCodec35,
5234
- fixDecoderSize as fixDecoderSize30,
5235
- fixEncoderSize as fixEncoderSize31,
5619
+ combineCodec as combineCodec37,
5620
+ fixDecoderSize as fixDecoderSize32,
5621
+ fixEncoderSize as fixEncoderSize33,
5236
5622
  getAddressDecoder as getAddressDecoder9,
5237
5623
  getAddressEncoder as getAddressEncoder9,
5238
- getBytesDecoder as getBytesDecoder30,
5239
- getBytesEncoder as getBytesEncoder31,
5240
- getStructDecoder as getStructDecoder32,
5241
- getStructEncoder as getStructEncoder32,
5242
- transformEncoder as transformEncoder30
5624
+ getBytesDecoder as getBytesDecoder32,
5625
+ getBytesEncoder as getBytesEncoder33,
5626
+ getStructDecoder as getStructDecoder34,
5627
+ getStructEncoder as getStructEncoder34,
5628
+ transformEncoder as transformEncoder32
5243
5629
  } from "@solana/kit";
5244
5630
  var SET_ADMIN_AUTHORITY_DISCRIMINATOR = new Uint8Array([
5245
5631
  72,
@@ -5252,27 +5638,27 @@ var SET_ADMIN_AUTHORITY_DISCRIMINATOR = new Uint8Array([
5252
5638
  174
5253
5639
  ]);
5254
5640
  function getSetAdminAuthorityDiscriminatorBytes() {
5255
- return fixEncoderSize31(getBytesEncoder31(), 8).encode(
5641
+ return fixEncoderSize33(getBytesEncoder33(), 8).encode(
5256
5642
  SET_ADMIN_AUTHORITY_DISCRIMINATOR
5257
5643
  );
5258
5644
  }
5259
5645
  function getSetAdminAuthorityInstructionDataEncoder() {
5260
- return transformEncoder30(
5261
- getStructEncoder32([
5262
- ["discriminator", fixEncoderSize31(getBytesEncoder31(), 8)],
5646
+ return transformEncoder32(
5647
+ getStructEncoder34([
5648
+ ["discriminator", fixEncoderSize33(getBytesEncoder33(), 8)],
5263
5649
  ["adminAuthority", getAddressEncoder9()]
5264
5650
  ]),
5265
5651
  (value) => ({ ...value, discriminator: SET_ADMIN_AUTHORITY_DISCRIMINATOR })
5266
5652
  );
5267
5653
  }
5268
5654
  function getSetAdminAuthorityInstructionDataDecoder() {
5269
- return getStructDecoder32([
5270
- ["discriminator", fixDecoderSize30(getBytesDecoder30(), 8)],
5655
+ return getStructDecoder34([
5656
+ ["discriminator", fixDecoderSize32(getBytesDecoder32(), 8)],
5271
5657
  ["adminAuthority", getAddressDecoder9()]
5272
5658
  ]);
5273
5659
  }
5274
5660
  function getSetAdminAuthorityInstructionDataCodec() {
5275
- return combineCodec35(
5661
+ return combineCodec37(
5276
5662
  getSetAdminAuthorityInstructionDataEncoder(),
5277
5663
  getSetAdminAuthorityInstructionDataDecoder()
5278
5664
  );
@@ -5320,27 +5706,27 @@ function parseSetAdminAuthorityInstruction(instruction) {
5320
5706
 
5321
5707
  // src/generated/instructions/setDefaultMaxPercentageOfLeftovers.ts
5322
5708
  import {
5323
- combineCodec as combineCodec36,
5324
- fixDecoderSize as fixDecoderSize31,
5325
- fixEncoderSize as fixEncoderSize32,
5326
- getBytesDecoder as getBytesDecoder31,
5327
- getBytesEncoder as getBytesEncoder32,
5328
- getStructDecoder as getStructDecoder33,
5329
- getStructEncoder as getStructEncoder33,
5709
+ combineCodec as combineCodec38,
5710
+ fixDecoderSize as fixDecoderSize33,
5711
+ fixEncoderSize as fixEncoderSize34,
5712
+ getBytesDecoder as getBytesDecoder33,
5713
+ getBytesEncoder as getBytesEncoder34,
5714
+ getStructDecoder as getStructDecoder35,
5715
+ getStructEncoder as getStructEncoder35,
5330
5716
  getU32Decoder as getU32Decoder15,
5331
5717
  getU32Encoder as getU32Encoder15,
5332
- transformEncoder as transformEncoder31
5718
+ transformEncoder as transformEncoder33
5333
5719
  } from "@solana/kit";
5334
5720
  var SET_DEFAULT_MAX_PERCENTAGE_OF_LEFTOVERS_DISCRIMINATOR = new Uint8Array([37, 179, 107, 65, 203, 141, 183, 27]);
5335
5721
  function getSetDefaultMaxPercentageOfLeftoversDiscriminatorBytes() {
5336
- return fixEncoderSize32(getBytesEncoder32(), 8).encode(
5722
+ return fixEncoderSize34(getBytesEncoder34(), 8).encode(
5337
5723
  SET_DEFAULT_MAX_PERCENTAGE_OF_LEFTOVERS_DISCRIMINATOR
5338
5724
  );
5339
5725
  }
5340
5726
  function getSetDefaultMaxPercentageOfLeftoversInstructionDataEncoder() {
5341
- return transformEncoder31(
5342
- getStructEncoder33([
5343
- ["discriminator", fixEncoderSize32(getBytesEncoder32(), 8)],
5727
+ return transformEncoder33(
5728
+ getStructEncoder35([
5729
+ ["discriminator", fixEncoderSize34(getBytesEncoder34(), 8)],
5344
5730
  ["maxPercentageOfLeftovers", getU32Encoder15()]
5345
5731
  ]),
5346
5732
  (value) => ({
@@ -5350,13 +5736,13 @@ function getSetDefaultMaxPercentageOfLeftoversInstructionDataEncoder() {
5350
5736
  );
5351
5737
  }
5352
5738
  function getSetDefaultMaxPercentageOfLeftoversInstructionDataDecoder() {
5353
- return getStructDecoder33([
5354
- ["discriminator", fixDecoderSize31(getBytesDecoder31(), 8)],
5739
+ return getStructDecoder35([
5740
+ ["discriminator", fixDecoderSize33(getBytesDecoder33(), 8)],
5355
5741
  ["maxPercentageOfLeftovers", getU32Decoder15()]
5356
5742
  ]);
5357
5743
  }
5358
5744
  function getSetDefaultMaxPercentageOfLeftoversInstructionDataCodec() {
5359
- return combineCodec36(
5745
+ return combineCodec38(
5360
5746
  getSetDefaultMaxPercentageOfLeftoversInstructionDataEncoder(),
5361
5747
  getSetDefaultMaxPercentageOfLeftoversInstructionDataDecoder()
5362
5748
  );
@@ -5406,16 +5792,16 @@ function parseSetDefaultMaxPercentageOfLeftoversInstruction(instruction) {
5406
5792
 
5407
5793
  // src/generated/instructions/setDefaultMaxSwapSlippage.ts
5408
5794
  import {
5409
- combineCodec as combineCodec37,
5410
- fixDecoderSize as fixDecoderSize32,
5411
- fixEncoderSize as fixEncoderSize33,
5412
- getBytesDecoder as getBytesDecoder32,
5413
- getBytesEncoder as getBytesEncoder33,
5414
- getStructDecoder as getStructDecoder34,
5415
- getStructEncoder as getStructEncoder34,
5795
+ combineCodec as combineCodec39,
5796
+ fixDecoderSize as fixDecoderSize34,
5797
+ fixEncoderSize as fixEncoderSize35,
5798
+ getBytesDecoder as getBytesDecoder34,
5799
+ getBytesEncoder as getBytesEncoder35,
5800
+ getStructDecoder as getStructDecoder36,
5801
+ getStructEncoder as getStructEncoder36,
5416
5802
  getU32Decoder as getU32Decoder16,
5417
5803
  getU32Encoder as getU32Encoder16,
5418
- transformEncoder as transformEncoder32
5804
+ transformEncoder as transformEncoder34
5419
5805
  } from "@solana/kit";
5420
5806
  var SET_DEFAULT_MAX_SWAP_SLIPPAGE_DISCRIMINATOR = new Uint8Array([
5421
5807
  122,
@@ -5428,14 +5814,14 @@ var SET_DEFAULT_MAX_SWAP_SLIPPAGE_DISCRIMINATOR = new Uint8Array([
5428
5814
  181
5429
5815
  ]);
5430
5816
  function getSetDefaultMaxSwapSlippageDiscriminatorBytes() {
5431
- return fixEncoderSize33(getBytesEncoder33(), 8).encode(
5817
+ return fixEncoderSize35(getBytesEncoder35(), 8).encode(
5432
5818
  SET_DEFAULT_MAX_SWAP_SLIPPAGE_DISCRIMINATOR
5433
5819
  );
5434
5820
  }
5435
5821
  function getSetDefaultMaxSwapSlippageInstructionDataEncoder() {
5436
- return transformEncoder32(
5437
- getStructEncoder34([
5438
- ["discriminator", fixEncoderSize33(getBytesEncoder33(), 8)],
5822
+ return transformEncoder34(
5823
+ getStructEncoder36([
5824
+ ["discriminator", fixEncoderSize35(getBytesEncoder35(), 8)],
5439
5825
  ["maxSwapSlippage", getU32Encoder16()]
5440
5826
  ]),
5441
5827
  (value) => ({
@@ -5445,13 +5831,13 @@ function getSetDefaultMaxSwapSlippageInstructionDataEncoder() {
5445
5831
  );
5446
5832
  }
5447
5833
  function getSetDefaultMaxSwapSlippageInstructionDataDecoder() {
5448
- return getStructDecoder34([
5449
- ["discriminator", fixDecoderSize32(getBytesDecoder32(), 8)],
5834
+ return getStructDecoder36([
5835
+ ["discriminator", fixDecoderSize34(getBytesDecoder34(), 8)],
5450
5836
  ["maxSwapSlippage", getU32Decoder16()]
5451
5837
  ]);
5452
5838
  }
5453
5839
  function getSetDefaultMaxSwapSlippageInstructionDataCodec() {
5454
- return combineCodec37(
5840
+ return combineCodec39(
5455
5841
  getSetDefaultMaxSwapSlippageInstructionDataEncoder(),
5456
5842
  getSetDefaultMaxSwapSlippageInstructionDataDecoder()
5457
5843
  );
@@ -5501,27 +5887,27 @@ function parseSetDefaultMaxSwapSlippageInstruction(instruction) {
5501
5887
 
5502
5888
  // src/generated/instructions/setDefaultOraclePriceDeviationThreshold.ts
5503
5889
  import {
5504
- combineCodec as combineCodec38,
5505
- fixDecoderSize as fixDecoderSize33,
5506
- fixEncoderSize as fixEncoderSize34,
5507
- getBytesDecoder as getBytesDecoder33,
5508
- getBytesEncoder as getBytesEncoder34,
5509
- getStructDecoder as getStructDecoder35,
5510
- getStructEncoder as getStructEncoder35,
5890
+ combineCodec as combineCodec40,
5891
+ fixDecoderSize as fixDecoderSize35,
5892
+ fixEncoderSize as fixEncoderSize36,
5893
+ getBytesDecoder as getBytesDecoder35,
5894
+ getBytesEncoder as getBytesEncoder36,
5895
+ getStructDecoder as getStructDecoder37,
5896
+ getStructEncoder as getStructEncoder37,
5511
5897
  getU32Decoder as getU32Decoder17,
5512
5898
  getU32Encoder as getU32Encoder17,
5513
- transformEncoder as transformEncoder33
5899
+ transformEncoder as transformEncoder35
5514
5900
  } from "@solana/kit";
5515
5901
  var SET_DEFAULT_ORACLE_PRICE_DEVIATION_THRESHOLD_DISCRIMINATOR = new Uint8Array([142, 158, 143, 67, 206, 91, 139, 120]);
5516
5902
  function getSetDefaultOraclePriceDeviationThresholdDiscriminatorBytes() {
5517
- return fixEncoderSize34(getBytesEncoder34(), 8).encode(
5903
+ return fixEncoderSize36(getBytesEncoder36(), 8).encode(
5518
5904
  SET_DEFAULT_ORACLE_PRICE_DEVIATION_THRESHOLD_DISCRIMINATOR
5519
5905
  );
5520
5906
  }
5521
5907
  function getSetDefaultOraclePriceDeviationThresholdInstructionDataEncoder() {
5522
- return transformEncoder33(
5523
- getStructEncoder35([
5524
- ["discriminator", fixEncoderSize34(getBytesEncoder34(), 8)],
5908
+ return transformEncoder35(
5909
+ getStructEncoder37([
5910
+ ["discriminator", fixEncoderSize36(getBytesEncoder36(), 8)],
5525
5911
  ["oraclePriceDeviationThreshold", getU32Encoder17()]
5526
5912
  ]),
5527
5913
  (value) => ({
@@ -5531,13 +5917,13 @@ function getSetDefaultOraclePriceDeviationThresholdInstructionDataEncoder() {
5531
5917
  );
5532
5918
  }
5533
5919
  function getSetDefaultOraclePriceDeviationThresholdInstructionDataDecoder() {
5534
- return getStructDecoder35([
5535
- ["discriminator", fixDecoderSize33(getBytesDecoder33(), 8)],
5920
+ return getStructDecoder37([
5921
+ ["discriminator", fixDecoderSize35(getBytesDecoder35(), 8)],
5536
5922
  ["oraclePriceDeviationThreshold", getU32Decoder17()]
5537
5923
  ]);
5538
5924
  }
5539
5925
  function getSetDefaultOraclePriceDeviationThresholdInstructionDataCodec() {
5540
- return combineCodec38(
5926
+ return combineCodec40(
5541
5927
  getSetDefaultOraclePriceDeviationThresholdInstructionDataEncoder(),
5542
5928
  getSetDefaultOraclePriceDeviationThresholdInstructionDataDecoder()
5543
5929
  );
@@ -5587,16 +5973,16 @@ function parseSetDefaultOraclePriceDeviationThresholdInstruction(instruction) {
5587
5973
 
5588
5974
  // src/generated/instructions/setFeeRecipient.ts
5589
5975
  import {
5590
- combineCodec as combineCodec39,
5591
- fixDecoderSize as fixDecoderSize34,
5592
- fixEncoderSize as fixEncoderSize35,
5976
+ combineCodec as combineCodec41,
5977
+ fixDecoderSize as fixDecoderSize36,
5978
+ fixEncoderSize as fixEncoderSize37,
5593
5979
  getAddressDecoder as getAddressDecoder10,
5594
5980
  getAddressEncoder as getAddressEncoder10,
5595
- getBytesDecoder as getBytesDecoder34,
5596
- getBytesEncoder as getBytesEncoder35,
5597
- getStructDecoder as getStructDecoder36,
5598
- getStructEncoder as getStructEncoder36,
5599
- transformEncoder as transformEncoder34
5981
+ getBytesDecoder as getBytesDecoder36,
5982
+ getBytesEncoder as getBytesEncoder37,
5983
+ getStructDecoder as getStructDecoder38,
5984
+ getStructEncoder as getStructEncoder38,
5985
+ transformEncoder as transformEncoder36
5600
5986
  } from "@solana/kit";
5601
5987
  var SET_FEE_RECIPIENT_DISCRIMINATOR = new Uint8Array([
5602
5988
  227,
@@ -5609,27 +5995,27 @@ var SET_FEE_RECIPIENT_DISCRIMINATOR = new Uint8Array([
5609
5995
  66
5610
5996
  ]);
5611
5997
  function getSetFeeRecipientDiscriminatorBytes() {
5612
- return fixEncoderSize35(getBytesEncoder35(), 8).encode(
5998
+ return fixEncoderSize37(getBytesEncoder37(), 8).encode(
5613
5999
  SET_FEE_RECIPIENT_DISCRIMINATOR
5614
6000
  );
5615
6001
  }
5616
6002
  function getSetFeeRecipientInstructionDataEncoder() {
5617
- return transformEncoder34(
5618
- getStructEncoder36([
5619
- ["discriminator", fixEncoderSize35(getBytesEncoder35(), 8)],
6003
+ return transformEncoder36(
6004
+ getStructEncoder38([
6005
+ ["discriminator", fixEncoderSize37(getBytesEncoder37(), 8)],
5620
6006
  ["feeRecipient", getAddressEncoder10()]
5621
6007
  ]),
5622
6008
  (value) => ({ ...value, discriminator: SET_FEE_RECIPIENT_DISCRIMINATOR })
5623
6009
  );
5624
6010
  }
5625
6011
  function getSetFeeRecipientInstructionDataDecoder() {
5626
- return getStructDecoder36([
5627
- ["discriminator", fixDecoderSize34(getBytesDecoder34(), 8)],
6012
+ return getStructDecoder38([
6013
+ ["discriminator", fixDecoderSize36(getBytesDecoder36(), 8)],
5628
6014
  ["feeRecipient", getAddressDecoder10()]
5629
6015
  ]);
5630
6016
  }
5631
6017
  function getSetFeeRecipientInstructionDataCodec() {
5632
- return combineCodec39(
6018
+ return combineCodec41(
5633
6019
  getSetFeeRecipientInstructionDataEncoder(),
5634
6020
  getSetFeeRecipientInstructionDataDecoder()
5635
6021
  );
@@ -5677,18 +6063,18 @@ function parseSetFeeRecipientInstruction(instruction) {
5677
6063
 
5678
6064
  // src/generated/instructions/setLimitOrders.ts
5679
6065
  import {
5680
- combineCodec as combineCodec40,
5681
- fixDecoderSize as fixDecoderSize35,
5682
- fixEncoderSize as fixEncoderSize36,
5683
- getBytesDecoder as getBytesDecoder35,
5684
- getBytesEncoder as getBytesEncoder36,
6066
+ combineCodec as combineCodec42,
6067
+ fixDecoderSize as fixDecoderSize37,
6068
+ fixEncoderSize as fixEncoderSize38,
6069
+ getBytesDecoder as getBytesDecoder37,
6070
+ getBytesEncoder as getBytesEncoder38,
5685
6071
  getI32Decoder as getI32Decoder6,
5686
6072
  getI32Encoder as getI32Encoder6,
5687
- getStructDecoder as getStructDecoder37,
5688
- getStructEncoder as getStructEncoder37,
6073
+ getStructDecoder as getStructDecoder39,
6074
+ getStructEncoder as getStructEncoder39,
5689
6075
  getU8Decoder as getU8Decoder7,
5690
6076
  getU8Encoder as getU8Encoder7,
5691
- transformEncoder as transformEncoder35
6077
+ transformEncoder as transformEncoder37
5692
6078
  } from "@solana/kit";
5693
6079
  var SET_LIMIT_ORDERS_DISCRIMINATOR = new Uint8Array([
5694
6080
  65,
@@ -5701,14 +6087,14 @@ var SET_LIMIT_ORDERS_DISCRIMINATOR = new Uint8Array([
5701
6087
  255
5702
6088
  ]);
5703
6089
  function getSetLimitOrdersDiscriminatorBytes() {
5704
- return fixEncoderSize36(getBytesEncoder36(), 8).encode(
6090
+ return fixEncoderSize38(getBytesEncoder38(), 8).encode(
5705
6091
  SET_LIMIT_ORDERS_DISCRIMINATOR
5706
6092
  );
5707
6093
  }
5708
6094
  function getSetLimitOrdersInstructionDataEncoder() {
5709
- return transformEncoder35(
5710
- getStructEncoder37([
5711
- ["discriminator", fixEncoderSize36(getBytesEncoder36(), 8)],
6095
+ return transformEncoder37(
6096
+ getStructEncoder39([
6097
+ ["discriminator", fixEncoderSize38(getBytesEncoder38(), 8)],
5712
6098
  ["tickStopLossIndex", getI32Encoder6()],
5713
6099
  ["tickTakeProfitIndex", getI32Encoder6()],
5714
6100
  ["swapToTokenOnLimitOrder", getU8Encoder7()]
@@ -5717,15 +6103,15 @@ function getSetLimitOrdersInstructionDataEncoder() {
5717
6103
  );
5718
6104
  }
5719
6105
  function getSetLimitOrdersInstructionDataDecoder() {
5720
- return getStructDecoder37([
5721
- ["discriminator", fixDecoderSize35(getBytesDecoder35(), 8)],
6106
+ return getStructDecoder39([
6107
+ ["discriminator", fixDecoderSize37(getBytesDecoder37(), 8)],
5722
6108
  ["tickStopLossIndex", getI32Decoder6()],
5723
6109
  ["tickTakeProfitIndex", getI32Decoder6()],
5724
6110
  ["swapToTokenOnLimitOrder", getU8Decoder7()]
5725
6111
  ]);
5726
6112
  }
5727
6113
  function getSetLimitOrdersInstructionDataCodec() {
5728
- return combineCodec40(
6114
+ return combineCodec42(
5729
6115
  getSetLimitOrdersInstructionDataEncoder(),
5730
6116
  getSetLimitOrdersInstructionDataDecoder()
5731
6117
  );
@@ -5773,16 +6159,16 @@ function parseSetLimitOrdersInstruction(instruction) {
5773
6159
 
5774
6160
  // src/generated/instructions/setLiquidatorAuthority.ts
5775
6161
  import {
5776
- combineCodec as combineCodec41,
5777
- fixDecoderSize as fixDecoderSize36,
5778
- fixEncoderSize as fixEncoderSize37,
6162
+ combineCodec as combineCodec43,
6163
+ fixDecoderSize as fixDecoderSize38,
6164
+ fixEncoderSize as fixEncoderSize39,
5779
6165
  getAddressDecoder as getAddressDecoder11,
5780
6166
  getAddressEncoder as getAddressEncoder11,
5781
- getBytesDecoder as getBytesDecoder36,
5782
- getBytesEncoder as getBytesEncoder37,
5783
- getStructDecoder as getStructDecoder38,
5784
- getStructEncoder as getStructEncoder38,
5785
- transformEncoder as transformEncoder36
6167
+ getBytesDecoder as getBytesDecoder38,
6168
+ getBytesEncoder as getBytesEncoder39,
6169
+ getStructDecoder as getStructDecoder40,
6170
+ getStructEncoder as getStructEncoder40,
6171
+ transformEncoder as transformEncoder38
5786
6172
  } from "@solana/kit";
5787
6173
  var SET_LIQUIDATOR_AUTHORITY_DISCRIMINATOR = new Uint8Array([
5788
6174
  246,
@@ -5795,14 +6181,14 @@ var SET_LIQUIDATOR_AUTHORITY_DISCRIMINATOR = new Uint8Array([
5795
6181
  143
5796
6182
  ]);
5797
6183
  function getSetLiquidatorAuthorityDiscriminatorBytes() {
5798
- return fixEncoderSize37(getBytesEncoder37(), 8).encode(
6184
+ return fixEncoderSize39(getBytesEncoder39(), 8).encode(
5799
6185
  SET_LIQUIDATOR_AUTHORITY_DISCRIMINATOR
5800
6186
  );
5801
6187
  }
5802
6188
  function getSetLiquidatorAuthorityInstructionDataEncoder() {
5803
- return transformEncoder36(
5804
- getStructEncoder38([
5805
- ["discriminator", fixEncoderSize37(getBytesEncoder37(), 8)],
6189
+ return transformEncoder38(
6190
+ getStructEncoder40([
6191
+ ["discriminator", fixEncoderSize39(getBytesEncoder39(), 8)],
5806
6192
  ["liquidatorAuthority", getAddressEncoder11()]
5807
6193
  ]),
5808
6194
  (value) => ({
@@ -5812,13 +6198,13 @@ function getSetLiquidatorAuthorityInstructionDataEncoder() {
5812
6198
  );
5813
6199
  }
5814
6200
  function getSetLiquidatorAuthorityInstructionDataDecoder() {
5815
- return getStructDecoder38([
5816
- ["discriminator", fixDecoderSize36(getBytesDecoder36(), 8)],
6201
+ return getStructDecoder40([
6202
+ ["discriminator", fixDecoderSize38(getBytesDecoder38(), 8)],
5817
6203
  ["liquidatorAuthority", getAddressDecoder11()]
5818
6204
  ]);
5819
6205
  }
5820
6206
  function getSetLiquidatorAuthorityInstructionDataCodec() {
5821
- return combineCodec41(
6207
+ return combineCodec43(
5822
6208
  getSetLiquidatorAuthorityInstructionDataEncoder(),
5823
6209
  getSetLiquidatorAuthorityInstructionDataDecoder()
5824
6210
  );
@@ -5868,16 +6254,16 @@ function parseSetLiquidatorAuthorityInstruction(instruction) {
5868
6254
 
5869
6255
  // src/generated/instructions/setOwnerAuthority.ts
5870
6256
  import {
5871
- combineCodec as combineCodec42,
5872
- fixDecoderSize as fixDecoderSize37,
5873
- fixEncoderSize as fixEncoderSize38,
6257
+ combineCodec as combineCodec44,
6258
+ fixDecoderSize as fixDecoderSize39,
6259
+ fixEncoderSize as fixEncoderSize40,
5874
6260
  getAddressDecoder as getAddressDecoder12,
5875
6261
  getAddressEncoder as getAddressEncoder12,
5876
- getBytesDecoder as getBytesDecoder37,
5877
- getBytesEncoder as getBytesEncoder38,
5878
- getStructDecoder as getStructDecoder39,
5879
- getStructEncoder as getStructEncoder39,
5880
- transformEncoder as transformEncoder37
6262
+ getBytesDecoder as getBytesDecoder39,
6263
+ getBytesEncoder as getBytesEncoder40,
6264
+ getStructDecoder as getStructDecoder41,
6265
+ getStructEncoder as getStructEncoder41,
6266
+ transformEncoder as transformEncoder39
5881
6267
  } from "@solana/kit";
5882
6268
  var SET_OWNER_AUTHORITY_DISCRIMINATOR = new Uint8Array([
5883
6269
  128,
@@ -5890,27 +6276,27 @@ var SET_OWNER_AUTHORITY_DISCRIMINATOR = new Uint8Array([
5890
6276
  117
5891
6277
  ]);
5892
6278
  function getSetOwnerAuthorityDiscriminatorBytes() {
5893
- return fixEncoderSize38(getBytesEncoder38(), 8).encode(
6279
+ return fixEncoderSize40(getBytesEncoder40(), 8).encode(
5894
6280
  SET_OWNER_AUTHORITY_DISCRIMINATOR
5895
6281
  );
5896
6282
  }
5897
6283
  function getSetOwnerAuthorityInstructionDataEncoder() {
5898
- return transformEncoder37(
5899
- getStructEncoder39([
5900
- ["discriminator", fixEncoderSize38(getBytesEncoder38(), 8)],
6284
+ return transformEncoder39(
6285
+ getStructEncoder41([
6286
+ ["discriminator", fixEncoderSize40(getBytesEncoder40(), 8)],
5901
6287
  ["ownerAuthority", getAddressEncoder12()]
5902
6288
  ]),
5903
6289
  (value) => ({ ...value, discriminator: SET_OWNER_AUTHORITY_DISCRIMINATOR })
5904
6290
  );
5905
6291
  }
5906
6292
  function getSetOwnerAuthorityInstructionDataDecoder() {
5907
- return getStructDecoder39([
5908
- ["discriminator", fixDecoderSize37(getBytesDecoder37(), 8)],
6293
+ return getStructDecoder41([
6294
+ ["discriminator", fixDecoderSize39(getBytesDecoder39(), 8)],
5909
6295
  ["ownerAuthority", getAddressDecoder12()]
5910
6296
  ]);
5911
6297
  }
5912
6298
  function getSetOwnerAuthorityInstructionDataCodec() {
5913
- return combineCodec42(
6299
+ return combineCodec44(
5914
6300
  getSetOwnerAuthorityInstructionDataEncoder(),
5915
6301
  getSetOwnerAuthorityInstructionDataDecoder()
5916
6302
  );
@@ -5958,16 +6344,16 @@ function parseSetOwnerAuthorityInstruction(instruction) {
5958
6344
 
5959
6345
  // src/generated/instructions/setSuspendedState.ts
5960
6346
  import {
5961
- combineCodec as combineCodec43,
5962
- fixDecoderSize as fixDecoderSize38,
5963
- fixEncoderSize as fixEncoderSize39,
6347
+ combineCodec as combineCodec45,
6348
+ fixDecoderSize as fixDecoderSize40,
6349
+ fixEncoderSize as fixEncoderSize41,
5964
6350
  getBooleanDecoder as getBooleanDecoder6,
5965
6351
  getBooleanEncoder as getBooleanEncoder6,
5966
- getBytesDecoder as getBytesDecoder38,
5967
- getBytesEncoder as getBytesEncoder39,
5968
- getStructDecoder as getStructDecoder40,
5969
- getStructEncoder as getStructEncoder40,
5970
- transformEncoder as transformEncoder38
6352
+ getBytesDecoder as getBytesDecoder40,
6353
+ getBytesEncoder as getBytesEncoder41,
6354
+ getStructDecoder as getStructDecoder42,
6355
+ getStructEncoder as getStructEncoder42,
6356
+ transformEncoder as transformEncoder40
5971
6357
  } from "@solana/kit";
5972
6358
  var SET_SUSPENDED_STATE_DISCRIMINATOR = new Uint8Array([
5973
6359
  145,
@@ -5980,14 +6366,14 @@ var SET_SUSPENDED_STATE_DISCRIMINATOR = new Uint8Array([
5980
6366
  32
5981
6367
  ]);
5982
6368
  function getSetSuspendedStateDiscriminatorBytes() {
5983
- return fixEncoderSize39(getBytesEncoder39(), 8).encode(
6369
+ return fixEncoderSize41(getBytesEncoder41(), 8).encode(
5984
6370
  SET_SUSPENDED_STATE_DISCRIMINATOR
5985
6371
  );
5986
6372
  }
5987
6373
  function getSetSuspendedStateInstructionDataEncoder() {
5988
- return transformEncoder38(
5989
- getStructEncoder40([
5990
- ["discriminator", fixEncoderSize39(getBytesEncoder39(), 8)],
6374
+ return transformEncoder40(
6375
+ getStructEncoder42([
6376
+ ["discriminator", fixEncoderSize41(getBytesEncoder41(), 8)],
5991
6377
  ["suspendLendingDeposits", getBooleanEncoder6()],
5992
6378
  ["suspendLendingWithdrawals", getBooleanEncoder6()],
5993
6379
  ["suspendAddLiquidity", getBooleanEncoder6()],
@@ -5997,8 +6383,8 @@ function getSetSuspendedStateInstructionDataEncoder() {
5997
6383
  );
5998
6384
  }
5999
6385
  function getSetSuspendedStateInstructionDataDecoder() {
6000
- return getStructDecoder40([
6001
- ["discriminator", fixDecoderSize38(getBytesDecoder38(), 8)],
6386
+ return getStructDecoder42([
6387
+ ["discriminator", fixDecoderSize40(getBytesDecoder40(), 8)],
6002
6388
  ["suspendLendingDeposits", getBooleanDecoder6()],
6003
6389
  ["suspendLendingWithdrawals", getBooleanDecoder6()],
6004
6390
  ["suspendAddLiquidity", getBooleanDecoder6()],
@@ -6006,7 +6392,7 @@ function getSetSuspendedStateInstructionDataDecoder() {
6006
6392
  ]);
6007
6393
  }
6008
6394
  function getSetSuspendedStateInstructionDataCodec() {
6009
- return combineCodec43(
6395
+ return combineCodec45(
6010
6396
  getSetSuspendedStateInstructionDataEncoder(),
6011
6397
  getSetSuspendedStateInstructionDataDecoder()
6012
6398
  );
@@ -6054,16 +6440,16 @@ function parseSetSuspendedStateInstruction(instruction) {
6054
6440
 
6055
6441
  // src/generated/instructions/setTunaPositionFlags.ts
6056
6442
  import {
6057
- combineCodec as combineCodec44,
6058
- fixDecoderSize as fixDecoderSize39,
6059
- fixEncoderSize as fixEncoderSize40,
6060
- getBytesDecoder as getBytesDecoder39,
6061
- getBytesEncoder as getBytesEncoder40,
6062
- getStructDecoder as getStructDecoder41,
6063
- getStructEncoder as getStructEncoder41,
6443
+ combineCodec as combineCodec46,
6444
+ fixDecoderSize as fixDecoderSize41,
6445
+ fixEncoderSize as fixEncoderSize42,
6446
+ getBytesDecoder as getBytesDecoder41,
6447
+ getBytesEncoder as getBytesEncoder42,
6448
+ getStructDecoder as getStructDecoder43,
6449
+ getStructEncoder as getStructEncoder43,
6064
6450
  getU32Decoder as getU32Decoder18,
6065
6451
  getU32Encoder as getU32Encoder18,
6066
- transformEncoder as transformEncoder39
6452
+ transformEncoder as transformEncoder41
6067
6453
  } from "@solana/kit";
6068
6454
  var SET_TUNA_POSITION_FLAGS_DISCRIMINATOR = new Uint8Array([
6069
6455
  110,
@@ -6076,14 +6462,14 @@ var SET_TUNA_POSITION_FLAGS_DISCRIMINATOR = new Uint8Array([
6076
6462
  57
6077
6463
  ]);
6078
6464
  function getSetTunaPositionFlagsDiscriminatorBytes() {
6079
- return fixEncoderSize40(getBytesEncoder40(), 8).encode(
6465
+ return fixEncoderSize42(getBytesEncoder42(), 8).encode(
6080
6466
  SET_TUNA_POSITION_FLAGS_DISCRIMINATOR
6081
6467
  );
6082
6468
  }
6083
6469
  function getSetTunaPositionFlagsInstructionDataEncoder() {
6084
- return transformEncoder39(
6085
- getStructEncoder41([
6086
- ["discriminator", fixEncoderSize40(getBytesEncoder40(), 8)],
6470
+ return transformEncoder41(
6471
+ getStructEncoder43([
6472
+ ["discriminator", fixEncoderSize42(getBytesEncoder42(), 8)],
6087
6473
  ["flags", getU32Encoder18()]
6088
6474
  ]),
6089
6475
  (value) => ({
@@ -6093,13 +6479,13 @@ function getSetTunaPositionFlagsInstructionDataEncoder() {
6093
6479
  );
6094
6480
  }
6095
6481
  function getSetTunaPositionFlagsInstructionDataDecoder() {
6096
- return getStructDecoder41([
6097
- ["discriminator", fixDecoderSize39(getBytesDecoder39(), 8)],
6482
+ return getStructDecoder43([
6483
+ ["discriminator", fixDecoderSize41(getBytesDecoder41(), 8)],
6098
6484
  ["flags", getU32Decoder18()]
6099
6485
  ]);
6100
6486
  }
6101
6487
  function getSetTunaPositionFlagsInstructionDataCodec() {
6102
- return combineCodec44(
6488
+ return combineCodec46(
6103
6489
  getSetTunaPositionFlagsInstructionDataEncoder(),
6104
6490
  getSetTunaPositionFlagsInstructionDataDecoder()
6105
6491
  );
@@ -6147,26 +6533,112 @@ function parseSetTunaPositionFlagsInstruction(instruction) {
6147
6533
  };
6148
6534
  }
6149
6535
 
6536
+ // src/generated/instructions/setTunaPositionRebalanceThreshold.ts
6537
+ import {
6538
+ combineCodec as combineCodec47,
6539
+ fixDecoderSize as fixDecoderSize42,
6540
+ fixEncoderSize as fixEncoderSize43,
6541
+ getBytesDecoder as getBytesDecoder42,
6542
+ getBytesEncoder as getBytesEncoder43,
6543
+ getStructDecoder as getStructDecoder44,
6544
+ getStructEncoder as getStructEncoder44,
6545
+ getU32Decoder as getU32Decoder19,
6546
+ getU32Encoder as getU32Encoder19,
6547
+ transformEncoder as transformEncoder42
6548
+ } from "@solana/kit";
6549
+ var SET_TUNA_POSITION_REBALANCE_THRESHOLD_DISCRIMINATOR = new Uint8Array([108, 170, 86, 159, 171, 164, 28, 51]);
6550
+ function getSetTunaPositionRebalanceThresholdDiscriminatorBytes() {
6551
+ return fixEncoderSize43(getBytesEncoder43(), 8).encode(
6552
+ SET_TUNA_POSITION_REBALANCE_THRESHOLD_DISCRIMINATOR
6553
+ );
6554
+ }
6555
+ function getSetTunaPositionRebalanceThresholdInstructionDataEncoder() {
6556
+ return transformEncoder42(
6557
+ getStructEncoder44([
6558
+ ["discriminator", fixEncoderSize43(getBytesEncoder43(), 8)],
6559
+ ["rebalanceThresholdTicks", getU32Encoder19()]
6560
+ ]),
6561
+ (value) => ({
6562
+ ...value,
6563
+ discriminator: SET_TUNA_POSITION_REBALANCE_THRESHOLD_DISCRIMINATOR
6564
+ })
6565
+ );
6566
+ }
6567
+ function getSetTunaPositionRebalanceThresholdInstructionDataDecoder() {
6568
+ return getStructDecoder44([
6569
+ ["discriminator", fixDecoderSize42(getBytesDecoder42(), 8)],
6570
+ ["rebalanceThresholdTicks", getU32Decoder19()]
6571
+ ]);
6572
+ }
6573
+ function getSetTunaPositionRebalanceThresholdInstructionDataCodec() {
6574
+ return combineCodec47(
6575
+ getSetTunaPositionRebalanceThresholdInstructionDataEncoder(),
6576
+ getSetTunaPositionRebalanceThresholdInstructionDataDecoder()
6577
+ );
6578
+ }
6579
+ function getSetTunaPositionRebalanceThresholdInstruction(input, config) {
6580
+ const programAddress = config?.programAddress ?? TUNA_PROGRAM_ADDRESS;
6581
+ const originalAccounts = {
6582
+ authority: { value: input.authority ?? null, isWritable: false },
6583
+ tunaPosition: { value: input.tunaPosition ?? null, isWritable: true }
6584
+ };
6585
+ const accounts = originalAccounts;
6586
+ const args = { ...input };
6587
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
6588
+ const instruction = {
6589
+ accounts: [
6590
+ getAccountMeta(accounts.authority),
6591
+ getAccountMeta(accounts.tunaPosition)
6592
+ ],
6593
+ programAddress,
6594
+ data: getSetTunaPositionRebalanceThresholdInstructionDataEncoder().encode(
6595
+ args
6596
+ )
6597
+ };
6598
+ return instruction;
6599
+ }
6600
+ function parseSetTunaPositionRebalanceThresholdInstruction(instruction) {
6601
+ if (instruction.accounts.length < 2) {
6602
+ throw new Error("Not enough accounts");
6603
+ }
6604
+ let accountIndex = 0;
6605
+ const getNextAccount = () => {
6606
+ const accountMeta = instruction.accounts[accountIndex];
6607
+ accountIndex += 1;
6608
+ return accountMeta;
6609
+ };
6610
+ return {
6611
+ programAddress: instruction.programAddress,
6612
+ accounts: {
6613
+ authority: getNextAccount(),
6614
+ tunaPosition: getNextAccount()
6615
+ },
6616
+ data: getSetTunaPositionRebalanceThresholdInstructionDataDecoder().decode(
6617
+ instruction.data
6618
+ )
6619
+ };
6620
+ }
6621
+
6150
6622
  // src/generated/instructions/updateMarket.ts
6151
6623
  import {
6152
- combineCodec as combineCodec45,
6153
- fixDecoderSize as fixDecoderSize40,
6154
- fixEncoderSize as fixEncoderSize41,
6624
+ combineCodec as combineCodec48,
6625
+ fixDecoderSize as fixDecoderSize43,
6626
+ fixEncoderSize as fixEncoderSize44,
6155
6627
  getAddressDecoder as getAddressDecoder13,
6156
6628
  getAddressEncoder as getAddressEncoder13,
6157
6629
  getBooleanDecoder as getBooleanDecoder7,
6158
6630
  getBooleanEncoder as getBooleanEncoder7,
6159
- getBytesDecoder as getBytesDecoder40,
6160
- getBytesEncoder as getBytesEncoder41,
6161
- getStructDecoder as getStructDecoder42,
6162
- getStructEncoder as getStructEncoder42,
6631
+ getBytesDecoder as getBytesDecoder43,
6632
+ getBytesEncoder as getBytesEncoder44,
6633
+ getStructDecoder as getStructDecoder45,
6634
+ getStructEncoder as getStructEncoder45,
6163
6635
  getU16Decoder as getU16Decoder7,
6164
6636
  getU16Encoder as getU16Encoder7,
6165
- getU32Decoder as getU32Decoder19,
6166
- getU32Encoder as getU32Encoder19,
6637
+ getU32Decoder as getU32Decoder20,
6638
+ getU32Encoder as getU32Encoder20,
6167
6639
  getU64Decoder as getU64Decoder16,
6168
6640
  getU64Encoder as getU64Encoder16,
6169
- transformEncoder as transformEncoder40
6641
+ transformEncoder as transformEncoder43
6170
6642
  } from "@solana/kit";
6171
6643
  var UPDATE_MARKET_DISCRIMINATOR = new Uint8Array([
6172
6644
  153,
@@ -6179,49 +6651,49 @@ var UPDATE_MARKET_DISCRIMINATOR = new Uint8Array([
6179
6651
  217
6180
6652
  ]);
6181
6653
  function getUpdateMarketDiscriminatorBytes() {
6182
- return fixEncoderSize41(getBytesEncoder41(), 8).encode(
6654
+ return fixEncoderSize44(getBytesEncoder44(), 8).encode(
6183
6655
  UPDATE_MARKET_DISCRIMINATOR
6184
6656
  );
6185
6657
  }
6186
6658
  function getUpdateMarketInstructionDataEncoder() {
6187
- return transformEncoder40(
6188
- getStructEncoder42([
6189
- ["discriminator", fixEncoderSize41(getBytesEncoder41(), 8)],
6659
+ return transformEncoder43(
6660
+ getStructEncoder45([
6661
+ ["discriminator", fixEncoderSize44(getBytesEncoder44(), 8)],
6190
6662
  ["addressLookupTable", getAddressEncoder13()],
6191
- ["maxLeverage", getU32Encoder19()],
6663
+ ["maxLeverage", getU32Encoder20()],
6192
6664
  ["protocolFee", getU16Encoder7()],
6193
6665
  ["protocolFeeOnCollateral", getU16Encoder7()],
6194
- ["liquidationFee", getU32Encoder19()],
6195
- ["liquidationThreshold", getU32Encoder19()],
6196
- ["limitOrderExecutionFee", getU32Encoder19()],
6197
- ["oraclePriceDeviationThreshold", getU32Encoder19()],
6666
+ ["liquidationFee", getU32Encoder20()],
6667
+ ["liquidationThreshold", getU32Encoder20()],
6668
+ ["limitOrderExecutionFee", getU32Encoder20()],
6669
+ ["oraclePriceDeviationThreshold", getU32Encoder20()],
6198
6670
  ["disabled", getBooleanEncoder7()],
6199
6671
  ["borrowLimitA", getU64Encoder16()],
6200
6672
  ["borrowLimitB", getU64Encoder16()],
6201
- ["maxSwapSlippage", getU32Encoder19()]
6673
+ ["maxSwapSlippage", getU32Encoder20()]
6202
6674
  ]),
6203
6675
  (value) => ({ ...value, discriminator: UPDATE_MARKET_DISCRIMINATOR })
6204
6676
  );
6205
6677
  }
6206
6678
  function getUpdateMarketInstructionDataDecoder() {
6207
- return getStructDecoder42([
6208
- ["discriminator", fixDecoderSize40(getBytesDecoder40(), 8)],
6679
+ return getStructDecoder45([
6680
+ ["discriminator", fixDecoderSize43(getBytesDecoder43(), 8)],
6209
6681
  ["addressLookupTable", getAddressDecoder13()],
6210
- ["maxLeverage", getU32Decoder19()],
6682
+ ["maxLeverage", getU32Decoder20()],
6211
6683
  ["protocolFee", getU16Decoder7()],
6212
6684
  ["protocolFeeOnCollateral", getU16Decoder7()],
6213
- ["liquidationFee", getU32Decoder19()],
6214
- ["liquidationThreshold", getU32Decoder19()],
6215
- ["limitOrderExecutionFee", getU32Decoder19()],
6216
- ["oraclePriceDeviationThreshold", getU32Decoder19()],
6685
+ ["liquidationFee", getU32Decoder20()],
6686
+ ["liquidationThreshold", getU32Decoder20()],
6687
+ ["limitOrderExecutionFee", getU32Decoder20()],
6688
+ ["oraclePriceDeviationThreshold", getU32Decoder20()],
6217
6689
  ["disabled", getBooleanDecoder7()],
6218
6690
  ["borrowLimitA", getU64Decoder16()],
6219
6691
  ["borrowLimitB", getU64Decoder16()],
6220
- ["maxSwapSlippage", getU32Decoder19()]
6692
+ ["maxSwapSlippage", getU32Decoder20()]
6221
6693
  ]);
6222
6694
  }
6223
6695
  function getUpdateMarketInstructionDataCodec() {
6224
- return combineCodec45(
6696
+ return combineCodec48(
6225
6697
  getUpdateMarketInstructionDataEncoder(),
6226
6698
  getUpdateMarketInstructionDataDecoder()
6227
6699
  );
@@ -6272,18 +6744,18 @@ function parseUpdateMarketInstruction(instruction) {
6272
6744
 
6273
6745
  // src/generated/instructions/updateVault.ts
6274
6746
  import {
6275
- combineCodec as combineCodec46,
6276
- fixDecoderSize as fixDecoderSize41,
6277
- fixEncoderSize as fixEncoderSize42,
6747
+ combineCodec as combineCodec49,
6748
+ fixDecoderSize as fixDecoderSize44,
6749
+ fixEncoderSize as fixEncoderSize45,
6278
6750
  getAddressDecoder as getAddressDecoder14,
6279
6751
  getAddressEncoder as getAddressEncoder14,
6280
- getBytesDecoder as getBytesDecoder41,
6281
- getBytesEncoder as getBytesEncoder42,
6282
- getStructDecoder as getStructDecoder43,
6283
- getStructEncoder as getStructEncoder43,
6752
+ getBytesDecoder as getBytesDecoder44,
6753
+ getBytesEncoder as getBytesEncoder45,
6754
+ getStructDecoder as getStructDecoder46,
6755
+ getStructEncoder as getStructEncoder46,
6284
6756
  getU64Decoder as getU64Decoder17,
6285
6757
  getU64Encoder as getU64Encoder17,
6286
- transformEncoder as transformEncoder41
6758
+ transformEncoder as transformEncoder44
6287
6759
  } from "@solana/kit";
6288
6760
  var UPDATE_VAULT_DISCRIMINATOR = new Uint8Array([
6289
6761
  67,
@@ -6296,14 +6768,14 @@ var UPDATE_VAULT_DISCRIMINATOR = new Uint8Array([
6296
6768
  60
6297
6769
  ]);
6298
6770
  function getUpdateVaultDiscriminatorBytes() {
6299
- return fixEncoderSize42(getBytesEncoder42(), 8).encode(
6771
+ return fixEncoderSize45(getBytesEncoder45(), 8).encode(
6300
6772
  UPDATE_VAULT_DISCRIMINATOR
6301
6773
  );
6302
6774
  }
6303
6775
  function getUpdateVaultInstructionDataEncoder() {
6304
- return transformEncoder41(
6305
- getStructEncoder43([
6306
- ["discriminator", fixEncoderSize42(getBytesEncoder42(), 8)],
6776
+ return transformEncoder44(
6777
+ getStructEncoder46([
6778
+ ["discriminator", fixEncoderSize45(getBytesEncoder45(), 8)],
6307
6779
  ["interestRate", getU64Encoder17()],
6308
6780
  ["supplyLimit", getU64Encoder17()],
6309
6781
  ["pythOraclePriceUpdate", getAddressEncoder14()],
@@ -6313,8 +6785,8 @@ function getUpdateVaultInstructionDataEncoder() {
6313
6785
  );
6314
6786
  }
6315
6787
  function getUpdateVaultInstructionDataDecoder() {
6316
- return getStructDecoder43([
6317
- ["discriminator", fixDecoderSize41(getBytesDecoder41(), 8)],
6788
+ return getStructDecoder46([
6789
+ ["discriminator", fixDecoderSize44(getBytesDecoder44(), 8)],
6318
6790
  ["interestRate", getU64Decoder17()],
6319
6791
  ["supplyLimit", getU64Decoder17()],
6320
6792
  ["pythOraclePriceUpdate", getAddressDecoder14()],
@@ -6322,7 +6794,7 @@ function getUpdateVaultInstructionDataDecoder() {
6322
6794
  ]);
6323
6795
  }
6324
6796
  function getUpdateVaultInstructionDataCodec() {
6325
- return combineCodec46(
6797
+ return combineCodec49(
6326
6798
  getUpdateVaultInstructionDataEncoder(),
6327
6799
  getUpdateVaultInstructionDataDecoder()
6328
6800
  );
@@ -6373,16 +6845,16 @@ function parseUpdateVaultInstruction(instruction) {
6373
6845
 
6374
6846
  // src/generated/instructions/withdraw.ts
6375
6847
  import {
6376
- combineCodec as combineCodec47,
6377
- fixDecoderSize as fixDecoderSize42,
6378
- fixEncoderSize as fixEncoderSize43,
6379
- getBytesDecoder as getBytesDecoder42,
6380
- getBytesEncoder as getBytesEncoder43,
6381
- getStructDecoder as getStructDecoder44,
6382
- getStructEncoder as getStructEncoder44,
6848
+ combineCodec as combineCodec50,
6849
+ fixDecoderSize as fixDecoderSize45,
6850
+ fixEncoderSize as fixEncoderSize46,
6851
+ getBytesDecoder as getBytesDecoder45,
6852
+ getBytesEncoder as getBytesEncoder46,
6853
+ getStructDecoder as getStructDecoder47,
6854
+ getStructEncoder as getStructEncoder47,
6383
6855
  getU64Decoder as getU64Decoder18,
6384
6856
  getU64Encoder as getU64Encoder18,
6385
- transformEncoder as transformEncoder42
6857
+ transformEncoder as transformEncoder45
6386
6858
  } from "@solana/kit";
6387
6859
  var WITHDRAW_DISCRIMINATOR = new Uint8Array([
6388
6860
  183,
@@ -6395,12 +6867,12 @@ var WITHDRAW_DISCRIMINATOR = new Uint8Array([
6395
6867
  34
6396
6868
  ]);
6397
6869
  function getWithdrawDiscriminatorBytes() {
6398
- return fixEncoderSize43(getBytesEncoder43(), 8).encode(WITHDRAW_DISCRIMINATOR);
6870
+ return fixEncoderSize46(getBytesEncoder46(), 8).encode(WITHDRAW_DISCRIMINATOR);
6399
6871
  }
6400
6872
  function getWithdrawInstructionDataEncoder() {
6401
- return transformEncoder42(
6402
- getStructEncoder44([
6403
- ["discriminator", fixEncoderSize43(getBytesEncoder43(), 8)],
6873
+ return transformEncoder45(
6874
+ getStructEncoder47([
6875
+ ["discriminator", fixEncoderSize46(getBytesEncoder46(), 8)],
6404
6876
  ["funds", getU64Encoder18()],
6405
6877
  ["shares", getU64Encoder18()]
6406
6878
  ]),
@@ -6408,14 +6880,14 @@ function getWithdrawInstructionDataEncoder() {
6408
6880
  );
6409
6881
  }
6410
6882
  function getWithdrawInstructionDataDecoder() {
6411
- return getStructDecoder44([
6412
- ["discriminator", fixDecoderSize42(getBytesDecoder42(), 8)],
6883
+ return getStructDecoder47([
6884
+ ["discriminator", fixDecoderSize45(getBytesDecoder45(), 8)],
6413
6885
  ["funds", getU64Decoder18()],
6414
6886
  ["shares", getU64Decoder18()]
6415
6887
  ]);
6416
6888
  }
6417
6889
  function getWithdrawInstructionDataCodec() {
6418
- return combineCodec47(
6890
+ return combineCodec50(
6419
6891
  getWithdrawInstructionDataEncoder(),
6420
6892
  getWithdrawInstructionDataDecoder()
6421
6893
  );
@@ -6656,6 +7128,7 @@ async function fetchAllLendingPositionWithFilter(rpc, ...filters) {
6656
7128
  }
6657
7129
 
6658
7130
  // src/utils/orca.ts
7131
+ import { getInitializableTickIndex } from "@crypticdot/fusionamm-core";
6659
7132
  import { getTickArrayAddress } from "@orca-so/whirlpools-client";
6660
7133
  import { _TICK_ARRAY_SIZE, getTickArrayStartTickIndex } from "@orca-so/whirlpools-core";
6661
7134
  var OrcaUtils = class {
@@ -6676,33 +7149,60 @@ var OrcaUtils = class {
6676
7149
  )
6677
7150
  );
6678
7151
  }
7152
+ static async getTickArraysForRebalancedPosition(whirlpool, tunaPosition) {
7153
+ const positionRange = tunaPosition.data.tickUpperIndex - tunaPosition.data.tickLowerIndex;
7154
+ const newTickLowerIndex = getInitializableTickIndex(
7155
+ whirlpool.data.tickCurrentIndex - Math.trunc(positionRange / 2),
7156
+ whirlpool.data.tickSpacing
7157
+ );
7158
+ const newTickUpperIndex = newTickLowerIndex + positionRange;
7159
+ const lowerTickArrayStartIndex = getTickArrayStartTickIndex(newTickLowerIndex, whirlpool.data.tickSpacing);
7160
+ const [lowerTickArrayAddress] = await getTickArrayAddress(whirlpool.address, lowerTickArrayStartIndex);
7161
+ const upperTickArrayStartIndex = getTickArrayStartTickIndex(newTickUpperIndex, whirlpool.data.tickSpacing);
7162
+ const [upperTickArrayAddress] = await getTickArrayAddress(whirlpool.address, upperTickArrayStartIndex);
7163
+ return { lowerTickArrayAddress, lowerTickArrayStartIndex, upperTickArrayAddress, upperTickArrayStartIndex };
7164
+ }
6679
7165
  };
6680
7166
 
6681
7167
  // src/utils/fusion.ts
6682
7168
  import { getTickArrayAddress as getTickArrayAddress2 } from "@crypticdot/fusionamm-client";
6683
- import { _TICK_ARRAY_SIZE as _TICK_ARRAY_SIZE2, getTickArrayStartTickIndex as getTickArrayStartTickIndex2 } from "@crypticdot/fusionamm-core";
7169
+ import { _TICK_ARRAY_SIZE as _TICK_ARRAY_SIZE2, getInitializableTickIndex as getInitializableTickIndex2, getTickArrayStartTickIndex as getTickArrayStartTickIndex2 } from "@crypticdot/fusionamm-core";
6684
7170
  var FusionUtils = class {
6685
- static async getTickArrayAddressFromTickIndex(whirlpool, tickIndex) {
6686
- const tickArrayStartTickIndex = getTickArrayStartTickIndex2(tickIndex, whirlpool.data.tickSpacing);
6687
- const [tickArrayPda] = await getTickArrayAddress2(whirlpool.address, tickArrayStartTickIndex);
7171
+ static async getTickArrayAddressFromTickIndex(fusionPool, tickIndex) {
7172
+ const tickArrayStartTickIndex = getTickArrayStartTickIndex2(tickIndex, fusionPool.data.tickSpacing);
7173
+ const [tickArrayPda] = await getTickArrayAddress2(fusionPool.address, tickArrayStartTickIndex);
6688
7174
  return tickArrayPda;
6689
7175
  }
6690
- static async getSwapTickArrayAddresses(whirlpool) {
6691
- const tickArrayStep = _TICK_ARRAY_SIZE2() * whirlpool.data.tickSpacing;
7176
+ static async getSwapTickArrayAddresses(fusionPool) {
7177
+ const tickArrayStep = _TICK_ARRAY_SIZE2() * fusionPool.data.tickSpacing;
6692
7178
  const currentArrayStartTickIndex = getTickArrayStartTickIndex2(
6693
- whirlpool.data.tickCurrentIndex,
6694
- whirlpool.data.tickSpacing
7179
+ fusionPool.data.tickCurrentIndex,
7180
+ fusionPool.data.tickSpacing
6695
7181
  );
6696
7182
  return Promise.all(
6697
7183
  [-2, -1, 0, 1, 2].map(
6698
- async (i) => (await getTickArrayAddress2(whirlpool.address, currentArrayStartTickIndex + i * tickArrayStep))[0]
7184
+ async (i) => (await getTickArrayAddress2(fusionPool.address, currentArrayStartTickIndex + i * tickArrayStep))[0]
6699
7185
  )
6700
7186
  );
6701
7187
  }
7188
+ static async getTickArraysForRebalancedPosition(fusionPool, tunaPosition) {
7189
+ const positionRange = tunaPosition.data.tickUpperIndex - tunaPosition.data.tickLowerIndex;
7190
+ const newTickLowerIndex = getInitializableTickIndex2(
7191
+ fusionPool.data.tickCurrentIndex - Math.trunc(positionRange / 2),
7192
+ fusionPool.data.tickSpacing
7193
+ );
7194
+ const newTickUpperIndex = newTickLowerIndex + positionRange;
7195
+ const lowerTickArrayStartIndex = getTickArrayStartTickIndex2(newTickLowerIndex, fusionPool.data.tickSpacing);
7196
+ const [lowerTickArrayAddress] = await getTickArrayAddress2(fusionPool.address, lowerTickArrayStartIndex);
7197
+ const upperTickArrayStartIndex = getTickArrayStartTickIndex2(newTickUpperIndex, fusionPool.data.tickSpacing);
7198
+ const [upperTickArrayAddress] = await getTickArrayAddress2(fusionPool.address, upperTickArrayStartIndex);
7199
+ return { lowerTickArrayAddress, lowerTickArrayStartIndex, upperTickArrayAddress, upperTickArrayStartIndex };
7200
+ }
6702
7201
  };
6703
7202
 
6704
7203
  // src/utils/token.ts
6705
7204
  import { address } from "@solana/kit";
7205
+ import { getTransferSolInstruction } from "@solana-program/system";
6706
7206
  import { findAssociatedTokenPda, TOKEN_PROGRAM_ADDRESS } from "@solana-program/token";
6707
7207
  import {
6708
7208
  fetchMaybeToken,
@@ -6710,7 +7210,6 @@ import {
6710
7210
  getCreateAssociatedTokenIdempotentInstruction,
6711
7211
  getSyncNativeInstruction
6712
7212
  } from "@solana-program/token-2022";
6713
- import { getTransferSolInstruction } from "@solana-program/system";
6714
7213
  var NATIVE_MINT = address("So11111111111111111111111111111111111111112");
6715
7214
  async function getCreateAtaInstruction(mint, owner, payer, tokenProgram = TOKEN_PROGRAM_ADDRESS) {
6716
7215
  const ata = (await findAssociatedTokenPda({
@@ -6809,6 +7308,7 @@ var TUNA_POSITION_FLAGS_TAKE_PROFIT_SWAP_TO_TOKEN_A = 1 << 2;
6809
7308
  var TUNA_POSITION_FLAGS_TAKE_PROFIT_SWAP_TO_TOKEN_B = 1 << 3;
6810
7309
  var TUNA_POSITION_FLAGS_AUTO_COMPOUND_YIELD = 1 << 4;
6811
7310
  var TUNA_POSITION_FLAGS_AUTO_COMPOUND_YIELD_WITH_LEVERAGE = 1 << 5;
7311
+ var TUNA_POSITION_FLAGS_ALLOW_REBALANCING = 1 << 6;
6812
7312
  var WP_NFT_UPDATE_AUTH = address2("3axbTs2z5GBy6usVbNVoqEgZMng3vZvMnAoX29BFfwhr");
6813
7313
 
6814
7314
  // src/utils/positionMath.ts
@@ -7131,9 +7631,9 @@ async function addLiquidityOrcaInstruction(authority, tunaPosition, tunaConfig,
7131
7631
  { accountsType: 0 /* SwapTickArrays */, length: 5 },
7132
7632
  { accountsType: 1 /* TickArrayLower */, length: 1 },
7133
7633
  { accountsType: 2 /* TickArrayUpper */, length: 1 },
7134
- { accountsType: 3 /* PoolVaultTokenA */, length: 1 },
7135
- { accountsType: 4 /* PoolVaultTokenB */, length: 1 },
7136
- { accountsType: 5 /* WhirlpoolOracle */, length: 1 }
7634
+ { accountsType: 5 /* PoolVaultTokenA */, length: 1 },
7635
+ { accountsType: 6 /* PoolVaultTokenB */, length: 1 },
7636
+ { accountsType: 7 /* WhirlpoolOracle */, length: 1 }
7137
7637
  ]
7138
7638
  };
7139
7639
  const ix = getAddLiquidityOrcaInstruction({
@@ -7381,8 +7881,8 @@ async function addLiquidityFusionInstruction(authority, tunaPosition, tunaConfig
7381
7881
  { accountsType: 0 /* SwapTickArrays */, length: 5 },
7382
7882
  { accountsType: 1 /* TickArrayLower */, length: 1 },
7383
7883
  { accountsType: 2 /* TickArrayUpper */, length: 1 },
7384
- { accountsType: 3 /* PoolVaultTokenA */, length: 1 },
7385
- { accountsType: 4 /* PoolVaultTokenB */, length: 1 }
7884
+ { accountsType: 5 /* PoolVaultTokenA */, length: 1 },
7885
+ { accountsType: 6 /* PoolVaultTokenB */, length: 1 }
7386
7886
  ]
7387
7887
  };
7388
7888
  const ix = getAddLiquidityFusionInstruction({
@@ -7639,9 +8139,9 @@ async function collectAndCompoundFeesOrcaInstruction(authority, tunaConfig, tuna
7639
8139
  { accountsType: 0 /* SwapTickArrays */, length: 5 },
7640
8140
  { accountsType: 1 /* TickArrayLower */, length: 1 },
7641
8141
  { accountsType: 2 /* TickArrayUpper */, length: 1 },
7642
- { accountsType: 3 /* PoolVaultTokenA */, length: 1 },
7643
- { accountsType: 4 /* PoolVaultTokenB */, length: 1 },
7644
- { accountsType: 5 /* WhirlpoolOracle */, length: 1 }
8142
+ { accountsType: 5 /* PoolVaultTokenA */, length: 1 },
8143
+ { accountsType: 6 /* PoolVaultTokenB */, length: 1 },
8144
+ { accountsType: 7 /* WhirlpoolOracle */, length: 1 }
7645
8145
  ]
7646
8146
  };
7647
8147
  const ix = getCollectAndCompoundFeesOrcaInstruction({
@@ -7801,8 +8301,8 @@ async function collectAndCompoundFeesFusionInstruction(authority, tunaConfig, tu
7801
8301
  { accountsType: 0 /* SwapTickArrays */, length: 5 },
7802
8302
  { accountsType: 1 /* TickArrayLower */, length: 1 },
7803
8303
  { accountsType: 2 /* TickArrayUpper */, length: 1 },
7804
- { accountsType: 3 /* PoolVaultTokenA */, length: 1 },
7805
- { accountsType: 4 /* PoolVaultTokenB */, length: 1 }
8304
+ { accountsType: 5 /* PoolVaultTokenA */, length: 1 },
8305
+ { accountsType: 6 /* PoolVaultTokenB */, length: 1 }
7806
8306
  ]
7807
8307
  };
7808
8308
  const ix = getCollectAndCompoundFeesFusionInstruction({
@@ -7933,8 +8433,8 @@ async function collectFeesOrcaInstruction(authority, tunaPosition, mintA, mintB,
7933
8433
  slices: [
7934
8434
  { accountsType: 1 /* TickArrayLower */, length: 1 },
7935
8435
  { accountsType: 2 /* TickArrayUpper */, length: 1 },
7936
- { accountsType: 3 /* PoolVaultTokenA */, length: 1 },
7937
- { accountsType: 4 /* PoolVaultTokenB */, length: 1 }
8436
+ { accountsType: 5 /* PoolVaultTokenA */, length: 1 },
8437
+ { accountsType: 6 /* PoolVaultTokenB */, length: 1 }
7938
8438
  ]
7939
8439
  };
7940
8440
  const ix = getCollectFeesOrcaInstruction({
@@ -8057,8 +8557,8 @@ async function collectFeesFusionInstruction(authority, tunaPosition, mintA, mint
8057
8557
  slices: [
8058
8558
  { accountsType: 1 /* TickArrayLower */, length: 1 },
8059
8559
  { accountsType: 2 /* TickArrayUpper */, length: 1 },
8060
- { accountsType: 3 /* PoolVaultTokenA */, length: 1 },
8061
- { accountsType: 4 /* PoolVaultTokenB */, length: 1 }
8560
+ { accountsType: 5 /* PoolVaultTokenA */, length: 1 },
8561
+ { accountsType: 6 /* PoolVaultTokenB */, length: 1 }
8062
8562
  ]
8063
8563
  };
8064
8564
  const ix = getCollectFeesFusionInstruction({
@@ -8390,7 +8890,7 @@ async function createMarketInstruction(authority, pool, args) {
8390
8890
  }
8391
8891
 
8392
8892
  // src/txbuilder/createTunaConfig.ts
8393
- async function createTunaConfigInstruction(authority, adminAuthority, feeRecipient, liquidatorAuthority, ownerAuthority) {
8893
+ async function createTunaConfigInstruction(authority, ownerAuthority, adminAuthority, liquidatorAuthority, feeRecipient) {
8394
8894
  const tunaConfigAddress = await getTunaConfigAddress();
8395
8895
  return getCreateTunaConfigInstruction({
8396
8896
  adminAuthority,
@@ -8531,9 +9031,9 @@ async function liquidatePositionOrcaInstruction(authority, tunaPosition, mintA,
8531
9031
  { accountsType: 0 /* SwapTickArrays */, length: 5 },
8532
9032
  { accountsType: 1 /* TickArrayLower */, length: 1 },
8533
9033
  { accountsType: 2 /* TickArrayUpper */, length: 1 },
8534
- { accountsType: 3 /* PoolVaultTokenA */, length: 1 },
8535
- { accountsType: 4 /* PoolVaultTokenB */, length: 1 },
8536
- { accountsType: 5 /* WhirlpoolOracle */, length: 1 }
9034
+ { accountsType: 5 /* PoolVaultTokenA */, length: 1 },
9035
+ { accountsType: 6 /* PoolVaultTokenB */, length: 1 },
9036
+ { accountsType: 7 /* WhirlpoolOracle */, length: 1 }
8537
9037
  ]
8538
9038
  };
8539
9039
  const ix = getLiquidatePositionOrcaInstruction({
@@ -8670,8 +9170,8 @@ async function liquidatePositionFusionInstruction(authority, tunaPosition, mintA
8670
9170
  { accountsType: 0 /* SwapTickArrays */, length: 5 },
8671
9171
  { accountsType: 1 /* TickArrayLower */, length: 1 },
8672
9172
  { accountsType: 2 /* TickArrayUpper */, length: 1 },
8673
- { accountsType: 3 /* PoolVaultTokenA */, length: 1 },
8674
- { accountsType: 4 /* PoolVaultTokenB */, length: 1 }
9173
+ { accountsType: 5 /* PoolVaultTokenA */, length: 1 },
9174
+ { accountsType: 6 /* PoolVaultTokenB */, length: 1 }
8675
9175
  ]
8676
9176
  };
8677
9177
  const ix = getLiquidatePositionFusionInstruction({
@@ -9017,9 +9517,9 @@ async function openPositionWithLiquidityOrcaInstruction(authority, positionMint,
9017
9517
  { accountsType: 0 /* SwapTickArrays */, length: 5 },
9018
9518
  { accountsType: 1 /* TickArrayLower */, length: 1 },
9019
9519
  { accountsType: 2 /* TickArrayUpper */, length: 1 },
9020
- { accountsType: 3 /* PoolVaultTokenA */, length: 1 },
9021
- { accountsType: 4 /* PoolVaultTokenB */, length: 1 },
9022
- { accountsType: 5 /* WhirlpoolOracle */, length: 1 }
9520
+ { accountsType: 5 /* PoolVaultTokenA */, length: 1 },
9521
+ { accountsType: 6 /* PoolVaultTokenB */, length: 1 },
9522
+ { accountsType: 7 /* WhirlpoolOracle */, length: 1 }
9023
9523
  ]
9024
9524
  };
9025
9525
  const ix = getOpenPositionWithLiquidityOrcaInstruction({
@@ -9258,8 +9758,8 @@ async function openPositionWithLiquidityFusionInstruction(authority, positionMin
9258
9758
  { accountsType: 0 /* SwapTickArrays */, length: 5 },
9259
9759
  { accountsType: 1 /* TickArrayLower */, length: 1 },
9260
9760
  { accountsType: 2 /* TickArrayUpper */, length: 1 },
9261
- { accountsType: 3 /* PoolVaultTokenA */, length: 1 },
9262
- { accountsType: 4 /* PoolVaultTokenB */, length: 1 }
9761
+ { accountsType: 5 /* PoolVaultTokenA */, length: 1 },
9762
+ { accountsType: 6 /* PoolVaultTokenB */, length: 1 }
9263
9763
  ]
9264
9764
  };
9265
9765
  const ix = getOpenPositionWithLiquidityFusionInstruction({
@@ -9482,13 +9982,13 @@ async function removeLiquidityOrcaInstruction(authority, tunaPosition, mintA, mi
9482
9982
  { accountsType: 0 /* SwapTickArrays */, length: 5 },
9483
9983
  { accountsType: 1 /* TickArrayLower */, length: 1 },
9484
9984
  { accountsType: 2 /* TickArrayUpper */, length: 1 },
9485
- { accountsType: 3 /* PoolVaultTokenA */, length: 1 },
9486
- { accountsType: 4 /* PoolVaultTokenB */, length: 1 },
9487
- { accountsType: 5 /* WhirlpoolOracle */, length: 1 }
9985
+ { accountsType: 5 /* PoolVaultTokenA */, length: 1 },
9986
+ { accountsType: 6 /* PoolVaultTokenB */, length: 1 },
9987
+ { accountsType: 7 /* WhirlpoolOracle */, length: 1 }
9488
9988
  ]
9489
9989
  };
9490
9990
  if (rewardIndicesToClaim.length > 0) {
9491
- remainingAccountsInfo.slices.push({ accountsType: 6 /* Rewards */, length: 4 * rewardIndicesToClaim.length });
9991
+ remainingAccountsInfo.slices.push({ accountsType: 8 /* Rewards */, length: 4 * rewardIndicesToClaim.length });
9492
9992
  }
9493
9993
  const ix = getRemoveLiquidityOrcaInstruction({
9494
9994
  market: marketAddress,
@@ -9546,25 +10046,28 @@ async function removeLiquidityFusionInstructions(rpc, authority, positionMint, a
9546
10046
  (await getLendingVaultAddress(fusionPool.data.tokenMintA))[0],
9547
10047
  (await getLendingVaultAddress(fusionPool.data.tokenMintB))[0]
9548
10048
  ]);
9549
- const [mintA, mintB, ...rewardMints] = await fetchAllMaybeMint16(rpc, [
9550
- fusionPool.data.tokenMintA,
9551
- fusionPool.data.tokenMintB
9552
- ]);
9553
- const allMints = [mintA, mintB, ...rewardMints];
10049
+ const [mintA, mintB] = await fetchAllMaybeMint16(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
9554
10050
  assert16(mintA.exists, "Token A account not found");
9555
10051
  assert16(mintB.exists, "Token B account not found");
9556
10052
  const instructions = [];
9557
10053
  if (!createInstructions) createInstructions = instructions;
9558
10054
  if (!cleanupInstructions) cleanupInstructions = instructions;
9559
- const internalCleanupInstructions = [];
9560
- const requiredMints = [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB];
9561
- for (const mintAddress of requiredMints) {
9562
- const mint = allMints.find((mint2) => mint2.address == mintAddress);
9563
- assert16(mint && mint.exists);
9564
- const ixs = await getCreateAtaInstructions(rpc, authority, mint.address, authority.address, mint.programAddress);
9565
- createInstructions.push(...ixs.init);
9566
- internalCleanupInstructions.push(...ixs.cleanup);
9567
- }
10055
+ const createUserAtaAInstructions = await getCreateAtaInstructions(
10056
+ rpc,
10057
+ authority,
10058
+ mintA.address,
10059
+ authority.address,
10060
+ mintA.programAddress
10061
+ );
10062
+ createInstructions.push(...createUserAtaAInstructions.init);
10063
+ const createUserAtaBInstructions = await getCreateAtaInstructions(
10064
+ rpc,
10065
+ authority,
10066
+ mintB.address,
10067
+ authority.address,
10068
+ mintB.programAddress
10069
+ );
10070
+ createInstructions.push(...createUserAtaBInstructions.init);
9568
10071
  const ix = await removeLiquidityFusionInstruction(
9569
10072
  authority,
9570
10073
  tunaPosition,
@@ -9577,7 +10080,8 @@ async function removeLiquidityFusionInstructions(rpc, authority, positionMint, a
9577
10080
  { ...args, minRemovedAmountA: 0, minRemovedAmountB: 0 }
9578
10081
  );
9579
10082
  instructions.push(ix);
9580
- cleanupInstructions.push(...internalCleanupInstructions);
10083
+ cleanupInstructions.push(...createUserAtaAInstructions.cleanup);
10084
+ cleanupInstructions.push(...createUserAtaBInstructions.cleanup);
9581
10085
  return instructions;
9582
10086
  }
9583
10087
  async function removeLiquidityFusionInstruction(authority, tunaPosition, mintA, mintB, vaultA, vaultB, fusionPool, args) {
@@ -9645,8 +10149,8 @@ async function removeLiquidityFusionInstruction(authority, tunaPosition, mintA,
9645
10149
  { accountsType: 0 /* SwapTickArrays */, length: 5 },
9646
10150
  { accountsType: 1 /* TickArrayLower */, length: 1 },
9647
10151
  { accountsType: 2 /* TickArrayUpper */, length: 1 },
9648
- { accountsType: 3 /* PoolVaultTokenA */, length: 1 },
9649
- { accountsType: 4 /* PoolVaultTokenB */, length: 1 }
10152
+ { accountsType: 5 /* PoolVaultTokenA */, length: 1 },
10153
+ { accountsType: 6 /* PoolVaultTokenB */, length: 1 }
9650
10154
  ]
9651
10155
  };
9652
10156
  const ix = getRemoveLiquidityFusionInstruction({
@@ -9713,7 +10217,7 @@ async function repayBadDebtInstruction(rpc, authority, mintAddress, funds, share
9713
10217
  }
9714
10218
 
9715
10219
  // src/txbuilder/setLimitOrders.ts
9716
- async function setLimitOrdersOrcaInstruction(authority, args, positionMint, tunaPositionAddress) {
10220
+ async function setLimitOrdersInstruction(authority, args, positionMint, tunaPositionAddress) {
9717
10221
  if (tunaPositionAddress === void 0) {
9718
10222
  if (positionMint === void 0) {
9719
10223
  throw new Error("At least one of 'positionMint' or 'tunaPositionAddress' must be provided.");
@@ -9987,6 +10491,374 @@ async function repayDebtInstruction(authority, positionMint, mintA, mintB, marke
9987
10491
  collateralFundsB: collateralB
9988
10492
  });
9989
10493
  }
10494
+
10495
+ // src/txbuilder/rebalancePositionOrca.ts
10496
+ import {
10497
+ fetchAllMaybeTickArray as fetchAllMaybeTickArray5,
10498
+ fetchMaybeWhirlpool as fetchMaybeWhirlpool9,
10499
+ getInitializeTickArrayInstruction as getInitializeTickArrayInstruction5,
10500
+ getOracleAddress as getOracleAddress7,
10501
+ getPositionAddress as getPositionAddress19,
10502
+ WHIRLPOOL_PROGRAM_ADDRESS as WHIRLPOOL_PROGRAM_ADDRESS11
10503
+ } from "@orca-so/whirlpools-client";
10504
+ import {
10505
+ AccountRole as AccountRole14
10506
+ } from "@solana/kit";
10507
+ import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS18 } from "@solana-program/memo";
10508
+ import {
10509
+ fetchAllMaybeMint as fetchAllMaybeMint18,
10510
+ findAssociatedTokenPda as findAssociatedTokenPda26,
10511
+ TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS20
10512
+ } from "@solana-program/token-2022";
10513
+ import assert18 from "assert";
10514
+ async function rebalancePositionOrcaInstructions(rpc, authority, positionMint, createInstructions, cleanupInstructions) {
10515
+ const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
10516
+ const tunaPosition = await fetchMaybeTunaPosition(rpc, (await getTunaPositionAddress(positionMint))[0]);
10517
+ if (!tunaPosition.exists) throw new Error("Tuna position account not found");
10518
+ const whirlpool = await fetchMaybeWhirlpool9(rpc, tunaPosition.data.pool);
10519
+ if (!whirlpool.exists) throw new Error("Whirlpool account not found");
10520
+ const [vaultA, vaultB] = await fetchAllVault(rpc, [
10521
+ (await getLendingVaultAddress(whirlpool.data.tokenMintA))[0],
10522
+ (await getLendingVaultAddress(whirlpool.data.tokenMintB))[0]
10523
+ ]);
10524
+ const [mintA, mintB] = await fetchAllMaybeMint18(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
10525
+ assert18(mintA.exists, "Token A account not found");
10526
+ assert18(mintB.exists, "Token B account not found");
10527
+ const instructions = [];
10528
+ if (!createInstructions) createInstructions = instructions;
10529
+ if (!cleanupInstructions) cleanupInstructions = instructions;
10530
+ const internalCleanupInstructions = [];
10531
+ const secondaryTickArrays = await OrcaUtils.getTickArraysForRebalancedPosition(whirlpool, tunaPosition);
10532
+ const [lowerTickArray, upperTickArray] = await fetchAllMaybeTickArray5(rpc, [
10533
+ secondaryTickArrays.lowerTickArrayAddress,
10534
+ secondaryTickArrays.upperTickArrayAddress
10535
+ ]);
10536
+ if (!lowerTickArray.exists) {
10537
+ instructions.push(
10538
+ getInitializeTickArrayInstruction5({
10539
+ whirlpool: whirlpool.address,
10540
+ funder: authority,
10541
+ tickArray: secondaryTickArrays.lowerTickArrayAddress,
10542
+ startTickIndex: secondaryTickArrays.lowerTickArrayStartIndex
10543
+ })
10544
+ );
10545
+ }
10546
+ if (!upperTickArray.exists && secondaryTickArrays.lowerTickArrayStartIndex !== secondaryTickArrays.upperTickArrayStartIndex) {
10547
+ instructions.push(
10548
+ getInitializeTickArrayInstruction5({
10549
+ whirlpool: whirlpool.address,
10550
+ funder: authority,
10551
+ tickArray: secondaryTickArrays.upperTickArrayAddress,
10552
+ startTickIndex: secondaryTickArrays.upperTickArrayStartIndex
10553
+ })
10554
+ );
10555
+ }
10556
+ const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
10557
+ rpc,
10558
+ authority,
10559
+ mintA.address,
10560
+ tunaConfig.data.feeRecipient,
10561
+ mintA.programAddress
10562
+ );
10563
+ createInstructions.push(...createFeeRecipientAtaAInstructions.init);
10564
+ const createFeeRecipientAtaBInstructions = await getCreateAtaInstructions(
10565
+ rpc,
10566
+ authority,
10567
+ mintB.address,
10568
+ tunaConfig.data.feeRecipient,
10569
+ mintB.programAddress
10570
+ );
10571
+ createInstructions.push(...createFeeRecipientAtaBInstructions.init);
10572
+ const ix = await rebalancePositionOrcaInstruction(
10573
+ authority,
10574
+ tunaPosition,
10575
+ tunaConfig,
10576
+ mintA,
10577
+ mintB,
10578
+ vaultA,
10579
+ vaultB,
10580
+ whirlpool
10581
+ );
10582
+ instructions.push(ix);
10583
+ cleanupInstructions.push(...internalCleanupInstructions);
10584
+ cleanupInstructions.push(...createFeeRecipientAtaAInstructions.cleanup);
10585
+ cleanupInstructions.push(...createFeeRecipientAtaBInstructions.cleanup);
10586
+ return instructions;
10587
+ }
10588
+ async function rebalancePositionOrcaInstruction(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, whirlpool) {
10589
+ const positionMint = tunaPosition.data.positionMint;
10590
+ const marketAddress = (await getMarketAddress(whirlpool.address))[0];
10591
+ const orcaPositionAddress = (await getPositionAddress19(positionMint))[0];
10592
+ const orcaOracleAddress = (await getOracleAddress7(whirlpool.address))[0];
10593
+ const tunaPositionAta = (await findAssociatedTokenPda26({
10594
+ owner: tunaPosition.address,
10595
+ mint: positionMint,
10596
+ tokenProgram: TOKEN_2022_PROGRAM_ADDRESS20
10597
+ }))[0];
10598
+ const tunaPositionAtaA = (await findAssociatedTokenPda26({
10599
+ owner: tunaPosition.address,
10600
+ mint: mintA.address,
10601
+ tokenProgram: mintA.programAddress
10602
+ }))[0];
10603
+ const tunaPositionAtaB = (await findAssociatedTokenPda26({
10604
+ owner: tunaPosition.address,
10605
+ mint: mintB.address,
10606
+ tokenProgram: mintB.programAddress
10607
+ }))[0];
10608
+ const feeRecipientAtaA = (await findAssociatedTokenPda26({
10609
+ owner: tunaConfig.data.feeRecipient,
10610
+ mint: mintA.address,
10611
+ tokenProgram: mintA.programAddress
10612
+ }))[0];
10613
+ const feeRecipientAtaB = (await findAssociatedTokenPda26({
10614
+ owner: tunaConfig.data.feeRecipient,
10615
+ mint: mintB.address,
10616
+ tokenProgram: mintB.programAddress
10617
+ }))[0];
10618
+ const swapTickArrays = await OrcaUtils.getSwapTickArrayAddresses(whirlpool);
10619
+ const lowerTickArrayAddress = await OrcaUtils.getTickArrayAddressFromTickIndex(
10620
+ whirlpool,
10621
+ tunaPosition.data.tickLowerIndex
10622
+ );
10623
+ const upperTickArrayAddress = await OrcaUtils.getTickArrayAddressFromTickIndex(
10624
+ whirlpool,
10625
+ tunaPosition.data.tickUpperIndex
10626
+ );
10627
+ const secondaryTickArrays = await OrcaUtils.getTickArraysForRebalancedPosition(whirlpool, tunaPosition);
10628
+ const remainingAccounts = [
10629
+ { address: swapTickArrays[0], role: AccountRole14.WRITABLE },
10630
+ { address: swapTickArrays[1], role: AccountRole14.WRITABLE },
10631
+ { address: swapTickArrays[2], role: AccountRole14.WRITABLE },
10632
+ { address: swapTickArrays[3], role: AccountRole14.WRITABLE },
10633
+ { address: swapTickArrays[4], role: AccountRole14.WRITABLE },
10634
+ { address: lowerTickArrayAddress, role: AccountRole14.WRITABLE },
10635
+ { address: upperTickArrayAddress, role: AccountRole14.WRITABLE },
10636
+ { address: secondaryTickArrays.lowerTickArrayAddress, role: AccountRole14.WRITABLE },
10637
+ { address: secondaryTickArrays.upperTickArrayAddress, role: AccountRole14.WRITABLE },
10638
+ { address: whirlpool.data.tokenVaultA, role: AccountRole14.WRITABLE },
10639
+ { address: whirlpool.data.tokenVaultB, role: AccountRole14.WRITABLE },
10640
+ { address: orcaOracleAddress, role: AccountRole14.WRITABLE }
10641
+ ];
10642
+ const remainingAccountsInfo = {
10643
+ slices: [
10644
+ { accountsType: 0 /* SwapTickArrays */, length: 5 },
10645
+ { accountsType: 1 /* TickArrayLower */, length: 1 },
10646
+ { accountsType: 2 /* TickArrayUpper */, length: 1 },
10647
+ { accountsType: 3 /* SecondaryTickArrayLower */, length: 1 },
10648
+ { accountsType: 4 /* SecondaryTickArrayUpper */, length: 1 },
10649
+ { accountsType: 5 /* PoolVaultTokenA */, length: 1 },
10650
+ { accountsType: 6 /* PoolVaultTokenB */, length: 1 },
10651
+ { accountsType: 7 /* WhirlpoolOracle */, length: 1 }
10652
+ ]
10653
+ };
10654
+ const ix = getRebalancePositionOrcaInstruction({
10655
+ market: marketAddress,
10656
+ mintA: mintA.address,
10657
+ mintB: mintB.address,
10658
+ pythOraclePriceFeedA: vaultA.data.pythOraclePriceUpdate,
10659
+ pythOraclePriceFeedB: vaultB.data.pythOraclePriceUpdate,
10660
+ vaultA: vaultA.address,
10661
+ vaultB: vaultB.address,
10662
+ authority,
10663
+ tunaConfig: tunaConfig.address,
10664
+ tunaPositionAta,
10665
+ tunaPositionAtaA,
10666
+ tunaPositionAtaB,
10667
+ orcaPosition: orcaPositionAddress,
10668
+ tunaPosition: tunaPosition.address,
10669
+ feeRecipientAtaA,
10670
+ feeRecipientAtaB,
10671
+ whirlpool: whirlpool.address,
10672
+ whirlpoolProgram: WHIRLPOOL_PROGRAM_ADDRESS11,
10673
+ tokenProgramA: mintA.programAddress,
10674
+ tokenProgramB: mintB.programAddress,
10675
+ memoProgram: MEMO_PROGRAM_ADDRESS18,
10676
+ remainingAccountsInfo
10677
+ });
10678
+ ix.accounts.push(...remainingAccounts);
10679
+ return ix;
10680
+ }
10681
+
10682
+ // src/txbuilder/rebalancePositionFusion.ts
10683
+ import {
10684
+ fetchAllMaybeTickArray as fetchAllMaybeTickArray6,
10685
+ fetchMaybeFusionPool as fetchMaybeFusionPool9,
10686
+ FUSIONAMM_PROGRAM_ADDRESS as FUSIONAMM_PROGRAM_ADDRESS11,
10687
+ getInitializeTickArrayInstruction as getInitializeTickArrayInstruction6,
10688
+ getPositionAddress as getPositionAddress20
10689
+ } from "@crypticdot/fusionamm-client";
10690
+ import {
10691
+ AccountRole as AccountRole15
10692
+ } from "@solana/kit";
10693
+ import { MEMO_PROGRAM_ADDRESS as MEMO_PROGRAM_ADDRESS19 } from "@solana-program/memo";
10694
+ import {
10695
+ fetchAllMaybeMint as fetchAllMaybeMint19,
10696
+ findAssociatedTokenPda as findAssociatedTokenPda27,
10697
+ TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS21
10698
+ } from "@solana-program/token-2022";
10699
+ import assert19 from "assert";
10700
+ async function rebalancePositionFusionInstructions(rpc, authority, positionMint, createInstructions, cleanupInstructions) {
10701
+ const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
10702
+ const tunaPosition = await fetchMaybeTunaPosition(rpc, (await getTunaPositionAddress(positionMint))[0]);
10703
+ if (!tunaPosition.exists) throw new Error("Tuna position account not found");
10704
+ const fusionPool = await fetchMaybeFusionPool9(rpc, tunaPosition.data.pool);
10705
+ if (!fusionPool.exists) throw new Error("FusionPool account not found");
10706
+ const [vaultA, vaultB] = await fetchAllVault(rpc, [
10707
+ (await getLendingVaultAddress(fusionPool.data.tokenMintA))[0],
10708
+ (await getLendingVaultAddress(fusionPool.data.tokenMintB))[0]
10709
+ ]);
10710
+ const [mintA, mintB] = await fetchAllMaybeMint19(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
10711
+ assert19(mintA.exists, "Token A account not found");
10712
+ assert19(mintB.exists, "Token B account not found");
10713
+ const instructions = [];
10714
+ if (!createInstructions) createInstructions = instructions;
10715
+ if (!cleanupInstructions) cleanupInstructions = instructions;
10716
+ const secondaryTickArrays = await FusionUtils.getTickArraysForRebalancedPosition(fusionPool, tunaPosition);
10717
+ const [lowerTickArray, upperTickArray] = await fetchAllMaybeTickArray6(rpc, [
10718
+ secondaryTickArrays.lowerTickArrayAddress,
10719
+ secondaryTickArrays.upperTickArrayAddress
10720
+ ]);
10721
+ if (!lowerTickArray.exists) {
10722
+ instructions.push(
10723
+ getInitializeTickArrayInstruction6({
10724
+ fusionPool: fusionPool.address,
10725
+ funder: authority,
10726
+ tickArray: secondaryTickArrays.lowerTickArrayAddress,
10727
+ startTickIndex: secondaryTickArrays.lowerTickArrayStartIndex
10728
+ })
10729
+ );
10730
+ }
10731
+ if (!upperTickArray.exists && secondaryTickArrays.lowerTickArrayStartIndex !== secondaryTickArrays.upperTickArrayStartIndex) {
10732
+ instructions.push(
10733
+ getInitializeTickArrayInstruction6({
10734
+ fusionPool: fusionPool.address,
10735
+ funder: authority,
10736
+ tickArray: secondaryTickArrays.upperTickArrayAddress,
10737
+ startTickIndex: secondaryTickArrays.upperTickArrayStartIndex
10738
+ })
10739
+ );
10740
+ }
10741
+ const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
10742
+ rpc,
10743
+ authority,
10744
+ mintA.address,
10745
+ tunaConfig.data.feeRecipient,
10746
+ mintA.programAddress
10747
+ );
10748
+ createInstructions.push(...createFeeRecipientAtaAInstructions.init);
10749
+ const createFeeRecipientAtaBInstructions = await getCreateAtaInstructions(
10750
+ rpc,
10751
+ authority,
10752
+ mintB.address,
10753
+ tunaConfig.data.feeRecipient,
10754
+ mintB.programAddress
10755
+ );
10756
+ createInstructions.push(...createFeeRecipientAtaBInstructions.init);
10757
+ const ix = await rebalancePositionFusionInstruction(
10758
+ authority,
10759
+ tunaPosition,
10760
+ tunaConfig,
10761
+ mintA,
10762
+ mintB,
10763
+ vaultA,
10764
+ vaultB,
10765
+ fusionPool
10766
+ );
10767
+ instructions.push(ix);
10768
+ cleanupInstructions.push(...createFeeRecipientAtaAInstructions.cleanup);
10769
+ cleanupInstructions.push(...createFeeRecipientAtaBInstructions.cleanup);
10770
+ return instructions;
10771
+ }
10772
+ async function rebalancePositionFusionInstruction(authority, tunaPosition, tunaConfig, mintA, mintB, vaultA, vaultB, fusionPool) {
10773
+ const positionMint = tunaPosition.data.positionMint;
10774
+ const marketAddress = (await getMarketAddress(fusionPool.address))[0];
10775
+ const fusionPositionAddress = (await getPositionAddress20(positionMint))[0];
10776
+ const tunaPositionAta = (await findAssociatedTokenPda27({
10777
+ owner: tunaPosition.address,
10778
+ mint: positionMint,
10779
+ tokenProgram: TOKEN_2022_PROGRAM_ADDRESS21
10780
+ }))[0];
10781
+ const tunaPositionAtaA = (await findAssociatedTokenPda27({
10782
+ owner: tunaPosition.address,
10783
+ mint: mintA.address,
10784
+ tokenProgram: mintA.programAddress
10785
+ }))[0];
10786
+ const tunaPositionAtaB = (await findAssociatedTokenPda27({
10787
+ owner: tunaPosition.address,
10788
+ mint: mintB.address,
10789
+ tokenProgram: mintB.programAddress
10790
+ }))[0];
10791
+ const feeRecipientAtaA = (await findAssociatedTokenPda27({
10792
+ owner: tunaConfig.data.feeRecipient,
10793
+ mint: mintA.address,
10794
+ tokenProgram: mintA.programAddress
10795
+ }))[0];
10796
+ const feeRecipientAtaB = (await findAssociatedTokenPda27({
10797
+ owner: tunaConfig.data.feeRecipient,
10798
+ mint: mintB.address,
10799
+ tokenProgram: mintB.programAddress
10800
+ }))[0];
10801
+ const swapTickArrays = await FusionUtils.getSwapTickArrayAddresses(fusionPool);
10802
+ const lowerTickArrayAddress = await FusionUtils.getTickArrayAddressFromTickIndex(
10803
+ fusionPool,
10804
+ tunaPosition.data.tickLowerIndex
10805
+ );
10806
+ const upperTickArrayAddress = await FusionUtils.getTickArrayAddressFromTickIndex(
10807
+ fusionPool,
10808
+ tunaPosition.data.tickUpperIndex
10809
+ );
10810
+ const secondaryTickArrays = await FusionUtils.getTickArraysForRebalancedPosition(fusionPool, tunaPosition);
10811
+ const remainingAccounts = [
10812
+ { address: swapTickArrays[0], role: AccountRole15.WRITABLE },
10813
+ { address: swapTickArrays[1], role: AccountRole15.WRITABLE },
10814
+ { address: swapTickArrays[2], role: AccountRole15.WRITABLE },
10815
+ { address: swapTickArrays[3], role: AccountRole15.WRITABLE },
10816
+ { address: swapTickArrays[4], role: AccountRole15.WRITABLE },
10817
+ { address: lowerTickArrayAddress, role: AccountRole15.WRITABLE },
10818
+ { address: upperTickArrayAddress, role: AccountRole15.WRITABLE },
10819
+ { address: secondaryTickArrays.lowerTickArrayAddress, role: AccountRole15.WRITABLE },
10820
+ { address: secondaryTickArrays.upperTickArrayAddress, role: AccountRole15.WRITABLE },
10821
+ { address: fusionPool.data.tokenVaultA, role: AccountRole15.WRITABLE },
10822
+ { address: fusionPool.data.tokenVaultB, role: AccountRole15.WRITABLE }
10823
+ ];
10824
+ const remainingAccountsInfo = {
10825
+ slices: [
10826
+ { accountsType: 0 /* SwapTickArrays */, length: 5 },
10827
+ { accountsType: 1 /* TickArrayLower */, length: 1 },
10828
+ { accountsType: 2 /* TickArrayUpper */, length: 1 },
10829
+ { accountsType: 3 /* SecondaryTickArrayLower */, length: 1 },
10830
+ { accountsType: 4 /* SecondaryTickArrayUpper */, length: 1 },
10831
+ { accountsType: 5 /* PoolVaultTokenA */, length: 1 },
10832
+ { accountsType: 6 /* PoolVaultTokenB */, length: 1 }
10833
+ ]
10834
+ };
10835
+ const ix = getRebalancePositionFusionInstruction({
10836
+ market: marketAddress,
10837
+ mintA: mintA.address,
10838
+ mintB: mintB.address,
10839
+ pythOraclePriceFeedA: vaultA.data.pythOraclePriceUpdate,
10840
+ pythOraclePriceFeedB: vaultB.data.pythOraclePriceUpdate,
10841
+ vaultA: vaultA.address,
10842
+ vaultB: vaultB.address,
10843
+ authority,
10844
+ tunaConfig: tunaConfig.address,
10845
+ tunaPositionAta,
10846
+ tunaPositionAtaA,
10847
+ tunaPositionAtaB,
10848
+ fusionPosition: fusionPositionAddress,
10849
+ tunaPosition: tunaPosition.address,
10850
+ feeRecipientAtaA,
10851
+ feeRecipientAtaB,
10852
+ fusionPool: fusionPool.address,
10853
+ fusionammProgram: FUSIONAMM_PROGRAM_ADDRESS11,
10854
+ tokenProgramA: mintA.programAddress,
10855
+ tokenProgramB: mintB.programAddress,
10856
+ memoProgram: MEMO_PROGRAM_ADDRESS19,
10857
+ remainingAccountsInfo
10858
+ });
10859
+ ix.accounts.push(...remainingAccounts);
10860
+ return ix;
10861
+ }
9990
10862
  export {
9991
10863
  ADD_LIQUIDITY_FUSION_DISCRIMINATOR,
9992
10864
  ADD_LIQUIDITY_ORCA_DISCRIMINATOR,
@@ -10028,6 +10900,8 @@ export {
10028
10900
  OPEN_POSITION_WITH_LIQUIDITY_FUSION_DISCRIMINATOR,
10029
10901
  OPEN_POSITION_WITH_LIQUIDITY_ORCA_DISCRIMINATOR,
10030
10902
  OrcaUtils,
10903
+ REBALANCE_POSITION_FUSION_DISCRIMINATOR,
10904
+ REBALANCE_POSITION_ORCA_DISCRIMINATOR,
10031
10905
  REMOVE_LIQUIDITY_FUSION_DISCRIMINATOR,
10032
10906
  REMOVE_LIQUIDITY_ORCA_DISCRIMINATOR,
10033
10907
  REPAY_BAD_DEBT_DISCRIMINATOR,
@@ -10042,6 +10916,7 @@ export {
10042
10916
  SET_OWNER_AUTHORITY_DISCRIMINATOR,
10043
10917
  SET_SUSPENDED_STATE_DISCRIMINATOR,
10044
10918
  SET_TUNA_POSITION_FLAGS_DISCRIMINATOR,
10919
+ SET_TUNA_POSITION_REBALANCE_THRESHOLD_DISCRIMINATOR,
10045
10920
  TUNA_CONFIG_DISCRIMINATOR,
10046
10921
  TUNA_ERROR__AMOUNT_SLIPPAGE_EXCEEDED,
10047
10922
  TUNA_ERROR__BAD_DEBT,
@@ -10052,7 +10927,6 @@ export {
10052
10927
  TUNA_ERROR__INVALID_MARKET_MAKER,
10053
10928
  TUNA_ERROR__INVALID_REMAINING_ACCOUNTS_LENGTH,
10054
10929
  TUNA_ERROR__INVALID_SQRT_PRICE_LIMIT_DIRECTION,
10055
- TUNA_ERROR__INVALID_TICK_ARRAY_ACCOUNTS,
10056
10930
  TUNA_ERROR__INVALID_TICK_ARRAY_SEQUENCE,
10057
10931
  TUNA_ERROR__LEFTOVERS_EXCEEDED,
10058
10932
  TUNA_ERROR__LEVERAGE_IS_OUT_OF_RANGE,
@@ -10081,6 +10955,7 @@ export {
10081
10955
  TUNA_ERROR__RAYDIUM_NOT_ENOUGH_TICK_ARRAY_ACCOUNT,
10082
10956
  TUNA_ERROR__RAYDIUM_SQRT_PRICE_LIMIT_OVERFLOW,
10083
10957
  TUNA_ERROR__RAYDIUM_ZERO_AMOUNT_SPECIFIED,
10958
+ TUNA_ERROR__REBALANCE_CONDITIONS_NOT_MET,
10084
10959
  TUNA_ERROR__REMAINING_ACCOUNTS_DUPLICATED_ACCOUNTS_TYPE,
10085
10960
  TUNA_ERROR__REMAINING_ACCOUNTS_INSUFFICIENT,
10086
10961
  TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE,
@@ -10090,8 +10965,10 @@ export {
10090
10965
  TUNA_ERROR__SQRT_PRICE_OUT_OF_BOUNDS,
10091
10966
  TUNA_ERROR__SUPPLY_LIMIT_EXCEEDED,
10092
10967
  TUNA_ERROR__SUSPENDED,
10968
+ TUNA_ERROR__SWAP_QUOTE_NOT_EQUAL_TO_ACTUAL_SWAP_AMOUNT,
10093
10969
  TUNA_ERROR__SWAP_SLIPPAGE_EXCEEDED,
10094
10970
  TUNA_ERROR__SWAP_SLIPPAGE_IS_OUT_OF_RANGE,
10971
+ TUNA_ERROR__SWAP_TO_POSITION_RATIO_ESTIMATION_FAILED,
10095
10972
  TUNA_ERROR__TICK_INDEX_OF_BOUNDS,
10096
10973
  TUNA_ERROR__TRANSFER_FEE_CALCULATION_ERROR,
10097
10974
  TUNA_ERROR__TYPE_CAST_OVERFLOW,
@@ -10105,6 +10982,7 @@ export {
10105
10982
  TUNA_ERROR__ZERO_TRADABLE_AMOUNT,
10106
10983
  TUNA_ERROR__ZERO_YIELD,
10107
10984
  TUNA_POSITION_DISCRIMINATOR,
10985
+ TUNA_POSITION_FLAGS_ALLOW_REBALANCING,
10108
10986
  TUNA_POSITION_FLAGS_AUTO_COMPOUND_YIELD,
10109
10987
  TUNA_POSITION_FLAGS_AUTO_COMPOUND_YIELD_WITH_LEVERAGE,
10110
10988
  TUNA_POSITION_FLAGS_STOP_LOSS_SWAP_TO_TOKEN_A,
@@ -10293,6 +11171,16 @@ export {
10293
11171
  getOpenPositionWithLiquidityOrcaInstructionDataCodec,
10294
11172
  getOpenPositionWithLiquidityOrcaInstructionDataDecoder,
10295
11173
  getOpenPositionWithLiquidityOrcaInstructionDataEncoder,
11174
+ getRebalancePositionFusionDiscriminatorBytes,
11175
+ getRebalancePositionFusionInstruction,
11176
+ getRebalancePositionFusionInstructionDataCodec,
11177
+ getRebalancePositionFusionInstructionDataDecoder,
11178
+ getRebalancePositionFusionInstructionDataEncoder,
11179
+ getRebalancePositionOrcaDiscriminatorBytes,
11180
+ getRebalancePositionOrcaInstruction,
11181
+ getRebalancePositionOrcaInstructionDataCodec,
11182
+ getRebalancePositionOrcaInstructionDataDecoder,
11183
+ getRebalancePositionOrcaInstructionDataEncoder,
10296
11184
  getRemainingAccountsInfoCodec,
10297
11185
  getRemainingAccountsInfoDecoder,
10298
11186
  getRemainingAccountsInfoEncoder,
@@ -10369,6 +11257,11 @@ export {
10369
11257
  getSetTunaPositionFlagsInstructionDataCodec,
10370
11258
  getSetTunaPositionFlagsInstructionDataDecoder,
10371
11259
  getSetTunaPositionFlagsInstructionDataEncoder,
11260
+ getSetTunaPositionRebalanceThresholdDiscriminatorBytes,
11261
+ getSetTunaPositionRebalanceThresholdInstruction,
11262
+ getSetTunaPositionRebalanceThresholdInstructionDataCodec,
11263
+ getSetTunaPositionRebalanceThresholdInstructionDataDecoder,
11264
+ getSetTunaPositionRebalanceThresholdInstructionDataEncoder,
10372
11265
  getTunaConfigAddress,
10373
11266
  getTunaConfigCodec,
10374
11267
  getTunaConfigDecoder,
@@ -10442,6 +11335,8 @@ export {
10442
11335
  parseOpenPositionOrcaInstruction,
10443
11336
  parseOpenPositionWithLiquidityFusionInstruction,
10444
11337
  parseOpenPositionWithLiquidityOrcaInstruction,
11338
+ parseRebalancePositionFusionInstruction,
11339
+ parseRebalancePositionOrcaInstruction,
10445
11340
  parseRemoveLiquidityFusionInstruction,
10446
11341
  parseRemoveLiquidityOrcaInstruction,
10447
11342
  parseRepayBadDebtInstruction,
@@ -10456,9 +11351,14 @@ export {
10456
11351
  parseSetOwnerAuthorityInstruction,
10457
11352
  parseSetSuspendedStateInstruction,
10458
11353
  parseSetTunaPositionFlagsInstruction,
11354
+ parseSetTunaPositionRebalanceThresholdInstruction,
10459
11355
  parseUpdateMarketInstruction,
10460
11356
  parseUpdateVaultInstruction,
10461
11357
  parseWithdrawInstruction,
11358
+ rebalancePositionFusionInstruction,
11359
+ rebalancePositionFusionInstructions,
11360
+ rebalancePositionOrcaInstruction,
11361
+ rebalancePositionOrcaInstructions,
10462
11362
  removeLiquidityFusionInstruction,
10463
11363
  removeLiquidityFusionInstructions,
10464
11364
  removeLiquidityOrcaInstruction,
@@ -10466,7 +11366,7 @@ export {
10466
11366
  repayBadDebtInstruction,
10467
11367
  repayDebtInstruction,
10468
11368
  repayDebtInstructions,
10469
- setLimitOrdersOrcaInstruction,
11369
+ setLimitOrdersInstruction,
10470
11370
  tunaPositionAuthorityFilter,
10471
11371
  tunaPositionMarketMakerFilter,
10472
11372
  tunaPositionMintAFilter,