@defisaver/sdk 1.3.38-semi-continuous-dev → 1.3.39

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.
Files changed (98) hide show
  1. package/docs/DEV.md +37 -0
  2. package/esm/src/actions/aaveV3/AaveV3SetEModeAction.d.ts +3 -2
  3. package/esm/src/actions/aaveV3/AaveV3SetEModeAction.js +7 -3
  4. package/esm/src/actions/flashloan/AaveV2FlashLoanAction.d.ts +2 -4
  5. package/esm/src/actions/flashloan/AaveV2FlashLoanAction.js +7 -4
  6. package/esm/src/actions/flashloan/AaveV3FlashLoanAction.d.ts +2 -4
  7. package/esm/src/actions/flashloan/AaveV3FlashLoanAction.js +7 -4
  8. package/esm/src/actions/flashloan/BalancerFlashLoanAction.d.ts +2 -4
  9. package/esm/src/actions/flashloan/BalancerFlashLoanAction.js +7 -4
  10. package/esm/src/actions/flashloan/BalancerV3FlashLoanAction.d.ts +2 -4
  11. package/esm/src/actions/flashloan/BalancerV3FlashLoanAction.js +7 -20
  12. package/esm/src/actions/flashloan/CurveUsdFlashLoanAction.d.ts +2 -4
  13. package/esm/src/actions/flashloan/CurveUsdFlashLoanAction.js +7 -4
  14. package/esm/src/actions/flashloan/FLAction.d.ts +7 -5
  15. package/esm/src/actions/flashloan/FLAction.js +12 -20
  16. package/esm/src/actions/flashloan/FLSource.d.ts +18 -0
  17. package/esm/src/actions/flashloan/FLSource.js +42 -0
  18. package/esm/src/actions/flashloan/FlashLoanId.d.ts +2 -1
  19. package/esm/src/actions/flashloan/GhoFlashLoanAction.d.ts +2 -4
  20. package/esm/src/actions/flashloan/GhoFlashLoanAction.js +7 -4
  21. package/esm/src/actions/flashloan/MakerFlashLoanAction.d.ts +2 -4
  22. package/esm/src/actions/flashloan/MakerFlashLoanAction.js +7 -4
  23. package/esm/src/actions/flashloan/MorphoBlueFlashLoanAction.d.ts +2 -4
  24. package/esm/src/actions/flashloan/MorphoBlueFlashLoanAction.js +7 -4
  25. package/esm/src/actions/flashloan/SparkFlashLoanAction.d.ts +2 -4
  26. package/esm/src/actions/flashloan/SparkFlashLoanAction.js +7 -4
  27. package/esm/src/actions/flashloan/UniV3FlashLoanAction.d.ts +2 -4
  28. package/esm/src/actions/flashloan/UniV3FlashLoanAction.js +7 -4
  29. package/esm/src/actions/flashloan/index.d.ts +1 -14
  30. package/esm/src/actions/flashloan/index.js +1 -14
  31. package/esm/src/addresses.d.ts +1 -67
  32. package/esm/src/addresses.js +111 -93
  33. package/esm/src/index.d.ts +4 -268
  34. package/package.json +1 -1
  35. package/src/actions/aaveV3/AaveV3SetEModeAction.ts +13 -4
  36. package/src/actions/flashloan/AaveV2FlashLoanAction.ts +7 -11
  37. package/src/actions/flashloan/AaveV3FlashLoanAction.ts +7 -11
  38. package/src/actions/flashloan/BalancerFlashLoanAction.ts +7 -11
  39. package/src/actions/flashloan/BalancerV3FlashLoanAction.ts +7 -27
  40. package/src/actions/flashloan/CurveUsdFlashLoanAction.ts +7 -11
  41. package/src/actions/flashloan/FLAction.ts +18 -21
  42. package/src/actions/flashloan/FLSource.ts +44 -0
  43. package/src/actions/flashloan/FlashLoanId.ts +3 -1
  44. package/src/actions/flashloan/GhoFlashLoanAction.ts +7 -11
  45. package/src/actions/flashloan/MakerFlashLoanAction.ts +7 -11
  46. package/src/actions/flashloan/MorphoBlueFlashLoanAction.ts +7 -11
  47. package/src/actions/flashloan/SparkFlashLoanAction.ts +7 -11
  48. package/src/actions/flashloan/UniV3FlashLoanAction.ts +7 -11
  49. package/src/actions/flashloan/index.ts +1 -14
  50. package/src/addresses.ts +133 -96
  51. package/test/accessLists/Recipe.js +1 -1
  52. package/test/accessLists/access-lists.js +1 -1
  53. package/test/actions/aaveV3/AaveV3SetEModeAction.js +42 -0
  54. package/test/actions/flashloan/FLAction.js +77 -0
  55. package/umd/index.js +1103 -1444
  56. package/esm/src/actions/flashloan/AaveV2FlashLoanPaybackAction.d.ts +0 -14
  57. package/esm/src/actions/flashloan/AaveV2FlashLoanPaybackAction.js +0 -16
  58. package/esm/src/actions/flashloan/AaveV3FlashLoanNoFeeAction.d.ts +0 -18
  59. package/esm/src/actions/flashloan/AaveV3FlashLoanNoFeeAction.js +0 -20
  60. package/esm/src/actions/flashloan/AaveV3FlashLoanNoFeePaybackAction.d.ts +0 -14
  61. package/esm/src/actions/flashloan/AaveV3FlashLoanNoFeePaybackAction.js +0 -16
  62. package/esm/src/actions/flashloan/AaveV3FlashLoanPaybackAction.d.ts +0 -14
  63. package/esm/src/actions/flashloan/AaveV3FlashLoanPaybackAction.js +0 -16
  64. package/esm/src/actions/flashloan/BalancerFlashLoanPaybackAction.d.ts +0 -14
  65. package/esm/src/actions/flashloan/BalancerFlashLoanPaybackAction.js +0 -16
  66. package/esm/src/actions/flashloan/DyDxFlashLoanAction.d.ts +0 -16
  67. package/esm/src/actions/flashloan/DyDxFlashLoanAction.js +0 -18
  68. package/esm/src/actions/flashloan/DyDxFlashLoanPaybackAction.d.ts +0 -14
  69. package/esm/src/actions/flashloan/DyDxFlashLoanPaybackAction.js +0 -16
  70. package/esm/src/actions/flashloan/EulerFlashLoanAction.d.ts +0 -16
  71. package/esm/src/actions/flashloan/EulerFlashLoanAction.js +0 -18
  72. package/esm/src/actions/flashloan/EulerFlashLoanPaybackAction.d.ts +0 -14
  73. package/esm/src/actions/flashloan/EulerFlashLoanPaybackAction.js +0 -16
  74. package/esm/src/actions/flashloan/GhoFlashLoanPaybackAction.d.ts +0 -13
  75. package/esm/src/actions/flashloan/GhoFlashLoanPaybackAction.js +0 -15
  76. package/esm/src/actions/flashloan/MakerFlashLoanPaybackAction.d.ts +0 -13
  77. package/esm/src/actions/flashloan/MakerFlashLoanPaybackAction.js +0 -15
  78. package/esm/src/actions/flashloan/MorphoBlueFlashLoanPaybackAction.d.ts +0 -14
  79. package/esm/src/actions/flashloan/MorphoBlueFlashLoanPaybackAction.js +0 -16
  80. package/esm/src/actions/flashloan/SparkFlashLoanPaybackAction.d.ts +0 -14
  81. package/esm/src/actions/flashloan/SparkFlashLoanPaybackAction.js +0 -16
  82. package/esm/src/actions/flashloan/UniV3FlashLoanPaybackAction.d.ts +0 -16
  83. package/esm/src/actions/flashloan/UniV3FlashLoanPaybackAction.js +0 -18
  84. package/src/actions/flashloan/AaveV2FlashLoanPaybackAction.ts +0 -18
  85. package/src/actions/flashloan/AaveV3FlashLoanNoFeeAction.ts +0 -27
  86. package/src/actions/flashloan/AaveV3FlashLoanNoFeePaybackAction.ts +0 -18
  87. package/src/actions/flashloan/AaveV3FlashLoanPaybackAction.ts +0 -18
  88. package/src/actions/flashloan/BalancerFlashLoanPaybackAction.ts +0 -18
  89. package/src/actions/flashloan/DyDxFlashLoanAction.ts +0 -24
  90. package/src/actions/flashloan/DyDxFlashLoanPaybackAction.ts +0 -18
  91. package/src/actions/flashloan/EulerFlashLoanAction.ts +0 -25
  92. package/src/actions/flashloan/EulerFlashLoanPaybackAction.ts +0 -18
  93. package/src/actions/flashloan/GhoFlashLoanPaybackAction.ts +0 -17
  94. package/src/actions/flashloan/MakerFlashLoanPaybackAction.ts +0 -17
  95. package/src/actions/flashloan/MorphoBlueFlashLoanPaybackAction.ts +0 -18
  96. package/src/actions/flashloan/SparkFlashLoanPaybackAction.ts +0 -18
  97. package/src/actions/flashloan/UniV3FlashLoanPaybackAction.ts +0 -20
  98. package/test/actions/flashloan/DyDxFlashLoanAction.js +0 -84
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/sdk",
3
- "version": "1.3.38-semi-continuous-dev",
3
+ "version": "1.3.39",
4
4
  "description": "",
5
5
  "main": "./umd/index.js",
6
6
  "module": "./esm/src/index.js",
@@ -2,7 +2,7 @@ import { ActionWithL2 } from '../../ActionWithL2';
2
2
  import { getAddr } from '../../addresses';
3
3
  import { EthAddress, uint8 } from '../../types';
4
4
  /**
5
- * AaveV3SetEModeAction - Set EMode for the proxy AaveV3 position
5
+ * AaveV3SetEModeAction - Set EMode for an AaveV3 position
6
6
  *
7
7
  * @category AaveV3
8
8
  */
@@ -11,15 +11,22 @@ export class AaveV3SetEModeAction extends ActionWithL2 {
11
11
  * @param useOnDefaultMarket If this is true it defaults to the hardcoded market in contract
12
12
  * @param market Address provider for specific market
13
13
  * @param categoryId ID of the category emode
14
+ * @param onBehalf Address of the position owner, defaults to proxy
14
15
  */
15
- constructor(useOnDefaultMarket: boolean, market: EthAddress, categoryId: uint8) {
16
+ constructor(
17
+ useOnDefaultMarket: boolean,
18
+ market: EthAddress,
19
+ categoryId: uint8,
20
+ onBehalf: EthAddress = getAddr('Empty'),
21
+ ) {
16
22
  super('AaveV3SetEMode', getAddr('AaveV3SetEMode'),
17
- ['uint8', 'bool', 'address'],
18
- [categoryId, useOnDefaultMarket, market],
23
+ ['uint8', 'bool', 'address', 'address'],
24
+ [categoryId, useOnDefaultMarket, market, onBehalf],
19
25
  );
20
26
 
21
27
  this.mappableArgs = [
22
28
  this.args[2],
29
+ this.args[3],
23
30
  ];
24
31
  }
25
32
 
@@ -34,6 +41,8 @@ export class AaveV3SetEModeAction extends ActionWithL2 {
34
41
  // market
35
42
  encodedInput = encodedInput.concat(this.addressToBytes20(this.args[2]));
36
43
  }
44
+ // onBehalf
45
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[3]));
37
46
 
38
47
  return encodedInput;
39
48
  }
@@ -1,16 +1,14 @@
1
- import { Action } from '../../Action';
1
+ import { FLAction } from './FLAction';
2
2
  import { getAddr } from '../../addresses';
3
3
  import { EthAddress, uint256, bytes } from '../../types';
4
- import { FlashLoanId } from './FlashLoanId';
4
+ import { FLSource } from './FLSource';
5
5
 
6
6
  /**
7
7
  * Gets a flashloan from Aave v2
8
8
  *
9
9
  * @category Flashloans
10
10
  */
11
- export class AaveV2FlashLoanAction extends Action implements FlashLoanId {
12
- public flashLoanId = 1;
13
-
11
+ export class AaveV2FlashLoanAction extends FLAction {
14
12
  /**
15
13
  * @param loanAmounts
16
14
  * @param tokens
@@ -20,11 +18,9 @@ export class AaveV2FlashLoanAction extends Action implements FlashLoanId {
20
18
  * @param flParamGetterData
21
19
  */
22
20
  constructor(tokens: Array<EthAddress>, loanAmounts: Array<uint256>, modes: Array<uint256>, loanPayer: EthAddress, flParamGetterAddr: EthAddress = getAddr('Empty'), flParamGetterData: bytes = []) {
23
- super(
24
- 'FLAaveV2',
25
- getAddr('FLAaveV2'),
26
- ['address[]', 'uint256[]', 'uint256[]', 'address', 'address', 'bytes', 'bytes'],
27
- [tokens, loanAmounts, modes, loanPayer, flParamGetterAddr, flParamGetterData, []],
28
- );
21
+ super({
22
+ flashLoanId: FLSource.AAVEV2,
23
+ args: [tokens, loanAmounts, modes, loanPayer, flParamGetterAddr, flParamGetterData, []],
24
+ });
29
25
  }
30
26
  }
@@ -1,16 +1,14 @@
1
- import { ActionWithL2 } from '../../ActionWithL2';
1
+ import { FLAction } from './FLAction';
2
2
  import { getAddr } from '../../addresses';
3
3
  import { EthAddress, uint256, bytes } from '../../types';
4
- import { FlashLoanId } from './FlashLoanId';
4
+ import { FLSource } from './FLSource';
5
5
 
6
6
  /**
7
7
  * Gets a flashloan from Aave v3 with fee enabled
8
8
  *
9
9
  * @category Flashloans
10
10
  */
11
- export class AaveV3FlashLoanAction extends ActionWithL2 implements FlashLoanId {
12
- public flashLoanId = 5;
13
-
11
+ export class AaveV3FlashLoanAction extends FLAction {
14
12
  /**
15
13
  * @param tokens
16
14
  * @param loanAmounts
@@ -20,11 +18,9 @@ export class AaveV3FlashLoanAction extends ActionWithL2 implements FlashLoanId {
20
18
  * @param flParamGetterData
21
19
  */
22
20
  constructor(tokens: Array<EthAddress>, loanAmounts: Array<uint256>, modes: Array<uint256>, loanPayer: EthAddress, flParamGetterAddr: EthAddress = getAddr('Empty'), flParamGetterData: bytes = []) {
23
- super(
24
- 'FLAaveV3WithFee',
25
- getAddr('FLAaveV3'),
26
- ['address[]', 'uint256[]', 'uint256[]', 'address', 'address', 'bytes', 'bytes'],
27
- [tokens, loanAmounts, modes, loanPayer, flParamGetterAddr, flParamGetterData, []],
28
- );
21
+ super({
22
+ flashLoanId: FLSource.AAVEV3,
23
+ args: [tokens, loanAmounts, modes, loanPayer, flParamGetterAddr, flParamGetterData, []],
24
+ });
29
25
  }
30
26
  }
@@ -1,16 +1,14 @@
1
- import { Action } from '../../Action';
1
+ import { FLAction } from './FLAction';
2
2
  import { getAddr } from '../../addresses';
3
3
  import { EthAddress, uint256, bytes } from '../../types';
4
- import { FlashLoanId } from './FlashLoanId';
4
+ import { FLSource } from './FLSource';
5
5
 
6
6
  /**
7
7
  * Gets a flashloan from Balancer
8
8
  *
9
9
  * @category Flashloans
10
10
  */
11
- export class BalancerFlashLoanAction extends Action implements FlashLoanId {
12
- public flashLoanId = 2;
13
-
11
+ export class BalancerFlashLoanAction extends FLAction {
14
12
  /**
15
13
  * @param tokens
16
14
  * @param amounts
@@ -18,11 +16,9 @@ export class BalancerFlashLoanAction extends Action implements FlashLoanId {
18
16
  * @param flParamGetterData
19
17
  */
20
18
  constructor(tokens: Array<EthAddress>, amounts: Array<uint256>, flParamGetterAddr: EthAddress = getAddr('Empty'), flParamGetterData: bytes = []) {
21
- super(
22
- 'FLBalancer',
23
- getAddr('FLBalancer'),
24
- ['address[]', 'uint256[]', 'uint256[]', 'address', 'address', 'bytes', 'bytes'],
25
- [tokens, amounts, [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
26
- );
19
+ super({
20
+ flashLoanId: FLSource.BALANCER,
21
+ args: [tokens, amounts, [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
22
+ });
27
23
  }
28
24
  }
@@ -1,16 +1,14 @@
1
- import { Action } from '../../Action';
1
+ import { FLAction } from './FLAction';
2
2
  import { getAddr } from '../../addresses';
3
3
  import { EthAddress, uint256, bytes } from '../../types';
4
- import { FlashLoanId } from './FlashLoanId';
4
+ import { FLSource } from './FLSource';
5
5
 
6
6
  /**
7
7
  * Gets a flashloan from BalancerV3
8
8
  *
9
9
  * @category Flashloans
10
10
  */
11
- export class BalancerV3FlashLoanAction extends Action implements FlashLoanId {
12
- public flashLoanId = 10;
13
-
11
+ export class BalancerV3FlashLoanAction extends FLAction {
14
12
  /**
15
13
  * @param tokens
16
14
  * @param loanAmounts
@@ -23,27 +21,9 @@ export class BalancerV3FlashLoanAction extends Action implements FlashLoanId {
23
21
  flParamGetterAddr: EthAddress = getAddr('Empty'),
24
22
  flParamGetterData: bytes = [],
25
23
  ) {
26
- super(
27
- 'FLAction',
28
- getAddr('FLAction'),
29
- [
30
- 'address[]',
31
- 'uint256[]',
32
- 'uint256[]',
33
- 'address',
34
- 'address',
35
- 'bytes',
36
- 'bytes',
37
- ],
38
- [
39
- tokens,
40
- loanAmounts,
41
- [],
42
- getAddr('Empty'),
43
- flParamGetterAddr,
44
- flParamGetterData,
45
- [],
46
- ],
47
- );
24
+ super({
25
+ flashLoanId: FLSource.BALANCER_V3,
26
+ args: [tokens, loanAmounts, [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
27
+ });
48
28
  }
49
29
  }
@@ -1,27 +1,23 @@
1
- import { Action } from '../../Action';
1
+ import { FLAction } from './FLAction';
2
2
  import { getAddr } from '../../addresses';
3
3
  import { EthAddress, uint256, bytes } from '../../types';
4
- import { FlashLoanId } from './FlashLoanId';
4
+ import { FLSource } from './FLSource';
5
5
 
6
6
  /**
7
7
  * Gets a crvUSD flashloan from CurveUsd Flash Minter
8
8
  *
9
9
  * @category Flashloans
10
10
  */
11
- export class CurveUsdFlashLoanAction extends Action implements FlashLoanId {
12
- public flashLoanId = 9;
13
-
11
+ export class CurveUsdFlashLoanAction extends FLAction {
14
12
  /**
15
13
  * @param amount
16
14
  * @param flParamGetterAddr
17
15
  * @param flParamGetterData
18
16
  */
19
17
  constructor(amount: uint256, flParamGetterAddr: EthAddress = getAddr('Empty'), flParamGetterData: bytes = []) {
20
- super(
21
- 'FLAction',
22
- getAddr('FLAction'),
23
- ['address[]', 'uint256[]', 'uint256[]', 'address', 'address', 'bytes', 'bytes'],
24
- [[], [amount], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
25
- );
18
+ super({
19
+ flashLoanId: FLSource.CURVEUSD,
20
+ args: [[], [amount], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
21
+ });
26
22
  }
27
23
  }
@@ -1,33 +1,21 @@
1
1
  import { Action } from '../../Action';
2
2
  import { getAddr } from '../../addresses';
3
3
  import { FlashLoanId } from './FlashLoanId';
4
- import { ActionWithL2 } from '../../ActionWithL2';
4
+ import { FLSource, assertFlashLoanSourceSupported } from './FLSource';
5
5
  /**
6
- * Gets a specific FL action
6
+ * Executes a supported provider through the unified FLAction contract.
7
+ * The inner action's arguments and flashLoanId are used.
8
+ * Repay with FLPaybackAction or send tokens to FLAction.
7
9
  *
8
10
  * @category Flashloans
9
11
  */
10
- type SpecificFlashLoanAction = (Action & FlashLoanId) | (ActionWithL2 & FlashLoanId);
12
+ type SpecificFlashLoanAction = FlashLoanId & Pick<Action, 'args'>;
11
13
 
12
- export class FLAction extends Action {
13
- /**
14
- * @param specificFLAction - FL Action to be used
15
- */
16
- #handleArgs(specificFLAction: SpecificFlashLoanAction) {
17
- const argsToReturn = [
18
- specificFLAction.args[0],
19
- specificFLAction.args[1],
20
- specificFLAction.args[2],
21
- specificFLAction.args[3],
22
- getAddr('Empty'),
23
- [specificFLAction.flashLoanId],
24
- specificFLAction.args[6],
25
- ];
26
-
27
- return argsToReturn;
28
- }
14
+ export class FLAction extends Action implements FlashLoanId {
15
+ public flashLoanId: FLSource;
29
16
 
30
17
  constructor(specificFLAction: SpecificFlashLoanAction) {
18
+ assertFlashLoanSourceSupported(specificFLAction?.flashLoanId);
31
19
  super(
32
20
  'FLAction',
33
21
  getAddr('FLAction'),
@@ -35,6 +23,15 @@ export class FLAction extends Action {
35
23
  [],
36
24
  );
37
25
  this.paramTypes = ['address[]', 'uint256[]', 'uint256[]', 'address', 'address', 'bytes', 'bytes'];
38
- this.args = this.#handleArgs(specificFLAction);
26
+ this.flashLoanId = specificFLAction.flashLoanId;
27
+ this.args = [
28
+ specificFLAction.args[0],
29
+ specificFLAction.args[1],
30
+ specificFLAction.args[2],
31
+ specificFLAction.args[3],
32
+ getAddr('Empty'),
33
+ [this.flashLoanId],
34
+ specificFLAction.args[6],
35
+ ];
39
36
  }
40
37
  }
@@ -0,0 +1,44 @@
1
+ import { CONFIG, NETWORKS } from '../../config';
2
+
3
+ /** Must match the unified FLAction contract's FLSource enum. */
4
+ export enum FLSource {
5
+ EMPTY,
6
+ AAVEV2,
7
+ BALANCER,
8
+ GHO,
9
+ MAKER,
10
+ AAVEV3,
11
+ UNIV3,
12
+ SPARK,
13
+ MORPHO_BLUE,
14
+ CURVEUSD,
15
+ BALANCER_V3,
16
+ }
17
+
18
+ /** Provider support in the current unified deployments. */
19
+ export const supportedFlashLoanSources: Readonly<Record<number, readonly FLSource[]>> = {
20
+ [NETWORKS.ethereum.chainId]: [
21
+ FLSource.AAVEV2, FLSource.BALANCER, FLSource.GHO, FLSource.MAKER,
22
+ FLSource.AAVEV3, FLSource.UNIV3, FLSource.SPARK, FLSource.MORPHO_BLUE,
23
+ FLSource.CURVEUSD, FLSource.BALANCER_V3,
24
+ ],
25
+ [NETWORKS.arbitrum.chainId]: [
26
+ FLSource.BALANCER, FLSource.AAVEV3, FLSource.UNIV3, FLSource.MORPHO_BLUE, FLSource.BALANCER_V3,
27
+ ],
28
+ [NETWORKS.base.chainId]: [
29
+ FLSource.BALANCER, FLSource.AAVEV3, FLSource.UNIV3, FLSource.MORPHO_BLUE, FLSource.BALANCER_V3,
30
+ ],
31
+ [NETWORKS.optimism.chainId]: [
32
+ FLSource.BALANCER, FLSource.AAVEV3, FLSource.UNIV3, FLSource.BALANCER_V3,
33
+ ],
34
+ [NETWORKS.linea.chainId]: [FLSource.AAVEV3],
35
+ [NETWORKS.plasma.chainId]: [FLSource.AAVEV3, FLSource.BALANCER_V3],
36
+ };
37
+
38
+ export const isFlashLoanSourceSupported = (source: FLSource, chainId: number = CONFIG.chainId): boolean => supportedFlashLoanSources[chainId]?.includes(source) ?? false;
39
+
40
+ export const assertFlashLoanSourceSupported = (source: FLSource, chainId: number = CONFIG.chainId): void => {
41
+ if (!isFlashLoanSourceSupported(source, chainId)) {
42
+ throw new Error(`Flashloan source ${FLSource[source] ?? String(source)} is not supported by FLAction on chainId: ${chainId}.`);
43
+ }
44
+ };
@@ -1,3 +1,5 @@
1
+ import { FLSource } from './FLSource';
2
+
1
3
  export interface FlashLoanId {
2
- flashLoanId: number;
4
+ flashLoanId: FLSource;
3
5
  }
@@ -1,27 +1,23 @@
1
- import { Action } from '../../Action';
1
+ import { FLAction } from './FLAction';
2
2
  import { getAddr } from '../../addresses';
3
3
  import { EthAddress, uint256, bytes } from '../../types';
4
- import { FlashLoanId } from './FlashLoanId';
4
+ import { FLSource } from './FLSource';
5
5
 
6
6
  /**
7
7
  * Gets a GHO flashloan from GHO Flash Minter
8
8
  *
9
9
  * @category Flashloans
10
10
  */
11
- export class GhoFlashLoanAction extends Action implements FlashLoanId {
12
- public flashLoanId = 3;
13
-
11
+ export class GhoFlashLoanAction extends FLAction {
14
12
  /**
15
13
  * @param amount
16
14
  * @param flParamGetterAddr
17
15
  * @param flParamGetterData
18
16
  */
19
17
  constructor(amount: uint256, flParamGetterAddr: EthAddress = getAddr('Empty'), flParamGetterData: bytes = []) {
20
- super(
21
- 'FLGho',
22
- getAddr('FLGho'),
23
- ['address[]', 'uint256[]', 'uint256[]', 'address', 'address', 'bytes', 'bytes'],
24
- [[], [amount], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
25
- );
18
+ super({
19
+ flashLoanId: FLSource.GHO,
20
+ args: [[], [amount], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
21
+ });
26
22
  }
27
23
  }
@@ -1,27 +1,23 @@
1
- import { Action } from '../../Action';
1
+ import { FLAction } from './FLAction';
2
2
  import { getAddr } from '../../addresses';
3
3
  import { EthAddress, uint256, bytes } from '../../types';
4
- import { FlashLoanId } from './FlashLoanId';
4
+ import { FLSource } from './FLSource';
5
5
 
6
6
  /**
7
7
  * Gets a flashloan from Maker
8
8
  *
9
9
  * @category Flashloans
10
10
  */
11
- export class MakerFlashLoanAction extends Action implements FlashLoanId {
12
- public flashLoanId = 4;
13
-
11
+ export class MakerFlashLoanAction extends FLAction {
14
12
  /**
15
13
  * @param amount
16
14
  * @param flParamGetterAddr
17
15
  * @param flParamGetterData
18
16
  */
19
17
  constructor(amount: uint256, flParamGetterAddr: EthAddress = getAddr('Empty'), flParamGetterData: bytes = []) {
20
- super(
21
- 'FLMaker',
22
- getAddr('FLMaker'),
23
- ['address[]', 'uint256[]', 'uint256[]', 'address', 'address', 'bytes', 'bytes'],
24
- [[], [amount], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
25
- );
18
+ super({
19
+ flashLoanId: FLSource.MAKER,
20
+ args: [[], [amount], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
21
+ });
26
22
  }
27
23
  }
@@ -1,16 +1,14 @@
1
- import { Action } from '../../Action';
1
+ import { FLAction } from './FLAction';
2
2
  import { getAddr } from '../../addresses';
3
3
  import { EthAddress, uint256, bytes } from '../../types';
4
- import { FlashLoanId } from './FlashLoanId';
4
+ import { FLSource } from './FLSource';
5
5
 
6
6
  /**
7
7
  * Gets a flashloan from MorphoBlue
8
8
  *
9
9
  * @category Flashloans
10
10
  */
11
- export class MorphoBlueFlashLoanAction extends Action implements FlashLoanId {
12
- public flashLoanId = 8;
13
-
11
+ export class MorphoBlueFlashLoanAction extends FLAction {
14
12
  /**
15
13
  * @param token
16
14
  * @param amount
@@ -18,11 +16,9 @@ export class MorphoBlueFlashLoanAction extends Action implements FlashLoanId {
18
16
  * @param flParamGetterData
19
17
  */
20
18
  constructor(token: EthAddress, amount: uint256, flParamGetterAddr: EthAddress = getAddr('Empty'), flParamGetterData: bytes = []) {
21
- super(
22
- 'FLMorphoBlue',
23
- getAddr('FLMorphoBlue'),
24
- ['address[]', 'uint256[]', 'uint256[]', 'address', 'address', 'bytes', 'bytes'],
25
- [[token], [amount], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
26
- );
19
+ super({
20
+ flashLoanId: FLSource.MORPHO_BLUE,
21
+ args: [[token], [amount], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
22
+ });
27
23
  }
28
24
  }
@@ -1,16 +1,14 @@
1
- import { ActionWithL2 } from '../../ActionWithL2';
1
+ import { FLAction } from './FLAction';
2
2
  import { getAddr } from '../../addresses';
3
3
  import { EthAddress, uint256, bytes } from '../../types';
4
- import { FlashLoanId } from './FlashLoanId';
4
+ import { FLSource } from './FLSource';
5
5
 
6
6
  /**
7
7
  * Gets a flashloan from Spark with fee enabled
8
8
  *
9
9
  * @category Flashloans
10
10
  */
11
- export class SparkFlashLoanAction extends ActionWithL2 implements FlashLoanId {
12
- public flashLoanId = 7;
13
-
11
+ export class SparkFlashLoanAction extends FLAction {
14
12
  /**
15
13
  * @param tokens
16
14
  * @param loanAmounts
@@ -20,11 +18,9 @@ export class SparkFlashLoanAction extends ActionWithL2 implements FlashLoanId {
20
18
  * @param flParamGetterData
21
19
  */
22
20
  constructor(tokens: Array<EthAddress>, loanAmounts: Array<uint256>, modes: Array<uint256>, loanPayer: EthAddress, flParamGetterAddr: EthAddress = getAddr('Empty'), flParamGetterData: bytes = []) {
23
- super(
24
- 'FLSpark',
25
- getAddr('FLSpark'),
26
- ['address[]', 'uint256[]', 'uint256[]', 'address', 'address', 'bytes', 'bytes'],
27
- [tokens, loanAmounts, modes, loanPayer, flParamGetterAddr, flParamGetterData, []],
28
- );
21
+ super({
22
+ flashLoanId: FLSource.SPARK,
23
+ args: [tokens, loanAmounts, modes, loanPayer, flParamGetterAddr, flParamGetterData, []],
24
+ });
29
25
  }
30
26
  }
@@ -1,16 +1,14 @@
1
- import { Action } from '../../Action';
1
+ import { FLAction } from './FLAction';
2
2
  import { getAddr } from '../../addresses';
3
3
  import { EthAddress, uint256, bytes } from '../../types';
4
- import { FlashLoanId } from './FlashLoanId';
4
+ import { FLSource } from './FLSource';
5
5
 
6
6
  /**
7
7
  * Gets a flashloan from UniV3 pool
8
8
  *
9
9
  * @category Flashloans
10
10
  */
11
- export class UniV3FlashLoanAction extends Action implements FlashLoanId {
12
- public flashLoanId = 6;
13
-
11
+ export class UniV3FlashLoanAction extends FLAction {
14
12
  /**
15
13
  * @param token0
16
14
  * @param token1
@@ -21,11 +19,9 @@ export class UniV3FlashLoanAction extends Action implements FlashLoanId {
21
19
  * @param flParamGetterData
22
20
  */
23
21
  constructor(token0: EthAddress, token1: EthAddress, pool: EthAddress, amount0: uint256, amount1: uint256, flParamGetterAddr: EthAddress = getAddr('Empty'), flParamGetterData: bytes = []) {
24
- super(
25
- 'FLUniV3',
26
- getAddr('FLUniV3'),
27
- ['address[]', 'uint256[]', 'uint256[]', 'address', 'address', 'bytes', 'bytes'],
28
- [[token0, token1, pool], [amount0, amount1], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
29
- );
22
+ super({
23
+ flashLoanId: FLSource.UNIV3,
24
+ args: [[token0, token1, pool], [amount0, amount1], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
25
+ });
30
26
  }
31
27
  }
@@ -1,27 +1,14 @@
1
- export * from './DyDxFlashLoanAction';
2
- export * from './DyDxFlashLoanPaybackAction';
3
1
  export * from './AaveV2FlashLoanAction';
4
- export * from './AaveV2FlashLoanPaybackAction';
5
2
  export * from './AaveV3FlashLoanAction';
6
- export * from './AaveV3FlashLoanPaybackAction';
7
- export * from './AaveV3FlashLoanNoFeeAction';
8
- export * from './AaveV3FlashLoanNoFeePaybackAction';
9
3
  export * from './AaveV3FlashLoanCarryDebtAction';
10
4
  export * from './SparkFlashLoanAction';
11
- export * from './SparkFlashLoanPaybackAction';
12
5
  export * from './MakerFlashLoanAction';
13
- export * from './MakerFlashLoanPaybackAction';
14
6
  export * from './BalancerFlashLoanAction';
15
- export * from './BalancerFlashLoanPaybackAction';
16
- export * from './EulerFlashLoanAction';
17
- export * from './EulerFlashLoanPaybackAction';
18
7
  export * from './FLAction';
8
+ export * from './FLSource';
19
9
  export * from './UniV3FlashLoanAction';
20
- export * from './UniV3FlashLoanPaybackAction';
21
10
  export * from './GhoFlashLoanAction';
22
- export * from './GhoFlashLoanPaybackAction';
23
11
  export * from './MorphoBlueFlashLoanAction';
24
- export * from './MorphoBlueFlashLoanPaybackAction';
25
12
  export * from './FLPaybackAction';
26
13
  export * from './CurveUsdFlashLoanAction';
27
14
  export * from './BalancerV3FlashLoanAction';