@flaunch/sdk 0.5.0 → 0.6.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.cjs.js CHANGED
@@ -20,7 +20,7 @@ function defineChain(chain) {
20
20
  };
21
21
  }
22
22
 
23
- const version = '2.28.3';
23
+ const version = '2.29.2';
24
24
 
25
25
  let errorConfig = {
26
26
  getDocsUrl: ({ docsBaseUrl, docsPath = '', docsSlug, }) => docsPath
@@ -3252,7 +3252,6 @@ const formatters = {
3252
3252
  });
3253
3253
  return {
3254
3254
  transactions,
3255
- ...(args.randomness ? { randomness: args.randomness } : {}),
3256
3255
  };
3257
3256
  },
3258
3257
  }),
@@ -5155,7 +5154,7 @@ const sourceId$3 = 11_155_111; // sepolia
5155
5154
  },
5156
5155
  disputeGameFactory: {
5157
5156
  [sourceId$3]: {
5158
- address: '0x8cF97Ee616C986a070F5020d973b456D0120C253',
5157
+ address: '0x8Ec1111f67Dad6b6A93B3F42DfBC92D81c98449A',
5159
5158
  },
5160
5159
  },
5161
5160
  l2OutputOracle: {
@@ -7094,11 +7093,11 @@ const generateTokenUri = async (name, params) => {
7094
7093
  name,
7095
7094
  description: params.metadata.description,
7096
7095
  image: `ipfs://${imageRes.IpfsHash}`,
7097
- external_link: params.metadata.websiteUrl,
7096
+ external_link: params.metadata.websiteUrl || "",
7098
7097
  collaborators: [],
7099
- discordUrl: params.metadata.discordUrl,
7100
- twitterUrl: params.metadata.twitterUrl,
7101
- telegramUrl: params.metadata.telegramUrl,
7098
+ discordUrl: params.metadata.discordUrl || "",
7099
+ twitterUrl: params.metadata.twitterUrl || "",
7100
+ telegramUrl: params.metadata.telegramUrl || "",
7102
7101
  };
7103
7102
  const metadataRes = await uploadJsonToIPFS({
7104
7103
  pinataConfig: params.pinataConfig,
@@ -8019,9 +8018,7 @@ class ReadFlaunchPositionManager {
8019
8018
  });
8020
8019
  // Get timestamps for each log
8021
8020
  const logsWithTimestamps = await Promise.all([..._logs].reverse().map(async (log) => {
8022
- const block = await this.drift.getBlock({
8023
- blockNumber: log.blockNumber,
8024
- });
8021
+ const block = await this.drift.getBlock(log.blockNumber);
8025
8022
  return {
8026
8023
  ...log,
8027
8024
  timestamp: Number(block?.timestamp) * 1000, // convert to ms for js
@@ -8084,9 +8081,7 @@ class ReadFlaunchPositionManager {
8084
8081
  });
8085
8082
  // Get timestamps for each log
8086
8083
  const logsWithTimestamps = await Promise.all([..._logs].reverse().map(async (log) => {
8087
- const block = await this.drift.getBlock({
8088
- blockNumber: log.blockNumber,
8089
- });
8084
+ const block = await this.drift.getBlock(log.blockNumber);
8090
8085
  const timestamp = Number(block?.timestamp) * 1000; // convert to ms for js
8091
8086
  if (flETHIsCurrencyZero === undefined) {
8092
8087
  return {
@@ -11953,9 +11948,7 @@ class ReadFlaunchPositionManagerV1_1 {
11953
11948
  });
11954
11949
  // Get timestamps for each log
11955
11950
  const logsWithTimestamps = await Promise.all([..._logs].reverse().map(async (log) => {
11956
- const block = await this.drift.getBlock({
11957
- blockNumber: log.blockNumber,
11958
- });
11951
+ const block = await this.drift.getBlock(log.blockNumber);
11959
11952
  return {
11960
11953
  ...log,
11961
11954
  timestamp: Number(block?.timestamp) * 1000, // convert to ms for js
@@ -12018,9 +12011,7 @@ class ReadFlaunchPositionManagerV1_1 {
12018
12011
  });
12019
12012
  // Get timestamps for each log
12020
12013
  const logsWithTimestamps = await Promise.all([..._logs].reverse().map(async (log) => {
12021
- const block = await this.drift.getBlock({
12022
- blockNumber: log.blockNumber,
12023
- });
12014
+ const block = await this.drift.getBlock(log.blockNumber);
12024
12015
  const timestamp = Number(block?.timestamp) * 1000; // convert to ms for js
12025
12016
  if (flETHIsCurrencyZero === undefined) {
12026
12017
  return {
@@ -12146,8 +12137,12 @@ class ReadWriteFlaunchPositionManagerV1_1 extends ReadFlaunchPositionManagerV1_1
12146
12137
  ], [initialMCapInUSDCWei]);
12147
12138
  const fairLaunchInBps = BigInt(fairLaunchPercent * 100);
12148
12139
  const creatorFeeAllocationInBps = creatorFeeAllocationPercent * 100;
12140
+ let sender = viem.zeroAddress;
12141
+ if (this.drift.adapter.getSignerAddress) {
12142
+ sender = await this.drift.adapter.getSignerAddress();
12143
+ }
12149
12144
  const flaunchingFee = await this.getFlaunchingFee({
12150
- sender: await this.drift.adapter.getSignerAddress(),
12145
+ sender,
12151
12146
  initialPriceParams,
12152
12147
  slippagePercent: 5,
12153
12148
  });
@@ -13569,7 +13564,7 @@ class ReadMemecoin {
13569
13564
  * @returns Promise<string> - The name of the token
13570
13565
  */
13571
13566
  name() {
13572
- return this.contract.read("name");
13567
+ return this.contract.read("name", {});
13573
13568
  }
13574
13569
  /**
13575
13570
  * Gets the symbol of the token
@@ -14644,6 +14639,19 @@ class ReadPermit2 {
14644
14639
  });
14645
14640
  }
14646
14641
  }
14642
+ class ReadWritePermit2 extends ReadPermit2 {
14643
+ constructor(address, drift$1 = drift.createDrift()) {
14644
+ super(address, drift$1);
14645
+ }
14646
+ /**
14647
+ * Approves a spender to spend a token via transaction
14648
+ * @param params - The parameters for the approval
14649
+ * @returns The transaction response
14650
+ */
14651
+ approve(params) {
14652
+ return this.contract.write("approve", params);
14653
+ }
14654
+ }
14647
14655
 
14648
14656
  const BidWallV1_1Abi = [
14649
14657
  {
@@ -18216,7 +18224,9 @@ class ReadFlaunchSDK {
18216
18224
  filterByPoolId: params.filterByCoin
18217
18225
  ? await this.poolId(params.filterByCoin, true)
18218
18226
  : undefined,
18219
- flETHIsCurrencyZero: this.flETHIsCurrencyZero(params.filterByCoin),
18227
+ flETHIsCurrencyZero: params.filterByCoin
18228
+ ? this.flETHIsCurrencyZero(params.filterByCoin)
18229
+ : undefined,
18220
18230
  });
18221
18231
  }
18222
18232
  /**
@@ -18230,7 +18240,9 @@ class ReadFlaunchSDK {
18230
18240
  filterByPoolId: params.filterByCoin
18231
18241
  ? await this.poolId(params.filterByCoin)
18232
18242
  : undefined,
18233
- flETHIsCurrencyZero: this.flETHIsCurrencyZero(params.filterByCoin),
18243
+ flETHIsCurrencyZero: params.filterByCoin
18244
+ ? this.flETHIsCurrencyZero(params.filterByCoin)
18245
+ : undefined,
18234
18246
  });
18235
18247
  }
18236
18248
  /**
@@ -18620,6 +18632,45 @@ class ReadFlaunchSDK {
18620
18632
  slippagePercent: params.slippagePercent,
18621
18633
  });
18622
18634
  }
18635
+ /**
18636
+ * Gets a quote for selling an exact amount of tokens for ETH
18637
+ * @param coinAddress - The address of the token to sell
18638
+ * @param amountIn - The exact amount of tokens to sell
18639
+ * @param isV1Coin - Optional flag to specify if token is V1. If not provided, V1.1 is assumed
18640
+ * @returns Promise<bigint> - The expected amount of ETH to receive
18641
+ */
18642
+ async getSellQuoteExactInput(coinAddress, amountIn, isV1Coin) {
18643
+ if (isV1Coin === undefined) {
18644
+ isV1Coin = await this.isV1Coin(coinAddress);
18645
+ }
18646
+ return this.readQuoter.getSellQuoteExactInput(coinAddress, amountIn, isV1Coin);
18647
+ }
18648
+ /**
18649
+ * Gets a quote for buying tokens with an exact amount of ETH
18650
+ * @param coinAddress - The address of the token to buy
18651
+ * @param ethIn - The exact amount of ETH to spend
18652
+ * @param isV1Coin - Optional flag to specify if token is V1. If not provided, V1.1 is assumed
18653
+ * @returns Promise<bigint> - The expected amount of tokens to receive
18654
+ */
18655
+ async getBuyQuoteExactInput(coinAddress, amountIn, isV1Coin) {
18656
+ if (isV1Coin === undefined) {
18657
+ isV1Coin = await this.isV1Coin(coinAddress);
18658
+ }
18659
+ return this.readQuoter.getBuyQuoteExactInput(coinAddress, amountIn, isV1Coin);
18660
+ }
18661
+ /**
18662
+ * Gets a quote for buying an exact amount of tokens with ETH
18663
+ * @param coinAddress - The address of the token to buy
18664
+ * @param coinOut - The exact amount of tokens to receive
18665
+ * @param isV1Coin - Optional flag to specify if token is V1. If not provided, V1.1 is assumed
18666
+ * @returns Promise<bigint> - The required amount of ETH to spend
18667
+ */
18668
+ async getBuyQuoteExactOutput(coinAddress, amountOut, isV1Coin) {
18669
+ if (isV1Coin === undefined) {
18670
+ isV1Coin = await this.isV1Coin(coinAddress);
18671
+ }
18672
+ return this.readQuoter.getBuyQuoteExactOutput(coinAddress, amountOut, isV1Coin);
18673
+ }
18623
18674
  /**
18624
18675
  * Determines if flETH is currency0 in the pool
18625
18676
  * @param coinAddress - The address of the coin
@@ -18645,6 +18696,7 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
18645
18696
  this.readWriteFastFlaunchZap = new ReadWriteFastFlaunchZap(FastFlaunchZapAddress[this.chainId], drift$1);
18646
18697
  this.readWriteFlaunchZap = new ReadWriteFlaunchZap(this.chainId, FlaunchZapAddress[this.chainId], drift$1);
18647
18698
  this.readWriteTreasuryManagerFactory = new ReadWriteTreasuryManagerFactory(this.chainId, TreasuryManagerFactoryAddress[this.chainId], drift$1);
18699
+ this.readWritePermit2 = new ReadWritePermit2(Permit2Address[this.chainId], drift$1);
18648
18700
  }
18649
18701
  /**
18650
18702
  * Deploys a new revenue manager
@@ -18790,7 +18842,7 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
18790
18842
  sender: sender,
18791
18843
  memecoin: params.coinAddress,
18792
18844
  chainId: this.chainId,
18793
- referrer: params.referrer,
18845
+ referrer: params.referrer ?? null,
18794
18846
  swapType: params.swapType,
18795
18847
  amountIn: amountIn,
18796
18848
  amountOutMin: amountOutMin,
@@ -18835,7 +18887,7 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
18835
18887
  ethOutMin,
18836
18888
  permitSingle: params.permitSingle,
18837
18889
  signature: params.signature,
18838
- referrer: params.referrer,
18890
+ referrer: params.referrer ?? null,
18839
18891
  isV1Coin: isV1Coin,
18840
18892
  });
18841
18893
  return this.drift.write({