@crypticdot/defituna-client 3.4.8 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -124,14 +124,11 @@ __export(index_exports, {
124
124
  TUNA_ERROR__INVALID_MARKET_MAKER: () => TUNA_ERROR__INVALID_MARKET_MAKER,
125
125
  TUNA_ERROR__INVALID_POOL: () => TUNA_ERROR__INVALID_POOL,
126
126
  TUNA_ERROR__INVALID_REMAINING_ACCOUNTS_LENGTH: () => TUNA_ERROR__INVALID_REMAINING_ACCOUNTS_LENGTH,
127
- TUNA_ERROR__INVALID_SQRT_PRICE_LIMIT_DIRECTION: () => TUNA_ERROR__INVALID_SQRT_PRICE_LIMIT_DIRECTION,
128
- TUNA_ERROR__INVALID_TICK_ARRAY_SEQUENCE: () => TUNA_ERROR__INVALID_TICK_ARRAY_SEQUENCE,
129
127
  TUNA_ERROR__INVALID_VAULT: () => TUNA_ERROR__INVALID_VAULT,
130
128
  TUNA_ERROR__LEFTOVERS_EXCEEDED: () => TUNA_ERROR__LEFTOVERS_EXCEEDED,
131
129
  TUNA_ERROR__LEVERAGE_IS_OUT_OF_RANGE: () => TUNA_ERROR__LEVERAGE_IS_OUT_OF_RANGE,
132
130
  TUNA_ERROR__LIQUIDATION_FEE_IS_OUT_OF_RANGE: () => TUNA_ERROR__LIQUIDATION_FEE_IS_OUT_OF_RANGE,
133
131
  TUNA_ERROR__LIQUIDATION_THRESHOLD_IS_OUT_OF_RANGE: () => TUNA_ERROR__LIQUIDATION_THRESHOLD_IS_OUT_OF_RANGE,
134
- TUNA_ERROR__LIQUIDITY_ZERO: () => TUNA_ERROR__LIQUIDITY_ZERO,
135
132
  TUNA_ERROR__MARKET_DEBT_LIMIT_EXCEEDED: () => TUNA_ERROR__MARKET_DEBT_LIMIT_EXCEEDED,
136
133
  TUNA_ERROR__MARKET_DISABLED: () => TUNA_ERROR__MARKET_DISABLED,
137
134
  TUNA_ERROR__MATH_OVERFLOW: () => TUNA_ERROR__MATH_OVERFLOW,
@@ -141,7 +138,6 @@ __export(index_exports, {
141
138
  TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_EXCEEDED: () => TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_EXCEEDED,
142
139
  TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_OUT_OF_RANGE: () => TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_OUT_OF_RANGE,
143
140
  TUNA_ERROR__ORACLE_STALE_PRICE: () => TUNA_ERROR__ORACLE_STALE_PRICE,
144
- TUNA_ERROR__PARTIAL_FILL_ERROR: () => TUNA_ERROR__PARTIAL_FILL_ERROR,
145
141
  TUNA_ERROR__POSITION_IS_AUTO_REBALANCEABLE: () => TUNA_ERROR__POSITION_IS_AUTO_REBALANCEABLE,
146
142
  TUNA_ERROR__POSITION_IS_EMPTY: () => TUNA_ERROR__POSITION_IS_EMPTY,
147
143
  TUNA_ERROR__POSITION_IS_HEALTHY: () => TUNA_ERROR__POSITION_IS_HEALTHY,
@@ -158,26 +154,22 @@ __export(index_exports, {
158
154
  TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE_LENGTH: () => TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE_LENGTH,
159
155
  TUNA_ERROR__REQUIRED_REMAINING_ACCOUNT_NOT_PROVIDED: () => TUNA_ERROR__REQUIRED_REMAINING_ACCOUNT_NOT_PROVIDED,
160
156
  TUNA_ERROR__SOLVER_FAILED_TO_FIND_ROOT: () => TUNA_ERROR__SOLVER_FAILED_TO_FIND_ROOT,
161
- TUNA_ERROR__SQRT_PRICE_OUT_OF_BOUNDS: () => TUNA_ERROR__SQRT_PRICE_OUT_OF_BOUNDS,
162
157
  TUNA_ERROR__SUPPLY_LIMIT_EXCEEDED: () => TUNA_ERROR__SUPPLY_LIMIT_EXCEEDED,
163
158
  TUNA_ERROR__SUSPENDED: () => TUNA_ERROR__SUSPENDED,
164
159
  TUNA_ERROR__SWAP_QUOTE_NOT_EQUAL_TO_ACTUAL_SWAP_AMOUNT: () => TUNA_ERROR__SWAP_QUOTE_NOT_EQUAL_TO_ACTUAL_SWAP_AMOUNT,
165
160
  TUNA_ERROR__SWAP_SLIPPAGE_EXCEEDED: () => TUNA_ERROR__SWAP_SLIPPAGE_EXCEEDED,
166
161
  TUNA_ERROR__SWAP_SLIPPAGE_IS_OUT_OF_RANGE: () => TUNA_ERROR__SWAP_SLIPPAGE_IS_OUT_OF_RANGE,
167
162
  TUNA_ERROR__SWAP_TO_POSITION_RATIO_ESTIMATION_FAILED: () => TUNA_ERROR__SWAP_TO_POSITION_RATIO_ESTIMATION_FAILED,
168
- TUNA_ERROR__TICK_INDEX_OF_BOUNDS: () => TUNA_ERROR__TICK_INDEX_OF_BOUNDS,
169
163
  TUNA_ERROR__TRANSFER_FEE_CALCULATION_ERROR: () => TUNA_ERROR__TRANSFER_FEE_CALCULATION_ERROR,
170
164
  TUNA_ERROR__TYPE_CAST_OVERFLOW: () => TUNA_ERROR__TYPE_CAST_OVERFLOW,
171
165
  TUNA_ERROR__UNABLE_TO_DESERIALIZE_ACCOUNT_DATA: () => TUNA_ERROR__UNABLE_TO_DESERIALIZE_ACCOUNT_DATA,
172
166
  TUNA_ERROR__UNABLE_TO_LOAD_ACCOUNT_DATA: () => TUNA_ERROR__UNABLE_TO_LOAD_ACCOUNT_DATA,
173
167
  TUNA_ERROR__UNEXPECTED_VALUE: () => TUNA_ERROR__UNEXPECTED_VALUE,
174
168
  TUNA_ERROR__UNSUPPORTED_TOKEN_MINT: () => TUNA_ERROR__UNSUPPORTED_TOKEN_MINT,
175
- TUNA_ERROR__UNUSED: () => TUNA_ERROR__UNUSED,
176
169
  TUNA_ERROR__VAULT_NOT_INITIALIZED: () => TUNA_ERROR__VAULT_NOT_INITIALIZED,
177
170
  TUNA_ERROR__WITHDRAW_REQUEST_EXCEEDS_USER_BALANCE: () => TUNA_ERROR__WITHDRAW_REQUEST_EXCEEDS_USER_BALANCE,
178
171
  TUNA_ERROR__ZERO_AMOUNT: () => TUNA_ERROR__ZERO_AMOUNT,
179
172
  TUNA_ERROR__ZERO_PRICE_RANGE: () => TUNA_ERROR__ZERO_PRICE_RANGE,
180
- TUNA_ERROR__ZERO_TRADABLE_AMOUNT: () => TUNA_ERROR__ZERO_TRADABLE_AMOUNT,
181
173
  TUNA_ERROR__ZERO_YIELD: () => TUNA_ERROR__ZERO_YIELD,
182
174
  TUNA_LP_POSITION_DISCRIMINATOR: () => TUNA_LP_POSITION_DISCRIMINATOR,
183
175
  TUNA_POSITION_FLAGS_ALLOW_REBALANCING: () => TUNA_POSITION_FLAGS_ALLOW_REBALANCING,
@@ -2092,77 +2084,69 @@ function identifyTunaInstruction(instruction) {
2092
2084
  }
2093
2085
 
2094
2086
  // src/generated/errors/tuna.ts
2095
- var TUNA_ERROR__AMOUNT_SLIPPAGE_EXCEEDED = 6e3;
2096
- var TUNA_ERROR__BAD_DEBT = 6001;
2097
- var TUNA_ERROR__INVALID_REMAINING_ACCOUNTS_LENGTH = 6002;
2098
- var TUNA_ERROR__INVALID_ACCOUNT_OWNER = 6003;
2099
- var TUNA_ERROR__INVALID_INSTRUCTION_ARGUMENTS = 6004;
2100
- var TUNA_ERROR__INVALID_MARKET_MAKER = 6005;
2101
- var TUNA_ERROR__INVALID_SQRT_PRICE_LIMIT_DIRECTION = 6006;
2102
- var TUNA_ERROR__INVALID_TICK_ARRAY_SEQUENCE = 6007;
2103
- var TUNA_ERROR__INSUFFICIENT_LIQUIDITY = 6008;
2104
- var TUNA_ERROR__INTEREST_RATE_IS_OUT_OF_RANGE = 6009;
2105
- var TUNA_ERROR__LEVERAGE_IS_OUT_OF_RANGE = 6010;
2106
- var TUNA_ERROR__LEFTOVERS_EXCEEDED = 6011;
2107
- var TUNA_ERROR__UNUSED = 6012;
2108
- var TUNA_ERROR__LIQUIDATION_FEE_IS_OUT_OF_RANGE = 6013;
2109
- var TUNA_ERROR__LIQUIDATION_THRESHOLD_IS_OUT_OF_RANGE = 6014;
2110
- var TUNA_ERROR__LIQUIDITY_ZERO = 6015;
2111
- var TUNA_ERROR__MARKET_DISABLED = 6016;
2112
- var TUNA_ERROR__MARKET_DEBT_LIMIT_EXCEEDED = 6017;
2113
- var TUNA_ERROR__MATH_OVERFLOW = 6018;
2114
- var TUNA_ERROR__MATH_UNDERFLOW = 6019;
2115
- var TUNA_ERROR__NO_EXTRA_ACCOUNTS_FOR_TRANSFER_HOOK = 6020;
2116
- var TUNA_ERROR__ORACLE_STALE_PRICE = 6021;
2117
- var TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_EXCEEDED = 6022;
2118
- var TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_OUT_OF_RANGE = 6023;
2119
- var TUNA_ERROR__PARTIAL_FILL_ERROR = 6024;
2120
- var TUNA_ERROR__POSITION_IS_HEALTHY = 6025;
2121
- var TUNA_ERROR__POSITION_IS_LIQUIDATED = 6026;
2122
- var TUNA_ERROR__POSITION_IS_UNHEALTHY = 6027;
2123
- var TUNA_ERROR__POSITION_NOT_EMPTY = 6028;
2124
- var TUNA_ERROR__PROTOCOL_FEE_IS_OUT_OF_RANGE = 6029;
2125
- var TUNA_ERROR__REBALANCE_CONDITIONS_NOT_MET = 6030;
2126
- var TUNA_ERROR__REMAINING_ACCOUNTS_DUPLICATED_ACCOUNTS_TYPE = 6031;
2127
- var TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE = 6032;
2128
- var TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE_LENGTH = 6033;
2129
- var TUNA_ERROR__REMAINING_ACCOUNTS_INSUFFICIENT = 6034;
2130
- var TUNA_ERROR__REQUIRED_REMAINING_ACCOUNT_NOT_PROVIDED = 6035;
2131
- var TUNA_ERROR__SOLVER_FAILED_TO_FIND_ROOT = 6036;
2132
- var TUNA_ERROR__SQRT_PRICE_OUT_OF_BOUNDS = 6037;
2133
- var TUNA_ERROR__SUPPLY_LIMIT_EXCEEDED = 6038;
2134
- var TUNA_ERROR__SUSPENDED = 6039;
2135
- var TUNA_ERROR__SWAP_SLIPPAGE_EXCEEDED = 6040;
2136
- var TUNA_ERROR__SWAP_SLIPPAGE_IS_OUT_OF_RANGE = 6041;
2137
- var TUNA_ERROR__SWAP_TO_POSITION_RATIO_ESTIMATION_FAILED = 6042;
2138
- var TUNA_ERROR__SWAP_QUOTE_NOT_EQUAL_TO_ACTUAL_SWAP_AMOUNT = 6043;
2139
- var TUNA_ERROR__TICK_INDEX_OF_BOUNDS = 6044;
2140
- var TUNA_ERROR__TRANSFER_FEE_CALCULATION_ERROR = 6045;
2141
- var TUNA_ERROR__TYPE_CAST_OVERFLOW = 6046;
2142
- var TUNA_ERROR__UNABLE_TO_LOAD_ACCOUNT_DATA = 6047;
2143
- var TUNA_ERROR__UNABLE_TO_DESERIALIZE_ACCOUNT_DATA = 6048;
2144
- var TUNA_ERROR__UNEXPECTED_VALUE = 6049;
2145
- var TUNA_ERROR__UNSUPPORTED_TOKEN_MINT = 6050;
2146
- var TUNA_ERROR__VAULT_NOT_INITIALIZED = 6051;
2147
- var TUNA_ERROR__WITHDRAW_REQUEST_EXCEEDS_USER_BALANCE = 6052;
2148
- var TUNA_ERROR__ZERO_PRICE_RANGE = 6053;
2149
- var TUNA_ERROR__ZERO_TRADABLE_AMOUNT = 6054;
2150
- var TUNA_ERROR__ZERO_YIELD = 6055;
2151
- var TUNA_ERROR__ZERO_AMOUNT = 6056;
2152
- var TUNA_ERROR__POSITION_IS_AUTO_REBALANCEABLE = 6057;
2153
- var TUNA_ERROR__INCORRECT_POSITION_DIRECTION = 6058;
2154
- var TUNA_ERROR__RECIPIENT_ACCOUNT_IS_NOT_SET = 6059;
2155
- var TUNA_ERROR__M_A_PRICE_DEVIATION_THRESHOLD_EXCEEDED = 6060;
2156
- var TUNA_ERROR__POSITION_SIZE_LIMIT_EXCEEDED = 6061;
2157
- var TUNA_ERROR__INVALID_JUPITER_ROUTE = 6062;
2158
- var TUNA_ERROR__INSUFFICIENT_SWAP_OUTPUT_AMOUNT = 6063;
2159
- var TUNA_ERROR__INCORRECT_SWAP_INPUT_AMOUNT = 6064;
2160
- var TUNA_ERROR__INCORRECT_SWAP_OUTPUT_AMOUNT = 6065;
2161
- var TUNA_ERROR__ACCOUNT_NOT_INITIALIZED = 6066;
2162
- var TUNA_ERROR__INVALID_ACCOUNT_DISCRIMINATOR = 6067;
2163
- var TUNA_ERROR__INVALID_POOL = 6068;
2164
- var TUNA_ERROR__POSITION_IS_EMPTY = 6069;
2165
- var TUNA_ERROR__INVALID_VAULT = 6070;
2087
+ var TUNA_ERROR__TYPE_CAST_OVERFLOW = 12500;
2088
+ var TUNA_ERROR__MATH_OVERFLOW = 12501;
2089
+ var TUNA_ERROR__MATH_UNDERFLOW = 12502;
2090
+ var TUNA_ERROR__VAULT_NOT_INITIALIZED = 12559;
2091
+ var TUNA_ERROR__WITHDRAW_REQUEST_EXCEEDS_USER_BALANCE = 12560;
2092
+ var TUNA_ERROR__ZERO_PRICE_RANGE = 12561;
2093
+ var TUNA_ERROR__AMOUNT_SLIPPAGE_EXCEEDED = 12600;
2094
+ var TUNA_ERROR__BAD_DEBT = 12601;
2095
+ var TUNA_ERROR__INVALID_REMAINING_ACCOUNTS_LENGTH = 12602;
2096
+ var TUNA_ERROR__INVALID_INSTRUCTION_ARGUMENTS = 12603;
2097
+ var TUNA_ERROR__INVALID_MARKET_MAKER = 12604;
2098
+ var TUNA_ERROR__INVALID_ACCOUNT_DISCRIMINATOR = 12605;
2099
+ var TUNA_ERROR__INVALID_ACCOUNT_OWNER = 12606;
2100
+ var TUNA_ERROR__INVALID_POOL = 12607;
2101
+ var TUNA_ERROR__INVALID_VAULT = 12608;
2102
+ var TUNA_ERROR__INSUFFICIENT_LIQUIDITY = 12609;
2103
+ var TUNA_ERROR__INTEREST_RATE_IS_OUT_OF_RANGE = 12610;
2104
+ var TUNA_ERROR__LEVERAGE_IS_OUT_OF_RANGE = 12611;
2105
+ var TUNA_ERROR__LEFTOVERS_EXCEEDED = 12612;
2106
+ var TUNA_ERROR__LIQUIDATION_FEE_IS_OUT_OF_RANGE = 12613;
2107
+ var TUNA_ERROR__LIQUIDATION_THRESHOLD_IS_OUT_OF_RANGE = 12614;
2108
+ var TUNA_ERROR__MARKET_DISABLED = 12615;
2109
+ var TUNA_ERROR__MARKET_DEBT_LIMIT_EXCEEDED = 12616;
2110
+ var TUNA_ERROR__NO_EXTRA_ACCOUNTS_FOR_TRANSFER_HOOK = 12617;
2111
+ var TUNA_ERROR__ORACLE_STALE_PRICE = 12618;
2112
+ var TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_EXCEEDED = 12619;
2113
+ var TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_OUT_OF_RANGE = 12620;
2114
+ var TUNA_ERROR__POSITION_IS_HEALTHY = 12622;
2115
+ var TUNA_ERROR__POSITION_IS_LIQUIDATED = 12623;
2116
+ var TUNA_ERROR__POSITION_IS_UNHEALTHY = 12624;
2117
+ var TUNA_ERROR__POSITION_NOT_EMPTY = 12625;
2118
+ var TUNA_ERROR__POSITION_IS_EMPTY = 12626;
2119
+ var TUNA_ERROR__POSITION_IS_AUTO_REBALANCEABLE = 12627;
2120
+ var TUNA_ERROR__POSITION_SIZE_LIMIT_EXCEEDED = 12628;
2121
+ var TUNA_ERROR__PROTOCOL_FEE_IS_OUT_OF_RANGE = 12640;
2122
+ var TUNA_ERROR__REBALANCE_CONDITIONS_NOT_MET = 12641;
2123
+ var TUNA_ERROR__REMAINING_ACCOUNTS_DUPLICATED_ACCOUNTS_TYPE = 12642;
2124
+ var TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE = 12643;
2125
+ var TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE_LENGTH = 12644;
2126
+ var TUNA_ERROR__REMAINING_ACCOUNTS_INSUFFICIENT = 12645;
2127
+ var TUNA_ERROR__REQUIRED_REMAINING_ACCOUNT_NOT_PROVIDED = 12646;
2128
+ var TUNA_ERROR__SOLVER_FAILED_TO_FIND_ROOT = 12647;
2129
+ var TUNA_ERROR__SUPPLY_LIMIT_EXCEEDED = 12648;
2130
+ var TUNA_ERROR__SUSPENDED = 12649;
2131
+ var TUNA_ERROR__SWAP_SLIPPAGE_EXCEEDED = 12650;
2132
+ var TUNA_ERROR__SWAP_SLIPPAGE_IS_OUT_OF_RANGE = 12651;
2133
+ var TUNA_ERROR__SWAP_TO_POSITION_RATIO_ESTIMATION_FAILED = 12652;
2134
+ var TUNA_ERROR__SWAP_QUOTE_NOT_EQUAL_TO_ACTUAL_SWAP_AMOUNT = 12653;
2135
+ var TUNA_ERROR__TRANSFER_FEE_CALCULATION_ERROR = 12654;
2136
+ var TUNA_ERROR__UNABLE_TO_LOAD_ACCOUNT_DATA = 12655;
2137
+ var TUNA_ERROR__UNABLE_TO_DESERIALIZE_ACCOUNT_DATA = 12656;
2138
+ var TUNA_ERROR__UNEXPECTED_VALUE = 12657;
2139
+ var TUNA_ERROR__UNSUPPORTED_TOKEN_MINT = 12658;
2140
+ var TUNA_ERROR__ZERO_YIELD = 12662;
2141
+ var TUNA_ERROR__ZERO_AMOUNT = 12663;
2142
+ var TUNA_ERROR__INCORRECT_POSITION_DIRECTION = 12670;
2143
+ var TUNA_ERROR__RECIPIENT_ACCOUNT_IS_NOT_SET = 12671;
2144
+ var TUNA_ERROR__M_A_PRICE_DEVIATION_THRESHOLD_EXCEEDED = 12672;
2145
+ var TUNA_ERROR__INVALID_JUPITER_ROUTE = 12673;
2146
+ var TUNA_ERROR__INSUFFICIENT_SWAP_OUTPUT_AMOUNT = 12674;
2147
+ var TUNA_ERROR__INCORRECT_SWAP_INPUT_AMOUNT = 12675;
2148
+ var TUNA_ERROR__INCORRECT_SWAP_OUTPUT_AMOUNT = 12676;
2149
+ var TUNA_ERROR__ACCOUNT_NOT_INITIALIZED = 12677;
2166
2150
  var tunaErrorMessages;
2167
2151
  if (process.env.NODE_ENV !== "production") {
2168
2152
  tunaErrorMessages = {
@@ -2182,14 +2166,11 @@ if (process.env.NODE_ENV !== "production") {
2182
2166
  [TUNA_ERROR__INVALID_MARKET_MAKER]: `Invalid market maker`,
2183
2167
  [TUNA_ERROR__INVALID_POOL]: `Invalid Fusion or Orca pool`,
2184
2168
  [TUNA_ERROR__INVALID_REMAINING_ACCOUNTS_LENGTH]: `Invalid number of remaining accounts`,
2185
- [TUNA_ERROR__INVALID_SQRT_PRICE_LIMIT_DIRECTION]: `Provided SqrtPriceLimit not in the same direction as the swap.`,
2186
- [TUNA_ERROR__INVALID_TICK_ARRAY_SEQUENCE]: `Invalid tick array sequence provided for instruction`,
2187
2169
  [TUNA_ERROR__INVALID_VAULT]: `Vault address is invalid`,
2188
2170
  [TUNA_ERROR__LEFTOVERS_EXCEEDED]: `Leftovers percentage exceeded the maximum allowed value`,
2189
2171
  [TUNA_ERROR__LEVERAGE_IS_OUT_OF_RANGE]: `Leverage is out or range`,
2190
2172
  [TUNA_ERROR__LIQUIDATION_FEE_IS_OUT_OF_RANGE]: `Liquidation fee is out of range`,
2191
2173
  [TUNA_ERROR__LIQUIDATION_THRESHOLD_IS_OUT_OF_RANGE]: `Liquidation threshold is out of range`,
2192
- [TUNA_ERROR__LIQUIDITY_ZERO]: `Liquidity amount must be greater than zero.`,
2193
2174
  [TUNA_ERROR__M_A_PRICE_DEVIATION_THRESHOLD_EXCEEDED]: `Moving Average price deviation threshold exceeded`,
2194
2175
  [TUNA_ERROR__MARKET_DEBT_LIMIT_EXCEEDED]: `Exceed the maximum allowed debt for the market`,
2195
2176
  [TUNA_ERROR__MARKET_DISABLED]: `Market is disabled`,
@@ -2199,7 +2180,6 @@ if (process.env.NODE_ENV !== "production") {
2199
2180
  [TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_EXCEEDED]: `Oracle price deviation threshold exceeded`,
2200
2181
  [TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_OUT_OF_RANGE]: `Oracle price deviation threshold out of range`,
2201
2182
  [TUNA_ERROR__ORACLE_STALE_PRICE]: `Oracle price is stale`,
2202
- [TUNA_ERROR__PARTIAL_FILL_ERROR]: `Trade resulted in partial fill`,
2203
2183
  [TUNA_ERROR__POSITION_IS_AUTO_REBALANCEABLE]: `Unable to claim yield for auto re-balanceable positions`,
2204
2184
  [TUNA_ERROR__POSITION_IS_EMPTY]: `Position is empty`,
2205
2185
  [TUNA_ERROR__POSITION_IS_HEALTHY]: `Position is healthy`,
@@ -2216,26 +2196,22 @@ if (process.env.NODE_ENV !== "production") {
2216
2196
  [TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE_LENGTH]: `Invalid remaining accounts slice length`,
2217
2197
  [TUNA_ERROR__REQUIRED_REMAINING_ACCOUNT_NOT_PROVIDED]: `Required remaining account is not provided`,
2218
2198
  [TUNA_ERROR__SOLVER_FAILED_TO_FIND_ROOT]: `Swap equation solver failed to t find the root`,
2219
- [TUNA_ERROR__SQRT_PRICE_OUT_OF_BOUNDS]: `Provided sqrt price out of bounds`,
2220
2199
  [TUNA_ERROR__SUPPLY_LIMIT_EXCEEDED]: `Lending vault supply limit exceeded`,
2221
2200
  [TUNA_ERROR__SUSPENDED]: `Instruction is suspended`,
2222
2201
  [TUNA_ERROR__SWAP_QUOTE_NOT_EQUAL_TO_ACTUAL_SWAP_AMOUNT]: `Swap quote amount is not equal to the actual swap amount`,
2223
2202
  [TUNA_ERROR__SWAP_SLIPPAGE_EXCEEDED]: `Maximum allowed swap slippage is exceeded`,
2224
2203
  [TUNA_ERROR__SWAP_SLIPPAGE_IS_OUT_OF_RANGE]: `Provided swap slippage value is out of range`,
2225
2204
  [TUNA_ERROR__SWAP_TO_POSITION_RATIO_ESTIMATION_FAILED]: `Swap to position ratio estimation failed`,
2226
- [TUNA_ERROR__TICK_INDEX_OF_BOUNDS]: `Tick index is out of bounds`,
2227
2205
  [TUNA_ERROR__TRANSFER_FEE_CALCULATION_ERROR]: `Transfer fee calculation failed`,
2228
2206
  [TUNA_ERROR__TYPE_CAST_OVERFLOW]: `Type cast overflow`,
2229
2207
  [TUNA_ERROR__UNABLE_TO_DESERIALIZE_ACCOUNT_DATA]: `Unable to deserialize the account data`,
2230
2208
  [TUNA_ERROR__UNABLE_TO_LOAD_ACCOUNT_DATA]: `Unable to load the account data`,
2231
2209
  [TUNA_ERROR__UNEXPECTED_VALUE]: `Unexpected value`,
2232
2210
  [TUNA_ERROR__UNSUPPORTED_TOKEN_MINT]: `Token mint has unsupported attributes`,
2233
- [TUNA_ERROR__UNUSED]: `Unused error`,
2234
2211
  [TUNA_ERROR__VAULT_NOT_INITIALIZED]: `Lending vault is not initialized`,
2235
2212
  [TUNA_ERROR__WITHDRAW_REQUEST_EXCEEDS_USER_BALANCE]: `Withdraw request the exceeds user balance`,
2236
2213
  [TUNA_ERROR__ZERO_AMOUNT]: `Position amount is zero`,
2237
2214
  [TUNA_ERROR__ZERO_PRICE_RANGE]: `Zero price range: the lower price is equal to upper price)`,
2238
- [TUNA_ERROR__ZERO_TRADABLE_AMOUNT]: `There are no tradable amount to swap.`,
2239
2215
  [TUNA_ERROR__ZERO_YIELD]: `Collected yield is zero`
2240
2216
  };
2241
2217
  }
@@ -2734,10 +2710,14 @@ function getCollectAndCompoundFeesFusionInstruction(input, config) {
2734
2710
  },
2735
2711
  fusionPool: { value: input.fusionPool ?? null, isWritable: true },
2736
2712
  fusionPosition: { value: input.fusionPosition ?? null, isWritable: true },
2737
- memoProgram: { value: input.memoProgram ?? null, isWritable: false }
2713
+ memoProgram: { value: input.memoProgram ?? null, isWritable: false },
2714
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
2738
2715
  };
2739
2716
  const accounts = originalAccounts;
2740
2717
  const args = { ...input };
2718
+ if (!accounts.systemProgram.value) {
2719
+ accounts.systemProgram.value = "11111111111111111111111111111111";
2720
+ }
2741
2721
  const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2742
2722
  const instruction = {
2743
2723
  accounts: [
@@ -2763,7 +2743,8 @@ function getCollectAndCompoundFeesFusionInstruction(input, config) {
2763
2743
  getAccountMeta(accounts.fusionammProgram),
2764
2744
  getAccountMeta(accounts.fusionPool),
2765
2745
  getAccountMeta(accounts.fusionPosition),
2766
- getAccountMeta(accounts.memoProgram)
2746
+ getAccountMeta(accounts.memoProgram),
2747
+ getAccountMeta(accounts.systemProgram)
2767
2748
  ],
2768
2749
  programAddress,
2769
2750
  data: getCollectAndCompoundFeesFusionInstructionDataEncoder().encode(
@@ -2773,7 +2754,7 @@ function getCollectAndCompoundFeesFusionInstruction(input, config) {
2773
2754
  return instruction;
2774
2755
  }
2775
2756
  function parseCollectAndCompoundFeesFusionInstruction(instruction) {
2776
- if (instruction.accounts.length < 23) {
2757
+ if (instruction.accounts.length < 24) {
2777
2758
  throw new Error("Not enough accounts");
2778
2759
  }
2779
2760
  let accountIndex = 0;
@@ -2807,7 +2788,8 @@ function parseCollectAndCompoundFeesFusionInstruction(instruction) {
2807
2788
  fusionammProgram: getNextAccount(),
2808
2789
  fusionPool: getNextAccount(),
2809
2790
  fusionPosition: getNextAccount(),
2810
- memoProgram: getNextAccount()
2791
+ memoProgram: getNextAccount(),
2792
+ systemProgram: getNextAccount()
2811
2793
  },
2812
2794
  data: getCollectAndCompoundFeesFusionInstructionDataDecoder().decode(
2813
2795
  instruction.data
@@ -2907,10 +2889,14 @@ function getCollectAndCompoundFeesOrcaInstruction(input, config) {
2907
2889
  orcaPosition: { value: input.orcaPosition ?? null, isWritable: true },
2908
2890
  tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false },
2909
2891
  tokenProgramB: { value: input.tokenProgramB ?? null, isWritable: false },
2910
- memoProgram: { value: input.memoProgram ?? null, isWritable: false }
2892
+ memoProgram: { value: input.memoProgram ?? null, isWritable: false },
2893
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
2911
2894
  };
2912
2895
  const accounts = originalAccounts;
2913
2896
  const args = { ...input };
2897
+ if (!accounts.systemProgram.value) {
2898
+ accounts.systemProgram.value = "11111111111111111111111111111111";
2899
+ }
2914
2900
  const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2915
2901
  const instruction = {
2916
2902
  accounts: [
@@ -2936,7 +2922,8 @@ function getCollectAndCompoundFeesOrcaInstruction(input, config) {
2936
2922
  getAccountMeta(accounts.orcaPosition),
2937
2923
  getAccountMeta(accounts.tokenProgramA),
2938
2924
  getAccountMeta(accounts.tokenProgramB),
2939
- getAccountMeta(accounts.memoProgram)
2925
+ getAccountMeta(accounts.memoProgram),
2926
+ getAccountMeta(accounts.systemProgram)
2940
2927
  ],
2941
2928
  programAddress,
2942
2929
  data: getCollectAndCompoundFeesOrcaInstructionDataEncoder().encode(
@@ -2946,7 +2933,7 @@ function getCollectAndCompoundFeesOrcaInstruction(input, config) {
2946
2933
  return instruction;
2947
2934
  }
2948
2935
  function parseCollectAndCompoundFeesOrcaInstruction(instruction) {
2949
- if (instruction.accounts.length < 23) {
2936
+ if (instruction.accounts.length < 24) {
2950
2937
  throw new Error("Not enough accounts");
2951
2938
  }
2952
2939
  let accountIndex = 0;
@@ -2980,7 +2967,8 @@ function parseCollectAndCompoundFeesOrcaInstruction(instruction) {
2980
2967
  orcaPosition: getNextAccount(),
2981
2968
  tokenProgramA: getNextAccount(),
2982
2969
  tokenProgramB: getNextAccount(),
2983
- memoProgram: getNextAccount()
2970
+ memoProgram: getNextAccount(),
2971
+ systemProgram: getNextAccount()
2984
2972
  },
2985
2973
  data: getCollectAndCompoundFeesOrcaInstructionDataDecoder().decode(
2986
2974
  instruction.data
@@ -4496,10 +4484,14 @@ function getIncreaseTunaLpPositionFusionInstruction(input, config) {
4496
4484
  },
4497
4485
  fusionPool: { value: input.fusionPool ?? null, isWritable: true },
4498
4486
  fusionPosition: { value: input.fusionPosition ?? null, isWritable: true },
4499
- memoProgram: { value: input.memoProgram ?? null, isWritable: false }
4487
+ memoProgram: { value: input.memoProgram ?? null, isWritable: false },
4488
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
4500
4489
  };
4501
4490
  const accounts = originalAccounts;
4502
4491
  const args = { ...input };
4492
+ if (!accounts.systemProgram.value) {
4493
+ accounts.systemProgram.value = "11111111111111111111111111111111";
4494
+ }
4503
4495
  const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
4504
4496
  const instruction = {
4505
4497
  accounts: [
@@ -4527,7 +4519,8 @@ function getIncreaseTunaLpPositionFusionInstruction(input, config) {
4527
4519
  getAccountMeta(accounts.fusionammProgram),
4528
4520
  getAccountMeta(accounts.fusionPool),
4529
4521
  getAccountMeta(accounts.fusionPosition),
4530
- getAccountMeta(accounts.memoProgram)
4522
+ getAccountMeta(accounts.memoProgram),
4523
+ getAccountMeta(accounts.systemProgram)
4531
4524
  ],
4532
4525
  programAddress,
4533
4526
  data: getIncreaseTunaLpPositionFusionInstructionDataEncoder().encode(
@@ -4537,7 +4530,7 @@ function getIncreaseTunaLpPositionFusionInstruction(input, config) {
4537
4530
  return instruction;
4538
4531
  }
4539
4532
  function parseIncreaseTunaLpPositionFusionInstruction(instruction) {
4540
- if (instruction.accounts.length < 25) {
4533
+ if (instruction.accounts.length < 26) {
4541
4534
  throw new Error("Not enough accounts");
4542
4535
  }
4543
4536
  let accountIndex = 0;
@@ -4573,7 +4566,8 @@ function parseIncreaseTunaLpPositionFusionInstruction(instruction) {
4573
4566
  fusionammProgram: getNextAccount(),
4574
4567
  fusionPool: getNextAccount(),
4575
4568
  fusionPosition: getNextAccount(),
4576
- memoProgram: getNextAccount()
4569
+ memoProgram: getNextAccount(),
4570
+ systemProgram: getNextAccount()
4577
4571
  },
4578
4572
  data: getIncreaseTunaLpPositionFusionInstructionDataDecoder().decode(
4579
4573
  instruction.data
@@ -4690,10 +4684,14 @@ function getIncreaseTunaLpPositionOrcaInstruction(input, config) {
4690
4684
  orcaPosition: { value: input.orcaPosition ?? null, isWritable: true },
4691
4685
  tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false },
4692
4686
  tokenProgramB: { value: input.tokenProgramB ?? null, isWritable: false },
4693
- memoProgram: { value: input.memoProgram ?? null, isWritable: false }
4687
+ memoProgram: { value: input.memoProgram ?? null, isWritable: false },
4688
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
4694
4689
  };
4695
4690
  const accounts = originalAccounts;
4696
4691
  const args = { ...input };
4692
+ if (!accounts.systemProgram.value) {
4693
+ accounts.systemProgram.value = "11111111111111111111111111111111";
4694
+ }
4697
4695
  const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
4698
4696
  const instruction = {
4699
4697
  accounts: [
@@ -4721,7 +4719,8 @@ function getIncreaseTunaLpPositionOrcaInstruction(input, config) {
4721
4719
  getAccountMeta(accounts.orcaPosition),
4722
4720
  getAccountMeta(accounts.tokenProgramA),
4723
4721
  getAccountMeta(accounts.tokenProgramB),
4724
- getAccountMeta(accounts.memoProgram)
4722
+ getAccountMeta(accounts.memoProgram),
4723
+ getAccountMeta(accounts.systemProgram)
4725
4724
  ],
4726
4725
  programAddress,
4727
4726
  data: getIncreaseTunaLpPositionOrcaInstructionDataEncoder().encode(
@@ -4731,7 +4730,7 @@ function getIncreaseTunaLpPositionOrcaInstruction(input, config) {
4731
4730
  return instruction;
4732
4731
  }
4733
4732
  function parseIncreaseTunaLpPositionOrcaInstruction(instruction) {
4734
- if (instruction.accounts.length < 25) {
4733
+ if (instruction.accounts.length < 26) {
4735
4734
  throw new Error("Not enough accounts");
4736
4735
  }
4737
4736
  let accountIndex = 0;
@@ -4767,7 +4766,8 @@ function parseIncreaseTunaLpPositionOrcaInstruction(instruction) {
4767
4766
  orcaPosition: getNextAccount(),
4768
4767
  tokenProgramA: getNextAccount(),
4769
4768
  tokenProgramB: getNextAccount(),
4770
- memoProgram: getNextAccount()
4769
+ memoProgram: getNextAccount(),
4770
+ systemProgram: getNextAccount()
4771
4771
  },
4772
4772
  data: getIncreaseTunaLpPositionOrcaInstructionDataDecoder().decode(
4773
4773
  instruction.data
@@ -7857,10 +7857,14 @@ function getRepayTunaLpPositionDebtInstruction(input, config) {
7857
7857
  },
7858
7858
  tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false },
7859
7859
  tokenProgramB: { value: input.tokenProgramB ?? null, isWritable: false },
7860
- memoProgram: { value: input.memoProgram ?? null, isWritable: false }
7860
+ memoProgram: { value: input.memoProgram ?? null, isWritable: false },
7861
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
7861
7862
  };
7862
7863
  const accounts = originalAccounts;
7863
7864
  const args = { ...input };
7865
+ if (!accounts.systemProgram.value) {
7866
+ accounts.systemProgram.value = "11111111111111111111111111111111";
7867
+ }
7864
7868
  const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
7865
7869
  const instruction = {
7866
7870
  accounts: [
@@ -7879,7 +7883,8 @@ function getRepayTunaLpPositionDebtInstruction(input, config) {
7879
7883
  getAccountMeta(accounts.tunaPositionOwnerAtaB),
7880
7884
  getAccountMeta(accounts.tokenProgramA),
7881
7885
  getAccountMeta(accounts.tokenProgramB),
7882
- getAccountMeta(accounts.memoProgram)
7886
+ getAccountMeta(accounts.memoProgram),
7887
+ getAccountMeta(accounts.systemProgram)
7883
7888
  ],
7884
7889
  programAddress,
7885
7890
  data: getRepayTunaLpPositionDebtInstructionDataEncoder().encode(
@@ -7889,7 +7894,7 @@ function getRepayTunaLpPositionDebtInstruction(input, config) {
7889
7894
  return instruction;
7890
7895
  }
7891
7896
  function parseRepayTunaLpPositionDebtInstruction(instruction) {
7892
- if (instruction.accounts.length < 16) {
7897
+ if (instruction.accounts.length < 17) {
7893
7898
  throw new Error("Not enough accounts");
7894
7899
  }
7895
7900
  let accountIndex = 0;
@@ -7916,7 +7921,8 @@ function parseRepayTunaLpPositionDebtInstruction(instruction) {
7916
7921
  tunaPositionOwnerAtaB: getNextAccount(),
7917
7922
  tokenProgramA: getNextAccount(),
7918
7923
  tokenProgramB: getNextAccount(),
7919
- memoProgram: getNextAccount()
7924
+ memoProgram: getNextAccount(),
7925
+ systemProgram: getNextAccount()
7920
7926
  },
7921
7927
  data: getRepayTunaLpPositionDebtInstructionDataDecoder().decode(
7922
7928
  instruction.data
@@ -10023,7 +10029,6 @@ async function createAddressLookupTableInstructions(authority, addresses, recent
10023
10029
  }
10024
10030
 
10025
10031
  // src/txbuilder/increaseTunaLpPositionOrca.ts
10026
- var import_defituna_core = require("@crypticdot/defituna-core");
10027
10032
  var import_whirlpools_client2 = require("@orca-so/whirlpools-client");
10028
10033
  var import_whirlpools_core2 = require("@orca-so/whirlpools-core");
10029
10034
  var import_kit81 = require("@solana/kit");
@@ -10039,8 +10044,6 @@ async function increaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
10039
10044
  if (!tunaPosition.exists) throw new Error("Tuna position account not found");
10040
10045
  const whirlpool = await (0, import_whirlpools_client2.fetchMaybeWhirlpool)(rpc, tunaPosition.data.pool);
10041
10046
  if (!whirlpool.exists) throw new Error("Whirlpool account not found");
10042
- const marketAddress = (await getMarketAddress(tunaPosition.data.pool))[0];
10043
- const market = await fetchMarket(rpc, marketAddress);
10044
10047
  const [vaultA, vaultB] = await fetchAllVault(rpc, [
10045
10048
  (await getLendingVaultAddress(whirlpool.data.tokenMintA))[0],
10046
10049
  (await getLendingVaultAddress(whirlpool.data.tokenMintB))[0]
@@ -10048,27 +10051,12 @@ async function increaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
10048
10051
  const [mintA, mintB] = await (0, import_token_20222.fetchAllMaybeMint)(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
10049
10052
  (0, import_assert.default)(mintA.exists, "Token A not found");
10050
10053
  (0, import_assert.default)(mintB.exists, "Token B not found");
10051
- const increaseAmounts = (0, import_defituna_core.getIncreaseLpPositionQuote)({
10052
- collateralA: BigInt(args.collateralA),
10053
- collateralB: BigInt(args.collateralB),
10054
- borrowA: BigInt(args.borrowA),
10055
- borrowB: BigInt(args.borrowB),
10056
- maxAmountSlippage: args.maxAmountSlippage,
10057
- sqrtPrice: whirlpool.data.sqrtPrice,
10058
- tickLowerIndex: tunaPosition.data.tickLowerIndex,
10059
- tickUpperIndex: tunaPosition.data.tickUpperIndex,
10060
- protocolFeeRate: market.data.protocolFee,
10061
- protocolFeeRateOnCollateral: market.data.protocolFeeOnCollateral,
10062
- swapFeeRate: whirlpool.data.feeRate,
10063
- liquidationThreshold: market.data.liquidationThreshold
10064
- });
10065
10054
  const createUserAtaAInstructions = await getCreateAtaInstructions(
10066
10055
  rpc,
10067
10056
  authority,
10068
10057
  mintA.address,
10069
10058
  authority.address,
10070
- mintA.programAddress,
10071
- increaseAmounts.maxCollateralA
10059
+ mintA.programAddress
10072
10060
  );
10073
10061
  createInstructions.push(...createUserAtaAInstructions.init);
10074
10062
  const createUserAtaBInstructions = await getCreateAtaInstructions(
@@ -10076,8 +10064,7 @@ async function increaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
10076
10064
  authority,
10077
10065
  mintB.address,
10078
10066
  authority.address,
10079
- mintB.programAddress,
10080
- increaseAmounts.maxCollateralB
10067
+ mintB.programAddress
10081
10068
  );
10082
10069
  createInstructions.push(...createUserAtaBInstructions.init);
10083
10070
  const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
@@ -10133,7 +10120,7 @@ async function increaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
10133
10120
  vaultA,
10134
10121
  vaultB,
10135
10122
  whirlpool,
10136
- { ...args, minAddedAmountA: increaseAmounts.minTotalA, minAddedAmountB: increaseAmounts.minTotalB }
10123
+ { ...args }
10137
10124
  );
10138
10125
  instructions.push(ix);
10139
10126
  cleanupInstructions.push(...createUserAtaAInstructions.cleanup);
@@ -10256,7 +10243,6 @@ async function increaseTunaLpPositionOrcaInstruction(authority, tunaPosition, tu
10256
10243
  }
10257
10244
 
10258
10245
  // src/txbuilder/increaseTunaLpPositionFusion.ts
10259
- var import_defituna_core2 = require("@crypticdot/defituna-core");
10260
10246
  var import_fusionamm_client2 = require("@crypticdot/fusionamm-client");
10261
10247
  var import_fusionamm_core3 = require("@crypticdot/fusionamm-core");
10262
10248
  var import_kit82 = require("@solana/kit");
@@ -10272,8 +10258,6 @@ async function increaseTunaLpPositionFusionInstructions(rpc, authority, position
10272
10258
  if (!tunaPosition.exists) throw new Error("Tuna position account not found");
10273
10259
  const fusionPool = await (0, import_fusionamm_client2.fetchMaybeFusionPool)(rpc, tunaPosition.data.pool);
10274
10260
  if (!fusionPool.exists) throw new Error("FusionPool account not found");
10275
- const marketAddress = (await getMarketAddress(tunaPosition.data.pool))[0];
10276
- const market = await fetchMarket(rpc, marketAddress);
10277
10261
  const [vaultA, vaultB] = await fetchAllVault(rpc, [
10278
10262
  (await getLendingVaultAddress(fusionPool.data.tokenMintA))[0],
10279
10263
  (await getLendingVaultAddress(fusionPool.data.tokenMintB))[0]
@@ -10281,27 +10265,12 @@ async function increaseTunaLpPositionFusionInstructions(rpc, authority, position
10281
10265
  const [mintA, mintB] = await (0, import_token_20223.fetchAllMaybeMint)(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
10282
10266
  (0, import_assert2.default)(mintA.exists, "Token A not found");
10283
10267
  (0, import_assert2.default)(mintB.exists, "Token B not found");
10284
- const increaseAmounts = (0, import_defituna_core2.getIncreaseLpPositionQuote)({
10285
- collateralA: BigInt(args.collateralA),
10286
- collateralB: BigInt(args.collateralB),
10287
- borrowA: BigInt(args.borrowA),
10288
- borrowB: BigInt(args.borrowB),
10289
- maxAmountSlippage: args.maxAmountSlippage,
10290
- sqrtPrice: fusionPool.data.sqrtPrice,
10291
- tickLowerIndex: tunaPosition.data.tickLowerIndex,
10292
- tickUpperIndex: tunaPosition.data.tickUpperIndex,
10293
- protocolFeeRate: market.data.protocolFee,
10294
- protocolFeeRateOnCollateral: market.data.protocolFeeOnCollateral,
10295
- swapFeeRate: fusionPool.data.feeRate,
10296
- liquidationThreshold: market.data.liquidationThreshold
10297
- });
10298
10268
  const createUserAtaAInstructions = await getCreateAtaInstructions(
10299
10269
  rpc,
10300
10270
  authority,
10301
10271
  mintA.address,
10302
10272
  authority.address,
10303
- mintA.programAddress,
10304
- increaseAmounts.maxCollateralA
10273
+ mintA.programAddress
10305
10274
  );
10306
10275
  createInstructions.push(...createUserAtaAInstructions.init);
10307
10276
  const createUserAtaBInstructions = await getCreateAtaInstructions(
@@ -10309,8 +10278,7 @@ async function increaseTunaLpPositionFusionInstructions(rpc, authority, position
10309
10278
  authority,
10310
10279
  mintB.address,
10311
10280
  authority.address,
10312
- mintB.programAddress,
10313
- increaseAmounts.maxCollateralB
10281
+ mintB.programAddress
10314
10282
  );
10315
10283
  createInstructions.push(...createUserAtaBInstructions.init);
10316
10284
  const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
@@ -10372,7 +10340,7 @@ async function increaseTunaLpPositionFusionInstructions(rpc, authority, position
10372
10340
  vaultA,
10373
10341
  vaultB,
10374
10342
  fusionPool,
10375
- { ...args, minAddedAmountA: increaseAmounts.minTotalA, minAddedAmountB: increaseAmounts.minTotalB }
10343
+ { ...args }
10376
10344
  );
10377
10345
  instructions.push(ix);
10378
10346
  cleanupInstructions.push(...createUserAtaAInstructions.cleanup);
@@ -11305,11 +11273,8 @@ async function closeActiveTunaLpPositionOrcaInstructions(rpc, authority, positio
11305
11273
  whirlpool,
11306
11274
  rewardsToClaim,
11307
11275
  rewardMints,
11308
- // TODO: Compute minRemovedAmounts according to slippage
11309
11276
  {
11310
11277
  ...args,
11311
- minRemovedAmountA: 0,
11312
- minRemovedAmountB: 0,
11313
11278
  decreasePercent: HUNDRED_PERCENT
11314
11279
  }
11315
11280
  )
@@ -11388,8 +11353,6 @@ async function closeActiveTunaLpPositionFusionInstructions(rpc, authority, posit
11388
11353
  // TODO: Compute minRemovedAmounts according to slippage
11389
11354
  {
11390
11355
  ...args,
11391
- minRemovedAmountA: 0,
11392
- minRemovedAmountB: 0,
11393
11356
  decreasePercent: HUNDRED_PERCENT
11394
11357
  }
11395
11358
  )
@@ -11461,23 +11424,9 @@ async function modifyTunaSpotPositionOrcaInstructions(rpc, authority, poolAddres
11461
11424
  hasDirectlyTransferredTokensA = tunaPositionAtaA.data.amount > (tunaPosition.data.positionToken == 0 /* A */ ? tunaPosition.data.amount : 0n);
11462
11425
  hasDirectlyTransferredTokensB = tunaPositionAtaB.data.amount > (tunaPosition.data.positionToken == 1 /* B */ ? tunaPosition.data.amount : 0n);
11463
11426
  }
11464
- const createUserAtaAInstructions = collateralToken == 0 /* A */ || hasDirectlyTransferredTokensA ? await getCreateAtaInstructions(
11465
- rpc,
11466
- authority,
11467
- mintA.address,
11468
- authority.address,
11469
- mintA.programAddress,
11470
- args.collateralAmount
11471
- ) : void 0;
11427
+ const createUserAtaAInstructions = collateralToken == 0 /* A */ || hasDirectlyTransferredTokensA ? await getCreateAtaInstructions(rpc, authority, mintA.address, authority.address, mintA.programAddress) : void 0;
11472
11428
  if (createUserAtaAInstructions) createInstructions.push(...createUserAtaAInstructions.init);
11473
- const createUserAtaBInstructions = collateralToken == 1 /* B */ || hasDirectlyTransferredTokensB ? await getCreateAtaInstructions(
11474
- rpc,
11475
- authority,
11476
- mintB.address,
11477
- authority.address,
11478
- mintB.programAddress,
11479
- args.collateralAmount
11480
- ) : void 0;
11429
+ const createUserAtaBInstructions = collateralToken == 1 /* B */ || hasDirectlyTransferredTokensB ? await getCreateAtaInstructions(rpc, authority, mintB.address, authority.address, mintB.programAddress) : void 0;
11481
11430
  if (createUserAtaBInstructions) createInstructions.push(...createUserAtaBInstructions.init);
11482
11431
  const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
11483
11432
  rpc,
@@ -11652,23 +11601,9 @@ async function modifyTunaSpotPositionFusionInstructions(rpc, authority, poolAddr
11652
11601
  hasDirectlyTransferredTokensA = tunaPositionAtaA.data.amount > (tunaPosition.data.positionToken == 0 /* A */ ? tunaPosition.data.amount : 0n);
11653
11602
  hasDirectlyTransferredTokensB = tunaPositionAtaB.data.amount > (tunaPosition.data.positionToken == 1 /* B */ ? tunaPosition.data.amount : 0n);
11654
11603
  }
11655
- const createUserAtaAInstructions = collateralToken == 0 /* A */ || hasDirectlyTransferredTokensA ? await getCreateAtaInstructions(
11656
- rpc,
11657
- authority,
11658
- mintA.address,
11659
- authority.address,
11660
- mintA.programAddress,
11661
- args.collateralAmount
11662
- ) : void 0;
11604
+ const createUserAtaAInstructions = collateralToken == 0 /* A */ || hasDirectlyTransferredTokensA ? await getCreateAtaInstructions(rpc, authority, mintA.address, authority.address, mintA.programAddress) : void 0;
11663
11605
  if (createUserAtaAInstructions) createInstructions.push(...createUserAtaAInstructions.init);
11664
- const createUserAtaBInstructions = collateralToken == 1 /* B */ || hasDirectlyTransferredTokensB ? await getCreateAtaInstructions(
11665
- rpc,
11666
- authority,
11667
- mintB.address,
11668
- authority.address,
11669
- mintB.programAddress,
11670
- args.collateralAmount
11671
- ) : void 0;
11606
+ const createUserAtaBInstructions = collateralToken == 1 /* B */ || hasDirectlyTransferredTokensB ? await getCreateAtaInstructions(rpc, authority, mintB.address, authority.address, mintB.programAddress) : void 0;
11672
11607
  if (createUserAtaBInstructions) createInstructions.push(...createUserAtaBInstructions.init);
11673
11608
  const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
11674
11609
  rpc,
@@ -13135,7 +13070,6 @@ async function openTunaLpPositionFusionInstruction(rpc, authority, positionMint,
13135
13070
  }
13136
13071
 
13137
13072
  // src/txbuilder/openAndIncreaseTunaLpPositionOrca.ts
13138
- var import_defituna_core3 = require("@crypticdot/defituna-core");
13139
13073
  var import_whirlpools_client12 = require("@orca-so/whirlpools-client");
13140
13074
  var import_whirlpools_core4 = require("@orca-so/whirlpools-core");
13141
13075
  var import_kit128 = require("@solana/kit");
@@ -13164,8 +13098,6 @@ async function openAndIncreaseTunaLpPositionOrcaInstructions(rpc, authority, whi
13164
13098
  const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
13165
13099
  const whirlpool = await (0, import_whirlpools_client12.fetchMaybeWhirlpool)(rpc, whirlpoolAddress);
13166
13100
  if (!whirlpool.exists) throw new Error("Whirlpool account not found");
13167
- const marketAddress = (await getMarketAddress(whirlpoolAddress))[0];
13168
- const market = await fetchMarket(rpc, marketAddress);
13169
13101
  const [mintA, mintB] = await (0, import_token_202226.fetchAllMaybeMint)(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
13170
13102
  (0, import_assert17.default)(mintA.exists, "Token A account not found");
13171
13103
  (0, import_assert17.default)(mintB.exists, "Token B account not found");
@@ -13173,27 +13105,12 @@ async function openAndIncreaseTunaLpPositionOrcaInstructions(rpc, authority, whi
13173
13105
  (await getLendingVaultAddress(whirlpool.data.tokenMintA))[0],
13174
13106
  (await getLendingVaultAddress(whirlpool.data.tokenMintB))[0]
13175
13107
  ]);
13176
- const increaseAmounts = (0, import_defituna_core3.getIncreaseLpPositionQuote)({
13177
- collateralA: BigInt(args.collateralA),
13178
- collateralB: BigInt(args.collateralB),
13179
- borrowA: BigInt(args.borrowA),
13180
- borrowB: BigInt(args.borrowB),
13181
- maxAmountSlippage: args.maxAmountSlippage,
13182
- sqrtPrice: whirlpool.data.sqrtPrice,
13183
- tickLowerIndex: args.tickLowerIndex,
13184
- tickUpperIndex: args.tickUpperIndex,
13185
- protocolFeeRate: market.data.protocolFee,
13186
- protocolFeeRateOnCollateral: market.data.protocolFeeOnCollateral,
13187
- swapFeeRate: whirlpool.data.feeRate,
13188
- liquidationThreshold: market.data.liquidationThreshold
13189
- });
13190
13108
  const createUserAtaAInstructions = await getCreateAtaInstructions(
13191
13109
  rpc,
13192
13110
  authority,
13193
13111
  mintA.address,
13194
13112
  authority.address,
13195
- mintA.programAddress,
13196
- increaseAmounts.maxCollateralA
13113
+ mintA.programAddress
13197
13114
  );
13198
13115
  createInstructions.push(...createUserAtaAInstructions.init);
13199
13116
  const createUserAtaBInstructions = await getCreateAtaInstructions(
@@ -13201,8 +13118,7 @@ async function openAndIncreaseTunaLpPositionOrcaInstructions(rpc, authority, whi
13201
13118
  authority,
13202
13119
  mintB.address,
13203
13120
  authority.address,
13204
- mintB.programAddress,
13205
- increaseAmounts.maxCollateralB
13121
+ mintB.programAddress
13206
13122
  );
13207
13123
  createInstructions.push(...createUserAtaBInstructions.init);
13208
13124
  const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
@@ -13262,7 +13178,7 @@ async function openAndIncreaseTunaLpPositionOrcaInstructions(rpc, authority, whi
13262
13178
  vaultA,
13263
13179
  vaultB,
13264
13180
  whirlpool,
13265
- { ...args, minAddedAmountA: increaseAmounts.minTotalA, minAddedAmountB: increaseAmounts.minTotalB }
13181
+ { ...args }
13266
13182
  );
13267
13183
  instructions.push(ix);
13268
13184
  cleanupInstructions.push(...createUserAtaAInstructions.cleanup);
@@ -13386,7 +13302,6 @@ async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionM
13386
13302
  }
13387
13303
 
13388
13304
  // src/txbuilder/openAndIncreaseTunaLpPositionFusion.ts
13389
- var import_defituna_core4 = require("@crypticdot/defituna-core");
13390
13305
  var import_fusionamm_client13 = require("@crypticdot/fusionamm-client");
13391
13306
  var import_fusionamm_core4 = require("@crypticdot/fusionamm-core");
13392
13307
  var import_kit129 = require("@solana/kit");
@@ -13404,8 +13319,6 @@ async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, f
13404
13319
  const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
13405
13320
  const fusionPool = await (0, import_fusionamm_client13.fetchMaybeFusionPool)(rpc, fusionPoolAddress);
13406
13321
  if (!fusionPool.exists) throw new Error("FusionPool account not found");
13407
- const marketAddress = (await getMarketAddress(fusionPoolAddress))[0];
13408
- const market = await fetchMarket(rpc, marketAddress);
13409
13322
  const [mintA, mintB] = await (0, import_token_202227.fetchAllMaybeMint)(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
13410
13323
  (0, import_assert18.default)(mintA.exists, "Token A account not found");
13411
13324
  (0, import_assert18.default)(mintB.exists, "Token B account not found");
@@ -13413,27 +13326,12 @@ async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, f
13413
13326
  (await getLendingVaultAddress(fusionPool.data.tokenMintA))[0],
13414
13327
  (await getLendingVaultAddress(fusionPool.data.tokenMintB))[0]
13415
13328
  ]);
13416
- const increaseAmounts = (0, import_defituna_core4.getIncreaseLpPositionQuote)({
13417
- collateralA: BigInt(args.collateralA),
13418
- collateralB: BigInt(args.collateralB),
13419
- borrowA: BigInt(args.borrowA),
13420
- borrowB: BigInt(args.borrowB),
13421
- maxAmountSlippage: args.maxAmountSlippage,
13422
- sqrtPrice: fusionPool.data.sqrtPrice,
13423
- tickLowerIndex: args.tickLowerIndex,
13424
- tickUpperIndex: args.tickUpperIndex,
13425
- protocolFeeRate: market.data.protocolFee,
13426
- protocolFeeRateOnCollateral: market.data.protocolFeeOnCollateral,
13427
- swapFeeRate: fusionPool.data.feeRate,
13428
- liquidationThreshold: market.data.liquidationThreshold
13429
- });
13430
13329
  const createUserAtaAInstructions = await getCreateAtaInstructions(
13431
13330
  rpc,
13432
13331
  authority,
13433
13332
  mintA.address,
13434
13333
  authority.address,
13435
- mintA.programAddress,
13436
- increaseAmounts.maxCollateralA
13334
+ mintA.programAddress
13437
13335
  );
13438
13336
  createInstructions.push(...createUserAtaAInstructions.init);
13439
13337
  const createUserAtaBInstructions = await getCreateAtaInstructions(
@@ -13441,8 +13339,7 @@ async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, f
13441
13339
  authority,
13442
13340
  mintB.address,
13443
13341
  authority.address,
13444
- mintB.programAddress,
13445
- increaseAmounts.maxCollateralB
13342
+ mintB.programAddress
13446
13343
  );
13447
13344
  createInstructions.push(...createUserAtaBInstructions.init);
13448
13345
  const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
@@ -13500,7 +13397,7 @@ async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, f
13500
13397
  vaultA,
13501
13398
  vaultB,
13502
13399
  fusionPool,
13503
- { ...args, minAddedAmountA: increaseAmounts.minTotalA, minAddedAmountB: increaseAmounts.minTotalB }
13400
+ { ...args }
13504
13401
  );
13505
13402
  instructions.push(ix);
13506
13403
  cleanupInstructions.push(...createUserAtaAInstructions.cleanup);
@@ -13750,8 +13647,7 @@ async function decreaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
13750
13647
  whirlpool,
13751
13648
  rewardsToClaim,
13752
13649
  rewardMints,
13753
- // TODO: Compute minRemovedAmounts according to slippage
13754
- { ...args, minRemovedAmountA: 0, minRemovedAmountB: 0 }
13650
+ { ...args }
13755
13651
  );
13756
13652
  instructions.push(ix);
13757
13653
  cleanupInstructions.push(...internalCleanupInstructions);
@@ -13922,8 +13818,7 @@ async function decreaseTunaLpPositionFusionInstructions(rpc, authority, position
13922
13818
  vaultA,
13923
13819
  vaultB,
13924
13820
  fusionPool,
13925
- // TODO: Compute minRemovedAmounts according to slippage
13926
- { ...args, minRemovedAmountA: 0, minRemovedAmountB: 0 }
13821
+ { ...args }
13927
13822
  );
13928
13823
  instructions.push(ix);
13929
13824
  cleanupInstructions.push(...createUserAtaAInstructions.cleanup);
@@ -14317,8 +14212,7 @@ async function repayTunaLpPositionDebtInstructions(rpc, authority, positionMint,
14317
14212
  authority,
14318
14213
  mintA.address,
14319
14214
  authority.address,
14320
- mintA.programAddress,
14321
- collateralA
14215
+ mintA.programAddress
14322
14216
  );
14323
14217
  createInstructions.push(...createUserAtaAInstructions.init);
14324
14218
  const createUserAtaBInstructions = await getCreateAtaInstructions(
@@ -14326,8 +14220,7 @@ async function repayTunaLpPositionDebtInstructions(rpc, authority, positionMint,
14326
14220
  authority,
14327
14221
  mintB.address,
14328
14222
  authority.address,
14329
- mintB.programAddress,
14330
- collateralB
14223
+ mintB.programAddress
14331
14224
  );
14332
14225
  createInstructions.push(...createUserAtaBInstructions.init);
14333
14226
  const ix = await repayTunaLpPositionDebtInstruction(
@@ -14853,14 +14746,11 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
14853
14746
  TUNA_ERROR__INVALID_MARKET_MAKER,
14854
14747
  TUNA_ERROR__INVALID_POOL,
14855
14748
  TUNA_ERROR__INVALID_REMAINING_ACCOUNTS_LENGTH,
14856
- TUNA_ERROR__INVALID_SQRT_PRICE_LIMIT_DIRECTION,
14857
- TUNA_ERROR__INVALID_TICK_ARRAY_SEQUENCE,
14858
14749
  TUNA_ERROR__INVALID_VAULT,
14859
14750
  TUNA_ERROR__LEFTOVERS_EXCEEDED,
14860
14751
  TUNA_ERROR__LEVERAGE_IS_OUT_OF_RANGE,
14861
14752
  TUNA_ERROR__LIQUIDATION_FEE_IS_OUT_OF_RANGE,
14862
14753
  TUNA_ERROR__LIQUIDATION_THRESHOLD_IS_OUT_OF_RANGE,
14863
- TUNA_ERROR__LIQUIDITY_ZERO,
14864
14754
  TUNA_ERROR__MARKET_DEBT_LIMIT_EXCEEDED,
14865
14755
  TUNA_ERROR__MARKET_DISABLED,
14866
14756
  TUNA_ERROR__MATH_OVERFLOW,
@@ -14870,7 +14760,6 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
14870
14760
  TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_EXCEEDED,
14871
14761
  TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_OUT_OF_RANGE,
14872
14762
  TUNA_ERROR__ORACLE_STALE_PRICE,
14873
- TUNA_ERROR__PARTIAL_FILL_ERROR,
14874
14763
  TUNA_ERROR__POSITION_IS_AUTO_REBALANCEABLE,
14875
14764
  TUNA_ERROR__POSITION_IS_EMPTY,
14876
14765
  TUNA_ERROR__POSITION_IS_HEALTHY,
@@ -14887,26 +14776,22 @@ async function rebalanceTunaLpPositionFusionInstruction(authority, tunaPosition,
14887
14776
  TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE_LENGTH,
14888
14777
  TUNA_ERROR__REQUIRED_REMAINING_ACCOUNT_NOT_PROVIDED,
14889
14778
  TUNA_ERROR__SOLVER_FAILED_TO_FIND_ROOT,
14890
- TUNA_ERROR__SQRT_PRICE_OUT_OF_BOUNDS,
14891
14779
  TUNA_ERROR__SUPPLY_LIMIT_EXCEEDED,
14892
14780
  TUNA_ERROR__SUSPENDED,
14893
14781
  TUNA_ERROR__SWAP_QUOTE_NOT_EQUAL_TO_ACTUAL_SWAP_AMOUNT,
14894
14782
  TUNA_ERROR__SWAP_SLIPPAGE_EXCEEDED,
14895
14783
  TUNA_ERROR__SWAP_SLIPPAGE_IS_OUT_OF_RANGE,
14896
14784
  TUNA_ERROR__SWAP_TO_POSITION_RATIO_ESTIMATION_FAILED,
14897
- TUNA_ERROR__TICK_INDEX_OF_BOUNDS,
14898
14785
  TUNA_ERROR__TRANSFER_FEE_CALCULATION_ERROR,
14899
14786
  TUNA_ERROR__TYPE_CAST_OVERFLOW,
14900
14787
  TUNA_ERROR__UNABLE_TO_DESERIALIZE_ACCOUNT_DATA,
14901
14788
  TUNA_ERROR__UNABLE_TO_LOAD_ACCOUNT_DATA,
14902
14789
  TUNA_ERROR__UNEXPECTED_VALUE,
14903
14790
  TUNA_ERROR__UNSUPPORTED_TOKEN_MINT,
14904
- TUNA_ERROR__UNUSED,
14905
14791
  TUNA_ERROR__VAULT_NOT_INITIALIZED,
14906
14792
  TUNA_ERROR__WITHDRAW_REQUEST_EXCEEDS_USER_BALANCE,
14907
14793
  TUNA_ERROR__ZERO_AMOUNT,
14908
14794
  TUNA_ERROR__ZERO_PRICE_RANGE,
14909
- TUNA_ERROR__ZERO_TRADABLE_AMOUNT,
14910
14795
  TUNA_ERROR__ZERO_YIELD,
14911
14796
  TUNA_LP_POSITION_DISCRIMINATOR,
14912
14797
  TUNA_POSITION_FLAGS_ALLOW_REBALANCING,