@1delta/calldatalib 0.0.2 → 0.0.10

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.
@@ -114,15 +114,14 @@ export declare function encodeUniswapV4Sync(singleton: Address, asset: Address):
114
114
  export declare function encodeUniswapV4Take(singleton: Address, asset: Address, receiver: Address, amount: bigint): Hex;
115
115
  export declare function swapHead(amount: bigint, amountOutMin: bigint, assetIn: Address): Hex;
116
116
  export declare function attachBranch(data: Hex, hops: bigint, splits: bigint, splitsData: Hex): Hex;
117
- export declare function uniswapV2StyleSwap(tokenOut: Address, receiver: Address, forkId: bigint, pool: Address, feeDenom: bigint, cfg: any, flashCalldata: Hex): Hex;
118
- export declare function uniswapV4StyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, manager: Address, fee: number, tickSpacing: number, hooks: Address, hookData: Hex, cfg: any): Hex;
119
- export declare function balancerV2StyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, poolId: Hex, balancerVault: Address, cfg: any): Hex;
120
- export declare function lbStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, pool: Address, swapForY: boolean, cfg: any): Hex;
121
- export declare function syncSwapStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, pool: Address, cfg: any): Hex;
122
- export declare function uniswapV3StyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, forkId: bigint, pool: Address, feeTier: bigint, cfg: any, flashCalldata: Hex): Hex;
123
- export declare function izumiV3StyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, forkId: bigint, pool: Address, feeTier: bigint, cfg: any, flashCalldata: Hex): Hex;
124
- export declare function balancerV3StyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, balancerV3Vault: Address, pool: Address, cfg: any, poolUserData: Hex): Hex;
125
- export declare function encodeIzumiStyleSwap(tokenOut: Address, receiver: Address, forkId: bigint, pool: Address, feeTier: bigint, cfg: any, flashCalldata: Hex): Hex;
117
+ export declare function encodeUniswapV2StyleSwap(tokenOut: Address, receiver: Address, forkId: bigint, pool: Address, feeDenom: bigint, cfg: any, flashCalldata: Hex): Hex;
118
+ export declare function encodeUniswapV4StyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, manager: Address, fee: number, tickSpacing: number, hooks: Address, hookData: Hex, cfg: any): Hex;
119
+ export declare function encodeBalancerV2StyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, poolId: Hex, balancerVault: Address, cfg: any): Hex;
120
+ export declare function encodeLbStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, pool: Address, swapForY: boolean, cfg: any): Hex;
121
+ export declare function encodeSyncSwapStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, pool: Address, cfg: any): Hex;
122
+ export declare function encodeUniswapV3StyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, forkId: bigint, pool: Address, feeTier: bigint, cfg: any, flashCalldata: Hex): Hex;
123
+ export declare function encodeIzumiStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, forkId: bigint, pool: Address, feeTier: bigint, cfg: any, flashCalldata: Hex): Hex;
124
+ export declare function encodeBalancerV3StyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, balancerV3Vault: Address, pool: Address, cfg: any, poolUserData: Hex): Hex;
126
125
  export declare function encodeDodoStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, pool: Address, selector: any, poolId: bigint, cfg: any, flashCalldata: Hex): Hex;
127
126
  export declare function encodeWooStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, pool: Address, cfg: any): Hex;
128
127
  export declare function encodeGmxStyleSwap(currentData: Hex, tokenOut: Address, receiver: Address, pool: Address, cfg: any): Hex;
@@ -131,7 +130,7 @@ export declare function encodeCurveStyleSwap(tokenOut: Address, receiver: Addres
131
130
  export declare function encodeCurveNGStyleSwap(tokenOut: Address, receiver: Address, pool: Address, indexIn: bigint, indexOut: bigint, selectorId: bigint, cfg: any): Hex;
132
131
  export declare function encodeNextGenDexSettle(singleton: Address, nativeAmount: bigint): Hex;
133
132
  export declare function encodeNextGenDexSettleBalancer(singleton: Address, asset: Address, amountHint: bigint): Hex;
134
- export declare function encodeTransferIn(asset: Address, receiver: Address, amount: bigint): Hex;
133
+ export declare function encodeTransferIn(asset: Address, from: Address, amount: bigint): Hex;
135
134
  export declare function encodeSweep(asset: Address, receiver: Address, amount: bigint, sweepType: any): Hex;
136
135
  export declare function encodeWrap(amount: bigint, wrapTarget: Address): Hex;
137
136
  export declare function encodeApprove(asset: Address, target: Address): Hex;
@@ -189,7 +189,7 @@ export function attachBranch(data, hops, splits, splitsData) {
189
189
  throw new Error("Nosplitsbutsplitdataprovided");
190
190
  return encodePacked(["bytes", "uint8", "uint8", "bytes"], [data, uint8(hops), uint8(splits), splitsData]);
191
191
  }
192
- export function uniswapV2StyleSwap(tokenOut, receiver, forkId, pool, feeDenom, cfg, flashCalldata) {
192
+ export function encodeUniswapV2StyleSwap(tokenOut, receiver, forkId, pool, feeDenom, cfg, flashCalldata) {
193
193
  if (uint256(cfg) < 2 && flashCalldata.length / 2 - 1 > 2)
194
194
  throw new Error("Invalidconfigforv2swap");
195
195
  return encodePacked(["address", "address", "uint8", "address", "uint16", "uint8", "uint16", "bytes"], [
@@ -199,11 +199,11 @@ export function uniswapV2StyleSwap(tokenOut, receiver, forkId, pool, feeDenom, c
199
199
  pool,
200
200
  uint16(feeDenom),
201
201
  uint8(forkId),
202
- uint16(flashCalldata.length / 2 - 1),
202
+ uint16(cfg === DexPayConfig.FLASH ? flashCalldata.length / 2 - 1 : uint256(cfg)),
203
203
  bytes(cfg === DexPayConfig.FLASH ? flashCalldata : newbytes(0)),
204
204
  ]);
205
205
  }
206
- export function uniswapV4StyleSwap(currentData, tokenOut, receiver, manager, fee, tickSpacing, hooks, hookData, cfg) {
206
+ export function encodeUniswapV4StyleSwap(currentData, tokenOut, receiver, manager, fee, tickSpacing, hooks, hookData, cfg) {
207
207
  if (cfg === DexPayConfig.FLASH)
208
208
  throw new Error("Invalidconfigforv2swap");
209
209
  return encodePacked(["bytes", "address", "address", "uint8", "address", "address", "uint24", "uint24", "uint8", "uint16", "bytes"], [
@@ -220,7 +220,7 @@ export function uniswapV4StyleSwap(currentData, tokenOut, receiver, manager, fee
220
220
  hookData,
221
221
  ]);
222
222
  }
223
- export function balancerV2StyleSwap(currentData, tokenOut, receiver, poolId, balancerVault, cfg) {
223
+ export function encodeBalancerV2StyleSwap(currentData, tokenOut, receiver, poolId, balancerVault, cfg) {
224
224
  if (cfg === DexPayConfig.FLASH)
225
225
  throw new Error("Invalidconfigforv2swap");
226
226
  return encodePacked(["bytes", "address", "address", "uint8", "bytes32", "address", "uint16"], [
@@ -233,7 +233,7 @@ export function balancerV2StyleSwap(currentData, tokenOut, receiver, poolId, bal
233
233
  uint16(uint256(cfg)),
234
234
  ]);
235
235
  }
236
- export function lbStyleSwap(currentData, tokenOut, receiver, pool, swapForY, cfg) {
236
+ export function encodeLbStyleSwap(currentData, tokenOut, receiver, pool, swapForY, cfg) {
237
237
  if (cfg === DexPayConfig.FLASH)
238
238
  throw new Error("Invalidconfigforv2swap");
239
239
  return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8", "uint16"], [
@@ -246,12 +246,12 @@ export function lbStyleSwap(currentData, tokenOut, receiver, pool, swapForY, cfg
246
246
  uint16(uint256(cfg)),
247
247
  ]);
248
248
  }
249
- export function syncSwapStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
249
+ export function encodeSyncSwapStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
250
250
  if (cfg === DexPayConfig.FLASH)
251
251
  throw new Error("Invalidconfigforv2swap");
252
252
  return encodePacked(["bytes", "address", "address", "uint8", "address", "uint16"], [currentData, tokenOut, receiver, uint8(DexTypeMappings.SYNC_SWAP_ID), pool, uint16(uint256(cfg))]);
253
253
  }
254
- export function uniswapV3StyleSwap(currentData, tokenOut, receiver, forkId, pool, feeTier, cfg, flashCalldata) {
254
+ export function encodeUniswapV3StyleSwap(currentData, tokenOut, receiver, forkId, pool, feeTier, cfg, flashCalldata) {
255
255
  if (uint256(cfg) < 2 && flashCalldata.length / 2 - 1 > 2)
256
256
  throw new Error("Invalidconfigforv2swap");
257
257
  return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8", "uint16", "uint16", "bytes"], [
@@ -266,7 +266,7 @@ export function uniswapV3StyleSwap(currentData, tokenOut, receiver, forkId, pool
266
266
  bytes(cfg === DexPayConfig.FLASH ? flashCalldata : newbytes(0)),
267
267
  ]);
268
268
  }
269
- export function izumiV3StyleSwap(currentData, tokenOut, receiver, forkId, pool, feeTier, cfg, flashCalldata) {
269
+ export function encodeIzumiStyleSwap(currentData, tokenOut, receiver, forkId, pool, feeTier, cfg, flashCalldata) {
270
270
  if (uint256(cfg) < 2 && flashCalldata.length / 2 - 1 > 2)
271
271
  throw new Error("Invalidconfigforv2swap");
272
272
  return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8", "uint16", "uint16", "bytes"], [
@@ -281,7 +281,7 @@ export function izumiV3StyleSwap(currentData, tokenOut, receiver, forkId, pool,
281
281
  bytes(cfg === DexPayConfig.FLASH ? flashCalldata : newbytes(0)),
282
282
  ]);
283
283
  }
284
- export function balancerV3StyleSwap(currentData, tokenOut, receiver, balancerV3Vault, pool, cfg, poolUserData) {
284
+ export function encodeBalancerV3StyleSwap(currentData, tokenOut, receiver, balancerV3Vault, pool, cfg, poolUserData) {
285
285
  return encodePacked(["bytes", "address", "address", "uint8", "address", "address", "uint8", "uint16", "bytes"], [
286
286
  currentData,
287
287
  tokenOut,
@@ -294,20 +294,6 @@ export function balancerV3StyleSwap(currentData, tokenOut, receiver, balancerV3V
294
294
  poolUserData,
295
295
  ]);
296
296
  }
297
- export function encodeIzumiStyleSwap(tokenOut, receiver, forkId, pool, feeTier, cfg, flashCalldata) {
298
- if (uint256(cfg) < 2 && flashCalldata.length / 2 - 1 > 2)
299
- throw new Error("Invalidconfigforv2swap");
300
- return encodePacked(["address", "address", "uint8", "address", "uint8", "uint16", "uint16", "bytes"], [
301
- tokenOut,
302
- receiver,
303
- uint8(DexTypeMappings.IZI_ID),
304
- pool,
305
- uint8(forkId),
306
- uint16(feeTier),
307
- uint16(cfg === DexPayConfig.FLASH ? flashCalldata.length / 2 - 1 : uint256(cfg)),
308
- bytes(cfg === DexPayConfig.FLASH ? flashCalldata : newbytes(0)),
309
- ]);
310
- }
311
297
  export function encodeDodoStyleSwap(currentData, tokenOut, receiver, pool, selector, poolId, cfg, flashCalldata) {
312
298
  return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8", "uint16", "uint16", "bytes"], [
313
299
  currentData,
@@ -324,7 +310,7 @@ export function encodeDodoStyleSwap(currentData, tokenOut, receiver, pool, selec
324
310
  export function encodeWooStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
325
311
  if (cfg === DexPayConfig.FLASH)
326
312
  throw new Error("NoflashforWoo");
327
- return encodePacked(["bytes", "address", "address", "uint8", "address", "uint16"], [currentData, tokenOut, receiver, uint8(DexTypeMappings.WOO_FI_ID), pool, uint16(uint256(cfg))]);
313
+ return encodePacked(["bytes", "address", "address", "uint8", "address", "uint8"], [currentData, tokenOut, receiver, uint8(DexTypeMappings.WOO_FI_ID), pool, uint8(uint256(cfg))]);
328
314
  }
329
315
  export function encodeGmxStyleSwap(currentData, tokenOut, receiver, pool, cfg) {
330
316
  if (cfg === DexPayConfig.FLASH)
@@ -381,8 +367,8 @@ export function encodeNextGenDexSettleBalancer(singleton, asset, amountHint) {
381
367
  uint128(amountHint >= 0xffffffffffffffffffffffffffffffn ? 0xffffffffffffffffffffffffffffffn : amountHint),
382
368
  ]);
383
369
  }
384
- export function encodeTransferIn(asset, receiver, amount) {
385
- return encodePacked(["uint8", "uint8", "address", "address", "uint128"], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.TRANSFER_FROM), asset, receiver, uint128(amount)]);
370
+ export function encodeTransferIn(asset, from, amount) {
371
+ return encodePacked(["uint8", "uint8", "address", "address", "uint128"], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.TRANSFER_FROM), asset, from, uint128(amount)]);
386
372
  }
387
373
  export function encodeSweep(asset, receiver, amount, sweepType) {
388
374
  return encodePacked(["uint8", "uint8", "address", "address", "uint8", "uint128"], [uint8(ComposerCommands.TRANSFERS), uint8(TransferIds.SWEEP), asset, receiver, sweepType, uint128(amount)]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1delta/calldatalib",
3
- "version": "0.0.2",
3
+ "version": "0.0.10",
4
4
  "description": "Generated CalldataLib TypeScript functions for 1delta smart contracts",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",