@huma-finance/sdk 0.0.8 → 0.0.10

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 (127) hide show
  1. package/LICENSE +660 -660
  2. package/README.md +30 -30
  3. package/package.json +3 -3
  4. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.d.ts +0 -10
  5. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js +0 -22
  6. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js.map +0 -1
  7. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.d.ts +0 -10
  8. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js +0 -22
  9. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js.map +0 -1
  10. package/dist/cjs/helpers/PoolContractHelper.d.ts +0 -12
  11. package/dist/cjs/helpers/PoolContractHelper.js +0 -21
  12. package/dist/cjs/helpers/PoolContractHelper.js.map +0 -1
  13. package/dist/cjs/helpers/index.d.ts +0 -3
  14. package/dist/cjs/helpers/index.js +0 -7
  15. package/dist/cjs/helpers/index.js.map +0 -1
  16. package/dist/cjs/hooks/index.d.ts +0 -4
  17. package/dist/cjs/hooks/index.js +0 -8
  18. package/dist/cjs/hooks/index.js.map +0 -1
  19. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.d.ts +0 -10
  20. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js +0 -20
  21. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js.map +0 -1
  22. package/dist/cjs/hooks/useContract.d.ts +0 -13
  23. package/dist/cjs/hooks/useContract.js +0 -31
  24. package/dist/cjs/hooks/useContract.js.map +0 -1
  25. package/dist/cjs/hooks/useERC20TransferableReceivableContract.d.ts +0 -12
  26. package/dist/cjs/hooks/useERC20TransferableReceivableContract.js +0 -21
  27. package/dist/cjs/hooks/useERC20TransferableReceivableContract.js.map +0 -1
  28. package/dist/cjs/hooks/usePoolContract.d.ts +0 -60
  29. package/dist/cjs/hooks/usePoolContract.js +0 -54
  30. package/dist/cjs/hooks/usePoolContract.js.map +0 -1
  31. package/dist/cjs/hooks/useReceivableFactoringPoolContract.d.ts +0 -10
  32. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js +0 -17
  33. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js.map +0 -1
  34. package/dist/cjs/index.d.ts +0 -4
  35. package/dist/cjs/index.js +0 -8
  36. package/dist/cjs/index.js.map +0 -1
  37. package/dist/cjs/services/ARWeaveService.d.ts +0 -84
  38. package/dist/cjs/services/ARWeaveService.js +0 -152
  39. package/dist/cjs/services/ARWeaveService.js.map +0 -1
  40. package/dist/cjs/services/EAService.d.ts +0 -36
  41. package/dist/cjs/services/EAService.js +0 -19
  42. package/dist/cjs/services/EAService.js.map +0 -1
  43. package/dist/cjs/services/ReceivableService.d.ts +0 -95
  44. package/dist/cjs/services/ReceivableService.js +0 -172
  45. package/dist/cjs/services/ReceivableService.js.map +0 -1
  46. package/dist/cjs/services/SubgraphService.d.ts +0 -53
  47. package/dist/cjs/services/SubgraphService.js +0 -101
  48. package/dist/cjs/services/SubgraphService.js.map +0 -1
  49. package/dist/cjs/services/index.d.ts +0 -4
  50. package/dist/cjs/services/index.js +0 -8
  51. package/dist/cjs/services/index.js.map +0 -1
  52. package/dist/cjs/utils/chain.d.ts +0 -14
  53. package/dist/cjs/utils/chain.js +0 -34
  54. package/dist/cjs/utils/chain.js.map +0 -1
  55. package/dist/cjs/utils/index.d.ts +0 -3
  56. package/dist/cjs/utils/index.js +0 -7
  57. package/dist/cjs/utils/index.js.map +0 -1
  58. package/dist/cjs/utils/poolInfo.d.ts +0 -9
  59. package/dist/cjs/utils/poolInfo.js +0 -14
  60. package/dist/cjs/utils/poolInfo.js.map +0 -1
  61. package/dist/cjs/utils/web3.d.ts +0 -4
  62. package/dist/cjs/utils/web3.js +0 -29
  63. package/dist/cjs/utils/web3.js.map +0 -1
  64. package/dist/helpers/BaseCreditPoolReceivableContractHelper.d.ts +0 -10
  65. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js +0 -18
  66. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js.map +0 -1
  67. package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +0 -10
  68. package/dist/helpers/ERC20TransferableReceivableContractHelper.js +0 -18
  69. package/dist/helpers/ERC20TransferableReceivableContractHelper.js.map +0 -1
  70. package/dist/helpers/PoolContractHelper.d.ts +0 -12
  71. package/dist/helpers/PoolContractHelper.js +0 -17
  72. package/dist/helpers/PoolContractHelper.js.map +0 -1
  73. package/dist/helpers/index.d.ts +0 -3
  74. package/dist/helpers/index.js +0 -4
  75. package/dist/helpers/index.js.map +0 -1
  76. package/dist/hooks/index.d.ts +0 -4
  77. package/dist/hooks/index.js +0 -5
  78. package/dist/hooks/index.js.map +0 -1
  79. package/dist/hooks/useBaseCreditPoolReceivableContract.d.ts +0 -10
  80. package/dist/hooks/useBaseCreditPoolReceivableContract.js +0 -16
  81. package/dist/hooks/useBaseCreditPoolReceivableContract.js.map +0 -1
  82. package/dist/hooks/useContract.d.ts +0 -13
  83. package/dist/hooks/useContract.js +0 -27
  84. package/dist/hooks/useContract.js.map +0 -1
  85. package/dist/hooks/useERC20TransferableReceivableContract.d.ts +0 -12
  86. package/dist/hooks/useERC20TransferableReceivableContract.js +0 -17
  87. package/dist/hooks/useERC20TransferableReceivableContract.js.map +0 -1
  88. package/dist/hooks/usePool.d.ts +0 -0
  89. package/dist/hooks/usePool.js +0 -2
  90. package/dist/hooks/usePool.js.map +0 -1
  91. package/dist/hooks/usePoolContract.d.ts +0 -60
  92. package/dist/hooks/usePoolContract.js +0 -49
  93. package/dist/hooks/usePoolContract.js.map +0 -1
  94. package/dist/hooks/useReceivableFactoringPoolContract.d.ts +0 -10
  95. package/dist/hooks/useReceivableFactoringPoolContract.js +0 -13
  96. package/dist/hooks/useReceivableFactoringPoolContract.js.map +0 -1
  97. package/dist/index.d.ts +0 -4
  98. package/dist/index.js +0 -5
  99. package/dist/index.js.map +0 -1
  100. package/dist/services/ARWeaveService.d.ts +0 -84
  101. package/dist/services/ARWeaveService.js +0 -147
  102. package/dist/services/ARWeaveService.js.map +0 -1
  103. package/dist/services/EAService.d.ts +0 -36
  104. package/dist/services/EAService.js +0 -16
  105. package/dist/services/EAService.js.map +0 -1
  106. package/dist/services/ReceivableService.d.ts +0 -95
  107. package/dist/services/ReceivableService.js +0 -169
  108. package/dist/services/ReceivableService.js.map +0 -1
  109. package/dist/services/SubgraphService.d.ts +0 -53
  110. package/dist/services/SubgraphService.js +0 -98
  111. package/dist/services/SubgraphService.js.map +0 -1
  112. package/dist/services/index.d.ts +0 -4
  113. package/dist/services/index.js +0 -5
  114. package/dist/services/index.js.map +0 -1
  115. package/dist/tsconfig.cjs.tsbuildinfo +0 -1
  116. package/dist/utils/chain.d.ts +0 -14
  117. package/dist/utils/chain.js +0 -29
  118. package/dist/utils/chain.js.map +0 -1
  119. package/dist/utils/index.d.ts +0 -3
  120. package/dist/utils/index.js +0 -4
  121. package/dist/utils/index.js.map +0 -1
  122. package/dist/utils/poolInfo.d.ts +0 -9
  123. package/dist/utils/poolInfo.js +0 -10
  124. package/dist/utils/poolInfo.js.map +0 -1
  125. package/dist/utils/web3.d.ts +0 -4
  126. package/dist/utils/web3.js +0 -24
  127. package/dist/utils/web3.js.map +0 -1
@@ -1,101 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SubgraphService = void 0;
4
- const shared_1 = require("@huma-finance/shared");
5
- /**
6
- * Returns the subgraph URL for a given chain ID.
7
- *
8
- * @memberof SubgraphService
9
- * @param {number} chainId - The ID of the chain.
10
- * @returns {string} The subgraph URL for the given chain ID.
11
- */
12
- function getSubgraphUrlForChainId(chainId) {
13
- switch (chainId) {
14
- case 5:
15
- return 'https://api.thegraph.com/subgraphs/name/00labs/huma-goerli';
16
- case 137:
17
- return 'https://api.thegraph.com/subgraphs/name/00labs/huma-polygon';
18
- case 80001:
19
- return 'https://api.thegraph.com/subgraphs/name/00labs/huma-mumbai';
20
- default:
21
- return '';
22
- }
23
- }
24
- /**
25
- * Returns the credit events for a given user.
26
- *
27
- * @memberof SubgraphService
28
- * @param {string} userAddress - The address of the user.
29
- * @param {number} chainId - The ID of the chain.
30
- * @param {POOL_NAME} poolName - The name of the pool.
31
- * @param {POOL_TYPE} poolType - The type of the pool.
32
- * @param {string[]} event - The event types to filter by.
33
- * @returns {Promise<CreditEventPayload[]>} The credit events for the given user.
34
- */
35
- function getCreditEventsForUser(userAddress, chainId, poolName, poolType, event) {
36
- var _a, _b, _c;
37
- const url = getSubgraphUrlForChainId(chainId);
38
- if (!url) {
39
- return Promise.resolve([]);
40
- }
41
- const poolAddress = (_c = (_b = (_a = shared_1.PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[poolType]) === null || _b === void 0 ? void 0 : _b[poolName]) === null || _c === void 0 ? void 0 : _c.pool;
42
- const query = `
43
- query {
44
- creditEvents(
45
- where: {
46
- owner: "${userAddress}",
47
- pool: "${poolAddress}",
48
- event_in: "[${event.join('", "')}]"
49
- }
50
- orderBy: timestamp
51
- orderDirection: desc
52
- ) {
53
- amount
54
- timestamp
55
- owner
56
- pool
57
- event
58
- }
59
- }
60
- `;
61
- return fetch(url, {
62
- method: 'POST',
63
- headers: {
64
- 'Content-Type': 'application/json',
65
- },
66
- body: JSON.stringify({ query }),
67
- })
68
- .then((res) => res.json())
69
- .then((res) => {
70
- if (res.errors) {
71
- console.error(res.errors);
72
- return [];
73
- }
74
- return res.data.creditEvents;
75
- });
76
- }
77
- /**
78
- * Returns the last factorized amount for a given user and pool.
79
- *
80
- * @memberof SubgraphService
81
- * @param {string} userAddress - The address of the user.
82
- * @param {number} chainId - The ID of the chain.
83
- * @param {POOL_NAME} poolName - The name of the pool.
84
- * @param {POOL_TYPE} poolType - The type of the pool.
85
- * @returns {Promise<number>} The last factorized amount for the given user and pool.
86
- */
87
- function getLastFactorizedAmountFromPool(userAddress, chainId, poolName, poolType) {
88
- return getCreditEventsForUser(userAddress, chainId, poolName, poolType, [
89
- shared_1.CreditEvent.DrawdownMadeWithReceivable.toString(),
90
- ]).then((events) => Number(events[0].amount));
91
- }
92
- /**
93
- * An object that contains functions to interact with Huma's Subgraph storage.
94
- * @namespace SubgraphService
95
- */
96
- exports.SubgraphService = {
97
- getSubgraphUrlForChainId,
98
- getCreditEventsForUser,
99
- getLastFactorizedAmountFromPool,
100
- };
101
- //# sourceMappingURL=SubgraphService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SubgraphService.js","sourceRoot":"","sources":["../../../src/services/SubgraphService.ts"],"names":[],"mappings":";;;AAAA,iDAK6B;AAE7B;;;;;;GAMG;AACH,SAAS,wBAAwB,CAAC,OAAe;IAC/C,QAAQ,OAAO,EAAE;QACf,KAAK,CAAC;YACJ,OAAO,4DAA4D,CAAA;QACrE,KAAK,GAAG;YACN,OAAO,6DAA6D,CAAA;QACtE,KAAK,KAAK;YACR,OAAO,4DAA4D,CAAA;QACrE;YACE,OAAO,EAAE,CAAA;KACZ;AACH,CAAC;AAcD;;;;;;;;;;GAUG;AACH,SAAS,sBAAsB,CAC7B,WAAmB,EACnB,OAAe,EACf,QAAmB,EACnB,QAAmB,EACnB,KAAe;;IAEf,MAAM,GAAG,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAA;IAC7C,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;KAC3B;IAED,MAAM,WAAW,GAAG,MAAA,MAAA,MAAA,wBAAe,CAAC,OAAO,CAAC,0CAAG,QAAQ,CAAC,0CAAG,QAAQ,CAAC,0CAAE,IAAI,CAAA;IAE1E,MAAM,KAAK,GAAG;;;;oBAII,WAAW;mBACZ,WAAW;wBACN,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;;;;;;;;;;;;GAYvC,CAAA;IAED,OAAO,KAAK,CAAC,GAAG,EAAE;QAChB,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC;KAChC,CAAC;SACC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACzB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;QACZ,IAAI,GAAG,CAAC,MAAM,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YACzB,OAAO,EAAE,CAAA;SACV;QACD,OAAO,GAAG,CAAC,IAAI,CAAC,YAAY,CAAA;IAC9B,CAAC,CAAC,CAAA;AACN,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,+BAA+B,CACtC,WAAmB,EACnB,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,OAAO,sBAAsB,CAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE;QACtE,oBAAW,CAAC,0BAA0B,CAAC,QAAQ,EAAE;KAClD,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAC/C,CAAC;AAED;;;GAGG;AACU,QAAA,eAAe,GAAG;IAC7B,wBAAwB;IACxB,sBAAsB;IACtB,+BAA+B;CAChC,CAAA"}
@@ -1,4 +0,0 @@
1
- export * from './ARWeaveService';
2
- export * from './EAService';
3
- export * from './SubgraphService';
4
- export * from './ReceivableService';
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./ARWeaveService"), exports);
5
- tslib_1.__exportStar(require("./EAService"), exports);
6
- tslib_1.__exportStar(require("./SubgraphService"), exports);
7
- tslib_1.__exportStar(require("./ReceivableService"), exports);
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,2DAAgC;AAChC,sDAA2B;AAC3B,4DAAiC;AACjC,8DAAmC"}
@@ -1,14 +0,0 @@
1
- import { JsonRpcProvider, JsonRpcSigner } from '@ethersproject/providers';
2
- import { ethers } from 'ethers';
3
- /**
4
- * Get the chain ID from a signer or provider object.
5
- * @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The signer or provider object to get the chain ID from.
6
- * @returns {number} - The chain ID.
7
- */
8
- export declare function getChainIdFromJsonSignerOrProvider(signerOrProvider: JsonRpcProvider | JsonRpcSigner): number;
9
- /**
10
- * Get the chain ID from a signer or provider object.
11
- * @param {ethers.provider.Provider | ethers.Signer} signerOrProvider - The signer or provider object to get the chain ID from.
12
- * @returns {number} - The chain ID.
13
- */
14
- export declare function getChainIdFromSignerOrProvider(signerOrProvider: ethers.providers.Provider | ethers.Signer): Promise<number | undefined>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getChainIdFromSignerOrProvider = exports.getChainIdFromJsonSignerOrProvider = void 0;
4
- const providers_1 = require("@ethersproject/providers");
5
- const ethers_1 = require("ethers");
6
- /**
7
- * Get the chain ID from a signer or provider object.
8
- * @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The signer or provider object to get the chain ID from.
9
- * @returns {number} - The chain ID.
10
- */
11
- function getChainIdFromJsonSignerOrProvider(signerOrProvider) {
12
- return signerOrProvider instanceof providers_1.JsonRpcProvider
13
- ? signerOrProvider.network.chainId
14
- : signerOrProvider.provider.network.chainId;
15
- }
16
- exports.getChainIdFromJsonSignerOrProvider = getChainIdFromJsonSignerOrProvider;
17
- /**
18
- * Get the chain ID from a signer or provider object.
19
- * @param {ethers.provider.Provider | ethers.Signer} signerOrProvider - The signer or provider object to get the chain ID from.
20
- * @returns {number} - The chain ID.
21
- */
22
- async function getChainIdFromSignerOrProvider(signerOrProvider) {
23
- var _a;
24
- let network;
25
- if (signerOrProvider instanceof ethers_1.ethers.providers.Provider) {
26
- network = await signerOrProvider.getNetwork();
27
- }
28
- else {
29
- network = await ((_a = signerOrProvider === null || signerOrProvider === void 0 ? void 0 : signerOrProvider.provider) === null || _a === void 0 ? void 0 : _a.getNetwork());
30
- }
31
- return network === null || network === void 0 ? void 0 : network.chainId;
32
- }
33
- exports.getChainIdFromSignerOrProvider = getChainIdFromSignerOrProvider;
34
- //# sourceMappingURL=chain.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../src/utils/chain.ts"],"names":[],"mappings":";;;AAAA,wDAAyE;AACzE,mCAA+B;AAE/B;;;;GAIG;AACH,SAAgB,kCAAkC,CAChD,gBAAiD;IAEjD,OAAO,gBAAgB,YAAY,2BAAe;QAChD,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO;QAClC,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAA;AAC/C,CAAC;AAND,gFAMC;AAED;;;;GAIG;AACI,KAAK,UAAU,8BAA8B,CAClD,gBAA2D;;IAE3D,IAAI,OAAO,CAAA;IACX,IAAI,gBAAgB,YAAY,eAAM,CAAC,SAAS,CAAC,QAAQ,EAAE;QACzD,OAAO,GAAG,MAAM,gBAAgB,CAAC,UAAU,EAAE,CAAA;KAC9C;SAAM;QACL,OAAO,GAAG,MAAM,CAAA,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,QAAQ,0CAAE,UAAU,EAAE,CAAA,CAAA;KACzD;IAED,OAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAA;AACzB,CAAC;AAXD,wEAWC"}
@@ -1,3 +0,0 @@
1
- export * from './chain';
2
- export * from './web3';
3
- export * from './poolInfo';
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./chain"), exports);
5
- tslib_1.__exportStar(require("./web3"), exports);
6
- tslib_1.__exportStar(require("./poolInfo"), exports);
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,kDAAuB;AACvB,iDAAsB;AACtB,qDAA0B"}
@@ -1,9 +0,0 @@
1
- import { POOL_NAME, POOL_TYPE, PoolInfoType } from '@huma-finance/shared';
2
- /**
3
- * Returns the pool info based on the provided pool name and type, using the same chain ID as the provider/signer given
4
- * @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The Web3 provider or signer.
5
- * @param {POOL_NAME} poolName - The name of the pool.
6
- * @param {POOL_TYPE} poolType - The type of the pool.
7
- * @returns {PoolInfoType|undefined} - The pool info or undefined if the chain ID is not supported.
8
- */
9
- export declare const getPoolInfo: (chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE) => PoolInfoType | undefined;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPoolInfo = void 0;
4
- const shared_1 = require("@huma-finance/shared");
5
- /**
6
- * Returns the pool info based on the provided pool name and type, using the same chain ID as the provider/signer given
7
- * @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The Web3 provider or signer.
8
- * @param {POOL_NAME} poolName - The name of the pool.
9
- * @param {POOL_TYPE} poolType - The type of the pool.
10
- * @returns {PoolInfoType|undefined} - The pool info or undefined if the chain ID is not supported.
11
- */
12
- const getPoolInfo = (chainId, poolName, poolType) => { var _a, _b; return (_b = (_a = shared_1.PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[poolType]) === null || _b === void 0 ? void 0 : _b[poolName]; };
13
- exports.getPoolInfo = getPoolInfo;
14
- //# sourceMappingURL=poolInfo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"poolInfo.js","sourceRoot":"","sources":["../../../src/utils/poolInfo.ts"],"names":[],"mappings":";;;AAAA,iDAK6B;AAE7B;;;;;;GAMG;AACI,MAAM,WAAW,GAAG,CACzB,OAAe,EACf,QAAmB,EACnB,QAAmB,EACO,EAAE,eAAC,OAAA,MAAA,MAAA,wBAAe,CAAC,OAAO,CAAC,0CAAG,QAAQ,CAAC,0CAAG,QAAQ,CAAC,CAAA,EAAA,CAAA;AAJlE,QAAA,WAAW,eAIuD"}
@@ -1,4 +0,0 @@
1
- import { Contract } from '@ethersproject/contracts';
2
- import { ethers } from 'ethers';
3
- export declare function isAddress(value: any): string | false;
4
- export declare function getContract(address: string, ABI: any, signerOrProvider: ethers.providers.Provider | ethers.Signer): Contract;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getContract = exports.isAddress = void 0;
4
- const contracts_1 = require("@ethersproject/contracts");
5
- const constants_1 = require("@ethersproject/constants");
6
- const address_1 = require("@ethersproject/address");
7
- // returns the checksummed address if the address is valid, otherwise returns false
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- function isAddress(value) {
10
- try {
11
- // Alphabetical letters must be made lowercase for getAddress to work.
12
- // See documentation here: https://docs.ethers.io/v5/api/utils/address/
13
- return (0, address_1.getAddress)(value.toLowerCase());
14
- }
15
- catch (_a) {
16
- return false;
17
- }
18
- }
19
- exports.isAddress = isAddress;
20
- function getContract(address,
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- ABI, signerOrProvider) {
23
- if (!isAddress(address) || address === constants_1.AddressZero) {
24
- throw Error(`Invalid 'address' parameter '${address}'.`);
25
- }
26
- return new contracts_1.Contract(address, ABI, signerOrProvider);
27
- }
28
- exports.getContract = getContract;
29
- //# sourceMappingURL=web3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web3.js","sourceRoot":"","sources":["../../../src/utils/web3.ts"],"names":[],"mappings":";;;AAAA,wDAAmD;AACnD,wDAAsD;AACtD,oDAAmD;AAGnD,mFAAmF;AACnF,8DAA8D;AAC9D,SAAgB,SAAS,CAAC,KAAU;IAClC,IAAI;QACF,sEAAsE;QACtE,uEAAuE;QACvE,OAAO,IAAA,oBAAU,EAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAA;KACvC;IAAC,WAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AARD,8BAQC;AAED,SAAgB,WAAW,CACzB,OAAe;AACf,8DAA8D;AAC9D,GAAQ,EACR,gBAA2D;IAE3D,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,OAAO,KAAK,uBAAW,EAAE;QAClD,MAAM,KAAK,CAAC,gCAAgC,OAAO,IAAI,CAAC,CAAA;KACzD;IAED,OAAO,IAAI,oBAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAA;AACrD,CAAC;AAXD,kCAWC"}
@@ -1,10 +0,0 @@
1
- import { Contract, ethers } from 'ethers';
2
- /**
3
- * Returns an ethers contract instance for the BaseCreditPoolReceivable contract
4
- * associated with the given pool name on the current chain.
5
- *
6
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
7
- * @param {number} chainId The chain id where the contract instance exists
8
- * @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
9
- */
10
- export declare function getBaseCreditPoolReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
@@ -1,18 +0,0 @@
1
- import { BASE_CREDIT_POOL_RECEIVABLE_ABI, SupplementaryContracts, SupplementaryContractsMap, } from '@huma-finance/shared';
2
- import { getContract } from '../utils';
3
- /**
4
- * Returns an ethers contract instance for the BaseCreditPoolReceivable contract
5
- * associated with the given pool name on the current chain.
6
- *
7
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
8
- * @param {number} chainId The chain id where the contract instance exists
9
- * @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
10
- */
11
- export function getBaseCreditPoolReceivableContract(signerOrProvider, chainId) {
12
- var _a;
13
- const baseCreditPoolReceivable = (_a = SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[SupplementaryContracts.BaseCreditPoolReceivable];
14
- if (!baseCreditPoolReceivable)
15
- return null;
16
- return getContract(baseCreditPoolReceivable, BASE_CREDIT_POOL_RECEIVABLE_ABI, signerOrProvider);
17
- }
18
- //# sourceMappingURL=BaseCreditPoolReceivableContractHelper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseCreditPoolReceivableContractHelper.js","sourceRoot":"","sources":["../../src/helpers/BaseCreditPoolReceivableContractHelper.ts"],"names":[],"mappings":"AACA,OAAO,EACL,+BAA+B,EAC/B,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEtC;;;;;;;GAOG;AACH,MAAM,UAAU,mCAAmC,CACjD,gBAA2D,EAC3D,OAAe;;IAEf,MAAM,wBAAwB,GAC5B,MAAA,yBAAyB,CAAC,OAAO,CAAC,0CAChC,sBAAsB,CAAC,wBAAwB,CAChD,CAAA;IAEH,IAAI,CAAC,wBAAwB;QAAE,OAAO,IAAI,CAAA;IAE1C,OAAO,WAAW,CAChB,wBAAwB,EACxB,+BAA+B,EAC/B,gBAAgB,CACjB,CAAA;AACH,CAAC"}
@@ -1,10 +0,0 @@
1
- import { Contract, ethers } from 'ethers';
2
- /**
3
- * Returns an ethers contract instance for the BaseCreditPoolReceivable contract
4
- * associated with the given pool name on the current chain.
5
- *
6
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
7
- * @param {number} chainId The chain id where the contract instance exists
8
- * @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
9
- */
10
- export declare function getERC20TransferableReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
@@ -1,18 +0,0 @@
1
- import { ERC20_TRANSFERABLE_RECEIVABLE_ABI, SupplementaryContracts, SupplementaryContractsMap, } from '@huma-finance/shared';
2
- import { getContract } from '../utils';
3
- /**
4
- * Returns an ethers contract instance for the BaseCreditPoolReceivable contract
5
- * associated with the given pool name on the current chain.
6
- *
7
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
8
- * @param {number} chainId The chain id where the contract instance exists
9
- * @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
10
- */
11
- export function getERC20TransferableReceivableContract(signerOrProvider, chainId) {
12
- var _a;
13
- const erc20TransferableReceiable = (_a = SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[SupplementaryContracts.ERC20TransferableReceivable];
14
- if (!erc20TransferableReceiable)
15
- return null;
16
- return getContract(erc20TransferableReceiable, ERC20_TRANSFERABLE_RECEIVABLE_ABI, signerOrProvider);
17
- }
18
- //# sourceMappingURL=ERC20TransferableReceivableContractHelper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ERC20TransferableReceivableContractHelper.js","sourceRoot":"","sources":["../../src/helpers/ERC20TransferableReceivableContractHelper.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iCAAiC,EACjC,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEtC;;;;;;;GAOG;AACH,MAAM,UAAU,sCAAsC,CACpD,gBAA2D,EAC3D,OAAe;;IAEf,MAAM,0BAA0B,GAC9B,MAAA,yBAAyB,CAAC,OAAO,CAAC,0CAChC,sBAAsB,CAAC,2BAA2B,CACnD,CAAA;IAEH,IAAI,CAAC,0BAA0B;QAAE,OAAO,IAAI,CAAA;IAE5C,OAAO,WAAW,CAChB,0BAA0B,EAC1B,iCAAiC,EACjC,gBAAgB,CACjB,CAAA;AACH,CAAC"}
@@ -1,12 +0,0 @@
1
- import { Contract, ethers } from 'ethers';
2
- import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
3
- /**
4
- * Returns an ethers contract instance for a Huma pool contract
5
- *
6
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
7
- * @param {number} chainId The chain id where the contract instance exists
8
- * @param {POOL_NAME} poolName The name of the pool contract to get.
9
- * @param {POOL_TYPE} poolType The type of the pool contract to get.
10
- * @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
11
- */
12
- export declare function getPoolContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): Contract | null;
@@ -1,17 +0,0 @@
1
- import { getContract, getPoolInfo } from '../utils';
2
- /**
3
- * Returns an ethers contract instance for a Huma pool contract
4
- *
5
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
6
- * @param {number} chainId The chain id where the contract instance exists
7
- * @param {POOL_NAME} poolName The name of the pool contract to get.
8
- * @param {POOL_TYPE} poolType The type of the pool contract to get.
9
- * @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
10
- */
11
- export function getPoolContract(signerOrProvider, chainId, poolName, poolType) {
12
- const poolInfo = getPoolInfo(chainId, poolName, poolType);
13
- if (!poolInfo)
14
- return null;
15
- return getContract(poolInfo.pool, poolInfo.poolAbi, signerOrProvider);
16
- }
17
- //# sourceMappingURL=PoolContractHelper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEnD;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,gBAA2D,EAC3D,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAEzD,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAA;IAE1B,OAAO,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;AACvE,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from './BaseCreditPoolReceivableContractHelper';
2
- export * from './ERC20TransferableReceivableContractHelper';
3
- export * from './PoolContractHelper';
@@ -1,4 +0,0 @@
1
- export * from './BaseCreditPoolReceivableContractHelper';
2
- export * from './ERC20TransferableReceivableContractHelper';
3
- export * from './PoolContractHelper';
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,0CAA0C,CAAA;AACxD,cAAc,6CAA6C,CAAA;AAC3D,cAAc,sBAAsB,CAAA"}
@@ -1,4 +0,0 @@
1
- export * from './useContract';
2
- export * from './useBaseCreditPoolReceivableContract';
3
- export * from './useERC20TransferableReceivableContract';
4
- export * from './usePoolContract';
@@ -1,5 +0,0 @@
1
- export * from './useContract';
2
- export * from './useBaseCreditPoolReceivableContract';
3
- export * from './useERC20TransferableReceivableContract';
4
- export * from './usePoolContract';
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,uCAAuC,CAAA;AACrD,cAAc,0CAA0C,CAAA;AACxD,cAAc,mBAAmB,CAAA"}
@@ -1,10 +0,0 @@
1
- import { Contract, ethers } from 'ethers';
2
- /**
3
- * A react hook that returns an ethers contract instance for the BaseCreditPoolReceivable contract
4
- * associated with the given pool name on the current chain.
5
- *
6
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
7
- * @param {number} chainId The chain id where the contract instance exists
8
- * @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
9
- */
10
- export declare function useBaseCreditPoolReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
@@ -1,16 +0,0 @@
1
- import { BASE_CREDIT_POOL_RECEIVABLE_ABI, SupplementaryContracts, SupplementaryContractsMap, } from '@huma-finance/shared';
2
- import { useContract } from './useContract';
3
- /**
4
- * A react hook that returns an ethers contract instance for the BaseCreditPoolReceivable contract
5
- * associated with the given pool name on the current chain.
6
- *
7
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
8
- * @param {number} chainId The chain id where the contract instance exists
9
- * @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
10
- */
11
- export function useBaseCreditPoolReceivableContract(signerOrProvider, chainId) {
12
- var _a;
13
- const baseCreditPoolReceivable = (_a = SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[SupplementaryContracts.BaseCreditPoolReceivable];
14
- return useContract(baseCreditPoolReceivable, BASE_CREDIT_POOL_RECEIVABLE_ABI, signerOrProvider);
15
- }
16
- //# sourceMappingURL=useBaseCreditPoolReceivableContract.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useBaseCreditPoolReceivableContract.js","sourceRoot":"","sources":["../../src/hooks/useBaseCreditPoolReceivableContract.ts"],"names":[],"mappings":"AACA,OAAO,EACL,+BAA+B,EAE/B,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;;;GAOG;AACH,MAAM,UAAU,mCAAmC,CACjD,gBAA2D,EAC3D,OAAe;;IAEf,MAAM,wBAAwB,GAC5B,MAAA,yBAAyB,CAAC,OAAO,CAAC,0CAChC,sBAAsB,CAAC,wBAAwB,CAChD,CAAA;IAEH,OAAO,WAAW,CAChB,wBAAwB,EACxB,+BAA+B,EAC/B,gBAAgB,CACjB,CAAA;AACH,CAAC"}
@@ -1,13 +0,0 @@
1
- import { Contract } from '@ethersproject/contracts';
2
- import { ethers } from 'ethers';
3
- /**
4
- * Custom hook for creating an ethers instance of a smart contract.
5
- *
6
- * @template T - The type of the contract.
7
- * @param {string | null | undefined} address - The address of the smart contract instance.
8
- * @param {any} ABI - The ABI of the smart contract.
9
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to sign transactions or retrieve blockchain data.
10
- * Note that this signerOrProvider must be connected to the same network as the smart contract in question.
11
- * @returns {T | null} An instance of the smart contract, or null if an error occurs.
12
- */
13
- export declare function useContract<T extends Contract = Contract>(address: string | null | undefined, ABI: any, signerOrProvider: ethers.providers.Provider | ethers.Signer): T | null;
@@ -1,27 +0,0 @@
1
- import { useMemo } from 'react';
2
- import { getContract } from '../utils/web3';
3
- /**
4
- * Custom hook for creating an ethers instance of a smart contract.
5
- *
6
- * @template T - The type of the contract.
7
- * @param {string | null | undefined} address - The address of the smart contract instance.
8
- * @param {any} ABI - The ABI of the smart contract.
9
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to sign transactions or retrieve blockchain data.
10
- * Note that this signerOrProvider must be connected to the same network as the smart contract in question.
11
- * @returns {T | null} An instance of the smart contract, or null if an error occurs.
12
- */
13
- export function useContract(address,
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- ABI, signerOrProvider) {
16
- return useMemo(() => {
17
- if (!address || !ABI || !signerOrProvider)
18
- return null;
19
- try {
20
- return getContract(address, ABI, signerOrProvider);
21
- }
22
- catch (error) {
23
- return null;
24
- }
25
- }, [address, ABI, signerOrProvider]);
26
- }
27
- //# sourceMappingURL=useContract.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useContract.js","sourceRoot":"","sources":["../../src/hooks/useContract.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAG/B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CACzB,OAAkC;AAClC,8DAA8D;AAC9D,GAAQ,EACR,gBAA2D;IAE3D,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,IAAI,CAAC,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,gBAAgB;YAAE,OAAO,IAAI,CAAA;QACtD,IAAI;YACF,OAAO,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAA;SACnD;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,IAAI,CAAA;SACZ;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAM,CAAA;AAC3C,CAAC"}
@@ -1,12 +0,0 @@
1
- import { Contract, ethers } from 'ethers';
2
- import { POOL_NAME } from '@huma-finance/shared';
3
- /**
4
- * A react hook that returns an ethers contract instance for the ERC20TransferableReceivable contract
5
- * associated with the given pool name on the current chain.
6
- *
7
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
8
- * @param {number} chainId The chain id where the contract instance exists
9
- * @param {POOL_NAME} poolName The name of the pool to get the contract for.
10
- * @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
11
- */
12
- export declare function useERC20TransferableReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME): Contract | null;
@@ -1,17 +0,0 @@
1
- import { ERC20_TRANSFERABLE_RECEIVABLE_ABI, POOL_TYPE, PoolContractMap, } from '@huma-finance/shared';
2
- import { useContract } from './useContract';
3
- /**
4
- * A react hook that returns an ethers contract instance for the ERC20TransferableReceivable contract
5
- * associated with the given pool name on the current chain.
6
- *
7
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
8
- * @param {number} chainId The chain id where the contract instance exists
9
- * @param {POOL_NAME} poolName The name of the pool to get the contract for.
10
- * @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
11
- */
12
- export function useERC20TransferableReceivableContract(signerOrProvider, chainId, poolName) {
13
- var _a, _b, _c;
14
- const TransferableReceivableAddress = (_c = (_b = (_a = PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[POOL_TYPE.Invoice]) === null || _b === void 0 ? void 0 : _b[poolName]) === null || _c === void 0 ? void 0 : _c.assetAddress;
15
- return useContract(TransferableReceivableAddress, ERC20_TRANSFERABLE_RECEIVABLE_ABI, signerOrProvider);
16
- }
17
- //# sourceMappingURL=useERC20TransferableReceivableContract.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useERC20TransferableReceivableContract.js","sourceRoot":"","sources":["../../src/hooks/useERC20TransferableReceivableContract.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iCAAiC,EAGjC,SAAS,EACT,eAAe,GAChB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;;;;GAQG;AACH,MAAM,UAAU,sCAAsC,CACpD,gBAA2D,EAC3D,OAAe,EACf,QAAmB;;IAEnB,MAAM,6BAA6B,GACjC,MAAA,MAAA,MAAA,eAAe,CAAC,OAAO,CAAC,0CAAG,SAAS,CAAC,OAAO,CAAC,0CAAG,QAAQ,CAAC,0CAAE,YAAY,CAAA;IAEzE,OAAO,WAAW,CAChB,6BAA6B,EAC7B,iCAAiC,EACjC,gBAAgB,CACjB,CAAA;AACH,CAAC"}
File without changes
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=usePool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePool.js","sourceRoot":"","sources":["../../src/hooks/usePool.ts"],"names":[],"mappings":""}
@@ -1,60 +0,0 @@
1
- import { BigNumber } from '@ethersproject/bignumber';
2
- import { Contract, ethers } from 'ethers';
3
- import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
4
- /**
5
- * A react hook that returns a contract instance of a specific pool using an ethers provider or signer
6
- *
7
- * @namespace usePoolContract
8
- * @template T - The type of the contract.
9
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - An ethers signer or provider instance.
10
- * @param {number} chainId The chain id where the contract instance exists
11
- * @param {POOL_NAME} poolName - The name of the pool.
12
- * @param {POOL_TYPE} poolType - The type of the pool.
13
- * @returns {T} A contract instance of the specific pool.
14
- */
15
- export declare function usePoolContract<T extends Contract>(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): T | null;
16
- /**
17
- * CreditRecordDetails type object representing the details of a credit line.
18
- *
19
- * @memberof usePoolContract
20
- * @typedef {Object} CreditRecordDetails
21
- * @property {number} aprInBps - The APR (annual percentage rate) in basis points.
22
- * @property {BigNumber} correction - adjustment of interest over or under-counted because of drawdown
23
- * or principal payment in the middle of a billing period
24
- * @property {BigNumber} creditLimit - The credit limit in the pools base currency.
25
- * @property {BigNumber} defaultAmount - The amount of the default, if any.
26
- * @property {BigNumber} dueDate - The due date of the next payment.
27
- * @property {BigNumber} feesAndInterestDue - The fees and interest due.
28
- * @property {number} intervalInDays - The interval in days between payment periods.
29
- * @property {number} missedPeriods - The number of missed periods.
30
- * @property {number} remainingPeriods - The number of remaining periods before this credit line is considered paid off.
31
- * @property {number} state - The state of the factorization. Please see the CreditState in huma-contracts for more details.
32
- * @property {BigNumber} totalDue - The total due amount of this credit line.
33
- * @property {BigNumber} unbilledPrincipal - The unbilled principal of the next payment.
34
- */
35
- export type CreditRecordDetails = {
36
- aprInBps: number;
37
- correction: BigNumber;
38
- creditLimit: BigNumber;
39
- defaultAmount: BigNumber;
40
- dueDate: BigNumber;
41
- feesAndInterestDue: BigNumber;
42
- intervalInDays: number;
43
- missedPeriods: number;
44
- remainingPeriods: number;
45
- state: number;
46
- totalDue: BigNumber;
47
- unbilledPrincipal: BigNumber;
48
- };
49
- /**
50
- * A react hook that returns the credit record details for a user in a given pool, as well as a function to refresh the data.
51
- *
52
- * @namespace usePoolContract
53
- * @param {string} userAddress - The address of the user to get the credit record details for.
54
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider object to use for the contract.
55
- * @param {number} chainId The chain id where the contract instance exists
56
- * @param {POOL_NAME} poolName - The name of the pool to get the credit record details for.
57
- * @param {POOL_TYPE} poolType - The type of the pool.
58
- * @returns {Array<CreditRecordDetails | undefined, function():void>} An array containing the credit record details and a function to refresh the data.
59
- */
60
- export declare function useCreditRecordDetails(userAddress: string, signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): [CreditRecordDetails | undefined, () => void];