@huma-finance/sdk 0.0.34 → 0.0.36

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 (119) hide show
  1. package/API.md +822 -1037
  2. package/LICENSE +660 -660
  3. package/README.md +37 -35
  4. package/dist/cjs/graphql/generatedTypes.d.ts +40 -40
  5. package/dist/cjs/graphql/generatedTypes.js +8 -8
  6. package/dist/cjs/graphql/index.d.ts +1 -1
  7. package/dist/cjs/graphql/index.js +4 -4
  8. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -10
  9. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js +21 -21
  10. package/dist/cjs/helpers/PoolContractHelper.d.ts +119 -119
  11. package/dist/cjs/helpers/PoolContractHelper.js +143 -142
  12. package/dist/cjs/helpers/PoolContractHelper.js.map +1 -1
  13. package/dist/cjs/helpers/RealWorldReceivableContractHelper.d.ts +10 -10
  14. package/dist/cjs/helpers/RealWorldReceivableContractHelper.js +21 -21
  15. package/dist/cjs/helpers/index.d.ts +3 -3
  16. package/dist/cjs/helpers/index.js +6 -6
  17. package/dist/cjs/hooks/index.d.ts +4 -4
  18. package/dist/cjs/hooks/index.js +7 -7
  19. package/dist/cjs/hooks/useContract.d.ts +13 -13
  20. package/dist/cjs/hooks/useContract.js +30 -30
  21. package/dist/cjs/hooks/useERC20TransferableReceivableContract.d.ts +12 -12
  22. package/dist/cjs/hooks/useERC20TransferableReceivableContract.js +20 -20
  23. package/dist/cjs/hooks/usePoolContract.d.ts +60 -60
  24. package/dist/cjs/hooks/usePoolContract.js +53 -53
  25. package/dist/cjs/hooks/useRealWorldReceivableContract.d.ts +10 -10
  26. package/dist/cjs/hooks/useRealWorldReceivableContract.js +19 -19
  27. package/dist/cjs/index.d.ts +4 -4
  28. package/dist/cjs/index.js +7 -7
  29. package/dist/cjs/services/ARWeaveService.d.ts +106 -106
  30. package/dist/cjs/services/ARWeaveService.js +190 -190
  31. package/dist/cjs/services/EAService.d.ts +20 -20
  32. package/dist/cjs/services/EAService.js +33 -33
  33. package/dist/cjs/services/ReceivableService.d.ts +104 -104
  34. package/dist/cjs/services/ReceivableService.js +308 -309
  35. package/dist/cjs/services/ReceivableService.js.map +1 -1
  36. package/dist/cjs/services/SubgraphService.d.ts +53 -53
  37. package/dist/cjs/services/SubgraphService.js +93 -93
  38. package/dist/cjs/services/index.d.ts +4 -4
  39. package/dist/cjs/services/index.js +7 -7
  40. package/dist/cjs/utils/chain.d.ts +15 -15
  41. package/dist/cjs/utils/chain.js +37 -37
  42. package/dist/cjs/utils/index.d.ts +4 -4
  43. package/dist/cjs/utils/index.js +7 -7
  44. package/dist/cjs/utils/maticGasStation.d.ts +3 -3
  45. package/dist/cjs/utils/maticGasStation.js +38 -38
  46. package/dist/cjs/utils/poolInfo.d.ts +8 -8
  47. package/dist/cjs/utils/poolInfo.js +12 -12
  48. package/dist/cjs/utils/web3.d.ts +5 -5
  49. package/dist/cjs/utils/web3.js +33 -33
  50. package/dist/graphql/generatedTypes.d.ts +40 -40
  51. package/dist/graphql/generatedTypes.js +4 -4
  52. package/dist/graphql/index.d.ts +1 -1
  53. package/dist/graphql/index.js +1 -1
  54. package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -10
  55. package/dist/helpers/ERC20TransferableReceivableContractHelper.js +17 -17
  56. package/dist/helpers/PoolContractHelper.d.ts +119 -119
  57. package/dist/helpers/PoolContractHelper.js +134 -133
  58. package/dist/helpers/PoolContractHelper.js.map +1 -1
  59. package/dist/helpers/RealWorldReceivableContractHelper.d.ts +10 -10
  60. package/dist/helpers/RealWorldReceivableContractHelper.js +17 -17
  61. package/dist/helpers/index.d.ts +3 -3
  62. package/dist/helpers/index.js +3 -3
  63. package/dist/hooks/index.d.ts +4 -4
  64. package/dist/hooks/index.js +4 -4
  65. package/dist/hooks/useContract.d.ts +13 -13
  66. package/dist/hooks/useContract.js +26 -26
  67. package/dist/hooks/useERC20TransferableReceivableContract.d.ts +12 -12
  68. package/dist/hooks/useERC20TransferableReceivableContract.js +16 -16
  69. package/dist/hooks/usePoolContract.d.ts +60 -60
  70. package/dist/hooks/usePoolContract.js +48 -48
  71. package/dist/hooks/useRealWorldReceivableContract.d.ts +10 -10
  72. package/dist/hooks/useRealWorldReceivableContract.js +15 -15
  73. package/dist/index.d.ts +4 -4
  74. package/dist/index.js +4 -4
  75. package/dist/services/ARWeaveService.d.ts +106 -106
  76. package/dist/services/ARWeaveService.js +185 -185
  77. package/dist/services/EAService.d.ts +20 -20
  78. package/dist/services/EAService.js +30 -30
  79. package/dist/services/ReceivableService.d.ts +104 -104
  80. package/dist/services/ReceivableService.js +305 -305
  81. package/dist/services/ReceivableService.js.map +1 -1
  82. package/dist/services/SubgraphService.d.ts +53 -53
  83. package/dist/services/SubgraphService.js +90 -90
  84. package/dist/services/index.d.ts +4 -4
  85. package/dist/services/index.js +4 -4
  86. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  87. package/dist/utils/chain.d.ts +15 -15
  88. package/dist/utils/chain.js +31 -31
  89. package/dist/utils/index.d.ts +4 -4
  90. package/dist/utils/index.js +4 -4
  91. package/dist/utils/maticGasStation.d.ts +3 -3
  92. package/dist/utils/maticGasStation.js +33 -33
  93. package/dist/utils/poolInfo.d.ts +8 -8
  94. package/dist/utils/poolInfo.js +8 -8
  95. package/dist/utils/web3.d.ts +5 -5
  96. package/dist/utils/web3.js +27 -27
  97. package/getting-started.md +190 -190
  98. package/package.json +23 -6
  99. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.d.ts +0 -10
  100. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js +0 -22
  101. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js.map +0 -1
  102. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.d.ts +0 -10
  103. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js +0 -20
  104. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js.map +0 -1
  105. package/dist/cjs/hooks/useReceivableFactoringPoolContract.d.ts +0 -10
  106. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js +0 -17
  107. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js.map +0 -1
  108. package/dist/helpers/BaseCreditPoolReceivableContractHelper.d.ts +0 -10
  109. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js +0 -18
  110. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js.map +0 -1
  111. package/dist/hooks/useBaseCreditPoolReceivableContract.d.ts +0 -10
  112. package/dist/hooks/useBaseCreditPoolReceivableContract.js +0 -16
  113. package/dist/hooks/useBaseCreditPoolReceivableContract.js.map +0 -1
  114. package/dist/hooks/usePool.d.ts +0 -0
  115. package/dist/hooks/usePool.js +0 -2
  116. package/dist/hooks/usePool.js.map +0 -1
  117. package/dist/hooks/useReceivableFactoringPoolContract.d.ts +0 -10
  118. package/dist/hooks/useReceivableFactoringPoolContract.js +0 -13
  119. package/dist/hooks/useReceivableFactoringPoolContract.js.map +0 -1
@@ -1,34 +1,34 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getERC20Contract = 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
- const shared_1 = require("@huma-finance/shared");
8
- // returns the checksummed address if the address is valid, otherwise returns false
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- function isAddress(value) {
11
- try {
12
- // Alphabetical letters must be made lowercase for getAddress to work.
13
- // See documentation here: https://docs.ethers.io/v5/api/utils/address/
14
- return (0, address_1.getAddress)(value.toLowerCase());
15
- }
16
- catch (_a) {
17
- return false;
18
- }
19
- }
20
- exports.isAddress = isAddress;
21
- function getContract(address,
22
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
- ABI, signerOrProvider) {
24
- if (!isAddress(address) || address === constants_1.AddressZero) {
25
- throw Error(`Invalid 'address' parameter '${address}'.`);
26
- }
27
- return new contracts_1.Contract(address, ABI, signerOrProvider);
28
- }
29
- exports.getContract = getContract;
30
- function getERC20Contract(address, signerOrProvider) {
31
- return getContract(address, shared_1.ERC20_ABI, signerOrProvider);
32
- }
33
- exports.getERC20Contract = getERC20Contract;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getERC20Contract = 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
+ const shared_1 = require("@huma-finance/shared");
8
+ // returns the checksummed address if the address is valid, otherwise returns false
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ function isAddress(value) {
11
+ try {
12
+ // Alphabetical letters must be made lowercase for getAddress to work.
13
+ // See documentation here: https://docs.ethers.io/v5/api/utils/address/
14
+ return (0, address_1.getAddress)(value.toLowerCase());
15
+ }
16
+ catch (_a) {
17
+ return false;
18
+ }
19
+ }
20
+ exports.isAddress = isAddress;
21
+ function getContract(address,
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
+ ABI, signerOrProvider) {
24
+ if (!isAddress(address) || address === constants_1.AddressZero) {
25
+ throw Error(`Invalid 'address' parameter '${address}'.`);
26
+ }
27
+ return new contracts_1.Contract(address, ABI, signerOrProvider);
28
+ }
29
+ exports.getContract = getContract;
30
+ function getERC20Contract(address, signerOrProvider) {
31
+ return getContract(address, shared_1.ERC20_ABI, signerOrProvider);
32
+ }
33
+ exports.getERC20Contract = getERC20Contract;
34
34
  //# sourceMappingURL=web3.js.map
@@ -1,40 +1,40 @@
1
- import { GraphQLClient } from 'graphql-request';
2
- export type Maybe<T> = T | null;
3
- export type InputMaybe<T> = Maybe<T>;
4
- export type Exact<T extends {
5
- [key: string]: unknown;
6
- }> = {
7
- [K in keyof T]: T[K];
8
- };
9
- export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
10
- [SubKey in K]?: Maybe<T[SubKey]>;
11
- };
12
- export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
13
- [SubKey in K]: Maybe<T[SubKey]>;
14
- };
15
- /** All built-in and custom scalars, mapped to their actual values */
16
- export type Scalars = {
17
- ID: string;
18
- String: string;
19
- Boolean: boolean;
20
- Int: number;
21
- Float: number;
22
- };
23
- export type Receivable = {
24
- __typename?: 'Receivable';
25
- creationDate?: Maybe<Scalars['String']>;
26
- currencyCode?: Maybe<Scalars['String']>;
27
- id?: Maybe<Scalars['String']>;
28
- lastUpdate?: Maybe<Scalars['String']>;
29
- maturityDate?: Maybe<Scalars['String']>;
30
- owner?: Maybe<Scalars['String']>;
31
- paidAmount?: Maybe<Scalars['String']>;
32
- pool?: Maybe<Scalars['String']>;
33
- receivableAmount?: Maybe<Scalars['String']>;
34
- status?: Maybe<Scalars['String']>;
35
- tokenId?: Maybe<Scalars['String']>;
36
- uri?: Maybe<Scalars['String']>;
37
- };
38
- export type SdkFunctionWrapper = <T>(action: (requestHeaders?: Record<string, string>) => Promise<T>, operationName: string, operationType?: string) => Promise<T>;
39
- export declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionWrapper): {};
40
- export type Sdk = ReturnType<typeof getSdk>;
1
+ import { GraphQLClient } from 'graphql-request';
2
+ export type Maybe<T> = T | null;
3
+ export type InputMaybe<T> = Maybe<T>;
4
+ export type Exact<T extends {
5
+ [key: string]: unknown;
6
+ }> = {
7
+ [K in keyof T]: T[K];
8
+ };
9
+ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
10
+ [SubKey in K]?: Maybe<T[SubKey]>;
11
+ };
12
+ export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
13
+ [SubKey in K]: Maybe<T[SubKey]>;
14
+ };
15
+ /** All built-in and custom scalars, mapped to their actual values */
16
+ export type Scalars = {
17
+ ID: string;
18
+ String: string;
19
+ Boolean: boolean;
20
+ Int: number;
21
+ Float: number;
22
+ };
23
+ export type Receivable = {
24
+ __typename?: 'Receivable';
25
+ creationDate?: Maybe<Scalars['String']>;
26
+ currencyCode?: Maybe<Scalars['String']>;
27
+ id?: Maybe<Scalars['String']>;
28
+ lastUpdate?: Maybe<Scalars['String']>;
29
+ maturityDate?: Maybe<Scalars['String']>;
30
+ owner?: Maybe<Scalars['String']>;
31
+ paidAmount?: Maybe<Scalars['String']>;
32
+ pool?: Maybe<Scalars['String']>;
33
+ receivableAmount?: Maybe<Scalars['String']>;
34
+ status?: Maybe<Scalars['String']>;
35
+ tokenId?: Maybe<Scalars['String']>;
36
+ uri?: Maybe<Scalars['String']>;
37
+ };
38
+ export type SdkFunctionWrapper = <T>(action: (requestHeaders?: Record<string, string>) => Promise<T>, operationName: string, operationType?: string) => Promise<T>;
39
+ export declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionWrapper): {};
40
+ export type Sdk = ReturnType<typeof getSdk>;
@@ -1,5 +1,5 @@
1
- const defaultWrapper = (action, _operationName, _operationType) => action();
2
- export function getSdk(client, withWrapper = defaultWrapper) {
3
- return {};
4
- }
1
+ const defaultWrapper = (action, _operationName, _operationType) => action();
2
+ export function getSdk(client, withWrapper = defaultWrapper) {
3
+ return {};
4
+ }
5
5
  //# sourceMappingURL=generatedTypes.js.map
@@ -1 +1 @@
1
- export * from './generatedTypes';
1
+ export * from './generatedTypes';
@@ -1,2 +1,2 @@
1
- export * from './generatedTypes';
1
+ export * from './generatedTypes';
2
2
  //# sourceMappingURL=index.js.map
@@ -1,10 +1,10 @@
1
- import { Contract, ethers } from 'ethers';
2
- /**
3
- * Returns an ethers contract instance for the ERC20TransferableReceivable 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 ERC20TransferableReceivable 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
+ import { Contract, ethers } from 'ethers';
2
+ /**
3
+ * Returns an ethers contract instance for the ERC20TransferableReceivable 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 ERC20TransferableReceivable 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 +1,18 @@
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 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
- * @returns {Contract | null} A contract instance for the ERC20TransferableReceivable 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
- }
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 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
+ * @returns {Contract | null} A contract instance for the ERC20TransferableReceivable 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
18
  //# sourceMappingURL=ERC20TransferableReceivableContractHelper.js.map
@@ -1,119 +1,119 @@
1
- import { BigNumber } from '@ethersproject/bignumber';
2
- import { BigNumberish, Contract, Overrides, ethers } from 'ethers';
3
- import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
4
- import { TransactionResponse } from '@ethersproject/providers';
5
- /**
6
- * Returns an ethers contract instance for a Huma pool contract
7
- *
8
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
9
- * @param {number} chainId The chain id where the contract instance exists
10
- * @param {POOL_NAME} poolName The name of the pool contract to get.
11
- * @param {POOL_TYPE} poolType The type of the pool contract to get.
12
- * @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
13
- */
14
- export declare function getPoolContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): Contract | null;
15
- /**
16
- * Return type of getCreditRecord
17
- *
18
- * @memberof getCreditRecord
19
- * @typedef {Object} CreditRecord
20
- * @property {BigNumber} unbilledPrincipal - The amount of principal not included in the bill
21
- * @property {BigNumber} dueDate - Unix timestamp due date of the next payment
22
- * @property {BigNumber} correction - the adjustment of interest over or under-counted because of drawdown
23
- * or principal payment in the middle of a billing period
24
- * @property {BigNumber} totalDue - The due amount of the next payment
25
- * @property {BigNumber} feesAndInterestDue - Interest and fees due for the next payment
26
- * @property {number} missedPeriods - # of consecutive missed payments, for default processing
27
- * @property {number} remainingPeriods - # of payment periods until the maturity of the credit line
28
- * @property {number} state - status of the credit line.
29
- * For more info: https://github.com/00labs/huma-contracts/blob/b075a8f957de281e0885e37dbd72a422b6a54a38/contracts/libraries/BaseStructs.sol#L49
30
- */
31
- export type CreditRecord = [
32
- BigNumber,
33
- BigNumber,
34
- BigNumber,
35
- BigNumber,
36
- BigNumber,
37
- number,
38
- number,
39
- number
40
- ] & {
41
- unbilledPrincipal: BigNumber;
42
- dueDate: BigNumber;
43
- correction: BigNumber;
44
- totalDue: BigNumber;
45
- feesAndInterestDue: BigNumber;
46
- missedPeriods: number;
47
- remainingPeriods: number;
48
- state: number;
49
- };
50
- /**
51
- * Gets the credit record of a wallet in a Huma pool. Denominated in the ERC20 tokens of the pool.
52
- *
53
- * @namespace getCreditRecord
54
- * @async
55
- * @function
56
- * @param {string} address - The address to lookup.
57
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to read data.
58
- * @param {number} chainId - The chain ID of the pool. Used to lookup the pool address.
59
- * @param {POOL_NAME} poolName - The name of the credit pool. Used to lookup the pool address.
60
- * @param {POOL_TYPE} poolType - The type of the credit pool. Used to lookup the pool address.
61
- * @returns {Promise<CreditRecord>} - A Promise of the transaction response.
62
- */
63
- export declare function getCreditRecord(address: string, signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): Promise<CreditRecord>;
64
- /**
65
- * Gets the total due for a Huma pool of the given wallet. Denominated in the ERC20 tokens of the pool.
66
- *
67
- * @async
68
- * @function
69
- * @param {string} address - The address to lookup.
70
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to read data.
71
- * @param {number} chainId - The chain ID of the pool. Used to lookup the pool address.
72
- * @param {POOL_NAME} poolName - The name of the credit pool. Used to lookup the pool address.
73
- * @param {POOL_TYPE} poolType - The type of the credit pool. Used to lookup the pool address.
74
- * @returns {Promise<BigNumber>} - A Promise of the transaction response.
75
- */
76
- export declare function getTotalDue(address: string, signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): Promise<BigNumber>;
77
- /**
78
- * Calls drawdown on a Huma pool contract
79
- *
80
- * @async
81
- * @function
82
- * @param {ethers.Signer} signer - The signer used to send the transaction.
83
- * @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
84
- * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
85
- * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
86
- * @param {BigNumberish} drawdownAmount - The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.
87
- * @param {Overrides} [gasOpts] - The gas options to use for the transaction.
88
- * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
89
- */
90
- export declare function drawdownFromPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, drawdownAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
91
- /**
92
- * Calls makePayment on a Huma pool contract. If the pool does not have sufficient allowance to complete the operation,
93
- * attempt to first increase the allowance of the pool.
94
- *
95
- * @async
96
- * @function
97
- * @param {ethers.Signer} signer - The signer used to send the transaction.
98
- * @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
99
- * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
100
- * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
101
- * @param {BigNumberish} paymentAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
102
- * @param {Overrides} [gasOpts] - The gas options to use for the transaction.
103
- * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
104
- */
105
- export declare function makePaymentToPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, paymentAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
106
- /**
107
- * Approves an allowance for a Huma pool contract, which is required to do certain actions (e.g. makePayment)
108
- *
109
- * @async
110
- * @function
111
- * @param {ethers.Signer} signer - The signer used to send the transaction.
112
- * @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
113
- * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
114
- * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
115
- * @param {BigNumberish} allowanceAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
116
- * @param {Overrides} [gasOpts] - The gas options to use for the transaction.
117
- * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
118
- */
119
- export declare function approvePoolAllowance(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, allowanceAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
1
+ import { BigNumber } from '@ethersproject/bignumber';
2
+ import { BigNumberish, Contract, Overrides, ethers } from 'ethers';
3
+ import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
4
+ import { TransactionResponse } from '@ethersproject/providers';
5
+ /**
6
+ * Returns an ethers contract instance for a Huma pool contract
7
+ *
8
+ * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
9
+ * @param {number} chainId The chain id where the contract instance exists
10
+ * @param {POOL_NAME} poolName The name of the pool contract to get.
11
+ * @param {POOL_TYPE} poolType The type of the pool contract to get.
12
+ * @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
13
+ */
14
+ export declare function getPoolContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): Contract | null;
15
+ /**
16
+ * Return type of getCreditRecord
17
+ *
18
+ * @memberof getCreditRecord
19
+ * @typedef {Object} CreditRecord
20
+ * @property {BigNumber} unbilledPrincipal - The amount of principal not included in the bill
21
+ * @property {BigNumber} dueDate - Unix timestamp due date of the next payment
22
+ * @property {BigNumber} correction - the adjustment of interest over or under-counted because of drawdown
23
+ * or principal payment in the middle of a billing period
24
+ * @property {BigNumber} totalDue - The due amount of the next payment
25
+ * @property {BigNumber} feesAndInterestDue - Interest and fees due for the next payment
26
+ * @property {number} missedPeriods - # of consecutive missed payments, for default processing
27
+ * @property {number} remainingPeriods - # of payment periods until the maturity of the credit line
28
+ * @property {number} state - status of the credit line.
29
+ * For more info: https://github.com/00labs/huma-contracts/blob/b075a8f957de281e0885e37dbd72a422b6a54a38/contracts/libraries/BaseStructs.sol#L49
30
+ */
31
+ export type CreditRecord = [
32
+ BigNumber,
33
+ BigNumber,
34
+ BigNumber,
35
+ BigNumber,
36
+ BigNumber,
37
+ number,
38
+ number,
39
+ number
40
+ ] & {
41
+ unbilledPrincipal: BigNumber;
42
+ dueDate: BigNumber;
43
+ correction: BigNumber;
44
+ totalDue: BigNumber;
45
+ feesAndInterestDue: BigNumber;
46
+ missedPeriods: number;
47
+ remainingPeriods: number;
48
+ state: number;
49
+ };
50
+ /**
51
+ * Gets the credit record of a wallet in a Huma pool. Denominated in the ERC20 tokens of the pool.
52
+ *
53
+ * @namespace getCreditRecord
54
+ * @async
55
+ * @function
56
+ * @param {string} address - The address to lookup.
57
+ * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to read data.
58
+ * @param {number} chainId - The chain ID of the pool. Used to lookup the pool address.
59
+ * @param {POOL_NAME} poolName - The name of the credit pool. Used to lookup the pool address.
60
+ * @param {POOL_TYPE} poolType - The type of the credit pool. Used to lookup the pool address.
61
+ * @returns {Promise<CreditRecord>} - A Promise of the transaction response.
62
+ */
63
+ export declare function getCreditRecord(address: string, signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): Promise<CreditRecord>;
64
+ /**
65
+ * Gets the total due for a Huma pool of the given wallet. Denominated in the ERC20 tokens of the pool.
66
+ *
67
+ * @async
68
+ * @function
69
+ * @param {string} address - The address to lookup.
70
+ * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to read data.
71
+ * @param {number} chainId - The chain ID of the pool. Used to lookup the pool address.
72
+ * @param {POOL_NAME} poolName - The name of the credit pool. Used to lookup the pool address.
73
+ * @param {POOL_TYPE} poolType - The type of the credit pool. Used to lookup the pool address.
74
+ * @returns {Promise<BigNumber>} - A Promise of the transaction response.
75
+ */
76
+ export declare function getTotalDue(address: string, signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): Promise<BigNumber>;
77
+ /**
78
+ * Calls drawdown on a Huma pool contract
79
+ *
80
+ * @async
81
+ * @function
82
+ * @param {ethers.Signer} signer - The signer used to send the transaction.
83
+ * @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
84
+ * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
85
+ * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
86
+ * @param {BigNumberish} drawdownAmount - The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.
87
+ * @param {Overrides} [gasOpts] - The gas options to use for the transaction.
88
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
89
+ */
90
+ export declare function drawdownFromPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, drawdownAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
91
+ /**
92
+ * Calls makePayment on a Huma pool contract. If the pool does not have sufficient allowance to complete the operation,
93
+ * attempt to first increase the allowance of the pool.
94
+ *
95
+ * @async
96
+ * @function
97
+ * @param {ethers.Signer} signer - The signer used to send the transaction.
98
+ * @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
99
+ * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
100
+ * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
101
+ * @param {BigNumberish} paymentAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
102
+ * @param {Overrides} [gasOpts] - The gas options to use for the transaction.
103
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
104
+ */
105
+ export declare function makePaymentToPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, paymentAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
106
+ /**
107
+ * Approves an allowance for a Huma pool contract, which is required to do certain actions (e.g. makePayment)
108
+ *
109
+ * @async
110
+ * @function
111
+ * @param {ethers.Signer} signer - The signer used to send the transaction.
112
+ * @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
113
+ * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
114
+ * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
115
+ * @param {BigNumberish} allowanceAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
116
+ * @param {Overrides} [gasOpts] - The gas options to use for the transaction.
117
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
118
+ */
119
+ export declare function approvePoolAllowance(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, allowanceAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;