@cowprotocol/sdk-flash-loans 1.5.0 → 1.5.2

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.d.mts CHANGED
@@ -119,6 +119,12 @@ declare const AAVE_DAPP_ID_PER_TYPE: Record<AaveFlashLoanType, string>;
119
119
  * @param {Record<AaveFlashLoanType, Record<SupportedChainId, string>>} hookAdapterPerType -
120
120
  * Mapping of flash loan types to chain-specific hook adapter addresses.
121
121
  * Defaults to the predefined addresses from the constants.
122
+ * @param {Record<SupportedChainId, string>} aaveAdapterFactory -
123
+ * Mapping of chain IDs to Aave adapter factory addresses.
124
+ * Defaults to the predefined addresses from the constants.
125
+ * @param {Record<SupportedChainId, string>} aavePoolAddress -
126
+ * Mapping of chain IDs to Aave pool addresses.
127
+ * Defaults to the predefined addresses from the constants.
122
128
  * @example
123
129
  * ```typescript
124
130
  * const config: AaveCollateralSwapSdkConfig = {
@@ -127,13 +133,22 @@ declare const AAVE_DAPP_ID_PER_TYPE: Record<AaveFlashLoanType, string>;
127
133
  * [SupportedChainId.GNOSIS_CHAIN]: '0x...',
128
134
  * },
129
135
  * },
136
+ * aaveAdapterFactory: {
137
+ * [SupportedChainId.MAINNET]: '0x...',
138
+ * },
139
+ * aavePoolAddress: {
140
+ * [SupportedChainId.MAINNET]: '0x...',
141
+ * },
130
142
  * }
131
143
  * ```
132
144
  */
133
145
  type AaveCollateralSwapSdkConfig = {
134
146
  hookAdapterPerType?: Record<AaveFlashLoanType, Record<SupportedChainId, string>>;
147
+ aaveAdapterFactory?: Record<SupportedChainId, string>;
148
+ aavePoolAddress?: Record<SupportedChainId, string>;
135
149
  };
136
150
  /**
151
+ >>>>>>> Stashed changes
137
152
  * SDK for executing Aave flash loan operations, particularly collateral swaps.
138
153
  *
139
154
  * @remarks This SDK facilitates flash loan-based collateral swaps using Aave Protocol V3,
@@ -145,6 +160,8 @@ type AaveCollateralSwapSdkConfig = {
145
160
  */
146
161
  declare class AaveCollateralSwapSdk {
147
162
  private readonly hookAdapterPerType;
163
+ private readonly aaveAdapterFactory;
164
+ private readonly aavePoolAddress;
148
165
  /**
149
166
  * Creates an instance of AaveCollateralSwapSdk.
150
167
  *
@@ -152,6 +169,12 @@ declare class AaveCollateralSwapSdk {
152
169
  * @param {Record<AaveFlashLoanType, Record<SupportedChainId, string>>} config.hookAdapterPerType -
153
170
  * Mapping of flash loan types to chain-specific hook adapter addresses.
154
171
  * Defaults to the predefined addresses from the constants.
172
+ * @param {Record<SupportedChainId, string>} config.aaveAdapterFactory -
173
+ * Mapping of chain IDs to Aave adapter factory addresses.
174
+ * Defaults to the predefined addresses from the constants.
175
+ * @param {Record<SupportedChainId, string>} config.aavePoolAddress -
176
+ * Mapping of chain IDs to Aave pool addresses.
177
+ * Defaults to the predefined addresses from the constants.
155
178
  */
156
179
  constructor(config?: AaveCollateralSwapSdkConfig);
157
180
  /**
package/dist/index.d.ts CHANGED
@@ -119,6 +119,12 @@ declare const AAVE_DAPP_ID_PER_TYPE: Record<AaveFlashLoanType, string>;
119
119
  * @param {Record<AaveFlashLoanType, Record<SupportedChainId, string>>} hookAdapterPerType -
120
120
  * Mapping of flash loan types to chain-specific hook adapter addresses.
121
121
  * Defaults to the predefined addresses from the constants.
122
+ * @param {Record<SupportedChainId, string>} aaveAdapterFactory -
123
+ * Mapping of chain IDs to Aave adapter factory addresses.
124
+ * Defaults to the predefined addresses from the constants.
125
+ * @param {Record<SupportedChainId, string>} aavePoolAddress -
126
+ * Mapping of chain IDs to Aave pool addresses.
127
+ * Defaults to the predefined addresses from the constants.
122
128
  * @example
123
129
  * ```typescript
124
130
  * const config: AaveCollateralSwapSdkConfig = {
@@ -127,13 +133,22 @@ declare const AAVE_DAPP_ID_PER_TYPE: Record<AaveFlashLoanType, string>;
127
133
  * [SupportedChainId.GNOSIS_CHAIN]: '0x...',
128
134
  * },
129
135
  * },
136
+ * aaveAdapterFactory: {
137
+ * [SupportedChainId.MAINNET]: '0x...',
138
+ * },
139
+ * aavePoolAddress: {
140
+ * [SupportedChainId.MAINNET]: '0x...',
141
+ * },
130
142
  * }
131
143
  * ```
132
144
  */
133
145
  type AaveCollateralSwapSdkConfig = {
134
146
  hookAdapterPerType?: Record<AaveFlashLoanType, Record<SupportedChainId, string>>;
147
+ aaveAdapterFactory?: Record<SupportedChainId, string>;
148
+ aavePoolAddress?: Record<SupportedChainId, string>;
135
149
  };
136
150
  /**
151
+ >>>>>>> Stashed changes
137
152
  * SDK for executing Aave flash loan operations, particularly collateral swaps.
138
153
  *
139
154
  * @remarks This SDK facilitates flash loan-based collateral swaps using Aave Protocol V3,
@@ -145,6 +160,8 @@ type AaveCollateralSwapSdkConfig = {
145
160
  */
146
161
  declare class AaveCollateralSwapSdk {
147
162
  private readonly hookAdapterPerType;
163
+ private readonly aaveAdapterFactory;
164
+ private readonly aavePoolAddress;
148
165
  /**
149
166
  * Creates an instance of AaveCollateralSwapSdk.
150
167
  *
@@ -152,6 +169,12 @@ declare class AaveCollateralSwapSdk {
152
169
  * @param {Record<AaveFlashLoanType, Record<SupportedChainId, string>>} config.hookAdapterPerType -
153
170
  * Mapping of flash loan types to chain-specific hook adapter addresses.
154
171
  * Defaults to the predefined addresses from the constants.
172
+ * @param {Record<SupportedChainId, string>} config.aaveAdapterFactory -
173
+ * Mapping of chain IDs to Aave adapter factory addresses.
174
+ * Defaults to the predefined addresses from the constants.
175
+ * @param {Record<SupportedChainId, string>} config.aavePoolAddress -
176
+ * Mapping of chain IDs to Aave pool addresses.
177
+ * Defaults to the predefined addresses from the constants.
155
178
  */
156
179
  constructor(config?: AaveCollateralSwapSdkConfig);
157
180
  /**
package/dist/index.js CHANGED
@@ -438,6 +438,8 @@ var repayWithCollateralAdapterAbi = [
438
438
  // src/aave/AaveCollateralSwapSdk.ts
439
439
  var AaveCollateralSwapSdk = class {
440
440
  hookAdapterPerType;
441
+ aaveAdapterFactory;
442
+ aavePoolAddress;
441
443
  /**
442
444
  * Creates an instance of AaveCollateralSwapSdk.
443
445
  *
@@ -445,9 +447,17 @@ var AaveCollateralSwapSdk = class {
445
447
  * @param {Record<AaveFlashLoanType, Record<SupportedChainId, string>>} config.hookAdapterPerType -
446
448
  * Mapping of flash loan types to chain-specific hook adapter addresses.
447
449
  * Defaults to the predefined addresses from the constants.
450
+ * @param {Record<SupportedChainId, string>} config.aaveAdapterFactory -
451
+ * Mapping of chain IDs to Aave adapter factory addresses.
452
+ * Defaults to the predefined addresses from the constants.
453
+ * @param {Record<SupportedChainId, string>} config.aavePoolAddress -
454
+ * Mapping of chain IDs to Aave pool addresses.
455
+ * Defaults to the predefined addresses from the constants.
448
456
  */
449
457
  constructor(config) {
450
458
  this.hookAdapterPerType = config?.hookAdapterPerType ?? AAVE_HOOK_ADAPTER_PER_TYPE;
459
+ this.aaveAdapterFactory = config?.aaveAdapterFactory ?? AAVE_ADAPTER_FACTORY;
460
+ this.aavePoolAddress = config?.aavePoolAddress ?? AAVE_POOL_ADDRESS;
451
461
  }
452
462
  /**
453
463
  * Executes a collateral swap using Aave flash loans.
@@ -590,9 +600,9 @@ var AaveCollateralSwapSdk = class {
590
600
  const flashLoanHint = {
591
601
  amount,
592
602
  // this is actually in UNDERLYING but aave tokens are 1:1
593
- receiver: AAVE_ADAPTER_FACTORY[chainId],
594
- liquidityProvider: AAVE_POOL_ADDRESS[chainId],
595
- protocolAdapter: AAVE_ADAPTER_FACTORY[chainId],
603
+ receiver: this.aaveAdapterFactory[chainId],
604
+ liquidityProvider: this.aavePoolAddress[chainId],
605
+ protocolAdapter: this.aaveAdapterFactory[chainId],
596
606
  token: orderToSign.sellToken
597
607
  };
598
608
  const hooks = await this.getOrderHooks(
@@ -703,7 +713,7 @@ var AaveCollateralSwapSdk = class {
703
713
  async getExpectedInstanceAddress(flashLoanType, chainId, trader, hookAmounts, order) {
704
714
  const hookData = this.buildHookOrderData(trader, hookAmounts, order);
705
715
  return await (0, import_sdk_common.getGlobalAdapter)().readContract({
706
- address: AAVE_ADAPTER_FACTORY[chainId],
716
+ address: this.aaveAdapterFactory[chainId],
707
717
  args: [this.hookAdapterPerType[flashLoanType][chainId], hookData],
708
718
  functionName: "getInstanceDeterministicAddress",
709
719
  abi: aaveAdapterFactoryAbi
@@ -792,7 +802,7 @@ var AaveCollateralSwapSdk = class {
792
802
  return {
793
803
  pre: [
794
804
  {
795
- target: AAVE_ADAPTER_FACTORY[chainId],
805
+ target: this.aaveAdapterFactory[chainId],
796
806
  callData: preHookCallData,
797
807
  gasLimit: DEFAULT_HOOK_GAS_LIMIT.pre.toString(),
798
808
  dappId
@@ -809,7 +819,7 @@ var AaveCollateralSwapSdk = class {
809
819
  };
810
820
  }
811
821
  async adapterEIP1271Signature(chainId, instanceAddress, orderToSign, signer) {
812
- const adapterFactoryAddress = AAVE_ADAPTER_FACTORY[chainId];
822
+ const adapterFactoryAddress = this.aaveAdapterFactory[chainId];
813
823
  const encodedOrder = import_sdk_order_signing.OrderSigningUtils.encodeUnsignedOrder(orderToSign);
814
824
  const domain = {
815
825
  name: ADAPTER_DOMAIN_NAME,
package/dist/index.mjs CHANGED
@@ -401,6 +401,8 @@ var repayWithCollateralAdapterAbi = [
401
401
  // src/aave/AaveCollateralSwapSdk.ts
402
402
  var AaveCollateralSwapSdk = class {
403
403
  hookAdapterPerType;
404
+ aaveAdapterFactory;
405
+ aavePoolAddress;
404
406
  /**
405
407
  * Creates an instance of AaveCollateralSwapSdk.
406
408
  *
@@ -408,9 +410,17 @@ var AaveCollateralSwapSdk = class {
408
410
  * @param {Record<AaveFlashLoanType, Record<SupportedChainId, string>>} config.hookAdapterPerType -
409
411
  * Mapping of flash loan types to chain-specific hook adapter addresses.
410
412
  * Defaults to the predefined addresses from the constants.
413
+ * @param {Record<SupportedChainId, string>} config.aaveAdapterFactory -
414
+ * Mapping of chain IDs to Aave adapter factory addresses.
415
+ * Defaults to the predefined addresses from the constants.
416
+ * @param {Record<SupportedChainId, string>} config.aavePoolAddress -
417
+ * Mapping of chain IDs to Aave pool addresses.
418
+ * Defaults to the predefined addresses from the constants.
411
419
  */
412
420
  constructor(config) {
413
421
  this.hookAdapterPerType = config?.hookAdapterPerType ?? AAVE_HOOK_ADAPTER_PER_TYPE;
422
+ this.aaveAdapterFactory = config?.aaveAdapterFactory ?? AAVE_ADAPTER_FACTORY;
423
+ this.aavePoolAddress = config?.aavePoolAddress ?? AAVE_POOL_ADDRESS;
414
424
  }
415
425
  /**
416
426
  * Executes a collateral swap using Aave flash loans.
@@ -553,9 +563,9 @@ var AaveCollateralSwapSdk = class {
553
563
  const flashLoanHint = {
554
564
  amount,
555
565
  // this is actually in UNDERLYING but aave tokens are 1:1
556
- receiver: AAVE_ADAPTER_FACTORY[chainId],
557
- liquidityProvider: AAVE_POOL_ADDRESS[chainId],
558
- protocolAdapter: AAVE_ADAPTER_FACTORY[chainId],
566
+ receiver: this.aaveAdapterFactory[chainId],
567
+ liquidityProvider: this.aavePoolAddress[chainId],
568
+ protocolAdapter: this.aaveAdapterFactory[chainId],
559
569
  token: orderToSign.sellToken
560
570
  };
561
571
  const hooks = await this.getOrderHooks(
@@ -666,7 +676,7 @@ var AaveCollateralSwapSdk = class {
666
676
  async getExpectedInstanceAddress(flashLoanType, chainId, trader, hookAmounts, order) {
667
677
  const hookData = this.buildHookOrderData(trader, hookAmounts, order);
668
678
  return await getGlobalAdapter().readContract({
669
- address: AAVE_ADAPTER_FACTORY[chainId],
679
+ address: this.aaveAdapterFactory[chainId],
670
680
  args: [this.hookAdapterPerType[flashLoanType][chainId], hookData],
671
681
  functionName: "getInstanceDeterministicAddress",
672
682
  abi: aaveAdapterFactoryAbi
@@ -755,7 +765,7 @@ var AaveCollateralSwapSdk = class {
755
765
  return {
756
766
  pre: [
757
767
  {
758
- target: AAVE_ADAPTER_FACTORY[chainId],
768
+ target: this.aaveAdapterFactory[chainId],
759
769
  callData: preHookCallData,
760
770
  gasLimit: DEFAULT_HOOK_GAS_LIMIT.pre.toString(),
761
771
  dappId
@@ -772,7 +782,7 @@ var AaveCollateralSwapSdk = class {
772
782
  };
773
783
  }
774
784
  async adapterEIP1271Signature(chainId, instanceAddress, orderToSign, signer) {
775
- const adapterFactoryAddress = AAVE_ADAPTER_FACTORY[chainId];
785
+ const adapterFactoryAddress = this.aaveAdapterFactory[chainId];
776
786
  const encodedOrder = OrderSigningUtils.encodeUnsignedOrder(orderToSign);
777
787
  const domain = {
778
788
  name: ADAPTER_DOMAIN_NAME,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/sdk-flash-loans",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "Flash loans for CoW Protocol",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -14,12 +14,12 @@
14
14
  "access": "public"
15
15
  },
16
16
  "dependencies": {
17
- "@cowprotocol/sdk-app-data": "4.1.6",
18
17
  "@cowprotocol/sdk-common": "0.3.0",
19
- "@cowprotocol/sdk-order-book": "0.2.0",
20
- "@cowprotocol/sdk-config": "0.3.0",
18
+ "@cowprotocol/sdk-app-data": "4.1.6",
21
19
  "@cowprotocol/sdk-trading": "0.4.6",
22
- "@cowprotocol/sdk-order-signing": "0.1.11"
20
+ "@cowprotocol/sdk-order-signing": "0.1.11",
21
+ "@cowprotocol/sdk-order-book": "0.2.0",
22
+ "@cowprotocol/sdk-config": "0.3.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "ethers-v5": "npm:ethers@^5.7.2",
@@ -34,10 +34,10 @@
34
34
  "ts-jest": "^29.0.0",
35
35
  "ethers": "^5.7.2",
36
36
  "viem": "2.30.5",
37
- "@cow-sdk/typescript-config": "0.0.0-beta.0",
38
37
  "@cowprotocol/sdk-ethers-v5-adapter": "0.2.0",
39
- "@cowprotocol/sdk-viem-adapter": "0.2.0",
40
- "@cowprotocol/sdk-ethers-v6-adapter": "0.2.0"
38
+ "@cowprotocol/sdk-ethers-v6-adapter": "0.2.0",
39
+ "@cow-sdk/typescript-config": "0.0.0-beta.0",
40
+ "@cowprotocol/sdk-viem-adapter": "0.2.0"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "tsup src/index.ts --format esm,cjs --dts",