@huma-finance/sdk 0.0.20 → 0.0.22
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 +2 -2
- package/dist/cjs/helpers/PoolContractHelper.js +5 -3
- package/dist/cjs/helpers/PoolContractHelper.js.map +1 -1
- package/dist/cjs/services/ARWeaveService.js +7 -2
- package/dist/cjs/services/ARWeaveService.js.map +1 -1
- package/dist/cjs/services/EAService.d.ts +3 -1
- package/dist/cjs/services/EAService.js +22 -1
- package/dist/cjs/services/EAService.js.map +1 -1
- package/dist/cjs/services/ReceivableService.d.ts +5 -3
- package/dist/cjs/services/ReceivableService.js +25 -20
- package/dist/cjs/services/ReceivableService.js.map +1 -1
- package/dist/cjs/services/SubgraphService.d.ts +2 -2
- package/dist/cjs/services/SubgraphService.js +5 -12
- package/dist/cjs/services/SubgraphService.js.map +1 -1
- package/dist/cjs/utils/chain.d.ts +1 -0
- package/dist/cjs/utils/chain.js +5 -1
- package/dist/cjs/utils/chain.js.map +1 -1
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/maticGasStation.d.ts +3 -0
- package/dist/cjs/utils/maticGasStation.js +39 -0
- package/dist/cjs/utils/maticGasStation.js.map +1 -0
- package/dist/helpers/PoolContractHelper.d.ts +2 -2
- package/dist/helpers/PoolContractHelper.js +6 -4
- package/dist/helpers/PoolContractHelper.js.map +1 -1
- package/dist/services/ARWeaveService.js +7 -2
- package/dist/services/ARWeaveService.js.map +1 -1
- package/dist/services/EAService.d.ts +3 -1
- package/dist/services/EAService.js +23 -2
- package/dist/services/EAService.js.map +1 -1
- package/dist/services/ReceivableService.d.ts +5 -3
- package/dist/services/ReceivableService.js +22 -17
- package/dist/services/ReceivableService.js.map +1 -1
- package/dist/services/SubgraphService.d.ts +2 -2
- package/dist/services/SubgraphService.js +6 -13
- package/dist/services/SubgraphService.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/utils/chain.d.ts +1 -0
- package/dist/utils/chain.js +3 -0
- package/dist/utils/chain.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/maticGasStation.d.ts +3 -0
- package/dist/utils/maticGasStation.js +34 -0
- package/dist/utils/maticGasStation.js.map +1 -0
- package/package.json +4 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ARWeaveService.js","sourceRoot":"","sources":["../../src/services/ARWeaveService.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,wBAAwB,CAAA;AAM3C,OAAO,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAkB9C;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,QAAQ,OAAO,EAAE;QACf,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"ARWeaveService.js","sourceRoot":"","sources":["../../src/services/ARWeaveService.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,wBAAwB,CAAA;AAM3C,OAAO,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAkB9C;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,QAAQ,OAAO,EAAE;QACf,KAAK,CAAC,EAAE,SAAS;YACf,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,EAAE,UAAU;gBACpB,WAAW,EACT,8DAA8D;aACjE,CAAA;QACH,KAAK,KAAK,EAAE,SAAS;YACnB,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,EAAE,OAAO;gBACjB,WAAW,EAAE,gCAAgC;aAC9C,CAAA;QACH,KAAK,GAAG,EAAE,QAAQ;YAChB,OAAO;gBACL,OAAO,EAAE,8BAA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,OAAO,CAAC,GAAG,CACT,uBAAuB,KAAK,IAAI,MAAM,CAAC,QAAQ,iBAAiB,CACjE,CAAA;QACD,MAAM,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;KACzB;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AACzC,CAAC;AAED;;;;;;;;;;GAUG;AACH,KAAK,UAAU,gBAAgB,CAC7B,OAAe,EACf,MAAc,EACd,WAAmB;;IAEnB,MAAM,MAAM,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAA;IAC9C,MAAM,KAAK,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;GAgBhB,CAAA;IAED,8DAA8D;IAC9D,MAAM,IAAI,GAAQ,MAAM,OAAO,CAAC,GAAG,MAAM,CAAC,OAAO,UAAU,EAAE,KAAK,EAAE;QAClE,MAAM;QACN,WAAW;KACZ,CAAC,CAAA;IAEF,OAAO,MAAA,MAAA,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,0CAAE,KAAK,0CAAG,CAAC,CAAC,0CAAE,IAAI,0CAAE,EAAE,CAAA;AACjD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,gBAAgB;IAChB,SAAS;IACT,aAAa;IACb,sBAAsB;CACvB,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EAPayload, EAPreapprovalPayload } from '@huma-finance/shared';
|
|
1
2
|
/**
|
|
2
3
|
* Object representing the response to the underwriting approval request.
|
|
3
4
|
* @typedef {Object} ApprovalResult
|
|
@@ -14,5 +15,6 @@ export type { ApprovalResult, EAPayload } from '@huma-finance/shared';
|
|
|
14
15
|
* @namespace EAService
|
|
15
16
|
*/
|
|
16
17
|
export declare const EAService: {
|
|
17
|
-
approve: (payload:
|
|
18
|
+
approve: (payload: EAPayload, chainId: number) => Promise<import("@huma-finance/shared").Approval>;
|
|
19
|
+
preapprove: (payload: EAPreapprovalPayload, chainId: number) => Promise<import("@huma-finance/shared").PreapprovalResult>;
|
|
18
20
|
};
|
|
@@ -1,10 +1,31 @@
|
|
|
1
|
-
import { EAService as EAServiceInternal } from '@huma-finance/shared';
|
|
1
|
+
import { EAService as EAServiceInternal, } from '@huma-finance/shared';
|
|
2
|
+
/**
|
|
3
|
+
* Submits a credit underwriting request to Huma's EAVerse. This approves a creditline
|
|
4
|
+
* in Huma's pools that can be drawn down by the borrower.
|
|
5
|
+
*
|
|
6
|
+
* @memberof EAService
|
|
7
|
+
* @param {EAPayload} payload The payload for the underwrite approval.
|
|
8
|
+
* @param {number} chainId The chain ID.
|
|
9
|
+
* @returns {Promise<Approval>} Promise that returns the approval on success.
|
|
10
|
+
* @throws {EARejectionError} If the underwrite approval is rejected.
|
|
11
|
+
*/
|
|
12
|
+
const approve = async (payload, chainId) => EAServiceInternal.approve(payload, chainId);
|
|
13
|
+
/**
|
|
14
|
+
* Checks whether or not a credit underwriting request to Huma's EAVerse would be approved.
|
|
15
|
+
* Note that this does not approve a creditline in Huma's pools and an approve call is still required.
|
|
16
|
+
*
|
|
17
|
+
* @param {EAPreapprovalPayload} payload The payload for the underwrite approval.
|
|
18
|
+
* @param {number} chainId The chain ID.
|
|
19
|
+
* @returns {Promise<Approval>} Promise that returns the approval on success.
|
|
20
|
+
*/
|
|
21
|
+
const preapprove = async (payload, chainId) => EAServiceInternal.preapprove(payload, chainId);
|
|
2
22
|
/**
|
|
3
23
|
* An object that contains functions to interact with Huma's EAVerse service.
|
|
4
24
|
*
|
|
5
25
|
* @namespace EAService
|
|
6
26
|
*/
|
|
7
27
|
export const EAService = {
|
|
8
|
-
approve
|
|
28
|
+
approve,
|
|
29
|
+
preapprove,
|
|
9
30
|
};
|
|
10
31
|
//# sourceMappingURL=EAService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EAService.js","sourceRoot":"","sources":["../../src/services/EAService.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"EAService.js","sourceRoot":"","sources":["../../src/services/EAService.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,IAAI,iBAAiB,GAC/B,MAAM,sBAAsB,CAAA;AAa7B;;;;;;;;;GASG;AACH,MAAM,OAAO,GAAG,KAAK,EAAE,OAAkB,EAAE,OAAe,EAAE,EAAE,CAC5D,iBAAiB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAE7C;;;;;;;GAOG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,OAA6B,EAAE,OAAe,EAAE,EAAE,CAC1E,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,OAAO;IACP,UAAU;CACX,CAAA"}
|
|
@@ -10,9 +10,10 @@ import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
|
|
|
10
10
|
* @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
|
|
11
11
|
* @param {string} referenceId - An internal identifier value added as a tag on ARWeave
|
|
12
12
|
* @param {number} paymentAmount - The amount to declare paid to the receivable.
|
|
13
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
13
14
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
|
|
14
15
|
*/
|
|
15
|
-
declare function declareReceivablePaymentByReferenceId(signer: ethers.Signer, referenceId: string, paymentAmount: number): Promise<TransactionResponse>;
|
|
16
|
+
declare function declareReceivablePaymentByReferenceId(signer: ethers.Signer, referenceId: string, paymentAmount: number, gasOpts?: Overrides): Promise<TransactionResponse>;
|
|
16
17
|
/**
|
|
17
18
|
* Declares a payment on a RealWorldReceivable given a tokenID of the receivable.
|
|
18
19
|
*
|
|
@@ -22,10 +23,11 @@ declare function declareReceivablePaymentByReferenceId(signer: ethers.Signer, re
|
|
|
22
23
|
* @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
|
|
23
24
|
* @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
|
|
24
25
|
* @param {number} paymentAmount - The amount to pay the receivable.
|
|
26
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
25
27
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
|
|
26
28
|
* @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
|
|
27
29
|
*/
|
|
28
|
-
declare function declareReceivablePaymentByTokenId(signer: ethers.Signer, receivableTokenId: BigNumberish, paymentAmount: number): Promise<TransactionResponse>;
|
|
30
|
+
declare function declareReceivablePaymentByTokenId(signer: ethers.Signer, receivableTokenId: BigNumberish, paymentAmount: number, gasOpts?: Overrides): Promise<TransactionResponse>;
|
|
29
31
|
/**
|
|
30
32
|
* Creates a new RealWorldReceivable token on the given chain of the signer
|
|
31
33
|
*
|
|
@@ -39,7 +41,7 @@ declare function declareReceivablePaymentByTokenId(signer: ethers.Signer, receiv
|
|
|
39
41
|
* @param {number} receivableAmount - The amount of the receivable token to mint.
|
|
40
42
|
* @param {number} maturityDate - The maturity date of the receivable token, in UNIX timestamp format.
|
|
41
43
|
* @param {string} uri - The URI of the receivable token metadata.
|
|
42
|
-
* @param {Overrides} gasOpts - The gas options to use for the transaction.
|
|
44
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
43
45
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
44
46
|
* @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
|
|
45
47
|
*/
|
|
@@ -3,7 +3,7 @@ import { ChainEnum, PoolContractMap, SupplementaryContracts, SupplementaryContra
|
|
|
3
3
|
import request, { gql } from 'graphql-request';
|
|
4
4
|
import { ARWeaveService } from './ARWeaveService';
|
|
5
5
|
import { getRealWorldReceivableContract } from '../helpers';
|
|
6
|
-
import { getChainIdFromSignerOrProvider } from '../utils
|
|
6
|
+
import { getDefaultGasOptions, getChainIdFromSignerOrProvider } from '../utils';
|
|
7
7
|
/**
|
|
8
8
|
* Declares a payment on a RealWorldReceivable given a reference ID of the receivable, which was used as an index for ARWeave data.
|
|
9
9
|
*
|
|
@@ -13,9 +13,10 @@ import { getChainIdFromSignerOrProvider } from '../utils/chain';
|
|
|
13
13
|
* @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
|
|
14
14
|
* @param {string} referenceId - An internal identifier value added as a tag on ARWeave
|
|
15
15
|
* @param {number} paymentAmount - The amount to declare paid to the receivable.
|
|
16
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
16
17
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
|
|
17
18
|
*/
|
|
18
|
-
async function declareReceivablePaymentByReferenceId(signer, referenceId, paymentAmount) {
|
|
19
|
+
async function declareReceivablePaymentByReferenceId(signer, referenceId, paymentAmount, gasOpts = {}) {
|
|
19
20
|
var _a, _b, _c;
|
|
20
21
|
const chainId = await getChainIdFromSignerOrProvider(signer);
|
|
21
22
|
const signerAddress = await signer.getAddress();
|
|
@@ -25,16 +26,16 @@ async function declareReceivablePaymentByReferenceId(signer, referenceId, paymen
|
|
|
25
26
|
// Get ARWeave ID
|
|
26
27
|
const dataID = await ARWeaveService.queryForMetadata(chainId, signerAddress, referenceId);
|
|
27
28
|
// Fetch receivables with the same ARWeave ID
|
|
28
|
-
const receivablesQuery = gql `
|
|
29
|
-
query ReceivablesByURIQuery($owner: String!, $uri: String!) {
|
|
30
|
-
receivables(where: { owner: $owner, uri: $uri }) {
|
|
31
|
-
...ReceivableFields
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
fragment ReceivableFields on Receivable {
|
|
36
|
-
tokenId
|
|
37
|
-
}
|
|
29
|
+
const receivablesQuery = gql `
|
|
30
|
+
query ReceivablesByURIQuery($owner: String!, $uri: String!) {
|
|
31
|
+
receivables(where: { owner: $owner, uri: $uri }) {
|
|
32
|
+
...ReceivableFields
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fragment ReceivableFields on Receivable {
|
|
37
|
+
tokenId
|
|
38
|
+
}
|
|
38
39
|
`;
|
|
39
40
|
let receivableSubgraph;
|
|
40
41
|
switch (chainId) {
|
|
@@ -52,14 +53,15 @@ async function declareReceivablePaymentByReferenceId(signer, referenceId, paymen
|
|
|
52
53
|
throw new Error('No receivables found with this ARWeave ID.');
|
|
53
54
|
}
|
|
54
55
|
else if (((_b = receivablesData === null || receivablesData === void 0 ? void 0 : receivablesData.receivables) === null || _b === void 0 ? void 0 : _b.length) > 1) {
|
|
55
|
-
throw new Error(`This owner has multiple receivables with the same URI. Please burn
|
|
56
|
+
throw new Error(`This owner has multiple receivables with the same URI. Please burn
|
|
56
57
|
unnecessary receivables or pay the correct token manually using declareReceivablePaymentByTokenId`);
|
|
57
58
|
}
|
|
58
59
|
const contract = getRealWorldReceivableContract(signer, chainId);
|
|
59
60
|
if (!contract) {
|
|
60
61
|
throw new Error('Could not find RealWorldReceivable contract');
|
|
61
62
|
}
|
|
62
|
-
|
|
63
|
+
gasOpts = await getDefaultGasOptions(gasOpts, chainId);
|
|
64
|
+
return contract.declarePayment((_c = receivablesData === null || receivablesData === void 0 ? void 0 : receivablesData.receivables[0]) === null || _c === void 0 ? void 0 : _c.tokenId, paymentAmount, gasOpts);
|
|
63
65
|
}
|
|
64
66
|
/**
|
|
65
67
|
* Declares a payment on a RealWorldReceivable given a tokenID of the receivable.
|
|
@@ -70,10 +72,11 @@ async function declareReceivablePaymentByReferenceId(signer, referenceId, paymen
|
|
|
70
72
|
* @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
|
|
71
73
|
* @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
|
|
72
74
|
* @param {number} paymentAmount - The amount to pay the receivable.
|
|
75
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
73
76
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
|
|
74
77
|
* @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
|
|
75
78
|
*/
|
|
76
|
-
async function declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount) {
|
|
79
|
+
async function declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount, gasOpts = {}) {
|
|
77
80
|
var _a;
|
|
78
81
|
const chainId = await getChainIdFromSignerOrProvider(signer);
|
|
79
82
|
if (!chainId) {
|
|
@@ -87,7 +90,8 @@ async function declareReceivablePaymentByTokenId(signer, receivableTokenId, paym
|
|
|
87
90
|
if (!contract) {
|
|
88
91
|
throw new Error('Could not find RealWorldReceivable contract');
|
|
89
92
|
}
|
|
90
|
-
|
|
93
|
+
gasOpts = await getDefaultGasOptions(gasOpts, chainId);
|
|
94
|
+
return contract.declarePayment(receivableTokenId, paymentAmount, gasOpts);
|
|
91
95
|
}
|
|
92
96
|
/**
|
|
93
97
|
* Creates a new RealWorldReceivable token on the given chain of the signer
|
|
@@ -102,7 +106,7 @@ async function declareReceivablePaymentByTokenId(signer, receivableTokenId, paym
|
|
|
102
106
|
* @param {number} receivableAmount - The amount of the receivable token to mint.
|
|
103
107
|
* @param {number} maturityDate - The maturity date of the receivable token, in UNIX timestamp format.
|
|
104
108
|
* @param {string} uri - The URI of the receivable token metadata.
|
|
105
|
-
* @param {Overrides} gasOpts - The gas options to use for the transaction.
|
|
109
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
106
110
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
107
111
|
* @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
|
|
108
112
|
*/
|
|
@@ -122,6 +126,7 @@ async function createReceivable(signer, poolName, poolType, currencyCode, receiv
|
|
|
122
126
|
if (!contract) {
|
|
123
127
|
throw new Error('Could not find RealWorldReceivable contract');
|
|
124
128
|
}
|
|
129
|
+
gasOpts = await getDefaultGasOptions(gasOpts, chainId);
|
|
125
130
|
return contract.createRealWorldReceivable(poolInfo.pool, currencyCode, receivableAmount, maturityDate, uri, gasOpts);
|
|
126
131
|
}
|
|
127
132
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReceivableService.js","sourceRoot":"","sources":["../../src/services/ReceivableService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE5E,OAAO,EACL,SAAS,EAGT,eAAe,EACf,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAA;AAC3D,OAAO,EAAE,8BAA8B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ReceivableService.js","sourceRoot":"","sources":["../../src/services/ReceivableService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE5E,OAAO,EACL,SAAS,EAGT,eAAe,EACf,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAA;AAC3D,OAAO,EAAE,oBAAoB,EAAE,8BAA8B,EAAE,MAAM,UAAU,CAAA;AAG/E;;;;;;;;;;;GAWG;AACH,KAAK,UAAU,qCAAqC,CAClD,MAAqB,EACrB,WAAmB,EACnB,aAAqB,EACrB,UAAqB,EAAE;;IAEvB,MAAM,OAAO,GAAG,MAAM,8BAA8B,CAAC,MAAM,CAAC,CAAA;IAC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AAU,EAAE,KAAK,EAAE,QAAQ,EAAE;YACrC,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE;YAC3C,GAAG,SAAS;SACb,CAAA;QAED,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,SAAS,CAC7C,MAAM,EACN,gBAAgB,YAAY,YAAY,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAW,EACzE,QAAQ,EACR,IAAI,EACJ,QAAQ,CACT,CAAA;QACD,OAAO,CAAC,GAAG,CAAC,yCAAyC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAA;QAEnE,OAAO,MAAM,gBAAgB,CAC3B,gBAAgB,YAAY,YAAY;YACtC,CAAC,CAAC,gBAAgB,CAAC,SAAS,EAAE;YAC9B,CAAC,CAAC,gBAAgB,EACpB,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,QAAQ,CAAC,EAAE,EAAE,EACpC,OAAO,CACR,CAAA;KACF;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAChB,MAAM,CAAC,CAAA;KACR;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,4BAA4B;IAC5B,gBAAgB;IAChB,iCAAiC;IACjC,qCAAqC;CACtC,CAAA"}
|
|
@@ -26,10 +26,10 @@ export type CreditEventPayload = {
|
|
|
26
26
|
* @param {number} chainId - The ID of the chain.
|
|
27
27
|
* @param {POOL_NAME} poolName - The name of the pool.
|
|
28
28
|
* @param {POOL_TYPE} poolType - The type of the pool.
|
|
29
|
-
* @param {
|
|
29
|
+
* @param {number[]} event - The event types to filter by.
|
|
30
30
|
* @returns {Promise<CreditEventPayload[]>} The credit events for the given user.
|
|
31
31
|
*/
|
|
32
|
-
declare function getCreditEventsForUser(userAddress: string, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, event:
|
|
32
|
+
declare function getCreditEventsForUser(userAddress: string, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, event: number[]): Promise<CreditEventPayload[]>;
|
|
33
33
|
/**
|
|
34
34
|
* Returns the last factorized amount for a given user and pool.
|
|
35
35
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreditEvent, PoolContractMap, } from '@huma-finance/shared';
|
|
1
|
+
import { CreditEvent, PoolContractMap, requestPost, } from '@huma-finance/shared';
|
|
2
2
|
/**
|
|
3
3
|
* Returns the subgraph URL for a given chain ID.
|
|
4
4
|
*
|
|
@@ -26,7 +26,7 @@ function getSubgraphUrlForChainId(chainId) {
|
|
|
26
26
|
* @param {number} chainId - The ID of the chain.
|
|
27
27
|
* @param {POOL_NAME} poolName - The name of the pool.
|
|
28
28
|
* @param {POOL_TYPE} poolType - The type of the pool.
|
|
29
|
-
* @param {
|
|
29
|
+
* @param {number[]} event - The event types to filter by.
|
|
30
30
|
* @returns {Promise<CreditEventPayload[]>} The credit events for the given user.
|
|
31
31
|
*/
|
|
32
32
|
function getCreditEventsForUser(userAddress, chainId, poolName, poolType, event) {
|
|
@@ -42,7 +42,7 @@ function getCreditEventsForUser(userAddress, chainId, poolName, poolType, event)
|
|
|
42
42
|
where: {
|
|
43
43
|
owner: "${userAddress}",
|
|
44
44
|
pool: "${poolAddress}",
|
|
45
|
-
event_in:
|
|
45
|
+
event_in: [${event.join(',')}]
|
|
46
46
|
}
|
|
47
47
|
orderBy: timestamp
|
|
48
48
|
orderDirection: desc
|
|
@@ -55,15 +55,8 @@ function getCreditEventsForUser(userAddress, chainId, poolName, poolType, event)
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
`;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
headers: {
|
|
61
|
-
'Content-Type': 'application/json',
|
|
62
|
-
},
|
|
63
|
-
body: JSON.stringify({ query }),
|
|
64
|
-
})
|
|
65
|
-
.then((res) => res.json())
|
|
66
|
-
.then((res) => {
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
+
return requestPost(url, JSON.stringify({ query })).then((res) => {
|
|
67
60
|
if (res.errors) {
|
|
68
61
|
console.error(res.errors);
|
|
69
62
|
return [];
|
|
@@ -83,7 +76,7 @@ function getCreditEventsForUser(userAddress, chainId, poolName, poolType, event)
|
|
|
83
76
|
*/
|
|
84
77
|
function getLastFactorizedAmountFromPool(userAddress, chainId, poolName, poolType) {
|
|
85
78
|
return getCreditEventsForUser(userAddress, chainId, poolName, poolType, [
|
|
86
|
-
CreditEvent.DrawdownMadeWithReceivable
|
|
79
|
+
CreditEvent.DrawdownMadeWithReceivable,
|
|
87
80
|
]).then((events) => Number(events[0].amount));
|
|
88
81
|
}
|
|
89
82
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubgraphService.js","sourceRoot":"","sources":["../../src/services/SubgraphService.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,
|
|
1
|
+
{"version":3,"file":"SubgraphService.js","sourceRoot":"","sources":["../../src/services/SubgraphService.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EAGf,WAAW,GACZ,MAAM,sBAAsB,CAAA;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,EAA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