@defisaver/sdk 0.1.21 → 0.1.24

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 (91) hide show
  1. package/ACTIONS.md +20 -254
  2. package/AccessLists/DyDxAccessLists.js +0 -4
  3. package/AccessLists/InstaAccessLists.js +0 -8
  4. package/AccessLists/UtilsAccessLists.js +0 -5
  5. package/DEV.md +0 -7
  6. package/index.js +15 -2
  7. package/package.json +1 -1
  8. package/src/Action.js +52 -12
  9. package/src/L2Action.js +44 -0
  10. package/src/Recipe.js +5 -4
  11. package/src/Strategy.js +63 -0
  12. package/src/abis/Action.json +157 -11
  13. package/src/abis/Recipe.json +92 -47
  14. package/src/actions/aave/AaveBorrowAction.js +11 -2
  15. package/src/actions/aave/AavePaybackAction.js +11 -2
  16. package/src/actions/aave/AaveSupplyAction.js +9 -1
  17. package/src/actions/aave/AaveWithdrawAction.js +8 -1
  18. package/src/actions/aaveV3/AaveV3ATokenPaybackAction.js +53 -0
  19. package/src/actions/aaveV3/AaveV3BorrowAction.js +54 -0
  20. package/src/actions/aaveV3/AaveV3CollateralSwitchAction.js +41 -0
  21. package/src/actions/aaveV3/AaveV3PaybackAction.js +63 -0
  22. package/src/actions/aaveV3/AaveV3SetEModeAction.js +35 -0
  23. package/src/actions/aaveV3/AaveV3SupplyAction.js +64 -0
  24. package/src/actions/aaveV3/AaveV3WithdrawAction.js +41 -0
  25. package/src/actions/aaveV3/index.js +17 -0
  26. package/src/actions/basic/GasFeeAction.js +27 -0
  27. package/src/actions/basic/PullTokenAction.js +9 -3
  28. package/src/actions/basic/SellAction.js +6 -5
  29. package/src/actions/basic/SendTokenAction.js +9 -3
  30. package/src/actions/basic/SumInputsAction.js +8 -3
  31. package/src/actions/basic/UnwrapEthAction.js +8 -3
  32. package/src/actions/basic/WrapEthAction.js +5 -1
  33. package/src/actions/basic/index.js +2 -2
  34. package/src/actions/checkers/MakerRatioCheckAction.js +29 -0
  35. package/src/actions/checkers/index.js +5 -0
  36. package/src/actions/compound/CompoundBorrowAction.js +7 -1
  37. package/src/actions/compound/CompoundClaimAction.js +6 -1
  38. package/src/actions/compound/CompoundPaybackAction.js +7 -1
  39. package/src/actions/compound/CompoundSupplyAction.js +7 -1
  40. package/src/actions/compound/CompoundWithdrawAction.js +7 -1
  41. package/src/actions/dydx/DyDxWithdrawAction.js +7 -1
  42. package/src/actions/dydx/index.js +0 -2
  43. package/src/actions/flashloan/AaveV2FlashLoanAction.js +2 -2
  44. package/src/actions/flashloan/BalancerFlashLoanAction.js +2 -2
  45. package/src/actions/flashloan/DyDxFlashLoanAction.js +1 -1
  46. package/src/actions/flashloan/MakerFlashLoanAction.js +2 -2
  47. package/src/actions/index.js +4 -0
  48. package/src/actions/insta/index.js +0 -2
  49. package/src/actions/liquity/LiquityClaimAction.js +6 -2
  50. package/src/actions/liquity/LiquityCloseAction.js +7 -2
  51. package/src/actions/maker/MakerGenerateAction.js +8 -1
  52. package/src/actions/maker/MakerGiveAction.js +7 -1
  53. package/src/actions/maker/MakerMergeAction.js +7 -1
  54. package/src/actions/maker/MakerOpenVaultAction.js +6 -1
  55. package/src/actions/maker/MakerPaybackAction.js +1 -0
  56. package/src/actions/maker/MakerRatioAction.js +20 -0
  57. package/src/actions/maker/MakerSupplyAction.js +9 -1
  58. package/src/actions/maker/MakerWithdrawAction.js +10 -2
  59. package/src/actions/maker/index.js +2 -0
  60. package/src/actions/mstable/MStableDepositAction.js +2 -2
  61. package/src/actions/mstable/MStableWithdrawAction.js +2 -2
  62. package/src/actions/reflexer/ReflexerGenerateAction.js +7 -1
  63. package/src/actions/reflexer/ReflexerOpenSafeAction.js +5 -1
  64. package/src/actions/reflexer/ReflexerPaybackAction.js +7 -1
  65. package/src/actions/reflexer/ReflexerSupplyAction.js +8 -1
  66. package/src/actions/reflexer/ReflexerWithdrawAction.js +8 -1
  67. package/src/addresses.js +179 -143
  68. package/src/config.js +74 -0
  69. package/src/triggers/ChainLinkPriceTrigger.js +12 -0
  70. package/src/triggers/CompoundRatioTrigger.js +11 -0
  71. package/src/triggers/GasPriceTrigger.js +11 -0
  72. package/src/triggers/LiquityRatioTrigger.js +16 -0
  73. package/src/triggers/MakerRatioTrigger.js +15 -0
  74. package/src/triggers/ReflexerRatioTrigger.js +11 -0
  75. package/src/triggers/TimestampTrigger.js +11 -0
  76. package/src/triggers/UniV3CurrentTickTrigger.js +12 -0
  77. package/src/triggers/index.js +19 -0
  78. package/src/types.js +33 -0
  79. package/src/utils/general.js +2 -0
  80. package/src/utils/zeroExExchange.js +2 -40
  81. package/test/accessLists/MockAccessLists.json +0 -72
  82. package/test/accessLists/Recipe.js +3 -3
  83. package/test/actions/insta/InstPullTokensAction.js +2 -2
  84. package/test/index.js +4 -1
  85. package/test/utils/zeroExExchange.js +0 -8
  86. package/src/actions/basic/BuyAction.js +0 -53
  87. package/src/actions/dydx/DyDxSupplyAction.js +0 -25
  88. package/src/actions/insta/ClaimInstMakerAction.js +0 -21
  89. package/test/actions/basic/BuyAction.js +0 -100
  90. package/test/actions/dydx/DyDxSupplyAction.js +0 -78
  91. package/test/actions/insta/ClaimInstMakerAction.js +0 -46
package/src/addresses.js CHANGED
@@ -1,154 +1,190 @@
1
-
1
+ const { CONFIG, NETWORKS } = require('./config');
2
2
 
3
3
  const actionAddresses = {
4
- 'TaskExecutor': '0xb3e5371d55e1e84bfFE7D0b57Bd9c6A4C6b3C635',
5
- 'DFSRegistry': '0xD6049E1F5F3EfF1F921f5532aF1A1632bA23929C',
6
-
7
- // utils
8
- 'WrapEth': '0x9E702937F42Db2cE58342Ca5F213Ef33D51AEF6b',
9
- 'UnwrapEth': '0x5cD02A169CfE5B0596B352547879Dd60B7033488',
10
- 'PullToken': '0x795a89f6D4E97A959fe81aa22772441323783479',
11
- 'SendToken': '0xBbe0D7f2AF01aE678f8A873CB2d2EB73871C9b5A',
12
- 'SumInputs': '0xCdef35425579fc566B6Ee0499A79256ac88d25cf',
13
- 'SubInputs': '0x3f71c5b806c2aCFA88bd7Ae5F7f8A14121E0FcA6',
14
- 'ChangeProxyOwner': '0x32cEdFfF6e64f6cD1907Ae0b27b78c36320587E7',
15
- 'TokenBalance': '0xFEb82445aEaA675D59A43CD5833f5A6807f97ea2',
16
- 'AutomationV2Unsub': '0xd3D70313d1E2ab6ae47674C88390Fd9865806201',
17
-
18
- // exchange
19
- 'DFSSell': '0xf4adae649B2c3B2795608b2D222c852929944898',
20
- 'DFSBuy': '0x939dCad6A3D1fEACccB60Af90876D904468CbF66',
21
-
22
- // maker
23
- 'McdGenerate': '0x2bF4586636329Ae930cFe085a1e57BAb4a8f741b',
24
- 'McdGive': '0xD2dc5DA4172a3901C9f26c7cd29eFE656Fc20332',
25
- 'McdMerge': '0x66c7f4C7e59b6e780142aaD5c9f427FA5F8dfFc6',
26
- 'McdOpen': '0x72AFC60B90c976397C37B5c64DDc067Ea521D388',
27
- 'McdPayback': '0xb7C2c78846493Bed18fa07B51fcc5EAFAc9d629C',
28
- 'McdSupply': '0x91c3167aC51F92c2f720C6A8418FDF46060698A1',
29
- 'McdWithdraw': '0xb1ab48556d9bBDDa1E3C9223533111b2a248d695',
30
- 'McdClaim': '0xd78783b50227A84d43604843065494e2666182Ab',
31
-
32
- // reflexer
33
- 'ReflexerSupply': '0x24C537A93A9ab75b5A593BA0B2dc03200345A844',
34
- 'ReflexerWithdraw': '0xcA99fB3430180E43bC1929a3a84d0500E3118e0A',
35
- 'ReflexerPayback': '0x0c8320033340277791C5dCD9BC87d20f086BB34b',
36
- 'ReflexerGenerate': '0x28E78093dF6d370Ca9ea1aC85668d8a097f09087',
37
- 'ReflexerOpen': '0xcf174aFFbB7be200afa37Dfc4CD067ae3Cb91054',
38
- 'ReflexerNativeUniV2SaviourDeposit':'0x5F66CC360657Bf224aa280Ae104550b5042E185a',
39
- 'ReflexerNativeUniV2SaviourGetReserves':'0x9C7518F7a0f5bC4D57702fcE8C0778F7Fb2f09f8',
40
- 'ReflexerNativeUniV2SaviourWithdraw':'0x6a61363243Cad1BE5caaE5e53284520592deB154',
41
-
42
- // aave
43
- 'AaveBorrow': '0xEdBbF97C505309e5174E164fbec3cAE774d310Ea',
44
- 'AavePayback': '0xb583Bc7603E5E482F475Ec9Ea90129029D53fbc8',
45
- 'AaveSupply': '0xC71113E9122465e8bCd42123f840Df99abaF29F1',
46
- 'AaveWithdraw': '0xE06Fc1CBD78Eb0799d5B0ca62D51B065886e08FC',
47
- 'AaveCollateralSwitch': '0x27d77c80A88665342C98Ea31B687A5fc8ca9a445',
48
-
49
- // compound
50
- 'CompBorrow': '0xde1b05266f2D05Bf9216B76500583c2b7785b7e9',
51
- 'CompClaim': '0xAA165C03fF61301b79f35649157f6738263739A3',
52
- 'CompPayback': '0x67D2CC825730cCb70FD4579E55cDb3cf3152fcb6',
53
- 'CompSupply': '0x1F22890C166B30cE8769b7B55354064C254e063F',
54
- 'CompWithdraw': '0xD326a003bcfDbad0E9A4Ccc37a76Ce264345F38a',
55
- 'CompGetDebt': '0x009109AB7b8CAFf748cdA2F272F36043528Bef2C',
56
- 'CompCollateralSwitch': '0x1c0BD1E4da2c3108f6caA64609E89a37531B0f86',
57
-
58
- // flashloan
59
- 'FLAaveV2': '0x45F17B18134B4398468A5bcdCdf22f0e1cAbEad5',
60
- 'FLDyDx': '0x973065599BACa33FC9CAD2823710f1332D2B7805',
61
- 'FLMaker': '0xEA2C6B373Ea3e596995d2523a74592E22EE49BFF',
62
- 'FLBalancer': '0x81c69A428fDB21bBaB8A7434fF511382058c29dC',
63
-
64
- // uniswap
65
- 'UniSupply': '0xcAE220B5398AfAad75bfeb946164f6C23CF65A98',
66
- 'UniWithdraw': '0x847aF4eFDf64E4F54Af95D3b867DfC92f4Ea91B4',
67
-
68
- // uniswap V3
69
- 'UniCollectV3': '0x4D49FB2Cc0DF856b936CCA1816A9e6DD0ADFa232',
70
- 'UniMintV3': '0x488794Aa06Ec668fDeC29375CB8B6629f4692B0B',
71
- 'UniSupplyV3': '0x1dc3C2c16195bD6e49f6ED05F1f482c3C7FD35Af',
72
- 'UniWithdrawV3': '0xe5FAB89bdC01130c686B35540531EB1cBbaE8ff3',
73
- 'UniCreatePoolV3': '0xAD599cA05C7295a0cbc5CD696BF3f7E633402C99',
74
-
75
- // dydx
76
- 'DyDxSupply': '0xA8D1C1eea86573cBcC919fbf28Db542bDfE7Ed5b',
77
- 'DyDxWithdraw': '0x55AA33F42D79DbD3f1885b410e4796d641549bC3',
78
-
79
- // yearn
80
- 'YearnSupply': '0x3B8538B070a0890ef7E13FF60c9d19F893a93B8a',
81
- 'YearnWithdraw': '0x03CC90F24C23C9F766902917c32411417c28Db92',
82
-
83
- // liquity
84
- 'LiquityClose': '0x9C563dc9F8e3FcCF996DAB4b6B6003fb7Bbca90f',
85
- 'LiquityBorrow': '0x46e8fE6bbE3C08eCc250295583490be9ac97B969',
86
- 'LiquityOpen': '0x50D69350E2629987551C563E19D29dee6Faf3A78',
87
- 'LiquityPayback': '0x86eCa72dF81ae76AfF0dEeC01521154F33147e46',
88
- 'LiquityWithdraw': '0x8CDA51bB0D7E03252d554Ba5Bbb9254f3deB8441',
89
- 'LiquitySupply': '0x7d9157a022A263EFd34C867Fd261235D45B48453',
90
- 'LiquitySPDeposit': '0x20D85391A69E9906b67238cb82E51114dE7116a9',
91
- 'LiquitySPWithdraw': '0x621ac2A927cc9323C23f7792e8FD25aAbc9cC04B',
92
- 'LiquityStake': '0xF0782DE9d734e54aa080B985d6a9235880C48Fe5',
93
- 'LiquityUnstake': '0xc39DdBa031D014BFC1E3b6158842Ffb43f8D47e9',
94
- 'LiquityEthGainToTrove': '0x60427bD08785527FDca7d84d2A75871273E9F209',
95
- 'LiquityClaim': '0x5a2E638DE65323c55f1245f920B84dB4603002eE',
96
- 'LiquityRedeem': '0x6C5Dd88D033c8857254Cc94098BF75Ac275B17c7',
97
-
98
- // lido
99
- 'LidoStake': '0x71D44c05B94438fe09a4A7F4dB75fb421dEC1067',
100
- 'LidoWrap': '0x752e08eB2882DA273Cb8b70151f6c6c33f34D62b',
101
- 'LidoUnwrap': '0x37800CF1Fe630efc5F2E15A2e182E5C5084861D9',
102
-
103
- // insta
104
- 'ClaimInstMaker': '0x15E22A8160F0bDb619C6846C982F8D208A5670D2',
105
- 'InstPullTokens': '0x37FC940Be30e11d578243dEBea4f9B950E22aC99',
106
-
107
- // balancer
108
- 'BalancerV2Supply': '0xD78E5D95A28a67F7851b0a94505790813A92E405',
109
- 'BalancerV2Withdraw': '0xCcf4b96407BEF25D7df1c95045CCF64950e73E97',
110
- 'BalancerV2Claim': '0x259Ae83567858B7960d2De0D00F3717a764aD73B',
111
-
112
- // GUni
113
- 'GUniWithdraw': '0xa329263fFac25F86E03481Ec39307bbf5DbeDD83',
114
- 'GUniDeposit': '0xe943958f01630038c23f8471a2d0ea4378e58b0d',
115
-
116
- // Rari
117
- 'RariDeposit': '0xC627A3F12c4f7236218a511DC10e3f5ead1a1D7c',
118
- 'RariWithdraw': '0x8408EeCcC2c2FC25F2cF720398DAAD0A05EfE487',
119
-
120
- // mStable
121
- 'MStableDeposit': '0x1887235CFE1927782a3e7eD15fb073586c949858',
122
- 'MStableWithdraw': '0xb164456190577fbBe8FB8bF5Fa48a106b328A579',
123
-
124
- 'MStableDepositNew': '0x2AFfE3899d985212aD8ee99e1269D7Dd17576f1d',
125
- 'MStableWithdrawNew': '0x6468215Bf4811244Ab78599e1df9206716A35aB7',
126
-
127
- 'MStableClaim': '0x28279A806aDeDedFD33e39C7375dc0c0ee943847',
128
-
129
- 'CurveStethPoolDeposit': '0x0f042a5CC97C4cd8D8136c28F966839f195D08B9',
130
- 'CurveStethPoolWithdraw': '0x2F4ad71Bd8045d0633B304BD2d94ef349eB09105',
4
+ [NETWORKS.ethereum.chainId]: {
5
+ // utils
6
+ WrapEth: '0x8EbBd35f84D7f0DFCBEf08fD30CD09176133251A',
7
+ UnwrapEth: '0xDB6C8cFDd7c1C0F8895CDBC01Dbf4A6D4B6d2a29',
8
+ PullToken: '0x254cA89a00d53ab61de2Ba5641DBDC01aE48aed4',
9
+ SendToken: '0x5612e490c9549486dF16b34EBfD0E8b6cF6a1717',
10
+ SumInputs: '0x70907d840aBBc984Fd949311d2f005e6aC4a4D7a',
11
+ SubInputs: '0xe1804b756188F63f723d2FECc02988D0Cc1aB823',
12
+ ChangeProxyOwner: '0x81cA52CfE66421d0ceF82d5F33230e43b5F23D2B',
13
+ TokenBalance: '0xa92B177950F1460119940436515FD857C24494BC',
14
+ AutomationV2Unsub: '0xe35Fb12fE9796847751076aCf5ee7d124108612C',
15
+
16
+ // exchange
17
+ DFSSell: '0x1abDDCae131ce200e66140d9fBd0C37F7a40e642',
18
+
19
+ // maker
20
+ McdGenerate: '0x2bF4586636329Ae930cFe085a1e57BAb4a8f741b',
21
+ McdGive: '0xD2dc5DA4172a3901C9f26c7cd29eFE656Fc20332',
22
+ McdMerge: '0x66c7f4C7e59b6e780142aaD5c9f427FA5F8dfFc6',
23
+ McdOpen: '0x72AFC60B90c976397C37B5c64DDc067Ea521D388',
24
+ McdPayback: '0xb7C2c78846493Bed18fa07B51fcc5EAFAc9d629C',
25
+ McdSupply: '0x91c3167aC51F92c2f720C6A8418FDF46060698A1',
26
+ McdWithdraw: '0x3c232F0ae183C3e2eb421e8e317318Dfe85a7b10',
27
+ McdClaim: '0xd78783b50227A84d43604843065494e2666182Ab',
28
+
29
+ // reflexer
30
+ ReflexerSupply: '0xd7a36CD4ce7CCc2F1376Dc5C48BaC84380A4f698',
31
+ ReflexerWithdraw: '0xD8a14d447AB6789F3bf1Eb763b6306db3FC3d666',
32
+ ReflexerPayback: '0xcC6838d8a61a4b29Ea565d39C38b830f1491cb29',
33
+ ReflexerGenerate: '0x8e8Fd178A5FAE3A29F9CB1A06aBBBCFd5B83beb7',
34
+ ReflexerOpen: '0x4704a7cBd4d913d1233765B70531D601b4384011',
35
+
36
+ // not deployed as currently not used
37
+ ReflexerNativeUniV2SaviourDeposit: '0x0000000000000000000000000000000000000000',
38
+ ReflexerNativeUniV2SaviourGetReserves: '0x0000000000000000000000000000000000000000',
39
+ ReflexerNativeUniV2SaviourWithdraw: '0x0000000000000000000000000000000000000000',
40
+
41
+ // aave
42
+ AaveBorrow: '0x1B95E800a869bc3F89914470a7901D93D1401cD1',
43
+ AavePayback: '0x066225964999F1D07C888c5Ac4a6C885bDa88b9A',
44
+ AaveSupply: '0xEbB200a529058B561B42Eab510DA157a63243CEc',
45
+ AaveWithdraw: '0x754C58fA92246414a448c1ed44ea3D1AD446d482',
46
+ AaveCollateralSwitch: '0xFf5dfF1B90bd5Aa6E12768AB497dB90cc9DE6F5d',
47
+
48
+ // compound
49
+ CompBorrow: '0x8495579BF6Ae848f7E59686536F834f1d2CCd79C',
50
+ CompClaim: '0x81F488cF7A0128A9DB5e7207042cCAB1CB0ac902',
51
+ CompPayback: '0x2881590d5FfBd1e88BFc0Dc292f10e5377977f87',
52
+ CompSupply: '0xB4CEDe40b249b756Ce0EAa3e14F6af89f25f9a3d',
53
+ CompWithdraw: '0x3792F83D6A82091cb53052458038CC86e206463F',
54
+ CompGetDebt: '0xc2B8f8423bc8Fe2e9A44cA9d364d835D1751b725',
55
+ CompCollateralSwitch: '0xC3d89139508A3883775D3d1E62E2A0fea363b448',
56
+
57
+ // flashloan
58
+ FLAaveV2: '0x6fE6B0eeeeC7B05d663A99C0805E1A18FbdC6E59', // CHECK IF REDEPLOY
59
+ FLDyDx: '0x08AC78B418fCB0DDF1096533856A757C28d430d7',
60
+ FLMaker: '0xd393582bE148A45585aB202Fa7Cc789Fa5127223',
61
+ FLBalancer: '0x5C7a9f4635AE4F95da2e45317311AAe255FB71B3',
62
+
63
+ // uniswap
64
+ UniSupply: '0x9935e12F0218E61c27D7f23eAC9A9D6881a078eC',
65
+ UniWithdraw: '0xf8bb8F68b0A45DC315F3f7602a60cfb274B00951',
66
+
67
+ // uniswap V3
68
+ UniCollectV3: '0x331D7C3F6E710cB6cFE94c4Aa04AC3345AC00e00',
69
+ UniMintV3: '0x3dF75BE8Fb0a6186BE9705cACaa6dD2a4Ec3e40C',
70
+ UniSupplyV3: '0x0CA4255b37DD083dBD48Ca74d575F46037992520',
71
+ UniWithdrawV3: '0xe06224593D9c860B2fBF39eEA3b9B8A85b77Fbc4',
72
+ UniCreatePoolV3: '0x9058aAbEdEfe652b1d85DBBAB48Dfa78db613C44',
73
+
74
+ // dydx
75
+ DyDxWithdraw: '0x827089C5Fc7653655c4080c660Cd8f755F818443',
76
+
77
+ // yearn
78
+ YearnSupply: '0x837D6E7F469b3cC820B0a6Da25415D5aE0A861c4',
79
+ YearnWithdraw: '0x563eF9b1075628E62aDc657702517dEA72ca08d6', // CHECK IF REDEPLOY
80
+
81
+ // liquity
82
+ LiquityClose: '0x4B2d174129789a88e92D46342201F207132144b7',
83
+ LiquityBorrow: '0xF978d6C5c8af80a059AdB85EEb64F14C9c436D68',
84
+ LiquityOpen: '0x4EFF392cc69B31Ad159EcfA10305251b2d8E40E0',
85
+ LiquityPayback: '0x8fc7D24414e9740ed9841d9205D458e3677e71f7',
86
+ LiquityWithdraw: '0x733F53579bEcdd3Ed07e745A55Ee9af8B9669048',
87
+ LiquitySupply: '0xD539943e080C2a29e3f1DB2d45Ea7240d7ddDEE2',
88
+ LiquitySPDeposit: '0x5aB0244a00a733f16E6b238B462bdF3538C698E1',
89
+ LiquitySPWithdraw: '0xa71817957eaF993fAA9a1F4B5c2402c0aeFCd9C6',
90
+ LiquityStake: '0x671280800B540cbF073561d84A297a2c4c5D529F',
91
+ LiquityUnstake: '0x86FDD4A6438D448a794A44ABBe47D57590b3350d',
92
+ LiquityEthGainToTrove: '0x65e19f967B3F3cB6466110aD238039F5423E3177',
93
+ LiquityClaim: '0x526735aDcBe5c9059275c5ED2E0574b4a24b875e',
94
+ LiquityRedeem: '0x20B78854658011394C931EF2BF3cEEA2Fe62E7f0',
95
+
96
+ // lido
97
+ LidoStake: '0x4a7dd38D2BcA817fb68165155F869ca4179d8060',
98
+ LidoWrap: '0xE637544390db79EdDE0a9CAF352ED0FfF7451bDB',
99
+ LidoUnwrap: '0x910F73Fb8C0Bd15423c0D0BaD9F1ed95187a48fD',
100
+
101
+ // insta
102
+ InstPullTokens: '0xf2c87782D6Eff0511e82007119BAC40e9ba86F69',
103
+
104
+ // balancer
105
+ BalancerV2Supply: '0xE48123018Db5e9075841C61EA702cEca51621191',
106
+ BalancerV2Withdraw: '0xbED38692438b90AF738F8A7A3142C217DE8fB069',
107
+ BalancerV2Claim: '0xEac7c5bEFaA6E17f1A2e86947eEd6419c74A7C03',
108
+
109
+ // GUni
110
+ GUniWithdraw: '0x6F7cD7C0Dd3634E14bAB91FDF3bCE0a4315b3C59',
111
+ GUniDeposit: '0xb247cD4cab056800cCDa7cE1AFB781a8bFA9b57A',
112
+
113
+ // Rari
114
+ RariDeposit: '0x77A05c15f62F1fA6471D466001E21C1B189fcA9F',
115
+ RariWithdraw: '0xa052eD427EFa63B5bb87c409449a47e7C50317e3',
116
+
117
+ // mStable
118
+ MStableDeposit: '0xdf24ed1250fbfa274316b50Bc9A009aFA8F61E16',
119
+ MStableWithdraw: '0xa4d5d3e56012C1eD8aba4bE246964962DC3F735f',
120
+
121
+ MStableClaim: '0xD56F0EC66267958e08c91547c259cCAC006BF118',
122
+
123
+ McdRatioCheck: '0x3f09773e5e945C6Aa1bc8a8B3492f507620DE1e1',
124
+ GasFeeTaker: '0x431F1E1A9859EF99953801dbdeB31d2846ADcc0d',
125
+
126
+ CurveStethPoolDeposit: '0x0f042a5CC97C4cd8D8136c28F966839f195D08B9', // REDEPLOY
127
+ CurveStethPoolWithdraw: '0x2F4ad71Bd8045d0633B304BD2d94ef349eB09105', // REDEPLOY
128
+ },
129
+ [NETWORKS.optimism.chainId]: {
130
+ DFSSell: '0xf6814226b87303ad32567c1f02ea9fbc6b9c0288',
131
+ //
132
+ // // Deployed on fork id: 5ec01a9a-a2f0-49ad-8e90-0bfbeb760f69
133
+ // AaveV3Supply: '0xe5f14fbaa7ad7fa471e5fc33272420343b2bed31',
134
+ // AaveV3Borrow: '0x342af8144bfc01fbf7f64972fe7bc168d21e96ac',
135
+ // AaveV3Withdraw: '0xcac76ef428f6c9285b0a2874bab781ca32b2c864',
136
+ // AaveV3SetEMode: '0x3a37401d17f08651a513f02abf72b7d373aabb90',
137
+ // AaveV3Payback: '0x5235e785c10022f8e56b78fe15e1732c32a0a09c',
138
+ // AaveV3CollateralSwitch: '0xf0791f26bddcdc263f3d45e75d82fb6ffa62d85f',
139
+ // AaveV3ATokenPayback: '0xbb42b1f9ecec45e85c268f2a0020948c282a6687',
140
+ },
131
141
  };
132
142
 
133
143
  const otherAddresses = {
134
- Empty: '0x0000000000000000000000000000000000000000',
135
- McdCdpManager: '0x5ef30b9986345249bc32d8928b7ee64de9435e39',
136
- BCdpManager: '0x3f30c2381CD8B917Dd96EB2f1A4F96D91324BBed',
137
- AaveDefaultMarket: '0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5',
138
- ProxyRegistry: '0x4678f0a6958e4D2Bc4F1BAF7Bc52E8F3564f3fE4',
139
- DFSProxyRegistry: '0x29474FdaC7142f9aB7773B8e38264FA15E3805ed',
140
- UniswapV3PositionManager : '0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
141
- RaiWethUniV2LPToken : '0x8aE720a71622e824F576b4A8C03031066548A3B1',
142
- BalancerToken : '0xba100000625a3754423978a60c9317c58a424e3D',
143
- CrvToken: '0xD533a949740bb3306d119CC777fa900bA034cd52',
144
- DAI: '0x6b175474e89094c44da98b954eedeac495271d0f',
145
- }
144
+ [NETWORKS.ethereum.chainId]: {
145
+ RecipeExecutor: '0xe822d76c2632FC52f3eaa686bDA9Cea3212579D8',
146
+ DFSRegistry: '0x287778F121F134C66212FB16c9b53eC991D32f5b',
147
+ DFSProxyRegistry: '0x29474FdaC7142f9aB7773B8e38264FA15E3805ed',
148
+ ProxyRegistry: '0x4678f0a6958e4D2Bc4F1BAF7Bc52E8F3564f3fE4',
149
+
150
+ McdCdpManager: '0x5ef30b9986345249bc32d8928b7ee64de9435e39',
151
+ BCdpManager: '0x3f30c2381CD8B917Dd96EB2f1A4F96D91324BBed',
152
+ AaveDefaultMarket: '0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5',
153
+ UniswapV3PositionManager : '0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
154
+ RaiWethUniV2LPToken : '0x8aE720a71622e824F576b4A8C03031066548A3B1',
155
+ BalancerToken : '0xba100000625a3754423978a60c9317c58a424e3D',
156
+ CrvToken: '0xD533a949740bb3306d119CC777fa900bA034cd52',
157
+ DAI: '0x6b175474e89094c44da98b954eedeac495271d0f',
158
+ Empty: '0x0000000000000000000000000000000000000000',
159
+ },
160
+ [NETWORKS.optimism.chainId]: {
161
+ RecipeExecutor: '0x5c1cFF487Bed642f27b4B931617A96f22A2Dc5dC',
162
+ DFSRegistry: '0xA1A445d1d8F97cBf380E98759230FcC0f2E23fc1',
163
+ ProxyRegistry: '0x283Cc5C26e53D66ed2Ea252D986F094B37E6e895',
164
+
165
+ DSGuardFactory: '0xc19d0F1E2b38AA283E226Ca4044766A43aA7B02b',
166
+ AdminVault: '0xB64dB2153861ddDE62c8038C6A3c6199FCfBD094',
167
+ DefisaverLogger: '0xC0986E9803a41542c5422dbe336F9B68C55E0a49',
168
+ Empty: '0x0000000000000000000000000000000000000000',
169
+ },
170
+ };
171
+
172
+ /**
173
+ *
174
+ * @param {string} name
175
+ * @param {chainId} chainId
176
+ * @returns {EthAddress}
177
+ */
178
+ const getAddr = (name, chainId) => {
179
+ const _chainId = typeof chainId === 'undefined' ? CONFIG.chainId : chainId;
146
180
 
181
+ const actions = actionAddresses[_chainId];
182
+ const other = otherAddresses[_chainId];
147
183
 
148
- const getAddr = (name) => {
149
- if (!actionAddresses[name] && !otherAddresses[name]) return otherAddresses.Empty;
184
+ if (!actions && !other) throw new Error(`Cannot find address for chainId: ${_chainId}.`);
185
+ if (!actions[name] && !other[name]) throw new Error(`Cannot find address for name: ${name} (chainId: ${_chainId}).`);
150
186
 
151
- return actionAddresses[name] || otherAddresses[name];
187
+ return actions[name] || other[name];
152
188
  };
153
189
 
154
190
  module.exports = {
package/src/config.js ADDED
@@ -0,0 +1,74 @@
1
+ const dfsTokensSetConfig = require("@defisaver/tokens").set;
2
+ /**
3
+ *
4
+ * @type {Networks}
5
+ */
6
+ const NETWORKS = {
7
+ ethereum: {
8
+ chainId: 1,
9
+ chainName: 'Ethereum Mainnet',
10
+ blockExplorerUrls: ['https://etherscan.io/'],
11
+ iconUrls: [],
12
+ rpcUrls: [],
13
+ nativeCurrency: { name: 'Ethereum', decimals: 18, symbol: 'ETH' },
14
+ },
15
+ optimism: {
16
+ chainId: 10,
17
+ chainName: 'Optimism',
18
+ blockExplorerUrls: ['https://optimistic.etherscan.io/'],
19
+ iconUrls: ['https://gateway.optimism.io/favicon.ico'],
20
+ rpcUrls: ['https://mainnet.optimism.io'],
21
+ nativeCurrency: { name: 'Ethereum', decimals: 18, symbol: 'ETH' },
22
+ },
23
+ arbitrum: {
24
+ chainId: 42161,
25
+ chainName: 'Arbitrum One',
26
+ blockExplorerUrls: ['https://arbiscan.io/'],
27
+ iconUrls: ['https://bridge.arbitrum.io/logo.png'],
28
+ rpcUrls: ['https://arb1.arbitrum.io/rpc'],
29
+ nativeCurrency: { name: 'Ethereum', decimals: 18, symbol: 'ETH' },
30
+ },
31
+ };
32
+
33
+ /**
34
+ *
35
+ * @type {Config}
36
+ */
37
+ const CONFIG = {
38
+ chainId: NETWORKS.ethereum.chainId,
39
+ };
40
+
41
+ /**
42
+ *
43
+ * @param {chainId} chainId
44
+ * @returns {Network}
45
+ */
46
+ const getNetworkData = (chainId) => {
47
+ const networkData = Object.values(NETWORKS).find((network) => network.chainId === +chainId);
48
+
49
+ if (!networkData) throw new Error(`Cannot find network data for chainId: ${chainId}`);
50
+
51
+ return networkData;
52
+ }
53
+
54
+ /**
55
+ *
56
+ * @param {Config} config
57
+ */
58
+ const configure = (config) => {
59
+ if (!config || typeof config !== 'object') throw new Error('Object expected');
60
+
61
+ const newKeys = Object.keys(config);
62
+
63
+ newKeys.forEach((key) => {
64
+ CONFIG[key] = config[key]
65
+ if (key === 'chainId') dfsTokensSetConfig('network', config[key]);
66
+ });
67
+ };
68
+
69
+ module.exports = {
70
+ configure,
71
+ CONFIG,
72
+ NETWORKS,
73
+ getNetworkData,
74
+ }
@@ -0,0 +1,12 @@
1
+ const Action = require("../Action");
2
+ const {getAddr} = require("../addresses.js");
3
+
4
+ class ChainLinkPriceTrigger extends Action {
5
+
6
+ constructor(tokenAddr, price, state) {
7
+ super("ChainLinkPriceTrigger", getAddr("ChainLinkPriceTrigger"), [["address", "uint256", "uint8"]], [[...arguments]]);
8
+ }
9
+
10
+ }
11
+
12
+ module.exports = ChainLinkPriceTrigger;
@@ -0,0 +1,11 @@
1
+ const Action = require("../Action");
2
+ const {getAddr} = require("../addresses.js");
3
+
4
+ class CompoundRatioTrigger extends Action {
5
+
6
+ constructor(user, ratio, state) {
7
+ super("CompoundRatioTrigger", getAddr("CompoundRatioTrigger"), [["address", "uint256", "uint8"]], [[...arguments]]);
8
+ }
9
+ }
10
+
11
+ module.exports = CompoundRatioTrigger;
@@ -0,0 +1,11 @@
1
+ const Action = require("../Action");
2
+ const {getAddr} = require("../addresses.js");
3
+
4
+ class GasPriceTrigger extends Action {
5
+
6
+ constructor(maxGasPrice) {
7
+ super("GasPriceTrigger", getAddr("GasPriceTrigger"), [["uint256"]], [[...arguments]]);
8
+ }
9
+ }
10
+
11
+ module.exports = GasPriceTrigger;
@@ -0,0 +1,16 @@
1
+ const Action = require("../Action");
2
+ const {getAddr} = require("../addresses");
3
+
4
+ class LiquityRatioTrigger extends Action {
5
+
6
+ constructor(troveOwner, ratio, state) {
7
+ super(
8
+ "LiquityRatioTrigger",
9
+ getAddr("LiquityRatioTrigger"),
10
+ [["addresss", "uint256", "uint8"]],
11
+ [[...arguments]]
12
+ );
13
+ }
14
+ }
15
+
16
+ module.exports = LiquityRatioTrigger;
@@ -0,0 +1,15 @@
1
+ const Action = require("../Action");
2
+ const {getAddr} = require("../addresses.js");
3
+
4
+ class MakerRatioTrigger extends Action {
5
+
6
+ constructor(vaultId, ratio, state) {
7
+ super("McdRatioTrigger", getAddr("McdRatioTrigger"), [["uint256", "uint256", "uint8"]], [[...arguments]]);
8
+ }
9
+
10
+ async getEthValue() {
11
+ return this.args[0];
12
+ }
13
+ }
14
+
15
+ module.exports = MakerRatioTrigger;
@@ -0,0 +1,11 @@
1
+ const Action = require("../Action");
2
+ const {getAddr} = require("../addresses");
3
+
4
+ class ReflexerRatioTrigger extends Action {
5
+
6
+ constructor(vaultId, ratio, state) {
7
+ super("ReflexerRatioTrigger", getAddr("ReflexerRatioTrigger"), [["uint256", "uint256", "uint8"]], [[...arguments]]);
8
+ }
9
+ }
10
+
11
+ module.exports = ReflexerRatioTrigger;
@@ -0,0 +1,11 @@
1
+ const Action = require("../Action");
2
+ const {getAddr} = require("../addresses.js");
3
+
4
+ class TimestampTrigger extends Action {
5
+
6
+ constructor(nextTimestamp) {
7
+ super("TimestampTrigger", getAddr("TimestampTrigger"), [["uint256"]], [[...arguments]]);
8
+ }
9
+ }
10
+
11
+ module.exports = TimestampTrigger;
@@ -0,0 +1,12 @@
1
+ const Action = require("../Action");
2
+ const {getAddr} = require("../addresses.js");
3
+
4
+ class UniV3CurrentTickTrigger extends Action {
5
+
6
+ constructor(tokenId, state) {
7
+ super("UniV3CurrentTickTrigger", getAddr("UniV3CurrentTickTrigger"), [["uint256", "uint8"]], [[...arguments]]);
8
+ }
9
+
10
+ }
11
+
12
+ module.exports = UniV3CurrentTickTrigger;
@@ -0,0 +1,19 @@
1
+ const MakerRatioTrigger = require('./MakerRatioTrigger');
2
+ const ChainLinkPriceTrigger = require('./ChainLinkPriceTrigger');
3
+ const UniV3CurrentTickTrigger = require('./UniV3CurrentTickTrigger');
4
+ const TimestampTrigger = require('./TimestampTrigger');
5
+ const GasPriceTrigger = require('./GasPriceTrigger');
6
+ const CompoundRatioTrigger = require('./CompoundRatioTrigger');
7
+ const ReflexerRatioTrigger = require('./ReflexerRatioTrigger');
8
+ const LiquityRatioTrigger = require('./LiquityRatioTrigger');
9
+
10
+ module.exports = {
11
+ MakerRatioTrigger,
12
+ ChainLinkPriceTrigger,
13
+ UniV3CurrentTickTrigger,
14
+ TimestampTrigger,
15
+ GasPriceTrigger,
16
+ CompoundRatioTrigger,
17
+ ReflexerRatioTrigger,
18
+ LiquityRatioTrigger,
19
+ }
package/src/types.js CHANGED
@@ -3,6 +3,11 @@
3
3
  * @typedef {string} EthAddress
4
4
  */
5
5
 
6
+ /**
7
+ * Chain ID number of the Network
8
+ * @typedef {number} chainId
9
+ */
10
+
6
11
  /**
7
12
  * Maker vault ID
8
13
  * @typedef {(string|number)} VaultId
@@ -18,3 +23,31 @@
18
23
  /**
19
24
  * @typedef {Array<AccessListItem>} AccessList
20
25
  */
26
+
27
+ /**
28
+ * Global configuration object
29
+ * @typedef {Object.<string, any>} Config
30
+ * @property {chainId}
31
+ */
32
+
33
+ /**
34
+ * @typedef {object} NativeCurrency
35
+ * @property {string} name
36
+ * @property {string} symbol
37
+ * @property {number} decimals
38
+ */
39
+
40
+ /**
41
+ * @typedef {object} Network
42
+ * @property {chainId} chainId
43
+ * @property {string} chainName
44
+ * @property {array<string>} blockExplorerUrls
45
+ * @property {array<string>} iconUrls
46
+ * @property {array<string>} rpcUrls
47
+ * @property {NativeCurrency} nativeCurrency
48
+ */
49
+
50
+ /**
51
+ * @typedef Networks
52
+ * @type {Object.<string, Network>}
53
+ */
@@ -2,6 +2,8 @@ const Dec = require('decimal.js');
2
2
  const {getAssetInfo} = require('@defisaver/tokens');
3
3
 
4
4
  module.exports.requireAddress = (address) => {
5
+ if (address.startsWith('%') || address.startsWith('&')) return;
6
+
5
7
  if (typeof address !== 'string') throw new Error('Address is not a string');
6
8
  if (address === '') throw new Error('Address is empty string');
7
9
  if (address.length < 42) throw new Error(`Address too short (${address.length} instead of 42)`);