@defisaver/sdk 0.3.27 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/sdk",
3
- "version": "0.3.27",
3
+ "version": "0.4.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,20 @@
1
+ const Action = require("../../Action");
2
+ const { getAddr } = require('../../addresses.js');
3
+
4
+ class TransferNFTAction extends Action {
5
+ constructor(nftAddr, from, to, nftId) {
6
+ super(
7
+ 'TransferNFT',
8
+ getAddr('TransferNFT'),
9
+ [
10
+ "address",
11
+ "address",
12
+ "address",
13
+ "uint256"
14
+ ],
15
+ [...arguments]
16
+ );
17
+ }
18
+ }
19
+
20
+ module.exports = TransferNFTAction;
@@ -13,6 +13,7 @@ const GasFeeAction = require('./GasFeeAction');
13
13
  const UpdateSubAction = require('./UpdateSubAction');
14
14
  const ToggleSubAction = require('./ToggleSubAction');
15
15
  const GasFeeActionL2 = require('./GasFeeActionL2');
16
+ const TransferNFTAction = require('./TransferNFTAction');
16
17
 
17
18
  module.exports = {
18
19
  SellAction,
@@ -30,4 +31,5 @@ module.exports = {
30
31
  SendTokenAndUnwrapAction,
31
32
  ToggleSubAction,
32
33
  GasFeeActionL2,
34
+ TransferNFTAction,
33
35
  };
@@ -0,0 +1,27 @@
1
+ const Action = require("../../Action");
2
+ const {getAddr} = require("../../addresses.js");
3
+
4
+ /**
5
+ * CompoundV3RatioCheckAction - Checks comp V3 ratio for user position and reverts if faulty
6
+ */
7
+ class CompoundV3RatioCheckAction extends Action {
8
+ /**
9
+ * @param ratioState {uint8} If it should lower/higher
10
+ * @param targetRatio {string} The ratio user want to be at
11
+ * @param market {address} Address of compV3 market
12
+ * @param user {address} Address of the user we are checking the ratio for (default to proxy)
13
+ */
14
+ constructor(ratioState, targetRatio, market, user) {
15
+ super("CompV3RatioCheck", getAddr("CompV3RatioCheck"), ["uint8","uint256","address","address"], [ratioState, targetRatio, market, user]);
16
+
17
+ this.mappableArgs = [
18
+ this.args[0],
19
+ this.args[1],
20
+ this.args[2],
21
+ this.args[3]
22
+ ];
23
+ }
24
+
25
+ }
26
+
27
+ module.exports = CompoundV3RatioCheckAction;
@@ -1,7 +1,9 @@
1
1
  const MakerRatioCheckAction = require('./MakerRatioCheckAction');
2
2
  const AaveV3RatioCheckAction = require('./AaveV3RatioCheckAction');
3
+ const CompoundV3RatioCheckAction = require('./CompoundV3RatioCheckAction');
3
4
 
4
5
  module.exports = {
5
6
  MakerRatioCheckAction,
6
7
  AaveV3RatioCheckAction,
8
+ CompoundV3RatioCheckAction,
7
9
  };
@@ -0,0 +1,19 @@
1
+ const Action = require("../../Action");
2
+ const { requireAddress } = require("../../utils/general");
3
+ const { getAddr } = require('../../addresses.js');
4
+
5
+ /**
6
+ * CBCreateAction - Chickens in the pending bond
7
+ */
8
+ class CBChickenInAction extends Action {
9
+ /**
10
+ * @param bondID {string} Nft id of the bond
11
+ * @param to {EthAddress}
12
+ */
13
+ constructor(bondId, to) {
14
+ requireAddress(to);
15
+ super('CBChickenIn', getAddr('CBChickenIn'), ['uint256','address'], [...arguments]);
16
+ }
17
+ }
18
+
19
+ module.exports = CBChickenInAction;
@@ -0,0 +1,20 @@
1
+ const Action = require("../../Action");
2
+ const { requireAddress } = require("../../utils/general");
3
+ const { getAddr } = require('../../addresses.js');
4
+
5
+ /**
6
+ * CBChickenOutAction - Chickens out the pending bond
7
+ */
8
+ class CBChickenOutAction extends Action {
9
+ /**
10
+ * @param bondID {string} Nft id of the bond
11
+ * @param minLUSD {string} Min amount of lusd to receive
12
+ * @param to {EthAddress}
13
+ */
14
+ constructor(bondId, minLUSD, to) {
15
+ requireAddress(to);
16
+ super('CBChickenOut', getAddr('CBChickenOut'), ['uint256','uint256','address'], [...arguments]);
17
+ }
18
+ }
19
+
20
+ module.exports = CBChickenOutAction;
@@ -0,0 +1,23 @@
1
+ const Action = require("../../Action");
2
+ const { requireAddress } = require("../../utils/general");
3
+ const { getAddr } = require('../../addresses.js');
4
+
5
+ /**
6
+ * CBCreateAction - Create a chicken bond nft
7
+ */
8
+ class CBCreateAction extends Action {
9
+ /**
10
+ * @param amount {string} Wei amount in LUSD
11
+ * @param from {EthAddress}
12
+ */
13
+ constructor(amount, from) {
14
+ requireAddress(from);
15
+ super('CBCreate', getAddr('CBCreate'), ['uint256','address'], [...arguments]);
16
+ }
17
+
18
+ async getAssetsToApprove() {
19
+ return [{asset: getAddr('LUSD'), owner: this.args[1]}]
20
+ }
21
+ }
22
+
23
+ module.exports = CBCreateAction;
@@ -0,0 +1,27 @@
1
+ const Action = require("../../Action");
2
+ const { requireAddress } = require("../../utils/general");
3
+ const { getAddr } = require('../../addresses.js');
4
+
5
+ /**
6
+ * CBRedeemAction - Redeems bLUSD for Lusd (might also get yTokens)
7
+ */
8
+ class CBRedeemAction extends Action {
9
+ /**
10
+ * @param bLUSDAmount {string} Amount of bLUSD
11
+ * @param minLUSDFromSP {string} Min amount of lusd to receive
12
+ * @param from {EthAddress}
13
+ * @param to {EthAddress}
14
+ */
15
+ constructor(bLUSDAmount, minLUSDFromSP, from, to) {
16
+ requireAddress(from);
17
+ requireAddress(to);
18
+ super('CBRedeem', getAddr('CBRedeem'), ['uint256','uint256','address','address'], [...arguments]);
19
+ }
20
+
21
+ async getAssetsToApprove() {
22
+ return [{asset: getAddr('BLUSD'), owner: this.args[2]}]
23
+ }
24
+
25
+ }
26
+
27
+ module.exports = CBRedeemAction;
@@ -0,0 +1,11 @@
1
+ const CBCreateAction = require('./CBCreateAction');
2
+ const CBChickenInAction = require('./CBChickenInAction');
3
+ const CBChickenOutAction = require('./CBChickenOutAction');
4
+ const CBRedeemAction = require('./CBRedeemAction');
5
+
6
+ module.exports = {
7
+ CBCreateAction,
8
+ CBChickenInAction,
9
+ CBChickenOutAction,
10
+ CBRedeemAction,
11
+ };
@@ -8,17 +8,19 @@ const { getAddr } = require('../../addresses.js');
8
8
  class CompoundV3BorrowAction extends Action {
9
9
  /**
10
10
  * @param market {EthAddress} Comet proxy address of the market
11
- * @param amount {string} Wei amount in underlying asset decimals (not cAsset) - ie. 18 dec for cETH, not 8
12
- * @param to {EthAddress}
11
+ * @param amount {string} Wei amount in underlying asset decimals
12
+ * @param to {EthAddress} Address where we send the borrowed tokens
13
+ * @param onBehalf {EthAddress} Address from which we are borrowing the tokens
13
14
  */
14
- constructor(market, amount, to) {
15
+ constructor(market, amount, to, onBehalf) {
15
16
  requireAddress(to);
16
- super('CompV3Borrow', getAddr('CompV3Borrow'), ['address','uint256','address'], [...arguments]);
17
+ super('CompV3Borrow', getAddr('CompV3Borrow'), ['address','uint256','address','address'], [...arguments]);
17
18
 
18
19
  this.mappableArgs = [
19
20
  this.args[0],
20
21
  this.args[1],
21
22
  this.args[2],
23
+ this.args[3],
22
24
  ];
23
25
  }
24
26
  }
@@ -11,16 +11,18 @@ const {getAssetInfoByAddress} = require("@defisaver/tokens");
11
11
  * @param market {EthAddress} Comet proxy address of the market
12
12
  * @param tokenAddr {EthAddress}
13
13
  * @param amount {uint256} wei amount of asset to supply
14
- * @param from {EthAddress}
14
+ * @param from {EthAddress} Address from where we're pulling the tokens
15
+ * @param onBehalf {EthAddress} Address of the account we are supplying the tokens
15
16
  */
16
- constructor(market, tokenAddr, amount, from,) {
17
- super('CompV3Supply', getAddr('CompV3Supply'), ['address','address','uint256','address'], [market, tokenAddr, amount, from]);
17
+ constructor(market, tokenAddr, amount, from, onBehalf) {
18
+ super('CompV3Supply', getAddr('CompV3Supply'), ['address','address','uint256','address', 'address'], [market, tokenAddr, amount, from, onBehalf]);
18
19
 
19
20
  this.mappableArgs = [
20
21
  this.args[0],
21
22
  this.args[1],
22
23
  this.args[2],
23
- this.args[3]
24
+ this.args[3],
25
+ this.args[4]
24
26
  ];
25
27
  this.tokenForApproval = tokenAddr;
26
28
  }
@@ -8,17 +8,18 @@ const { getAddr } = require("../../addresses.js");
8
8
  class CompoundV3WithdrawAction extends Action {
9
9
  /**
10
10
  * @param market {EthAddress} Comet proxy address of the market
11
- * @param to {EthAddress} Address of the recipient
11
+ * @param to {EthAddress} Address where we are sending the tokens
12
12
  * @param asset {EthAddress} Address of asset to withdraw
13
13
  * @param amount {string} Wei amount in specified asset
14
+ * @param onBehalf {EthAddress} Address from where we are withdrawing the tokens
14
15
  */
15
- constructor(market, to, asset, amount) {
16
+ constructor(market, to, asset, amount, onBehalf) {
16
17
  requireAddress(to);
17
18
  requireAddress(asset);
18
19
  super(
19
20
  "CompV3Withdraw",
20
21
  getAddr("CompV3Withdraw"),
21
- ["address","address", "address", "uint256"],
22
+ ["address","address", "address","uint256","address"],
22
23
  [...arguments]
23
24
  );
24
25
 
@@ -27,6 +28,7 @@ class CompoundV3WithdrawAction extends Action {
27
28
  this.args[1],
28
29
  this.args[2],
29
30
  this.args[3],
31
+ this.args[4],
30
32
  ];
31
33
  }
32
34
  }
@@ -19,6 +19,7 @@ const mstable = require('./mstable');
19
19
  const rari = require('./rari');
20
20
  const aaveV3 = require('./aaveV3');
21
21
  const convex = require('./convex');
22
+ const chickenBonds = require('./chickenBonds');
22
23
  const compoundV3 = require('./compoundV3');
23
24
 
24
25
  module.exports = {
@@ -43,5 +44,6 @@ module.exports = {
43
44
  rari,
44
45
  aaveV3,
45
46
  convex,
47
+ chickenBonds,
46
48
  compoundV3,
47
49
  };
package/src/addresses.js CHANGED
@@ -15,6 +15,7 @@ const actionAddresses = {
15
15
  SendTokenAndUnwrap: '0xeecd376026335261c89faD40D89625391b1eFF6a',
16
16
  ToggleSub: '0x9A78E9d6538cfDbA0242Ca5eC46771E6132E8085',
17
17
  UpdateSub: '0x94D707f411B852082a5ce49C3f47c49c7757761f',
18
+ TransferNFT: '0x861e893E1796F81248e75F06C0b09Abdc8fe2f6F',
18
19
 
19
20
  // exchange
20
21
  DFSSell: '0xB744474Bdd7226736ACa4Ba87593e32d8315e5c9',
@@ -142,14 +143,19 @@ const actionAddresses = {
142
143
  ConvexWithdraw: '0x2B2c235F9e27A121947c34A39d447bD4C585aA15',
143
144
  ConvexClaim: '0xA012afAA97B48894b8FCB2ECC007045Be7a8E8B6',
144
145
 
146
+ // Chicken Bonds
147
+ CBCreate: '0xAB38eCb27aBc1d75cb83725a4c408C22F426A1c1',
148
+ CBRedeem: '0xdD06754cA5367B03af7014AB359332eD82D988d1',
149
+ CBChickenIn: '0x1E990AF6dCf9E9f8a0b2fc76f3BC032A34fFfD14',
150
+ CBChickenOut: '0x3d2f2d88749BB387abD07A2408b68D2Bf2D4be3f',
145
151
  // CompV3
146
152
  CompV3Allow: '0xC4a80f22bf56E0dFa2CB378561B934F41E14bc9f',
147
- CompV3Borrow: '0xAb01C815063178C3021a516ecaf56915fD0E6534',
153
+ CompV3Borrow: '0x11e7b984299a771C92CD42A87358a32791A75CEA',
148
154
  CompV3Claim: '0x4CEa369B63daAc0dA3423c5038a57483c5150986',
149
155
  CompV3Payback: '0x6d14b9d69aADcb0d31a3e5d89fba75AB053fc9f0',
150
- CompV3Supply: '0xAB53342d922Cc52b33486B92dC5dc361b7E4B436',
156
+ CompV3Supply: '0xaF36Eca43bb26468078B8163fe5Bc1fCFc292095',
151
157
  CompV3Transfer: '0xeD7450e9C17146476137b77198DFfB17857906c4',
152
- CompV3Withdraw: '0x59fED9975cd3bb07bB75490e86751D6025ce0bC2',
158
+ CompV3Withdraw: '0x0b0F21EDE32DE4243D9145a899E97FC2366Aec46',
153
159
  },
154
160
  [NETWORKS.optimism.chainId]: {
155
161
  DFSSell: '0xBA0f6039b95CC0A02B5fc983eCf0FC4437BaacC7',
@@ -244,6 +250,8 @@ const otherAddresses = {
244
250
  CrvToken: '0xD533a949740bb3306d119CC777fa900bA034cd52',
245
251
  CvxToken: '0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B',
246
252
  DAI: '0x6b175474e89094c44da98b954eedeac495271d0f',
253
+ LUSD: '0x5f98805A4E8be255a32880FDeC7F6728C6568bA0',
254
+ BLUSD: '0x76F7774139bf0097d2882C41AF5A37717e3641A7',
247
255
  Empty: '0x0000000000000000000000000000000000000000',
248
256
  },
249
257
  [NETWORKS.optimism.chainId]: {
@@ -0,0 +1,11 @@
1
+ const Action = require("../Action");
2
+ const { getAddr } = require("../addresses.js");
3
+
4
+ class CompV3RatioTrigger extends Action {
5
+
6
+ constructor(user, market, ratio, state) {
7
+ super("CompV3RatioTrigger", getAddr("CompV3RatioTrigger"), [["address", "address", "uint256", "uint8"]], [[...arguments]]);
8
+ }
9
+ }
10
+
11
+ module.exports = CompV3RatioTrigger;
@@ -0,0 +1,11 @@
1
+ const Action = require("../Action");
2
+ const { getAddr } = require("../addresses.js");
3
+
4
+ class CompV3RatioTrigger extends Action {
5
+
6
+ constructor(user, market, ratio, state) {
7
+ super("CompV3RatioTrigger", getAddr("CompV3RatioTrigger"), [["address", "address", "uint256", "uint8"]], [[...arguments]]);
8
+ }
9
+ }
10
+
11
+ module.exports = CompV3RatioTrigger;
@@ -7,8 +7,10 @@ const CompoundRatioTrigger = require('./CompoundRatioTrigger');
7
7
  const ReflexerRatioTrigger = require('./ReflexerRatioTrigger');
8
8
  const LiquityRatioTrigger = require('./LiquityRatioTrigger');
9
9
  const AaveV3RatioTrigger = require('./AaveV3RatioTrigger');
10
+ const CompV3RatioTrigger = require('./CompV3RatioTrigger');
10
11
  const TrailingStopTrigger = require('./TrailingStopTrigger');
11
12
 
13
+
12
14
  module.exports = {
13
15
  MakerRatioTrigger,
14
16
  ChainLinkPriceTrigger,
@@ -19,5 +21,6 @@ module.exports = {
19
21
  ReflexerRatioTrigger,
20
22
  LiquityRatioTrigger,
21
23
  AaveV3RatioTrigger,
24
+ CompV3RatioTrigger,
22
25
  TrailingStopTrigger,
23
26
  }