@huma-finance/sdk 0.0.13 → 0.0.16
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.
- package/dist/cjs/helpers/PoolContractHelper.d.ts +63 -0
- package/dist/cjs/helpers/PoolContractHelper.js +39 -1
- package/dist/cjs/helpers/PoolContractHelper.js.map +1 -1
- package/dist/cjs/services/ARWeaveService.js +16 -16
- package/dist/cjs/utils/poolInfo.d.ts +0 -1
- package/dist/cjs/utils/poolInfo.js +0 -1
- package/dist/cjs/utils/poolInfo.js.map +1 -1
- package/dist/helpers/PoolContractHelper.d.ts +63 -0
- package/dist/helpers/PoolContractHelper.js +36 -0
- package/dist/helpers/PoolContractHelper.js.map +1 -1
- package/dist/services/ARWeaveService.js +16 -16
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/utils/poolInfo.d.ts +0 -1
- package/dist/utils/poolInfo.js +0 -1
- package/dist/utils/poolInfo.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BigNumber } from '@ethersproject/bignumber';
|
|
1
2
|
import { BigNumberish, Contract, Overrides, ethers } from 'ethers';
|
|
2
3
|
import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
|
|
3
4
|
import { TransactionResponse } from '@ethersproject/providers';
|
|
@@ -11,6 +12,68 @@ import { TransactionResponse } from '@ethersproject/providers';
|
|
|
11
12
|
* @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
|
|
12
13
|
*/
|
|
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>;
|
|
14
77
|
/**
|
|
15
78
|
* Calls drawdown on a Huma pool contract
|
|
16
79
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makePaymentToPool = exports.drawdownFromPool = exports.getPoolContract = void 0;
|
|
3
|
+
exports.makePaymentToPool = exports.drawdownFromPool = exports.getTotalDue = exports.getCreditRecord = exports.getPoolContract = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
/**
|
|
6
6
|
* Returns an ethers contract instance for a Huma pool contract
|
|
@@ -18,6 +18,44 @@ function getPoolContract(signerOrProvider, chainId, poolName, poolType) {
|
|
|
18
18
|
return (0, utils_1.getContract)(poolInfo.pool, poolInfo.poolAbi, signerOrProvider);
|
|
19
19
|
}
|
|
20
20
|
exports.getPoolContract = getPoolContract;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the credit record of a wallet in a Huma pool. Denominated in the ERC20 tokens of the pool.
|
|
23
|
+
*
|
|
24
|
+
* @namespace getCreditRecord
|
|
25
|
+
* @async
|
|
26
|
+
* @function
|
|
27
|
+
* @param {string} address - The address to lookup.
|
|
28
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to read data.
|
|
29
|
+
* @param {number} chainId - The chain ID of the pool. Used to lookup the pool address.
|
|
30
|
+
* @param {POOL_NAME} poolName - The name of the credit pool. Used to lookup the pool address.
|
|
31
|
+
* @param {POOL_TYPE} poolType - The type of the credit pool. Used to lookup the pool address.
|
|
32
|
+
* @returns {Promise<CreditRecord>} - A Promise of the transaction response.
|
|
33
|
+
*/
|
|
34
|
+
async function getCreditRecord(address, signerOrProvider, chainId, poolName, poolType) {
|
|
35
|
+
const poolContract = getPoolContract(signerOrProvider, chainId, poolName, poolType);
|
|
36
|
+
if (!poolContract) {
|
|
37
|
+
throw new Error('Could not find pool contract');
|
|
38
|
+
}
|
|
39
|
+
return poolContract.creditRecordMapping(address);
|
|
40
|
+
}
|
|
41
|
+
exports.getCreditRecord = getCreditRecord;
|
|
42
|
+
/**
|
|
43
|
+
* Gets the total due for a Huma pool of the given wallet. Denominated in the ERC20 tokens of the pool.
|
|
44
|
+
*
|
|
45
|
+
* @async
|
|
46
|
+
* @function
|
|
47
|
+
* @param {string} address - The address to lookup.
|
|
48
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to read data.
|
|
49
|
+
* @param {number} chainId - The chain ID of the pool. Used to lookup the pool address.
|
|
50
|
+
* @param {POOL_NAME} poolName - The name of the credit pool. Used to lookup the pool address.
|
|
51
|
+
* @param {POOL_TYPE} poolType - The type of the credit pool. Used to lookup the pool address.
|
|
52
|
+
* @returns {Promise<BigNumber>} - A Promise of the transaction response.
|
|
53
|
+
*/
|
|
54
|
+
async function getTotalDue(address, signerOrProvider, chainId, poolName, poolType) {
|
|
55
|
+
const creditRecord = await getCreditRecord(address, signerOrProvider, chainId, poolName, poolType);
|
|
56
|
+
return creditRecord.totalDue;
|
|
57
|
+
}
|
|
58
|
+
exports.getTotalDue = getTotalDue;
|
|
21
59
|
/**
|
|
22
60
|
* Calls drawdown on a Huma pool contract
|
|
23
61
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":";;;AAKA,oCAAmD;AAEnD;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAC7B,gBAA2D,EAC3D,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAEzD,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAA;IAE1B,OAAO,IAAA,mBAAW,EAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;AACvE,CAAC;AAXD,0CAWC;AAsCD;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,eAAe,CACnC,OAAe,EACf,gBAA2D,EAC3D,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,MAAM,YAAY,GAAG,eAAe,CAClC,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,QAAQ,CACT,CAAA;IAED,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;KAChD;IAED,OAAO,YAAY,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAA;AAClD,CAAC;AAnBD,0CAmBC;AAED;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,WAAW,CAC/B,OAAe,EACf,gBAA2D,EAC3D,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,MAAM,YAAY,GAAG,MAAM,eAAe,CACxC,OAAO,EACP,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,QAAQ,CACT,CAAA;IAED,OAAO,YAAY,CAAC,QAAQ,CAAA;AAC9B,CAAC;AAhBD,kCAgBC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,gBAAgB,CAC9B,MAAqB,EACrB,OAAe,EACf,QAAmB,EACnB,QAAmB,EACnB,cAA4B,EAC5B,UAAqB,EAAE;IAEvB,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAEzE,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;KAChD;IAED,6CAA6C;IAC7C,OAAO,YAAY,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;AACvD,CAAC;AAhBD,4CAgBC;AAED;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,iBAAiB,CACrC,MAAqB,EACrB,OAAe,EACf,QAAmB,EACnB,QAAmB,EACnB,aAA2B,EAC3B,UAAqB,EAAE;IAEvB,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAEzE,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;KAChD;IAED,6CAA6C;IAC7C,OAAO,YAAY,CAAC,WAAW,CAC7B,MAAM,MAAM,CAAC,UAAU,EAAE,EACzB,aAAa,EACb,OAAO,CACR,CAAA;AACH,CAAC;AApBD,8CAoBC"}
|
|
@@ -104,22 +104,22 @@ async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true
|
|
|
104
104
|
async function queryForMetadata(chainId, sender, referenceId) {
|
|
105
105
|
var _a, _b, _c, _d;
|
|
106
106
|
const config = getBundlrNetworkConfig(chainId);
|
|
107
|
-
const query = (0, graphql_request_1.gql) `
|
|
108
|
-
query ArweaveHumaMetadataQuery($sender: String!, $referenceId: String!) {
|
|
109
|
-
transactions(
|
|
110
|
-
owners: [$sender]
|
|
111
|
-
tags: [
|
|
112
|
-
{ name: "appName", values: ["HumaFinance"] }
|
|
113
|
-
{ name: "referenceId", values: [$referenceId] }
|
|
114
|
-
]
|
|
115
|
-
) {
|
|
116
|
-
edges {
|
|
117
|
-
node {
|
|
118
|
-
id
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
107
|
+
const query = (0, graphql_request_1.gql) `
|
|
108
|
+
query ArweaveHumaMetadataQuery($sender: String!, $referenceId: String!) {
|
|
109
|
+
transactions(
|
|
110
|
+
owners: [$sender]
|
|
111
|
+
tags: [
|
|
112
|
+
{ name: "appName", values: ["HumaFinance"] }
|
|
113
|
+
{ name: "referenceId", values: [$referenceId] }
|
|
114
|
+
]
|
|
115
|
+
) {
|
|
116
|
+
edges {
|
|
117
|
+
node {
|
|
118
|
+
id
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
123
|
`;
|
|
124
124
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
125
125
|
const data = await (0, graphql_request_1.default)(`${config.nodeUrl}/graphql`, query, {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { POOL_NAME, POOL_TYPE, PoolInfoType } from '@huma-finance/shared';
|
|
2
2
|
/**
|
|
3
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
4
|
* @param {POOL_NAME} poolName - The name of the pool.
|
|
6
5
|
* @param {POOL_TYPE} poolType - The type of the pool.
|
|
7
6
|
* @returns {PoolInfoType|undefined} - The pool info or undefined if the chain ID is not supported.
|
|
@@ -4,7 +4,6 @@ exports.getPoolInfo = void 0;
|
|
|
4
4
|
const shared_1 = require("@huma-finance/shared");
|
|
5
5
|
/**
|
|
6
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
7
|
* @param {POOL_NAME} poolName - The name of the pool.
|
|
9
8
|
* @param {POOL_TYPE} poolType - The type of the pool.
|
|
10
9
|
* @returns {PoolInfoType|undefined} - The pool info or undefined if the chain ID is not supported.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poolInfo.js","sourceRoot":"","sources":["../../../src/utils/poolInfo.ts"],"names":[],"mappings":";;;AAAA,iDAK6B;AAE7B
|
|
1
|
+
{"version":3,"file":"poolInfo.js","sourceRoot":"","sources":["../../../src/utils/poolInfo.ts"],"names":[],"mappings":";;;AAAA,iDAK6B;AAE7B;;;;;GAKG;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,3 +1,4 @@
|
|
|
1
|
+
import { BigNumber } from '@ethersproject/bignumber';
|
|
1
2
|
import { BigNumberish, Contract, Overrides, ethers } from 'ethers';
|
|
2
3
|
import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
|
|
3
4
|
import { TransactionResponse } from '@ethersproject/providers';
|
|
@@ -11,6 +12,68 @@ import { TransactionResponse } from '@ethersproject/providers';
|
|
|
11
12
|
* @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
|
|
12
13
|
*/
|
|
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>;
|
|
14
77
|
/**
|
|
15
78
|
* Calls drawdown on a Huma pool contract
|
|
16
79
|
*
|
|
@@ -14,6 +14,42 @@ export function getPoolContract(signerOrProvider, chainId, poolName, poolType) {
|
|
|
14
14
|
return null;
|
|
15
15
|
return getContract(poolInfo.pool, poolInfo.poolAbi, signerOrProvider);
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Gets the credit record of a wallet in a Huma pool. Denominated in the ERC20 tokens of the pool.
|
|
19
|
+
*
|
|
20
|
+
* @namespace getCreditRecord
|
|
21
|
+
* @async
|
|
22
|
+
* @function
|
|
23
|
+
* @param {string} address - The address to lookup.
|
|
24
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to read data.
|
|
25
|
+
* @param {number} chainId - The chain ID of the pool. Used to lookup the pool address.
|
|
26
|
+
* @param {POOL_NAME} poolName - The name of the credit pool. Used to lookup the pool address.
|
|
27
|
+
* @param {POOL_TYPE} poolType - The type of the credit pool. Used to lookup the pool address.
|
|
28
|
+
* @returns {Promise<CreditRecord>} - A Promise of the transaction response.
|
|
29
|
+
*/
|
|
30
|
+
export async function getCreditRecord(address, signerOrProvider, chainId, poolName, poolType) {
|
|
31
|
+
const poolContract = getPoolContract(signerOrProvider, chainId, poolName, poolType);
|
|
32
|
+
if (!poolContract) {
|
|
33
|
+
throw new Error('Could not find pool contract');
|
|
34
|
+
}
|
|
35
|
+
return poolContract.creditRecordMapping(address);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Gets the total due for a Huma pool of the given wallet. Denominated in the ERC20 tokens of the pool.
|
|
39
|
+
*
|
|
40
|
+
* @async
|
|
41
|
+
* @function
|
|
42
|
+
* @param {string} address - The address to lookup.
|
|
43
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to read data.
|
|
44
|
+
* @param {number} chainId - The chain ID of the pool. Used to lookup the pool address.
|
|
45
|
+
* @param {POOL_NAME} poolName - The name of the credit pool. Used to lookup the pool address.
|
|
46
|
+
* @param {POOL_TYPE} poolType - The type of the credit pool. Used to lookup the pool address.
|
|
47
|
+
* @returns {Promise<BigNumber>} - A Promise of the transaction response.
|
|
48
|
+
*/
|
|
49
|
+
export async function getTotalDue(address, signerOrProvider, chainId, poolName, poolType) {
|
|
50
|
+
const creditRecord = await getCreditRecord(address, signerOrProvider, chainId, poolName, poolType);
|
|
51
|
+
return creditRecord.totalDue;
|
|
52
|
+
}
|
|
17
53
|
/**
|
|
18
54
|
* Calls drawdown on a Huma pool contract
|
|
19
55
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":"AAKA,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;AAsCD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAAe,EACf,gBAA2D,EAC3D,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,MAAM,YAAY,GAAG,eAAe,CAClC,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,QAAQ,CACT,CAAA;IAED,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;KAChD;IAED,OAAO,YAAY,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAA;AAClD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAe,EACf,gBAA2D,EAC3D,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,MAAM,YAAY,GAAG,MAAM,eAAe,CACxC,OAAO,EACP,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,QAAQ,CACT,CAAA;IAED,OAAO,YAAY,CAAC,QAAQ,CAAA;AAC9B,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAqB,EACrB,OAAe,EACf,QAAmB,EACnB,QAAmB,EACnB,cAA4B,EAC5B,UAAqB,EAAE;IAEvB,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAEzE,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;KAChD;IAED,6CAA6C;IAC7C,OAAO,YAAY,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;AACvD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAqB,EACrB,OAAe,EACf,QAAmB,EACnB,QAAmB,EACnB,aAA2B,EAC3B,UAAqB,EAAE;IAEvB,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAEzE,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;KAChD;IAED,6CAA6C;IAC7C,OAAO,YAAY,CAAC,WAAW,CAC7B,MAAM,MAAM,CAAC,UAAU,EAAE,EACzB,aAAa,EACb,OAAO,CACR,CAAA;AACH,CAAC"}
|
|
@@ -99,22 +99,22 @@ async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true
|
|
|
99
99
|
async function queryForMetadata(chainId, sender, referenceId) {
|
|
100
100
|
var _a, _b, _c, _d;
|
|
101
101
|
const config = getBundlrNetworkConfig(chainId);
|
|
102
|
-
const query = gql `
|
|
103
|
-
query ArweaveHumaMetadataQuery($sender: String!, $referenceId: String!) {
|
|
104
|
-
transactions(
|
|
105
|
-
owners: [$sender]
|
|
106
|
-
tags: [
|
|
107
|
-
{ name: "appName", values: ["HumaFinance"] }
|
|
108
|
-
{ name: "referenceId", values: [$referenceId] }
|
|
109
|
-
]
|
|
110
|
-
) {
|
|
111
|
-
edges {
|
|
112
|
-
node {
|
|
113
|
-
id
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
102
|
+
const query = gql `
|
|
103
|
+
query ArweaveHumaMetadataQuery($sender: String!, $referenceId: String!) {
|
|
104
|
+
transactions(
|
|
105
|
+
owners: [$sender]
|
|
106
|
+
tags: [
|
|
107
|
+
{ name: "appName", values: ["HumaFinance"] }
|
|
108
|
+
{ name: "referenceId", values: [$referenceId] }
|
|
109
|
+
]
|
|
110
|
+
) {
|
|
111
|
+
edges {
|
|
112
|
+
node {
|
|
113
|
+
id
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
118
|
`;
|
|
119
119
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
120
|
const data = await request(`${config.nodeUrl}/graphql`, query, {
|