torchsdk 3.7.21 → 3.7.23

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.
@@ -2,7 +2,7 @@
2
2
  "address": "8hbUkonssSEEtkqzwM7ZcZrD9evacM92TcWSooVF4BeT",
3
3
  "metadata": {
4
4
  "name": "torch_market",
5
- "version": "3.7.5",
5
+ "version": "3.7.8",
6
6
  "spec": "0.1.0",
7
7
  "description": "torch.market"
8
8
  },
@@ -796,6 +796,13 @@
796
796
  ]
797
797
  }
798
798
  },
799
+ {
800
+ "name": "creator",
801
+ "docs": [
802
+ "[V34] Creator wallet — receives SOL share during bonding (0.2%→1%)"
803
+ ],
804
+ "writable": true
805
+ },
799
806
  {
800
807
  "name": "torch_vault",
801
808
  "docs": [
@@ -1466,233 +1473,6 @@
1466
1473
  }
1467
1474
  ]
1468
1475
  },
1469
- {
1470
- "name": "execute_auto_buyback",
1471
- "docs": [
1472
- "[V9] Execute automatic treasury buyback on Raydium DEX.",
1473
- "Monitors pool ratio and triggers buyback when price drops below threshold.",
1474
- "Permissionless - anyone can call (keeper/crank)."
1475
- ],
1476
- "discriminator": [
1477
- 191,
1478
- 2,
1479
- 228,
1480
- 246,
1481
- 241,
1482
- 139,
1483
- 119,
1484
- 21
1485
- ],
1486
- "accounts": [
1487
- {
1488
- "name": "payer",
1489
- "docs": [
1490
- "Anyone can trigger buyback (permissionless)"
1491
- ],
1492
- "writable": true,
1493
- "signer": true
1494
- },
1495
- {
1496
- "name": "mint",
1497
- "docs": [
1498
- "Token mint (mutable for burning)"
1499
- ],
1500
- "writable": true
1501
- },
1502
- {
1503
- "name": "bonding_curve",
1504
- "docs": [
1505
- "Bonding curve (must be migrated)"
1506
- ],
1507
- "pda": {
1508
- "seeds": [
1509
- {
1510
- "kind": "const",
1511
- "value": [
1512
- 98,
1513
- 111,
1514
- 110,
1515
- 100,
1516
- 105,
1517
- 110,
1518
- 103,
1519
- 95,
1520
- 99,
1521
- 117,
1522
- 114,
1523
- 118,
1524
- 101
1525
- ]
1526
- },
1527
- {
1528
- "kind": "account",
1529
- "path": "mint"
1530
- }
1531
- ]
1532
- }
1533
- },
1534
- {
1535
- "name": "treasury",
1536
- "docs": [
1537
- "Token treasury (has SOL for buybacks)"
1538
- ],
1539
- "writable": true,
1540
- "pda": {
1541
- "seeds": [
1542
- {
1543
- "kind": "const",
1544
- "value": [
1545
- 116,
1546
- 114,
1547
- 101,
1548
- 97,
1549
- 115,
1550
- 117,
1551
- 114,
1552
- 121
1553
- ]
1554
- },
1555
- {
1556
- "kind": "account",
1557
- "path": "mint"
1558
- }
1559
- ]
1560
- }
1561
- },
1562
- {
1563
- "name": "treasury_wsol",
1564
- "docs": [
1565
- "[V27] Treasury's WSOL account — constrained as treasury's WSOL ATA"
1566
- ],
1567
- "writable": true
1568
- },
1569
- {
1570
- "name": "treasury_token",
1571
- "docs": [
1572
- "Treasury's token account for receiving bought tokens"
1573
- ],
1574
- "writable": true,
1575
- "pda": {
1576
- "seeds": [
1577
- {
1578
- "kind": "account",
1579
- "path": "treasury"
1580
- },
1581
- {
1582
- "kind": "account",
1583
- "path": "token_2022_program"
1584
- },
1585
- {
1586
- "kind": "account",
1587
- "path": "mint"
1588
- }
1589
- ],
1590
- "program": {
1591
- "kind": "const",
1592
- "value": [
1593
- 140,
1594
- 151,
1595
- 37,
1596
- 143,
1597
- 78,
1598
- 36,
1599
- 137,
1600
- 241,
1601
- 187,
1602
- 61,
1603
- 16,
1604
- 41,
1605
- 20,
1606
- 142,
1607
- 13,
1608
- 131,
1609
- 11,
1610
- 90,
1611
- 19,
1612
- 153,
1613
- 218,
1614
- 255,
1615
- 16,
1616
- 132,
1617
- 4,
1618
- 142,
1619
- 123,
1620
- 216,
1621
- 219,
1622
- 233,
1623
- 248,
1624
- 89
1625
- ]
1626
- }
1627
- }
1628
- },
1629
- {
1630
- "name": "raydium_program",
1631
- "address": "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"
1632
- },
1633
- {
1634
- "name": "raydium_authority"
1635
- },
1636
- {
1637
- "name": "amm_config",
1638
- "docs": [
1639
- "Raydium AMM config — constrained to prevent pool substitution attacks"
1640
- ],
1641
- "address": "D4FPEruKEHrG5TenZ2mpDGEfu1iUvTiqBxvpU8HLBvC2"
1642
- },
1643
- {
1644
- "name": "pool_state",
1645
- "docs": [
1646
- "[V27] Raydium pool state — constrained via PDA derivation"
1647
- ],
1648
- "writable": true
1649
- },
1650
- {
1651
- "name": "input_vault",
1652
- "docs": [
1653
- "[V27] Pool's input vault (WSOL vault) — constrained via PDA derivation"
1654
- ],
1655
- "writable": true
1656
- },
1657
- {
1658
- "name": "output_vault",
1659
- "docs": [
1660
- "[V27] Pool's output vault (token vault) — constrained via PDA derivation"
1661
- ],
1662
- "writable": true
1663
- },
1664
- {
1665
- "name": "wsol_mint",
1666
- "docs": [
1667
- "WSOL mint"
1668
- ],
1669
- "address": "So11111111111111111111111111111111111111112"
1670
- },
1671
- {
1672
- "name": "observation_state",
1673
- "docs": [
1674
- "[V27] Raydium observation state — constrained via PDA derivation"
1675
- ],
1676
- "writable": true
1677
- },
1678
- {
1679
- "name": "token_program"
1680
- },
1681
- {
1682
- "name": "token_2022_program"
1683
- },
1684
- {
1685
- "name": "system_program",
1686
- "address": "11111111111111111111111111111111"
1687
- }
1688
- ],
1689
- "args": [
1690
- {
1691
- "name": "minimum_amount_out",
1692
- "type": "u64"
1693
- }
1694
- ]
1695
- },
1696
1476
  {
1697
1477
  "name": "fund_migration_wsol",
1698
1478
  "docs": [
@@ -4078,6 +3858,13 @@
4078
3858
  ]
4079
3859
  }
4080
3860
  },
3861
+ {
3862
+ "name": "creator",
3863
+ "docs": [
3864
+ "[V34] Creator wallet — receives 15% of fee swap proceeds"
3865
+ ],
3866
+ "writable": true
3867
+ },
4081
3868
  {
4082
3869
  "name": "treasury",
4083
3870
  "docs": [
@@ -5365,7 +5152,7 @@
5365
5152
  {
5366
5153
  "code": 6040,
5367
5154
  "name": "InsufficientVolumeForRewards",
5368
- "msg": "Insufficient volume for protocol rewards (need >= 10 SOL/epoch)"
5155
+ "msg": "Insufficient volume for protocol rewards (need >= 2 SOL/epoch)"
5369
5156
  },
5370
5157
  {
5371
5158
  "code": 6041,
@@ -5466,6 +5253,11 @@
5466
5253
  "code": 6060,
5467
5254
  "name": "InvalidTokenAccount",
5468
5255
  "msg": "Invalid token account - must be treasury lock's Token-2022 ATA"
5256
+ },
5257
+ {
5258
+ "code": 6061,
5259
+ "name": "ClaimBelowMinimum",
5260
+ "msg": "Claim amount below minimum (0.1 SOL)"
5469
5261
  }
5470
5262
  ],
5471
5263
  "types": [
@@ -5,7 +5,7 @@
5
5
  * Agents sign these locally and submit to the network.
6
6
  */
7
7
  import { Connection } from '@solana/web3.js';
8
- import { BuyParams, DirectBuyParams, SellParams, CreateTokenParams, StarParams, MigrateParams, BorrowParams, RepayParams, LiquidateParams, ClaimProtocolRewardsParams, VaultSwapParams, AutoBuybackParams, HarvestFeesParams, SwapFeesToSolParams, CreateVaultParams, DepositVaultParams, WithdrawVaultParams, WithdrawTokensParams, LinkWalletParams, UnlinkWalletParams, TransferAuthorityParams, TransactionResult, BuyTransactionResult, CreateTokenResult } from './types';
8
+ import { BuyParams, DirectBuyParams, SellParams, CreateTokenParams, StarParams, MigrateParams, BorrowParams, RepayParams, LiquidateParams, ClaimProtocolRewardsParams, VaultSwapParams, HarvestFeesParams, SwapFeesToSolParams, CreateVaultParams, DepositVaultParams, WithdrawVaultParams, WithdrawTokensParams, LinkWalletParams, UnlinkWalletParams, TransferAuthorityParams, TransactionResult, BuyTransactionResult, CreateTokenResult } from './types';
9
9
  /**
10
10
  * Build an unsigned vault-funded buy transaction.
11
11
  *
@@ -151,7 +151,7 @@ export declare const buildLiquidateTransaction: (connection: Connection, params:
151
151
  * Build an unsigned claim protocol rewards transaction.
152
152
  *
153
153
  * Claims the user's proportional share of protocol treasury rewards
154
- * based on trading volume in the previous epoch. Requires >= 10 SOL volume.
154
+ * based on trading volume in the previous epoch. Requires >= 2 SOL volume. Min claim: 0.1 SOL.
155
155
  *
156
156
  * @param connection - Solana RPC connection
157
157
  * @param params - Claim parameters (user, optional vault)
@@ -198,17 +198,6 @@ export declare const buildMigrateTransaction: (connection: Connection, params: M
198
198
  * @returns Unsigned transaction and descriptive message
199
199
  */
200
200
  export declare const buildVaultSwapTransaction: (connection: Connection, params: VaultSwapParams) => Promise<TransactionResult>;
201
- /**
202
- * Build an unsigned auto-buyback transaction.
203
- *
204
- * Permissionless crank — triggers a treasury buyback on Raydium when the pool
205
- * price has dropped below the treasury's ratio threshold. Holds bought tokens
206
- * in treasury ATA (swap_fees_to_sol recycles them).
207
- *
208
- * Pre-checks all on-chain conditions and throws descriptive errors so the
209
- * caller (e.g. frontend) knows exactly why a buyback can't fire.
210
- */
211
- export declare const buildAutoBuybackTransaction: (connection: Connection, params: AutoBuybackParams) => Promise<TransactionResult>;
212
201
  /**
213
202
  * Build an unsigned harvest-fees transaction.
214
203
  *
@@ -1 +1 @@
1
- {"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../src/transactions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,UAAU,EAQX,MAAM,iBAAiB,CAAA;AAiCxB,OAAO,EACL,SAAS,EACT,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,YAAY,EACZ,WAAW,EACX,eAAe,EACf,0BAA0B,EAC1B,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,SAAS,CAAA;AA6MhB;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAC9B,YAAY,UAAU,EACtB,QAAQ,SAAS,KAChB,OAAO,CAAC,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A8B,GACzC,YAAY,UAAU,EACtB,QAAQ,oBAAoB,KAC3B,OAAO,CAAC,iBAAiB,CAyD3B,CAAA;AAUD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,uBAAuB,GAClC,YAAY,UAAU,EACtB,QAAQ,aAAa,KACpB,OAAO,CAAC,iBAAiB,CAoH3B,CAAA;AAMD;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,GACpC,YAAY,UAAU,EACtB,QAAQ,eAAe,KACtB,OAAO,CAAC,iBAAiB,CAoH3B,CAAA;AAMD;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,GACtC,YAAY,UAAU,EACtB,QAAQ,iBAAiB,KACxB,OAAO,CAAC,iBAAiB,CAmF3B,CAAA;AAKD;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,GACxC,YAAY,UAAU,EACtB,QAAQ,mBAAmB,KAC1B,OAAO,CAAC,iBAAiB,CAkL3B,CAAA"}
@@ -9,7 +9,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.buildSwapFeesToSolTransaction = exports.buildHarvestFeesTransaction = exports.buildAutoBuybackTransaction = exports.buildVaultSwapTransaction = exports.buildMigrateTransaction = exports.buildWithdrawTokensTransaction = exports.buildClaimProtocolRewardsTransaction = exports.buildLiquidateTransaction = exports.buildRepayTransaction = exports.buildBorrowTransaction = exports.buildTransferAuthorityTransaction = exports.buildUnlinkWalletTransaction = exports.buildLinkWalletTransaction = exports.buildWithdrawVaultTransaction = exports.buildDepositVaultTransaction = exports.buildCreateVaultTransaction = exports.buildStarTransaction = exports.buildCreateTokenTransaction = exports.buildSellTransaction = exports.buildDirectBuyTransaction = exports.buildBuyTransaction = void 0;
12
+ exports.buildSwapFeesToSolTransaction = exports.buildHarvestFeesTransaction = exports.buildVaultSwapTransaction = exports.buildMigrateTransaction = exports.buildWithdrawTokensTransaction = exports.buildClaimProtocolRewardsTransaction = exports.buildLiquidateTransaction = exports.buildRepayTransaction = exports.buildBorrowTransaction = exports.buildTransferAuthorityTransaction = exports.buildUnlinkWalletTransaction = exports.buildLinkWalletTransaction = exports.buildWithdrawVaultTransaction = exports.buildDepositVaultTransaction = exports.buildCreateVaultTransaction = exports.buildStarTransaction = exports.buildCreateTokenTransaction = exports.buildSellTransaction = exports.buildDirectBuyTransaction = exports.buildBuyTransaction = void 0;
13
13
  const web3_js_1 = require("@solana/web3.js");
14
14
  const spl_token_1 = require("@solana/spl-token");
15
15
  const anchor_1 = require("@coral-xyz/anchor");
@@ -104,6 +104,7 @@ const buildBuyTransactionInternal = async (connection, mintStr, buyerStr, amount
104
104
  globalConfig: globalConfigPda,
105
105
  devWallet: globalConfigAccount.devWallet || globalConfigAccount.dev_wallet,
106
106
  protocolTreasury: protocolTreasuryPda,
107
+ creator: bondingCurve.creator,
107
108
  mint,
108
109
  bondingCurve: bondingCurvePda,
109
110
  tokenVault: bondingCurveTokenAccount,
@@ -840,7 +841,7 @@ exports.buildLiquidateTransaction = buildLiquidateTransaction;
840
841
  * Build an unsigned claim protocol rewards transaction.
841
842
  *
842
843
  * Claims the user's proportional share of protocol treasury rewards
843
- * based on trading volume in the previous epoch. Requires >= 10 SOL volume.
844
+ * based on trading volume in the previous epoch. Requires >= 2 SOL volume. Min claim: 0.1 SOL.
844
845
  *
845
846
  * @param connection - Solana RPC connection
846
847
  * @param params - Claim parameters (user, optional vault)
@@ -1122,125 +1123,6 @@ exports.buildVaultSwapTransaction = buildVaultSwapTransaction;
1122
1123
  // ============================================================================
1123
1124
  // Treasury Cranks
1124
1125
  // ============================================================================
1125
- // Auto-buyback constants (must match the on-chain program)
1126
- const MIN_BUYBACK_AMOUNT = BigInt('10000000'); // 0.01 SOL in lamports
1127
- const RATIO_PRECISION = BigInt('1000000000'); // 1e9
1128
- /**
1129
- * Build an unsigned auto-buyback transaction.
1130
- *
1131
- * Permissionless crank — triggers a treasury buyback on Raydium when the pool
1132
- * price has dropped below the treasury's ratio threshold. Holds bought tokens
1133
- * in treasury ATA (swap_fees_to_sol recycles them).
1134
- *
1135
- * Pre-checks all on-chain conditions and throws descriptive errors so the
1136
- * caller (e.g. frontend) knows exactly why a buyback can't fire.
1137
- */
1138
- const buildAutoBuybackTransaction = async (connection, params) => {
1139
- const { mint: mintStr, payer: payerStr, minimum_amount_out = 1 } = params;
1140
- const mint = new web3_js_1.PublicKey(mintStr);
1141
- const payer = new web3_js_1.PublicKey(payerStr);
1142
- // Fetch on-chain state for pre-checks
1143
- const tokenData = await (0, tokens_1.fetchTokenRaw)(connection, mint);
1144
- if (!tokenData)
1145
- throw new Error(`Token not found: ${mintStr}`);
1146
- const { bondingCurve, treasury } = tokenData;
1147
- // Pre-check 1: Token must be migrated
1148
- if (!bondingCurve.migrated) {
1149
- throw new Error('Token not yet migrated');
1150
- }
1151
- // Pre-check 2: Baseline must be initialized
1152
- if (!treasury || !treasury.baseline_initialized) {
1153
- throw new Error('Buyback baseline not initialized');
1154
- }
1155
- // Pre-check 3: Cooldown check
1156
- const currentSlot = await connection.getSlot('confirmed');
1157
- const lastBuybackSlot = BigInt(treasury.last_buyback_slot.toString());
1158
- const minInterval = BigInt(treasury.min_buyback_interval_slots.toString());
1159
- const nextBuybackSlot = lastBuybackSlot + minInterval;
1160
- if (BigInt(currentSlot) < nextBuybackSlot) {
1161
- const slotsRemaining = Number(nextBuybackSlot - BigInt(currentSlot));
1162
- throw new Error(`Buyback cooldown: ${slotsRemaining} slots remaining`);
1163
- }
1164
- // Raydium pool accounts
1165
- const raydium = (0, program_1.getRaydiumMigrationAccounts)(mint);
1166
- // Pre-check 5: Price check — read pool vault balances
1167
- const solVault = raydium.isWsolToken0 ? raydium.token0Vault : raydium.token1Vault;
1168
- const tokenVault = raydium.isWsolToken0 ? raydium.token1Vault : raydium.token0Vault;
1169
- const [solVaultInfo, tokenVaultInfo] = await Promise.all([
1170
- connection.getTokenAccountBalance(solVault),
1171
- connection.getTokenAccountBalance(tokenVault),
1172
- ]);
1173
- const poolSol = BigInt(solVaultInfo.value.amount);
1174
- const poolTokens = BigInt(tokenVaultInfo.value.amount);
1175
- const baselineSol = BigInt(treasury.baseline_sol_reserves.toString());
1176
- const baselineTokens = BigInt(treasury.baseline_token_reserves.toString());
1177
- const thresholdBps = BigInt(treasury.ratio_threshold_bps);
1178
- if (poolTokens > BigInt(0) && baselineTokens > BigInt(0)) {
1179
- const currentRatio = (poolSol * RATIO_PRECISION) / poolTokens;
1180
- const baselineRatio = (baselineSol * RATIO_PRECISION) / baselineTokens;
1181
- const thresholdRatio = (baselineRatio * thresholdBps) / BigInt(10000);
1182
- if (currentRatio >= thresholdRatio) {
1183
- const currentPct = Number((currentRatio * BigInt(10000)) / baselineRatio) / 100;
1184
- const thresholdPct = Number(thresholdBps) / 100;
1185
- throw new Error(`Price is healthy — no buyback needed (current: ${currentPct.toFixed(1)}% of baseline, threshold: ${thresholdPct.toFixed(1)}%)`);
1186
- }
1187
- }
1188
- // Pre-check 6: Dust check — compute buyback_amount
1189
- const treasurySolBalance = BigInt(treasury.sol_balance.toString());
1190
- const reserveRatioBps = BigInt(treasury.reserve_ratio_bps);
1191
- const buybackPercentBps = BigInt(treasury.buyback_percent_bps);
1192
- const availableSol = (treasurySolBalance * (BigInt(10000) - reserveRatioBps)) / BigInt(10000);
1193
- const buybackAmount = (availableSol * buybackPercentBps) / BigInt(10000);
1194
- if (buybackAmount < MIN_BUYBACK_AMOUNT) {
1195
- const availableSolNum = Number(availableSol) / 1e9;
1196
- throw new Error(`Treasury SOL too low for buyback (available: ${availableSolNum.toFixed(4)} SOL, need >= 0.01 SOL after reserves)`);
1197
- }
1198
- // All pre-checks passed — build the transaction
1199
- const [bondingCurvePda] = (0, program_1.getBondingCurvePda)(mint);
1200
- const [treasuryPda] = (0, program_1.getTokenTreasuryPda)(mint);
1201
- const treasuryTokenAccount = (0, program_1.getTreasuryTokenAccount)(mint, treasuryPda);
1202
- // Treasury's WSOL ATA (SPL Token)
1203
- const treasuryWsol = (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.WSOL_MINT, treasuryPda, true, spl_token_1.TOKEN_PROGRAM_ID);
1204
- // For buyback: input = WSOL (SOL side), output = token
1205
- const inputVault = raydium.isWsolToken0 ? raydium.token0Vault : raydium.token1Vault;
1206
- const outputVault = raydium.isWsolToken0 ? raydium.token1Vault : raydium.token0Vault;
1207
- const tx = new web3_js_1.Transaction();
1208
- tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 400000 }));
1209
- // Create treasury WSOL ATA if needed
1210
- tx.add((0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(payer, treasuryWsol, treasuryPda, constants_1.WSOL_MINT, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID));
1211
- const provider = makeDummyProvider(connection, payer);
1212
- const program = new anchor_1.Program(torch_market_json_1.default, provider);
1213
- const buybackIx = await program.methods
1214
- .executeAutoBuyback(new anchor_1.BN(minimum_amount_out.toString()))
1215
- .accounts({
1216
- payer,
1217
- mint,
1218
- bondingCurve: bondingCurvePda,
1219
- treasury: treasuryPda,
1220
- treasuryWsol,
1221
- treasuryToken: treasuryTokenAccount,
1222
- raydiumProgram: (0, constants_1.getRaydiumCpmmProgram)(),
1223
- raydiumAuthority: raydium.raydiumAuthority,
1224
- ammConfig: (0, constants_1.getRaydiumAmmConfig)(),
1225
- poolState: raydium.poolState,
1226
- inputVault,
1227
- outputVault,
1228
- wsolMint: constants_1.WSOL_MINT,
1229
- observationState: raydium.observationState,
1230
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1231
- token2022Program: spl_token_1.TOKEN_2022_PROGRAM_ID,
1232
- systemProgram: web3_js_1.SystemProgram.programId,
1233
- })
1234
- .instruction();
1235
- tx.add(buybackIx);
1236
- await finalizeTransaction(connection, tx, payer);
1237
- const buybackSol = Number(buybackAmount) / 1e9;
1238
- return {
1239
- transaction: tx,
1240
- message: `Auto-buyback ${buybackSol.toFixed(4)} SOL for ${mintStr.slice(0, 8)}...`,
1241
- };
1242
- };
1243
- exports.buildAutoBuybackTransaction = buildAutoBuybackTransaction;
1244
1126
  /**
1245
1127
  * Build an unsigned harvest-fees transaction.
1246
1128
  *
@@ -1352,6 +1234,11 @@ const buildSwapFeesToSolTransaction = async (connection, params) => {
1352
1234
  const wsolVault = raydium.isWsolToken0 ? raydium.token0Vault : raydium.token1Vault;
1353
1235
  const provider = makeDummyProvider(connection, payer);
1354
1236
  const program = new anchor_1.Program(torch_market_json_1.default, provider);
1237
+ // [V34] Fetch bonding curve to get creator address for fee split
1238
+ const tokenData = await (0, tokens_1.fetchTokenRaw)(connection, mint);
1239
+ if (!tokenData)
1240
+ throw new Error(`Token not found: ${mintStr}`);
1241
+ const creator = tokenData.bondingCurve.creator;
1355
1242
  // Helper: build the harvest instruction with given sources
1356
1243
  const buildHarvestIx = async (sources) => {
1357
1244
  return program.methods
@@ -1380,6 +1267,7 @@ const buildSwapFeesToSolTransaction = async (connection, params) => {
1380
1267
  payer,
1381
1268
  mint,
1382
1269
  bondingCurve: bondingCurvePda,
1270
+ creator,
1383
1271
  treasury: treasuryPda,
1384
1272
  treasuryTokenAccount,
1385
1273
  treasuryWsol,