@ichidao/ichi-vaults-sdk 0.0.113 → 0.1.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 (68) hide show
  1. package/README.md +191 -0
  2. package/dist/abis/types/MultiFeeDistributer.d.ts +475 -0
  3. package/dist/abis/types/MultiFeeDistributer.js +3 -0
  4. package/dist/abis/types/MultiFeeDistributer.js.map +1 -0
  5. package/dist/abis/types/factories/MultiFeeDistributer__factory.d.ts +451 -0
  6. package/dist/abis/types/factories/MultiFeeDistributer__factory.js +596 -0
  7. package/dist/abis/types/factories/MultiFeeDistributer__factory.js.map +1 -0
  8. package/dist/abis/types/factories/index.d.ts +1 -0
  9. package/dist/abis/types/factories/index.js +3 -1
  10. package/dist/abis/types/factories/index.js.map +1 -1
  11. package/dist/abis/types/index.d.ts +2 -0
  12. package/dist/abis/types/index.js +3 -1
  13. package/dist/abis/types/index.js.map +1 -1
  14. package/dist/src/__tests__/index.test.js +74 -1
  15. package/dist/src/__tests__/index.test.js.map +1 -1
  16. package/dist/src/abis/types/MultiFeeDistributer.d.ts +475 -0
  17. package/dist/src/abis/types/factories/MultiFeeDistributer__factory.d.ts +451 -0
  18. package/dist/src/abis/types/factories/index.d.ts +1 -0
  19. package/dist/src/abis/types/index.d.ts +2 -0
  20. package/dist/src/contracts/index.d.ts +2 -1
  21. package/dist/src/contracts/index.js +11 -1
  22. package/dist/src/contracts/index.js.map +1 -1
  23. package/dist/src/functions/claimRewards.d.ts +14 -0
  24. package/dist/src/functions/claimRewards.js +109 -0
  25. package/dist/src/functions/claimRewards.js.map +1 -0
  26. package/dist/src/functions/rewardInfo.d.ts +3 -0
  27. package/dist/src/functions/rewardInfo.js +176 -0
  28. package/dist/src/functions/rewardInfo.js.map +1 -0
  29. package/dist/src/functions/userBalances.d.ts +1 -1
  30. package/dist/src/functions/userBalances.js +64 -29
  31. package/dist/src/functions/userBalances.js.map +1 -1
  32. package/dist/src/functions/userRewards.d.ts +6 -0
  33. package/dist/src/functions/userRewards.js +161 -0
  34. package/dist/src/functions/userRewards.js.map +1 -0
  35. package/dist/src/functions/vault.d.ts +2 -1
  36. package/dist/src/functions/vault.js +74 -26
  37. package/dist/src/functions/vault.js.map +1 -1
  38. package/dist/src/graphql/constants.js +2 -2
  39. package/dist/src/graphql/constants.js.map +1 -1
  40. package/dist/src/graphql/queries.d.ts +14 -1
  41. package/dist/src/graphql/queries.js +57 -18
  42. package/dist/src/graphql/queries.js.map +1 -1
  43. package/dist/src/index.cjs.js +4 -1
  44. package/dist/src/index.d.ts +3 -0
  45. package/dist/src/index.esm.js +4 -1
  46. package/dist/src/index.js +3 -0
  47. package/dist/src/index.js.map +1 -1
  48. package/dist/src/src/contracts/index.d.ts +2 -1
  49. package/dist/src/src/functions/claimRewards.d.ts +14 -0
  50. package/dist/src/src/functions/rewardInfo.d.ts +3 -0
  51. package/dist/src/src/functions/userBalances.d.ts +1 -1
  52. package/dist/src/src/functions/userRewards.d.ts +6 -0
  53. package/dist/src/src/functions/vault.d.ts +2 -1
  54. package/dist/src/src/graphql/queries.d.ts +14 -1
  55. package/dist/src/src/index.d.ts +3 -0
  56. package/dist/src/src/types/index.d.ts +50 -0
  57. package/dist/src/src/types/vaultQueryData.d.ts +10 -1
  58. package/dist/src/src/utils/isVelodrome.d.ts +2 -0
  59. package/dist/src/src/utils/multicallUtils.d.ts +2 -0
  60. package/dist/src/types/index.d.ts +50 -0
  61. package/dist/src/types/vaultQueryData.d.ts +10 -1
  62. package/dist/src/utils/isVelodrome.d.ts +2 -0
  63. package/dist/src/utils/isVelodrome.js +11 -0
  64. package/dist/src/utils/isVelodrome.js.map +1 -0
  65. package/dist/src/utils/multicallUtils.d.ts +2 -0
  66. package/dist/src/utils/multicallUtils.js +19 -1
  67. package/dist/src/utils/multicallUtils.js.map +1 -1
  68. package/package.json +1 -1
package/README.md CHANGED
@@ -38,6 +38,11 @@ This sdk contains collection of functions to interact with IchiVault's smart con
38
38
  * [`getVaultPositions()`](#26-getVaultPositions)
39
39
  * [`getSupportedDexes()`](#27-getSupportedDexes)
40
40
  * [`getChainsForDex()`](#28-getChainsForDex)
41
+ * [`getRewardInfo()`](#29-getRewardInfo)
42
+ * [`getAllRewardInfo()`](#30-getAllRewardInfo)
43
+ * [`getAllUserRewards()`](#31-getAllUserRewards)
44
+ * [`getUserRewards()`](#32-getUserRewards)
45
+ * [`claimRewards()`](#33-claimRewards)
41
46
 
42
47
  ## Installation
43
48
  Install with
@@ -1036,6 +1041,116 @@ const dex = SupportedChainId.UniswapV3;
1036
1041
  const chains: SupportedChainId[] = getChainsForDex(dex);
1037
1042
  ```
1038
1043
 
1044
+ #### 29. `getRewardInfo()`
1045
+
1046
+ | param | type | default | required
1047
+ | -------- | -------- | -------- | --------
1048
+ | chainId | SupportedChainId | - | true |
1049
+ | dex | SupportedDex | - | true |
1050
+ | vaultAddress | string | - | true |
1051
+
1052
+ <br/>
1053
+ This function returns information about reward rates and farming contract for the specified vault. This functions is specific for the Velodrome vaults.
1054
+
1055
+ ```typescript
1056
+ import { getRewardInfo, SupportedChainId, SupportedDex } from '@ichidao/ichi-vaults-sdk';
1057
+
1058
+ const vaultAddress = "0x3e4...45a";
1059
+ const chainId = SupportedChainId.Ink;
1060
+ const dex = SupportedDex.Velodrome;
1061
+
1062
+ const rewardInfo: RewardInfo = getRewardInfo(chainId, dex, vaultAddress);
1063
+ ```
1064
+
1065
+ #### 30. `getAllRewardInfo()`
1066
+
1067
+ | param | type | default | required
1068
+ | -------- | -------- | -------- | --------
1069
+ | chainId | SupportedChainId | - | true |
1070
+ | dex | SupportedDex | - | true |
1071
+
1072
+ <br/>
1073
+ This function returns information about reward rates and farming contract for all vaults on the dex. This functions is specific for the Velodrome vaults.
1074
+
1075
+ ```typescript
1076
+ import { getAllRewardInfo, SupportedChainId, SupportedDex } from '@ichidao/ichi-vaults-sdk';
1077
+
1078
+ const chainId = SupportedChainId.Ink;
1079
+ const dex = SupportedDex.Velodrome;
1080
+
1081
+ const chains: RewardInfo[] = getAllRewardInfo(chainId, dex);
1082
+ ```
1083
+
1084
+ #### 31. `getAllUserRewards()`
1085
+
1086
+ | param | type | default | required
1087
+ | -------- | -------- | -------- | --------
1088
+ | accountAddress | string | - | true |
1089
+ | jsonProvider | JsonRpcProvider | - | true |
1090
+ | dex | SupportedDex | - | true |
1091
+ | raw | true | undefined | - | false |
1092
+
1093
+ <br/>
1094
+ This function returns user rewards for all vaults on the dex. This functions is specific for the Velodrome vaults.
1095
+
1096
+ ```typescript
1097
+ import { getAllUserRewards, SupportedDex } from '@ichidao/ichi-vaults-sdk';
1098
+
1099
+ const account = "0x123...890";
1100
+ const provider = new Web3Provider(YOUR_WEB3_PROVIDER);
1101
+ const dex = SupportedDex.Velodrome;
1102
+
1103
+ const rewards: UserRewards[] = await getAllUserRewards(account, provider, dex);
1104
+ ```
1105
+
1106
+ #### 32. `getUserRewards()`
1107
+
1108
+ | param | type | default | required
1109
+ | -------- | -------- | -------- | --------
1110
+ | accountAddress | string | - | true |
1111
+ | vaultAddress | string | - | true |
1112
+ | jsonProvider | JsonRpcProvider | - | true |
1113
+ | dex | SupportedDex | - | true |
1114
+ | raw | true | undefined | - | false |
1115
+
1116
+ <br/>
1117
+ This function returns claimable reward amounts for the specified vault and user account. This functions is specific for the Velodrome vaults.
1118
+
1119
+ ```typescript
1120
+ import { getUserRewards, SupportedDex } from '@ichidao/ichi-vaults-sdk';
1121
+
1122
+ const account = "0x123...890";
1123
+ const vaultAddress = "0x3e4...45a";
1124
+ const provider = new Web3Provider(YOUR_WEB3_PROVIDER);
1125
+ const dex = SupportedDex.Velodrome;
1126
+
1127
+ const rewards: UserRewardByToken[] = getUserRewards(account, vaultAddress, provider, dex);
1128
+ const rewardsBN: UserRewardByTokenBN[] = getUserRewards(account, vaultAddress, provider, dex, true);
1129
+ ```
1130
+
1131
+ #### 33. `claimRewards()`
1132
+
1133
+ | param | type | default | required
1134
+ | -------- | -------- | -------- | --------
1135
+ | accountAddress | string | - | true |
1136
+ | vaultAddress | string | - | true |
1137
+ | jsonProvider | JsonRpcProvider | - | true |
1138
+ | dex | SupportedDex | - | true |
1139
+
1140
+ <br/>
1141
+ This function transfers rewards from the reward contract to the specified account. This functions is specific for the Velodrome vaults.
1142
+
1143
+ ```typescript
1144
+ import { claimRewards, SupportedDex } from '@ichidao/ichi-vaults-sdk';
1145
+
1146
+ const account = "0x123...890";
1147
+ const vaultAddress = "0x3e4...45a";
1148
+ const provider = new Web3Provider(YOUR_WEB3_PROVIDER);
1149
+ const dex = SupportedDex.Velodrome;
1150
+
1151
+ await claimRewards(account, vaultAddress, provider, dex);
1152
+ ```
1153
+
1039
1154
  ## Types
1040
1155
 
1041
1156
  ### SupportedChainId
@@ -1150,6 +1265,12 @@ interface IchiVault {
1150
1265
  allowTokenB: boolean;
1151
1266
  holdersCount?: string // number of vault LP holders
1152
1267
  fee?: string
1268
+ farmingContract?: string; // used for Velodrome vaults only
1269
+ rewardTokens?: {
1270
+ // used for Velodrome vaults only
1271
+ token: string;
1272
+ tokenDecimals: number;
1273
+ }[];
1153
1274
  }
1154
1275
  ```
1155
1276
 
@@ -1251,6 +1372,7 @@ type UserAmountsInVaultBN = {
1251
1372
  type UserBalanceInVault = {
1252
1373
  vaultAddress: string;
1253
1374
  shares: string;
1375
+ stakedShares?: string;
1254
1376
  };
1255
1377
  ```
1256
1378
 
@@ -1260,6 +1382,7 @@ type UserBalanceInVault = {
1260
1382
  type UserBalanceInVaultBN = {
1261
1383
  vaultAddress: string;
1262
1384
  shares: BigNumber;
1385
+ stakedShares?: BigNumber;
1263
1386
  };
1264
1387
  ```
1265
1388
 
@@ -1282,3 +1405,71 @@ type VaultPositionsInfo = {
1282
1405
  } [],
1283
1406
  }
1284
1407
  ```
1408
+
1409
+ ### RewardToken
1410
+ used for Velodrome vaults only
1411
+
1412
+ ```typescript
1413
+
1414
+ type RewardToken = {
1415
+ rewardRatePerToken_1d: string;
1416
+ rewardRatePerToken_3d: string;
1417
+ token: string;
1418
+ tokenDecimals: number;
1419
+ };
1420
+ ```
1421
+
1422
+ ### UserRewardsByToken
1423
+
1424
+ ```typescript
1425
+
1426
+ type UserRewardsByToken = {
1427
+ token: string;
1428
+ tokenDecimals: number;
1429
+ rewardAmount: string;
1430
+ };
1431
+ ```
1432
+
1433
+ ### UserRewardsByTokenBN
1434
+
1435
+ ```typescript
1436
+
1437
+ type UserRewardsByTokenBN = {
1438
+ token: string;
1439
+ tokenDecimals: number;
1440
+ rewardAmount: BigNumber;
1441
+ };
1442
+ ```
1443
+
1444
+ ### RewardInfo
1445
+
1446
+ ```typescript
1447
+
1448
+ type RewardInfo = {
1449
+ id: string;
1450
+ farmingContract: {
1451
+ id: string;
1452
+ rewardTokens: RewardToken[];
1453
+ };
1454
+ };
1455
+ ```
1456
+
1457
+ ### UserRewards
1458
+
1459
+ ```typescript
1460
+
1461
+ type UserRewards = {
1462
+ vaultAddress: string;
1463
+ rewardTokens: UserRewardsByToken[];
1464
+ };
1465
+ ```
1466
+
1467
+ ### UserRewardsBN
1468
+
1469
+ ```typescript
1470
+
1471
+ type UserRewardsBN = {
1472
+ vaultAddress: string;
1473
+ rewardTokens: UserRewardsByTokenBN[];
1474
+ };
1475
+ ```