liquid-sdk 1.7.2 → 1.7.3

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.js CHANGED
@@ -161,7 +161,7 @@ var POOL_POSITIONS = {
161
161
  };
162
162
  var DEFAULTS = {
163
163
  HOOK: ADDRESSES.HOOK_STATIC_FEE_V2,
164
- /** LP Locker with fee conversion (converts fees to ETH before distributing) */
164
+ /** LP Locker with fee conversion (converts fees to WETH before distributing) */
165
165
  LOCKER: ADDRESSES.LP_LOCKER_FEE_CONVERSION,
166
166
  TICK_SPACING: 200,
167
167
  TICK_IF_TOKEN0_IS_LIQUID: -230400,
@@ -1201,6 +1201,73 @@ var LiquidSDK = class {
1201
1201
  extensionData
1202
1202
  };
1203
1203
  }
1204
+ // ── Airdrop Extension ──────────────────────────────────────────
1205
+ /**
1206
+ * Build an ExtensionConfig that reserves a percentage of supply into
1207
+ * the LiquidAirdropV2 contract for merkle-tree-based distribution.
1208
+ *
1209
+ * The airdrop contract expects `AirdropV2ExtensionData`:
1210
+ * { address admin, bytes32 merkleRoot, uint256 lockupDuration, uint256 vestingDuration }
1211
+ *
1212
+ * Leaf encoding used by LiquidAirdropV2.claim (note: **double hashed**
1213
+ * — OZ's standard 2nd-preimage-resistant pattern):
1214
+ * leaf = keccak256(bytes.concat(keccak256(abi.encode(recipient, allocatedAmount))))
1215
+ *
1216
+ * @example
1217
+ * ```typescript
1218
+ * const airdropExt = sdk.buildAirdropExtension({
1219
+ * admin: account.address,
1220
+ * merkleRoot: "0x…",
1221
+ * allocationBps: 2000, // 20%
1222
+ * lockupDuration: 86400, // 1 day (minimum)
1223
+ * vestingDuration: 0, // instant claim after lockup
1224
+ * });
1225
+ * ```
1226
+ */
1227
+ buildAirdropExtension(airdrop) {
1228
+ const MIN_LOCKUP = 86400;
1229
+ const MAX_BPS = 9e3;
1230
+ if (airdrop.allocationBps < 1 || airdrop.allocationBps > MAX_BPS) {
1231
+ throw new Error(
1232
+ `Airdrop allocationBps must be 1\u2013${MAX_BPS} (0.01%\u201390%). Got ${airdrop.allocationBps}.`
1233
+ );
1234
+ }
1235
+ if (airdrop.lockupDuration < MIN_LOCKUP) {
1236
+ throw new Error(
1237
+ `Airdrop lockupDuration must be \u2265 ${MIN_LOCKUP} seconds (1 day). Got ${airdrop.lockupDuration}.`
1238
+ );
1239
+ }
1240
+ if (airdrop.vestingDuration !== void 0 && airdrop.vestingDuration < 0) {
1241
+ throw new Error("Airdrop vestingDuration cannot be negative.");
1242
+ }
1243
+ const extensionData = (0, import_viem2.encodeAbiParameters)(
1244
+ [
1245
+ {
1246
+ type: "tuple",
1247
+ components: [
1248
+ { type: "address", name: "admin" },
1249
+ { type: "bytes32", name: "merkleRoot" },
1250
+ { type: "uint256", name: "lockupDuration" },
1251
+ { type: "uint256", name: "vestingDuration" }
1252
+ ]
1253
+ }
1254
+ ],
1255
+ [
1256
+ {
1257
+ admin: airdrop.admin,
1258
+ merkleRoot: airdrop.merkleRoot,
1259
+ lockupDuration: BigInt(airdrop.lockupDuration),
1260
+ vestingDuration: BigInt(airdrop.vestingDuration ?? 0)
1261
+ }
1262
+ ]
1263
+ );
1264
+ return {
1265
+ extension: ADDRESSES.AIRDROP_V2,
1266
+ msgValue: 0n,
1267
+ extensionBps: airdrop.allocationBps,
1268
+ extensionData
1269
+ };
1270
+ }
1204
1271
  // ── Validation ─────────────────────────────────────────────────
1205
1272
  /**
1206
1273
  * Validate a DeploymentConfig before sending to the contract.
@@ -1365,13 +1432,27 @@ var LiquidSDK = class {
1365
1432
  (sum, ext) => sum + ext.msgValue,
1366
1433
  0n
1367
1434
  );
1435
+ let gas;
1436
+ try {
1437
+ const estimated = await this.publicClient.estimateContractGas({
1438
+ address: ADDRESSES.FACTORY,
1439
+ abi: LiquidFactoryAbi,
1440
+ functionName: "deployToken",
1441
+ args: [deploymentConfig],
1442
+ value: msgValue,
1443
+ account: this.walletClient.account
1444
+ });
1445
+ gas = estimated * 120n / 100n;
1446
+ } catch {
1447
+ gas = 6000000n;
1448
+ }
1368
1449
  const txHash = await this.walletClient.writeContract({
1369
1450
  address: ADDRESSES.FACTORY,
1370
1451
  abi: LiquidFactoryAbi,
1371
1452
  functionName: "deployToken",
1372
1453
  args: [deploymentConfig],
1373
1454
  value: msgValue,
1374
- gas: 5000000n,
1455
+ gas,
1375
1456
  chain: import_chains2.base,
1376
1457
  account: this.walletClient.account
1377
1458
  });