@ichidao/ichi-vaults-sdk 0.1.43 → 2.0.1

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 (210) hide show
  1. package/README.md +62 -208
  2. package/dist/abis/types/AlgebraIntegralPool.d.ts +702 -793
  3. package/dist/abis/types/AlgebraPool.d.ts +693 -730
  4. package/dist/abis/types/ClPool.d.ts +789 -871
  5. package/dist/abis/types/DepositGuard.d.ts +193 -178
  6. package/dist/abis/types/DepositGuardWithHtsWrapping.d.ts +300 -297
  7. package/dist/abis/types/ERC20.d.ts +120 -147
  8. package/dist/abis/types/ERC20Wrapper.d.ts +147 -155
  9. package/dist/abis/types/IchiVault.d.ts +598 -728
  10. package/dist/abis/types/MultiFeeDistributer.d.ts +314 -423
  11. package/dist/abis/types/Multicall.d.ts +58 -73
  12. package/dist/abis/types/UniswapV3Pool.d.ts +654 -693
  13. package/dist/abis/types/common.d.ts +40 -12
  14. package/dist/abis/types/factories/AlgebraIntegralPool__factory.d.ts +2 -3
  15. package/dist/abis/types/factories/AlgebraIntegralPool__factory.js +10 -13
  16. package/dist/abis/types/factories/AlgebraIntegralPool__factory.js.map +1 -1
  17. package/dist/abis/types/factories/AlgebraPool__factory.d.ts +2 -3
  18. package/dist/abis/types/factories/AlgebraPool__factory.js +10 -13
  19. package/dist/abis/types/factories/AlgebraPool__factory.js.map +1 -1
  20. package/dist/abis/types/factories/ClPool__factory.d.ts +2 -3
  21. package/dist/abis/types/factories/ClPool__factory.js +10 -13
  22. package/dist/abis/types/factories/ClPool__factory.js.map +1 -1
  23. package/dist/abis/types/factories/DepositGuardWithHtsWrapping__factory.d.ts +2 -3
  24. package/dist/abis/types/factories/DepositGuardWithHtsWrapping__factory.js +10 -13
  25. package/dist/abis/types/factories/DepositGuardWithHtsWrapping__factory.js.map +1 -1
  26. package/dist/abis/types/factories/DepositGuard__factory.d.ts +2 -3
  27. package/dist/abis/types/factories/DepositGuard__factory.js +10 -13
  28. package/dist/abis/types/factories/DepositGuard__factory.js.map +1 -1
  29. package/dist/abis/types/factories/ERC20Wrapper__factory.d.ts +2 -3
  30. package/dist/abis/types/factories/ERC20Wrapper__factory.js +10 -13
  31. package/dist/abis/types/factories/ERC20Wrapper__factory.js.map +1 -1
  32. package/dist/abis/types/factories/ERC20__factory.d.ts +2 -3
  33. package/dist/abis/types/factories/ERC20__factory.js +10 -13
  34. package/dist/abis/types/factories/ERC20__factory.js.map +1 -1
  35. package/dist/abis/types/factories/IchiVault__factory.d.ts +2 -3
  36. package/dist/abis/types/factories/IchiVault__factory.js +10 -13
  37. package/dist/abis/types/factories/IchiVault__factory.js.map +1 -1
  38. package/dist/abis/types/factories/MultiFeeDistributer__factory.d.ts +2 -3
  39. package/dist/abis/types/factories/MultiFeeDistributer__factory.js +10 -13
  40. package/dist/abis/types/factories/MultiFeeDistributer__factory.js.map +1 -1
  41. package/dist/abis/types/factories/Multicall__factory.d.ts +2 -3
  42. package/dist/abis/types/factories/Multicall__factory.js +10 -13
  43. package/dist/abis/types/factories/Multicall__factory.js.map +1 -1
  44. package/dist/abis/types/factories/UniswapV3Pool__factory.d.ts +2 -3
  45. package/dist/abis/types/factories/UniswapV3Pool__factory.js +10 -13
  46. package/dist/abis/types/factories/UniswapV3Pool__factory.js.map +1 -1
  47. package/dist/src/__tests__/index.test.js +356 -738
  48. package/dist/src/__tests__/index.test.js.map +1 -1
  49. package/dist/src/abis/types/AlgebraIntegralPool.d.ts +702 -793
  50. package/dist/src/abis/types/AlgebraPool.d.ts +693 -730
  51. package/dist/src/abis/types/ClPool.d.ts +789 -871
  52. package/dist/src/abis/types/DepositGuard.d.ts +193 -178
  53. package/dist/src/abis/types/DepositGuardWithHtsWrapping.d.ts +300 -297
  54. package/dist/src/abis/types/ERC20.d.ts +120 -147
  55. package/dist/src/abis/types/ERC20Wrapper.d.ts +147 -155
  56. package/dist/src/abis/types/IchiVault.d.ts +598 -728
  57. package/dist/src/abis/types/MultiFeeDistributer.d.ts +314 -423
  58. package/dist/src/abis/types/Multicall.d.ts +58 -73
  59. package/dist/src/abis/types/UniswapV3Pool.d.ts +654 -693
  60. package/dist/src/abis/types/common.d.ts +40 -12
  61. package/dist/src/abis/types/factories/AlgebraIntegralPool__factory.d.ts +2 -3
  62. package/dist/src/abis/types/factories/AlgebraPool__factory.d.ts +2 -3
  63. package/dist/src/abis/types/factories/ClPool__factory.d.ts +2 -3
  64. package/dist/src/abis/types/factories/DepositGuardWithHtsWrapping__factory.d.ts +2 -3
  65. package/dist/src/abis/types/factories/DepositGuard__factory.d.ts +2 -3
  66. package/dist/src/abis/types/factories/ERC20Wrapper__factory.d.ts +2 -3
  67. package/dist/src/abis/types/factories/ERC20__factory.d.ts +2 -3
  68. package/dist/src/abis/types/factories/IchiVault__factory.d.ts +2 -3
  69. package/dist/src/abis/types/factories/MultiFeeDistributer__factory.d.ts +2 -3
  70. package/dist/src/abis/types/factories/Multicall__factory.d.ts +2 -3
  71. package/dist/src/abis/types/factories/UniswapV3Pool__factory.d.ts +2 -3
  72. package/dist/src/contracts/index.d.ts +1 -1
  73. package/dist/src/contracts/index.js +12 -12
  74. package/dist/src/contracts/index.js.map +1 -1
  75. package/dist/src/functions/_totalBalances.d.ts +2 -3
  76. package/dist/src/functions/_totalBalances.js +46 -117
  77. package/dist/src/functions/_totalBalances.js.map +1 -1
  78. package/dist/src/functions/_vaultEvents.js +347 -488
  79. package/dist/src/functions/_vaultEvents.js.map +1 -1
  80. package/dist/src/functions/_withdrawHelpers.d.ts +2 -3
  81. package/dist/src/functions/_withdrawHelpers.js +13 -62
  82. package/dist/src/functions/_withdrawHelpers.js.map +1 -1
  83. package/dist/src/functions/calculateApr.d.ts +1 -1
  84. package/dist/src/functions/calculateApr.js +77 -150
  85. package/dist/src/functions/calculateApr.js.map +1 -1
  86. package/dist/src/functions/calculateDtr.d.ts +1 -1
  87. package/dist/src/functions/calculateDtr.js +84 -169
  88. package/dist/src/functions/calculateDtr.js.map +1 -1
  89. package/dist/src/functions/calculateFees.d.ts +1 -1
  90. package/dist/src/functions/calculateFees.js +97 -172
  91. package/dist/src/functions/calculateFees.js.map +1 -1
  92. package/dist/src/functions/chains.js +6 -6
  93. package/dist/src/functions/chains.js.map +1 -1
  94. package/dist/src/functions/claimRewards.d.ts +3 -4
  95. package/dist/src/functions/claimRewards.js +29 -92
  96. package/dist/src/functions/claimRewards.js.map +1 -1
  97. package/dist/src/functions/deposit.d.ts +7 -9
  98. package/dist/src/functions/deposit.js +199 -364
  99. package/dist/src/functions/deposit.js.map +1 -1
  100. package/dist/src/functions/depositWithHtsWrapping.d.ts +4 -6
  101. package/dist/src/functions/depositWithHtsWrapping.js +109 -226
  102. package/dist/src/functions/depositWithHtsWrapping.js.map +1 -1
  103. package/dist/src/functions/getFeeAprs.d.ts +1 -1
  104. package/dist/src/functions/getFeeAprs.js +55 -111
  105. package/dist/src/functions/getFeeAprs.js.map +1 -1
  106. package/dist/src/functions/priceFromPool.d.ts +3 -4
  107. package/dist/src/functions/priceFromPool.js +99 -208
  108. package/dist/src/functions/priceFromPool.js.map +1 -1
  109. package/dist/src/functions/rewardInfo.js +79 -159
  110. package/dist/src/functions/rewardInfo.js.map +1 -1
  111. package/dist/src/functions/totalBalances.d.ts +2 -3
  112. package/dist/src/functions/totalBalances.js +14 -67
  113. package/dist/src/functions/totalBalances.js.map +1 -1
  114. package/dist/src/functions/userBalances.d.ts +2 -3
  115. package/dist/src/functions/userBalances.js +244 -368
  116. package/dist/src/functions/userBalances.js.map +1 -1
  117. package/dist/src/functions/userRewards.d.ts +1 -1
  118. package/dist/src/functions/userRewards.js +87 -145
  119. package/dist/src/functions/userRewards.js.map +1 -1
  120. package/dist/src/functions/vault.d.ts +1 -1
  121. package/dist/src/functions/vault.js +203 -383
  122. package/dist/src/functions/vault.js.map +1 -1
  123. package/dist/src/functions/vaultBasics.js +6 -7
  124. package/dist/src/functions/vaultBasics.js.map +1 -1
  125. package/dist/src/functions/vaultMetrics.d.ts +1 -1
  126. package/dist/src/functions/vaultMetrics.js +111 -189
  127. package/dist/src/functions/vaultMetrics.js.map +1 -1
  128. package/dist/src/functions/vaultPositions.d.ts +1 -1
  129. package/dist/src/functions/vaultPositions.js +69 -134
  130. package/dist/src/functions/vaultPositions.js.map +1 -1
  131. package/dist/src/functions/vaultTvl.d.ts +1 -1
  132. package/dist/src/functions/vaultTvl.js +80 -165
  133. package/dist/src/functions/vaultTvl.js.map +1 -1
  134. package/dist/src/functions/withdraw.d.ts +6 -8
  135. package/dist/src/functions/withdraw.js +165 -295
  136. package/dist/src/functions/withdraw.js.map +1 -1
  137. package/dist/src/functions/withdrawWithErc20Wrapping.d.ts +2 -4
  138. package/dist/src/functions/withdrawWithErc20Wrapping.js +59 -126
  139. package/dist/src/functions/withdrawWithErc20Wrapping.js.map +1 -1
  140. package/dist/src/graphql/constants.js +217 -212
  141. package/dist/src/graphql/constants.js.map +1 -1
  142. package/dist/src/graphql/functions.js +30 -102
  143. package/dist/src/graphql/functions.js.map +1 -1
  144. package/dist/src/graphql/queries.js +407 -42
  145. package/dist/src/graphql/queries.js.map +1 -1
  146. package/dist/src/index.cjs.js +2 -2
  147. package/dist/src/index.esm.js +2 -2
  148. package/dist/src/src/contracts/index.d.ts +1 -1
  149. package/dist/src/src/functions/_totalBalances.d.ts +2 -3
  150. package/dist/src/src/functions/_withdrawHelpers.d.ts +2 -3
  151. package/dist/src/src/functions/calculateApr.d.ts +1 -1
  152. package/dist/src/src/functions/calculateDtr.d.ts +1 -1
  153. package/dist/src/src/functions/calculateFees.d.ts +1 -1
  154. package/dist/src/src/functions/claimRewards.d.ts +3 -4
  155. package/dist/src/src/functions/deposit.d.ts +7 -9
  156. package/dist/src/src/functions/depositWithHtsWrapping.d.ts +4 -6
  157. package/dist/src/src/functions/getFeeAprs.d.ts +1 -1
  158. package/dist/src/src/functions/priceFromPool.d.ts +3 -4
  159. package/dist/src/src/functions/totalBalances.d.ts +2 -3
  160. package/dist/src/src/functions/userBalances.d.ts +2 -3
  161. package/dist/src/src/functions/userRewards.d.ts +1 -1
  162. package/dist/src/src/functions/vault.d.ts +1 -1
  163. package/dist/src/src/functions/vaultMetrics.d.ts +1 -1
  164. package/dist/src/src/functions/vaultPositions.d.ts +1 -1
  165. package/dist/src/src/functions/vaultTvl.d.ts +1 -1
  166. package/dist/src/src/functions/withdraw.d.ts +6 -8
  167. package/dist/src/src/functions/withdrawWithErc20Wrapping.d.ts +2 -4
  168. package/dist/src/src/types/calculateGasMargin.d.ts +1 -2
  169. package/dist/src/src/types/index.d.ts +12 -13
  170. package/dist/src/src/utils/amountWithSlippage.d.ts +1 -2
  171. package/dist/src/src/utils/config/addresses.d.ts +1 -1
  172. package/dist/src/src/utils/formatBigInt.d.ts +1 -2
  173. package/dist/src/src/utils/getPrice.d.ts +1 -2
  174. package/dist/src/src/utils/multicallUtils.d.ts +9 -10
  175. package/dist/src/src/utils/parseBigInt.d.ts +1 -2
  176. package/dist/src/types/calculateGasMargin.d.ts +1 -2
  177. package/dist/src/types/calculateGasMargin.js +4 -5
  178. package/dist/src/types/calculateGasMargin.js.map +1 -1
  179. package/dist/src/types/index.d.ts +12 -13
  180. package/dist/src/types/index.js +1 -0
  181. package/dist/src/types/index.js.map +1 -1
  182. package/dist/src/utils/amountWithSlippage.d.ts +1 -2
  183. package/dist/src/utils/amountWithSlippage.js +1 -1
  184. package/dist/src/utils/amountWithSlippage.js.map +1 -1
  185. package/dist/src/utils/cache.js +2 -2
  186. package/dist/src/utils/cache.js.map +1 -1
  187. package/dist/src/utils/config/addresses.d.ts +1 -1
  188. package/dist/src/utils/config/addresses.js +276 -268
  189. package/dist/src/utils/config/addresses.js.map +1 -1
  190. package/dist/src/utils/formatBigInt.d.ts +1 -2
  191. package/dist/src/utils/formatBigInt.js +4 -5
  192. package/dist/src/utils/formatBigInt.js.map +1 -1
  193. package/dist/src/utils/getConfigByFactory.js +24 -28
  194. package/dist/src/utils/getConfigByFactory.js.map +1 -1
  195. package/dist/src/utils/getGraphUrls.js +8 -12
  196. package/dist/src/utils/getGraphUrls.js.map +1 -1
  197. package/dist/src/utils/getPrice.d.ts +1 -2
  198. package/dist/src/utils/getPrice.js +5 -6
  199. package/dist/src/utils/getPrice.js.map +1 -1
  200. package/dist/src/utils/isVelodrome.js +2 -3
  201. package/dist/src/utils/isVelodrome.js.map +1 -1
  202. package/dist/src/utils/multicallUtils.d.ts +9 -10
  203. package/dist/src/utils/multicallUtils.js +38 -93
  204. package/dist/src/utils/multicallUtils.js.map +1 -1
  205. package/dist/src/utils/parseBigInt.d.ts +1 -2
  206. package/dist/src/utils/parseBigInt.js +5 -7
  207. package/dist/src/utils/parseBigInt.js.map +1 -1
  208. package/dist/src/utils/positionKey.js +2 -4
  209. package/dist/src/utils/positionKey.js.map +1 -1
  210. package/package.json +5 -17
package/README.md CHANGED
@@ -7,6 +7,8 @@ This sdk contains collection of functions to interact with IchiVault's smart con
7
7
  ## Table of Contents
8
8
 
9
9
  * [__Installation__](#Installation)
10
+ * [Version Compatibility](#version-compatibility)
11
+ * [Migration from v1 to v2](#migration-from-v1-to-v2)
10
12
  * [__Subgraphs__](#Subgraphs)
11
13
  * [__Usage__](#Usage)
12
14
  * [__Vault Functions__](#Vault)
@@ -18,11 +20,6 @@ This sdk contains collection of functions to interact with IchiVault's smart con
18
20
  * [`withdraw()`](#6-withdraw)
19
21
  * [`withdrawWithSlippage()`](#7-withdraw)
20
22
  * [`withdrawNativeToken()`](#8-withdraw)
21
- * [`approveToken()`](#8a-approveToken)
22
- * [`isTokenApproved()`](#8b-isTokenApproved)
23
- * [`getActualDepositToken()`](#8c-getActualDepositToken)
24
- * [`depositWithHtsWrapping()`](#8d-depositWithHtsWrapping)
25
- * [`withdrawWithErc20Wrapping()`](#8e-withdrawWithErc20Wrapping)
26
23
  * [`isDepositTokenApproved()`](#9-isDepositTokenApproved)
27
24
  * [`isTokenAllowed()`](#10-isTokenAllowed)
28
25
  * [`getMaxDepositAmount()`](#11-getMaxDepositAmount)
@@ -59,12 +56,69 @@ or
59
56
  npm install @ichidao/ichi-vaults-sdk
60
57
  ```
61
58
 
59
+ ### Version Compatibility
60
+
61
+ | SDK Version | Ethers.js Version | Status |
62
+ |-------------|-------------------|--------|
63
+ | 2.x.x | v6 | Active |
64
+ | 0.1.x | v5 | Maintenance |
65
+
66
+ **Version 2.x (ethers v6)** - Current default version. If you're using ethers v6 in your project, install the latest version:
67
+ ```bash
68
+ yarn add @ichidao/ichi-vaults-sdk
69
+ # or
70
+ npm install @ichidao/ichi-vaults-sdk
71
+ ```
72
+
73
+ **Version 0.1.x (ethers v5)** - For projects still using ethers v5, install the legacy version:
74
+ ```bash
75
+ yarn add @ichidao/ichi-vaults-sdk@ethers5
76
+ # or
77
+ npm install @ichidao/ichi-vaults-sdk@ethers5
78
+ ```
79
+
80
+ To install a specific version:
81
+ ```bash
82
+ yarn add @ichidao/ichi-vaults-sdk@0.1.x
83
+ # or
84
+ npm install @ichidao/ichi-vaults-sdk@0.1.x
85
+ ```
86
+
87
+ ### Migration from v0.1 to v2
88
+
89
+ The main breaking change in v2 is that functions requiring transaction signing now accept a `Signer` instead of `JsonRpcProvider`. This aligns with ethers v6's architecture where signers are explicitly passed rather than obtained from providers.
90
+
91
+ **Before (v0.1 with ethers v5):**
92
+ ```typescript
93
+ import { JsonRpcProvider } from '@ethersproject/providers';
94
+ const provider = new JsonRpcProvider(rpcUrl);
95
+ await deposit(account, amount0, amount1, vaultAddress, provider, dex);
96
+ ```
97
+
98
+ **After (v2 with ethers v6):**
99
+ ```typescript
100
+ import { JsonRpcProvider, Wallet } from 'ethers';
101
+ const provider = new JsonRpcProvider(rpcUrl);
102
+ const signer = new Wallet(privateKey, provider);
103
+ await deposit(account, amount0, amount1, vaultAddress, signer, dex);
104
+ ```
105
+
106
+ Functions affected by this change:
107
+ - `approveDepositToken()`
108
+ - `deposit()`
109
+ - `depositNativeToken()`
110
+ - `approveVaultToken()`
111
+ - `withdraw()`
112
+ - `withdrawWithSlippage()`
113
+ - `withdrawNativeToken()`
114
+ - `claimRewards()`
115
+
116
+ Read-only functions continue to accept `JsonRpcProvider`.
117
+
62
118
  ## Usage
63
119
  ### Subgraphs
64
120
  This SDK uses subgraphs to obtain information about ICHI vaults. The subgraphs are deployed in the Subgraph Studio and published on Arbitrum One. If you prefer to use published subgraphs, you need to add your [subgraph API key](https://thegraph.com/studio/apikeys/) to the SUBGRAPH_API_KEY environment variable. Otherwise, the SDK will use the subgraph's Studio endpoint.
65
121
 
66
- **Note for Flow users:** The Flow blockchain uses Alchemy subgraph instead of Subgraph Studio. If you're using this SDK on Flow, you need to provide your own Alchemy subgraph API key by adding it to the ALCHEMY_SUBGRAPH_API_KEY environment variable.
67
-
68
122
  ### Vault
69
123
 
70
124
  #### 1. `approveDepositToken()`
@@ -387,206 +441,6 @@ const txnDetails = await withdraw(
387
441
  )
388
442
  ```
389
443
 
390
- #### 8a. `approveToken()`
391
-
392
- | param | type | default | required
393
- | -------- | -------- | -------- | --------
394
- | accountAddress | string | - | true
395
- | tokenAddress | string | - | true
396
- | vaultAddress | string | - | true |
397
- | jsonProvider | [JsonRpcProvider](https://github.com/ethers-io/ethers.js/blob/f97b92bbb1bde22fcc44100af78d7f31602863ab/packages/providers/src.ts/json-rpc-provider.ts#L393) | - | true
398
- | dex | SupportedDex | - | true |
399
- | amount | string \| number \| BigNumber | undefined | false |
400
- | overrides | [Overrides](https://github.com/ethers-io/ethers.js/blob/f97b92bbb1bde22fcc44100af78d7f31602863ab/packages/contracts/lib/index.d.ts#L7) | undefined | false
401
-
402
- <br/>
403
-
404
- This function approves a specific token for deposit into the vault by token address. Unlike `approveDepositToken()` which uses a token index (0 or 1), this function accepts the actual token address. This is particularly useful when working with HTS wrapped tokens where the actual deposit token may differ from the vault's token. Use `getActualDepositToken()` to determine the correct token address to approve.
405
-
406
- ```typescript
407
- import { Web3Provider } from '@ethersproject/providers';
408
- import { approveToken, getActualDepositToken, SupportedDex } from '@ichidao/ichi-vaults-sdk';
409
-
410
- const web3Provider = new Web3Provider(YOUR_WEB3_PROVIDER);
411
- const vaultAddress = "0x3ac9...a5f132"
412
- const accountAddress = "0xaaaa...aaaaaa"
413
- const depositToken = "0xbbbb...bbbbbb" // original deposit token from vault
414
- const dex = SupportedDex.Bonzo
415
-
416
- // Get the actual token to approve (may be ERC20 counterpart of HTS token)
417
- const actualToken = await getActualDepositToken(depositToken, web3Provider);
418
-
419
- const txnDetails = await approveToken(
420
- accountAddress,
421
- actualToken,
422
- vaultAddress,
423
- web3Provider,
424
- dex,
425
- 100 // amount (optional)
426
- );
427
-
428
- await txnDetails.wait();
429
- ```
430
-
431
- #### 8b. `isTokenApproved()`
432
-
433
- | param | type | default | required
434
- | -------- | -------- | -------- | --------
435
- | accountAddress | string | - | true
436
- | tokenAddress | string | - | true
437
- | amount | string \| number \| BigNumber | - | true |
438
- | vaultAddress | string | - | true |
439
- | jsonProvider | [JsonRpcProvider](https://github.com/ethers-io/ethers.js/blob/f97b92bbb1bde22fcc44100af78d7f31602863ab/packages/providers/src.ts/json-rpc-provider.ts#L393) | - | true
440
- | dex | SupportedDex | - | true |
441
-
442
- <br/>
443
-
444
- This function returns true if the specified token's allowance is non-zero and greater than or equal to the specified amount. Use this to check approval status for the actual deposit token (which may be the ERC20 counterpart of an HTS token for vaults on Hedera).
445
-
446
- ```typescript
447
- import { Web3Provider } from '@ethersproject/providers';
448
- import { isTokenApproved, getActualDepositToken, SupportedDex } from '@ichidao/ichi-vaults-sdk';
449
-
450
- const web3Provider = new Web3Provider(YOUR_WEB3_PROVIDER);
451
- const vaultAddress = "0x3ac9...a5f132"
452
- const accountAddress = "0xaaaa...aaaaaa"
453
- const depositToken = "0xbbbb...bbbbbb"
454
- const amount = 100
455
- const dex = SupportedDex.Bonzo
456
-
457
- // Get the actual token to check (may be ERC20 counterpart of HTS token)
458
- const actualToken = await getActualDepositToken(depositToken, web3Provider);
459
-
460
- const isApproved: boolean = await isTokenApproved(
461
- accountAddress,
462
- actualToken,
463
- amount,
464
- vaultAddress,
465
- web3Provider,
466
- dex
467
- )
468
- ```
469
-
470
- #### 8c. `getActualDepositToken()` - Bonzo on Hedera Only
471
-
472
- | param | type | default | required
473
- | -------- | -------- | -------- | --------
474
- | depositToken | string | - | true
475
- | jsonProvider | [JsonRpcProvider](https://github.com/ethers-io/ethers.js/blob/f97b92bbb1bde22fcc44100af78d7f31602863ab/packages/providers/src.ts/json-rpc-provider.ts#L393) | - | true
476
-
477
- <br/>
478
-
479
- > **Note:** This function is only available for Bonzo vaults on the Hedera chain.
480
-
481
- This helper function checks if the deposit token is an HTS wrapped token and returns its ERC20 counterpart if one exists. If no ERC20 counterpart exists, it returns the original token address. Use this function to determine the correct token address for approval and deposit operations.
482
-
483
- ```typescript
484
- import { Web3Provider } from '@ethersproject/providers';
485
- import { getActualDepositToken } from '@ichidao/ichi-vaults-sdk';
486
-
487
- const web3Provider = new Web3Provider(YOUR_WEB3_PROVIDER);
488
- const depositToken = "0xbbbb...bbbbbb" // HTS wrapped token
489
-
490
- const actualToken = await getActualDepositToken(depositToken, web3Provider);
491
- // actualToken will be the ERC20 counterpart if one exists, otherwise the original token
492
- ```
493
-
494
- #### 8d. `depositWithHtsWrapping()` - Bonzo on Hedera Only
495
-
496
- | param | type | default | required
497
- | -------- | -------- | -------- | --------
498
- | accountAddress | string | - | true
499
- | amount0 | string \| number \| BigNumber | - | true
500
- | amount1 | string \| number \| BigNumber | - | true
501
- | vaultAddress | string | - | true
502
- | jsonProvider | [JsonRpcProvider](https://github.com/ethers-io/ethers.js/blob/f97b92bbb1bde22fcc44100af78d7f31602863ab/packages/providers/src.ts/json-rpc-provider.ts#L393) | - | true
503
- | dex | SupportedDex | - | true
504
- | percentSlippage | number | 1 | false
505
- | overrides | [Overrides](https://github.com/ethers-io/ethers.js/blob/f97b92bbb1bde22fcc44100af78d7f31602863ab/packages/contracts/lib/index.d.ts#L7) | undefined | false
506
-
507
- <br/>
508
-
509
- > **Note:** This function is only available for Bonzo vaults on the Hedera chain. Using it with other vaults or chains will throw an error.
510
-
511
- This function facilitates deposits into Bonzo vaults on Hedera with automatic HTS token wrapping. If the deposit token is an HTS wrapped token, the function automatically finds and uses its ERC20 counterpart for the deposit. The vault tokens received will be wrapped to HTS format. Use `approveToken()` with `getActualDepositToken()` to approve the correct token before calling this function.
512
-
513
- ```typescript
514
- import { Web3Provider } from '@ethersproject/providers';
515
- import { depositWithHtsWrapping, approveToken, getActualDepositToken, SupportedDex } from '@ichidao/ichi-vaults-sdk';
516
-
517
- const web3Provider = new Web3Provider(YOUR_WEB3_PROVIDER);
518
- const vaultAddress = "0x3ac9...a5f132"
519
- const dex = SupportedDex.Bonzo
520
- const accountAddress = "0xaaaa...aaaaaa"
521
- const depositToken = "0xbbbb...bbbbbb" // token from vault
522
-
523
- // First, get the actual token and approve it
524
- const actualToken = await getActualDepositToken(depositToken, web3Provider);
525
- await approveToken(accountAddress, actualToken, vaultAddress, web3Provider, dex);
526
-
527
- const amount0 = 100
528
- const amount1 = 0
529
-
530
- const txnDetails = await depositWithHtsWrapping(
531
- accountAddress,
532
- amount0,
533
- amount1,
534
- vaultAddress,
535
- web3Provider,
536
- dex,
537
- 1 // acceptable slippage (percent)
538
- )
539
- ```
540
-
541
- #### 8e. `withdrawWithErc20Wrapping()` - Bonzo on Hedera Only
542
-
543
- | param | type | default | required
544
- | -------- | -------- | -------- | --------
545
- | accountAddress | string | - | true
546
- | shares | string \| number \| BigNumber | - | true
547
- | vaultAddress | string | - | true
548
- | jsonProvider | [JsonRpcProvider](https://github.com/ethers-io/ethers.js/blob/f97b92bbb1bde22fcc44100af78d7f31602863ab/packages/providers/src.ts/json-rpc-provider.ts#L393) | - | true
549
- | dex | SupportedDex | - | true
550
- | percentSlippage | number | 1 | false
551
- | overrides | [Overrides](https://github.com/ethers-io/ethers.js/blob/f97b92bbb1bde22fcc44100af78d7f31602863ab/packages/contracts/lib/index.d.ts#L7) | undefined | false
552
-
553
- <br/>
554
-
555
- > **Note:** This function is only available for Bonzo vaults on the Hedera chain. Using it with other vaults or chains will throw an error.
556
-
557
- This function facilitates withdrawals from Bonzo vaults on Hedera with automatic unwrapping of HTS tokens to their ERC20 counterparts. If the vault tokens are HTS wrapped, they will be automatically converted to ERC20 tokens during withdrawal. Ensure to use the `approveVaultToken()` function before invoking this function.
558
-
559
- ```typescript
560
- import { Web3Provider } from '@ethersproject/providers';
561
- import { getUserBalance, withdrawWithErc20Wrapping, approveVaultToken, SupportedDex } from '@ichidao/ichi-vaults-sdk';
562
-
563
- const web3Provider = new Web3Provider(YOUR_WEB3_PROVIDER);
564
- const vaultAddress = "0x3ac9...a5f132"
565
- const dex = SupportedDex.Bonzo
566
- const accountAddress = "0xaaaa...aaaaaa"
567
-
568
- const totalUserShares: string = await getUserBalance(
569
- accountAddress,
570
- vaultAddress,
571
- web3Provider,
572
- dex
573
- )
574
-
575
- let shares = Number(totalUserShares) * 0.5 // 50% of user share balance
576
-
577
- // Approve vault tokens first
578
- await approveVaultToken(accountAddress, vaultAddress, web3Provider, dex, shares);
579
-
580
- const txnDetails = await withdrawWithErc20Wrapping(
581
- accountAddress,
582
- shares,
583
- vaultAddress,
584
- web3Provider,
585
- dex,
586
- 1 // acceptable slippage (percent)
587
- )
588
- ```
589
-
590
444
  #### 9. `isDepositTokenApproved()`
591
445
 
592
446
  | param | type | default | required
@@ -1425,6 +1279,7 @@ enum SupportedDex {
1425
1279
  Agni = 'Agni',
1426
1280
  Ascent = 'Ascent',
1427
1281
  Atlantis = 'Anlantis',
1282
+ Aux = 'Aux',
1428
1283
  Bitzy = 'Bitzy',
1429
1284
  Blueprint = 'Blueprint',
1430
1285
  Bonzo = 'Bonzo',
@@ -1446,7 +1301,6 @@ enum SupportedDex {
1446
1301
  Linehub = 'Linehub',
1447
1302
  Lynex = 'Lynex',
1448
1303
  Metavault = 'Metavault',
1449
- Nest = 'Nest',
1450
1304
  Nile = 'Nile',
1451
1305
  Ocelex = 'Ocelex',
1452
1306
  Pancakeswap = 'PancakeSwap',