@gearbox-protocol/sdk 0.0.101 → 0.0.104

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 (139) hide show
  1. package/.eslintignore +5 -0
  2. package/.eslintrc.js +52 -0
  3. package/.husky/pre-push +4 -0
  4. package/lib/apy/convexAPY.js +7 -9
  5. package/lib/apy/lidoAPY.js +35 -29
  6. package/lib/contracts/contracts.d.ts +5 -2
  7. package/lib/contracts/contracts.js +19 -18
  8. package/lib/contracts/contractsRegister.js +13 -1
  9. package/lib/core/constants.d.ts +5 -3
  10. package/lib/core/constants.js +8 -6
  11. package/lib/core/creditAccount.d.ts +2 -2
  12. package/lib/core/creditAccount.js +12 -11
  13. package/lib/core/creditManager.d.ts +1 -1
  14. package/lib/core/creditManager.js +4 -10
  15. package/lib/core/creditSession.js +14 -3
  16. package/lib/core/eventOrTx.d.ts +1 -1
  17. package/lib/core/events.d.ts +19 -19
  18. package/lib/core/events.js +23 -21
  19. package/lib/core/pool.d.ts +1 -1
  20. package/lib/core/pool.js +1 -7
  21. package/lib/core/price.d.ts +1 -3
  22. package/lib/core/price.js +9 -7
  23. package/lib/core/strategy.d.ts +8 -6
  24. package/lib/core/strategy.js +25 -25
  25. package/lib/core/tokenDistributor.js +1 -1
  26. package/lib/core/transactions.d.ts +18 -3
  27. package/lib/core/transactions.js +39 -3
  28. package/lib/index.d.ts +8 -2
  29. package/lib/index.js +8 -1
  30. package/lib/oracles/priceFeeds.js +1 -1
  31. package/lib/pathfinder/convexLP.d.ts +1 -1
  32. package/lib/pathfinder/convexLP.js +26 -29
  33. package/lib/pathfinder/curveLP.d.ts +1 -1
  34. package/lib/pathfinder/curveLP.js +5 -7
  35. package/lib/pathfinder/path.d.ts +1 -1
  36. package/lib/pathfinder/path.js +38 -42
  37. package/lib/pathfinder/trade.d.ts +1 -2
  38. package/lib/pathfinder/tradeTypes.d.ts +5 -5
  39. package/lib/pathfinder/yVault.d.ts +2 -2
  40. package/lib/pathfinder/yVault.js +22 -22
  41. package/lib/payload/creditAccount.d.ts +4 -4
  42. package/lib/payload/creditManager.d.ts +3 -13
  43. package/lib/payload/pool.d.ts +2 -2
  44. package/lib/strategies/convex.d.ts +12 -0
  45. package/lib/strategies/convex.js +74 -1
  46. package/lib/strategies/creditFacade.d.ts +1 -0
  47. package/lib/strategies/creditFacade.js +3 -0
  48. package/lib/strategies/curve.d.ts +15 -60
  49. package/lib/strategies/curve.js +74 -1
  50. package/lib/strategies/lido.d.ts +6 -0
  51. package/lib/strategies/lido.js +23 -1
  52. package/lib/strategies/uniswapV2.d.ts +1 -0
  53. package/lib/strategies/uniswapV2.js +6 -19
  54. package/lib/strategies/uniswapV3.d.ts +1 -0
  55. package/lib/strategies/uniswapV3.js +4 -1
  56. package/lib/strategies/yearn.d.ts +8 -0
  57. package/lib/strategies/yearn.js +92 -12
  58. package/lib/tokens/convex.d.ts +3 -3
  59. package/lib/tokens/curveLP.d.ts +7 -2
  60. package/lib/tokens/curveLP.js +8 -1
  61. package/lib/tokens/gear.d.ts +2 -2
  62. package/lib/tokens/gear.js +1 -1
  63. package/lib/tokens/normal.d.ts +1 -1
  64. package/lib/tokens/token.js +8 -8
  65. package/lib/tokens/tokenData.d.ts +3 -1
  66. package/lib/tokens/tokenData.js +10 -8
  67. package/lib/tokens/yearn.d.ts +6 -2
  68. package/lib/tokens/yearn.js +6 -0
  69. package/lib/utils/errors.d.ts +6 -0
  70. package/lib/utils/errors.js +13 -0
  71. package/lib/utils/formatter.d.ts +1 -1
  72. package/lib/utils/formatter.js +17 -14
  73. package/lib/utils/loading.d.ts +2 -1
  74. package/lib/utils/loading.js +9 -13
  75. package/lib/utils/mappers.js +2 -2
  76. package/lib/utils/network.js +2 -2
  77. package/lib/utils/repeater.js +12 -24
  78. package/lib/utils/validate.js +1 -1
  79. package/package.json +24 -7
  80. package/src/apy/convexAPY.ts +13 -12
  81. package/src/apy/lidoAPY.ts +35 -27
  82. package/src/contracts/contracts.ts +27 -17
  83. package/src/contracts/contractsRegister.ts +16 -1
  84. package/src/core/constants.ts +8 -5
  85. package/src/core/creditAccount.ts +42 -16
  86. package/src/core/creditManager.ts +33 -7
  87. package/src/core/creditOperation.ts +7 -7
  88. package/src/core/creditSession.ts +25 -5
  89. package/src/core/errors.ts +1 -0
  90. package/src/core/eventOrTx.ts +8 -5
  91. package/src/core/events.ts +85 -24
  92. package/src/core/history.ts +46 -46
  93. package/src/core/operations.ts +6 -0
  94. package/src/core/pool.ts +16 -4
  95. package/src/core/price.ts +10 -13
  96. package/src/core/strategy.ts +54 -43
  97. package/src/core/tokenDistributor.ts +2 -2
  98. package/src/core/transactions.ts +427 -350
  99. package/src/index.ts +10 -3
  100. package/src/oracles/priceFeeds.ts +523 -523
  101. package/src/pathfinder/contracts.ts +15 -13
  102. package/src/pathfinder/convexLP.ts +29 -25
  103. package/src/pathfinder/curveLP.ts +57 -53
  104. package/src/pathfinder/path.ts +17 -9
  105. package/src/pathfinder/priority.ts +11 -11
  106. package/src/pathfinder/trade.ts +84 -77
  107. package/src/pathfinder/tradeTypes.ts +98 -94
  108. package/src/pathfinder/yVault.ts +32 -17
  109. package/src/payload/creditAccount.ts +4 -4
  110. package/src/payload/creditManager.ts +3 -13
  111. package/src/payload/pool.ts +2 -2
  112. package/src/payload/token.ts +3 -3
  113. package/src/strategies/convex.ts +360 -186
  114. package/src/strategies/creditFacade.ts +74 -53
  115. package/src/strategies/curve.ts +400 -189
  116. package/src/strategies/lido.ts +70 -32
  117. package/src/strategies/uniswapV2.ts +93 -111
  118. package/src/strategies/uniswapV3.ts +118 -91
  119. package/src/strategies/yearn.ts +187 -60
  120. package/src/tokens/connectors.ts +6 -6
  121. package/src/tokens/convex.ts +297 -296
  122. package/src/tokens/curveLP.ts +176 -165
  123. package/src/tokens/gear.ts +47 -45
  124. package/src/tokens/normal.ts +801 -802
  125. package/src/tokens/token.ts +13 -9
  126. package/src/tokens/tokenData.ts +19 -9
  127. package/src/tokens/tokenType.ts +11 -11
  128. package/src/tokens/yearn.ts +130 -124
  129. package/src/utils/errors.ts +11 -0
  130. package/src/utils/formatter.ts +22 -18
  131. package/src/utils/loading.ts +14 -6
  132. package/src/utils/mappers.ts +8 -6
  133. package/src/utils/multicall.ts +2 -0
  134. package/src/utils/network.ts +21 -21
  135. package/src/utils/repeater.ts +2 -2
  136. package/src/utils/validate.ts +1 -1
  137. package/lib/utils/events.d.ts +0 -2
  138. package/lib/utils/events.js +0 -13
  139. package/src/utils/events.ts +0 -10
@@ -1,70 +1,91 @@
1
1
  import { BigNumberish } from "ethers";
2
2
 
3
- import { ICreditFacade__factory, ICreditFacadeBalanceChecker__factory } from "../types";
3
+ import {
4
+ ICreditFacade__factory,
5
+ ICreditFacadeBalanceChecker__factory
6
+ } from "../types";
4
7
  import { MultiCallStruct } from "../types/contracts/interfaces/ICreditFacade.sol/ICreditFacade";
5
8
 
6
9
  export class CreditFacadeCalls {
7
- public static addCollateral(onBehalfOf: string, token: string, amount: BigNumberish) {
8
- return ICreditFacade__factory.createInterface().encodeFunctionData(
9
- "addCollateral",
10
- [onBehalfOf, token, amount]
11
- )
12
- }
10
+ public static addCollateral(
11
+ onBehalfOf: string,
12
+ token: string,
13
+ amount: BigNumberish
14
+ ) {
15
+ return ICreditFacade__factory.createInterface().encodeFunctionData(
16
+ "addCollateral",
17
+ [onBehalfOf, token, amount]
18
+ );
19
+ }
13
20
 
14
- public static increaseDebt(amount: BigNumberish) {
15
- return ICreditFacade__factory.createInterface().encodeFunctionData(
16
- "increaseDebt",
17
- [amount]
18
- )
19
- }
21
+ public static increaseDebt(amount: BigNumberish) {
22
+ return ICreditFacade__factory.createInterface().encodeFunctionData(
23
+ "increaseDebt",
24
+ [amount]
25
+ );
26
+ }
20
27
 
21
- public static decreaseDebt(amount: BigNumberish) {
22
- return ICreditFacade__factory.createInterface().encodeFunctionData(
23
- "decreaseDebt",
24
- [amount]
25
- )
26
- }
28
+ public static decreaseDebt(amount: BigNumberish) {
29
+ return ICreditFacade__factory.createInterface().encodeFunctionData(
30
+ "decreaseDebt",
31
+ [amount]
32
+ );
33
+ }
27
34
 
28
- public static revertIfBalanceLessThan(token: string, minBalance: BigNumberish) {
29
- return ICreditFacadeBalanceChecker__factory.createInterface().encodeFunctionData(
30
- "revertIfBalanceLessThan",
31
- [token, minBalance]
32
- )
33
- }
35
+ public static revertIfBalanceLessThan(
36
+ token: string,
37
+ minBalance: BigNumberish
38
+ ) {
39
+ return ICreditFacadeBalanceChecker__factory.createInterface().encodeFunctionData(
40
+ "revertIfBalanceLessThan",
41
+ [token, minBalance]
42
+ );
43
+ }
34
44
  }
35
45
 
36
46
  export class CreditFacadeMulticaller {
37
- private readonly _address: string;
47
+ private readonly _address: string;
38
48
 
39
- constructor(address: string) {
40
- this._address = address;
41
- }
49
+ constructor(address: string) {
50
+ this._address = address;
51
+ }
42
52
 
43
- addCollateral(onBehalfOf: string, token: string, amount: BigNumberish): MultiCallStruct {
44
- return {
45
- target: this._address,
46
- callData: CreditFacadeCalls.addCollateral(onBehalfOf, token, amount)
47
- }
48
- }
53
+ static connect(address: string) {
54
+ return new CreditFacadeMulticaller(address);
55
+ }
49
56
 
50
- increaseDebt(amount: BigNumberish): MultiCallStruct {
51
- return {
52
- target: this._address,
53
- callData: CreditFacadeCalls.increaseDebt(amount)
54
- }
55
- }
57
+ addCollateral(
58
+ onBehalfOf: string,
59
+ token: string,
60
+ amount: BigNumberish
61
+ ): MultiCallStruct {
62
+ return {
63
+ target: this._address,
64
+ callData: CreditFacadeCalls.addCollateral(onBehalfOf, token, amount)
65
+ };
66
+ }
56
67
 
57
- decreaseDebt(amount: BigNumberish): MultiCallStruct {
58
- return {
59
- target: this._address,
60
- callData: CreditFacadeCalls.decreaseDebt(amount)
61
- }
62
- }
68
+ increaseDebt(amount: BigNumberish): MultiCallStruct {
69
+ return {
70
+ target: this._address,
71
+ callData: CreditFacadeCalls.increaseDebt(amount)
72
+ };
73
+ }
63
74
 
64
- revertIfBalanceLessThan(token: string, minBalance: BigNumberish): MultiCallStruct {
65
- return {
66
- target: this._address,
67
- callData: CreditFacadeCalls.revertIfBalanceLessThan(token, minBalance)
68
- }
69
- }
75
+ decreaseDebt(amount: BigNumberish): MultiCallStruct {
76
+ return {
77
+ target: this._address,
78
+ callData: CreditFacadeCalls.decreaseDebt(amount)
79
+ };
80
+ }
81
+
82
+ revertIfBalanceLessThan(
83
+ token: string,
84
+ minBalance: BigNumberish
85
+ ): MultiCallStruct {
86
+ return {
87
+ target: this._address,
88
+ callData: CreditFacadeCalls.revertIfBalanceLessThan(token, minBalance)
89
+ };
90
+ }
70
91
  }