@defisaver/sdk 1.3.37 → 1.3.38
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/docs/DEV.md +37 -0
- package/esm/src/actions/flashloan/AaveV2FlashLoanAction.d.ts +2 -4
- package/esm/src/actions/flashloan/AaveV2FlashLoanAction.js +7 -4
- package/esm/src/actions/flashloan/AaveV3FlashLoanAction.d.ts +2 -4
- package/esm/src/actions/flashloan/AaveV3FlashLoanAction.js +7 -4
- package/esm/src/actions/flashloan/BalancerFlashLoanAction.d.ts +2 -4
- package/esm/src/actions/flashloan/BalancerFlashLoanAction.js +7 -4
- package/esm/src/actions/flashloan/BalancerV3FlashLoanAction.d.ts +2 -4
- package/esm/src/actions/flashloan/BalancerV3FlashLoanAction.js +7 -20
- package/esm/src/actions/flashloan/CurveUsdFlashLoanAction.d.ts +2 -4
- package/esm/src/actions/flashloan/CurveUsdFlashLoanAction.js +7 -4
- package/esm/src/actions/flashloan/FLAction.d.ts +7 -5
- package/esm/src/actions/flashloan/FLAction.js +12 -20
- package/esm/src/actions/flashloan/FLSource.d.ts +18 -0
- package/esm/src/actions/flashloan/FLSource.js +42 -0
- package/esm/src/actions/flashloan/FlashLoanId.d.ts +2 -1
- package/esm/src/actions/flashloan/GhoFlashLoanAction.d.ts +2 -4
- package/esm/src/actions/flashloan/GhoFlashLoanAction.js +7 -4
- package/esm/src/actions/flashloan/MakerFlashLoanAction.d.ts +2 -4
- package/esm/src/actions/flashloan/MakerFlashLoanAction.js +7 -4
- package/esm/src/actions/flashloan/MorphoBlueFlashLoanAction.d.ts +2 -4
- package/esm/src/actions/flashloan/MorphoBlueFlashLoanAction.js +7 -4
- package/esm/src/actions/flashloan/SparkFlashLoanAction.d.ts +2 -4
- package/esm/src/actions/flashloan/SparkFlashLoanAction.js +7 -4
- package/esm/src/actions/flashloan/UniV3FlashLoanAction.d.ts +2 -4
- package/esm/src/actions/flashloan/UniV3FlashLoanAction.js +7 -4
- package/esm/src/actions/flashloan/index.d.ts +1 -14
- package/esm/src/actions/flashloan/index.js +1 -14
- package/esm/src/addresses.d.ts +1 -67
- package/esm/src/addresses.js +105 -87
- package/esm/src/index.d.ts +4 -268
- package/package.json +1 -1
- package/src/actions/flashloan/AaveV2FlashLoanAction.ts +7 -11
- package/src/actions/flashloan/AaveV3FlashLoanAction.ts +7 -11
- package/src/actions/flashloan/BalancerFlashLoanAction.ts +7 -11
- package/src/actions/flashloan/BalancerV3FlashLoanAction.ts +7 -27
- package/src/actions/flashloan/CurveUsdFlashLoanAction.ts +7 -11
- package/src/actions/flashloan/FLAction.ts +18 -21
- package/src/actions/flashloan/FLSource.ts +44 -0
- package/src/actions/flashloan/FlashLoanId.ts +3 -1
- package/src/actions/flashloan/GhoFlashLoanAction.ts +7 -11
- package/src/actions/flashloan/MakerFlashLoanAction.ts +7 -11
- package/src/actions/flashloan/MorphoBlueFlashLoanAction.ts +7 -11
- package/src/actions/flashloan/SparkFlashLoanAction.ts +7 -11
- package/src/actions/flashloan/UniV3FlashLoanAction.ts +7 -11
- package/src/actions/flashloan/index.ts +1 -14
- package/src/addresses.ts +127 -90
- package/test/accessLists/Recipe.js +1 -1
- package/test/accessLists/access-lists.js +1 -1
- package/test/actions/flashloan/FLAction.js +77 -0
- package/umd/index.js +1090 -1435
- package/esm/src/actions/flashloan/AaveV2FlashLoanPaybackAction.d.ts +0 -14
- package/esm/src/actions/flashloan/AaveV2FlashLoanPaybackAction.js +0 -16
- package/esm/src/actions/flashloan/AaveV3FlashLoanNoFeeAction.d.ts +0 -18
- package/esm/src/actions/flashloan/AaveV3FlashLoanNoFeeAction.js +0 -20
- package/esm/src/actions/flashloan/AaveV3FlashLoanNoFeePaybackAction.d.ts +0 -14
- package/esm/src/actions/flashloan/AaveV3FlashLoanNoFeePaybackAction.js +0 -16
- package/esm/src/actions/flashloan/AaveV3FlashLoanPaybackAction.d.ts +0 -14
- package/esm/src/actions/flashloan/AaveV3FlashLoanPaybackAction.js +0 -16
- package/esm/src/actions/flashloan/BalancerFlashLoanPaybackAction.d.ts +0 -14
- package/esm/src/actions/flashloan/BalancerFlashLoanPaybackAction.js +0 -16
- package/esm/src/actions/flashloan/DyDxFlashLoanAction.d.ts +0 -16
- package/esm/src/actions/flashloan/DyDxFlashLoanAction.js +0 -18
- package/esm/src/actions/flashloan/DyDxFlashLoanPaybackAction.d.ts +0 -14
- package/esm/src/actions/flashloan/DyDxFlashLoanPaybackAction.js +0 -16
- package/esm/src/actions/flashloan/EulerFlashLoanAction.d.ts +0 -16
- package/esm/src/actions/flashloan/EulerFlashLoanAction.js +0 -18
- package/esm/src/actions/flashloan/EulerFlashLoanPaybackAction.d.ts +0 -14
- package/esm/src/actions/flashloan/EulerFlashLoanPaybackAction.js +0 -16
- package/esm/src/actions/flashloan/GhoFlashLoanPaybackAction.d.ts +0 -13
- package/esm/src/actions/flashloan/GhoFlashLoanPaybackAction.js +0 -15
- package/esm/src/actions/flashloan/MakerFlashLoanPaybackAction.d.ts +0 -13
- package/esm/src/actions/flashloan/MakerFlashLoanPaybackAction.js +0 -15
- package/esm/src/actions/flashloan/MorphoBlueFlashLoanPaybackAction.d.ts +0 -14
- package/esm/src/actions/flashloan/MorphoBlueFlashLoanPaybackAction.js +0 -16
- package/esm/src/actions/flashloan/SparkFlashLoanPaybackAction.d.ts +0 -14
- package/esm/src/actions/flashloan/SparkFlashLoanPaybackAction.js +0 -16
- package/esm/src/actions/flashloan/UniV3FlashLoanPaybackAction.d.ts +0 -16
- package/esm/src/actions/flashloan/UniV3FlashLoanPaybackAction.js +0 -18
- package/src/actions/flashloan/AaveV2FlashLoanPaybackAction.ts +0 -18
- package/src/actions/flashloan/AaveV3FlashLoanNoFeeAction.ts +0 -27
- package/src/actions/flashloan/AaveV3FlashLoanNoFeePaybackAction.ts +0 -18
- package/src/actions/flashloan/AaveV3FlashLoanPaybackAction.ts +0 -18
- package/src/actions/flashloan/BalancerFlashLoanPaybackAction.ts +0 -18
- package/src/actions/flashloan/DyDxFlashLoanAction.ts +0 -24
- package/src/actions/flashloan/DyDxFlashLoanPaybackAction.ts +0 -18
- package/src/actions/flashloan/EulerFlashLoanAction.ts +0 -25
- package/src/actions/flashloan/EulerFlashLoanPaybackAction.ts +0 -18
- package/src/actions/flashloan/GhoFlashLoanPaybackAction.ts +0 -17
- package/src/actions/flashloan/MakerFlashLoanPaybackAction.ts +0 -17
- package/src/actions/flashloan/MorphoBlueFlashLoanPaybackAction.ts +0 -18
- package/src/actions/flashloan/SparkFlashLoanPaybackAction.ts +0 -18
- package/src/actions/flashloan/UniV3FlashLoanPaybackAction.ts +0 -20
- package/test/actions/flashloan/DyDxFlashLoanAction.js +0 -84
package/docs/DEV.md
CHANGED
|
@@ -44,6 +44,43 @@ For a DSProxy, pass `target` and `data` to its `execute(address,bytes)` method a
|
|
|
44
44
|
|
|
45
45
|
A single action also exposes `encodeForDsProxyCall()`, `getAssetsToApprove()`, and `getEthValue()`. `ActionWithL2` supports specialized packed calldata; callers should normally use the public encoding methods rather than pack bytes themselves.
|
|
46
46
|
|
|
47
|
+
## Flashloans
|
|
48
|
+
|
|
49
|
+
Choose a provider action to borrow and use `FLPaybackAction` to repay. You can use
|
|
50
|
+
the provider action directly or pass it to `FLAction`.
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
const { configure, Recipe, actions } = require('@defisaver/sdk');
|
|
54
|
+
const { FLAction, MorphoBlueFlashLoanAction, FLPaybackAction } = actions.flashloan;
|
|
55
|
+
|
|
56
|
+
configure({ chainId: 1, testingMode: false });
|
|
57
|
+
const usdc = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
58
|
+
|
|
59
|
+
const recipe = new Recipe('Morpho flashloan', [
|
|
60
|
+
new MorphoBlueFlashLoanAction(usdc, '1000000000'),
|
|
61
|
+
// Add your actions here.
|
|
62
|
+
new FLPaybackAction('$1', usdc),
|
|
63
|
+
]);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
This borrows 1,000 USDC from Morpho Blue and repays it in the same recipe. The
|
|
67
|
+
flashloan can also be written with an explicit wrapper:
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
const flashloan = new FLAction(
|
|
71
|
+
new MorphoBlueFlashLoanAction(usdc, '1000000000'),
|
|
72
|
+
);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Both forms produce identical calldata for the same provider and arguments. Each
|
|
76
|
+
encodes one loan through the network's `FLAction` contract.
|
|
77
|
+
|
|
78
|
+
Constructors throw if the chosen provider isn't supported on the selected network.
|
|
79
|
+
Use `isFlashLoanSourceSupported(FLSource.MORPHO_BLUE, chainId)` from
|
|
80
|
+
`actions.flashloan` to check support beforehand.
|
|
81
|
+
|
|
82
|
+
For Aave V3 loans that open debt instead of repaying, use `AaveV3FlashLoanCarryDebtAction`.
|
|
83
|
+
|
|
47
84
|
## Strategies
|
|
48
85
|
|
|
49
86
|
`Strategy` describes reusable automation: add subscription slots with `addSubSlot`, triggers with `addTrigger`, and actions with `addAction`. Strategy inputs can refer to named subscription slots such as `'&vaultId'`, or the special addresses `'&proxy'` and `'&eoa'`. Action return references still use `'$1'`, `'$2'`, and so on.
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { EthAddress, uint256, bytes } from '../../types';
|
|
3
|
-
import { FlashLoanId } from './FlashLoanId';
|
|
4
3
|
/**
|
|
5
4
|
* Gets a flashloan from Aave v2
|
|
6
5
|
*
|
|
7
6
|
* @category Flashloans
|
|
8
7
|
*/
|
|
9
|
-
export declare class AaveV2FlashLoanAction extends
|
|
10
|
-
flashLoanId: number;
|
|
8
|
+
export declare class AaveV2FlashLoanAction extends FLAction {
|
|
11
9
|
/**
|
|
12
10
|
* @param loanAmounts
|
|
13
11
|
* @param tokens
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { getAddr } from '../../addresses';
|
|
3
|
+
import { FLSource } from './FLSource';
|
|
3
4
|
/**
|
|
4
5
|
* Gets a flashloan from Aave v2
|
|
5
6
|
*
|
|
6
7
|
* @category Flashloans
|
|
7
8
|
*/
|
|
8
|
-
export class AaveV2FlashLoanAction extends
|
|
9
|
+
export class AaveV2FlashLoanAction extends FLAction {
|
|
9
10
|
/**
|
|
10
11
|
* @param loanAmounts
|
|
11
12
|
* @param tokens
|
|
@@ -15,7 +16,9 @@ export class AaveV2FlashLoanAction extends Action {
|
|
|
15
16
|
* @param flParamGetterData
|
|
16
17
|
*/
|
|
17
18
|
constructor(tokens, loanAmounts, modes, loanPayer, flParamGetterAddr = getAddr('Empty'), flParamGetterData = []) {
|
|
18
|
-
super(
|
|
19
|
-
|
|
19
|
+
super({
|
|
20
|
+
flashLoanId: FLSource.AAVEV2,
|
|
21
|
+
args: [tokens, loanAmounts, modes, loanPayer, flParamGetterAddr, flParamGetterData, []],
|
|
22
|
+
});
|
|
20
23
|
}
|
|
21
24
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { EthAddress, uint256, bytes } from '../../types';
|
|
3
|
-
import { FlashLoanId } from './FlashLoanId';
|
|
4
3
|
/**
|
|
5
4
|
* Gets a flashloan from Aave v3 with fee enabled
|
|
6
5
|
*
|
|
7
6
|
* @category Flashloans
|
|
8
7
|
*/
|
|
9
|
-
export declare class AaveV3FlashLoanAction extends
|
|
10
|
-
flashLoanId: number;
|
|
8
|
+
export declare class AaveV3FlashLoanAction extends FLAction {
|
|
11
9
|
/**
|
|
12
10
|
* @param tokens
|
|
13
11
|
* @param loanAmounts
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { getAddr } from '../../addresses';
|
|
3
|
+
import { FLSource } from './FLSource';
|
|
3
4
|
/**
|
|
4
5
|
* Gets a flashloan from Aave v3 with fee enabled
|
|
5
6
|
*
|
|
6
7
|
* @category Flashloans
|
|
7
8
|
*/
|
|
8
|
-
export class AaveV3FlashLoanAction extends
|
|
9
|
+
export class AaveV3FlashLoanAction extends FLAction {
|
|
9
10
|
/**
|
|
10
11
|
* @param tokens
|
|
11
12
|
* @param loanAmounts
|
|
@@ -15,7 +16,9 @@ export class AaveV3FlashLoanAction extends ActionWithL2 {
|
|
|
15
16
|
* @param flParamGetterData
|
|
16
17
|
*/
|
|
17
18
|
constructor(tokens, loanAmounts, modes, loanPayer, flParamGetterAddr = getAddr('Empty'), flParamGetterData = []) {
|
|
18
|
-
super(
|
|
19
|
-
|
|
19
|
+
super({
|
|
20
|
+
flashLoanId: FLSource.AAVEV3,
|
|
21
|
+
args: [tokens, loanAmounts, modes, loanPayer, flParamGetterAddr, flParamGetterData, []],
|
|
22
|
+
});
|
|
20
23
|
}
|
|
21
24
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { EthAddress, uint256, bytes } from '../../types';
|
|
3
|
-
import { FlashLoanId } from './FlashLoanId';
|
|
4
3
|
/**
|
|
5
4
|
* Gets a flashloan from Balancer
|
|
6
5
|
*
|
|
7
6
|
* @category Flashloans
|
|
8
7
|
*/
|
|
9
|
-
export declare class BalancerFlashLoanAction extends
|
|
10
|
-
flashLoanId: number;
|
|
8
|
+
export declare class BalancerFlashLoanAction extends FLAction {
|
|
11
9
|
/**
|
|
12
10
|
* @param tokens
|
|
13
11
|
* @param amounts
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { getAddr } from '../../addresses';
|
|
3
|
+
import { FLSource } from './FLSource';
|
|
3
4
|
/**
|
|
4
5
|
* Gets a flashloan from Balancer
|
|
5
6
|
*
|
|
6
7
|
* @category Flashloans
|
|
7
8
|
*/
|
|
8
|
-
export class BalancerFlashLoanAction extends
|
|
9
|
+
export class BalancerFlashLoanAction extends FLAction {
|
|
9
10
|
/**
|
|
10
11
|
* @param tokens
|
|
11
12
|
* @param amounts
|
|
@@ -13,7 +14,9 @@ export class BalancerFlashLoanAction extends Action {
|
|
|
13
14
|
* @param flParamGetterData
|
|
14
15
|
*/
|
|
15
16
|
constructor(tokens, amounts, flParamGetterAddr = getAddr('Empty'), flParamGetterData = []) {
|
|
16
|
-
super(
|
|
17
|
-
|
|
17
|
+
super({
|
|
18
|
+
flashLoanId: FLSource.BALANCER,
|
|
19
|
+
args: [tokens, amounts, [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
|
|
20
|
+
});
|
|
18
21
|
}
|
|
19
22
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { EthAddress, uint256, bytes } from '../../types';
|
|
3
|
-
import { FlashLoanId } from './FlashLoanId';
|
|
4
3
|
/**
|
|
5
4
|
* Gets a flashloan from BalancerV3
|
|
6
5
|
*
|
|
7
6
|
* @category Flashloans
|
|
8
7
|
*/
|
|
9
|
-
export declare class BalancerV3FlashLoanAction extends
|
|
10
|
-
flashLoanId: number;
|
|
8
|
+
export declare class BalancerV3FlashLoanAction extends FLAction {
|
|
11
9
|
/**
|
|
12
10
|
* @param tokens
|
|
13
11
|
* @param loanAmounts
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { getAddr } from '../../addresses';
|
|
3
|
+
import { FLSource } from './FLSource';
|
|
3
4
|
/**
|
|
4
5
|
* Gets a flashloan from BalancerV3
|
|
5
6
|
*
|
|
6
7
|
* @category Flashloans
|
|
7
8
|
*/
|
|
8
|
-
export class BalancerV3FlashLoanAction extends
|
|
9
|
+
export class BalancerV3FlashLoanAction extends FLAction {
|
|
9
10
|
/**
|
|
10
11
|
* @param tokens
|
|
11
12
|
* @param loanAmounts
|
|
@@ -13,23 +14,9 @@ export class BalancerV3FlashLoanAction extends Action {
|
|
|
13
14
|
* @param flParamGetterData
|
|
14
15
|
*/
|
|
15
16
|
constructor(tokens, loanAmounts, flParamGetterAddr = getAddr('Empty'), flParamGetterData = []) {
|
|
16
|
-
super(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
'address',
|
|
21
|
-
'address',
|
|
22
|
-
'bytes',
|
|
23
|
-
'bytes',
|
|
24
|
-
], [
|
|
25
|
-
tokens,
|
|
26
|
-
loanAmounts,
|
|
27
|
-
[],
|
|
28
|
-
getAddr('Empty'),
|
|
29
|
-
flParamGetterAddr,
|
|
30
|
-
flParamGetterData,
|
|
31
|
-
[],
|
|
32
|
-
]);
|
|
33
|
-
this.flashLoanId = 10;
|
|
17
|
+
super({
|
|
18
|
+
flashLoanId: FLSource.BALANCER_V3,
|
|
19
|
+
args: [tokens, loanAmounts, [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
|
|
20
|
+
});
|
|
34
21
|
}
|
|
35
22
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { EthAddress, uint256, bytes } from '../../types';
|
|
3
|
-
import { FlashLoanId } from './FlashLoanId';
|
|
4
3
|
/**
|
|
5
4
|
* Gets a crvUSD flashloan from CurveUsd Flash Minter
|
|
6
5
|
*
|
|
7
6
|
* @category Flashloans
|
|
8
7
|
*/
|
|
9
|
-
export declare class CurveUsdFlashLoanAction extends
|
|
10
|
-
flashLoanId: number;
|
|
8
|
+
export declare class CurveUsdFlashLoanAction extends FLAction {
|
|
11
9
|
/**
|
|
12
10
|
* @param amount
|
|
13
11
|
* @param flParamGetterAddr
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { getAddr } from '../../addresses';
|
|
3
|
+
import { FLSource } from './FLSource';
|
|
3
4
|
/**
|
|
4
5
|
* Gets a crvUSD flashloan from CurveUsd Flash Minter
|
|
5
6
|
*
|
|
6
7
|
* @category Flashloans
|
|
7
8
|
*/
|
|
8
|
-
export class CurveUsdFlashLoanAction extends
|
|
9
|
+
export class CurveUsdFlashLoanAction extends FLAction {
|
|
9
10
|
/**
|
|
10
11
|
* @param amount
|
|
11
12
|
* @param flParamGetterAddr
|
|
12
13
|
* @param flParamGetterData
|
|
13
14
|
*/
|
|
14
15
|
constructor(amount, flParamGetterAddr = getAddr('Empty'), flParamGetterData = []) {
|
|
15
|
-
super(
|
|
16
|
-
|
|
16
|
+
super({
|
|
17
|
+
flashLoanId: FLSource.CURVEUSD,
|
|
18
|
+
args: [[], [amount], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
|
|
19
|
+
});
|
|
17
20
|
}
|
|
18
21
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { Action } from '../../Action';
|
|
2
2
|
import { FlashLoanId } from './FlashLoanId';
|
|
3
|
-
import {
|
|
3
|
+
import { FLSource } from './FLSource';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Executes a supported provider through the unified FLAction contract.
|
|
6
|
+
* The inner action's arguments and flashLoanId are used.
|
|
7
|
+
* Repay with FLPaybackAction or send tokens to FLAction.
|
|
6
8
|
*
|
|
7
9
|
* @category Flashloans
|
|
8
10
|
*/
|
|
9
|
-
declare type SpecificFlashLoanAction =
|
|
10
|
-
export declare class FLAction extends Action {
|
|
11
|
-
|
|
11
|
+
declare type SpecificFlashLoanAction = FlashLoanId & Pick<Action, 'args'>;
|
|
12
|
+
export declare class FLAction extends Action implements FlashLoanId {
|
|
13
|
+
flashLoanId: FLSource;
|
|
12
14
|
constructor(specificFLAction: SpecificFlashLoanAction);
|
|
13
15
|
}
|
|
14
16
|
export {};
|
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
|
-
var _FLAction_instances, _FLAction_handleArgs;
|
|
7
1
|
import { Action } from '../../Action';
|
|
8
2
|
import { getAddr } from '../../addresses';
|
|
3
|
+
import { assertFlashLoanSourceSupported } from './FLSource';
|
|
9
4
|
export class FLAction extends Action {
|
|
10
5
|
constructor(specificFLAction) {
|
|
6
|
+
assertFlashLoanSourceSupported(specificFLAction === null || specificFLAction === void 0 ? void 0 : specificFLAction.flashLoanId);
|
|
11
7
|
super('FLAction', getAddr('FLAction'), [], []);
|
|
12
|
-
_FLAction_instances.add(this);
|
|
13
8
|
this.paramTypes = ['address[]', 'uint256[]', 'uint256[]', 'address', 'address', 'bytes', 'bytes'];
|
|
14
|
-
this.
|
|
9
|
+
this.flashLoanId = specificFLAction.flashLoanId;
|
|
10
|
+
this.args = [
|
|
11
|
+
specificFLAction.args[0],
|
|
12
|
+
specificFLAction.args[1],
|
|
13
|
+
specificFLAction.args[2],
|
|
14
|
+
specificFLAction.args[3],
|
|
15
|
+
getAddr('Empty'),
|
|
16
|
+
[this.flashLoanId],
|
|
17
|
+
specificFLAction.args[6],
|
|
18
|
+
];
|
|
15
19
|
}
|
|
16
20
|
}
|
|
17
|
-
_FLAction_instances = new WeakSet(), _FLAction_handleArgs = function _FLAction_handleArgs(specificFLAction) {
|
|
18
|
-
const argsToReturn = [
|
|
19
|
-
specificFLAction.args[0],
|
|
20
|
-
specificFLAction.args[1],
|
|
21
|
-
specificFLAction.args[2],
|
|
22
|
-
specificFLAction.args[3],
|
|
23
|
-
getAddr('Empty'),
|
|
24
|
-
[specificFLAction.flashLoanId],
|
|
25
|
-
specificFLAction.args[6],
|
|
26
|
-
];
|
|
27
|
-
return argsToReturn;
|
|
28
|
-
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Must match the unified FLAction contract's FLSource enum. */
|
|
2
|
+
export declare enum FLSource {
|
|
3
|
+
EMPTY = 0,
|
|
4
|
+
AAVEV2 = 1,
|
|
5
|
+
BALANCER = 2,
|
|
6
|
+
GHO = 3,
|
|
7
|
+
MAKER = 4,
|
|
8
|
+
AAVEV3 = 5,
|
|
9
|
+
UNIV3 = 6,
|
|
10
|
+
SPARK = 7,
|
|
11
|
+
MORPHO_BLUE = 8,
|
|
12
|
+
CURVEUSD = 9,
|
|
13
|
+
BALANCER_V3 = 10
|
|
14
|
+
}
|
|
15
|
+
/** Provider support in the current unified deployments. */
|
|
16
|
+
export declare const supportedFlashLoanSources: Readonly<Record<number, readonly FLSource[]>>;
|
|
17
|
+
export declare const isFlashLoanSourceSupported: (source: FLSource, chainId?: number) => boolean;
|
|
18
|
+
export declare const assertFlashLoanSourceSupported: (source: FLSource, chainId?: number) => void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CONFIG, NETWORKS } from '../../config';
|
|
2
|
+
/** Must match the unified FLAction contract's FLSource enum. */
|
|
3
|
+
export var FLSource;
|
|
4
|
+
(function (FLSource) {
|
|
5
|
+
FLSource[FLSource["EMPTY"] = 0] = "EMPTY";
|
|
6
|
+
FLSource[FLSource["AAVEV2"] = 1] = "AAVEV2";
|
|
7
|
+
FLSource[FLSource["BALANCER"] = 2] = "BALANCER";
|
|
8
|
+
FLSource[FLSource["GHO"] = 3] = "GHO";
|
|
9
|
+
FLSource[FLSource["MAKER"] = 4] = "MAKER";
|
|
10
|
+
FLSource[FLSource["AAVEV3"] = 5] = "AAVEV3";
|
|
11
|
+
FLSource[FLSource["UNIV3"] = 6] = "UNIV3";
|
|
12
|
+
FLSource[FLSource["SPARK"] = 7] = "SPARK";
|
|
13
|
+
FLSource[FLSource["MORPHO_BLUE"] = 8] = "MORPHO_BLUE";
|
|
14
|
+
FLSource[FLSource["CURVEUSD"] = 9] = "CURVEUSD";
|
|
15
|
+
FLSource[FLSource["BALANCER_V3"] = 10] = "BALANCER_V3";
|
|
16
|
+
})(FLSource || (FLSource = {}));
|
|
17
|
+
/** Provider support in the current unified deployments. */
|
|
18
|
+
export const supportedFlashLoanSources = {
|
|
19
|
+
[NETWORKS.ethereum.chainId]: [
|
|
20
|
+
FLSource.AAVEV2, FLSource.BALANCER, FLSource.GHO, FLSource.MAKER,
|
|
21
|
+
FLSource.AAVEV3, FLSource.UNIV3, FLSource.SPARK, FLSource.MORPHO_BLUE,
|
|
22
|
+
FLSource.CURVEUSD, FLSource.BALANCER_V3,
|
|
23
|
+
],
|
|
24
|
+
[NETWORKS.arbitrum.chainId]: [
|
|
25
|
+
FLSource.BALANCER, FLSource.AAVEV3, FLSource.UNIV3, FLSource.MORPHO_BLUE, FLSource.BALANCER_V3,
|
|
26
|
+
],
|
|
27
|
+
[NETWORKS.base.chainId]: [
|
|
28
|
+
FLSource.BALANCER, FLSource.AAVEV3, FLSource.UNIV3, FLSource.MORPHO_BLUE, FLSource.BALANCER_V3,
|
|
29
|
+
],
|
|
30
|
+
[NETWORKS.optimism.chainId]: [
|
|
31
|
+
FLSource.BALANCER, FLSource.AAVEV3, FLSource.UNIV3, FLSource.BALANCER_V3,
|
|
32
|
+
],
|
|
33
|
+
[NETWORKS.linea.chainId]: [FLSource.AAVEV3],
|
|
34
|
+
[NETWORKS.plasma.chainId]: [FLSource.AAVEV3, FLSource.BALANCER_V3],
|
|
35
|
+
};
|
|
36
|
+
export const isFlashLoanSourceSupported = (source, chainId = CONFIG.chainId) => { var _a, _b; return (_b = (_a = supportedFlashLoanSources[chainId]) === null || _a === void 0 ? void 0 : _a.includes(source)) !== null && _b !== void 0 ? _b : false; };
|
|
37
|
+
export const assertFlashLoanSourceSupported = (source, chainId = CONFIG.chainId) => {
|
|
38
|
+
var _a;
|
|
39
|
+
if (!isFlashLoanSourceSupported(source, chainId)) {
|
|
40
|
+
throw new Error(`Flashloan source ${(_a = FLSource[source]) !== null && _a !== void 0 ? _a : String(source)} is not supported by FLAction on chainId: ${chainId}.`);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { EthAddress, uint256, bytes } from '../../types';
|
|
3
|
-
import { FlashLoanId } from './FlashLoanId';
|
|
4
3
|
/**
|
|
5
4
|
* Gets a GHO flashloan from GHO Flash Minter
|
|
6
5
|
*
|
|
7
6
|
* @category Flashloans
|
|
8
7
|
*/
|
|
9
|
-
export declare class GhoFlashLoanAction extends
|
|
10
|
-
flashLoanId: number;
|
|
8
|
+
export declare class GhoFlashLoanAction extends FLAction {
|
|
11
9
|
/**
|
|
12
10
|
* @param amount
|
|
13
11
|
* @param flParamGetterAddr
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { getAddr } from '../../addresses';
|
|
3
|
+
import { FLSource } from './FLSource';
|
|
3
4
|
/**
|
|
4
5
|
* Gets a GHO flashloan from GHO Flash Minter
|
|
5
6
|
*
|
|
6
7
|
* @category Flashloans
|
|
7
8
|
*/
|
|
8
|
-
export class GhoFlashLoanAction extends
|
|
9
|
+
export class GhoFlashLoanAction extends FLAction {
|
|
9
10
|
/**
|
|
10
11
|
* @param amount
|
|
11
12
|
* @param flParamGetterAddr
|
|
12
13
|
* @param flParamGetterData
|
|
13
14
|
*/
|
|
14
15
|
constructor(amount, flParamGetterAddr = getAddr('Empty'), flParamGetterData = []) {
|
|
15
|
-
super(
|
|
16
|
-
|
|
16
|
+
super({
|
|
17
|
+
flashLoanId: FLSource.GHO,
|
|
18
|
+
args: [[], [amount], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
|
|
19
|
+
});
|
|
17
20
|
}
|
|
18
21
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { EthAddress, uint256, bytes } from '../../types';
|
|
3
|
-
import { FlashLoanId } from './FlashLoanId';
|
|
4
3
|
/**
|
|
5
4
|
* Gets a flashloan from Maker
|
|
6
5
|
*
|
|
7
6
|
* @category Flashloans
|
|
8
7
|
*/
|
|
9
|
-
export declare class MakerFlashLoanAction extends
|
|
10
|
-
flashLoanId: number;
|
|
8
|
+
export declare class MakerFlashLoanAction extends FLAction {
|
|
11
9
|
/**
|
|
12
10
|
* @param amount
|
|
13
11
|
* @param flParamGetterAddr
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { getAddr } from '../../addresses';
|
|
3
|
+
import { FLSource } from './FLSource';
|
|
3
4
|
/**
|
|
4
5
|
* Gets a flashloan from Maker
|
|
5
6
|
*
|
|
6
7
|
* @category Flashloans
|
|
7
8
|
*/
|
|
8
|
-
export class MakerFlashLoanAction extends
|
|
9
|
+
export class MakerFlashLoanAction extends FLAction {
|
|
9
10
|
/**
|
|
10
11
|
* @param amount
|
|
11
12
|
* @param flParamGetterAddr
|
|
12
13
|
* @param flParamGetterData
|
|
13
14
|
*/
|
|
14
15
|
constructor(amount, flParamGetterAddr = getAddr('Empty'), flParamGetterData = []) {
|
|
15
|
-
super(
|
|
16
|
-
|
|
16
|
+
super({
|
|
17
|
+
flashLoanId: FLSource.MAKER,
|
|
18
|
+
args: [[], [amount], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
|
|
19
|
+
});
|
|
17
20
|
}
|
|
18
21
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { EthAddress, uint256, bytes } from '../../types';
|
|
3
|
-
import { FlashLoanId } from './FlashLoanId';
|
|
4
3
|
/**
|
|
5
4
|
* Gets a flashloan from MorphoBlue
|
|
6
5
|
*
|
|
7
6
|
* @category Flashloans
|
|
8
7
|
*/
|
|
9
|
-
export declare class MorphoBlueFlashLoanAction extends
|
|
10
|
-
flashLoanId: number;
|
|
8
|
+
export declare class MorphoBlueFlashLoanAction extends FLAction {
|
|
11
9
|
/**
|
|
12
10
|
* @param token
|
|
13
11
|
* @param amount
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { getAddr } from '../../addresses';
|
|
3
|
+
import { FLSource } from './FLSource';
|
|
3
4
|
/**
|
|
4
5
|
* Gets a flashloan from MorphoBlue
|
|
5
6
|
*
|
|
6
7
|
* @category Flashloans
|
|
7
8
|
*/
|
|
8
|
-
export class MorphoBlueFlashLoanAction extends
|
|
9
|
+
export class MorphoBlueFlashLoanAction extends FLAction {
|
|
9
10
|
/**
|
|
10
11
|
* @param token
|
|
11
12
|
* @param amount
|
|
@@ -13,7 +14,9 @@ export class MorphoBlueFlashLoanAction extends Action {
|
|
|
13
14
|
* @param flParamGetterData
|
|
14
15
|
*/
|
|
15
16
|
constructor(token, amount, flParamGetterAddr = getAddr('Empty'), flParamGetterData = []) {
|
|
16
|
-
super(
|
|
17
|
-
|
|
17
|
+
super({
|
|
18
|
+
flashLoanId: FLSource.MORPHO_BLUE,
|
|
19
|
+
args: [[token], [amount], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
|
|
20
|
+
});
|
|
18
21
|
}
|
|
19
22
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { EthAddress, uint256, bytes } from '../../types';
|
|
3
|
-
import { FlashLoanId } from './FlashLoanId';
|
|
4
3
|
/**
|
|
5
4
|
* Gets a flashloan from Spark with fee enabled
|
|
6
5
|
*
|
|
7
6
|
* @category Flashloans
|
|
8
7
|
*/
|
|
9
|
-
export declare class SparkFlashLoanAction extends
|
|
10
|
-
flashLoanId: number;
|
|
8
|
+
export declare class SparkFlashLoanAction extends FLAction {
|
|
11
9
|
/**
|
|
12
10
|
* @param tokens
|
|
13
11
|
* @param loanAmounts
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { getAddr } from '../../addresses';
|
|
3
|
+
import { FLSource } from './FLSource';
|
|
3
4
|
/**
|
|
4
5
|
* Gets a flashloan from Spark with fee enabled
|
|
5
6
|
*
|
|
6
7
|
* @category Flashloans
|
|
7
8
|
*/
|
|
8
|
-
export class SparkFlashLoanAction extends
|
|
9
|
+
export class SparkFlashLoanAction extends FLAction {
|
|
9
10
|
/**
|
|
10
11
|
* @param tokens
|
|
11
12
|
* @param loanAmounts
|
|
@@ -15,7 +16,9 @@ export class SparkFlashLoanAction extends ActionWithL2 {
|
|
|
15
16
|
* @param flParamGetterData
|
|
16
17
|
*/
|
|
17
18
|
constructor(tokens, loanAmounts, modes, loanPayer, flParamGetterAddr = getAddr('Empty'), flParamGetterData = []) {
|
|
18
|
-
super(
|
|
19
|
-
|
|
19
|
+
super({
|
|
20
|
+
flashLoanId: FLSource.SPARK,
|
|
21
|
+
args: [tokens, loanAmounts, modes, loanPayer, flParamGetterAddr, flParamGetterData, []],
|
|
22
|
+
});
|
|
20
23
|
}
|
|
21
24
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { EthAddress, uint256, bytes } from '../../types';
|
|
3
|
-
import { FlashLoanId } from './FlashLoanId';
|
|
4
3
|
/**
|
|
5
4
|
* Gets a flashloan from UniV3 pool
|
|
6
5
|
*
|
|
7
6
|
* @category Flashloans
|
|
8
7
|
*/
|
|
9
|
-
export declare class UniV3FlashLoanAction extends
|
|
10
|
-
flashLoanId: number;
|
|
8
|
+
export declare class UniV3FlashLoanAction extends FLAction {
|
|
11
9
|
/**
|
|
12
10
|
* @param token0
|
|
13
11
|
* @param token1
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FLAction } from './FLAction';
|
|
2
2
|
import { getAddr } from '../../addresses';
|
|
3
|
+
import { FLSource } from './FLSource';
|
|
3
4
|
/**
|
|
4
5
|
* Gets a flashloan from UniV3 pool
|
|
5
6
|
*
|
|
6
7
|
* @category Flashloans
|
|
7
8
|
*/
|
|
8
|
-
export class UniV3FlashLoanAction extends
|
|
9
|
+
export class UniV3FlashLoanAction extends FLAction {
|
|
9
10
|
/**
|
|
10
11
|
* @param token0
|
|
11
12
|
* @param token1
|
|
@@ -16,7 +17,9 @@ export class UniV3FlashLoanAction extends Action {
|
|
|
16
17
|
* @param flParamGetterData
|
|
17
18
|
*/
|
|
18
19
|
constructor(token0, token1, pool, amount0, amount1, flParamGetterAddr = getAddr('Empty'), flParamGetterData = []) {
|
|
19
|
-
super(
|
|
20
|
-
|
|
20
|
+
super({
|
|
21
|
+
flashLoanId: FLSource.UNIV3,
|
|
22
|
+
args: [[token0, token1, pool], [amount0, amount1], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
|
|
23
|
+
});
|
|
21
24
|
}
|
|
22
25
|
}
|