@crypticdot/defituna-client 3.4.8 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1544,77 +1544,69 @@ function identifyTunaInstruction(instruction) {
1544
1544
  }
1545
1545
 
1546
1546
  // src/generated/errors/tuna.ts
1547
- var TUNA_ERROR__AMOUNT_SLIPPAGE_EXCEEDED = 6e3;
1548
- var TUNA_ERROR__BAD_DEBT = 6001;
1549
- var TUNA_ERROR__INVALID_REMAINING_ACCOUNTS_LENGTH = 6002;
1550
- var TUNA_ERROR__INVALID_ACCOUNT_OWNER = 6003;
1551
- var TUNA_ERROR__INVALID_INSTRUCTION_ARGUMENTS = 6004;
1552
- var TUNA_ERROR__INVALID_MARKET_MAKER = 6005;
1553
- var TUNA_ERROR__INVALID_SQRT_PRICE_LIMIT_DIRECTION = 6006;
1554
- var TUNA_ERROR__INVALID_TICK_ARRAY_SEQUENCE = 6007;
1555
- var TUNA_ERROR__INSUFFICIENT_LIQUIDITY = 6008;
1556
- var TUNA_ERROR__INTEREST_RATE_IS_OUT_OF_RANGE = 6009;
1557
- var TUNA_ERROR__LEVERAGE_IS_OUT_OF_RANGE = 6010;
1558
- var TUNA_ERROR__LEFTOVERS_EXCEEDED = 6011;
1559
- var TUNA_ERROR__UNUSED = 6012;
1560
- var TUNA_ERROR__LIQUIDATION_FEE_IS_OUT_OF_RANGE = 6013;
1561
- var TUNA_ERROR__LIQUIDATION_THRESHOLD_IS_OUT_OF_RANGE = 6014;
1562
- var TUNA_ERROR__LIQUIDITY_ZERO = 6015;
1563
- var TUNA_ERROR__MARKET_DISABLED = 6016;
1564
- var TUNA_ERROR__MARKET_DEBT_LIMIT_EXCEEDED = 6017;
1565
- var TUNA_ERROR__MATH_OVERFLOW = 6018;
1566
- var TUNA_ERROR__MATH_UNDERFLOW = 6019;
1567
- var TUNA_ERROR__NO_EXTRA_ACCOUNTS_FOR_TRANSFER_HOOK = 6020;
1568
- var TUNA_ERROR__ORACLE_STALE_PRICE = 6021;
1569
- var TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_EXCEEDED = 6022;
1570
- var TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_OUT_OF_RANGE = 6023;
1571
- var TUNA_ERROR__PARTIAL_FILL_ERROR = 6024;
1572
- var TUNA_ERROR__POSITION_IS_HEALTHY = 6025;
1573
- var TUNA_ERROR__POSITION_IS_LIQUIDATED = 6026;
1574
- var TUNA_ERROR__POSITION_IS_UNHEALTHY = 6027;
1575
- var TUNA_ERROR__POSITION_NOT_EMPTY = 6028;
1576
- var TUNA_ERROR__PROTOCOL_FEE_IS_OUT_OF_RANGE = 6029;
1577
- var TUNA_ERROR__REBALANCE_CONDITIONS_NOT_MET = 6030;
1578
- var TUNA_ERROR__REMAINING_ACCOUNTS_DUPLICATED_ACCOUNTS_TYPE = 6031;
1579
- var TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE = 6032;
1580
- var TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE_LENGTH = 6033;
1581
- var TUNA_ERROR__REMAINING_ACCOUNTS_INSUFFICIENT = 6034;
1582
- var TUNA_ERROR__REQUIRED_REMAINING_ACCOUNT_NOT_PROVIDED = 6035;
1583
- var TUNA_ERROR__SOLVER_FAILED_TO_FIND_ROOT = 6036;
1584
- var TUNA_ERROR__SQRT_PRICE_OUT_OF_BOUNDS = 6037;
1585
- var TUNA_ERROR__SUPPLY_LIMIT_EXCEEDED = 6038;
1586
- var TUNA_ERROR__SUSPENDED = 6039;
1587
- var TUNA_ERROR__SWAP_SLIPPAGE_EXCEEDED = 6040;
1588
- var TUNA_ERROR__SWAP_SLIPPAGE_IS_OUT_OF_RANGE = 6041;
1589
- var TUNA_ERROR__SWAP_TO_POSITION_RATIO_ESTIMATION_FAILED = 6042;
1590
- var TUNA_ERROR__SWAP_QUOTE_NOT_EQUAL_TO_ACTUAL_SWAP_AMOUNT = 6043;
1591
- var TUNA_ERROR__TICK_INDEX_OF_BOUNDS = 6044;
1592
- var TUNA_ERROR__TRANSFER_FEE_CALCULATION_ERROR = 6045;
1593
- var TUNA_ERROR__TYPE_CAST_OVERFLOW = 6046;
1594
- var TUNA_ERROR__UNABLE_TO_LOAD_ACCOUNT_DATA = 6047;
1595
- var TUNA_ERROR__UNABLE_TO_DESERIALIZE_ACCOUNT_DATA = 6048;
1596
- var TUNA_ERROR__UNEXPECTED_VALUE = 6049;
1597
- var TUNA_ERROR__UNSUPPORTED_TOKEN_MINT = 6050;
1598
- var TUNA_ERROR__VAULT_NOT_INITIALIZED = 6051;
1599
- var TUNA_ERROR__WITHDRAW_REQUEST_EXCEEDS_USER_BALANCE = 6052;
1600
- var TUNA_ERROR__ZERO_PRICE_RANGE = 6053;
1601
- var TUNA_ERROR__ZERO_TRADABLE_AMOUNT = 6054;
1602
- var TUNA_ERROR__ZERO_YIELD = 6055;
1603
- var TUNA_ERROR__ZERO_AMOUNT = 6056;
1604
- var TUNA_ERROR__POSITION_IS_AUTO_REBALANCEABLE = 6057;
1605
- var TUNA_ERROR__INCORRECT_POSITION_DIRECTION = 6058;
1606
- var TUNA_ERROR__RECIPIENT_ACCOUNT_IS_NOT_SET = 6059;
1607
- var TUNA_ERROR__M_A_PRICE_DEVIATION_THRESHOLD_EXCEEDED = 6060;
1608
- var TUNA_ERROR__POSITION_SIZE_LIMIT_EXCEEDED = 6061;
1609
- var TUNA_ERROR__INVALID_JUPITER_ROUTE = 6062;
1610
- var TUNA_ERROR__INSUFFICIENT_SWAP_OUTPUT_AMOUNT = 6063;
1611
- var TUNA_ERROR__INCORRECT_SWAP_INPUT_AMOUNT = 6064;
1612
- var TUNA_ERROR__INCORRECT_SWAP_OUTPUT_AMOUNT = 6065;
1613
- var TUNA_ERROR__ACCOUNT_NOT_INITIALIZED = 6066;
1614
- var TUNA_ERROR__INVALID_ACCOUNT_DISCRIMINATOR = 6067;
1615
- var TUNA_ERROR__INVALID_POOL = 6068;
1616
- var TUNA_ERROR__POSITION_IS_EMPTY = 6069;
1617
- var TUNA_ERROR__INVALID_VAULT = 6070;
1547
+ var TUNA_ERROR__TYPE_CAST_OVERFLOW = 12500;
1548
+ var TUNA_ERROR__MATH_OVERFLOW = 12501;
1549
+ var TUNA_ERROR__MATH_UNDERFLOW = 12502;
1550
+ var TUNA_ERROR__VAULT_NOT_INITIALIZED = 12559;
1551
+ var TUNA_ERROR__WITHDRAW_REQUEST_EXCEEDS_USER_BALANCE = 12560;
1552
+ var TUNA_ERROR__ZERO_PRICE_RANGE = 12561;
1553
+ var TUNA_ERROR__AMOUNT_SLIPPAGE_EXCEEDED = 12600;
1554
+ var TUNA_ERROR__BAD_DEBT = 12601;
1555
+ var TUNA_ERROR__INVALID_REMAINING_ACCOUNTS_LENGTH = 12602;
1556
+ var TUNA_ERROR__INVALID_INSTRUCTION_ARGUMENTS = 12603;
1557
+ var TUNA_ERROR__INVALID_MARKET_MAKER = 12604;
1558
+ var TUNA_ERROR__INVALID_ACCOUNT_DISCRIMINATOR = 12605;
1559
+ var TUNA_ERROR__INVALID_ACCOUNT_OWNER = 12606;
1560
+ var TUNA_ERROR__INVALID_POOL = 12607;
1561
+ var TUNA_ERROR__INVALID_VAULT = 12608;
1562
+ var TUNA_ERROR__INSUFFICIENT_LIQUIDITY = 12609;
1563
+ var TUNA_ERROR__INTEREST_RATE_IS_OUT_OF_RANGE = 12610;
1564
+ var TUNA_ERROR__LEVERAGE_IS_OUT_OF_RANGE = 12611;
1565
+ var TUNA_ERROR__LEFTOVERS_EXCEEDED = 12612;
1566
+ var TUNA_ERROR__LIQUIDATION_FEE_IS_OUT_OF_RANGE = 12613;
1567
+ var TUNA_ERROR__LIQUIDATION_THRESHOLD_IS_OUT_OF_RANGE = 12614;
1568
+ var TUNA_ERROR__MARKET_DISABLED = 12615;
1569
+ var TUNA_ERROR__MARKET_DEBT_LIMIT_EXCEEDED = 12616;
1570
+ var TUNA_ERROR__NO_EXTRA_ACCOUNTS_FOR_TRANSFER_HOOK = 12617;
1571
+ var TUNA_ERROR__ORACLE_STALE_PRICE = 12618;
1572
+ var TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_EXCEEDED = 12619;
1573
+ var TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_OUT_OF_RANGE = 12620;
1574
+ var TUNA_ERROR__POSITION_IS_HEALTHY = 12622;
1575
+ var TUNA_ERROR__POSITION_IS_LIQUIDATED = 12623;
1576
+ var TUNA_ERROR__POSITION_IS_UNHEALTHY = 12624;
1577
+ var TUNA_ERROR__POSITION_NOT_EMPTY = 12625;
1578
+ var TUNA_ERROR__POSITION_IS_EMPTY = 12626;
1579
+ var TUNA_ERROR__POSITION_IS_AUTO_REBALANCEABLE = 12627;
1580
+ var TUNA_ERROR__POSITION_SIZE_LIMIT_EXCEEDED = 12628;
1581
+ var TUNA_ERROR__PROTOCOL_FEE_IS_OUT_OF_RANGE = 12640;
1582
+ var TUNA_ERROR__REBALANCE_CONDITIONS_NOT_MET = 12641;
1583
+ var TUNA_ERROR__REMAINING_ACCOUNTS_DUPLICATED_ACCOUNTS_TYPE = 12642;
1584
+ var TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE = 12643;
1585
+ var TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE_LENGTH = 12644;
1586
+ var TUNA_ERROR__REMAINING_ACCOUNTS_INSUFFICIENT = 12645;
1587
+ var TUNA_ERROR__REQUIRED_REMAINING_ACCOUNT_NOT_PROVIDED = 12646;
1588
+ var TUNA_ERROR__SOLVER_FAILED_TO_FIND_ROOT = 12647;
1589
+ var TUNA_ERROR__SUPPLY_LIMIT_EXCEEDED = 12648;
1590
+ var TUNA_ERROR__SUSPENDED = 12649;
1591
+ var TUNA_ERROR__SWAP_SLIPPAGE_EXCEEDED = 12650;
1592
+ var TUNA_ERROR__SWAP_SLIPPAGE_IS_OUT_OF_RANGE = 12651;
1593
+ var TUNA_ERROR__SWAP_TO_POSITION_RATIO_ESTIMATION_FAILED = 12652;
1594
+ var TUNA_ERROR__SWAP_QUOTE_NOT_EQUAL_TO_ACTUAL_SWAP_AMOUNT = 12653;
1595
+ var TUNA_ERROR__TRANSFER_FEE_CALCULATION_ERROR = 12654;
1596
+ var TUNA_ERROR__UNABLE_TO_LOAD_ACCOUNT_DATA = 12655;
1597
+ var TUNA_ERROR__UNABLE_TO_DESERIALIZE_ACCOUNT_DATA = 12656;
1598
+ var TUNA_ERROR__UNEXPECTED_VALUE = 12657;
1599
+ var TUNA_ERROR__UNSUPPORTED_TOKEN_MINT = 12658;
1600
+ var TUNA_ERROR__ZERO_YIELD = 12662;
1601
+ var TUNA_ERROR__ZERO_AMOUNT = 12663;
1602
+ var TUNA_ERROR__INCORRECT_POSITION_DIRECTION = 12670;
1603
+ var TUNA_ERROR__RECIPIENT_ACCOUNT_IS_NOT_SET = 12671;
1604
+ var TUNA_ERROR__M_A_PRICE_DEVIATION_THRESHOLD_EXCEEDED = 12672;
1605
+ var TUNA_ERROR__INVALID_JUPITER_ROUTE = 12673;
1606
+ var TUNA_ERROR__INSUFFICIENT_SWAP_OUTPUT_AMOUNT = 12674;
1607
+ var TUNA_ERROR__INCORRECT_SWAP_INPUT_AMOUNT = 12675;
1608
+ var TUNA_ERROR__INCORRECT_SWAP_OUTPUT_AMOUNT = 12676;
1609
+ var TUNA_ERROR__ACCOUNT_NOT_INITIALIZED = 12677;
1618
1610
  var tunaErrorMessages;
1619
1611
  if (process.env.NODE_ENV !== "production") {
1620
1612
  tunaErrorMessages = {
@@ -1634,14 +1626,11 @@ if (process.env.NODE_ENV !== "production") {
1634
1626
  [TUNA_ERROR__INVALID_MARKET_MAKER]: `Invalid market maker`,
1635
1627
  [TUNA_ERROR__INVALID_POOL]: `Invalid Fusion or Orca pool`,
1636
1628
  [TUNA_ERROR__INVALID_REMAINING_ACCOUNTS_LENGTH]: `Invalid number of remaining accounts`,
1637
- [TUNA_ERROR__INVALID_SQRT_PRICE_LIMIT_DIRECTION]: `Provided SqrtPriceLimit not in the same direction as the swap.`,
1638
- [TUNA_ERROR__INVALID_TICK_ARRAY_SEQUENCE]: `Invalid tick array sequence provided for instruction`,
1639
1629
  [TUNA_ERROR__INVALID_VAULT]: `Vault address is invalid`,
1640
1630
  [TUNA_ERROR__LEFTOVERS_EXCEEDED]: `Leftovers percentage exceeded the maximum allowed value`,
1641
1631
  [TUNA_ERROR__LEVERAGE_IS_OUT_OF_RANGE]: `Leverage is out or range`,
1642
1632
  [TUNA_ERROR__LIQUIDATION_FEE_IS_OUT_OF_RANGE]: `Liquidation fee is out of range`,
1643
1633
  [TUNA_ERROR__LIQUIDATION_THRESHOLD_IS_OUT_OF_RANGE]: `Liquidation threshold is out of range`,
1644
- [TUNA_ERROR__LIQUIDITY_ZERO]: `Liquidity amount must be greater than zero.`,
1645
1634
  [TUNA_ERROR__M_A_PRICE_DEVIATION_THRESHOLD_EXCEEDED]: `Moving Average price deviation threshold exceeded`,
1646
1635
  [TUNA_ERROR__MARKET_DEBT_LIMIT_EXCEEDED]: `Exceed the maximum allowed debt for the market`,
1647
1636
  [TUNA_ERROR__MARKET_DISABLED]: `Market is disabled`,
@@ -1651,7 +1640,6 @@ if (process.env.NODE_ENV !== "production") {
1651
1640
  [TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_EXCEEDED]: `Oracle price deviation threshold exceeded`,
1652
1641
  [TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_OUT_OF_RANGE]: `Oracle price deviation threshold out of range`,
1653
1642
  [TUNA_ERROR__ORACLE_STALE_PRICE]: `Oracle price is stale`,
1654
- [TUNA_ERROR__PARTIAL_FILL_ERROR]: `Trade resulted in partial fill`,
1655
1643
  [TUNA_ERROR__POSITION_IS_AUTO_REBALANCEABLE]: `Unable to claim yield for auto re-balanceable positions`,
1656
1644
  [TUNA_ERROR__POSITION_IS_EMPTY]: `Position is empty`,
1657
1645
  [TUNA_ERROR__POSITION_IS_HEALTHY]: `Position is healthy`,
@@ -1668,26 +1656,22 @@ if (process.env.NODE_ENV !== "production") {
1668
1656
  [TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE_LENGTH]: `Invalid remaining accounts slice length`,
1669
1657
  [TUNA_ERROR__REQUIRED_REMAINING_ACCOUNT_NOT_PROVIDED]: `Required remaining account is not provided`,
1670
1658
  [TUNA_ERROR__SOLVER_FAILED_TO_FIND_ROOT]: `Swap equation solver failed to t find the root`,
1671
- [TUNA_ERROR__SQRT_PRICE_OUT_OF_BOUNDS]: `Provided sqrt price out of bounds`,
1672
1659
  [TUNA_ERROR__SUPPLY_LIMIT_EXCEEDED]: `Lending vault supply limit exceeded`,
1673
1660
  [TUNA_ERROR__SUSPENDED]: `Instruction is suspended`,
1674
1661
  [TUNA_ERROR__SWAP_QUOTE_NOT_EQUAL_TO_ACTUAL_SWAP_AMOUNT]: `Swap quote amount is not equal to the actual swap amount`,
1675
1662
  [TUNA_ERROR__SWAP_SLIPPAGE_EXCEEDED]: `Maximum allowed swap slippage is exceeded`,
1676
1663
  [TUNA_ERROR__SWAP_SLIPPAGE_IS_OUT_OF_RANGE]: `Provided swap slippage value is out of range`,
1677
1664
  [TUNA_ERROR__SWAP_TO_POSITION_RATIO_ESTIMATION_FAILED]: `Swap to position ratio estimation failed`,
1678
- [TUNA_ERROR__TICK_INDEX_OF_BOUNDS]: `Tick index is out of bounds`,
1679
1665
  [TUNA_ERROR__TRANSFER_FEE_CALCULATION_ERROR]: `Transfer fee calculation failed`,
1680
1666
  [TUNA_ERROR__TYPE_CAST_OVERFLOW]: `Type cast overflow`,
1681
1667
  [TUNA_ERROR__UNABLE_TO_DESERIALIZE_ACCOUNT_DATA]: `Unable to deserialize the account data`,
1682
1668
  [TUNA_ERROR__UNABLE_TO_LOAD_ACCOUNT_DATA]: `Unable to load the account data`,
1683
1669
  [TUNA_ERROR__UNEXPECTED_VALUE]: `Unexpected value`,
1684
1670
  [TUNA_ERROR__UNSUPPORTED_TOKEN_MINT]: `Token mint has unsupported attributes`,
1685
- [TUNA_ERROR__UNUSED]: `Unused error`,
1686
1671
  [TUNA_ERROR__VAULT_NOT_INITIALIZED]: `Lending vault is not initialized`,
1687
1672
  [TUNA_ERROR__WITHDRAW_REQUEST_EXCEEDS_USER_BALANCE]: `Withdraw request the exceeds user balance`,
1688
1673
  [TUNA_ERROR__ZERO_AMOUNT]: `Position amount is zero`,
1689
1674
  [TUNA_ERROR__ZERO_PRICE_RANGE]: `Zero price range: the lower price is equal to upper price)`,
1690
- [TUNA_ERROR__ZERO_TRADABLE_AMOUNT]: `There are no tradable amount to swap.`,
1691
1675
  [TUNA_ERROR__ZERO_YIELD]: `Collected yield is zero`
1692
1676
  };
1693
1677
  }
@@ -2229,10 +2213,14 @@ function getCollectAndCompoundFeesFusionInstruction(input, config) {
2229
2213
  },
2230
2214
  fusionPool: { value: input.fusionPool ?? null, isWritable: true },
2231
2215
  fusionPosition: { value: input.fusionPosition ?? null, isWritable: true },
2232
- memoProgram: { value: input.memoProgram ?? null, isWritable: false }
2216
+ memoProgram: { value: input.memoProgram ?? null, isWritable: false },
2217
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
2233
2218
  };
2234
2219
  const accounts = originalAccounts;
2235
2220
  const args = { ...input };
2221
+ if (!accounts.systemProgram.value) {
2222
+ accounts.systemProgram.value = "11111111111111111111111111111111";
2223
+ }
2236
2224
  const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2237
2225
  const instruction = {
2238
2226
  accounts: [
@@ -2258,7 +2246,8 @@ function getCollectAndCompoundFeesFusionInstruction(input, config) {
2258
2246
  getAccountMeta(accounts.fusionammProgram),
2259
2247
  getAccountMeta(accounts.fusionPool),
2260
2248
  getAccountMeta(accounts.fusionPosition),
2261
- getAccountMeta(accounts.memoProgram)
2249
+ getAccountMeta(accounts.memoProgram),
2250
+ getAccountMeta(accounts.systemProgram)
2262
2251
  ],
2263
2252
  programAddress,
2264
2253
  data: getCollectAndCompoundFeesFusionInstructionDataEncoder().encode(
@@ -2268,7 +2257,7 @@ function getCollectAndCompoundFeesFusionInstruction(input, config) {
2268
2257
  return instruction;
2269
2258
  }
2270
2259
  function parseCollectAndCompoundFeesFusionInstruction(instruction) {
2271
- if (instruction.accounts.length < 23) {
2260
+ if (instruction.accounts.length < 24) {
2272
2261
  throw new Error("Not enough accounts");
2273
2262
  }
2274
2263
  let accountIndex = 0;
@@ -2302,7 +2291,8 @@ function parseCollectAndCompoundFeesFusionInstruction(instruction) {
2302
2291
  fusionammProgram: getNextAccount(),
2303
2292
  fusionPool: getNextAccount(),
2304
2293
  fusionPosition: getNextAccount(),
2305
- memoProgram: getNextAccount()
2294
+ memoProgram: getNextAccount(),
2295
+ systemProgram: getNextAccount()
2306
2296
  },
2307
2297
  data: getCollectAndCompoundFeesFusionInstructionDataDecoder().decode(
2308
2298
  instruction.data
@@ -2413,10 +2403,14 @@ function getCollectAndCompoundFeesOrcaInstruction(input, config) {
2413
2403
  orcaPosition: { value: input.orcaPosition ?? null, isWritable: true },
2414
2404
  tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false },
2415
2405
  tokenProgramB: { value: input.tokenProgramB ?? null, isWritable: false },
2416
- memoProgram: { value: input.memoProgram ?? null, isWritable: false }
2406
+ memoProgram: { value: input.memoProgram ?? null, isWritable: false },
2407
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
2417
2408
  };
2418
2409
  const accounts = originalAccounts;
2419
2410
  const args = { ...input };
2411
+ if (!accounts.systemProgram.value) {
2412
+ accounts.systemProgram.value = "11111111111111111111111111111111";
2413
+ }
2420
2414
  const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
2421
2415
  const instruction = {
2422
2416
  accounts: [
@@ -2442,7 +2436,8 @@ function getCollectAndCompoundFeesOrcaInstruction(input, config) {
2442
2436
  getAccountMeta(accounts.orcaPosition),
2443
2437
  getAccountMeta(accounts.tokenProgramA),
2444
2438
  getAccountMeta(accounts.tokenProgramB),
2445
- getAccountMeta(accounts.memoProgram)
2439
+ getAccountMeta(accounts.memoProgram),
2440
+ getAccountMeta(accounts.systemProgram)
2446
2441
  ],
2447
2442
  programAddress,
2448
2443
  data: getCollectAndCompoundFeesOrcaInstructionDataEncoder().encode(
@@ -2452,7 +2447,7 @@ function getCollectAndCompoundFeesOrcaInstruction(input, config) {
2452
2447
  return instruction;
2453
2448
  }
2454
2449
  function parseCollectAndCompoundFeesOrcaInstruction(instruction) {
2455
- if (instruction.accounts.length < 23) {
2450
+ if (instruction.accounts.length < 24) {
2456
2451
  throw new Error("Not enough accounts");
2457
2452
  }
2458
2453
  let accountIndex = 0;
@@ -2486,7 +2481,8 @@ function parseCollectAndCompoundFeesOrcaInstruction(instruction) {
2486
2481
  orcaPosition: getNextAccount(),
2487
2482
  tokenProgramA: getNextAccount(),
2488
2483
  tokenProgramB: getNextAccount(),
2489
- memoProgram: getNextAccount()
2484
+ memoProgram: getNextAccount(),
2485
+ systemProgram: getNextAccount()
2490
2486
  },
2491
2487
  data: getCollectAndCompoundFeesOrcaInstructionDataDecoder().decode(
2492
2488
  instruction.data
@@ -4160,10 +4156,14 @@ function getIncreaseTunaLpPositionFusionInstruction(input, config) {
4160
4156
  },
4161
4157
  fusionPool: { value: input.fusionPool ?? null, isWritable: true },
4162
4158
  fusionPosition: { value: input.fusionPosition ?? null, isWritable: true },
4163
- memoProgram: { value: input.memoProgram ?? null, isWritable: false }
4159
+ memoProgram: { value: input.memoProgram ?? null, isWritable: false },
4160
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
4164
4161
  };
4165
4162
  const accounts = originalAccounts;
4166
4163
  const args = { ...input };
4164
+ if (!accounts.systemProgram.value) {
4165
+ accounts.systemProgram.value = "11111111111111111111111111111111";
4166
+ }
4167
4167
  const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
4168
4168
  const instruction = {
4169
4169
  accounts: [
@@ -4191,7 +4191,8 @@ function getIncreaseTunaLpPositionFusionInstruction(input, config) {
4191
4191
  getAccountMeta(accounts.fusionammProgram),
4192
4192
  getAccountMeta(accounts.fusionPool),
4193
4193
  getAccountMeta(accounts.fusionPosition),
4194
- getAccountMeta(accounts.memoProgram)
4194
+ getAccountMeta(accounts.memoProgram),
4195
+ getAccountMeta(accounts.systemProgram)
4195
4196
  ],
4196
4197
  programAddress,
4197
4198
  data: getIncreaseTunaLpPositionFusionInstructionDataEncoder().encode(
@@ -4201,7 +4202,7 @@ function getIncreaseTunaLpPositionFusionInstruction(input, config) {
4201
4202
  return instruction;
4202
4203
  }
4203
4204
  function parseIncreaseTunaLpPositionFusionInstruction(instruction) {
4204
- if (instruction.accounts.length < 25) {
4205
+ if (instruction.accounts.length < 26) {
4205
4206
  throw new Error("Not enough accounts");
4206
4207
  }
4207
4208
  let accountIndex = 0;
@@ -4237,7 +4238,8 @@ function parseIncreaseTunaLpPositionFusionInstruction(instruction) {
4237
4238
  fusionammProgram: getNextAccount(),
4238
4239
  fusionPool: getNextAccount(),
4239
4240
  fusionPosition: getNextAccount(),
4240
- memoProgram: getNextAccount()
4241
+ memoProgram: getNextAccount(),
4242
+ systemProgram: getNextAccount()
4241
4243
  },
4242
4244
  data: getIncreaseTunaLpPositionFusionInstructionDataDecoder().decode(
4243
4245
  instruction.data
@@ -4367,10 +4369,14 @@ function getIncreaseTunaLpPositionOrcaInstruction(input, config) {
4367
4369
  orcaPosition: { value: input.orcaPosition ?? null, isWritable: true },
4368
4370
  tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false },
4369
4371
  tokenProgramB: { value: input.tokenProgramB ?? null, isWritable: false },
4370
- memoProgram: { value: input.memoProgram ?? null, isWritable: false }
4372
+ memoProgram: { value: input.memoProgram ?? null, isWritable: false },
4373
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
4371
4374
  };
4372
4375
  const accounts = originalAccounts;
4373
4376
  const args = { ...input };
4377
+ if (!accounts.systemProgram.value) {
4378
+ accounts.systemProgram.value = "11111111111111111111111111111111";
4379
+ }
4374
4380
  const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
4375
4381
  const instruction = {
4376
4382
  accounts: [
@@ -4398,7 +4404,8 @@ function getIncreaseTunaLpPositionOrcaInstruction(input, config) {
4398
4404
  getAccountMeta(accounts.orcaPosition),
4399
4405
  getAccountMeta(accounts.tokenProgramA),
4400
4406
  getAccountMeta(accounts.tokenProgramB),
4401
- getAccountMeta(accounts.memoProgram)
4407
+ getAccountMeta(accounts.memoProgram),
4408
+ getAccountMeta(accounts.systemProgram)
4402
4409
  ],
4403
4410
  programAddress,
4404
4411
  data: getIncreaseTunaLpPositionOrcaInstructionDataEncoder().encode(
@@ -4408,7 +4415,7 @@ function getIncreaseTunaLpPositionOrcaInstruction(input, config) {
4408
4415
  return instruction;
4409
4416
  }
4410
4417
  function parseIncreaseTunaLpPositionOrcaInstruction(instruction) {
4411
- if (instruction.accounts.length < 25) {
4418
+ if (instruction.accounts.length < 26) {
4412
4419
  throw new Error("Not enough accounts");
4413
4420
  }
4414
4421
  let accountIndex = 0;
@@ -4444,7 +4451,8 @@ function parseIncreaseTunaLpPositionOrcaInstruction(instruction) {
4444
4451
  orcaPosition: getNextAccount(),
4445
4452
  tokenProgramA: getNextAccount(),
4446
4453
  tokenProgramB: getNextAccount(),
4447
- memoProgram: getNextAccount()
4454
+ memoProgram: getNextAccount(),
4455
+ systemProgram: getNextAccount()
4448
4456
  },
4449
4457
  data: getIncreaseTunaLpPositionOrcaInstructionDataDecoder().decode(
4450
4458
  instruction.data
@@ -7763,10 +7771,14 @@ function getRepayTunaLpPositionDebtInstruction(input, config) {
7763
7771
  },
7764
7772
  tokenProgramA: { value: input.tokenProgramA ?? null, isWritable: false },
7765
7773
  tokenProgramB: { value: input.tokenProgramB ?? null, isWritable: false },
7766
- memoProgram: { value: input.memoProgram ?? null, isWritable: false }
7774
+ memoProgram: { value: input.memoProgram ?? null, isWritable: false },
7775
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
7767
7776
  };
7768
7777
  const accounts = originalAccounts;
7769
7778
  const args = { ...input };
7779
+ if (!accounts.systemProgram.value) {
7780
+ accounts.systemProgram.value = "11111111111111111111111111111111";
7781
+ }
7770
7782
  const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
7771
7783
  const instruction = {
7772
7784
  accounts: [
@@ -7785,7 +7797,8 @@ function getRepayTunaLpPositionDebtInstruction(input, config) {
7785
7797
  getAccountMeta(accounts.tunaPositionOwnerAtaB),
7786
7798
  getAccountMeta(accounts.tokenProgramA),
7787
7799
  getAccountMeta(accounts.tokenProgramB),
7788
- getAccountMeta(accounts.memoProgram)
7800
+ getAccountMeta(accounts.memoProgram),
7801
+ getAccountMeta(accounts.systemProgram)
7789
7802
  ],
7790
7803
  programAddress,
7791
7804
  data: getRepayTunaLpPositionDebtInstructionDataEncoder().encode(
@@ -7795,7 +7808,7 @@ function getRepayTunaLpPositionDebtInstruction(input, config) {
7795
7808
  return instruction;
7796
7809
  }
7797
7810
  function parseRepayTunaLpPositionDebtInstruction(instruction) {
7798
- if (instruction.accounts.length < 16) {
7811
+ if (instruction.accounts.length < 17) {
7799
7812
  throw new Error("Not enough accounts");
7800
7813
  }
7801
7814
  let accountIndex = 0;
@@ -7822,7 +7835,8 @@ function parseRepayTunaLpPositionDebtInstruction(instruction) {
7822
7835
  tunaPositionOwnerAtaB: getNextAccount(),
7823
7836
  tokenProgramA: getNextAccount(),
7824
7837
  tokenProgramB: getNextAccount(),
7825
- memoProgram: getNextAccount()
7838
+ memoProgram: getNextAccount(),
7839
+ systemProgram: getNextAccount()
7826
7840
  },
7827
7841
  data: getRepayTunaLpPositionDebtInstructionDataDecoder().decode(
7828
7842
  instruction.data
@@ -10178,7 +10192,6 @@ async function createAddressLookupTableInstructions(authority, addresses, recent
10178
10192
  }
10179
10193
 
10180
10194
  // src/txbuilder/increaseTunaLpPositionOrca.ts
10181
- import { getIncreaseLpPositionQuote } from "@crypticdot/defituna-core";
10182
10195
  import {
10183
10196
  fetchMaybeWhirlpool,
10184
10197
  getInitializeDynamicTickArrayInstruction,
@@ -10207,8 +10220,6 @@ async function increaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
10207
10220
  if (!tunaPosition.exists) throw new Error("Tuna position account not found");
10208
10221
  const whirlpool = await fetchMaybeWhirlpool(rpc, tunaPosition.data.pool);
10209
10222
  if (!whirlpool.exists) throw new Error("Whirlpool account not found");
10210
- const marketAddress = (await getMarketAddress(tunaPosition.data.pool))[0];
10211
- const market = await fetchMarket(rpc, marketAddress);
10212
10223
  const [vaultA, vaultB] = await fetchAllVault(rpc, [
10213
10224
  (await getLendingVaultAddress(whirlpool.data.tokenMintA))[0],
10214
10225
  (await getLendingVaultAddress(whirlpool.data.tokenMintB))[0]
@@ -10216,27 +10227,12 @@ async function increaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
10216
10227
  const [mintA, mintB] = await fetchAllMaybeMint(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
10217
10228
  assert(mintA.exists, "Token A not found");
10218
10229
  assert(mintB.exists, "Token B not found");
10219
- const increaseAmounts = getIncreaseLpPositionQuote({
10220
- collateralA: BigInt(args.collateralA),
10221
- collateralB: BigInt(args.collateralB),
10222
- borrowA: BigInt(args.borrowA),
10223
- borrowB: BigInt(args.borrowB),
10224
- maxAmountSlippage: args.maxAmountSlippage,
10225
- sqrtPrice: whirlpool.data.sqrtPrice,
10226
- tickLowerIndex: tunaPosition.data.tickLowerIndex,
10227
- tickUpperIndex: tunaPosition.data.tickUpperIndex,
10228
- protocolFeeRate: market.data.protocolFee,
10229
- protocolFeeRateOnCollateral: market.data.protocolFeeOnCollateral,
10230
- swapFeeRate: whirlpool.data.feeRate,
10231
- liquidationThreshold: market.data.liquidationThreshold
10232
- });
10233
10230
  const createUserAtaAInstructions = await getCreateAtaInstructions(
10234
10231
  rpc,
10235
10232
  authority,
10236
10233
  mintA.address,
10237
10234
  authority.address,
10238
- mintA.programAddress,
10239
- increaseAmounts.maxCollateralA
10235
+ mintA.programAddress
10240
10236
  );
10241
10237
  createInstructions.push(...createUserAtaAInstructions.init);
10242
10238
  const createUserAtaBInstructions = await getCreateAtaInstructions(
@@ -10244,8 +10240,7 @@ async function increaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
10244
10240
  authority,
10245
10241
  mintB.address,
10246
10242
  authority.address,
10247
- mintB.programAddress,
10248
- increaseAmounts.maxCollateralB
10243
+ mintB.programAddress
10249
10244
  );
10250
10245
  createInstructions.push(...createUserAtaBInstructions.init);
10251
10246
  const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
@@ -10301,7 +10296,7 @@ async function increaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
10301
10296
  vaultA,
10302
10297
  vaultB,
10303
10298
  whirlpool,
10304
- { ...args, minAddedAmountA: increaseAmounts.minTotalA, minAddedAmountB: increaseAmounts.minTotalB }
10299
+ { ...args }
10305
10300
  );
10306
10301
  instructions.push(ix);
10307
10302
  cleanupInstructions.push(...createUserAtaAInstructions.cleanup);
@@ -10424,7 +10419,6 @@ async function increaseTunaLpPositionOrcaInstruction(authority, tunaPosition, tu
10424
10419
  }
10425
10420
 
10426
10421
  // src/txbuilder/increaseTunaLpPositionFusion.ts
10427
- import { getIncreaseLpPositionQuote as getIncreaseLpPositionQuote2 } from "@crypticdot/defituna-core";
10428
10422
  import {
10429
10423
  fetchAllMaybeTickArray,
10430
10424
  fetchMaybeFusionPool,
@@ -10453,8 +10447,6 @@ async function increaseTunaLpPositionFusionInstructions(rpc, authority, position
10453
10447
  if (!tunaPosition.exists) throw new Error("Tuna position account not found");
10454
10448
  const fusionPool = await fetchMaybeFusionPool(rpc, tunaPosition.data.pool);
10455
10449
  if (!fusionPool.exists) throw new Error("FusionPool account not found");
10456
- const marketAddress = (await getMarketAddress(tunaPosition.data.pool))[0];
10457
- const market = await fetchMarket(rpc, marketAddress);
10458
10450
  const [vaultA, vaultB] = await fetchAllVault(rpc, [
10459
10451
  (await getLendingVaultAddress(fusionPool.data.tokenMintA))[0],
10460
10452
  (await getLendingVaultAddress(fusionPool.data.tokenMintB))[0]
@@ -10462,27 +10454,12 @@ async function increaseTunaLpPositionFusionInstructions(rpc, authority, position
10462
10454
  const [mintA, mintB] = await fetchAllMaybeMint2(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
10463
10455
  assert2(mintA.exists, "Token A not found");
10464
10456
  assert2(mintB.exists, "Token B not found");
10465
- const increaseAmounts = getIncreaseLpPositionQuote2({
10466
- collateralA: BigInt(args.collateralA),
10467
- collateralB: BigInt(args.collateralB),
10468
- borrowA: BigInt(args.borrowA),
10469
- borrowB: BigInt(args.borrowB),
10470
- maxAmountSlippage: args.maxAmountSlippage,
10471
- sqrtPrice: fusionPool.data.sqrtPrice,
10472
- tickLowerIndex: tunaPosition.data.tickLowerIndex,
10473
- tickUpperIndex: tunaPosition.data.tickUpperIndex,
10474
- protocolFeeRate: market.data.protocolFee,
10475
- protocolFeeRateOnCollateral: market.data.protocolFeeOnCollateral,
10476
- swapFeeRate: fusionPool.data.feeRate,
10477
- liquidationThreshold: market.data.liquidationThreshold
10478
- });
10479
10457
  const createUserAtaAInstructions = await getCreateAtaInstructions(
10480
10458
  rpc,
10481
10459
  authority,
10482
10460
  mintA.address,
10483
10461
  authority.address,
10484
- mintA.programAddress,
10485
- increaseAmounts.maxCollateralA
10462
+ mintA.programAddress
10486
10463
  );
10487
10464
  createInstructions.push(...createUserAtaAInstructions.init);
10488
10465
  const createUserAtaBInstructions = await getCreateAtaInstructions(
@@ -10490,8 +10467,7 @@ async function increaseTunaLpPositionFusionInstructions(rpc, authority, position
10490
10467
  authority,
10491
10468
  mintB.address,
10492
10469
  authority.address,
10493
- mintB.programAddress,
10494
- increaseAmounts.maxCollateralB
10470
+ mintB.programAddress
10495
10471
  );
10496
10472
  createInstructions.push(...createUserAtaBInstructions.init);
10497
10473
  const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
@@ -10553,7 +10529,7 @@ async function increaseTunaLpPositionFusionInstructions(rpc, authority, position
10553
10529
  vaultA,
10554
10530
  vaultB,
10555
10531
  fusionPool,
10556
- { ...args, minAddedAmountA: increaseAmounts.minTotalA, minAddedAmountB: increaseAmounts.minTotalB }
10532
+ { ...args }
10557
10533
  );
10558
10534
  instructions.push(ix);
10559
10535
  cleanupInstructions.push(...createUserAtaAInstructions.cleanup);
@@ -11536,11 +11512,8 @@ async function closeActiveTunaLpPositionOrcaInstructions(rpc, authority, positio
11536
11512
  whirlpool,
11537
11513
  rewardsToClaim,
11538
11514
  rewardMints,
11539
- // TODO: Compute minRemovedAmounts according to slippage
11540
11515
  {
11541
11516
  ...args,
11542
- minRemovedAmountA: 0,
11543
- minRemovedAmountB: 0,
11544
11517
  decreasePercent: HUNDRED_PERCENT
11545
11518
  }
11546
11519
  )
@@ -11624,8 +11597,6 @@ async function closeActiveTunaLpPositionFusionInstructions(rpc, authority, posit
11624
11597
  // TODO: Compute minRemovedAmounts according to slippage
11625
11598
  {
11626
11599
  ...args,
11627
- minRemovedAmountA: 0,
11628
- minRemovedAmountB: 0,
11629
11600
  decreasePercent: HUNDRED_PERCENT
11630
11601
  }
11631
11602
  )
@@ -11699,23 +11670,9 @@ async function modifyTunaSpotPositionOrcaInstructions(rpc, authority, poolAddres
11699
11670
  hasDirectlyTransferredTokensA = tunaPositionAtaA.data.amount > (tunaPosition.data.positionToken == 0 /* A */ ? tunaPosition.data.amount : 0n);
11700
11671
  hasDirectlyTransferredTokensB = tunaPositionAtaB.data.amount > (tunaPosition.data.positionToken == 1 /* B */ ? tunaPosition.data.amount : 0n);
11701
11672
  }
11702
- const createUserAtaAInstructions = collateralToken == 0 /* A */ || hasDirectlyTransferredTokensA ? await getCreateAtaInstructions(
11703
- rpc,
11704
- authority,
11705
- mintA.address,
11706
- authority.address,
11707
- mintA.programAddress,
11708
- args.collateralAmount
11709
- ) : void 0;
11673
+ const createUserAtaAInstructions = collateralToken == 0 /* A */ || hasDirectlyTransferredTokensA ? await getCreateAtaInstructions(rpc, authority, mintA.address, authority.address, mintA.programAddress) : void 0;
11710
11674
  if (createUserAtaAInstructions) createInstructions.push(...createUserAtaAInstructions.init);
11711
- const createUserAtaBInstructions = collateralToken == 1 /* B */ || hasDirectlyTransferredTokensB ? await getCreateAtaInstructions(
11712
- rpc,
11713
- authority,
11714
- mintB.address,
11715
- authority.address,
11716
- mintB.programAddress,
11717
- args.collateralAmount
11718
- ) : void 0;
11675
+ const createUserAtaBInstructions = collateralToken == 1 /* B */ || hasDirectlyTransferredTokensB ? await getCreateAtaInstructions(rpc, authority, mintB.address, authority.address, mintB.programAddress) : void 0;
11719
11676
  if (createUserAtaBInstructions) createInstructions.push(...createUserAtaBInstructions.init);
11720
11677
  const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
11721
11678
  rpc,
@@ -11892,23 +11849,9 @@ async function modifyTunaSpotPositionFusionInstructions(rpc, authority, poolAddr
11892
11849
  hasDirectlyTransferredTokensA = tunaPositionAtaA.data.amount > (tunaPosition.data.positionToken == 0 /* A */ ? tunaPosition.data.amount : 0n);
11893
11850
  hasDirectlyTransferredTokensB = tunaPositionAtaB.data.amount > (tunaPosition.data.positionToken == 1 /* B */ ? tunaPosition.data.amount : 0n);
11894
11851
  }
11895
- const createUserAtaAInstructions = collateralToken == 0 /* A */ || hasDirectlyTransferredTokensA ? await getCreateAtaInstructions(
11896
- rpc,
11897
- authority,
11898
- mintA.address,
11899
- authority.address,
11900
- mintA.programAddress,
11901
- args.collateralAmount
11902
- ) : void 0;
11852
+ const createUserAtaAInstructions = collateralToken == 0 /* A */ || hasDirectlyTransferredTokensA ? await getCreateAtaInstructions(rpc, authority, mintA.address, authority.address, mintA.programAddress) : void 0;
11903
11853
  if (createUserAtaAInstructions) createInstructions.push(...createUserAtaAInstructions.init);
11904
- const createUserAtaBInstructions = collateralToken == 1 /* B */ || hasDirectlyTransferredTokensB ? await getCreateAtaInstructions(
11905
- rpc,
11906
- authority,
11907
- mintB.address,
11908
- authority.address,
11909
- mintB.programAddress,
11910
- args.collateralAmount
11911
- ) : void 0;
11854
+ const createUserAtaBInstructions = collateralToken == 1 /* B */ || hasDirectlyTransferredTokensB ? await getCreateAtaInstructions(rpc, authority, mintB.address, authority.address, mintB.programAddress) : void 0;
11912
11855
  if (createUserAtaBInstructions) createInstructions.push(...createUserAtaBInstructions.init);
11913
11856
  const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
11914
11857
  rpc,
@@ -13754,7 +13697,6 @@ async function openTunaLpPositionFusionInstruction(rpc, authority, positionMint,
13754
13697
  }
13755
13698
 
13756
13699
  // src/txbuilder/openAndIncreaseTunaLpPositionOrca.ts
13757
- import { getIncreaseLpPositionQuote as getIncreaseLpPositionQuote3 } from "@crypticdot/defituna-core";
13758
13700
  import {
13759
13701
  fetchAllMaybeTickArray as fetchAllMaybeTickArray2,
13760
13702
  fetchMaybeWhirlpool as fetchMaybeWhirlpool7,
@@ -13801,8 +13743,6 @@ async function openAndIncreaseTunaLpPositionOrcaInstructions(rpc, authority, whi
13801
13743
  const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
13802
13744
  const whirlpool = await fetchMaybeWhirlpool7(rpc, whirlpoolAddress);
13803
13745
  if (!whirlpool.exists) throw new Error("Whirlpool account not found");
13804
- const marketAddress = (await getMarketAddress(whirlpoolAddress))[0];
13805
- const market = await fetchMarket(rpc, marketAddress);
13806
13746
  const [mintA, mintB] = await fetchAllMaybeMint17(rpc, [whirlpool.data.tokenMintA, whirlpool.data.tokenMintB]);
13807
13747
  assert17(mintA.exists, "Token A account not found");
13808
13748
  assert17(mintB.exists, "Token B account not found");
@@ -13810,27 +13750,12 @@ async function openAndIncreaseTunaLpPositionOrcaInstructions(rpc, authority, whi
13810
13750
  (await getLendingVaultAddress(whirlpool.data.tokenMintA))[0],
13811
13751
  (await getLendingVaultAddress(whirlpool.data.tokenMintB))[0]
13812
13752
  ]);
13813
- const increaseAmounts = getIncreaseLpPositionQuote3({
13814
- collateralA: BigInt(args.collateralA),
13815
- collateralB: BigInt(args.collateralB),
13816
- borrowA: BigInt(args.borrowA),
13817
- borrowB: BigInt(args.borrowB),
13818
- maxAmountSlippage: args.maxAmountSlippage,
13819
- sqrtPrice: whirlpool.data.sqrtPrice,
13820
- tickLowerIndex: args.tickLowerIndex,
13821
- tickUpperIndex: args.tickUpperIndex,
13822
- protocolFeeRate: market.data.protocolFee,
13823
- protocolFeeRateOnCollateral: market.data.protocolFeeOnCollateral,
13824
- swapFeeRate: whirlpool.data.feeRate,
13825
- liquidationThreshold: market.data.liquidationThreshold
13826
- });
13827
13753
  const createUserAtaAInstructions = await getCreateAtaInstructions(
13828
13754
  rpc,
13829
13755
  authority,
13830
13756
  mintA.address,
13831
13757
  authority.address,
13832
- mintA.programAddress,
13833
- increaseAmounts.maxCollateralA
13758
+ mintA.programAddress
13834
13759
  );
13835
13760
  createInstructions.push(...createUserAtaAInstructions.init);
13836
13761
  const createUserAtaBInstructions = await getCreateAtaInstructions(
@@ -13838,8 +13763,7 @@ async function openAndIncreaseTunaLpPositionOrcaInstructions(rpc, authority, whi
13838
13763
  authority,
13839
13764
  mintB.address,
13840
13765
  authority.address,
13841
- mintB.programAddress,
13842
- increaseAmounts.maxCollateralB
13766
+ mintB.programAddress
13843
13767
  );
13844
13768
  createInstructions.push(...createUserAtaBInstructions.init);
13845
13769
  const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
@@ -13899,7 +13823,7 @@ async function openAndIncreaseTunaLpPositionOrcaInstructions(rpc, authority, whi
13899
13823
  vaultA,
13900
13824
  vaultB,
13901
13825
  whirlpool,
13902
- { ...args, minAddedAmountA: increaseAmounts.minTotalA, minAddedAmountB: increaseAmounts.minTotalB }
13826
+ { ...args }
13903
13827
  );
13904
13828
  instructions.push(ix);
13905
13829
  cleanupInstructions.push(...createUserAtaAInstructions.cleanup);
@@ -14023,7 +13947,6 @@ async function openAndIncreaseTunaLpPositionOrcaInstruction(authority, positionM
14023
13947
  }
14024
13948
 
14025
13949
  // src/txbuilder/openAndIncreaseTunaLpPositionFusion.ts
14026
- import { getIncreaseLpPositionQuote as getIncreaseLpPositionQuote4 } from "@crypticdot/defituna-core";
14027
13950
  import {
14028
13951
  fetchAllMaybeTickArray as fetchAllMaybeTickArray3,
14029
13952
  fetchMaybeFusionPool as fetchMaybeFusionPool7,
@@ -14059,8 +13982,6 @@ async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, f
14059
13982
  const tunaConfig = await fetchTunaConfig(rpc, (await getTunaConfigAddress())[0]);
14060
13983
  const fusionPool = await fetchMaybeFusionPool7(rpc, fusionPoolAddress);
14061
13984
  if (!fusionPool.exists) throw new Error("FusionPool account not found");
14062
- const marketAddress = (await getMarketAddress(fusionPoolAddress))[0];
14063
- const market = await fetchMarket(rpc, marketAddress);
14064
13985
  const [mintA, mintB] = await fetchAllMaybeMint18(rpc, [fusionPool.data.tokenMintA, fusionPool.data.tokenMintB]);
14065
13986
  assert18(mintA.exists, "Token A account not found");
14066
13987
  assert18(mintB.exists, "Token B account not found");
@@ -14068,27 +13989,12 @@ async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, f
14068
13989
  (await getLendingVaultAddress(fusionPool.data.tokenMintA))[0],
14069
13990
  (await getLendingVaultAddress(fusionPool.data.tokenMintB))[0]
14070
13991
  ]);
14071
- const increaseAmounts = getIncreaseLpPositionQuote4({
14072
- collateralA: BigInt(args.collateralA),
14073
- collateralB: BigInt(args.collateralB),
14074
- borrowA: BigInt(args.borrowA),
14075
- borrowB: BigInt(args.borrowB),
14076
- maxAmountSlippage: args.maxAmountSlippage,
14077
- sqrtPrice: fusionPool.data.sqrtPrice,
14078
- tickLowerIndex: args.tickLowerIndex,
14079
- tickUpperIndex: args.tickUpperIndex,
14080
- protocolFeeRate: market.data.protocolFee,
14081
- protocolFeeRateOnCollateral: market.data.protocolFeeOnCollateral,
14082
- swapFeeRate: fusionPool.data.feeRate,
14083
- liquidationThreshold: market.data.liquidationThreshold
14084
- });
14085
13992
  const createUserAtaAInstructions = await getCreateAtaInstructions(
14086
13993
  rpc,
14087
13994
  authority,
14088
13995
  mintA.address,
14089
13996
  authority.address,
14090
- mintA.programAddress,
14091
- increaseAmounts.maxCollateralA
13997
+ mintA.programAddress
14092
13998
  );
14093
13999
  createInstructions.push(...createUserAtaAInstructions.init);
14094
14000
  const createUserAtaBInstructions = await getCreateAtaInstructions(
@@ -14096,8 +14002,7 @@ async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, f
14096
14002
  authority,
14097
14003
  mintB.address,
14098
14004
  authority.address,
14099
- mintB.programAddress,
14100
- increaseAmounts.maxCollateralB
14005
+ mintB.programAddress
14101
14006
  );
14102
14007
  createInstructions.push(...createUserAtaBInstructions.init);
14103
14008
  const createFeeRecipientAtaAInstructions = await getCreateAtaInstructions(
@@ -14155,7 +14060,7 @@ async function openAndIncreaseTunaLpPositionFusionInstructions(rpc, authority, f
14155
14060
  vaultA,
14156
14061
  vaultB,
14157
14062
  fusionPool,
14158
- { ...args, minAddedAmountA: increaseAmounts.minTotalA, minAddedAmountB: increaseAmounts.minTotalB }
14063
+ { ...args }
14159
14064
  );
14160
14065
  instructions.push(ix);
14161
14066
  cleanupInstructions.push(...createUserAtaAInstructions.cleanup);
@@ -14427,8 +14332,7 @@ async function decreaseTunaLpPositionOrcaInstructions(rpc, authority, positionMi
14427
14332
  whirlpool,
14428
14333
  rewardsToClaim,
14429
14334
  rewardMints,
14430
- // TODO: Compute minRemovedAmounts according to slippage
14431
- { ...args, minRemovedAmountA: 0, minRemovedAmountB: 0 }
14335
+ { ...args }
14432
14336
  );
14433
14337
  instructions.push(ix);
14434
14338
  cleanupInstructions.push(...internalCleanupInstructions);
@@ -14609,8 +14513,7 @@ async function decreaseTunaLpPositionFusionInstructions(rpc, authority, position
14609
14513
  vaultA,
14610
14514
  vaultB,
14611
14515
  fusionPool,
14612
- // TODO: Compute minRemovedAmounts according to slippage
14613
- { ...args, minRemovedAmountA: 0, minRemovedAmountB: 0 }
14516
+ { ...args }
14614
14517
  );
14615
14518
  instructions.push(ix);
14616
14519
  cleanupInstructions.push(...createUserAtaAInstructions.cleanup);
@@ -15011,8 +14914,7 @@ async function repayTunaLpPositionDebtInstructions(rpc, authority, positionMint,
15011
14914
  authority,
15012
14915
  mintA.address,
15013
14916
  authority.address,
15014
- mintA.programAddress,
15015
- collateralA
14917
+ mintA.programAddress
15016
14918
  );
15017
14919
  createInstructions.push(...createUserAtaAInstructions.init);
15018
14920
  const createUserAtaBInstructions = await getCreateAtaInstructions(
@@ -15020,8 +14922,7 @@ async function repayTunaLpPositionDebtInstructions(rpc, authority, positionMint,
15020
14922
  authority,
15021
14923
  mintB.address,
15022
14924
  authority.address,
15023
- mintB.programAddress,
15024
- collateralB
14925
+ mintB.programAddress
15025
14926
  );
15026
14927
  createInstructions.push(...createUserAtaBInstructions.init);
15027
14928
  const ix = await repayTunaLpPositionDebtInstruction(
@@ -15575,14 +15476,11 @@ export {
15575
15476
  TUNA_ERROR__INVALID_MARKET_MAKER,
15576
15477
  TUNA_ERROR__INVALID_POOL,
15577
15478
  TUNA_ERROR__INVALID_REMAINING_ACCOUNTS_LENGTH,
15578
- TUNA_ERROR__INVALID_SQRT_PRICE_LIMIT_DIRECTION,
15579
- TUNA_ERROR__INVALID_TICK_ARRAY_SEQUENCE,
15580
15479
  TUNA_ERROR__INVALID_VAULT,
15581
15480
  TUNA_ERROR__LEFTOVERS_EXCEEDED,
15582
15481
  TUNA_ERROR__LEVERAGE_IS_OUT_OF_RANGE,
15583
15482
  TUNA_ERROR__LIQUIDATION_FEE_IS_OUT_OF_RANGE,
15584
15483
  TUNA_ERROR__LIQUIDATION_THRESHOLD_IS_OUT_OF_RANGE,
15585
- TUNA_ERROR__LIQUIDITY_ZERO,
15586
15484
  TUNA_ERROR__MARKET_DEBT_LIMIT_EXCEEDED,
15587
15485
  TUNA_ERROR__MARKET_DISABLED,
15588
15486
  TUNA_ERROR__MATH_OVERFLOW,
@@ -15592,7 +15490,6 @@ export {
15592
15490
  TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_EXCEEDED,
15593
15491
  TUNA_ERROR__ORACLE_PRICE_DEVIATION_THRESHOLD_OUT_OF_RANGE,
15594
15492
  TUNA_ERROR__ORACLE_STALE_PRICE,
15595
- TUNA_ERROR__PARTIAL_FILL_ERROR,
15596
15493
  TUNA_ERROR__POSITION_IS_AUTO_REBALANCEABLE,
15597
15494
  TUNA_ERROR__POSITION_IS_EMPTY,
15598
15495
  TUNA_ERROR__POSITION_IS_HEALTHY,
@@ -15609,26 +15506,22 @@ export {
15609
15506
  TUNA_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE_LENGTH,
15610
15507
  TUNA_ERROR__REQUIRED_REMAINING_ACCOUNT_NOT_PROVIDED,
15611
15508
  TUNA_ERROR__SOLVER_FAILED_TO_FIND_ROOT,
15612
- TUNA_ERROR__SQRT_PRICE_OUT_OF_BOUNDS,
15613
15509
  TUNA_ERROR__SUPPLY_LIMIT_EXCEEDED,
15614
15510
  TUNA_ERROR__SUSPENDED,
15615
15511
  TUNA_ERROR__SWAP_QUOTE_NOT_EQUAL_TO_ACTUAL_SWAP_AMOUNT,
15616
15512
  TUNA_ERROR__SWAP_SLIPPAGE_EXCEEDED,
15617
15513
  TUNA_ERROR__SWAP_SLIPPAGE_IS_OUT_OF_RANGE,
15618
15514
  TUNA_ERROR__SWAP_TO_POSITION_RATIO_ESTIMATION_FAILED,
15619
- TUNA_ERROR__TICK_INDEX_OF_BOUNDS,
15620
15515
  TUNA_ERROR__TRANSFER_FEE_CALCULATION_ERROR,
15621
15516
  TUNA_ERROR__TYPE_CAST_OVERFLOW,
15622
15517
  TUNA_ERROR__UNABLE_TO_DESERIALIZE_ACCOUNT_DATA,
15623
15518
  TUNA_ERROR__UNABLE_TO_LOAD_ACCOUNT_DATA,
15624
15519
  TUNA_ERROR__UNEXPECTED_VALUE,
15625
15520
  TUNA_ERROR__UNSUPPORTED_TOKEN_MINT,
15626
- TUNA_ERROR__UNUSED,
15627
15521
  TUNA_ERROR__VAULT_NOT_INITIALIZED,
15628
15522
  TUNA_ERROR__WITHDRAW_REQUEST_EXCEEDS_USER_BALANCE,
15629
15523
  TUNA_ERROR__ZERO_AMOUNT,
15630
15524
  TUNA_ERROR__ZERO_PRICE_RANGE,
15631
- TUNA_ERROR__ZERO_TRADABLE_AMOUNT,
15632
15525
  TUNA_ERROR__ZERO_YIELD,
15633
15526
  TUNA_LP_POSITION_DISCRIMINATOR,
15634
15527
  TUNA_POSITION_FLAGS_ALLOW_REBALANCING,