@huma-finance/sdk 0.0.26 → 0.0.28
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 +14 -9
- 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 +11 -6
- 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 +3 -3
|
@@ -84,7 +84,7 @@ export declare function getTotalDue(address: string, signerOrProvider: ethers.pr
|
|
|
84
84
|
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
85
85
|
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
86
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.
|
|
87
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
88
88
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
89
89
|
*/
|
|
90
90
|
export declare function drawdownFromPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, drawdownAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
|
|
@@ -98,7 +98,7 @@ export declare function drawdownFromPool(signer: ethers.Signer, chainId: number,
|
|
|
98
98
|
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
99
99
|
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
100
100
|
* @param {BigNumberish} paymentAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
|
|
101
|
-
* @param {Overrides} gasOpts - The gas options to use for the transaction.
|
|
101
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
102
102
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
103
103
|
*/
|
|
104
104
|
export declare function makePaymentToPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, paymentAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
|
|
@@ -66,14 +66,15 @@ exports.getTotalDue = getTotalDue;
|
|
|
66
66
|
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
67
67
|
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
68
68
|
* @param {BigNumberish} drawdownAmount - The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.
|
|
69
|
-
* @param {Overrides} gasOpts - The gas options to use for the transaction.
|
|
69
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
70
70
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
71
71
|
*/
|
|
72
|
-
function drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, gasOpts = {}) {
|
|
72
|
+
async function drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, gasOpts = {}) {
|
|
73
73
|
const poolContract = getPoolContract(signer, chainId, poolName, poolType);
|
|
74
74
|
if (!poolContract) {
|
|
75
75
|
throw new Error('Could not find pool contract');
|
|
76
76
|
}
|
|
77
|
+
gasOpts = await (0, utils_1.getDefaultGasOptions)(gasOpts, chainId);
|
|
77
78
|
// TODO: Generate typechain for pool contract
|
|
78
79
|
return poolContract.drawdown(drawdownAmount, gasOpts);
|
|
79
80
|
}
|
|
@@ -88,7 +89,7 @@ exports.drawdownFromPool = drawdownFromPool;
|
|
|
88
89
|
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
89
90
|
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
90
91
|
* @param {BigNumberish} paymentAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
|
|
91
|
-
* @param {Overrides} gasOpts - The gas options to use for the transaction.
|
|
92
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
92
93
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
93
94
|
*/
|
|
94
95
|
async function makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, gasOpts = {}) {
|
|
@@ -96,6 +97,7 @@ async function makePaymentToPool(signer, chainId, poolName, poolType, paymentAmo
|
|
|
96
97
|
if (!poolContract) {
|
|
97
98
|
throw new Error('Could not find pool contract');
|
|
98
99
|
}
|
|
100
|
+
gasOpts = await (0, utils_1.getDefaultGasOptions)(gasOpts, chainId);
|
|
99
101
|
// TODO: Generate typechain for pool contract
|
|
100
102
|
return poolContract.makePayment(await signer.getAddress(), paymentAmount, gasOpts);
|
|
101
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":";;;AAKA,
|
|
1
|
+
{"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":";;;AAKA,oCAAyE;AAEzE;;;;;;;;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,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AAG,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,OAAO,GAAG,MAAM,IAAA,4BAAoB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAEtD,6CAA6C;IAC7C,OAAO,YAAY,CAAC,WAAW,CAC7B,MAAM,MAAM,CAAC,UAAU,EAAE,EACzB,aAAa,EACb,OAAO,CACR,CAAA;AACH,CAAC;AAtBD,8CAsBC"}
|
|
@@ -14,18 +14,23 @@ const graphql_request_1 = tslib_1.__importStar(require("graphql-request"));
|
|
|
14
14
|
*/
|
|
15
15
|
function getBundlrNetworkConfig(chainId) {
|
|
16
16
|
switch (chainId) {
|
|
17
|
-
case 5:
|
|
17
|
+
case 5: // Goerli
|
|
18
18
|
return {
|
|
19
19
|
nodeUrl: 'https://devnet.bundlr.network',
|
|
20
20
|
currency: 'ethereum',
|
|
21
21
|
providerUrl: 'https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
|
|
22
22
|
};
|
|
23
|
-
case 80001:
|
|
23
|
+
case 80001: // Mumbai
|
|
24
24
|
return {
|
|
25
25
|
nodeUrl: 'https://devnet.bundlr.network',
|
|
26
26
|
currency: 'matic',
|
|
27
27
|
providerUrl: 'https://rpc-mumbai.matic.today',
|
|
28
28
|
};
|
|
29
|
+
case 137: // Matic
|
|
30
|
+
return {
|
|
31
|
+
nodeUrl: 'https://node1.bundlr.network',
|
|
32
|
+
currency: 'matic',
|
|
33
|
+
};
|
|
29
34
|
default:
|
|
30
35
|
return {
|
|
31
36
|
nodeUrl: '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ARWeaveService.js","sourceRoot":"","sources":["../../../src/services/ARWeaveService.ts"],"names":[],"mappings":";;;;AAAA,4EAA2C;AAM3C,2EAA8C;AAkB9C;;;;;;;GAOG;AACH,SAAgB,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,4EAA2C;AAM3C,2EAA8C;AAkB9C;;;;;;;GAOG;AACH,SAAgB,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,8BAA8B;gBACvC,QAAQ,EAAE,OAAO;aAClB,CAAA;QACH;YACE,OAAO;gBACL,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,EAAE;aACb,CAAA;KACJ;AACH,CAAC;AA1BD,wDA0BC;AAED;;;;;;;;;;GAUG;AACH,KAAK,UAAU,aAAa,CAC1B,MAAoB;AACpB,8DAA8D;AAC9D,MAAW,EACX,MAAc;IAEd,MAAM,MAAM,GAAG,IAAI,gBAAM,CACvB,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,QAAQ,EACf,MAAM,EACN,MAAM,CAAC,WAAW;QAChB,CAAC,CAAC;YACE,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC;QACH,CAAC,CAAC,SAAS,CACd,CAAA;IACD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;IAEpB,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAC5B,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,KAAK,UAAU,SA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,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;AACU,QAAA,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
|
};
|
|
@@ -2,12 +2,33 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EAService = void 0;
|
|
4
4
|
const shared_1 = require("@huma-finance/shared");
|
|
5
|
+
/**
|
|
6
|
+
* Submits a credit underwriting request to Huma's EAVerse. This approves a creditline
|
|
7
|
+
* in Huma's pools that can be drawn down by the borrower.
|
|
8
|
+
*
|
|
9
|
+
* @memberof EAService
|
|
10
|
+
* @param {EAPayload} payload The payload for the underwrite approval.
|
|
11
|
+
* @param {number} chainId The chain ID.
|
|
12
|
+
* @returns {Promise<Approval>} Promise that returns the approval on success.
|
|
13
|
+
* @throws {EARejectionError} If the underwrite approval is rejected.
|
|
14
|
+
*/
|
|
15
|
+
const approve = async (payload, chainId) => shared_1.EAService.approve(payload, chainId);
|
|
16
|
+
/**
|
|
17
|
+
* Checks whether or not a credit underwriting request to Huma's EAVerse would be approved.
|
|
18
|
+
* Note that this does not approve a creditline in Huma's pools and an approve call is still required.
|
|
19
|
+
*
|
|
20
|
+
* @param {EAPreapprovalPayload} payload The payload for the underwrite approval.
|
|
21
|
+
* @param {number} chainId The chain ID.
|
|
22
|
+
* @returns {Promise<Approval>} Promise that returns the approval on success.
|
|
23
|
+
*/
|
|
24
|
+
const preapprove = async (payload, chainId) => shared_1.EAService.preapprove(payload, chainId);
|
|
5
25
|
/**
|
|
6
26
|
* An object that contains functions to interact with Huma's EAVerse service.
|
|
7
27
|
*
|
|
8
28
|
* @namespace EAService
|
|
9
29
|
*/
|
|
10
30
|
exports.EAService = {
|
|
11
|
-
approve
|
|
31
|
+
approve,
|
|
32
|
+
preapprove,
|
|
12
33
|
};
|
|
13
34
|
//# sourceMappingURL=EAService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EAService.js","sourceRoot":"","sources":["../../../src/services/EAService.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"EAService.js","sourceRoot":"","sources":["../../../src/services/EAService.ts"],"names":[],"mappings":";;;AAAA,iDAI6B;AAa7B;;;;;;;;;GASG;AACH,MAAM,OAAO,GAAG,KAAK,EAAE,OAAkB,EAAE,OAAe,EAAE,EAAE,CAC5D,kBAAiB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAE7C;;;;;;;GAOG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,OAA6B,EAAE,OAAe,EAAE,EAAE,CAC1E,kBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAEhD;;;;GAIG;AACU,QAAA,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
|
*/
|
|
@@ -7,7 +7,7 @@ const shared_1 = require("@huma-finance/shared");
|
|
|
7
7
|
const graphql_request_1 = tslib_1.__importStar(require("graphql-request"));
|
|
8
8
|
const ARWeaveService_1 = require("./ARWeaveService");
|
|
9
9
|
const helpers_1 = require("../helpers");
|
|
10
|
-
const
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
11
|
/**
|
|
12
12
|
* Declares a payment on a RealWorldReceivable given a reference ID of the receivable, which was used as an index for ARWeave data.
|
|
13
13
|
*
|
|
@@ -17,11 +17,12 @@ const chain_1 = require("../utils/chain");
|
|
|
17
17
|
* @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
|
|
18
18
|
* @param {string} referenceId - An internal identifier value added as a tag on ARWeave
|
|
19
19
|
* @param {number} paymentAmount - The amount to declare paid to the receivable.
|
|
20
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
20
21
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
|
|
21
22
|
*/
|
|
22
|
-
async function declareReceivablePaymentByReferenceId(signer, referenceId, paymentAmount) {
|
|
23
|
+
async function declareReceivablePaymentByReferenceId(signer, referenceId, paymentAmount, gasOpts = {}) {
|
|
23
24
|
var _a, _b, _c;
|
|
24
|
-
const chainId = await (0,
|
|
25
|
+
const chainId = await (0, utils_1.getChainIdFromSignerOrProvider)(signer);
|
|
25
26
|
const signerAddress = await signer.getAddress();
|
|
26
27
|
if (!chainId) {
|
|
27
28
|
throw new Error('No Chain ID found');
|
|
@@ -63,7 +64,8 @@ async function declareReceivablePaymentByReferenceId(signer, referenceId, paymen
|
|
|
63
64
|
if (!contract) {
|
|
64
65
|
throw new Error('Could not find RealWorldReceivable contract');
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
+
gasOpts = await (0, utils_1.getDefaultGasOptions)(gasOpts, chainId);
|
|
68
|
+
return contract.declarePayment((_c = receivablesData === null || receivablesData === void 0 ? void 0 : receivablesData.receivables[0]) === null || _c === void 0 ? void 0 : _c.tokenId, paymentAmount, gasOpts);
|
|
67
69
|
}
|
|
68
70
|
/**
|
|
69
71
|
* Declares a payment on a RealWorldReceivable given a tokenID of the receivable.
|
|
@@ -74,12 +76,13 @@ async function declareReceivablePaymentByReferenceId(signer, referenceId, paymen
|
|
|
74
76
|
* @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
|
|
75
77
|
* @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
|
|
76
78
|
* @param {number} paymentAmount - The amount to pay the receivable.
|
|
79
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
77
80
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
|
|
78
81
|
* @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
|
|
79
82
|
*/
|
|
80
|
-
async function declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount) {
|
|
83
|
+
async function declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount, gasOpts = {}) {
|
|
81
84
|
var _a;
|
|
82
|
-
const chainId = await (0,
|
|
85
|
+
const chainId = await (0, utils_1.getChainIdFromSignerOrProvider)(signer);
|
|
83
86
|
if (!chainId) {
|
|
84
87
|
throw new Error('No Chain ID found');
|
|
85
88
|
}
|
|
@@ -91,7 +94,8 @@ async function declareReceivablePaymentByTokenId(signer, receivableTokenId, paym
|
|
|
91
94
|
if (!contract) {
|
|
92
95
|
throw new Error('Could not find RealWorldReceivable contract');
|
|
93
96
|
}
|
|
94
|
-
|
|
97
|
+
gasOpts = await (0, utils_1.getDefaultGasOptions)(gasOpts, chainId);
|
|
98
|
+
return contract.declarePayment(receivableTokenId, paymentAmount, gasOpts);
|
|
95
99
|
}
|
|
96
100
|
/**
|
|
97
101
|
* Creates a new RealWorldReceivable token on the given chain of the signer
|
|
@@ -106,13 +110,13 @@ async function declareReceivablePaymentByTokenId(signer, receivableTokenId, paym
|
|
|
106
110
|
* @param {number} receivableAmount - The amount of the receivable token to mint.
|
|
107
111
|
* @param {number} maturityDate - The maturity date of the receivable token, in UNIX timestamp format.
|
|
108
112
|
* @param {string} uri - The URI of the receivable token metadata.
|
|
109
|
-
* @param {Overrides} gasOpts - The gas options to use for the transaction.
|
|
113
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
110
114
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
111
115
|
* @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
|
|
112
116
|
*/
|
|
113
117
|
async function createReceivable(signer, poolName, poolType, currencyCode, receivableAmount, maturityDate, uri, gasOpts = {}) {
|
|
114
118
|
var _a, _b;
|
|
115
|
-
const chainId = await (0,
|
|
119
|
+
const chainId = await (0, utils_1.getChainIdFromSignerOrProvider)(signer);
|
|
116
120
|
if (!chainId) {
|
|
117
121
|
throw new Error('No Chain ID found');
|
|
118
122
|
}
|
|
@@ -126,6 +130,7 @@ async function createReceivable(signer, poolName, poolType, currencyCode, receiv
|
|
|
126
130
|
if (!contract) {
|
|
127
131
|
throw new Error('Could not find RealWorldReceivable contract');
|
|
128
132
|
}
|
|
133
|
+
gasOpts = await (0, utils_1.getDefaultGasOptions)(gasOpts, chainId);
|
|
129
134
|
return contract.createRealWorldReceivable(poolInfo.pool, currencyCode, receivableAmount, maturityDate, uri, gasOpts);
|
|
130
135
|
}
|
|
131
136
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReceivableService.js","sourceRoot":"","sources":["../../../src/services/ReceivableService.ts"],"names":[],"mappings":";;;;AAAA,wDAA4E;AAE5E,iDAO6B;AAC7B,2EAA8C;AAE9C,qDAAiD;AACjD,wCAA2D;AAC3D,
|
|
1
|
+
{"version":3,"file":"ReceivableService.js","sourceRoot":"","sources":["../../../src/services/ReceivableService.ts"],"names":[],"mappings":";;;;AAAA,wDAA4E;AAE5E,iDAO6B;AAC7B,2EAA8C;AAE9C,qDAAiD;AACjD,wCAA2D;AAC3D,oCAA+E;AAG/E;;;;;;;;;;;GAWG;AACH,KAAK,UAAU,qCAAqC,CAClD,MAAqB,EACrB,WAAmB,EACnB,aAAqB,EACrB,UAAqB,EAAE;;IAEvB,MAAM,OAAO,GAAG,MAAM,IAAA,sCAA8B,EAAC,MAAM,CAAC,CAAA;IAC5D,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAA;IAE/C,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;KACrC;IAED,iBAAiB;IACjB,MAAM,MAAM,GAAG,MAAM,+BAAc,CAAC,gBAAgB,CAClD,OAAO,EACP,aAAa,EACb,WAAW,CACZ,CAAA;IAED,6CAA6C;IAC7C,MAAM,gBAAgB,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;;GAU3B,CAAA;IAED,IAAI,kBAAkB,CAAA;IACtB,QAAQ,OAAO,EAAE;QACf,KAAK,kBAAS,CAAC,MAAM;YACnB,kBAAkB,GAAG,wEAAwE,CAAA;YAC7F,MAAK;QACP;YACE,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;KAClE;IAED,MAAM,eAAe,GAAkC,MAAM,IAAA,yBAAO,EAClE,kBAAkB,EAClB,gBAAgB,EAChB;QACE,KAAK,EAAE,aAAa;QACpB,GAAG,EAAE,uBAAuB,MAAM,EAAE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,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;AACU,QAAA,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
|
*
|
|
@@ -29,7 +29,7 @@ function getSubgraphUrlForChainId(chainId) {
|
|
|
29
29
|
* @param {number} chainId - The ID of the chain.
|
|
30
30
|
* @param {POOL_NAME} poolName - The name of the pool.
|
|
31
31
|
* @param {POOL_TYPE} poolType - The type of the pool.
|
|
32
|
-
* @param {
|
|
32
|
+
* @param {number[]} event - The event types to filter by.
|
|
33
33
|
* @returns {Promise<CreditEventPayload[]>} The credit events for the given user.
|
|
34
34
|
*/
|
|
35
35
|
function getCreditEventsForUser(userAddress, chainId, poolName, poolType, event) {
|
|
@@ -45,7 +45,7 @@ function getCreditEventsForUser(userAddress, chainId, poolName, poolType, event)
|
|
|
45
45
|
where: {
|
|
46
46
|
owner: "${userAddress}",
|
|
47
47
|
pool: "${poolAddress}",
|
|
48
|
-
event_in:
|
|
48
|
+
event_in: [${event.join(',')}]
|
|
49
49
|
}
|
|
50
50
|
orderBy: timestamp
|
|
51
51
|
orderDirection: desc
|
|
@@ -58,15 +58,8 @@ function getCreditEventsForUser(userAddress, chainId, poolName, poolType, event)
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
`;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
headers: {
|
|
64
|
-
'Content-Type': 'application/json',
|
|
65
|
-
},
|
|
66
|
-
body: JSON.stringify({ query }),
|
|
67
|
-
})
|
|
68
|
-
.then((res) => res.json())
|
|
69
|
-
.then((res) => {
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
+
return (0, shared_1.requestPost)(url, JSON.stringify({ query })).then((res) => {
|
|
70
63
|
if (res.errors) {
|
|
71
64
|
console.error(res.errors);
|
|
72
65
|
return [];
|
|
@@ -86,7 +79,7 @@ function getCreditEventsForUser(userAddress, chainId, poolName, poolType, event)
|
|
|
86
79
|
*/
|
|
87
80
|
function getLastFactorizedAmountFromPool(userAddress, chainId, poolName, poolType) {
|
|
88
81
|
return getCreditEventsForUser(userAddress, chainId, poolName, poolType, [
|
|
89
|
-
shared_1.CreditEvent.DrawdownMadeWithReceivable
|
|
82
|
+
shared_1.CreditEvent.DrawdownMadeWithReceivable,
|
|
90
83
|
]).then((events) => Number(events[0].amount));
|
|
91
84
|
}
|
|
92
85
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubgraphService.js","sourceRoot":"","sources":["../../../src/services/SubgraphService.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"SubgraphService.js","sourceRoot":"","sources":["../../../src/services/SubgraphService.ts"],"names":[],"mappings":";;;AAAA,iDAM6B;AAE7B;;;;;;GAMG;AACH,SAAS,wBAAwB,CAAC,OAAe;IAC/C,QAAQ,OAAO,EAA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0BAA0B;KACvC,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,5 +1,6 @@
|
|
|
1
1
|
import { JsonRpcProvider, JsonRpcSigner } from '@ethersproject/providers';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
|
+
export declare function isPolygonNetwork(network: number): boolean;
|
|
3
4
|
/**
|
|
4
5
|
* Get the chain ID from a signer or provider object.
|
|
5
6
|
* @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The signer or provider object to get the chain ID from.
|
package/dist/cjs/utils/chain.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getChainIdFromSignerOrProvider = exports.getChainIdFromJsonSignerOrProvider = void 0;
|
|
3
|
+
exports.getChainIdFromSignerOrProvider = exports.getChainIdFromJsonSignerOrProvider = exports.isPolygonNetwork = void 0;
|
|
4
4
|
const providers_1 = require("@ethersproject/providers");
|
|
5
5
|
const ethers_1 = require("ethers");
|
|
6
|
+
function isPolygonNetwork(network) {
|
|
7
|
+
return network === 137 || network === 80001;
|
|
8
|
+
}
|
|
9
|
+
exports.isPolygonNetwork = isPolygonNetwork;
|
|
6
10
|
/**
|
|
7
11
|
* Get the chain ID from a signer or provider object.
|
|
8
12
|
* @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The signer or provider object to get the chain ID from.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../src/utils/chain.ts"],"names":[],"mappings":";;;AAAA,wDAAyE;AACzE,mCAA+B;AAE/B;;;;GAIG;AACH,SA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,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"}
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -4,4 +4,5 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
tslib_1.__exportStar(require("./chain"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./web3"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./poolInfo"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./maticGasStation"), exports);
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,kDAAuB;AACvB,iDAAsB;AACtB,qDAA0B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,kDAAuB;AACvB,iDAAsB;AACtB,qDAA0B;AAC1B,4DAAiC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDefaultGasOptions = exports.getPolygonGasOptions = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const shared_1 = require("@huma-finance/shared");
|
|
6
|
+
const chain_1 = require("./chain");
|
|
7
|
+
async function getPolygonGasOptions(network) {
|
|
8
|
+
let maxFeePerGas = ethers_1.ethers.BigNumber.from(40000000000); // fallback to 40 gwei
|
|
9
|
+
let maxPriorityFeePerGas = ethers_1.ethers.BigNumber.from(40000000000); // fallback to 40 gwei
|
|
10
|
+
try {
|
|
11
|
+
const url = network === shared_1.ChainEnum.Polygon
|
|
12
|
+
? 'https://gasstation.polygon.technology/v2'
|
|
13
|
+
: 'https://gasstation-testnet.polygon.technology/v2';
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
const data = await (0, shared_1.requestGet)(url);
|
|
16
|
+
maxFeePerGas = ethers_1.ethers.utils.parseUnits(`${Math.ceil(data.fast.maxFee)}`, 'gwei');
|
|
17
|
+
maxPriorityFeePerGas = ethers_1.ethers.utils.parseUnits(`${Math.ceil(data.fast.maxPriorityFee)}`, 'gwei');
|
|
18
|
+
}
|
|
19
|
+
catch (_a) {
|
|
20
|
+
// ignore
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
maxFeePerGas,
|
|
24
|
+
maxPriorityFeePerGas,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.getPolygonGasOptions = getPolygonGasOptions;
|
|
28
|
+
async function getDefaultGasOptions(gasOpts, network) {
|
|
29
|
+
// Return gasOpts if there are values already set
|
|
30
|
+
if (Object.keys(gasOpts).length > 0) {
|
|
31
|
+
return gasOpts;
|
|
32
|
+
}
|
|
33
|
+
if ((0, chain_1.isPolygonNetwork)(network)) {
|
|
34
|
+
gasOpts = await getPolygonGasOptions(network);
|
|
35
|
+
}
|
|
36
|
+
return gasOpts;
|
|
37
|
+
}
|
|
38
|
+
exports.getDefaultGasOptions = getDefaultGasOptions;
|
|
39
|
+
//# sourceMappingURL=maticGasStation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maticGasStation.js","sourceRoot":"","sources":["../../../src/utils/maticGasStation.ts"],"names":[],"mappings":";;;AAAA,mCAA0C;AAC1C,iDAA4D;AAE5D,mCAA0C;AAEnC,KAAK,UAAU,oBAAoB,CACxC,OAAe;IAEf,IAAI,YAAY,GAAG,eAAM,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA,CAAC,sBAAsB;IAC5E,IAAI,oBAAoB,GAAG,eAAM,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA,CAAC,sBAAsB;IACpF,IAAI;QACF,MAAM,GAAG,GACP,OAAO,KAAK,kBAAS,CAAC,OAAO;YAC3B,CAAC,CAAC,0CAA0C;YAC5C,CAAC,CAAC,kDAAkD,CAAA;QACxD,8DAA8D;QAC9D,MAAM,IAAI,GAAQ,MAAM,IAAA,mBAAU,EAAC,GAAG,CAAC,CAAA;QACvC,YAAY,GAAG,eAAM,CAAC,KAAK,CAAC,UAAU,CACpC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAChC,MAAM,CACP,CAAA;QACD,oBAAoB,GAAG,eAAM,CAAC,KAAK,CAAC,UAAU,CAC5C,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,EACxC,MAAM,CACP,CAAA;KACF;IAAC,WAAM;QACN,SAAS;KACV;IAED,OAAO;QACL,YAAY;QACZ,oBAAoB;KACrB,CAAA;AACH,CAAC;AA5BD,oDA4BC;AAEM,KAAK,UAAU,oBAAoB,CACxC,OAAkB,EAClB,OAAe;IAEf,iDAAiD;IACjD,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;QACnC,OAAO,OAAO,CAAA;KACf;IAED,IAAI,IAAA,wBAAgB,EAAC,OAAO,CAAC,EAAE;QAC7B,OAAO,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC,CAAA;KAC9C;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAdD,oDAcC"}
|
|
@@ -84,7 +84,7 @@ export declare function getTotalDue(address: string, signerOrProvider: ethers.pr
|
|
|
84
84
|
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
85
85
|
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
86
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.
|
|
87
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
88
88
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
89
89
|
*/
|
|
90
90
|
export declare function drawdownFromPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, drawdownAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
|
|
@@ -98,7 +98,7 @@ export declare function drawdownFromPool(signer: ethers.Signer, chainId: number,
|
|
|
98
98
|
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
99
99
|
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
100
100
|
* @param {BigNumberish} paymentAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
|
|
101
|
-
* @param {Overrides} gasOpts - The gas options to use for the transaction.
|
|
101
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
102
102
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
103
103
|
*/
|
|
104
104
|
export declare function makePaymentToPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, paymentAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getContract, getPoolInfo } from '../utils';
|
|
1
|
+
import { getContract, getPoolInfo, getDefaultGasOptions } from '../utils';
|
|
2
2
|
/**
|
|
3
3
|
* Returns an ethers contract instance for a Huma pool contract
|
|
4
4
|
*
|
|
@@ -60,14 +60,15 @@ export async function getTotalDue(address, signerOrProvider, chainId, poolName,
|
|
|
60
60
|
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
61
61
|
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
62
62
|
* @param {BigNumberish} drawdownAmount - The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.
|
|
63
|
-
* @param {Overrides} gasOpts - The gas options to use for the transaction.
|
|
63
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
64
64
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
65
65
|
*/
|
|
66
|
-
export function drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, gasOpts = {}) {
|
|
66
|
+
export async function drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, gasOpts = {}) {
|
|
67
67
|
const poolContract = getPoolContract(signer, chainId, poolName, poolType);
|
|
68
68
|
if (!poolContract) {
|
|
69
69
|
throw new Error('Could not find pool contract');
|
|
70
70
|
}
|
|
71
|
+
gasOpts = await getDefaultGasOptions(gasOpts, chainId);
|
|
71
72
|
// TODO: Generate typechain for pool contract
|
|
72
73
|
return poolContract.drawdown(drawdownAmount, gasOpts);
|
|
73
74
|
}
|
|
@@ -81,7 +82,7 @@ export function drawdownFromPool(signer, chainId, poolName, poolType, drawdownAm
|
|
|
81
82
|
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
82
83
|
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
83
84
|
* @param {BigNumberish} paymentAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
|
|
84
|
-
* @param {Overrides} gasOpts - The gas options to use for the transaction.
|
|
85
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
85
86
|
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
86
87
|
*/
|
|
87
88
|
export async function makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, gasOpts = {}) {
|
|
@@ -89,6 +90,7 @@ export async function makePaymentToPool(signer, chainId, poolName, poolType, pay
|
|
|
89
90
|
if (!poolContract) {
|
|
90
91
|
throw new Error('Could not find pool contract');
|
|
91
92
|
}
|
|
93
|
+
gasOpts = await getDefaultGasOptions(gasOpts, chainId);
|
|
92
94
|
// TODO: Generate typechain for pool contract
|
|
93
95
|
return poolContract.makePayment(await signer.getAddress(), paymentAmount, gasOpts);
|
|
94
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEzE;;;;;;;;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,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AAO,EAAE,OAAO,CAAC,CAAA;IAEtD,6CAA6C;IAC7C,OAAO,YAAY,CAAC,WAAW,CAC7B,MAAM,MAAM,CAAC,UAAU,EAAE,EACzB,aAAa,EACb,OAAO,CACR,CAAA;AACH,CAAC"}
|
|
@@ -10,18 +10,23 @@ import request, { gql } from 'graphql-request';
|
|
|
10
10
|
*/
|
|
11
11
|
export function getBundlrNetworkConfig(chainId) {
|
|
12
12
|
switch (chainId) {
|
|
13
|
-
case 5:
|
|
13
|
+
case 5: // Goerli
|
|
14
14
|
return {
|
|
15
15
|
nodeUrl: 'https://devnet.bundlr.network',
|
|
16
16
|
currency: 'ethereum',
|
|
17
17
|
providerUrl: 'https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
|
|
18
18
|
};
|
|
19
|
-
case 80001:
|
|
19
|
+
case 80001: // Mumbai
|
|
20
20
|
return {
|
|
21
21
|
nodeUrl: 'https://devnet.bundlr.network',
|
|
22
22
|
currency: 'matic',
|
|
23
23
|
providerUrl: 'https://rpc-mumbai.matic.today',
|
|
24
24
|
};
|
|
25
|
+
case 137: // Matic
|
|
26
|
+
return {
|
|
27
|
+
nodeUrl: 'https://node1.bundlr.network',
|
|
28
|
+
currency: 'matic',
|
|
29
|
+
};
|
|
25
30
|
default:
|
|
26
31
|
return {
|
|
27
32
|
nodeUrl: '',
|
|
@@ -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":[],"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AE,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
|
};
|