@defisaver/sdk 0.1.8 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/sdk",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,43 @@
1
+ const Action = require("../../Action");
2
+ const { getAssetInfo } = require("@defisaver/tokens");
3
+ const { getAddr } = require('../../addresses.js');
4
+
5
+ /**
6
+ * Action that adds liquidity to G-UNI pool of interest (mints G-UNI LP tokens)
7
+ */
8
+ class GUniDeposit extends Action {
9
+ /// @param pool address of G-UNI pool to add liquidity to
10
+ /// @param token0 address of token0
11
+ /// @param token1 address of token1
12
+ /// @param amount0Max the maximum amount of token0 msg.sender willing to input
13
+ /// @param amount1Max the maximum amount of token1 msg.sender willing to input
14
+ /// @param amount0Min the minimum amount of token0 actually input (slippage protection)
15
+ /// @param amount1Min the minimum amount of token1 actually input (slippage protection)
16
+ /// @param to account to receive minted G-UNI tokens
17
+ /// @param from account from which to pull underlying tokens from
18
+ constructor(pool, token0, token1, amount0Max, amount1max, amount0Min, amount1Min, to, from) {
19
+ super(
20
+ 'GUniDeposit',
21
+ getAddr('GUniDeposit'),
22
+ [['address', 'address', 'address', 'uint256', 'uint256', 'uint256', 'uint256', 'address', 'address']],
23
+ [[pool, token0, token1, amount0Max, amount1max, amount0Min, amount1Min, to, from]]
24
+ );
25
+ this.mappableArgs = [
26
+ this.args[0][3],
27
+ this.args[0][4],
28
+ this.args[0][5],
29
+ this.args[0][6],
30
+ ];
31
+ }
32
+
33
+ async getAssetsToApprove() {
34
+ const approveArr = [];
35
+
36
+ approveArr.push({asset: this.args[0][1], owner: this.args[0][8]});
37
+ approveArr.push({asset: this.args[0][2], owner: this.args[0][8]});
38
+
39
+ return approveArr;
40
+ }
41
+ }
42
+
43
+ module.exports = GUniDeposit;
@@ -0,0 +1,32 @@
1
+ const Action = require("../../Action");
2
+ const { getAssetInfo } = require("@defisaver/tokens");
3
+ const { getAddr } = require('../../addresses.js');
4
+
5
+ /**
6
+ * Action that removes liquidity from a G-UNI pool and burns G-UNI LP tokens
7
+ */
8
+ class GUniWithdraw extends Action {
9
+ /// @param pool address of G-UNI pool to remove liquidity from
10
+ /// @param burnAmount The number of G-UNI tokens to burn
11
+ /// @param amount0Min Minimum amount of token0 received after burn (slippage protection)
12
+ /// @param amount1Min Minimum amount of token1 received after burn (slippage protection)
13
+ /// @param to The account to receive the underlying amounts of token0 and token1
14
+ /// @param from Account from which to pull G-Uni LP tokens
15
+ constructor(pool, burnAmount, amount0Min, amount1Min, to, from) {
16
+ super(
17
+ 'GUniWithdraw',
18
+ getAddr('GUniWithdraw'),
19
+ [['address', 'uint256', 'uint256', 'uint256', 'address', 'address']],
20
+ [[pool, burnAmount, amount0Min, amount1Min, to, from]]
21
+ );
22
+ this.mappableArgs = [
23
+ this.args[0][1],
24
+ ];
25
+ }
26
+
27
+ async getAssetsToApprove() {
28
+ return [{asset: this.args[0][0], owner: this.args[0][5]}];
29
+ }
30
+ }
31
+
32
+ module.exports = GUniWithdraw;
@@ -0,0 +1,6 @@
1
+ const GUniDeposit = require('./GUniDeposit');
2
+ const GUniWithdraw = require('./GUniWithdraw.js');
3
+ module.exports = {
4
+ GUniDeposit,
5
+ GUniWithdraw,
6
+ }
@@ -12,6 +12,9 @@ const yearn = require('./yearn');
12
12
  const lido = require('./lido');
13
13
  const insta = require('./insta');
14
14
  const balancer = require('./balancer');
15
+ const guni = require('./guni');
16
+ const mstable = require('./mstable');
17
+ const rari = require('./rari');
15
18
 
16
19
  module.exports = {
17
20
  maker,
@@ -28,4 +31,7 @@ module.exports = {
28
31
  lido,
29
32
  insta,
30
33
  balancer,
34
+ guni,
35
+ mstable,
36
+ rari,
31
37
  };
@@ -0,0 +1,38 @@
1
+ const Action = require("@defisaver/sdk/src/Action");
2
+ const {requireAddress} = require("@defisaver/sdk/src/utils/general");
3
+ const { getAddr } = require('@defisaver/sdk/src/addresses');
4
+
5
+ /**
6
+ * MStableClaimAction
7
+ */
8
+ class MStableClaimAction extends Action {
9
+ /**
10
+ * @param vaultAddress
11
+ * @param to
12
+ * @param first
13
+ * @param last
14
+ */
15
+ constructor(
16
+ vaultAddress,
17
+ to,
18
+ first,
19
+ last,
20
+ ) {
21
+ requireAddress(vaultAddress);
22
+ requireAddress(to);
23
+
24
+ super(
25
+ 'MStableClaim',
26
+ getAddr('MStableClaim'),
27
+ [['address', 'address', 'uint256', 'uint256']],
28
+ [[...arguments]],
29
+ );
30
+
31
+ this.mappableArgs = [
32
+ this.args[0][0],
33
+ this.args[0][1],
34
+ ];
35
+ }
36
+ }
37
+
38
+ module.exports = MStableClaimAction;
@@ -0,0 +1,63 @@
1
+ const Action = require("@defisaver/sdk/src/Action");
2
+ const {requireAddress} = require("@defisaver/sdk/src/utils/general");
3
+ const { getAddr } = require('@defisaver/sdk/src/addresses');
4
+
5
+ /**
6
+ * MStableDepositAction
7
+ */
8
+ class MStableDepositAction extends Action {
9
+ /**
10
+ * @param bAsset
11
+ * @param mAsset
12
+ * @param saveAddress
13
+ * @param vaultAddress
14
+ * @param from
15
+ * @param to
16
+ * @param amount
17
+ * @param minOut
18
+ * @param stake
19
+ */
20
+ constructor(
21
+ bAsset,
22
+ mAsset,
23
+ saveAddress,
24
+ vaultAddress,
25
+ from,
26
+ to,
27
+ amount,
28
+ minOut,
29
+ stake,
30
+ ) {
31
+ requireAddress(bAsset);
32
+ requireAddress(mAsset);
33
+ requireAddress(saveAddress);
34
+ requireAddress(vaultAddress);
35
+ requireAddress(from);
36
+ requireAddress(to);
37
+
38
+ super(
39
+ 'MStableDeposit',
40
+ getAddr('MStableDeposit'),
41
+ [['address', 'address', 'address', 'address', 'address', 'address', 'uint256', 'uint256', 'bool']],
42
+ [[...arguments]],
43
+ );
44
+
45
+ this.mappableArgs = [
46
+ this.args[0][0],
47
+ this.args[0][1],
48
+ this.args[0][2],
49
+ this.args[0][3],
50
+ this.args[0][4],
51
+ this.args[0][5],
52
+ this.args[0][6],
53
+ this.args[0][7],
54
+ this.args[0][8],
55
+ ];
56
+ }
57
+
58
+ async getAssetsToApprove() {
59
+ return [{ asset: this.args[0][0], owner: this.args[0][4]}];
60
+ }
61
+ }
62
+
63
+ module.exports = MStableDepositAction;
@@ -0,0 +1,66 @@
1
+ const Action = require("@defisaver/sdk/src/Action");
2
+ const {requireAddress} = require("@defisaver/sdk/src/utils/general");
3
+ const { getAddr } = require('@defisaver/sdk/src/addresses');
4
+
5
+ /**
6
+ * MStableWithdrawAction
7
+ */
8
+ class MStableWithdrawAction extends Action {
9
+ /**
10
+ * @param bAsset
11
+ * @param mAsset
12
+ * @param saveAddress
13
+ * @param vaultAddress
14
+ * @param from
15
+ * @param to
16
+ * @param amount
17
+ * @param minOut
18
+ * @param stake
19
+ */
20
+ constructor(
21
+ bAsset,
22
+ mAsset,
23
+ saveAddress,
24
+ vaultAddress,
25
+ from,
26
+ to,
27
+ amount,
28
+ minOut,
29
+ unstake,
30
+ ) {
31
+ requireAddress(bAsset);
32
+ requireAddress(mAsset);
33
+ requireAddress(saveAddress);
34
+ requireAddress(vaultAddress);
35
+ requireAddress(from);
36
+ requireAddress(to);
37
+
38
+ super(
39
+ 'MStableWithdraw',
40
+ getAddr('MStableWithdraw'),
41
+ [['address', 'address', 'address', 'address', 'address', 'address', 'uint256', 'uint256', 'bool']],
42
+ [[...arguments]],
43
+ );
44
+
45
+ this.mappableArgs = [
46
+ this.args[0][0],
47
+ this.args[0][1],
48
+ this.args[0][2],
49
+ this.args[0][3],
50
+ this.args[0][4],
51
+ this.args[0][5],
52
+ this.args[0][6],
53
+ this.args[0][7],
54
+ this.args[0][8],
55
+ ];
56
+ }
57
+
58
+ async getAssetsToApprove() {
59
+ const asset = this.args[2];
60
+ const from = this.args[4];
61
+ const unstake = this.args[8];
62
+ return unstake ? [] : [{asset: getAssetInfo(asset).address, owner: from}]
63
+ }
64
+ }
65
+
66
+ module.exports = MStableWithdrawAction;
@@ -0,0 +1,9 @@
1
+ const MStableDepositAction = require('./MStableDepositAction');
2
+ const MStableWithdrawAction = require('./MStableWithdrawAction');
3
+ const MStableClaimAction = require('./MStableClaimAction');
4
+
5
+ module.exports = {
6
+ MStableDepositAction,
7
+ MStableWithdrawAction,
8
+ MStableClaimAction,
9
+ }
@@ -0,0 +1,31 @@
1
+ const Action = require("../../Action");
2
+ const { getAssetInfo } = require("@defisaver/tokens");
3
+ const { getAddr } = require('../../addresses.js');
4
+
5
+ /**
6
+ * RariDepositAction - action that deposits one stablecoin (DAI, USDC, USDT, TUSD, BUSD, and sUSD) and receives RSPT back
7
+ */
8
+ class RariDepositAction extends Action {
9
+ /**
10
+ * @param fundManager {EthAddress} fundManager for the pool which we want to deposit into
11
+ * @param stablecoinAddress {EthAddress} stablecoin token address
12
+ * @param poolTokenAddress {EthAddress} poolTokenAddress
13
+ * @param amount {string} amount of stablecoin to pull and deposit
14
+ * @param from {EthAddress} stablecoins will be taken from this address
15
+ * @param to {EthAddress} RSPT will be sent to this address
16
+ */
17
+ constructor(fundManager, stablecoinAddress, poolTokenAddress, amount, from, to) {
18
+ super('RariDeposit', getAddr('RariDeposit'), [['address', 'address', 'address', 'uint256', 'address', 'address']], [[fundManager, stablecoinAddress, poolTokenAddress, amount, from, to]]);
19
+ this.mappableArgs = [
20
+ this.args[0][3],
21
+ this.args[0][4],
22
+ this.args[0][5],
23
+ ];
24
+ }
25
+
26
+ async getAssetsToApprove() {
27
+ return [{asset: this.args[0][1], owner: this.args[0][4]}];
28
+ }
29
+ }
30
+
31
+ module.exports = RariDepositAction;
@@ -0,0 +1,33 @@
1
+ const Action = require("../../Action");
2
+ const { getAssetInfo } = require("@defisaver/tokens");
3
+ const { getAddr } = require('../../addresses.js');
4
+
5
+ /**
6
+ * RariWithdrawAction - Send pool tokens to fund manager which burns them, receive underlying stablecoin back
7
+ */
8
+ class RariWithdrawAction extends Action {
9
+ /**
10
+ * @param fundManager {EthAddress} fundManager for the pool which we want to withdraw from
11
+ * @param poolTokenAddress {EthAddress} poolToken address
12
+ * @param poolTokensAmountToPull {string} amount of tokens to pull to proxy
13
+ * @param from {EthAddress} poolTokens will be taken from this address
14
+ * @param stablecoinAddress {EthAddress} stablecoin token address
15
+ * @param stablecoinAmountToWithdraw {string} amount of stablecoin to withdraw from Rari
16
+ * @param to {EthAddress} stablecoins withdrawn will be sent to this address
17
+ */
18
+ constructor(fundManager, poolTokenAddress, poolTokensAmountToPull, from, stablecoinAddress, stablecoinAmountToWithdraw, to) {
19
+ super('RariWithdraw', getAddr('RariWithdraw'), [['address', 'address', 'uint256', 'address', 'address', 'uint256', 'address']], [[fundManager, poolTokenAddress, poolTokensAmountToPull, from, stablecoinAddress, stablecoinAmountToWithdraw, to]]);
20
+ this.mappableArgs = [
21
+ this.args[0][2],
22
+ this.args[0][3],
23
+ this.args[0][5],
24
+ this.args[0][6],
25
+ ];
26
+ }
27
+
28
+ async getAssetsToApprove() {
29
+ return [{asset: this.args[0][1], owner: this.args[0][3]}];
30
+ }
31
+ }
32
+
33
+ module.exports = RariWithdrawAction;
@@ -0,0 +1,6 @@
1
+ const RariDepositAction = require('./RariDepositAction');
2
+ const RariWithdrawAction = require('./RariWithdrawAction');
3
+ module.exports = {
4
+ RariDepositAction,
5
+ RariWithdrawAction,
6
+ }
package/src/addresses.js CHANGED
@@ -106,6 +106,19 @@ const actionAddresses = {
106
106
  'BalancerV2Supply': '0xD78E5D95A28a67F7851b0a94505790813A92E405',
107
107
  'BalancerV2Withdraw': '0xCcf4b96407BEF25D7df1c95045CCF64950e73E97',
108
108
  'BalancerV2Claim': '0x259Ae83567858B7960d2De0D00F3717a764aD73B',
109
+
110
+ // GUni
111
+ 'GUniWithdraw': '0xa329263fFac25F86E03481Ec39307bbf5DbeDD83',
112
+ 'GUniDeposit': '0xe943958f01630038c23f8471a2d0ea4378e58b0d',
113
+
114
+ // Rari
115
+ 'RariDeposit': '0xC627A3F12c4f7236218a511DC10e3f5ead1a1D7c',
116
+ 'RariWithdraw': '0x8408EeCcC2c2FC25F2cF720398DAAD0A05EfE487',
117
+
118
+ // mStable
119
+ 'MStableDeposit': '0x1887235CFE1927782a3e7eD15fb073586c949858',
120
+ 'MStableWithdraw': '0xb164456190577fbBe8FB8bF5Fa48a106b328A579',
121
+ 'MStableClaim': '0x28279A806aDeDedFD33e39C7375dc0c0ee943847',
109
122
  };
110
123
 
111
124
  const otherAddresses = {