@flaunch/sdk 0.5.1 → 0.7.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/README.md +25 -41
- package/dist/addresses/index.cjs +2 -3
- package/dist/addresses/index.cjs.map +1 -1
- package/dist/addresses/index.js +2 -3
- package/dist/addresses/index.js.map +1 -1
- package/dist/clients/FlaunchPositionManagerClient.d.ts.map +1 -1
- package/dist/clients/FlaunchPositionManagerV1_1Client.d.ts.map +1 -1
- package/dist/clients/Permit2Client.d.ts +16 -1
- package/dist/clients/Permit2Client.d.ts.map +1 -1
- package/dist/helpers/index.cjs +6 -7
- package/dist/helpers/index.cjs.map +1 -1
- package/dist/helpers/index.js +6 -7
- package/dist/helpers/index.js.map +1 -1
- package/dist/index.cjs.js +62 -25
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +62 -26
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/sdk/FlaunchSDK.d.ts +7 -6
- package/dist/sdk/FlaunchSDK.d.ts.map +1 -1
- package/dist/sdk/factory.d.ts +21 -0
- package/dist/sdk/factory.d.ts.map +1 -0
- package/dist/utils/univ4.d.ts +1 -1
- package/package.json +6 -7
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export * from "./helpers";
|
|
|
5
5
|
export * from "./utils/univ4";
|
|
6
6
|
export type { BuySwapLog, PoolCreatedLogs, SellSwapLog, } from "./clients/FlaunchPositionManagerClient";
|
|
7
7
|
export { ReadFlaunchSDK, ReadWriteFlaunchSDK };
|
|
8
|
+
export { createFlaunch } from "./sdk/factory";
|
|
9
|
+
export type { CreateFlaunchParams } from "./sdk/factory";
|
|
8
10
|
export declare const FlaunchSDK: {
|
|
9
11
|
ReadFlaunchSDK: typeof ReadFlaunchSDK;
|
|
10
12
|
ReadWriteFlaunchSDK: typeof ReadWriteFlaunchSDK;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvE,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAE9B,YAAY,EACV,UAAU,EACV,eAAe,EACf,WAAW,GACZ,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvE,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAE9B,YAAY,EACV,UAAU,EACV,eAAe,EACf,WAAW,GACZ,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzD,eAAO,MAAM,UAAU;;;CAGtB,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createDrift } from '@delvtech/drift';
|
|
|
2
2
|
import { zeroAddress, parseEther, encodeAbiParameters, maxUint256 as maxUint256$1, encodeFunctionData, maxUint160, maxUint48, hexToBigInt as hexToBigInt$1, pad as pad$1, keccak256 as keccak256$1, encodePacked, stringToHex as stringToHex$1, parseUnits, formatUnits as formatUnits$1, concat, toHex as toHex$1, createPublicClient, http } from 'viem';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import { TickMath } from '@uniswap/v3-sdk';
|
|
5
|
+
import { viemAdapter } from '@delvtech/drift-viem';
|
|
5
6
|
|
|
6
7
|
function defineChain(chain) {
|
|
7
8
|
return {
|
|
@@ -12,7 +13,7 @@ function defineChain(chain) {
|
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
const version = '2.
|
|
16
|
+
const version = '2.29.2';
|
|
16
17
|
|
|
17
18
|
let errorConfig = {
|
|
18
19
|
getDocsUrl: ({ docsBaseUrl, docsPath = '', docsSlug, }) => docsPath
|
|
@@ -3244,7 +3245,6 @@ const formatters = {
|
|
|
3244
3245
|
});
|
|
3245
3246
|
return {
|
|
3246
3247
|
transactions,
|
|
3247
|
-
...(args.randomness ? { randomness: args.randomness } : {}),
|
|
3248
3248
|
};
|
|
3249
3249
|
},
|
|
3250
3250
|
}),
|
|
@@ -5147,7 +5147,7 @@ const sourceId$3 = 11_155_111; // sepolia
|
|
|
5147
5147
|
},
|
|
5148
5148
|
disputeGameFactory: {
|
|
5149
5149
|
[sourceId$3]: {
|
|
5150
|
-
address: '
|
|
5150
|
+
address: '0x8Ec1111f67Dad6b6A93B3F42DfBC92D81c98449A',
|
|
5151
5151
|
},
|
|
5152
5152
|
},
|
|
5153
5153
|
l2OutputOracle: {
|
|
@@ -7086,11 +7086,11 @@ const generateTokenUri = async (name, params) => {
|
|
|
7086
7086
|
name,
|
|
7087
7087
|
description: params.metadata.description,
|
|
7088
7088
|
image: `ipfs://${imageRes.IpfsHash}`,
|
|
7089
|
-
external_link: params.metadata.websiteUrl,
|
|
7089
|
+
external_link: params.metadata.websiteUrl || "",
|
|
7090
7090
|
collaborators: [],
|
|
7091
|
-
discordUrl: params.metadata.discordUrl,
|
|
7092
|
-
twitterUrl: params.metadata.twitterUrl,
|
|
7093
|
-
telegramUrl: params.metadata.telegramUrl,
|
|
7091
|
+
discordUrl: params.metadata.discordUrl || "",
|
|
7092
|
+
twitterUrl: params.metadata.twitterUrl || "",
|
|
7093
|
+
telegramUrl: params.metadata.telegramUrl || "",
|
|
7094
7094
|
};
|
|
7095
7095
|
const metadataRes = await uploadJsonToIPFS({
|
|
7096
7096
|
pinataConfig: params.pinataConfig,
|
|
@@ -8011,9 +8011,7 @@ class ReadFlaunchPositionManager {
|
|
|
8011
8011
|
});
|
|
8012
8012
|
// Get timestamps for each log
|
|
8013
8013
|
const logsWithTimestamps = await Promise.all([..._logs].reverse().map(async (log) => {
|
|
8014
|
-
const block = await this.drift.getBlock(
|
|
8015
|
-
blockNumber: log.blockNumber,
|
|
8016
|
-
});
|
|
8014
|
+
const block = await this.drift.getBlock(log.blockNumber);
|
|
8017
8015
|
return {
|
|
8018
8016
|
...log,
|
|
8019
8017
|
timestamp: Number(block?.timestamp) * 1000, // convert to ms for js
|
|
@@ -8076,9 +8074,7 @@ class ReadFlaunchPositionManager {
|
|
|
8076
8074
|
});
|
|
8077
8075
|
// Get timestamps for each log
|
|
8078
8076
|
const logsWithTimestamps = await Promise.all([..._logs].reverse().map(async (log) => {
|
|
8079
|
-
const block = await this.drift.getBlock(
|
|
8080
|
-
blockNumber: log.blockNumber,
|
|
8081
|
-
});
|
|
8077
|
+
const block = await this.drift.getBlock(log.blockNumber);
|
|
8082
8078
|
const timestamp = Number(block?.timestamp) * 1000; // convert to ms for js
|
|
8083
8079
|
if (flETHIsCurrencyZero === undefined) {
|
|
8084
8080
|
return {
|
|
@@ -11945,9 +11941,7 @@ class ReadFlaunchPositionManagerV1_1 {
|
|
|
11945
11941
|
});
|
|
11946
11942
|
// Get timestamps for each log
|
|
11947
11943
|
const logsWithTimestamps = await Promise.all([..._logs].reverse().map(async (log) => {
|
|
11948
|
-
const block = await this.drift.getBlock(
|
|
11949
|
-
blockNumber: log.blockNumber,
|
|
11950
|
-
});
|
|
11944
|
+
const block = await this.drift.getBlock(log.blockNumber);
|
|
11951
11945
|
return {
|
|
11952
11946
|
...log,
|
|
11953
11947
|
timestamp: Number(block?.timestamp) * 1000, // convert to ms for js
|
|
@@ -12010,9 +12004,7 @@ class ReadFlaunchPositionManagerV1_1 {
|
|
|
12010
12004
|
});
|
|
12011
12005
|
// Get timestamps for each log
|
|
12012
12006
|
const logsWithTimestamps = await Promise.all([..._logs].reverse().map(async (log) => {
|
|
12013
|
-
const block = await this.drift.getBlock(
|
|
12014
|
-
blockNumber: log.blockNumber,
|
|
12015
|
-
});
|
|
12007
|
+
const block = await this.drift.getBlock(log.blockNumber);
|
|
12016
12008
|
const timestamp = Number(block?.timestamp) * 1000; // convert to ms for js
|
|
12017
12009
|
if (flETHIsCurrencyZero === undefined) {
|
|
12018
12010
|
return {
|
|
@@ -12138,8 +12130,12 @@ class ReadWriteFlaunchPositionManagerV1_1 extends ReadFlaunchPositionManagerV1_1
|
|
|
12138
12130
|
], [initialMCapInUSDCWei]);
|
|
12139
12131
|
const fairLaunchInBps = BigInt(fairLaunchPercent * 100);
|
|
12140
12132
|
const creatorFeeAllocationInBps = creatorFeeAllocationPercent * 100;
|
|
12133
|
+
let sender = zeroAddress;
|
|
12134
|
+
if (this.drift.adapter.getSignerAddress) {
|
|
12135
|
+
sender = await this.drift.adapter.getSignerAddress();
|
|
12136
|
+
}
|
|
12141
12137
|
const flaunchingFee = await this.getFlaunchingFee({
|
|
12142
|
-
sender
|
|
12138
|
+
sender,
|
|
12143
12139
|
initialPriceParams,
|
|
12144
12140
|
slippagePercent: 5,
|
|
12145
12141
|
});
|
|
@@ -13561,7 +13557,7 @@ class ReadMemecoin {
|
|
|
13561
13557
|
* @returns Promise<string> - The name of the token
|
|
13562
13558
|
*/
|
|
13563
13559
|
name() {
|
|
13564
|
-
return this.contract.read("name");
|
|
13560
|
+
return this.contract.read("name", {});
|
|
13565
13561
|
}
|
|
13566
13562
|
/**
|
|
13567
13563
|
* Gets the symbol of the token
|
|
@@ -14636,6 +14632,19 @@ class ReadPermit2 {
|
|
|
14636
14632
|
});
|
|
14637
14633
|
}
|
|
14638
14634
|
}
|
|
14635
|
+
class ReadWritePermit2 extends ReadPermit2 {
|
|
14636
|
+
constructor(address, drift = createDrift()) {
|
|
14637
|
+
super(address, drift);
|
|
14638
|
+
}
|
|
14639
|
+
/**
|
|
14640
|
+
* Approves a spender to spend a token via transaction
|
|
14641
|
+
* @param params - The parameters for the approval
|
|
14642
|
+
* @returns The transaction response
|
|
14643
|
+
*/
|
|
14644
|
+
approve(params) {
|
|
14645
|
+
return this.contract.write("approve", params);
|
|
14646
|
+
}
|
|
14647
|
+
}
|
|
14639
14648
|
|
|
14640
14649
|
const BidWallV1_1Abi = [
|
|
14641
14650
|
{
|
|
@@ -18208,7 +18217,9 @@ class ReadFlaunchSDK {
|
|
|
18208
18217
|
filterByPoolId: params.filterByCoin
|
|
18209
18218
|
? await this.poolId(params.filterByCoin, true)
|
|
18210
18219
|
: undefined,
|
|
18211
|
-
flETHIsCurrencyZero:
|
|
18220
|
+
flETHIsCurrencyZero: params.filterByCoin
|
|
18221
|
+
? this.flETHIsCurrencyZero(params.filterByCoin)
|
|
18222
|
+
: undefined,
|
|
18212
18223
|
});
|
|
18213
18224
|
}
|
|
18214
18225
|
/**
|
|
@@ -18222,7 +18233,9 @@ class ReadFlaunchSDK {
|
|
|
18222
18233
|
filterByPoolId: params.filterByCoin
|
|
18223
18234
|
? await this.poolId(params.filterByCoin)
|
|
18224
18235
|
: undefined,
|
|
18225
|
-
flETHIsCurrencyZero:
|
|
18236
|
+
flETHIsCurrencyZero: params.filterByCoin
|
|
18237
|
+
? this.flETHIsCurrencyZero(params.filterByCoin)
|
|
18238
|
+
: undefined,
|
|
18226
18239
|
});
|
|
18227
18240
|
}
|
|
18228
18241
|
/**
|
|
@@ -18676,6 +18689,7 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
|
|
|
18676
18689
|
this.readWriteFastFlaunchZap = new ReadWriteFastFlaunchZap(FastFlaunchZapAddress[this.chainId], drift);
|
|
18677
18690
|
this.readWriteFlaunchZap = new ReadWriteFlaunchZap(this.chainId, FlaunchZapAddress[this.chainId], drift);
|
|
18678
18691
|
this.readWriteTreasuryManagerFactory = new ReadWriteTreasuryManagerFactory(this.chainId, TreasuryManagerFactoryAddress[this.chainId], drift);
|
|
18692
|
+
this.readWritePermit2 = new ReadWritePermit2(Permit2Address[this.chainId], drift);
|
|
18679
18693
|
}
|
|
18680
18694
|
/**
|
|
18681
18695
|
* Deploys a new revenue manager
|
|
@@ -18821,7 +18835,7 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
|
|
|
18821
18835
|
sender: sender,
|
|
18822
18836
|
memecoin: params.coinAddress,
|
|
18823
18837
|
chainId: this.chainId,
|
|
18824
|
-
referrer: params.referrer,
|
|
18838
|
+
referrer: params.referrer ?? null,
|
|
18825
18839
|
swapType: params.swapType,
|
|
18826
18840
|
amountIn: amountIn,
|
|
18827
18841
|
amountOutMin: amountOutMin,
|
|
@@ -18866,7 +18880,7 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
|
|
|
18866
18880
|
ethOutMin,
|
|
18867
18881
|
permitSingle: params.permitSingle,
|
|
18868
18882
|
signature: params.signature,
|
|
18869
|
-
referrer: params.referrer,
|
|
18883
|
+
referrer: params.referrer ?? null,
|
|
18870
18884
|
isV1Coin: isV1Coin,
|
|
18871
18885
|
});
|
|
18872
18886
|
return this.drift.write({
|
|
@@ -18937,10 +18951,32 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
|
|
|
18937
18951
|
}
|
|
18938
18952
|
}
|
|
18939
18953
|
|
|
18954
|
+
/**
|
|
18955
|
+
* Creates a Flaunch SDK instance with the provided clients
|
|
18956
|
+
* @param params - Parameters for creating the SDK
|
|
18957
|
+
* @returns ReadFlaunchSDK if only publicClient is provided, ReadWriteFlaunchSDK if walletClient is also provided
|
|
18958
|
+
* @throws Error if publicClient.chain is not configured
|
|
18959
|
+
*/
|
|
18960
|
+
function createFlaunch(params) {
|
|
18961
|
+
const { publicClient, walletClient } = params;
|
|
18962
|
+
if (!publicClient.chain) {
|
|
18963
|
+
throw new Error("publicClient must be configured with a chain");
|
|
18964
|
+
}
|
|
18965
|
+
const chainId = publicClient.chain.id;
|
|
18966
|
+
// Return appropriate SDK type based on whether walletClient is provided
|
|
18967
|
+
return walletClient
|
|
18968
|
+
? new ReadWriteFlaunchSDK(chainId, createDrift({
|
|
18969
|
+
adapter: viemAdapter({ publicClient, walletClient }),
|
|
18970
|
+
}))
|
|
18971
|
+
: new ReadFlaunchSDK(chainId, createDrift({
|
|
18972
|
+
adapter: viemAdapter({ publicClient }),
|
|
18973
|
+
}));
|
|
18974
|
+
}
|
|
18975
|
+
|
|
18940
18976
|
const FlaunchSDK = {
|
|
18941
18977
|
ReadFlaunchSDK,
|
|
18942
18978
|
ReadWriteFlaunchSDK,
|
|
18943
18979
|
};
|
|
18944
18980
|
|
|
18945
|
-
export { BidWallAddress, BidWallV1_1Address, FLETHAddress, FLETHHooksAddress, FairLaunchAbi, FairLaunchAddress, FairLaunchV1_1Address, FastFlaunchZapAbi, FastFlaunchZapAddress, FlaunchAddress, FlaunchPositionManagerAbi, FlaunchPositionManagerAddress, FlaunchPositionManagerV1_1Address, FlaunchSDK, FlaunchV1_1Address, FlaunchZapAddress, MemecoinAbi, Permit2Address, PoolManagerAbi, PoolManagerAddress, QuoterAddress, ReadFlaunchSDK, ReadWriteFlaunchSDK, RevenueManagerAddress, StateViewAddress, TICK_SPACING, TickFinder, TreasuryManagerFactoryAddress, USDCETHPoolKeys, UniversalRouterAddress, bytes32ToUint256, calculateUnderlyingTokenBalances, chainIdToChain, generateTokenUri, getPoolId, getSqrtPriceX96FromTick, getValidTick, orderPoolKey, resolveIPFS, uint256ToBytes32, uploadFileToIPFS, uploadImageToIPFS, uploadJsonToIPFS };
|
|
18981
|
+
export { BidWallAddress, BidWallV1_1Address, FLETHAddress, FLETHHooksAddress, FairLaunchAbi, FairLaunchAddress, FairLaunchV1_1Address, FastFlaunchZapAbi, FastFlaunchZapAddress, FlaunchAddress, FlaunchPositionManagerAbi, FlaunchPositionManagerAddress, FlaunchPositionManagerV1_1Address, FlaunchSDK, FlaunchV1_1Address, FlaunchZapAddress, MemecoinAbi, Permit2Address, PoolManagerAbi, PoolManagerAddress, QuoterAddress, ReadFlaunchSDK, ReadWriteFlaunchSDK, RevenueManagerAddress, StateViewAddress, TICK_SPACING, TickFinder, TreasuryManagerFactoryAddress, USDCETHPoolKeys, UniversalRouterAddress, bytes32ToUint256, calculateUnderlyingTokenBalances, chainIdToChain, createFlaunch, generateTokenUri, getPoolId, getSqrtPriceX96FromTick, getValidTick, orderPoolKey, resolveIPFS, uint256ToBytes32, uploadFileToIPFS, uploadImageToIPFS, uploadJsonToIPFS };
|
|
18946
18982
|
//# sourceMappingURL=index.esm.js.map
|