@defisaver/sdk 1.0.22 → 1.0.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 (51) hide show
  1. package/esm/src/actions/curveusd/CurveUsdBorrowAction.d.ts +15 -0
  2. package/esm/src/actions/curveusd/CurveUsdBorrowAction.js +22 -0
  3. package/esm/src/actions/curveusd/CurveUsdCreateAction.d.ts +22 -0
  4. package/esm/src/actions/curveusd/CurveUsdCreateAction.js +46 -0
  5. package/esm/src/actions/curveusd/CurveUsdPaybackAction.d.ts +22 -0
  6. package/esm/src/actions/curveusd/CurveUsdPaybackAction.js +43 -0
  7. package/esm/src/actions/curveusd/CurveUsdSupplyAction.d.ts +20 -0
  8. package/esm/src/actions/curveusd/CurveUsdSupplyAction.js +42 -0
  9. package/esm/src/actions/curveusd/CurveUsdWithdrawAction.d.ts +15 -0
  10. package/esm/src/actions/curveusd/CurveUsdWithdrawAction.js +22 -0
  11. package/esm/src/actions/curveusd/index.d.ts +5 -0
  12. package/esm/src/actions/curveusd/index.js +5 -0
  13. package/esm/src/actions/index.d.ts +2 -1
  14. package/esm/src/actions/index.js +2 -1
  15. package/esm/src/actions/morpho/index.d.ts +0 -4
  16. package/esm/src/actions/morpho/index.js +0 -4
  17. package/esm/src/addresses.d.ts +0 -12
  18. package/esm/src/addresses.js +0 -5
  19. package/esm/src/index.d.ts +0 -48
  20. package/esm/src/types.d.ts +2 -1
  21. package/esm/src/utils/curveusd-utils.d.ts +10 -0
  22. package/esm/src/utils/curveusd-utils.js +6 -0
  23. package/esm/src/utils/index.d.ts +2 -1
  24. package/esm/src/utils/index.js +2 -1
  25. package/package.json +1 -1
  26. package/src/actions/curveusd/CurveUsdBorrowAction.ts +34 -0
  27. package/src/actions/curveusd/CurveUsdCreateAction.ts +53 -0
  28. package/src/actions/curveusd/CurveUsdPaybackAction.ts +48 -0
  29. package/src/actions/curveusd/CurveUsdSupplyAction.ts +48 -0
  30. package/src/actions/curveusd/CurveUsdWithdrawAction.ts +34 -0
  31. package/src/actions/curveusd/index.ts +5 -0
  32. package/src/actions/index.ts +2 -0
  33. package/src/actions/morpho/index.ts +0 -4
  34. package/src/addresses.ts +0 -6
  35. package/src/types.ts +2 -1
  36. package/src/utils/curveusd-utils.ts +8 -0
  37. package/src/utils/index.ts +2 -0
  38. package/umd/index.js +311 -189
  39. package/yarn-error.log +3976 -0
  40. package/esm/src/actions/morpho/aaveV3/MorphoAaveV3BorrowAction.d.ts +0 -18
  41. package/esm/src/actions/morpho/aaveV3/MorphoAaveV3BorrowAction.js +0 -27
  42. package/esm/src/actions/morpho/aaveV3/MorphoAaveV3PaybackAction.d.ts +0 -21
  43. package/esm/src/actions/morpho/aaveV3/MorphoAaveV3PaybackAction.js +0 -44
  44. package/esm/src/actions/morpho/aaveV3/MorphoAaveV3SupplyAction.d.ts +0 -23
  45. package/esm/src/actions/morpho/aaveV3/MorphoAaveV3SupplyAction.js +0 -47
  46. package/esm/src/actions/morpho/aaveV3/MorphoAaveV3WithdrawAction.d.ts +0 -19
  47. package/esm/src/actions/morpho/aaveV3/MorphoAaveV3WithdrawAction.js +0 -29
  48. package/src/actions/morpho/aaveV3/MorphoAaveV3BorrowAction.ts +0 -42
  49. package/src/actions/morpho/aaveV3/MorphoAaveV3PaybackAction.ts +0 -47
  50. package/src/actions/morpho/aaveV3/MorphoAaveV3SupplyAction.ts +0 -52
  51. package/src/actions/morpho/aaveV3/MorphoAaveV3WithdrawAction.ts +0 -45
@@ -0,0 +1,48 @@
1
+ import { getAssetInfo } from '@defisaver/tokens';
2
+ import { Action } from '../../Action';
3
+ import { getAddr } from '../../addresses';
4
+ import { EthAddress, uint256, int256 } from '../../types';
5
+
6
+ /**
7
+ * CurveUsdPaybackAction - Action that pays back crvUSD to a curveusd position
8
+ *
9
+ * @category CurveUsd
10
+ */
11
+ export class CurveUsdPaybackAction extends Action {
12
+ /**
13
+ * address controllerAddress - Address of the curveusd market controller
14
+ * address from - Address from which to pull crvUSD, will default to proxy
15
+ * address onBehalfOf - Address for which we are paying back debt, will default to proxy
16
+ * address to - Address that will receive the crvUSD and collateral asset if close, will default to proxy
17
+ * uint256 debtAmount - Amount of crvUSD to payback
18
+ * int256 maxActiveBand - Don't allow active band to be higher than this (to prevent front-running the repay)
19
+ */
20
+ /// @dev debtAmount must be non-zero
21
+ /// @dev if debtAmount >= debt will repay whole debt and close the position, transfering collateral
22
+ constructor(
23
+ controllerAddress: EthAddress,
24
+ from: EthAddress,
25
+ onBehalfOf: EthAddress,
26
+ to: EthAddress,
27
+ debtAmount: uint256,
28
+ maxActiveBand: int256,
29
+ ) {
30
+ super(
31
+ 'CurveUsdBorrow',
32
+ getAddr('CurveUsdBorrow'),
33
+ ['address', 'address', 'address', 'address', 'uint256', 'int256'],
34
+ [controllerAddress, from, onBehalfOf, to, debtAmount, maxActiveBand],
35
+ );
36
+
37
+ this.mappableArgs = [
38
+ ...this.args,
39
+ ];
40
+ }
41
+
42
+ async getAssetsToApprove() {
43
+ return [{
44
+ owner: this.args[1],
45
+ asset: getAssetInfo('crvUSD').address,
46
+ }];
47
+ }
48
+ }
@@ -0,0 +1,48 @@
1
+ import { compare } from '@defisaver/tokens/esm/utils';
2
+ import { getAssetInfo } from '@defisaver/tokens';
3
+ import { Action } from '../../Action';
4
+ import { getAddr } from '../../addresses';
5
+ import { EthAddress, uint256 } from '../../types';
6
+ import { curveusdMarkets } from '../../utils/curveusd-utils';
7
+
8
+
9
+ /**
10
+ * CurveUsdSupplyAction - Action that supplies collateral to a curveusd position
11
+ *
12
+ * @category CurveUsd
13
+ */
14
+ export class CurveUsdSupplyAction extends Action {
15
+ /**
16
+ * address controllerAddress - Address of the curveusd market controller
17
+ * address from - Address from which to pull collateral asset, will default to proxy
18
+ * address onBehalfOf - Address for which we are supplying, will default to proxy
19
+ * uint256 collateralAmount - Amount of collateral asset to supply
20
+ */
21
+ /// @dev collateralAmount must be non-zero, can be maxUint
22
+ constructor(
23
+ controllerAddress: EthAddress,
24
+ from: EthAddress,
25
+ onBehalfOf: EthAddress,
26
+ collateralAmount: uint256,
27
+ ) {
28
+ super(
29
+ 'CurveUsdSupply',
30
+ getAddr('CurveUsdSupply'),
31
+ ['address', 'address', 'address', 'uint256'],
32
+ [controllerAddress, from, onBehalfOf, collateralAmount],
33
+ );
34
+
35
+ this.mappableArgs = [
36
+ ...this.args,
37
+ ];
38
+ }
39
+
40
+ async getAssetsToApprove() {
41
+ return [{
42
+ owner: this.args[1],
43
+ asset: getAssetInfo(
44
+ Object.entries(curveusdMarkets).filter(([, { controllerAddress }]) => compare(controllerAddress, this.args[0]))[0][0],
45
+ ).address,
46
+ }];
47
+ }
48
+ }
@@ -0,0 +1,34 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ import { EthAddress, uint256 } from '../../types';
4
+
5
+ /**
6
+ * CurveUsdWithdrawAction - Action that withdraws collateral from proxy curveusd position
7
+ *
8
+ * @category CurveUsd
9
+ */
10
+ export class CurveUsdWithdrawAction extends Action {
11
+ /**
12
+ * address controllerAddress - Address of the curveusd market controller
13
+ * address to - Address that will receive the withdrawn collateral, will default to proxy
14
+ * uint256 collateralAmount - Amount of collateral to withdraw
15
+ */
16
+ /// @dev collateralAmount must be non-zero
17
+ /// @dev if collateralAmount == uintMax will withdraw as much as the debt will allow
18
+ constructor(
19
+ controllerAddress: EthAddress,
20
+ to: EthAddress,
21
+ collateralAmount: uint256,
22
+ ) {
23
+ super(
24
+ 'CurveUsdSupply',
25
+ getAddr('CurveUsdSupply'),
26
+ ['address', 'address', 'uint256'],
27
+ [controllerAddress, to, collateralAmount],
28
+ );
29
+
30
+ this.mappableArgs = [
31
+ ...this.args,
32
+ ];
33
+ }
34
+ }
@@ -0,0 +1,5 @@
1
+ export * from './CurveUsdCreateAction';
2
+ export * from './CurveUsdSupplyAction';
3
+ export * from './CurveUsdWithdrawAction';
4
+ export * from './CurveUsdBorrowAction';
5
+ export * from './CurveUsdPaybackAction';
@@ -23,6 +23,7 @@ import * as chickenBonds from './chickenBonds';
23
23
  import * as compoundV3 from './compoundV3';
24
24
  import * as morpho from './morpho';
25
25
  import * as bprotocol from './bprotocol';
26
+ import * as curveusd from './curveusd';
26
27
 
27
28
  export {
28
29
  aave,
@@ -50,4 +51,5 @@ export {
50
51
  compoundV3,
51
52
  morpho,
52
53
  bprotocol,
54
+ curveusd,
53
55
  };
@@ -3,7 +3,3 @@ export * from './MorphoAaveV2WithdrawAction';
3
3
  export * from './MorphoAaveV2BorrowAction';
4
4
  export * from './MorphoAaveV2PaybackAction';
5
5
  export * from './MorphoClaimAction';
6
- export * from './aaveV3/MorphoAaveV3SupplyAction';
7
- export * from './aaveV3/MorphoAaveV3WithdrawAction';
8
- export * from './aaveV3/MorphoAaveV3BorrowAction';
9
- export * from './aaveV3/MorphoAaveV3PaybackAction';
package/src/addresses.ts CHANGED
@@ -71,12 +71,6 @@ export const actionAddresses = {
71
71
  MorphoAaveV2Withdraw: '0x29a8b5a8889f465c85b778edccf984e44ad70f12',
72
72
  MorphoClaim: '0xa269C841E26EA8Ee1F0350a2E5905F71446998dC',
73
73
 
74
- // morpho aave v3
75
- MorphoAaveV3Borrow: '0x487719C57b88477F19423aB0652b3E26b96baA7F',
76
- MorphoAaveV3Payback: '0x36b8b968c81D97cBfAa642e206b634A6f378d287',
77
- MorphoAaveV3Supply: '0x51fA8FBc6F0aDEfe2FBA06104FCA39f5beD69291',
78
- MorphoAaveV3Withdraw: '0xdc3e74C4cD577275296ceFE36A3D082223AfF206',
79
-
80
74
  // compound
81
75
  CompBorrow: '0x8495579BF6Ae848f7E59686536F834f1d2CCd79C',
82
76
  CompClaim: '0x81F488cF7A0128A9DB5e7207042cCAB1CB0ac902',
package/src/types.ts CHANGED
@@ -42,8 +42,9 @@ type uint64 = string;
42
42
  type uint24 = string;
43
43
  type uint16 = string;
44
44
  type uint8 = string;
45
+ type int256 = string;
45
46
  type int24 = string;
46
47
 
47
48
  export {
48
- AccessList, AccessListItem, AccessLists, Config, Network, Networks, EthAddress, bytes32, bytes, uint256, uint160, uint128, uint80, uint64, uint24, uint16, uint8, int24,
49
+ AccessList, AccessListItem, AccessLists, Config, Network, Networks, EthAddress, bytes32, bytes, uint256, uint160, uint128, uint80, uint64, uint24, uint16, uint8, int256, int24,
49
50
  };
@@ -0,0 +1,8 @@
1
+ /// @dev debtAvailableBlock is only used in v3-contracts repo
2
+ export const curveusdMarkets = {
3
+ sfrxETH: { controllerAddress: '0x8472a9a7632b173c8cf3a86d3afec50c35548e76', debtAvailableBlock: 17425859 },
4
+ wstETH: { controllerAddress: '0x100dAa78fC509Db39Ef7D04DE0c1ABD299f4C6CE' },
5
+ };
6
+
7
+ export const controllerFactoryAddress = '0xC9332fdCB1C491Dcc683bAe86Fe3cb70360738BC';
8
+
@@ -4,6 +4,7 @@ import * as uniswapV3LP from './uniswapV3LP';
4
4
  import * as convexUtils from './convex-utils';
5
5
  import mstableAssetPairs from './mstableAssetPairs';
6
6
  import * as curveUtils from './curve-utils';
7
+ import * as curveusdUtils from './curveusd-utils';
7
8
 
8
9
  export {
9
10
  zeroExExchange,
@@ -12,4 +13,5 @@ export {
12
13
  mstableAssetPairs,
13
14
  convexUtils,
14
15
  curveUtils,
16
+ curveusdUtils,
15
17
  };