@flaunch/sdk 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/abi/AnyBidWall.d.ts +740 -0
  2. package/dist/abi/AnyBidWall.d.ts.map +1 -0
  3. package/dist/abi/AnyPositionManager.d.ts +27 -27
  4. package/dist/abi/index.cjs +25 -25
  5. package/dist/abi/index.cjs.map +1 -1
  6. package/dist/abi/index.js +25 -25
  7. package/dist/abi/index.js.map +1 -1
  8. package/dist/addresses/index.cjs +21 -3
  9. package/dist/addresses/index.cjs.map +1 -1
  10. package/dist/addresses/index.js +19 -4
  11. package/dist/addresses/index.js.map +1 -1
  12. package/dist/addresses.d.ts +3 -0
  13. package/dist/addresses.d.ts.map +1 -1
  14. package/dist/clients/AnyBidWall.d.ts +46 -0
  15. package/dist/clients/AnyBidWall.d.ts.map +1 -0
  16. package/dist/clients/AnyPositionManagerClient.d.ts +8 -0
  17. package/dist/clients/AnyPositionManagerClient.d.ts.map +1 -1
  18. package/dist/clients/FlaunchPositionManagerClient.d.ts +8 -0
  19. package/dist/clients/FlaunchPositionManagerClient.d.ts.map +1 -1
  20. package/dist/clients/FlaunchPositionManagerV1_1Client.d.ts +8 -0
  21. package/dist/clients/FlaunchPositionManagerV1_1Client.d.ts.map +1 -1
  22. package/dist/clients/FlaunchZapClient.d.ts +35 -0
  23. package/dist/clients/FlaunchZapClient.d.ts.map +1 -1
  24. package/dist/index.cjs.js +1062 -221
  25. package/dist/index.cjs.js.map +1 -1
  26. package/dist/index.d.ts +2 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.esm.js +1059 -222
  29. package/dist/index.esm.js.map +1 -1
  30. package/dist/index.umd.js +1 -1
  31. package/dist/index.umd.js.map +1 -1
  32. package/dist/sdk/FlaunchSDK.d.ts +60 -2
  33. package/dist/sdk/FlaunchSDK.d.ts.map +1 -1
  34. package/dist/utils/parseSwap.d.ts +43 -0
  35. package/dist/utils/parseSwap.d.ts.map +1 -0
  36. package/package.json +1 -1
package/dist/index.cjs.js CHANGED
@@ -5325,8 +5325,9 @@ const FlaunchPositionManagerV1_1Address = {
5325
5325
  [baseSepolia.id]: "0x24347e0dd16357059abfc1b321df354873552fdc",
5326
5326
  };
5327
5327
  const AnyPositionManagerAddress = {
5328
- [base.id]: "0x69a96de474521f7c6c0be3ea0498e5cf2f0565dc",
5329
- [baseSepolia.id]: "0xe999c5676b0e0f83292074441292f4b3b11d65dc",
5328
+ // TODO: update with actual address
5329
+ [base.id]: viem.zeroAddress,
5330
+ [baseSepolia.id]: "0xB4A535B9D35851972736495CC52FBfDaCF32e5dc",
5330
5331
  };
5331
5332
  const FeeEscrowAddress = {
5332
5333
  [base.id]: "0x72e6f7948b1B1A343B477F39aAbd2E35E6D27dde",
@@ -5334,7 +5335,7 @@ const FeeEscrowAddress = {
5334
5335
  };
5335
5336
  const ReferralEscrowAddress = {
5336
5337
  [base.id]: "0xBD39c7Be6D98BD1a3e4Ad482baF99d738947fE55",
5337
- [baseSepolia.id]: "0x0651cadC51b6a13CB3465C134A22154a2b633779",
5338
+ [baseSepolia.id]: "0xd3d9047CaBE3346C70b510435866565176e8CE12",
5338
5339
  };
5339
5340
  const FLETHAddress = {
5340
5341
  [base.id]: "0x000000000D564D5be76f7f0d28fE52605afC7Cf8",
@@ -5362,6 +5363,11 @@ const FlaunchV1_1Address = {
5362
5363
  [base.id]: "0xb4512bf57d50fbcb64a3adf8b17a79b2a204c18c",
5363
5364
  [baseSepolia.id]: "0x96be8ff5e244294a34bfa507a39190dc7a839baa",
5364
5365
  };
5366
+ const AnyFlaunchAddress = {
5367
+ // FIXME: update with actual address
5368
+ [base.id]: viem.zeroAddress,
5369
+ [baseSepolia.id]: "0x67Ee6C83956a75f67bD3Fc8Ca4080D95a145c7C9",
5370
+ };
5365
5371
  const BidWallAddress = {
5366
5372
  [base.id]: "0x66681f10BA90496241A25e33380004f30Dfd8aa8",
5367
5373
  [baseSepolia.id]: "0xa2107050ACEf4809c88Ab744F8e667605db5ACDB",
@@ -5371,6 +5377,11 @@ const BidWallV1_1Address = {
5371
5377
  [base.id]: "0x7f22353d1634223a802D1c1Ea5308Ddf5DD0ef9c",
5372
5378
  [baseSepolia.id]: "0x6f2fa01a05ff8b6efbfefd91a3b85aaf19265a00",
5373
5379
  };
5380
+ const AnyBidWallAddress = {
5381
+ // FIXME: update with actual address
5382
+ [base.id]: viem.zeroAddress,
5383
+ [baseSepolia.id]: "0xcfF222eA42E43F46A98755db237E4c9C2CA9B772",
5384
+ };
5374
5385
  const FastFlaunchZapAddress = {
5375
5386
  [base.id]: "0x68d967d25806fef4aa134db031cdcc55d3e20f92",
5376
5387
  [baseSepolia.id]: "0x821d9f6075e7971cc71c379081de9d532f5f9957",
@@ -5383,6 +5394,10 @@ const RevenueManagerAddress = {
5383
5394
  [base.id]: "0x712fa8ddc7347b4b6b029aa21710f365cd02d898",
5384
5395
  [baseSepolia.id]: "0x17E02501dE3e420347e7C5fCAe3AD787C5aea690",
5385
5396
  };
5397
+ const AddressFeeSplitManagerAddress = {
5398
+ [base.id]: "0x6baa4ec493a9698dc7388c0f290e29ea3d149f99",
5399
+ [baseSepolia.id]: "0xf72dcdee692c188de6b14c6213e849982e04069b",
5400
+ };
5386
5401
  const TreasuryManagerFactoryAddress = {
5387
5402
  [base.id]: "0x48af8b28DDC5e5A86c4906212fc35Fa808CA8763",
5388
5403
  [baseSepolia.id]: "0xd2f3c6185e06925dcbe794c6574315b2202e9ccd",
@@ -7683,6 +7698,72 @@ const getPermit2TypedData = ({ chainId, coinAddress, nonce, deadline, }) => {
7683
7698
  };
7684
7699
  };
7685
7700
 
7701
+ /**
7702
+ * Parses raw swap log arguments into structured swap data
7703
+ * @param args - The swap log arguments
7704
+ * @param flETHIsCurrencyZero - Whether flETH is currency 0 in the pool
7705
+ * @returns Parsed swap data with type and delta information
7706
+ */
7707
+ function parseSwapData(args, flETHIsCurrencyZero) {
7708
+ const { flAmount0, flAmount1, flFee0, flFee1, ispAmount0, ispAmount1, ispFee0, ispFee1, uniAmount0, uniAmount1, uniFee0, uniFee1, } = args;
7709
+ const currency0Delta = flAmount0 + ispAmount0 + uniAmount0;
7710
+ const currency1Delta = flAmount1 + ispAmount1 + uniAmount1;
7711
+ const currency0Fees = flFee0 + ispFee0 + uniFee0;
7712
+ const currency1Fees = flFee1 + ispFee1 + uniFee1;
7713
+ let feesIsInFLETH;
7714
+ let swapType;
7715
+ if (flETHIsCurrencyZero) {
7716
+ swapType = currency0Delta < 0 ? "BUY" : "SELL";
7717
+ feesIsInFLETH = currency0Fees < 0;
7718
+ }
7719
+ else {
7720
+ swapType = currency1Delta < 0 ? "BUY" : "SELL";
7721
+ feesIsInFLETH = currency1Fees < 0;
7722
+ }
7723
+ const absCurrency0Delta = currency0Delta < 0 ? -currency0Delta : currency0Delta;
7724
+ const absCurrency1Delta = currency1Delta < 0 ? -currency1Delta : currency1Delta;
7725
+ const absCurrency0Fees = currency0Fees < 0 ? -currency0Fees : currency0Fees;
7726
+ const absCurrency1Fees = currency1Fees < 0 ? -currency1Fees : currency1Fees;
7727
+ const fees = {
7728
+ isInFLETH: feesIsInFLETH,
7729
+ amount: flETHIsCurrencyZero
7730
+ ? feesIsInFLETH
7731
+ ? absCurrency0Fees
7732
+ : absCurrency1Fees
7733
+ : feesIsInFLETH
7734
+ ? absCurrency1Fees
7735
+ : absCurrency0Fees,
7736
+ };
7737
+ if (swapType === "BUY") {
7738
+ return {
7739
+ type: swapType,
7740
+ delta: {
7741
+ coinsBought: flETHIsCurrencyZero
7742
+ ? absCurrency1Delta - (!fees.isInFLETH ? fees.amount : 0n)
7743
+ : absCurrency0Delta - (!fees.isInFLETH ? fees.amount : 0n),
7744
+ flETHSold: flETHIsCurrencyZero
7745
+ ? absCurrency0Delta - (fees.isInFLETH ? fees.amount : 0n)
7746
+ : absCurrency1Delta - (fees.isInFLETH ? fees.amount : 0n),
7747
+ fees,
7748
+ },
7749
+ };
7750
+ }
7751
+ else {
7752
+ return {
7753
+ type: swapType,
7754
+ delta: {
7755
+ coinsSold: flETHIsCurrencyZero
7756
+ ? absCurrency1Delta - (!fees.isInFLETH ? fees.amount : 0n)
7757
+ : absCurrency0Delta - (!fees.isInFLETH ? fees.amount : 0n),
7758
+ flETHBought: flETHIsCurrencyZero
7759
+ ? absCurrency0Delta - (fees.isInFLETH ? fees.amount : 0n)
7760
+ : absCurrency1Delta - (fees.isInFLETH ? fees.amount : 0n),
7761
+ fees,
7762
+ },
7763
+ };
7764
+ }
7765
+ }
7766
+
7686
7767
  const InitialPriceAbi = [
7687
7768
  {
7688
7769
  inputs: [
@@ -8084,6 +8165,53 @@ class ReadFlaunchPositionManager {
8084
8165
  pollPoolCreatedNow: pollEvents,
8085
8166
  };
8086
8167
  }
8168
+ /**
8169
+ * Parses a transaction hash to extract PoolSwap events and return parsed swap data
8170
+ * @param txHash - The transaction hash to parse
8171
+ * @param flETHIsCurrencyZero - Whether flETH is currency 0 in the pool (optional)
8172
+ * @returns Parsed swap log or undefined if no PoolSwap event found
8173
+ */
8174
+ async parseSwapTx(txHash, flETHIsCurrencyZero) {
8175
+ try {
8176
+ // Get transaction to get block number
8177
+ const tx = await this.drift.getTransaction({ hash: txHash });
8178
+ if (!tx) {
8179
+ return undefined;
8180
+ }
8181
+ // Get block to get timestamp
8182
+ const block = await this.drift.getBlock(tx.blockNumber);
8183
+ const timestamp = Number(block?.timestamp) * 1000; // convert to ms for js
8184
+ // Get PoolSwap events from the specific transaction
8185
+ const swapLogs = await this.contract.getEvents("PoolSwap", {
8186
+ fromBlock: tx.blockNumber,
8187
+ toBlock: tx.blockNumber,
8188
+ });
8189
+ // Find the first swap log that matches our transaction hash
8190
+ const targetLog = swapLogs.find((log) => log.transactionHash === txHash);
8191
+ if (!targetLog) {
8192
+ return undefined;
8193
+ }
8194
+ // If flETHIsCurrencyZero is not provided, return basic log
8195
+ if (flETHIsCurrencyZero === undefined) {
8196
+ return {
8197
+ ...targetLog,
8198
+ timestamp,
8199
+ };
8200
+ }
8201
+ // Parse the swap data using the utility function
8202
+ const swapData = parseSwapData(targetLog.args, flETHIsCurrencyZero);
8203
+ return {
8204
+ ...targetLog,
8205
+ timestamp,
8206
+ type: swapData.type,
8207
+ delta: swapData.delta,
8208
+ };
8209
+ }
8210
+ catch (error) {
8211
+ console.error("Error parsing swap transaction:", error);
8212
+ return undefined;
8213
+ }
8214
+ }
8087
8215
  async watchPoolSwap({ onPoolSwap, flETHIsCurrencyZero, startBlockNumber, filterByPoolId, }) {
8088
8216
  let intervalId;
8089
8217
  if (startBlockNumber !== undefined) {
@@ -8116,69 +8244,14 @@ class ReadFlaunchPositionManager {
8116
8244
  timestamp,
8117
8245
  };
8118
8246
  }
8119
- const { flAmount0, flAmount1, flFee0, flFee1, ispAmount0, ispAmount1, ispFee0, ispFee1, uniAmount0, uniAmount1, uniFee0, uniFee1, } = log.args;
8120
- const currency0Delta = flAmount0 + ispAmount0 + uniAmount0;
8121
- const currency1Delta = flAmount1 + ispAmount1 + uniAmount1;
8122
- const currency0Fees = flFee0 + ispFee0 + uniFee0;
8123
- const currency1Fees = flFee1 + ispFee1 + uniFee1;
8124
- let feesIsInFLETH;
8125
- let swapType;
8126
- if (flETHIsCurrencyZero) {
8127
- swapType = currency0Delta < 0 ? "BUY" : "SELL";
8128
- feesIsInFLETH = currency0Fees < 0;
8129
- }
8130
- else {
8131
- swapType = currency1Delta < 0 ? "BUY" : "SELL";
8132
- feesIsInFLETH = currency1Fees < 0;
8133
- }
8134
- const absCurrency0Delta = currency0Delta < 0 ? -currency0Delta : currency0Delta;
8135
- const absCurrency1Delta = currency1Delta < 0 ? -currency1Delta : currency1Delta;
8136
- const absCurrency0Fees = currency0Fees < 0 ? -currency0Fees : currency0Fees;
8137
- const absCurrency1Fees = currency1Fees < 0 ? -currency1Fees : currency1Fees;
8138
- const fees = {
8139
- isInFLETH: feesIsInFLETH,
8140
- amount: flETHIsCurrencyZero
8141
- ? feesIsInFLETH
8142
- ? absCurrency0Fees
8143
- : absCurrency1Fees
8144
- : feesIsInFLETH
8145
- ? absCurrency1Fees
8146
- : absCurrency0Fees,
8247
+ // parse swap data
8248
+ const swapData = parseSwapData(log.args, flETHIsCurrencyZero);
8249
+ return {
8250
+ ...log,
8251
+ timestamp,
8252
+ type: swapData.type,
8253
+ delta: swapData.delta,
8147
8254
  };
8148
- if (swapType === "BUY") {
8149
- return {
8150
- ...log,
8151
- timestamp,
8152
- type: swapType,
8153
- delta: {
8154
- coinsBought: flETHIsCurrencyZero
8155
- ? absCurrency1Delta - (!fees.isInFLETH ? fees.amount : 0n)
8156
- : absCurrency0Delta -
8157
- (!fees.isInFLETH ? fees.amount : 0n),
8158
- flETHSold: flETHIsCurrencyZero
8159
- ? absCurrency0Delta - (fees.isInFLETH ? fees.amount : 0n)
8160
- : absCurrency1Delta - (fees.isInFLETH ? fees.amount : 0n),
8161
- fees,
8162
- },
8163
- };
8164
- }
8165
- else {
8166
- return {
8167
- ...log,
8168
- timestamp,
8169
- type: swapType,
8170
- delta: {
8171
- coinsSold: flETHIsCurrencyZero
8172
- ? absCurrency1Delta - (!fees.isInFLETH ? fees.amount : 0n)
8173
- : absCurrency0Delta -
8174
- (!fees.isInFLETH ? fees.amount : 0n),
8175
- flETHBought: flETHIsCurrencyZero
8176
- ? absCurrency0Delta - (fees.isInFLETH ? fees.amount : 0n)
8177
- : absCurrency1Delta - (fees.isInFLETH ? fees.amount : 0n),
8178
- fees,
8179
- },
8180
- };
8181
- }
8182
8255
  }));
8183
8256
  if (logsWithTimestamps.length > 0) {
8184
8257
  onPoolSwap({
@@ -9981,7 +10054,595 @@ const BidwallAbi = [
9981
10054
  inputs: [],
9982
10055
  name: "positionManager",
9983
10056
  outputs: [
9984
- { internalType: "contract PositionManager", name: "", type: "address" },
10057
+ { internalType: "contract PositionManager", name: "", type: "address" },
10058
+ ],
10059
+ stateMutability: "view",
10060
+ type: "function",
10061
+ },
10062
+ {
10063
+ inputs: [],
10064
+ name: "renounceOwnership",
10065
+ outputs: [],
10066
+ stateMutability: "payable",
10067
+ type: "function",
10068
+ },
10069
+ {
10070
+ inputs: [],
10071
+ name: "requestOwnershipHandover",
10072
+ outputs: [],
10073
+ stateMutability: "payable",
10074
+ type: "function",
10075
+ },
10076
+ {
10077
+ inputs: [
10078
+ {
10079
+ components: [
10080
+ { internalType: "Currency", name: "currency0", type: "address" },
10081
+ { internalType: "Currency", name: "currency1", type: "address" },
10082
+ { internalType: "uint24", name: "fee", type: "uint24" },
10083
+ { internalType: "int24", name: "tickSpacing", type: "int24" },
10084
+ { internalType: "contract IHooks", name: "hooks", type: "address" },
10085
+ ],
10086
+ internalType: "struct PoolKey",
10087
+ name: "_key",
10088
+ type: "tuple",
10089
+ },
10090
+ { internalType: "bool", name: "_disable", type: "bool" },
10091
+ ],
10092
+ name: "setDisabledState",
10093
+ outputs: [],
10094
+ stateMutability: "nonpayable",
10095
+ type: "function",
10096
+ },
10097
+ {
10098
+ inputs: [
10099
+ { internalType: "uint256", name: "swapFeeThreshold", type: "uint256" },
10100
+ ],
10101
+ name: "setSwapFeeThreshold",
10102
+ outputs: [],
10103
+ stateMutability: "nonpayable",
10104
+ type: "function",
10105
+ },
10106
+ {
10107
+ inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
10108
+ name: "transferOwnership",
10109
+ outputs: [],
10110
+ stateMutability: "payable",
10111
+ type: "function",
10112
+ },
10113
+ ];
10114
+
10115
+ /**
10116
+ * Client for interacting with the BidWall V1 contract in read-only mode
10117
+ * Provides methods to query bid wall positions and pool information
10118
+ */
10119
+ class ReadBidWall {
10120
+ /**
10121
+ * Creates a new ReadBidWall instance
10122
+ * @param address - The address of the BidWall contract
10123
+ * @param drift - Optional drift instance for contract interactions (creates new instance if not provided)
10124
+ * @throws Error if address is not provided
10125
+ */
10126
+ constructor(address, drift$1 = drift.createDrift()) {
10127
+ if (!address) {
10128
+ throw new Error("Address is required");
10129
+ }
10130
+ this.contract = drift$1.contract({
10131
+ abi: BidwallAbi,
10132
+ address,
10133
+ });
10134
+ }
10135
+ /**
10136
+ * Gets information about a bid wall position for a specific pool
10137
+ * @param poolId - The ID of the pool
10138
+ * @returns Promise<{amount0_: bigint, amount1_: bigint, pendingEth_: bigint}> - Position details including token amounts and pending ETH
10139
+ */
10140
+ position({ poolId }) {
10141
+ return this.contract.read("position", {
10142
+ _poolId: poolId,
10143
+ });
10144
+ }
10145
+ /**
10146
+ * Gets configuration information about a pool's bid wall
10147
+ * @param poolId - The ID of the pool
10148
+ * @returns Promise<{tickLower: number, tickUpper: number}> - Pool configuration including tick range
10149
+ */
10150
+ poolInfo({ poolId }) {
10151
+ return this.contract.read("poolInfo", {
10152
+ _poolId: poolId,
10153
+ });
10154
+ }
10155
+ }
10156
+
10157
+ const AnyBidWallAbi = [
10158
+ {
10159
+ inputs: [
10160
+ { internalType: "address", name: "_nativeToken", type: "address" },
10161
+ { internalType: "address", name: "_poolManager", type: "address" },
10162
+ { internalType: "address", name: "_protocolOwner", type: "address" },
10163
+ ],
10164
+ stateMutability: "nonpayable",
10165
+ type: "constructor",
10166
+ },
10167
+ { inputs: [], name: "AccessControlBadConfirmation", type: "error" },
10168
+ {
10169
+ inputs: [
10170
+ { internalType: "address", name: "account", type: "address" },
10171
+ { internalType: "bytes32", name: "neededRole", type: "bytes32" },
10172
+ ],
10173
+ name: "AccessControlUnauthorizedAccount",
10174
+ type: "error",
10175
+ },
10176
+ { inputs: [], name: "AlreadyInitialized", type: "error" },
10177
+ { inputs: [], name: "CallerIsNotCreator", type: "error" },
10178
+ { inputs: [], name: "NewOwnerIsZeroAddress", type: "error" },
10179
+ { inputs: [], name: "NoHandoverRequest", type: "error" },
10180
+ { inputs: [], name: "NotPositionManager", type: "error" },
10181
+ { inputs: [], name: "Unauthorized", type: "error" },
10182
+ {
10183
+ anonymous: false,
10184
+ inputs: [
10185
+ {
10186
+ indexed: true,
10187
+ internalType: "PoolId",
10188
+ name: "_poolId",
10189
+ type: "bytes32",
10190
+ },
10191
+ {
10192
+ indexed: false,
10193
+ internalType: "address",
10194
+ name: "_recipient",
10195
+ type: "address",
10196
+ },
10197
+ {
10198
+ indexed: false,
10199
+ internalType: "uint256",
10200
+ name: "_eth",
10201
+ type: "uint256",
10202
+ },
10203
+ ],
10204
+ name: "BidWallClosed",
10205
+ type: "event",
10206
+ },
10207
+ {
10208
+ anonymous: false,
10209
+ inputs: [
10210
+ {
10211
+ indexed: true,
10212
+ internalType: "PoolId",
10213
+ name: "_poolId",
10214
+ type: "bytes32",
10215
+ },
10216
+ {
10217
+ indexed: false,
10218
+ internalType: "uint256",
10219
+ name: "_added",
10220
+ type: "uint256",
10221
+ },
10222
+ {
10223
+ indexed: false,
10224
+ internalType: "uint256",
10225
+ name: "_pending",
10226
+ type: "uint256",
10227
+ },
10228
+ ],
10229
+ name: "BidWallDeposit",
10230
+ type: "event",
10231
+ },
10232
+ {
10233
+ anonymous: false,
10234
+ inputs: [
10235
+ {
10236
+ indexed: true,
10237
+ internalType: "PoolId",
10238
+ name: "_poolId",
10239
+ type: "bytes32",
10240
+ },
10241
+ { indexed: false, internalType: "bool", name: "_disabled", type: "bool" },
10242
+ ],
10243
+ name: "BidWallDisabledStateUpdated",
10244
+ type: "event",
10245
+ },
10246
+ {
10247
+ anonymous: false,
10248
+ inputs: [
10249
+ {
10250
+ indexed: true,
10251
+ internalType: "PoolId",
10252
+ name: "_poolId",
10253
+ type: "bytes32",
10254
+ },
10255
+ {
10256
+ indexed: false,
10257
+ internalType: "uint256",
10258
+ name: "_eth",
10259
+ type: "uint256",
10260
+ },
10261
+ {
10262
+ indexed: false,
10263
+ internalType: "int24",
10264
+ name: "_tickLower",
10265
+ type: "int24",
10266
+ },
10267
+ {
10268
+ indexed: false,
10269
+ internalType: "int24",
10270
+ name: "_tickUpper",
10271
+ type: "int24",
10272
+ },
10273
+ ],
10274
+ name: "BidWallInitialized",
10275
+ type: "event",
10276
+ },
10277
+ {
10278
+ anonymous: false,
10279
+ inputs: [
10280
+ {
10281
+ indexed: true,
10282
+ internalType: "PoolId",
10283
+ name: "_poolId",
10284
+ type: "bytes32",
10285
+ },
10286
+ {
10287
+ indexed: false,
10288
+ internalType: "uint256",
10289
+ name: "_eth",
10290
+ type: "uint256",
10291
+ },
10292
+ {
10293
+ indexed: false,
10294
+ internalType: "int24",
10295
+ name: "_tickLower",
10296
+ type: "int24",
10297
+ },
10298
+ {
10299
+ indexed: false,
10300
+ internalType: "int24",
10301
+ name: "_tickUpper",
10302
+ type: "int24",
10303
+ },
10304
+ ],
10305
+ name: "BidWallRepositioned",
10306
+ type: "event",
10307
+ },
10308
+ {
10309
+ anonymous: false,
10310
+ inputs: [
10311
+ {
10312
+ indexed: true,
10313
+ internalType: "PoolId",
10314
+ name: "_poolId",
10315
+ type: "bytes32",
10316
+ },
10317
+ {
10318
+ indexed: false,
10319
+ internalType: "address",
10320
+ name: "_recipient",
10321
+ type: "address",
10322
+ },
10323
+ {
10324
+ indexed: false,
10325
+ internalType: "uint256",
10326
+ name: "_tokens",
10327
+ type: "uint256",
10328
+ },
10329
+ ],
10330
+ name: "BidWallRewardsTransferred",
10331
+ type: "event",
10332
+ },
10333
+ {
10334
+ anonymous: false,
10335
+ inputs: [
10336
+ {
10337
+ indexed: false,
10338
+ internalType: "uint256",
10339
+ name: "_newSwapFeeThreshold",
10340
+ type: "uint256",
10341
+ },
10342
+ ],
10343
+ name: "FixedSwapFeeThresholdUpdated",
10344
+ type: "event",
10345
+ },
10346
+ {
10347
+ anonymous: false,
10348
+ inputs: [
10349
+ {
10350
+ indexed: true,
10351
+ internalType: "address",
10352
+ name: "pendingOwner",
10353
+ type: "address",
10354
+ },
10355
+ ],
10356
+ name: "OwnershipHandoverCanceled",
10357
+ type: "event",
10358
+ },
10359
+ {
10360
+ anonymous: false,
10361
+ inputs: [
10362
+ {
10363
+ indexed: true,
10364
+ internalType: "address",
10365
+ name: "pendingOwner",
10366
+ type: "address",
10367
+ },
10368
+ ],
10369
+ name: "OwnershipHandoverRequested",
10370
+ type: "event",
10371
+ },
10372
+ {
10373
+ anonymous: false,
10374
+ inputs: [
10375
+ {
10376
+ indexed: true,
10377
+ internalType: "address",
10378
+ name: "oldOwner",
10379
+ type: "address",
10380
+ },
10381
+ {
10382
+ indexed: true,
10383
+ internalType: "address",
10384
+ name: "newOwner",
10385
+ type: "address",
10386
+ },
10387
+ ],
10388
+ name: "OwnershipTransferred",
10389
+ type: "event",
10390
+ },
10391
+ {
10392
+ anonymous: false,
10393
+ inputs: [
10394
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
10395
+ {
10396
+ indexed: true,
10397
+ internalType: "bytes32",
10398
+ name: "previousAdminRole",
10399
+ type: "bytes32",
10400
+ },
10401
+ {
10402
+ indexed: true,
10403
+ internalType: "bytes32",
10404
+ name: "newAdminRole",
10405
+ type: "bytes32",
10406
+ },
10407
+ ],
10408
+ name: "RoleAdminChanged",
10409
+ type: "event",
10410
+ },
10411
+ {
10412
+ anonymous: false,
10413
+ inputs: [
10414
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
10415
+ {
10416
+ indexed: true,
10417
+ internalType: "address",
10418
+ name: "account",
10419
+ type: "address",
10420
+ },
10421
+ {
10422
+ indexed: true,
10423
+ internalType: "address",
10424
+ name: "sender",
10425
+ type: "address",
10426
+ },
10427
+ ],
10428
+ name: "RoleGranted",
10429
+ type: "event",
10430
+ },
10431
+ {
10432
+ anonymous: false,
10433
+ inputs: [
10434
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
10435
+ {
10436
+ indexed: true,
10437
+ internalType: "address",
10438
+ name: "account",
10439
+ type: "address",
10440
+ },
10441
+ {
10442
+ indexed: true,
10443
+ internalType: "address",
10444
+ name: "sender",
10445
+ type: "address",
10446
+ },
10447
+ ],
10448
+ name: "RoleRevoked",
10449
+ type: "event",
10450
+ },
10451
+ {
10452
+ anonymous: false,
10453
+ inputs: [
10454
+ {
10455
+ indexed: false,
10456
+ internalType: "uint256",
10457
+ name: "_staleTimeWindow",
10458
+ type: "uint256",
10459
+ },
10460
+ ],
10461
+ name: "StaleTimeWindowUpdated",
10462
+ type: "event",
10463
+ },
10464
+ {
10465
+ inputs: [],
10466
+ name: "DEFAULT_ADMIN_ROLE",
10467
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
10468
+ stateMutability: "view",
10469
+ type: "function",
10470
+ },
10471
+ {
10472
+ inputs: [],
10473
+ name: "cancelOwnershipHandover",
10474
+ outputs: [],
10475
+ stateMutability: "payable",
10476
+ type: "function",
10477
+ },
10478
+ {
10479
+ inputs: [
10480
+ {
10481
+ components: [
10482
+ { internalType: "Currency", name: "currency0", type: "address" },
10483
+ { internalType: "Currency", name: "currency1", type: "address" },
10484
+ { internalType: "uint24", name: "fee", type: "uint24" },
10485
+ { internalType: "int24", name: "tickSpacing", type: "int24" },
10486
+ { internalType: "contract IHooks", name: "hooks", type: "address" },
10487
+ ],
10488
+ internalType: "struct PoolKey",
10489
+ name: "_poolKey",
10490
+ type: "tuple",
10491
+ },
10492
+ { internalType: "int24", name: "_currentTick", type: "int24" },
10493
+ { internalType: "bool", name: "_nativeIsZero", type: "bool" },
10494
+ ],
10495
+ name: "checkStalePosition",
10496
+ outputs: [],
10497
+ stateMutability: "nonpayable",
10498
+ type: "function",
10499
+ },
10500
+ {
10501
+ inputs: [
10502
+ {
10503
+ components: [
10504
+ { internalType: "Currency", name: "currency0", type: "address" },
10505
+ { internalType: "Currency", name: "currency1", type: "address" },
10506
+ { internalType: "uint24", name: "fee", type: "uint24" },
10507
+ { internalType: "int24", name: "tickSpacing", type: "int24" },
10508
+ { internalType: "contract IHooks", name: "hooks", type: "address" },
10509
+ ],
10510
+ internalType: "struct PoolKey",
10511
+ name: "_key",
10512
+ type: "tuple",
10513
+ },
10514
+ ],
10515
+ name: "closeBidWall",
10516
+ outputs: [],
10517
+ stateMutability: "nonpayable",
10518
+ type: "function",
10519
+ },
10520
+ {
10521
+ inputs: [
10522
+ { internalType: "address", name: "pendingOwner", type: "address" },
10523
+ ],
10524
+ name: "completeOwnershipHandover",
10525
+ outputs: [],
10526
+ stateMutability: "payable",
10527
+ type: "function",
10528
+ },
10529
+ {
10530
+ inputs: [
10531
+ {
10532
+ components: [
10533
+ { internalType: "Currency", name: "currency0", type: "address" },
10534
+ { internalType: "Currency", name: "currency1", type: "address" },
10535
+ { internalType: "uint24", name: "fee", type: "uint24" },
10536
+ { internalType: "int24", name: "tickSpacing", type: "int24" },
10537
+ { internalType: "contract IHooks", name: "hooks", type: "address" },
10538
+ ],
10539
+ internalType: "struct PoolKey",
10540
+ name: "_poolKey",
10541
+ type: "tuple",
10542
+ },
10543
+ { internalType: "uint256", name: "_ethSwapAmount", type: "uint256" },
10544
+ { internalType: "int24", name: "_currentTick", type: "int24" },
10545
+ { internalType: "bool", name: "_nativeIsZero", type: "bool" },
10546
+ ],
10547
+ name: "deposit",
10548
+ outputs: [],
10549
+ stateMutability: "nonpayable",
10550
+ type: "function",
10551
+ },
10552
+ {
10553
+ inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
10554
+ name: "getRoleAdmin",
10555
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
10556
+ stateMutability: "view",
10557
+ type: "function",
10558
+ },
10559
+ {
10560
+ inputs: [
10561
+ { internalType: "bytes32", name: "role", type: "bytes32" },
10562
+ { internalType: "address", name: "account", type: "address" },
10563
+ ],
10564
+ name: "grantRole",
10565
+ outputs: [],
10566
+ stateMutability: "nonpayable",
10567
+ type: "function",
10568
+ },
10569
+ {
10570
+ inputs: [
10571
+ { internalType: "bytes32", name: "role", type: "bytes32" },
10572
+ { internalType: "address", name: "account", type: "address" },
10573
+ ],
10574
+ name: "hasRole",
10575
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
10576
+ stateMutability: "view",
10577
+ type: "function",
10578
+ },
10579
+ {
10580
+ inputs: [{ internalType: "PoolId", name: "_poolId", type: "bytes32" }],
10581
+ name: "isBidWallEnabled",
10582
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
10583
+ stateMutability: "view",
10584
+ type: "function",
10585
+ },
10586
+ {
10587
+ inputs: [{ internalType: "PoolId", name: "_poolId", type: "bytes32" }],
10588
+ name: "lastPoolTransaction",
10589
+ outputs: [{ internalType: "uint256", name: "_timestamp", type: "uint256" }],
10590
+ stateMutability: "view",
10591
+ type: "function",
10592
+ },
10593
+ {
10594
+ inputs: [],
10595
+ name: "nativeToken",
10596
+ outputs: [{ internalType: "address", name: "", type: "address" }],
10597
+ stateMutability: "view",
10598
+ type: "function",
10599
+ },
10600
+ {
10601
+ inputs: [],
10602
+ name: "owner",
10603
+ outputs: [{ internalType: "address", name: "result", type: "address" }],
10604
+ stateMutability: "view",
10605
+ type: "function",
10606
+ },
10607
+ {
10608
+ inputs: [
10609
+ { internalType: "address", name: "pendingOwner", type: "address" },
10610
+ ],
10611
+ name: "ownershipHandoverExpiresAt",
10612
+ outputs: [{ internalType: "uint256", name: "result", type: "uint256" }],
10613
+ stateMutability: "view",
10614
+ type: "function",
10615
+ },
10616
+ {
10617
+ inputs: [{ internalType: "PoolId", name: "_poolId", type: "bytes32" }],
10618
+ name: "poolInfo",
10619
+ outputs: [
10620
+ { internalType: "bool", name: "disabled", type: "bool" },
10621
+ { internalType: "bool", name: "initialized", type: "bool" },
10622
+ { internalType: "int24", name: "tickLower", type: "int24" },
10623
+ { internalType: "int24", name: "tickUpper", type: "int24" },
10624
+ { internalType: "uint256", name: "pendingETHFees", type: "uint256" },
10625
+ { internalType: "uint256", name: "cumulativeSwapFees", type: "uint256" },
10626
+ ],
10627
+ stateMutability: "view",
10628
+ type: "function",
10629
+ },
10630
+ {
10631
+ inputs: [],
10632
+ name: "poolManager",
10633
+ outputs: [
10634
+ { internalType: "contract IPoolManager", name: "", type: "address" },
10635
+ ],
10636
+ stateMutability: "view",
10637
+ type: "function",
10638
+ },
10639
+ {
10640
+ inputs: [{ internalType: "PoolId", name: "_poolId", type: "bytes32" }],
10641
+ name: "position",
10642
+ outputs: [
10643
+ { internalType: "uint256", name: "amount0_", type: "uint256" },
10644
+ { internalType: "uint256", name: "amount1_", type: "uint256" },
10645
+ { internalType: "uint256", name: "pendingEth_", type: "uint256" },
9985
10646
  ],
9986
10647
  stateMutability: "view",
9987
10648
  type: "function",
@@ -9993,6 +10654,16 @@ const BidwallAbi = [
9993
10654
  stateMutability: "payable",
9994
10655
  type: "function",
9995
10656
  },
10657
+ {
10658
+ inputs: [
10659
+ { internalType: "bytes32", name: "role", type: "bytes32" },
10660
+ { internalType: "address", name: "callerConfirmation", type: "address" },
10661
+ ],
10662
+ name: "renounceRole",
10663
+ outputs: [],
10664
+ stateMutability: "nonpayable",
10665
+ type: "function",
10666
+ },
9996
10667
  {
9997
10668
  inputs: [],
9998
10669
  name: "requestOwnershipHandover",
@@ -10000,6 +10671,16 @@ const BidwallAbi = [
10000
10671
  stateMutability: "payable",
10001
10672
  type: "function",
10002
10673
  },
10674
+ {
10675
+ inputs: [
10676
+ { internalType: "bytes32", name: "role", type: "bytes32" },
10677
+ { internalType: "address", name: "account", type: "address" },
10678
+ ],
10679
+ name: "revokeRole",
10680
+ outputs: [],
10681
+ stateMutability: "nonpayable",
10682
+ type: "function",
10683
+ },
10003
10684
  {
10004
10685
  inputs: [
10005
10686
  {
@@ -10021,6 +10702,15 @@ const BidwallAbi = [
10021
10702
  stateMutability: "nonpayable",
10022
10703
  type: "function",
10023
10704
  },
10705
+ {
10706
+ inputs: [
10707
+ { internalType: "uint256", name: "_staleTimeWindow", type: "uint256" },
10708
+ ],
10709
+ name: "setStaleTimeWindow",
10710
+ outputs: [],
10711
+ stateMutability: "nonpayable",
10712
+ type: "function",
10713
+ },
10024
10714
  {
10025
10715
  inputs: [
10026
10716
  { internalType: "uint256", name: "swapFeeThreshold", type: "uint256" },
@@ -10030,6 +10720,20 @@ const BidwallAbi = [
10030
10720
  stateMutability: "nonpayable",
10031
10721
  type: "function",
10032
10722
  },
10723
+ {
10724
+ inputs: [],
10725
+ name: "staleTimeWindow",
10726
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
10727
+ stateMutability: "view",
10728
+ type: "function",
10729
+ },
10730
+ {
10731
+ inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
10732
+ name: "supportsInterface",
10733
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
10734
+ stateMutability: "view",
10735
+ type: "function",
10736
+ },
10033
10737
  {
10034
10738
  inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
10035
10739
  name: "transferOwnership",
@@ -10040,13 +10744,14 @@ const BidwallAbi = [
10040
10744
  ];
10041
10745
 
10042
10746
  /**
10043
- * Client for interacting with the BidWall V1 contract in read-only mode
10747
+ * Client for interacting with the AnyBidWall contract in read-only mode
10044
10748
  * Provides methods to query bid wall positions and pool information
10749
+ * Enhanced version of the V1 contract with additional features
10045
10750
  */
10046
- class ReadBidWall {
10751
+ class AnyBidWall {
10047
10752
  /**
10048
- * Creates a new ReadBidWall instance
10049
- * @param address - The address of the BidWall contract
10753
+ * Creates a new ReadBidWallV1_1 instance
10754
+ * @param address - The address of the BidWall V1.1 contract
10050
10755
  * @param drift - Optional drift instance for contract interactions (creates new instance if not provided)
10051
10756
  * @throws Error if address is not provided
10052
10757
  */
@@ -10055,7 +10760,7 @@ class ReadBidWall {
10055
10760
  throw new Error("Address is required");
10056
10761
  }
10057
10762
  this.contract = drift$1.contract({
10058
- abi: BidwallAbi,
10763
+ abi: AnyBidWallAbi,
10059
10764
  address,
10060
10765
  });
10061
10766
  }
@@ -11958,6 +12663,53 @@ class ReadFlaunchPositionManagerV1_1 {
11958
12663
  pollPoolCreatedNow: pollEvents,
11959
12664
  };
11960
12665
  }
12666
+ /**
12667
+ * Parses a transaction hash to extract PoolSwap events and return parsed swap data
12668
+ * @param txHash - The transaction hash to parse
12669
+ * @param flETHIsCurrencyZero - Whether flETH is currency 0 in the pool (optional)
12670
+ * @returns Parsed swap log or undefined if no PoolSwap event found
12671
+ */
12672
+ async parseSwapTx(txHash, flETHIsCurrencyZero) {
12673
+ try {
12674
+ // Get transaction to get block number
12675
+ const tx = await this.drift.getTransaction({ hash: txHash });
12676
+ if (!tx) {
12677
+ return undefined;
12678
+ }
12679
+ // Get block to get timestamp
12680
+ const block = await this.drift.getBlock(tx.blockNumber);
12681
+ const timestamp = Number(block?.timestamp) * 1000; // convert to ms for js
12682
+ // Get PoolSwap events from the specific transaction
12683
+ const swapLogs = await this.contract.getEvents("PoolSwap", {
12684
+ fromBlock: tx.blockNumber,
12685
+ toBlock: tx.blockNumber,
12686
+ });
12687
+ // Find the first swap log that matches our transaction hash
12688
+ const targetLog = swapLogs.find((log) => log.transactionHash === txHash);
12689
+ if (!targetLog) {
12690
+ return undefined;
12691
+ }
12692
+ // If flETHIsCurrencyZero is not provided, return basic log
12693
+ if (flETHIsCurrencyZero === undefined) {
12694
+ return {
12695
+ ...targetLog,
12696
+ timestamp,
12697
+ };
12698
+ }
12699
+ // Parse the swap data using the utility function
12700
+ const swapData = parseSwapData(targetLog.args, flETHIsCurrencyZero);
12701
+ return {
12702
+ ...targetLog,
12703
+ timestamp,
12704
+ type: swapData.type,
12705
+ delta: swapData.delta,
12706
+ };
12707
+ }
12708
+ catch (error) {
12709
+ console.error("Error parsing swap transaction:", error);
12710
+ return undefined;
12711
+ }
12712
+ }
11961
12713
  async watchPoolSwap({ onPoolSwap, flETHIsCurrencyZero, startBlockNumber, filterByPoolId, }) {
11962
12714
  let intervalId;
11963
12715
  if (startBlockNumber !== undefined) {
@@ -11990,69 +12742,14 @@ class ReadFlaunchPositionManagerV1_1 {
11990
12742
  timestamp,
11991
12743
  };
11992
12744
  }
11993
- const { flAmount0, flAmount1, flFee0, flFee1, ispAmount0, ispAmount1, ispFee0, ispFee1, uniAmount0, uniAmount1, uniFee0, uniFee1, } = log.args;
11994
- const currency0Delta = flAmount0 + ispAmount0 + uniAmount0;
11995
- const currency1Delta = flAmount1 + ispAmount1 + uniAmount1;
11996
- const currency0Fees = flFee0 + ispFee0 + uniFee0;
11997
- const currency1Fees = flFee1 + ispFee1 + uniFee1;
11998
- let feesIsInFLETH;
11999
- let swapType;
12000
- if (flETHIsCurrencyZero) {
12001
- swapType = currency0Delta < 0 ? "BUY" : "SELL";
12002
- feesIsInFLETH = currency0Fees < 0;
12003
- }
12004
- else {
12005
- swapType = currency1Delta < 0 ? "BUY" : "SELL";
12006
- feesIsInFLETH = currency1Fees < 0;
12007
- }
12008
- const absCurrency0Delta = currency0Delta < 0 ? -currency0Delta : currency0Delta;
12009
- const absCurrency1Delta = currency1Delta < 0 ? -currency1Delta : currency1Delta;
12010
- const absCurrency0Fees = currency0Fees < 0 ? -currency0Fees : currency0Fees;
12011
- const absCurrency1Fees = currency1Fees < 0 ? -currency1Fees : currency1Fees;
12012
- const fees = {
12013
- isInFLETH: feesIsInFLETH,
12014
- amount: flETHIsCurrencyZero
12015
- ? feesIsInFLETH
12016
- ? absCurrency0Fees
12017
- : absCurrency1Fees
12018
- : feesIsInFLETH
12019
- ? absCurrency1Fees
12020
- : absCurrency0Fees,
12745
+ // parse swap data
12746
+ const swapData = parseSwapData(log.args, flETHIsCurrencyZero);
12747
+ return {
12748
+ ...log,
12749
+ timestamp,
12750
+ type: swapData.type,
12751
+ delta: swapData.delta,
12021
12752
  };
12022
- if (swapType === "BUY") {
12023
- return {
12024
- ...log,
12025
- timestamp,
12026
- type: swapType,
12027
- delta: {
12028
- coinsBought: flETHIsCurrencyZero
12029
- ? absCurrency1Delta - (!fees.isInFLETH ? fees.amount : 0n)
12030
- : absCurrency0Delta -
12031
- (!fees.isInFLETH ? fees.amount : 0n),
12032
- flETHSold: flETHIsCurrencyZero
12033
- ? absCurrency0Delta - (fees.isInFLETH ? fees.amount : 0n)
12034
- : absCurrency1Delta - (fees.isInFLETH ? fees.amount : 0n),
12035
- fees,
12036
- },
12037
- };
12038
- }
12039
- else {
12040
- return {
12041
- ...log,
12042
- timestamp,
12043
- type: swapType,
12044
- delta: {
12045
- coinsSold: flETHIsCurrencyZero
12046
- ? absCurrency1Delta - (!fees.isInFLETH ? fees.amount : 0n)
12047
- : absCurrency0Delta -
12048
- (!fees.isInFLETH ? fees.amount : 0n),
12049
- flETHBought: flETHIsCurrencyZero
12050
- ? absCurrency0Delta - (fees.isInFLETH ? fees.amount : 0n)
12051
- : absCurrency1Delta - (fees.isInFLETH ? fees.amount : 0n),
12052
- fees,
12053
- },
12054
- };
12055
- }
12056
12753
  }));
12057
12754
  if (logsWithTimestamps.length > 0) {
12058
12755
  onPoolSwap({
@@ -12368,6 +13065,123 @@ class ReadWriteFlaunchZap extends ReadFlaunchZap {
12368
13065
  tokenUri,
12369
13066
  });
12370
13067
  }
13068
+ /**
13069
+ * Flaunches a new token that splits the creator fees to the creator and a list of recipients
13070
+ * @param params - Parameters for the flaunch with split manager
13071
+ * @param params.name - The name of the token
13072
+ * @param params.symbol - The symbol of the token
13073
+ * @param params.tokenUri - The URI containing the token metadata
13074
+ * @param params.fairLaunchPercent - Percentage of total supply to be used in fair launch (0-100)
13075
+ * @param params.fairLaunchDuration - Duration of fair launch in seconds
13076
+ * @param params.initialMarketCapUSD - Initial market cap in USD
13077
+ * @param params.creator - Address of the token creator
13078
+ * @param params.creatorFeeAllocationPercent - Percentage of fees allocated to creator (0-100)
13079
+ * @param params.creatorSplitPercent - Percentage of fees allocated to creator (0-100)
13080
+ * @param params.splitReceivers - List of recipients and their percentage of the fees
13081
+ * @param params.flaunchAt - Optional timestamp when the flaunch should start
13082
+ * @param params.premineAmount - Optional amount of tokens to premine
13083
+ * @param params.creatorSplitPercent - Split percentage of the fees for the creator (0-100)
13084
+ * @param params.splitReceivers - List of recipients and their percentage of the fees
13085
+ * @returns Transaction response for the flaunch creation
13086
+ */
13087
+ async flaunchWithSplitManager(params) {
13088
+ const initialMCapInUSDCWei = viem.parseUnits(params.initialMarketCapUSD.toString(), 6);
13089
+ const initialPriceParams = viem.encodeAbiParameters([
13090
+ {
13091
+ type: "uint256",
13092
+ },
13093
+ ], [initialMCapInUSDCWei]);
13094
+ const fairLaunchInBps = BigInt(params.fairLaunchPercent * 100);
13095
+ const creatorFeeAllocationInBps = params.creatorFeeAllocationPercent * 100;
13096
+ const ethRequired = await this.ethRequiredToFlaunch({
13097
+ premineAmount: params.premineAmount ?? 0n,
13098
+ initialPriceParams,
13099
+ slippagePercent: 5,
13100
+ });
13101
+ const VALID_SHARE_TOTAL = 10000000n; // 5 decimals as BigInt
13102
+ let creatorShare = (BigInt(params.creatorSplitPercent) * VALID_SHARE_TOTAL) / 100n;
13103
+ const recipientShares = params.splitReceivers.map((receiver) => {
13104
+ return {
13105
+ recipient: receiver.address,
13106
+ share: (BigInt(receiver.percent) * VALID_SHARE_TOTAL) / 100n,
13107
+ };
13108
+ });
13109
+ const totalRecipientShares = recipientShares.reduce((acc, curr) => acc + curr.share, 0n);
13110
+ // if there's a remainder (due to rounding errors), add it to the creator share
13111
+ const remainderShares = VALID_SHARE_TOTAL - totalRecipientShares;
13112
+ creatorShare += remainderShares;
13113
+ const initializeData = viem.encodeAbiParameters([
13114
+ {
13115
+ type: "tuple",
13116
+ name: "params",
13117
+ components: [
13118
+ { type: "uint256", name: "creatorShare" },
13119
+ {
13120
+ type: "tuple[]",
13121
+ name: "recipientShares",
13122
+ components: [
13123
+ { type: "address", name: "recipient" },
13124
+ { type: "uint256", name: "share" },
13125
+ ],
13126
+ },
13127
+ ],
13128
+ },
13129
+ ], [
13130
+ {
13131
+ creatorShare,
13132
+ recipientShares,
13133
+ },
13134
+ ]);
13135
+ return this.contract.write("flaunch", {
13136
+ _flaunchParams: {
13137
+ name: params.name,
13138
+ symbol: params.symbol,
13139
+ tokenUri: params.tokenUri,
13140
+ initialTokenFairLaunch: (this.TOTAL_SUPPLY * fairLaunchInBps) / 10000n,
13141
+ fairLaunchDuration: BigInt(params.fairLaunchDuration),
13142
+ premineAmount: params.premineAmount ?? 0n,
13143
+ creator: params.creator,
13144
+ creatorFeeAllocation: creatorFeeAllocationInBps,
13145
+ flaunchAt: params.flaunchAt ?? 0n,
13146
+ initialPriceParams,
13147
+ feeCalculatorParams: "0x",
13148
+ },
13149
+ _treasuryManagerParams: {
13150
+ manager: AddressFeeSplitManagerAddress[this.chainId],
13151
+ initializeData,
13152
+ depositData: "0x",
13153
+ },
13154
+ _whitelistParams: {
13155
+ merkleRoot: viem.zeroHash,
13156
+ merkleIPFSHash: "",
13157
+ maxTokens: 0n,
13158
+ },
13159
+ _airdropParams: {
13160
+ airdropIndex: 0n,
13161
+ airdropAmount: 0n,
13162
+ airdropEndTime: 0n,
13163
+ merkleRoot: viem.zeroHash,
13164
+ merkleIPFSHash: "",
13165
+ },
13166
+ }, {
13167
+ value: ethRequired,
13168
+ });
13169
+ }
13170
+ /**
13171
+ * Flaunches a new token that splits the creator fees to the creator and a list of recipients, storing the token metadata on IPFS
13172
+ * @param params - Parameters for the flaunch with split manager including all IPFS metadata
13173
+ * @returns Promise resolving to the transaction response for the flaunch creation
13174
+ */
13175
+ async flaunchIPFSWithSplitManager(params) {
13176
+ const tokenUri = await generateTokenUri(params.name, {
13177
+ metadata: params.metadata,
13178
+ pinataConfig: params.pinataConfig,
13179
+ });
13180
+ return this.flaunchWithSplitManager({
13181
+ ...params,
13182
+ tokenUri,
13183
+ });
13184
+ }
12371
13185
  }
12372
13186
 
12373
13187
  const FlaunchAbi = [
@@ -14682,8 +15496,8 @@ const AnyPositionManagerAbi = [
14682
15496
  },
14683
15497
  { inputs: [], name: "AlreadyFlaunched", type: "error" },
14684
15498
  { inputs: [], name: "AlreadyInitialized", type: "error" },
15499
+ { inputs: [], name: "CallerIsNotApprovedCreator", type: "error" },
14685
15500
  { inputs: [], name: "CallerIsNotBidWall", type: "error" },
14686
- { inputs: [], name: "CallerIsNotCreator", type: "error" },
14687
15501
  {
14688
15502
  inputs: [{ internalType: "address", name: "_caller", type: "address" }],
14689
15503
  name: "CallerNotCreator",
@@ -14707,6 +15521,25 @@ const AnyPositionManagerAbi = [
14707
15521
  name: "UnknownPool",
14708
15522
  type: "error",
14709
15523
  },
15524
+ {
15525
+ anonymous: false,
15526
+ inputs: [
15527
+ {
15528
+ indexed: false,
15529
+ internalType: "address",
15530
+ name: "_creator",
15531
+ type: "address",
15532
+ },
15533
+ {
15534
+ indexed: false,
15535
+ internalType: "bool",
15536
+ name: "_isApproved",
15537
+ type: "bool",
15538
+ },
15539
+ ],
15540
+ name: "CreatorApproved",
15541
+ type: "event",
15542
+ },
14710
15543
  {
14711
15544
  anonymous: false,
14712
15545
  inputs: [
@@ -14848,25 +15681,6 @@ const AnyPositionManagerAbi = [
14848
15681
  name: "InitialPriceUpdated",
14849
15682
  type: "event",
14850
15683
  },
14851
- {
14852
- anonymous: false,
14853
- inputs: [
14854
- {
14855
- indexed: false,
14856
- internalType: "address",
14857
- name: "_memecoin",
14858
- type: "address",
14859
- },
14860
- {
14861
- indexed: false,
14862
- internalType: "address",
14863
- name: "_creator",
14864
- type: "address",
14865
- },
14866
- ],
14867
- name: "MemecoinApproved",
14868
- type: "event",
14869
- },
14870
15684
  {
14871
15685
  anonymous: false,
14872
15686
  inputs: [
@@ -15449,18 +16263,18 @@ const AnyPositionManagerAbi = [
15449
16263
  },
15450
16264
  {
15451
16265
  inputs: [
15452
- { internalType: "address", name: "_memecoin", type: "address" },
15453
16266
  { internalType: "address", name: "_creator", type: "address" },
16267
+ { internalType: "bool", name: "_isApproved", type: "bool" },
15454
16268
  ],
15455
- name: "approveMemecoin",
16269
+ name: "approveCreator",
15456
16270
  outputs: [],
15457
16271
  stateMutability: "nonpayable",
15458
16272
  type: "function",
15459
16273
  },
15460
16274
  {
15461
- inputs: [{ internalType: "address", name: "_memecoin", type: "address" }],
15462
- name: "approvedMemecoinToCreator",
15463
- outputs: [{ internalType: "address", name: "_creator", type: "address" }],
16275
+ inputs: [{ internalType: "address", name: "_creator", type: "address" }],
16276
+ name: "approvedMemecoinCreator",
16277
+ outputs: [{ internalType: "bool", name: "isApproved", type: "bool" }],
15464
16278
  stateMutability: "view",
15465
16279
  type: "function",
15466
16280
  },
@@ -16149,6 +16963,53 @@ class ReadAnyPositionManager {
16149
16963
  pollPoolCreatedNow: pollEvents,
16150
16964
  };
16151
16965
  }
16966
+ /**
16967
+ * Parses a transaction hash to extract PoolSwap events and return parsed swap data
16968
+ * @param txHash - The transaction hash to parse
16969
+ * @param flETHIsCurrencyZero - Whether flETH is currency 0 in the pool (optional)
16970
+ * @returns Parsed swap log or undefined if no PoolSwap event found
16971
+ */
16972
+ async parseSwapTx(txHash, flETHIsCurrencyZero) {
16973
+ try {
16974
+ // Get transaction to get block number
16975
+ const tx = await this.drift.getTransaction({ hash: txHash });
16976
+ if (!tx) {
16977
+ return undefined;
16978
+ }
16979
+ // Get block to get timestamp
16980
+ const block = await this.drift.getBlock(tx.blockNumber);
16981
+ const timestamp = Number(block?.timestamp) * 1000; // convert to ms for js
16982
+ // Get PoolSwap events from the specific transaction
16983
+ const swapLogs = await this.contract.getEvents("PoolSwap", {
16984
+ fromBlock: tx.blockNumber,
16985
+ toBlock: tx.blockNumber,
16986
+ });
16987
+ // Find the first swap log that matches our transaction hash
16988
+ const targetLog = swapLogs.find((log) => log.transactionHash === txHash);
16989
+ if (!targetLog) {
16990
+ return undefined;
16991
+ }
16992
+ // If flETHIsCurrencyZero is not provided, return basic log
16993
+ if (flETHIsCurrencyZero === undefined) {
16994
+ return {
16995
+ ...targetLog,
16996
+ timestamp,
16997
+ };
16998
+ }
16999
+ // Parse the swap data using the utility function
17000
+ const swapData = parseSwapData(targetLog.args, flETHIsCurrencyZero);
17001
+ return {
17002
+ ...targetLog,
17003
+ timestamp,
17004
+ type: swapData.type,
17005
+ delta: swapData.delta,
17006
+ };
17007
+ }
17008
+ catch (error) {
17009
+ console.error("Error parsing swap transaction:", error);
17010
+ return undefined;
17011
+ }
17012
+ }
16152
17013
  async watchPoolSwap({ onPoolSwap, flETHIsCurrencyZero, startBlockNumber, filterByPoolId, }) {
16153
17014
  let intervalId;
16154
17015
  if (startBlockNumber !== undefined) {
@@ -16181,69 +17042,14 @@ class ReadAnyPositionManager {
16181
17042
  timestamp,
16182
17043
  };
16183
17044
  }
16184
- const { flAmount0, flAmount1, flFee0, flFee1, ispAmount0, ispAmount1, ispFee0, ispFee1, uniAmount0, uniAmount1, uniFee0, uniFee1, } = log.args;
16185
- const currency0Delta = flAmount0 + ispAmount0 + uniAmount0;
16186
- const currency1Delta = flAmount1 + ispAmount1 + uniAmount1;
16187
- const currency0Fees = flFee0 + ispFee0 + uniFee0;
16188
- const currency1Fees = flFee1 + ispFee1 + uniFee1;
16189
- let feesIsInFLETH;
16190
- let swapType;
16191
- if (flETHIsCurrencyZero) {
16192
- swapType = currency0Delta < 0 ? "BUY" : "SELL";
16193
- feesIsInFLETH = currency0Fees < 0;
16194
- }
16195
- else {
16196
- swapType = currency1Delta < 0 ? "BUY" : "SELL";
16197
- feesIsInFLETH = currency1Fees < 0;
16198
- }
16199
- const absCurrency0Delta = currency0Delta < 0 ? -currency0Delta : currency0Delta;
16200
- const absCurrency1Delta = currency1Delta < 0 ? -currency1Delta : currency1Delta;
16201
- const absCurrency0Fees = currency0Fees < 0 ? -currency0Fees : currency0Fees;
16202
- const absCurrency1Fees = currency1Fees < 0 ? -currency1Fees : currency1Fees;
16203
- const fees = {
16204
- isInFLETH: feesIsInFLETH,
16205
- amount: flETHIsCurrencyZero
16206
- ? feesIsInFLETH
16207
- ? absCurrency0Fees
16208
- : absCurrency1Fees
16209
- : feesIsInFLETH
16210
- ? absCurrency1Fees
16211
- : absCurrency0Fees,
17045
+ // parse swap data
17046
+ const swapData = parseSwapData(log.args, flETHIsCurrencyZero);
17047
+ return {
17048
+ ...log,
17049
+ timestamp,
17050
+ type: swapData.type,
17051
+ delta: swapData.delta,
16212
17052
  };
16213
- if (swapType === "BUY") {
16214
- return {
16215
- ...log,
16216
- timestamp,
16217
- type: swapType,
16218
- delta: {
16219
- coinsBought: flETHIsCurrencyZero
16220
- ? absCurrency1Delta - (!fees.isInFLETH ? fees.amount : 0n)
16221
- : absCurrency0Delta -
16222
- (!fees.isInFLETH ? fees.amount : 0n),
16223
- flETHSold: flETHIsCurrencyZero
16224
- ? absCurrency0Delta - (fees.isInFLETH ? fees.amount : 0n)
16225
- : absCurrency1Delta - (fees.isInFLETH ? fees.amount : 0n),
16226
- fees,
16227
- },
16228
- };
16229
- }
16230
- else {
16231
- return {
16232
- ...log,
16233
- timestamp,
16234
- type: swapType,
16235
- delta: {
16236
- coinsSold: flETHIsCurrencyZero
16237
- ? absCurrency1Delta - (!fees.isInFLETH ? fees.amount : 0n)
16238
- : absCurrency0Delta -
16239
- (!fees.isInFLETH ? fees.amount : 0n),
16240
- flETHBought: flETHIsCurrencyZero
16241
- ? absCurrency0Delta - (fees.isInFLETH ? fees.amount : 0n)
16242
- : absCurrency1Delta - (fees.isInFLETH ? fees.amount : 0n),
16243
- fees,
16244
- },
16245
- };
16246
- }
16247
17053
  }));
16248
17054
  if (logsWithTimestamps.length > 0) {
16249
17055
  onPoolSwap({
@@ -20393,6 +21199,7 @@ class ReadFlaunchSDK {
20393
21199
  this.readFairLaunchV1_1 = new ReadFairLaunchV1_1(FairLaunchV1_1Address[this.chainId], drift$1);
20394
21200
  this.readBidWall = new ReadBidWall(BidWallAddress[this.chainId], drift$1);
20395
21201
  this.readBidWallV1_1 = new ReadBidWallV1_1(BidWallV1_1Address[this.chainId], drift$1);
21202
+ this.readAnyBidWall = new AnyBidWall(AnyBidWallAddress[this.chainId], drift$1);
20396
21203
  this.readFlaunch = new ReadFlaunch(FlaunchAddress[this.chainId], drift$1);
20397
21204
  this.readFlaunchV1_1 = new ReadFlaunchV1_1(FlaunchV1_1Address[this.chainId], drift$1);
20398
21205
  this.readQuoter = new ReadQuoter(this.chainId, QuoterAddress[this.chainId], drift$1);
@@ -20469,7 +21276,7 @@ class ReadFlaunchSDK {
20469
21276
  case exports.FlaunchVersion.V1_1:
20470
21277
  return this.readBidWallV1_1;
20471
21278
  case exports.FlaunchVersion.ANY:
20472
- return this.readBidWallV1_1;
21279
+ return this.readAnyBidWall;
20473
21280
  default:
20474
21281
  return this.readBidWallV1_1;
20475
21282
  }
@@ -21106,6 +21913,20 @@ class ReadFlaunchSDK {
21106
21913
  setIPFSResolver(resolverFn) {
21107
21914
  this.resolveIPFS = resolverFn;
21108
21915
  }
21916
+ /**
21917
+ * Parses a transaction hash to extract PoolSwap events and return parsed swap data
21918
+ * @param params - Object containing parsing parameters
21919
+ * @param params.txHash - The transaction hash to parse
21920
+ * @param params.version - The Flaunch version to use for parsing
21921
+ * @param params.flETHIsCurrencyZero - Whether flETH is currency 0 in the pool (optional)
21922
+ * @returns Parsed swap log or undefined if no PoolSwap event found.
21923
+ * If flETHIsCurrencyZero is provided, returns typed swap data with BUY/SELL information.
21924
+ * If flETHIsCurrencyZero is undefined, returns basic swap log without parsed delta.
21925
+ */
21926
+ async parseSwapTx(params) {
21927
+ const positionManager = this.getPositionManager(params.version);
21928
+ return positionManager.parseSwapTx(params.txHash, params.flETHIsCurrencyZero);
21929
+ }
21109
21930
  }
21110
21931
  class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
21111
21932
  constructor(chainId, drift$1 = drift.createDrift()) {
@@ -21190,6 +22011,22 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
21190
22011
  }
21191
22012
  return this.readWriteFlaunchZap.flaunchIPFSWithRevenueManager(params);
21192
22013
  }
22014
+ /**
22015
+ * Creates a new Flaunch that splits the creator fees to the creator and a list of recipients
22016
+ * @param params - Parameters for creating the Flaunch with split manager
22017
+ * @returns Transaction response
22018
+ */
22019
+ flaunchWithSplitManager(params) {
22020
+ return this.readWriteFlaunchZap.flaunchWithSplitManager(params);
22021
+ }
22022
+ /**
22023
+ * Creates a new Flaunch that splits the creator fees to the creator and a list of recipients, storing the token metadata on IPFS
22024
+ * @param params - Parameters for creating the Flaunch with split manager including all IPFS metadata
22025
+ * @returns Transaction response
22026
+ */
22027
+ flaunchIPFSWithSplitManager(params) {
22028
+ return this.readWriteFlaunchZap.flaunchIPFSWithSplitManager(params);
22029
+ }
21193
22030
  /**
21194
22031
  * Creates a new Flaunch with AnyPositionManager for external coins
21195
22032
  * @param params - Parameters for creating the Flaunch with AnyPositionManager
@@ -21432,6 +22269,9 @@ const FlaunchSDK = {
21432
22269
  ReadWriteFlaunchSDK,
21433
22270
  };
21434
22271
 
22272
+ exports.AddressFeeSplitManagerAddress = AddressFeeSplitManagerAddress;
22273
+ exports.AnyBidWallAddress = AnyBidWallAddress;
22274
+ exports.AnyFlaunchAddress = AnyFlaunchAddress;
21435
22275
  exports.AnyPositionManagerAbi = AnyPositionManagerAbi;
21436
22276
  exports.AnyPositionManagerAddress = AnyPositionManagerAddress;
21437
22277
  exports.BidWallAddress = BidWallAddress;
@@ -21493,6 +22333,7 @@ exports.getPoolId = getPoolId;
21493
22333
  exports.getSqrtPriceX96FromTick = getSqrtPriceX96FromTick;
21494
22334
  exports.getValidTick = getValidTick;
21495
22335
  exports.orderPoolKey = orderPoolKey;
22336
+ exports.parseSwapData = parseSwapData;
21496
22337
  exports.resolveIPFS = resolveIPFS;
21497
22338
  exports.uint256ToBytes32 = uint256ToBytes32;
21498
22339
  exports.uploadFileToIPFS = uploadFileToIPFS;