@defisaver/sdk 0.1.24 → 0.2.0

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/index.js CHANGED
@@ -2,9 +2,6 @@ const Action = require('./src/Action');
2
2
  const Recipe = require('./src/Recipe');
3
3
  const Strategy = require('./src/Strategy');
4
4
  const DfsWeb3 = require('./src/DfsWeb3');
5
- const {
6
- configure, getNetworkData, CONFIG, NETWORKS,
7
- } = require('./src/config');
8
5
 
9
6
  const actions = require('./src/actions/');
10
7
  const triggers = require('./src/triggers/');
@@ -15,15 +12,9 @@ module.exports = {
15
12
  Action,
16
13
  Recipe,
17
14
  Strategy,
18
- DfsWeb3,
19
-
20
15
  actions,
21
16
  triggers,
17
+ actionAddresses,
22
18
  utils,
23
-
24
- configure,
25
- getNetworkData,
26
- networks: NETWORKS,
27
- actionAddressesAllChains: actionAddresses,
28
- actionAddresses: actionAddresses[CONFIG.chainId],
19
+ DfsWeb3,
29
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/sdk",
3
- "version": "0.1.24",
3
+ "version": "0.2.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/Action.js CHANGED
@@ -1,6 +1,5 @@
1
1
  const AbiCoder = require('web3-eth-abi');
2
2
  const { keccak256, padLeft, toHex } = require('web3-utils');
3
- const { CONFIG } = require('./config');
4
3
 
5
4
  const ActionAbi = require('./abis/Action.json');
6
5
 
@@ -108,18 +107,13 @@ class Action {
108
107
  * @private
109
108
  */
110
109
  _encodeForCall() {
111
- return this.args.map((arg, i) => {
110
+ const bytesEncodedArgs = this.args.map((arg, i) => {
112
111
  let paramType = this.paramTypes[i];
113
112
  let _arg = this._replaceWithPlaceholders(arg, paramType);
114
113
  let _paramType = this._formatType(paramType);
115
114
  return AbiCoder.encodeParameter(_paramType, _arg);
116
115
  });
117
- }
118
-
119
- encodeForL2DsProxyCall() {
120
- // TODO fix this mess
121
- const executeActionDirectAbi = ActionAbi.find(({ name }) => name === 'executeActionDirect');
122
- return AbiCoder.encodeFunctionCall(executeActionDirectAbi, this._encodeForCall());
116
+ return bytesEncodedArgs;
123
117
  }
124
118
 
125
119
  /**
@@ -127,15 +121,11 @@ class Action {
127
121
  * @returns {Array<string>} `address` & `data` to be passed on to DSProxy's `execute(address _target, bytes memory _data)`
128
122
  */
129
123
  encodeForDsProxyCall() {
130
- if (CONFIG.chainId === 1) {
131
- const executeActionDirectAbi = ActionAbi.find(({ name }) => name === 'executeActionDirect');
132
- return [
133
- this.contractAddress,
134
- AbiCoder.encodeFunctionCall(executeActionDirectAbi, this._encodeForCall()),
135
- ];
136
- } else {
137
- return [this.contractAddress, this.encodeForL2DsProxyCall()];
138
- }
124
+ const executeActionDirectAbi = ActionAbi.find(({ name }) => name === 'executeActionDirect');
125
+ return [
126
+ this.contractAddress,
127
+ AbiCoder.encodeFunctionCall(executeActionDirectAbi, this._encodeForCall()),
128
+ ];
139
129
  }
140
130
 
141
131
  /**
@@ -0,0 +1,36 @@
1
+ const Action = require("../../Action");
2
+ const {requireAddress} = require("../../utils/general");
3
+ const {getAssetInfoByAddress} = require("@defisaver/tokens");
4
+ const { getAddr } = require('../../addresses.js');
5
+
6
+ /**
7
+ * Transfers specified token from recipe (DsProxy) to specified address unwraps if Weth address
8
+ */
9
+ class SendTokenAndUnwrapAction extends Action {
10
+ /**
11
+ * @param token {string} Token address
12
+ * @param to {string} Transfer recipient
13
+ * @param amount {string} Transfer amount (-1 for whole Recipe (DsProxy) balance)
14
+ */
15
+ constructor(token, to, amount) {
16
+ requireAddress(to);
17
+ super(
18
+ 'SendTokenAndUnwrap',
19
+ getAddr('SendTokenAndUnwrap'),
20
+ [[
21
+ "address",
22
+ "address",
23
+ "uint",
24
+ ]],
25
+ [[...arguments]]
26
+ );
27
+
28
+ this.mappableArgs = [
29
+ this.args[0][0],
30
+ this.args[0][1],
31
+ this.args[0][2],
32
+ ];
33
+ }
34
+ }
35
+
36
+ module.exports = SendTokenAndUnwrapAction;
@@ -0,0 +1,19 @@
1
+ const Action = require("../../Action");
2
+ const {getAddr} = require("../../addresses.js");
3
+
4
+ /**
5
+ * Action for updating sub data
6
+ */
7
+ class UpdateSubAction extends Action {
8
+ /**
9
+ * @param subId id of the subscription in the SubStorage contract
10
+ * @param sub object that contains new sub information
11
+ */
12
+ constructor(subId, sub) {
13
+ super("UpdateSub", getAddr("UpdateSub"), [["uint256", "(uint64,bool,bytes[],bytes32[])"]], [[...arguments]]);
14
+
15
+ }
16
+
17
+ }
18
+
19
+ module.exports = UpdateSubAction;
@@ -1,5 +1,6 @@
1
1
  const SellAction = require('./SellAction');
2
2
  const SendTokenAction = require('./SendTokenAction');
3
+ const SendTokenAndUnwrapAction = require('./SendTokenAndUnwrapAction');
3
4
  const PullTokenAction = require('./PullTokenAction');
4
5
  const WrapEthAction = require('./WrapEthAction');
5
6
  const UnwrapEthAction = require('./UnwrapEthAction');
@@ -9,6 +10,7 @@ const ChangeProxyOwnerAction = require('./ChangeProxyOwnerAction');
9
10
  const TokenBalanceAction = require('./TokenBalanceAction');
10
11
  const AutomationV2Unsub = require('./AutomationV2Unsub');
11
12
  const GasFeeAction = require('./GasFeeAction');
13
+ const UpdateSubAction = require('./UpdateSubAction');
12
14
 
13
15
  module.exports = {
14
16
  SellAction,
@@ -22,4 +24,6 @@ module.exports = {
22
24
  TokenBalanceAction,
23
25
  AutomationV2Unsub,
24
26
  GasFeeAction,
27
+ UpdateSubAction,
28
+ SendTokenAndUnwrapAction,
25
29
  };
@@ -17,7 +17,6 @@ const curve = require('./curve');
17
17
  const guni = require('./guni');
18
18
  const mstable = require('./mstable');
19
19
  const rari = require('./rari');
20
- const aaveV3 = require('./aaveV3');
21
20
 
22
21
  module.exports = {
23
22
  maker,
@@ -39,5 +38,4 @@ module.exports = {
39
38
  guni,
40
39
  mstable,
41
40
  rari,
42
- aaveV3,
43
41
  };
package/src/addresses.js CHANGED
@@ -1,190 +1,154 @@
1
- const { CONFIG, NETWORKS } = require('./config');
1
+
2
2
 
3
3
  const actionAddresses = {
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
- },
4
+ 'RecipeExecutor': '0xe822d76c2632FC52f3eaa686bDA9Cea3212579D8',
5
+ 'DFSRegistry': '0x287778F121F134C66212FB16c9b53eC991D32f5b',
6
+
7
+ // utils
8
+ 'WrapEth': '0x8EbBd35f84D7f0DFCBEf08fD30CD09176133251A',
9
+ 'UnwrapEth': '0xDB6C8cFDd7c1C0F8895CDBC01Dbf4A6D4B6d2a29',
10
+ 'PullToken': '0x254cA89a00d53ab61de2Ba5641DBDC01aE48aed4',
11
+ 'SendToken': '0x5612e490c9549486dF16b34EBfD0E8b6cF6a1717',
12
+ 'SumInputs': '0x70907d840aBBc984Fd949311d2f005e6aC4a4D7a',
13
+ 'SubInputs': '0xe1804b756188F63f723d2FECc02988D0Cc1aB823',
14
+ 'ChangeProxyOwner': '0x81cA52CfE66421d0ceF82d5F33230e43b5F23D2B',
15
+ 'TokenBalance': '0xa92B177950F1460119940436515FD857C24494BC',
16
+ 'AutomationV2Unsub': '0xe35Fb12fE9796847751076aCf5ee7d124108612C',
17
+ 'SendTokenAndUnwrap': '0xeecd376026335261c89faD40D89625391b1eFF6a',
18
+
19
+ // exchange
20
+ 'DFSSell': '0x1abDDCae131ce200e66140d9fBd0C37F7a40e642',
21
+
22
+ // maker
23
+ 'McdGenerate': '0xCb50a91C0f12f439b8bf11E9474B9c1ED62Bf7a3',
24
+ 'McdGive': '0xf9556A87BF424834FDe7De0547b58E36Cb42EF01',
25
+ 'McdMerge': '0x6D06C6c2BCeaEC31b0F8Cd68C594120dDCcCC427',
26
+ 'McdOpen': '0x1b54e8b6073ac7382c42830BE715466aDA11Cf37',
27
+ 'McdPayback': '0xE68AeD979Af6f85516fF485D098804c0f9eD9A5b',
28
+ 'McdSupply': '0x84372e73e1A2E95510869D2D81A3ef1AEC9e0Da8',
29
+ 'McdWithdraw': '0xa704FBBe2f7ea8eF45a8280f6Bf96939eBC73252',
30
+ 'McdClaim': '0xc0FC0f5Ba156E16217F8C7f400AEc0a658419C13',
31
+
32
+ // reflexer
33
+ 'ReflexerSupply': '0xd7a36CD4ce7CCc2F1376Dc5C48BaC84380A4f698',
34
+ 'ReflexerWithdraw': '0xD8a14d447AB6789F3bf1Eb763b6306db3FC3d666',
35
+ 'ReflexerPayback': '0xcC6838d8a61a4b29Ea565d39C38b830f1491cb29',
36
+ 'ReflexerGenerate': '0x8e8Fd178A5FAE3A29F9CB1A06aBBBCFd5B83beb7',
37
+ 'ReflexerOpen': '0x4704a7cBd4d913d1233765B70531D601b4384011',
38
+
39
+ // not deployed as currently not used
40
+ 'ReflexerNativeUniV2SaviourDeposit':'0x0000000000000000000000000000000000000000',
41
+ 'ReflexerNativeUniV2SaviourGetReserves':'0x0000000000000000000000000000000000000000',
42
+ 'ReflexerNativeUniV2SaviourWithdraw':'0x0000000000000000000000000000000000000000',
43
+
44
+ // aave
45
+ 'AaveBorrow': '0x1B95E800a869bc3F89914470a7901D93D1401cD1',
46
+ 'AavePayback': '0x066225964999F1D07C888c5Ac4a6C885bDa88b9A',
47
+ 'AaveSupply': '0xEbB200a529058B561B42Eab510DA157a63243CEc',
48
+ 'AaveWithdraw': '0x754C58fA92246414a448c1ed44ea3D1AD446d482',
49
+ 'AaveCollateralSwitch': '0xFf5dfF1B90bd5Aa6E12768AB497dB90cc9DE6F5d',
50
+
51
+ // compound
52
+ 'CompBorrow': '0x8495579BF6Ae848f7E59686536F834f1d2CCd79C',
53
+ 'CompClaim': '0x81F488cF7A0128A9DB5e7207042cCAB1CB0ac902',
54
+ 'CompPayback': '0x2881590d5FfBd1e88BFc0Dc292f10e5377977f87',
55
+ 'CompSupply': '0xB4CEDe40b249b756Ce0EAa3e14F6af89f25f9a3d',
56
+ 'CompWithdraw': '0x3792F83D6A82091cb53052458038CC86e206463F',
57
+ 'CompGetDebt': '0xc2B8f8423bc8Fe2e9A44cA9d364d835D1751b725',
58
+ 'CompCollateralSwitch': '0xC3d89139508A3883775D3d1E62E2A0fea363b448',
59
+
60
+ // flashloan
61
+ 'FLAaveV2': '0xa4d52ED15018a5be4adE5796899e5d75cc8759C1',
62
+ 'FLDyDx': '0x08AC78B418fCB0DDF1096533856A757C28d430d7',
63
+ 'FLMaker': '0xd393582bE148A45585aB202Fa7Cc789Fa5127223',
64
+ 'FLBalancer': '0x5C7a9f4635AE4F95da2e45317311AAe255FB71B3',
65
+
66
+ // uniswap
67
+ 'UniSupply': '0x9935e12F0218E61c27D7f23eAC9A9D6881a078eC',
68
+ 'UniWithdraw': '0xf8bb8F68b0A45DC315F3f7602a60cfb274B00951',
69
+
70
+ // uniswap V3
71
+ 'UniCollectV3': '0x331D7C3F6E710cB6cFE94c4Aa04AC3345AC00e00',
72
+ 'UniMintV3': '0x3dF75BE8Fb0a6186BE9705cACaa6dD2a4Ec3e40C',
73
+ 'UniSupplyV3': '0x0CA4255b37DD083dBD48Ca74d575F46037992520',
74
+ 'UniWithdrawV3': '0xe06224593D9c860B2fBF39eEA3b9B8A85b77Fbc4',
75
+ 'UniCreatePoolV3': '0x9058aAbEdEfe652b1d85DBBAB48Dfa78db613C44',
76
+
77
+ // dydx
78
+ 'DyDxWithdraw': '0x827089C5Fc7653655c4080c660Cd8f755F818443',
79
+
80
+ // yearn
81
+ 'YearnSupply': '0x837D6E7F469b3cC820B0a6Da25415D5aE0A861c4',
82
+ 'YearnWithdraw': '0x563eF9b1075628E62aDc657702517dEA72ca08d6',
83
+
84
+ // liquity
85
+ 'LiquityClose': '0x4B2d174129789a88e92D46342201F207132144b7',
86
+ 'LiquityBorrow': '0xF978d6C5c8af80a059AdB85EEb64F14C9c436D68',
87
+ 'LiquityOpen': '0x4EFF392cc69B31Ad159EcfA10305251b2d8E40E0',
88
+ 'LiquityPayback': '0x8fc7D24414e9740ed9841d9205D458e3677e71f7',
89
+ 'LiquityWithdraw': '0x733F53579bEcdd3Ed07e745A55Ee9af8B9669048',
90
+ 'LiquitySupply': '0xD539943e080C2a29e3f1DB2d45Ea7240d7ddDEE2',
91
+ 'LiquitySPDeposit': '0x5aB0244a00a733f16E6b238B462bdF3538C698E1',
92
+ 'LiquitySPWithdraw': '0xa71817957eaF993fAA9a1F4B5c2402c0aeFCd9C6',
93
+ 'LiquityStake': '0x671280800B540cbF073561d84A297a2c4c5D529F',
94
+ 'LiquityUnstake': '0x86FDD4A6438D448a794A44ABBe47D57590b3350d',
95
+ 'LiquityEthGainToTrove': '0x65e19f967B3F3cB6466110aD238039F5423E3177',
96
+ 'LiquityClaim': '0x526735aDcBe5c9059275c5ED2E0574b4a24b875e',
97
+ 'LiquityRedeem': '0x20B78854658011394C931EF2BF3cEEA2Fe62E7f0',
98
+
99
+ // lido
100
+ 'LidoStake': '0x4a7dd38D2BcA817fb68165155F869ca4179d8060',
101
+ 'LidoWrap': '0xE637544390db79EdDE0a9CAF352ED0FfF7451bDB',
102
+ 'LidoUnwrap': '0x910F73Fb8C0Bd15423c0D0BaD9F1ed95187a48fD',
103
+
104
+ // insta
105
+ 'InstPullTokens': '0xf2c87782D6Eff0511e82007119BAC40e9ba86F69',
106
+
107
+ // balancer
108
+ 'BalancerV2Supply': '0xE48123018Db5e9075841C61EA702cEca51621191',
109
+ 'BalancerV2Withdraw': '0xbED38692438b90AF738F8A7A3142C217DE8fB069',
110
+ 'BalancerV2Claim': '0xEac7c5bEFaA6E17f1A2e86947eEd6419c74A7C03',
111
+
112
+ // GUni
113
+ 'GUniWithdraw': '0x6F7cD7C0Dd3634E14bAB91FDF3bCE0a4315b3C59',
114
+ 'GUniDeposit': '0xb247cD4cab056800cCDa7cE1AFB781a8bFA9b57A',
115
+
116
+ // Rari
117
+ 'RariDeposit': '0x77A05c15f62F1fA6471D466001E21C1B189fcA9F',
118
+ 'RariWithdraw': '0xa052eD427EFa63B5bb87c409449a47e7C50317e3',
119
+
120
+ // mStable
121
+ 'MStableDeposit': '0xdf24ed1250fbfa274316b50Bc9A009aFA8F61E16',
122
+ 'MStableWithdraw': '0xa4d5d3e56012C1eD8aba4bE246964962DC3F735f',
123
+
124
+ 'MStableClaim': '0xD56F0EC66267958e08c91547c259cCAC006BF118',
125
+
126
+ 'McdRatioCheck': '0x3f09773e5e945C6Aa1bc8a8B3492f507620DE1e1',
127
+ 'GasFeeTaker': '0x431F1E1A9859EF99953801dbdeB31d2846ADcc0d',
128
+
129
+ 'CurveStethPoolDeposit': '0x5Ae5870dC0C780e9eb68bE7a223eCd7F3BDad12B',
130
+ 'CurveStethPoolWithdraw': '0x4089731d843Ce52699Fe64F68556aBbD95D70D00',
141
131
  };
142
132
 
143
133
  const otherAddresses = {
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;
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
+ }
180
146
 
181
- const actions = actionAddresses[_chainId];
182
- const other = otherAddresses[_chainId];
183
147
 
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}).`);
148
+ const getAddr = (name) => {
149
+ if (!actionAddresses[name] && !otherAddresses[name]) return otherAddresses.Empty;
186
150
 
187
- return actions[name] || other[name];
151
+ return actionAddresses[name] || otherAddresses[name];
188
152
  };
189
153
 
190
154
  module.exports = {
@@ -1,5 +1,4 @@
1
1
  const Action = require("../Action");
2
- const {getAddr} = require("../addresses");
3
2
 
4
3
  class LiquityRatioTrigger extends Action {
5
4
 
@@ -1,5 +1,4 @@
1
1
  const Action = require("../Action");
2
- const {getAddr} = require("../addresses");
3
2
 
4
3
  class ReflexerRatioTrigger extends Action {
5
4
 
package/src/types.js CHANGED
@@ -3,11 +3,6 @@
3
3
  * @typedef {string} EthAddress
4
4
  */
5
5
 
6
- /**
7
- * Chain ID number of the Network
8
- * @typedef {number} chainId
9
- */
10
-
11
6
  /**
12
7
  * Maker vault ID
13
8
  * @typedef {(string|number)} VaultId
@@ -23,31 +18,3 @@
23
18
  /**
24
19
  * @typedef {Array<AccessListItem>} AccessList
25
20
  */
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
- */
package/test/index.js CHANGED
@@ -3,9 +3,6 @@ const {assert} = require('chai');
3
3
 
4
4
  describe('DFS', () => {
5
5
  it('Exports constructors', () => {
6
- assert.containsAllKeys(dfs, [
7
- 'Action', 'Recipe', 'actions', 'actionAddresses', 'utils', 'DfsWeb3', 'configure', 'getNetworkData', 'networks',
8
- 'actionAddressesAllChains',
9
- ]);
6
+ assert.containsAllKeys(dfs, ['Action', 'Recipe', 'actions', 'actionAddresses', 'utils', 'DfsWeb3']);
10
7
  })
11
8
  })
package/src/L2Action.js DELETED
@@ -1,44 +0,0 @@
1
- const Action = require('./Action');
2
- class L2Action extends Action {
3
- /**
4
- * Encode arguments for calling the action via DsProxy
5
- * @returns {string}
6
- */
7
- encodeForL2DsProxyCall() {
8
- return this.encodeInputs();
9
- }
10
-
11
- encodeInputs(){
12
- throw new Error('Use implementation from specific L2Action');
13
- }
14
-
15
- addressToBytes20(address){
16
- return address.slice(2);
17
- }
18
-
19
- boolToBytes1(bool){
20
- if (bool) {
21
- return '01';
22
- } else {
23
- return '00';
24
- }
25
- }
26
-
27
- numberToBytes2(number){
28
- const hexNumber = number.toString(16);
29
- return hexNumber.padStart(4, '0');
30
- }
31
-
32
- numberToBytes1(number){
33
- const hexNumber = number.toString(16);
34
- return hexNumber.padStart(2, '0');
35
- }
36
-
37
- numberToBytes32(number){
38
- let hexNumber = number.toHexString();
39
- hexNumber = hexNumber.slice(2);
40
-
41
- return hexNumber.padStart(64, '0');
42
- }
43
- }
44
- module.exports = L2Action;
@@ -1,53 +0,0 @@
1
- const L2Action = require("../../L2Action");
2
- const {getAssetInfoByAddress} = require("@defisaver/tokens");
3
- const { getAddr } = require('../../addresses.js');
4
-
5
- /**
6
- * AaveV3ATokenPaybackAction - Repay Aave V3 debt using aTokens
7
- */
8
- class AaveV3ATokenPaybackAction extends L2Action {
9
- /**
10
- * @param market {EthAddress} Address provider for specific market
11
- * @param amount {string} Amount of tokens to be payed back (uint.max for full debt)
12
- * @param from {EthAddress} Where are we pulling the payback aTokens from
13
- * @param rateMode {number} Type of borrow debt [Stable: 1, Variable: 2]
14
- * @param aTokenAddr {EthAddress} address of the aToken to be pulled
15
- * @param assetId {number} The id of the underlying asset to be repaid
16
- */
17
- constructor(market, amount, from, rateMode, aTokenAddr, assetId) {
18
- super('AaveV3Payback', getAddr('AaveV3Payback'),
19
- [['address','uint256','address','uint8','uint16']],
20
- [[market, amount, from, rateMode, assetId]]
21
- );
22
-
23
- this.mappableArgs = [
24
- this.args[0][0],
25
- this.args[0][1],
26
- this.args[0][2],
27
- ];
28
- this.addressForApproval = aTokenAddr;
29
- }
30
-
31
- async getAssetsToApprove() {
32
- const asset = getAssetInfoByAddress(this.addressForApproval);
33
- if (asset.symbol !== 'ETH') return [{asset: this.addressForApproval, owner: this.args[0][2]}];
34
- return [];
35
- }
36
- encodeInputs() {
37
- // executeActionDirectL2
38
- let encodedInput = "0x2895f3aa";
39
- // market
40
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][0]));
41
- // amount
42
- encodedInput = encodedInput.concat(this.numberToBytes32(this.args[0][1]));
43
- // from
44
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][2]));
45
- // rateMode
46
- encodedInput = encodedInput.concat(this.numberToBytes1(this.args[0][3]));
47
- // assetId
48
- encodedInput = encodedInput.concat(this.numberToBytes2(this.args[0][4]));
49
- return encodedInput;
50
- }
51
- }
52
-
53
- module.exports = AaveV3ATokenPaybackAction;
@@ -1,54 +0,0 @@
1
- const L2Action = require("../../L2Action");
2
- const { getAddr } = require('../../addresses.js');
3
-
4
- /**
5
- * AaveV3BorrowAction - Borrow a token from AaveV3
6
- */
7
- class AaveV3BorrowAction extends L2Action {
8
- /**
9
- * @param market {EthAddress} Address provider for specific market
10
- * @param amount {string} Amount of tokens to be borrowed
11
- * @param to {EthAddress} The address we are sending the borrowed tokens to
12
- * @param rateMode {number} Type of borrow debt [Stable: 1, Variable: 2]
13
- * @param assetId {number} The id of the token to be borrowed
14
- * @param useOnBehalf {boolean} use on behalf or default to proxy
15
- * @param onBehalf {EthAddress} On whose behalf we borrow the tokens, defaults to proxy
16
- */
17
- constructor(market, amount, to, rateMode, assetId, useOnBehalf , onBehalf = getAddr('Empty')) {
18
- super('AaveV3Borrow', getAddr('AaveV3Borrow'),
19
- [['address','uint256','address','uint8','uint16','bool', 'address']],
20
- [[market, amount, to, rateMode, assetId, useOnBehalf, onBehalf]]
21
- );
22
-
23
- this.mappableArgs = [
24
- this.args[0][0],
25
- this.args[0][1],
26
- this.args[0][2],
27
- this.args[0][6],
28
- ];
29
- }
30
-
31
- encodeInputs() {
32
- // executeActionDirectL2
33
- let encodedInput = "0x2895f3aa";
34
- // market
35
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][0]));
36
- // amount
37
- encodedInput = encodedInput.concat(this.numberToBytes32(this.args[0][1]));
38
- // to
39
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][2]));
40
- // rateMode
41
- encodedInput = encodedInput.concat(this.numberToBytes1(this.args[0][3]));
42
- // assetId
43
- encodedInput = encodedInput.concat(this.numberToBytes2(this.args[0][4]));
44
- // useOnBehalf
45
- encodedInput = encodedInput.concat(this.boolToBytes1(this.args[0][5]));
46
- if (this.args[0][5]) {
47
- // onBehalf
48
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][6]));
49
- }
50
- return encodedInput;
51
- }
52
- }
53
-
54
- module.exports = AaveV3BorrowAction;
@@ -1,41 +0,0 @@
1
- const L2Action = require("../../L2Action");
2
- const { getAddr } = require('../../addresses.js');
3
-
4
- /**
5
- * AaveV3CollateralSwitchAction - Aave enable/disable token usage as collateral for AaveV3 position
6
- */
7
- class AaveV3CollateralSwitchAction extends L2Action {
8
- /**
9
- * @param market {EthAddress} Address provider for specific market
10
- * @param arrayLength {number} length of two arrays
11
- * @param assetIds {Array<number>}
12
- * @param useAsCollateral {Array<boolean>}
13
- */
14
- constructor(market, arrayLength, assetIds, useAsCollateral) {
15
- super(
16
- 'AaveV3CollateralSwitch',
17
- getAddr('AaveV3CollateralSwitch'),
18
- [['address', 'uint8', 'uint16[]', 'bool[]']],
19
- [[market, arrayLength, assetIds, useAsCollateral]],
20
- );
21
- }
22
- encodeInputs() {
23
- // executeActionDirectL2
24
- let encodedInput = "0x2895f3aa";
25
- // market
26
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][0]));
27
- // arrayLength
28
- encodedInput = encodedInput.concat(this.numberToBytes1(this.args[0][1]));
29
- const arrayLength = this.args[0][1];
30
- for (let i = 0; i < arrayLength; i++){
31
- // assetIds[i]
32
- encodedInput = encodedInput.concat(this.numberToBytes2(this.args[0][2][i]));
33
- // useAsCollateral[i]
34
- encodedInput = encodedInput.concat(this.boolToBytes1(this.args[0][3][i]));
35
- }
36
-
37
- return encodedInput;
38
- }
39
- }
40
-
41
- module.exports = AaveV3CollateralSwitchAction;
@@ -1,63 +0,0 @@
1
- const L2Action = require("../../L2Action");
2
- const {getAssetInfoByAddress} = require("@defisaver/tokens");
3
- const { getAddr } = require('../../addresses.js');
4
-
5
- /**
6
- * AaveV3PaybackAction - Payback debt on Aave using underlying token
7
- */
8
- class AaveV3PaybackAction extends L2Action {
9
- /**
10
- * @param market {EthAddress} Address provider for specific market
11
- * @param amount {string} Amount of tokens to be payed back
12
- * @param from {EthAddress} Tokens will be supplied from this address
13
- * @param rateMode {number} Type of borrow debt [Stable: 1, Variable: 2]
14
- * @param tokenAddr {EthAddress} Address of underlying asset
15
- * @param assetId {number} The id of the underlying asset to be repaid
16
- * @param useOnBehalf {boolean} use on behalf param or default to proxy
17
- * @param onBehalf {EthAddress} For what user we are paying back the debt, defaults to proxy
18
- */
19
- constructor(market, amount, from, rateMode, tokenAddr, assetId, useOnBehalf , onBehalf = getAddr('Empty')) {
20
- super('AaveV3Payback', getAddr('AaveV3Payback'),
21
- [['address','uint256','address','uint8','uint16','bool', 'address']],
22
- [[market, amount, from, rateMode, assetId, useOnBehalf, onBehalf]]
23
- );
24
-
25
- this.mappableArgs = [
26
- this.args[0][0],
27
- this.args[0][1],
28
- this.args[0][2],
29
- this.args[0][6],
30
- ];
31
- this.tokenForApproval = tokenAddr;
32
- }
33
-
34
- async getAssetsToApprove() {
35
- const asset = getAssetInfoByAddress(this.tokenForApproval);
36
- if (asset.symbol !== 'ETH') return [{asset: this.tokenForApproval, owner: this.args[3]}];
37
- return [];
38
- }
39
-
40
- encodeInputs() {
41
- // executeActionDirectL2
42
- let encodedInput = "0x2895f3aa";
43
- // market
44
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][0]));
45
- // amount
46
- encodedInput = encodedInput.concat(this.numberToBytes32(this.args[0][1]));
47
- // from
48
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][2]));
49
- // rateMode
50
- encodedInput = encodedInput.concat(this.numberToBytes1(this.args[0][3]));
51
- // assetId
52
- encodedInput = encodedInput.concat(this.numberToBytes2(this.args[0][4]));
53
- // useOnBehalf
54
- encodedInput = encodedInput.concat(this.boolToBytes1(this.args[0][5]));
55
- if (this.args[0][5]) {
56
- // onBehalf
57
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][6]));
58
- }
59
- return encodedInput;
60
- }
61
- }
62
-
63
- module.exports = AaveV3PaybackAction;
@@ -1,35 +0,0 @@
1
- const L2Action = require("../../L2Action");
2
- const { getAddr } = require('../../addresses.js');
3
-
4
- /**
5
- * AaveV3SetEModeAction - Set EMode for the proxy AaveV3 position
6
- */
7
- class AaveV3SetEModeAction extends L2Action {
8
- /**
9
- * @param market {EthAddress} Address provider for specific market
10
- * @param categoryId {number} ID of the category emode
11
- */
12
- constructor(market, categoryId) {
13
- super('AaveV3SetEMode', getAddr('AaveV3SetEMode'),
14
- [['address','uint8']],
15
- [[market, categoryId]]
16
- );
17
-
18
- this.mappableArgs = [
19
- this.args[0][0],
20
- ];
21
- }
22
- encodeInputs() {
23
- // executeActionDirectL2
24
- let encodedInput = "0x2895f3aa";
25
- // market
26
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][0]));
27
- // assetId
28
- encodedInput = encodedInput.concat(this.numberToBytes1(this.args[0][1]));
29
- // amount
30
- return encodedInput;
31
- }
32
-
33
- }
34
-
35
- module.exports = AaveV3SetEModeAction;
@@ -1,64 +0,0 @@
1
- const L2Action = require("../../L2Action");
2
- const {getAssetInfoByAddress} = require("@defisaver/tokens");
3
- const { getAddr } = require('../../addresses.js');
4
-
5
- /**
6
- * AaveV3SupplyAction - Supply token to an aave position on Aave V3
7
- */
8
- class AaveV3SupplyAction extends L2Action {
9
-
10
- /**
11
- * @param market {EthAddress} Address provider for specific market
12
- * @param amount {string} Amount of tokens to be deposited
13
- * @param from {EthAddress} Tokens will be supplied from this address
14
- * @param tokenAddress {EthAddress} Address of the token
15
- * @param assetId {number} The id of the token to be deposited
16
- * @param enableAsColl {boolean} If we need to enable asset as collateral
17
- * @param useOnBehalf {boolean}
18
- * @param onBehalf {EthAddress} For what user we are supplying the tokens, defaults to proxy
19
- */
20
- constructor(market, amount, from, tokenAddress, assetId, enableAsColl, useOnBehalf , onBehalf = getAddr('Empty')) {
21
- super('AaveV3Supply', getAddr('AaveV3Supply'),
22
- [['address','uint256','address','uint16','bool','bool', 'address']],
23
- [[market, amount, from, assetId, enableAsColl, useOnBehalf, onBehalf]]
24
- );
25
-
26
- this.mappableArgs = [
27
- this.args[0][0],
28
- this.args[0][1],
29
- this.args[0][2],
30
- this.args[0][6],
31
- ];
32
- this.tokenForApproval = tokenAddress;
33
- }
34
-
35
- async getAssetsToApprove() {
36
- const asset = getAssetInfoByAddress(this.tokenForApproval);
37
- if (asset.symbol !== 'ETH') return [{asset: this.tokenForApproval, owner: this.args[0][2]}];
38
- return [];
39
- }
40
-
41
- encodeInputs() {
42
- // executeActionDirectL2
43
- let encodedInput = "0x2895f3aa";
44
- // market
45
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][0]));
46
- // assetId
47
- encodedInput = encodedInput.concat(this.numberToBytes2(this.args[0][3]));
48
- // amount
49
- encodedInput = encodedInput.concat(this.numberToBytes32(this.args[0][1]));
50
- // from
51
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][2]));
52
- // enableAsColl
53
- encodedInput = encodedInput.concat(this.boolToBytes1(this.args[0][4]));
54
- // useOnBehalf
55
- encodedInput = encodedInput.concat(this.boolToBytes1(this.args[0][5]));
56
- if (this.args[0][5]) {
57
- // onBehalf
58
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][6]));
59
- }
60
- return encodedInput;
61
- }
62
- }
63
-
64
- module.exports = AaveV3SupplyAction;
@@ -1,41 +0,0 @@
1
- const L2Action = require("../../L2Action");
2
- const { getAddr } = require('../../addresses.js');
3
-
4
- /**
5
- * AaveV3WithdrawAction - Withdraw a previously supplied token from a position in AaveV3
6
- */
7
- class AaveV3WithdrawAction extends L2Action {
8
- /**
9
- * @param market {EthAddress} Address provider for specific market
10
- * @param assetId {number} The id of the token to be deposited
11
- * @param amount {string} Amount of tokens to be withdrawn -> send type(uint).max for whole amount
12
- * @param to {EthAddress} Where the withdrawn tokens will be sent
13
- */
14
- constructor(market, assetId, amount, to) {
15
- super('AaveV3Withdraw', getAddr('AaveV3Withdraw'),
16
- [['address','uint16','uint256','address']],
17
- [[market, assetId, amount, to]]
18
- );
19
-
20
- this.mappableArgs = [
21
- this.args[0][0],
22
- this.args[0][2],
23
- this.args[0][3],
24
- ];
25
- }
26
- encodeInputs() {
27
- // executeActionDirectL2
28
- let encodedInput = "0x2895f3aa";
29
- // market
30
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][0]));
31
- // assetId
32
- encodedInput = encodedInput.concat(this.numberToBytes2(this.args[0][1]));
33
- // amount
34
- encodedInput = encodedInput.concat(this.numberToBytes32(this.args[0][2]));
35
- // from
36
- encodedInput = encodedInput.concat(this.addressToBytes20(this.args[0][3]));
37
- return encodedInput;
38
- }
39
- }
40
-
41
- module.exports = AaveV3WithdrawAction;
@@ -1,17 +0,0 @@
1
- const AaveV3SupplyAction = require('./AaveV3SupplyAction');
2
- const AaveV3BorrowAction = require('./AaveV3BorrowAction');
3
- const AaveV3PaybackAction = require('./AaveV3PaybackAction');
4
- const AaveV3WithdrawAction = require('./AaveV3WithdrawAction');
5
- const AaveV3SetEModeAction = require('./AaveV3SetEModeAction');
6
- const AaveV3ATokenPaybackAction = require('./AaveV3ATokenPaybackAction');
7
- const AaveV3CollateralSwitchAction = require('./AaveV3CollateralSwitchAction');
8
-
9
- module.exports = {
10
- AaveV3SupplyAction,
11
- AaveV3BorrowAction,
12
- AaveV3PaybackAction,
13
- AaveV3WithdrawAction,
14
- AaveV3SetEModeAction,
15
- AaveV3ATokenPaybackAction,
16
- AaveV3CollateralSwitchAction,
17
- }
package/src/config.js DELETED
@@ -1,74 +0,0 @@
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
- }