@defisaver/sdk 1.2.8 → 1.2.9
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/.mocharc.json +4 -0
- package/.nvmrc +1 -0
- package/README.md +6 -0
- package/esm/src/actions/checkers/AaveV3OpenRatioCheckAction.d.ts +16 -0
- package/esm/src/actions/checkers/AaveV3OpenRatioCheckAction.js +22 -0
- package/esm/src/actions/checkers/index.d.ts +1 -0
- package/esm/src/actions/checkers/index.js +1 -0
- package/esm/src/actions/eulerV2/EulerV2PaybackWithSharesAction.js +1 -1
- package/esm/src/actions/eulerV2/EulerV2PullDebtAction.js +1 -1
- package/esm/src/actions/eulerV2/EulerV2ReorderCollateralsAction.js +1 -1
- package/esm/src/addresses.d.ts +1 -1
- package/esm/src/addresses.js +6 -8
- package/esm/src/index.d.ts +4 -4
- package/esm/src/triggers/AaveV2RatioTrigger.js +1 -1
- package/esm/src/triggers/AaveV3QuotePriceTrigger.js +1 -1
- package/esm/src/triggers/AaveV3RatioTrigger.js +1 -1
- package/esm/src/triggers/CBRebondTrigger.js +1 -1
- package/esm/src/triggers/ChainLinkPriceTrigger.js +1 -1
- package/esm/src/triggers/CompV3RatioTrigger.js +1 -1
- package/esm/src/triggers/CompoundRatioTrigger.js +1 -1
- package/esm/src/triggers/CurveUsdCollRatioTrigger.js +1 -1
- package/esm/src/triggers/CurveUsdHealthRatioTrigger.js +1 -1
- package/esm/src/triggers/GasPriceTrigger.js +1 -1
- package/esm/src/triggers/LiquityDebtInFrontWithLimitTrigger.js +1 -1
- package/esm/src/triggers/LiquityRatioTrigger.js +1 -1
- package/esm/src/triggers/MakerRatioTrigger.js +1 -1
- package/esm/src/triggers/MorphoAaveV2RatioTrigger.js +1 -1
- package/esm/src/triggers/MorphoBlueRatioTrigger.js +1 -1
- package/esm/src/triggers/OffchainPriceTrigger.js +1 -1
- package/esm/src/triggers/ReflexerRatioTrigger.js +1 -1
- package/esm/src/triggers/SparkQuotePriceTrigger.js +1 -1
- package/esm/src/triggers/SparkRatioTrigger.js +1 -1
- package/esm/src/triggers/TimestampTrigger.js +1 -1
- package/esm/src/triggers/TrailingStopTrigger.js +1 -1
- package/esm/src/triggers/UniV3CurrentTickTrigger.js +1 -1
- package/package.json +8 -5
- package/src/actions/checkers/AaveV3OpenRatioCheckAction.ts +30 -0
- package/src/actions/checkers/index.ts +2 -1
- package/src/actions/eulerV2/EulerV2PaybackWithSharesAction.ts +1 -1
- package/src/actions/eulerV2/EulerV2PullDebtAction.ts +1 -1
- package/src/actions/eulerV2/EulerV2ReorderCollateralsAction.ts +1 -1
- package/src/actions/eulerV2/index.ts +1 -2
- package/src/addresses.ts +4 -6
- package/src/triggers/AaveV2RatioTrigger.ts +2 -2
- package/src/triggers/AaveV3QuotePriceTrigger.ts +2 -2
- package/src/triggers/AaveV3RatioTrigger.ts +2 -2
- package/src/triggers/CBRebondTrigger.ts +2 -2
- package/src/triggers/ChainLinkPriceTrigger.ts +2 -2
- package/src/triggers/CompV3RatioTrigger.ts +2 -2
- package/src/triggers/CompoundRatioTrigger.ts +2 -2
- package/src/triggers/CurveUsdCollRatioTrigger.ts +2 -2
- package/src/triggers/CurveUsdHealthRatioTrigger.ts +1 -1
- package/src/triggers/GasPriceTrigger.ts +2 -2
- package/src/triggers/LiquityDebtInFrontWithLimitTrigger.ts +2 -2
- package/src/triggers/LiquityRatioTrigger.ts +2 -2
- package/src/triggers/MakerRatioTrigger.ts +2 -2
- package/src/triggers/MorphoAaveV2RatioTrigger.ts +2 -2
- package/src/triggers/MorphoBlueRatioTrigger.ts +2 -2
- package/src/triggers/OffchainPriceTrigger.ts +2 -2
- package/src/triggers/ReflexerRatioTrigger.ts +2 -2
- package/src/triggers/SparkQuotePriceTrigger.ts +2 -2
- package/src/triggers/SparkRatioTrigger.ts +2 -2
- package/src/triggers/TimestampTrigger.ts +2 -2
- package/src/triggers/TrailingStopTrigger.ts +2 -2
- package/src/triggers/UniV3CurrentTickTrigger.ts +2 -2
- package/test/Action.js +1 -1
- package/test/ActionWithL2.js +1 -1
- package/test/DfsWeb3.js +1 -1
- package/test/Recipe.js +1 -1
- package/test/Strategy.js +1 -1
- package/test/accessLists/Recipe.js +1 -1
- package/test/accessLists/access-lists.js +1 -1
- package/test/actions/aave/AaveBorrowAction.js +1 -1
- package/test/actions/aave/AaveClaimStkAaveAction.js +1 -1
- package/test/actions/aave/AaveCollateralSwitchAction.js +1 -1
- package/test/actions/aave/AavePaybackAction.js +1 -1
- package/test/actions/aave/AaveSupplyAction.js +1 -1
- package/test/actions/aave/AaveWithdrawAction.js +1 -1
- package/test/actions/balancer/BalancerV2ClaimAction.js +1 -1
- package/test/actions/balancer/BalancerV2SupplyAction.js +1 -1
- package/test/actions/balancer/BalancerV2WithdrawAction.js +1 -1
- package/test/actions/basic/ChangeProxyOwnerAction.js +1 -1
- package/test/actions/basic/CreateSubAction.js +1 -2
- package/test/actions/basic/SellAction.js +1 -1
- package/test/actions/basic/SendTokenAction.js +1 -1
- package/test/actions/basic/TokenBalanceAction.js +1 -1
- package/test/actions/checkers/AaveV3OpenRatioCheckAction.js +22 -0
- package/test/actions/compound/CompoundBorrowAction.js +1 -1
- package/test/actions/compound/CompoundCollateralSwitchAction.js +1 -1
- package/test/actions/compound/CompoundGetDebtAction.js +1 -1
- package/test/actions/compound/CompoundPaybackAction.js +1 -1
- package/test/actions/compound/CompoundSupplyAction.js +1 -1
- package/test/actions/compound/CompoundWithdrawAction.js +1 -1
- package/test/actions/dydx/DyDxWithdrawAction.js +1 -1
- package/test/actions/eulerV2/EulerV2BorrowAction.js +31 -0
- package/test/actions/eulerV2/EulerV2CollateralSwitchAction.js +28 -0
- package/test/actions/eulerV2/EulerV2PaybackAction.js +39 -0
- package/test/actions/eulerV2/EulerV2SupplyAction.js +42 -0
- package/test/actions/eulerV2/EulerV2WithdrawAction.js +31 -0
- package/test/actions/flashloan/DyDxFlashLoanAction.js +1 -1
- package/test/actions/insta/InstPullTokensAction.js +1 -1
- package/test/actions/lido/LidoStakeAction.js +1 -1
- package/test/actions/liquity/LiquityBorrowAction.js +1 -1
- package/test/actions/liquity/LiquityClaimAction.js +1 -1
- package/test/actions/liquity/LiquityClaimSPRewardsAction.js +1 -1
- package/test/actions/liquity/LiquityClaimStakingRewardsAction.js +1 -1
- package/test/actions/liquity/LiquityCloseAction.js +1 -1
- package/test/actions/liquity/LiquityEthGainToTroveAction.js +1 -1
- package/test/actions/liquity/LiquityOpenAction.js +1 -1
- package/test/actions/liquity/LiquityPaybackAction.js +1 -1
- package/test/actions/liquity/LiquityRedeemAction.js +1 -1
- package/test/actions/liquity/LiquitySPDepositAction.js +1 -1
- package/test/actions/liquity/LiquitySPWithdrawAction.js +1 -1
- package/test/actions/liquity/LiquityStakeAction.js +1 -1
- package/test/actions/liquity/LiquitySupplyAction.js +1 -1
- package/test/actions/liquity/LiquityUnstakeAction.js +1 -1
- package/test/actions/liquity/LiquityWithdrawAction.js +1 -1
- package/test/actions/maker/MakerGenerateAction.js +1 -1
- package/test/actions/maker/MakerGiveAction.js +1 -1
- package/test/actions/maker/MakerMergeAction.js +1 -1
- package/test/actions/maker/MakerOpenVaultAction.js +1 -1
- package/test/actions/maker/MakerPaybackAction.js +1 -1
- package/test/actions/maker/MakerSupplyAction.js +1 -1
- package/test/actions/maker/MakerWithdrawAction.js +1 -1
- package/test/actions/reflexer/ReflexerNativeUniV2SaviourDepositAction.js +1 -1
- package/test/actions/reflexer/ReflexerNativeUniV2SaviourGetReservesAction.js +1 -1
- package/test/actions/reflexer/ReflexerNativeUniV2SaviourWithdrawAction.js +1 -1
- package/test/actions/uniswap/UniswapSupplyAction.js +1 -1
- package/test/actions/uniswap/UniswapWithdrawAction.js +1 -1
- package/test/actions/uniswapV3/UniswapV3CollectAction.js +1 -1
- package/test/actions/uniswapV3/UniswapV3CreatePoolAction.js +1 -1
- package/test/actions/uniswapV3/UniswapV3MintAction.js +1 -1
- package/test/actions/uniswapV3/UniswapV3SupplyAction.js +1 -1
- package/test/actions/uniswapV3/UniswapV3WithdrawAction.js +1 -1
- package/test/actions/yearn/YearnSupplyAction.js +1 -1
- package/test/actions/yearn/YearnWithdrawAction.js +1 -1
- package/test/index.js +1 -1
- package/test/utils/uniswapLP.js +1 -1
- package/test/utils/zeroExExchange.js +3 -2
- package/tsconfig.esm.json +11 -0
- package/tsconfig.json +2 -2
- package/umd/index.js +465 -435
- package/.env.example +0 -1
package/.mocharc.json
ADDED
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v20.17.0
|
package/README.md
CHANGED
|
@@ -8,3 +8,9 @@ Create complex transactions that interact with multiple DeFi protocols.
|
|
|
8
8
|
- [SDK docs](https://github.com/DecenterApps/defisaver-sdk/blob/master/DEV.md)
|
|
9
9
|
- [Available Actions](https://github.com/DecenterApps/defisaver-sdk/blob/master/ACTIONS.md)
|
|
10
10
|
- [Pre-made recipes - TODO](https://github.com/DecenterApps/defisaver-sdk/blob/master/RECIPES.md)
|
|
11
|
+
|
|
12
|
+
## Testing
|
|
13
|
+
|
|
14
|
+
`npm run test` - Run all tests
|
|
15
|
+
|
|
16
|
+
`npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { EthAddress, uint256 } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* AaveV3OpenRatioCheckAction - Checks aave V3 ratio for users proxy position and reverts if faulty.
|
|
5
|
+
*
|
|
6
|
+
* @dev This checker action is different from AaveV3RatioCheckAction in that it checks current ratio without checking previous ratio.
|
|
7
|
+
*
|
|
8
|
+
* @category Checkers
|
|
9
|
+
*/
|
|
10
|
+
export declare class AaveV3OpenRatioCheckAction extends Action {
|
|
11
|
+
/**
|
|
12
|
+
* @param targetRatio The ratio user want to be at
|
|
13
|
+
* @param market Address provider for specific market
|
|
14
|
+
*/
|
|
15
|
+
constructor(targetRatio: uint256, market: EthAddress);
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { getAddr } from '../../addresses';
|
|
3
|
+
/**
|
|
4
|
+
* AaveV3OpenRatioCheckAction - Checks aave V3 ratio for users proxy position and reverts if faulty.
|
|
5
|
+
*
|
|
6
|
+
* @dev This checker action is different from AaveV3RatioCheckAction in that it checks current ratio without checking previous ratio.
|
|
7
|
+
*
|
|
8
|
+
* @category Checkers
|
|
9
|
+
*/
|
|
10
|
+
export class AaveV3OpenRatioCheckAction extends Action {
|
|
11
|
+
/**
|
|
12
|
+
* @param targetRatio The ratio user want to be at
|
|
13
|
+
* @param market Address provider for specific market
|
|
14
|
+
*/
|
|
15
|
+
constructor(targetRatio, market) {
|
|
16
|
+
super('AaveV3OpenRatioCheck', getAddr('Empty'), ['uint256', 'address'], [targetRatio, market]);
|
|
17
|
+
this.mappableArgs = [
|
|
18
|
+
this.args[0],
|
|
19
|
+
this.args[1],
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -13,7 +13,7 @@ export class EulerV2PaybackWithSharesAction extends Action {
|
|
|
13
13
|
* @param amount The amount of asset tokens to be paid back (uint256.max for full debt repayment or up to the available deposit shares in 'from' account)
|
|
14
14
|
*/
|
|
15
15
|
constructor(vault, account, from, amount) {
|
|
16
|
-
super('EulerV2PaybackWithShares', getAddr('
|
|
16
|
+
super('EulerV2PaybackWithShares', getAddr('Empty'), ['address', 'address', 'address', 'uint256'], [vault, account, from, amount]);
|
|
17
17
|
this.mappableArgs = [
|
|
18
18
|
this.args[0],
|
|
19
19
|
this.args[1],
|
|
@@ -13,7 +13,7 @@ export class EulerV2PullDebtAction extends Action {
|
|
|
13
13
|
* @param amount The amount of debt to be pulled (uint256.max for full debt pull)
|
|
14
14
|
*/
|
|
15
15
|
constructor(vault, account, from, amount) {
|
|
16
|
-
super('EulerV2PullDebt', getAddr('
|
|
16
|
+
super('EulerV2PullDebt', getAddr('Empty'), ['address', 'address', 'address', 'uint256'], [vault, account, from, amount]);
|
|
17
17
|
this.mappableArgs = [
|
|
18
18
|
this.args[0],
|
|
19
19
|
this.args[1],
|
|
@@ -11,7 +11,7 @@ export class EulerV2ReorderCollateralsAction extends Action {
|
|
|
11
11
|
* @param indexes The array of swap steps to reorder collaterals
|
|
12
12
|
*/
|
|
13
13
|
constructor(account, indexes) {
|
|
14
|
-
super('EulerV2ReorderCollaterals', getAddr('
|
|
14
|
+
super('EulerV2ReorderCollaterals', getAddr('Empty'), ['address', 'uint8[][]'], [account, indexes]);
|
|
15
15
|
this.mappableArgs = [
|
|
16
16
|
this.args[0],
|
|
17
17
|
this.args[1],
|
package/esm/src/addresses.d.ts
CHANGED
|
@@ -685,6 +685,7 @@ export declare const actionAddresses: {
|
|
|
685
685
|
ChangeProxyOwner: string;
|
|
686
686
|
PermitToken: string;
|
|
687
687
|
HandleAuth: string;
|
|
688
|
+
ToggleSub: string;
|
|
688
689
|
FLAaveV3: string;
|
|
689
690
|
FLBalancer: string;
|
|
690
691
|
FLUniV3: string;
|
|
@@ -719,7 +720,6 @@ export declare const actionAddresses: {
|
|
|
719
720
|
MorphoBlueView: string;
|
|
720
721
|
AutomationV2Unsub?: undefined;
|
|
721
722
|
SendTokenAndUnwrap?: undefined;
|
|
722
|
-
ToggleSub?: undefined;
|
|
723
723
|
UpdateSub?: undefined;
|
|
724
724
|
TransferNFT?: undefined;
|
|
725
725
|
CreateSub?: undefined;
|
package/esm/src/addresses.js
CHANGED
|
@@ -250,7 +250,7 @@ export const actionAddresses = {
|
|
|
250
250
|
EulerV2Borrow: '0x38d66ecD38b7800D8FD0Bc29489c2306170a9Ede',
|
|
251
251
|
EulerV2Payback: '0x738b1df6b6962D8795Bda5bc5EFCd8b0B8c74d01',
|
|
252
252
|
EulerV2CollateralSwitch: '0x38950b50Fb38aC19D06e8CE5AAE632D6dF1EEb1a',
|
|
253
|
-
EulerV2View: '
|
|
253
|
+
EulerV2View: '0x8932E46Ecf96b5Fe033F5e27Ab6dC755Cb668967',
|
|
254
254
|
MerklClaim: '0xE88036F3F0D7e216D63726356cA2bC334e305fe5',
|
|
255
255
|
},
|
|
256
256
|
[NETWORKS.optimism.chainId]: {
|
|
@@ -382,6 +382,7 @@ export const actionAddresses = {
|
|
|
382
382
|
ChangeProxyOwner: '0x1947a44d3717a47556175d64fdc208619aa08874',
|
|
383
383
|
PermitToken: '0x57c8ae94a5A11dA33e0518054102488b604628D0',
|
|
384
384
|
HandleAuth: '0x18a90e6db79199ace00140631ef931e0bd97837c',
|
|
385
|
+
ToggleSub: '0x5F16C0a08d52b67fc73706c494F7535Dd3382b58',
|
|
385
386
|
// Flashloan
|
|
386
387
|
FLAaveV3: '0x79Eb9cEe432Cd3e7b09A9eFdB21A733A6d7b4c3A',
|
|
387
388
|
FLBalancer: '0x862E533198C9656B75bB6A5dDF0953F7ED5E8507',
|
|
@@ -479,13 +480,10 @@ export const getAddr = (name, chainId = CONFIG.chainId) => {
|
|
|
479
480
|
const _chainId = typeof chainId === 'undefined' ? CONFIG.chainId : chainId;
|
|
480
481
|
const actions = actionAddresses[_chainId];
|
|
481
482
|
const other = otherAddresses[_chainId];
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
if (!actions[name] && !other[name])
|
|
487
|
-
throw new Error(`Cannot find address for name: ${name} (chainId: ${_chainId}).`);
|
|
488
|
-
}
|
|
483
|
+
if (!actions && !other)
|
|
484
|
+
throw new Error(`Cannot find address for chainId: ${_chainId}.`);
|
|
485
|
+
if (!actions[name] && !other[name])
|
|
486
|
+
throw new Error(`Cannot find address for name: ${name} (chainId: ${_chainId}).`);
|
|
489
487
|
if (actions[name])
|
|
490
488
|
return actions[name];
|
|
491
489
|
return other[name];
|
package/esm/src/index.d.ts
CHANGED
|
@@ -696,6 +696,7 @@ declare const actionAddressesAllChains: {
|
|
|
696
696
|
ChangeProxyOwner: string;
|
|
697
697
|
PermitToken: string;
|
|
698
698
|
HandleAuth: string;
|
|
699
|
+
ToggleSub: string;
|
|
699
700
|
FLAaveV3: string;
|
|
700
701
|
FLBalancer: string;
|
|
701
702
|
FLUniV3: string;
|
|
@@ -730,7 +731,6 @@ declare const actionAddressesAllChains: {
|
|
|
730
731
|
MorphoBlueView: string;
|
|
731
732
|
AutomationV2Unsub?: undefined;
|
|
732
733
|
SendTokenAndUnwrap?: undefined;
|
|
733
|
-
ToggleSub?: undefined;
|
|
734
734
|
UpdateSub?: undefined;
|
|
735
735
|
TransferNFT?: undefined;
|
|
736
736
|
CreateSub?: undefined;
|
|
@@ -1594,6 +1594,7 @@ declare const actionAddresses: (chainId?: null) => {
|
|
|
1594
1594
|
ChangeProxyOwner: string;
|
|
1595
1595
|
PermitToken: string;
|
|
1596
1596
|
HandleAuth: string;
|
|
1597
|
+
ToggleSub: string;
|
|
1597
1598
|
FLAaveV3: string;
|
|
1598
1599
|
FLBalancer: string;
|
|
1599
1600
|
FLUniV3: string;
|
|
@@ -1628,7 +1629,6 @@ declare const actionAddresses: (chainId?: null) => {
|
|
|
1628
1629
|
MorphoBlueView: string;
|
|
1629
1630
|
AutomationV2Unsub?: undefined;
|
|
1630
1631
|
SendTokenAndUnwrap?: undefined;
|
|
1631
|
-
ToggleSub?: undefined;
|
|
1632
1632
|
UpdateSub?: undefined;
|
|
1633
1633
|
TransferNFT?: undefined;
|
|
1634
1634
|
CreateSub?: undefined;
|
|
@@ -2635,6 +2635,7 @@ declare const _default: {
|
|
|
2635
2635
|
ChangeProxyOwner: string;
|
|
2636
2636
|
PermitToken: string;
|
|
2637
2637
|
HandleAuth: string;
|
|
2638
|
+
ToggleSub: string;
|
|
2638
2639
|
FLAaveV3: string;
|
|
2639
2640
|
FLBalancer: string;
|
|
2640
2641
|
FLUniV3: string;
|
|
@@ -2669,7 +2670,6 @@ declare const _default: {
|
|
|
2669
2670
|
MorphoBlueView: string;
|
|
2670
2671
|
AutomationV2Unsub?: undefined;
|
|
2671
2672
|
SendTokenAndUnwrap?: undefined;
|
|
2672
|
-
ToggleSub?: undefined;
|
|
2673
2673
|
UpdateSub?: undefined;
|
|
2674
2674
|
TransferNFT?: undefined;
|
|
2675
2675
|
CreateSub?: undefined;
|
|
@@ -3533,6 +3533,7 @@ declare const _default: {
|
|
|
3533
3533
|
ChangeProxyOwner: string;
|
|
3534
3534
|
PermitToken: string;
|
|
3535
3535
|
HandleAuth: string;
|
|
3536
|
+
ToggleSub: string;
|
|
3536
3537
|
FLAaveV3: string;
|
|
3537
3538
|
FLBalancer: string;
|
|
3538
3539
|
FLUniV3: string;
|
|
@@ -3567,7 +3568,6 @@ declare const _default: {
|
|
|
3567
3568
|
MorphoBlueView: string;
|
|
3568
3569
|
AutomationV2Unsub?: undefined;
|
|
3569
3570
|
SendTokenAndUnwrap?: undefined;
|
|
3570
|
-
ToggleSub?: undefined;
|
|
3571
3571
|
UpdateSub?: undefined;
|
|
3572
3572
|
TransferNFT?: undefined;
|
|
3573
3573
|
CreateSub?: undefined;
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class AaveV2RatioTrigger extends Action {
|
|
9
9
|
constructor(user, market, ratio, state) {
|
|
10
|
-
super('AaveV2RatioTrigger', getAddr('
|
|
10
|
+
super('AaveV2RatioTrigger', getAddr('Empty'), [['address', 'address', 'uint256', 'uint8']], [[user, market, ratio, state]]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class AaveV3QuotePriceTrigger extends Action {
|
|
9
9
|
constructor(baseTokenAddr, quoteTokenAddr, price, state) {
|
|
10
|
-
super('AaveV3QuotePriceTrigger', getAddr('
|
|
10
|
+
super('AaveV3QuotePriceTrigger', getAddr('Empty'), [['address', 'address', 'uint256', 'uint8']], [[baseTokenAddr, quoteTokenAddr, price, state]]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class AaveV3RatioTrigger extends Action {
|
|
9
9
|
constructor(user, market, ratio, state) {
|
|
10
|
-
super('AaveV3RatioTrigger', getAddr('
|
|
10
|
+
super('AaveV3RatioTrigger', getAddr('Empty'), [['address', 'address', 'uint256', 'uint8']], [[user, market, ratio, state]]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class CBRebondTrigger extends Action {
|
|
9
9
|
constructor(bondID) {
|
|
10
|
-
super('CBRebondTrigger', getAddr('
|
|
10
|
+
super('CBRebondTrigger', getAddr('Empty'), ['uint256'], [bondID]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class ChainLinkPriceTrigger extends Action {
|
|
9
9
|
constructor(tokenAddr, price, state) {
|
|
10
|
-
super('ChainLinkPriceTrigger', getAddr('
|
|
10
|
+
super('ChainLinkPriceTrigger', getAddr('Empty'), ['address', 'uint256', 'uint8'], [tokenAddr, price, state]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class CompV3RatioTrigger extends Action {
|
|
9
9
|
constructor(user, market, ratio, state) {
|
|
10
|
-
super('CompV3RatioTrigger', getAddr('
|
|
10
|
+
super('CompV3RatioTrigger', getAddr('Empty'), [['address', 'address', 'uint256', 'uint8']], [[user, market, ratio, state]]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class CompoundRatioTrigger extends Action {
|
|
9
9
|
constructor(user, ratio, state) {
|
|
10
|
-
super('CompoundRatioTrigger', getAddr('
|
|
10
|
+
super('CompoundRatioTrigger', getAddr('Empty'), ['address', 'uint256', 'uint8'], [user, ratio, state]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class CurveUsdCollRatioTrigger extends Action {
|
|
9
9
|
constructor(user, controller, ratio, state) {
|
|
10
|
-
super('CurveUsdCollRatioTrigger', getAddr('
|
|
10
|
+
super('CurveUsdCollRatioTrigger', getAddr('Empty'), [['address', 'address', 'uint256', 'uint8']], [[user, controller, ratio, state]]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class CurveUsdHealthRatioTrigger extends Action {
|
|
9
9
|
constructor(user, controller, ratio) {
|
|
10
|
-
super('CurveUsdHealthRatioTrigger', getAddr('
|
|
10
|
+
super('CurveUsdHealthRatioTrigger', getAddr('Empty'), [['address', 'address', 'uint256']], [[user, controller, ratio]]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class GasPriceTrigger extends Action {
|
|
9
9
|
constructor(maxGasPrice) {
|
|
10
|
-
super('GasPriceTrigger', getAddr('
|
|
10
|
+
super('GasPriceTrigger', getAddr('Empty'), ['uint256'], [maxGasPrice]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class LiquityDebtInFrontWithLimitTrigger extends Action {
|
|
9
9
|
constructor(troveOwner, debtInFront) {
|
|
10
|
-
super('LiquityDebtInFrontWithLimitTrigger', getAddr('
|
|
10
|
+
super('LiquityDebtInFrontWithLimitTrigger', getAddr('Empty'), ['address', 'uint256'], [troveOwner, debtInFront]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class LiquityRatioTrigger extends Action {
|
|
9
9
|
constructor(troveOwner, ratio, state) {
|
|
10
|
-
super('LiquityRatioTrigger', getAddr('
|
|
10
|
+
super('LiquityRatioTrigger', getAddr('Empty'), ['addresss', 'uint256', 'uint8'], [troveOwner, ratio, state]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class MakerRatioTrigger extends Action {
|
|
9
9
|
constructor(vaultId, ratio, state) {
|
|
10
|
-
super('McdRatioTrigger', getAddr('
|
|
10
|
+
super('McdRatioTrigger', getAddr('Empty'), ['uint256', 'uint256', 'uint8'], [vaultId, ratio, state]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class MorphoAaveV2RatioTrigger extends Action {
|
|
9
9
|
constructor(user, ratio, state) {
|
|
10
|
-
super('MorphoAaveV2RatioTrigger', getAddr('
|
|
10
|
+
super('MorphoAaveV2RatioTrigger', getAddr('Empty'), ['address', 'uint256', 'uint8'], [user, ratio, state]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class MorphoBlueRatioTrigger extends Action {
|
|
9
9
|
constructor(marketId, user, ratio, state) {
|
|
10
|
-
super('MorphoBlueRatioTrigger', getAddr('
|
|
10
|
+
super('MorphoBlueRatioTrigger', getAddr('Empty'), [['bytes32', 'address', 'uint256', 'uint8']], [[marketId, user, ratio, state]]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class OffchainPriceTrigger extends Action {
|
|
9
9
|
constructor(limitPrice, limitType) {
|
|
10
|
-
super('OffchainPriceTrigger', getAddr('
|
|
10
|
+
super('OffchainPriceTrigger', getAddr('Empty'), ['uint256', 'uint8'], [limitPrice, limitType]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class ReflexerRatioTrigger extends Action {
|
|
9
9
|
constructor(vaultId, ratio, state) {
|
|
10
|
-
super('ReflexerRatioTrigger', getAddr('
|
|
10
|
+
super('ReflexerRatioTrigger', getAddr('Empty'), ['uint256', 'uint256', 'uint8'], [vaultId, ratio, state]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class SparkQuotePriceTrigger extends Action {
|
|
9
9
|
constructor(baseTokenAddr, quoteTokenAddr, price, state) {
|
|
10
|
-
super('SparkQuotePriceTrigger', getAddr('
|
|
10
|
+
super('SparkQuotePriceTrigger', getAddr('Empty'), [['address', 'address', 'uint256', 'uint8']], [[baseTokenAddr, quoteTokenAddr, price, state]]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class SparkRatioTrigger extends Action {
|
|
9
9
|
constructor(user, market, ratio, state) {
|
|
10
|
-
super('SparkRatioTrigger', getAddr('
|
|
10
|
+
super('SparkRatioTrigger', getAddr('Empty'), [['address', 'address', 'uint256', 'uint8']], [[user, market, ratio, state]]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class TimestampTrigger extends Action {
|
|
9
9
|
constructor(nextTimestamp) {
|
|
10
|
-
super('TimestampTrigger', getAddr('
|
|
10
|
+
super('TimestampTrigger', getAddr('Empty'), ['uint256'], [nextTimestamp]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class TrailingStopTrigger extends Action {
|
|
9
9
|
constructor(tokenAddr, percentage, roundId) {
|
|
10
|
-
super('TrailingStopTrigger', getAddr('
|
|
10
|
+
super('TrailingStopTrigger', getAddr('Empty'), ['address', 'uint256', 'uint80'], [tokenAddr, percentage, roundId]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -7,6 +7,6 @@ import { getAddr } from '../addresses';
|
|
|
7
7
|
*/
|
|
8
8
|
export class UniV3CurrentTickTrigger extends Action {
|
|
9
9
|
constructor(tokenId, state) {
|
|
10
|
-
super('UniV3CurrentTickTrigger', getAddr('
|
|
10
|
+
super('UniV3CurrentTickTrigger', getAddr('Empty'), ['uint256', 'uint8'], [tokenId, state]);
|
|
11
11
|
}
|
|
12
12
|
}
|
package/package.json
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defisaver/sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./umd/index.js",
|
|
6
6
|
"module": "./esm/src/index.js",
|
|
7
7
|
"types": "./esm/src/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"test": "mocha
|
|
9
|
+
"test": "mocha 'test/**'",
|
|
10
|
+
"test-single": "mocha ./test/$npm_config_name.js",
|
|
10
11
|
"version-bump": "git commit -am \"Version bump to $(npm version patch | cut -c 2-)\"",
|
|
11
|
-
"build:esm": "rm -rf esm && tsc -
|
|
12
|
+
"build:esm": "rm -rf esm && tsc -p tsconfig.esm.json",
|
|
12
13
|
"build:umd": "rm -rf umd && webpack --config=webpack.umd.js",
|
|
13
14
|
"build": "npm run lint && npm run build:umd && npm run build:esm",
|
|
14
15
|
"documentMD": "npx typedoc --plugin typedoc-plugin-markdown --out docs/md",
|
|
15
16
|
"document": "npx typedoc --out docs/default",
|
|
16
|
-
"lint": "eslint . --ext .ts"
|
|
17
|
+
"lint": "eslint . --ext .ts --fix",
|
|
18
|
+
"lint-check": "eslint .",
|
|
19
|
+
"build-test": "npm run build && npm run test"
|
|
17
20
|
},
|
|
18
21
|
"author": "DeFi Saver",
|
|
19
22
|
"repository": "https://github.com/DecenterApps/defisaver-sdk",
|
|
20
23
|
"license": "ISC",
|
|
21
24
|
"dependencies": {
|
|
22
25
|
"@defisaver/eslint-config": "^1.0.0",
|
|
23
|
-
"@defisaver/tokens": "^1.5.
|
|
26
|
+
"@defisaver/tokens": "^1.5.46",
|
|
24
27
|
"@ethersproject/address": "^5.0.10",
|
|
25
28
|
"@ethersproject/solidity": "^5.0.9",
|
|
26
29
|
"@types/web3-eth-abi": "^1.2.2",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Action } from '../../Action';
|
|
2
|
+
import { getAddr } from '../../addresses';
|
|
3
|
+
import { EthAddress, uint256 } from '../../types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* AaveV3OpenRatioCheckAction - Checks aave V3 ratio for users proxy position and reverts if faulty.
|
|
7
|
+
*
|
|
8
|
+
* @dev This checker action is different from AaveV3RatioCheckAction in that it checks current ratio without checking previous ratio.
|
|
9
|
+
*
|
|
10
|
+
* @category Checkers
|
|
11
|
+
*/
|
|
12
|
+
export class AaveV3OpenRatioCheckAction extends Action {
|
|
13
|
+
/**
|
|
14
|
+
* @param targetRatio The ratio user want to be at
|
|
15
|
+
* @param market Address provider for specific market
|
|
16
|
+
*/
|
|
17
|
+
constructor(targetRatio:uint256, market:EthAddress) {
|
|
18
|
+
super(
|
|
19
|
+
'AaveV3OpenRatioCheck',
|
|
20
|
+
getAddr('Empty'),
|
|
21
|
+
['uint256', 'address'],
|
|
22
|
+
[targetRatio, market],
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
this.mappableArgs = [
|
|
26
|
+
this.args[0],
|
|
27
|
+
this.args[1],
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -8,4 +8,5 @@ export * from './MorphoAaveV2RatioCheckAction';
|
|
|
8
8
|
export * from './SparkRatioCheckAction';
|
|
9
9
|
export * from './LiquityRatioIncreaseCheckAction';
|
|
10
10
|
export * from './CurveUsdCollRatioCheck';
|
|
11
|
-
export * from './MorphoBlueRatioCheckAction';
|
|
11
|
+
export * from './MorphoBlueRatioCheckAction';
|
|
12
|
+
export * from './AaveV3OpenRatioCheckAction';
|
|
@@ -5,5 +5,4 @@ export * from './EulerV2PaybackAction';
|
|
|
5
5
|
export * from './EulerV2PaybackWithSharesAction';
|
|
6
6
|
export * from './EulerV2PullDebtAction';
|
|
7
7
|
export * from './EulerV2ReorderCollateralsAction';
|
|
8
|
-
export * from './EulerV2CollateralSwitchAction';
|
|
9
|
-
|
|
8
|
+
export * from './EulerV2CollateralSwitchAction';
|
package/src/addresses.ts
CHANGED
|
@@ -289,7 +289,7 @@ export const actionAddresses = {
|
|
|
289
289
|
EulerV2Borrow: '0x38d66ecD38b7800D8FD0Bc29489c2306170a9Ede',
|
|
290
290
|
EulerV2Payback: '0x738b1df6b6962D8795Bda5bc5EFCd8b0B8c74d01',
|
|
291
291
|
EulerV2CollateralSwitch: '0x38950b50Fb38aC19D06e8CE5AAE632D6dF1EEb1a',
|
|
292
|
-
EulerV2View: '
|
|
292
|
+
EulerV2View: '0x8932E46Ecf96b5Fe033F5e27Ab6dC755Cb668967',
|
|
293
293
|
|
|
294
294
|
MerklClaim: '0xE88036F3F0D7e216D63726356cA2bC334e305fe5',
|
|
295
295
|
},
|
|
@@ -436,6 +436,7 @@ export const actionAddresses = {
|
|
|
436
436
|
ChangeProxyOwner: '0x1947a44d3717a47556175d64fdc208619aa08874',
|
|
437
437
|
PermitToken: '0x57c8ae94a5A11dA33e0518054102488b604628D0',
|
|
438
438
|
HandleAuth: '0x18a90e6db79199ace00140631ef931e0bd97837c',
|
|
439
|
+
ToggleSub: '0x5F16C0a08d52b67fc73706c494F7535Dd3382b58',
|
|
439
440
|
|
|
440
441
|
// Flashloan
|
|
441
442
|
FLAaveV3: '0x79Eb9cEe432Cd3e7b09A9eFdB21A733A6d7b4c3A',
|
|
@@ -547,11 +548,8 @@ export const getAddr = (name: string, chainId:number = CONFIG.chainId) : EthAddr
|
|
|
547
548
|
const actions = actionAddresses[_chainId];
|
|
548
549
|
const other = otherAddresses[_chainId];
|
|
549
550
|
|
|
550
|
-
|
|
551
|
-
if (!
|
|
552
|
-
if (!actions && !other) throw new Error(`Cannot find address for chainId: ${_chainId}.`);
|
|
553
|
-
if (!actions[name as keyof typeof actions] && !other[name as keyof typeof other]) throw new Error(`Cannot find address for name: ${name} (chainId: ${_chainId}).`);
|
|
554
|
-
}
|
|
551
|
+
if (!actions && !other) throw new Error(`Cannot find address for chainId: ${_chainId}.`);
|
|
552
|
+
if (!actions[name as keyof typeof actions] && !other[name as keyof typeof other]) throw new Error(`Cannot find address for name: ${name} (chainId: ${_chainId}).`);
|
|
555
553
|
|
|
556
554
|
if (actions[name as keyof typeof actions]) return actions[name as keyof typeof actions]!;
|
|
557
555
|
return other[name as keyof typeof other]!;
|
|
@@ -9,6 +9,6 @@ import { EthAddress, uint256, uint8 } from '../types';
|
|
|
9
9
|
*/
|
|
10
10
|
export class AaveV2RatioTrigger extends Action {
|
|
11
11
|
constructor(user:EthAddress, market:EthAddress, ratio:uint256, state:uint8) {
|
|
12
|
-
super('AaveV2RatioTrigger', getAddr('
|
|
12
|
+
super('AaveV2RatioTrigger', getAddr('Empty'), [['address', 'address', 'uint256', 'uint8']], [[user, market, ratio, state]]);
|
|
13
13
|
}
|
|
14
|
-
}
|
|
14
|
+
}
|
|
@@ -9,6 +9,6 @@ import { EthAddress, uint256, uint8 } from '../types';
|
|
|
9
9
|
*/
|
|
10
10
|
export class AaveV3QuotePriceTrigger extends Action {
|
|
11
11
|
constructor(baseTokenAddr:EthAddress, quoteTokenAddr:EthAddress, price:uint256, state:uint8) {
|
|
12
|
-
super('AaveV3QuotePriceTrigger', getAddr('
|
|
12
|
+
super('AaveV3QuotePriceTrigger', getAddr('Empty'), [['address', 'address', 'uint256', 'uint8']], [[baseTokenAddr, quoteTokenAddr, price, state]]);
|
|
13
13
|
}
|
|
14
|
-
}
|
|
14
|
+
}
|
|
@@ -9,6 +9,6 @@ import { EthAddress, uint256, uint8 } from '../types';
|
|
|
9
9
|
*/
|
|
10
10
|
export class AaveV3RatioTrigger extends Action {
|
|
11
11
|
constructor(user:EthAddress, market:EthAddress, ratio:uint256, state:uint8) {
|
|
12
|
-
super('AaveV3RatioTrigger', getAddr('
|
|
12
|
+
super('AaveV3RatioTrigger', getAddr('Empty'), [['address', 'address', 'uint256', 'uint8']], [[user, market, ratio, state]]);
|
|
13
13
|
}
|
|
14
|
-
}
|
|
14
|
+
}
|
|
@@ -9,6 +9,6 @@ import { uint256 } from '../types';
|
|
|
9
9
|
*/
|
|
10
10
|
export class CBRebondTrigger extends Action {
|
|
11
11
|
constructor(bondID:uint256) {
|
|
12
|
-
super('CBRebondTrigger', getAddr('
|
|
12
|
+
super('CBRebondTrigger', getAddr('Empty'), ['uint256'], [bondID]);
|
|
13
13
|
}
|
|
14
|
-
}
|
|
14
|
+
}
|
|
@@ -9,6 +9,6 @@ import { EthAddress, uint256, uint8 } from '../types';
|
|
|
9
9
|
*/
|
|
10
10
|
export class ChainLinkPriceTrigger extends Action {
|
|
11
11
|
constructor(tokenAddr:EthAddress, price:uint256, state:uint8) {
|
|
12
|
-
super('ChainLinkPriceTrigger', getAddr('
|
|
12
|
+
super('ChainLinkPriceTrigger', getAddr('Empty'), ['address', 'uint256', 'uint8'], [tokenAddr, price, state]);
|
|
13
13
|
}
|
|
14
|
-
}
|
|
14
|
+
}
|