@huma-finance/sdk 0.0.48-beta.202 → 0.0.48-beta.279
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/API.md +134 -0
- package/dist/cjs/helpers/ERC20ContractHelper.d.ts +16 -0
- package/dist/cjs/helpers/ERC20ContractHelper.js +33 -0
- package/dist/cjs/helpers/ERC20ContractHelper.js.map +1 -0
- package/dist/cjs/helpers/PoolContractHelper.d.ts +3 -3
- package/dist/cjs/helpers/PoolContractHelper.js +3 -6
- package/dist/cjs/helpers/PoolContractHelper.js.map +1 -1
- package/dist/cjs/helpers/index.d.ts +2 -0
- package/dist/cjs/helpers/index.js +2 -0
- package/dist/cjs/helpers/index.js.map +1 -1
- package/dist/cjs/helpers/v2/ReceivableBackedCreditLineContractHelper.d.ts +55 -0
- package/dist/cjs/helpers/v2/ReceivableBackedCreditLineContractHelper.js +102 -0
- package/dist/cjs/helpers/v2/ReceivableBackedCreditLineContractHelper.js.map +1 -0
- package/dist/cjs/helpers/v2/ReceivableContractHelper.d.ts +14 -0
- package/dist/cjs/helpers/v2/ReceivableContractHelper.js +45 -0
- package/dist/cjs/helpers/v2/ReceivableContractHelper.js.map +1 -0
- package/dist/cjs/services/ReceivableService.js +0 -1
- package/dist/cjs/services/ReceivableService.js.map +1 -1
- package/dist/cjs/services/SubgraphService.d.ts +14 -1
- package/dist/cjs/services/SubgraphService.js +88 -11
- package/dist/cjs/services/SubgraphService.js.map +1 -1
- package/dist/cjs/services/index.d.ts +3 -0
- package/dist/cjs/services/index.js +3 -0
- package/dist/cjs/services/index.js.map +1 -1
- package/dist/cjs/services/v2/HumaContext.d.ts +23 -0
- package/dist/cjs/services/v2/HumaContext.js +55 -0
- package/dist/cjs/services/v2/HumaContext.js.map +1 -0
- package/dist/cjs/services/v2/HumaReceivableFactory.d.ts +21 -0
- package/dist/cjs/services/v2/HumaReceivableFactory.js +77 -0
- package/dist/cjs/services/v2/HumaReceivableFactory.js.map +1 -0
- package/dist/cjs/services/v2/HumaReceivableHandler.d.ts +10 -0
- package/dist/cjs/services/v2/HumaReceivableHandler.js +32 -0
- package/dist/cjs/services/v2/HumaReceivableHandler.js.map +1 -0
- package/dist/cjs/utils/chain.js +2 -10
- package/dist/cjs/utils/chain.js.map +1 -1
- package/dist/cjs/utils/poolInfo.js +1 -1
- package/dist/cjs/utils/poolInfo.js.map +1 -1
- package/dist/cjs/utils/web3.d.ts +3 -2
- package/dist/cjs/utils/web3.js.map +1 -1
- package/dist/helpers/ERC20ContractHelper.d.ts +16 -0
- package/dist/helpers/ERC20ContractHelper.js +29 -0
- package/dist/helpers/ERC20ContractHelper.js.map +1 -0
- package/dist/helpers/PoolContractHelper.d.ts +3 -3
- package/dist/helpers/PoolContractHelper.js +3 -6
- package/dist/helpers/PoolContractHelper.js.map +1 -1
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/index.js +2 -0
- package/dist/helpers/index.js.map +1 -1
- package/dist/helpers/v2/ReceivableBackedCreditLineContractHelper.d.ts +55 -0
- package/dist/helpers/v2/ReceivableBackedCreditLineContractHelper.js +95 -0
- package/dist/helpers/v2/ReceivableBackedCreditLineContractHelper.js.map +1 -0
- package/dist/helpers/v2/ReceivableContractHelper.d.ts +14 -0
- package/dist/helpers/v2/ReceivableContractHelper.js +39 -0
- package/dist/helpers/v2/ReceivableContractHelper.js.map +1 -0
- package/dist/services/ReceivableService.js +0 -1
- package/dist/services/ReceivableService.js.map +1 -1
- package/dist/services/SubgraphService.d.ts +14 -1
- package/dist/services/SubgraphService.js +89 -12
- package/dist/services/SubgraphService.js.map +1 -1
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.js +3 -0
- package/dist/services/index.js.map +1 -1
- package/dist/services/v2/HumaContext.d.ts +23 -0
- package/dist/services/v2/HumaContext.js +51 -0
- package/dist/services/v2/HumaContext.js.map +1 -0
- package/dist/services/v2/HumaReceivableFactory.d.ts +21 -0
- package/dist/services/v2/HumaReceivableFactory.js +73 -0
- package/dist/services/v2/HumaReceivableFactory.js.map +1 -0
- package/dist/services/v2/HumaReceivableHandler.d.ts +10 -0
- package/dist/services/v2/HumaReceivableHandler.js +28 -0
- package/dist/services/v2/HumaReceivableHandler.js.map +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/utils/chain.js +2 -10
- package/dist/utils/chain.js.map +1 -1
- package/dist/utils/poolInfo.js +2 -2
- package/dist/utils/poolInfo.js.map +1 -1
- package/dist/utils/web3.d.ts +3 -2
- package/dist/utils/web3.js.map +1 -1
- package/package.json +4 -4
package/API.md
CHANGED
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
<dl>
|
|
19
19
|
<dt><a href="#defaultWrapper">defaultWrapper()</a></dt>
|
|
20
20
|
<dd><p>All built-in and custom scalars, mapped to their actual values</p></dd>
|
|
21
|
+
<dt><a href="#approveERC20AllowanceIfInsufficient">approveERC20AllowanceIfInsufficient(signer, tokenAddress, spenderAddress, allowanceAmount, [gasOpts])</a> ⇒ <code>Promise.<(TransactionResponse|null)></code></dt>
|
|
22
|
+
<dd><p>Approves an ERC20 allowance for a spender address, if the current allowance is insufficient.
|
|
23
|
+
Allowance is required to do certain actions on the Huma protocol (e.g. makePayment)</p></dd>
|
|
21
24
|
<dt><a href="#getERC20TransferableReceivableContract">getERC20TransferableReceivableContract(signerOrProvider, chainId)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
|
|
22
25
|
<dd><p>Returns an ethers contract instance for the ERC20TransferableReceivable contract
|
|
23
26
|
associated with the given pool name on the current chain.</p></dd>
|
|
@@ -37,6 +40,18 @@ attempt to first increase the allowance of the pool.</p></dd>
|
|
|
37
40
|
<dt><a href="#getRealWorldReceivableContract">getRealWorldReceivableContract(signerOrProvider, chainId)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
|
|
38
41
|
<dd><p>Returns an ethers contract instance for the RealWorldReceivable contract
|
|
39
42
|
associated with the given pool name on the current chain.</p></dd>
|
|
43
|
+
<dt><a href="#getReceivableBackedCreditLineContractV2">getReceivableBackedCreditLineContractV2(signerOrProvider, poolName)</a> ⇒ <code>ReceivableBackedCreditLine</code> | <code>null</code></dt>
|
|
44
|
+
<dd><p>Returns an ethers contract instance for the V2 Receivable contract
|
|
45
|
+
associated with the given pool name on the current chain.</p></dd>
|
|
46
|
+
<dt><a href="#drawdownWithReceivable">drawdownWithReceivable(signer, poolName, receivableId, drawdownAmount, [gasOpts])</a> ⇒ <code>Promise.<TransactionResponse></code></dt>
|
|
47
|
+
<dd><p>Draws down from a pool using a receivable.</p></dd>
|
|
48
|
+
<dt><a href="#makePaymentWithReceivable">makePaymentWithReceivable(signer, poolName, receivableId, paymentAmount, principalOnly, [gasOpts])</a> ⇒ <code>Promise.<TransactionResponse></code></dt>
|
|
49
|
+
<dd><p>Makes a payment with a receivable.</p></dd>
|
|
50
|
+
<dt><a href="#makePrincipalPaymentAndDrawdownWithReceivable">makePrincipalPaymentAndDrawdownWithReceivable(signer, poolName, paymentReceivableId, paymentAmount, drawdownReceivableId, drawdownAmount, [gasOpts])</a> ⇒ <code>Promise.<TransactionResponse></code></dt>
|
|
51
|
+
<dd><p>Makes a principal payment and drawdown with receivables.</p></dd>
|
|
52
|
+
<dt><a href="#getReceivableContractV2">getReceivableContractV2(signerOrProvider, chainId)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
|
|
53
|
+
<dd><p>Returns an ethers contract instance for the V2 Receivable contract
|
|
54
|
+
associated with the given pool name on the current chain.</p></dd>
|
|
40
55
|
<dt><a href="#useContract">useContract(address, ABI, signerOrProvider)</a> ⇒ <code>T</code> | <code>null</code></dt>
|
|
41
56
|
<dd><p>Custom hook for creating an ethers instance of a smart contract.</p></dd>
|
|
42
57
|
<dt><a href="#useERC20TransferableReceivableContract">useERC20TransferableReceivableContract(signerOrProvider, chainId, poolName)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
|
|
@@ -475,6 +490,7 @@ in Huma's pools that can be drawn down by the borrower.</p>
|
|
|
475
490
|
* [.getLastFactorizedAmountFromPool(userAddress, chainId, poolName, poolType)](#SubgraphService.getLastFactorizedAmountFromPool) ⇒ <code>Promise.<number></code>
|
|
476
491
|
* [.getRWReceivableInfo(userAddress, chainId, poolName, poolType, pagination)](#SubgraphService.getRWReceivableInfo) ⇒ <code>Promise.<RealWorldReceivableInfoBase></code>
|
|
477
492
|
* [.getPoolStats(chainId, pool)](#SubgraphService.getPoolStats) ⇒ <code>Promise.<{PoolStats}></code>
|
|
493
|
+
* [.checkBorrowAndLendHistory(chainId, pool, userAddress)](#SubgraphService.checkBorrowAndLendHistory) ⇒ <code>Promise.<{hasBorrowHistory: boolean, hasLendHistory: boolean}></code>
|
|
478
494
|
|
|
479
495
|
<a name="SubgraphService.getSubgraphUrlForChainId"></a>
|
|
480
496
|
|
|
@@ -548,12 +564,45 @@ in Huma's pools that can be drawn down by the borrower.</p>
|
|
|
548
564
|
| chainId | <code>number</code> | <p>The ID of the chain.</p> |
|
|
549
565
|
| pool | <code>string</code> | <p>The address of the pool.</p> |
|
|
550
566
|
|
|
567
|
+
<a name="SubgraphService.checkBorrowAndLendHistory"></a>
|
|
568
|
+
|
|
569
|
+
### SubgraphService.checkBorrowAndLendHistory(chainId, pool, userAddress) ⇒ <code>Promise.<{hasBorrowHistory: boolean, hasLendHistory: boolean}></code>
|
|
570
|
+
<p>Returns if user has borrow or lend history.</p>
|
|
571
|
+
|
|
572
|
+
**Kind**: static method of [<code>SubgraphService</code>](#SubgraphService)
|
|
573
|
+
**Returns**: <code>Promise.<{hasBorrowHistory: boolean, hasLendHistory: boolean}></code> - <p>If user has borrow or lend history.</p>
|
|
574
|
+
|
|
575
|
+
| Param | Type | Description |
|
|
576
|
+
| --- | --- | --- |
|
|
577
|
+
| chainId | <code>number</code> | <p>The ID of the chain.</p> |
|
|
578
|
+
| pool | <code>string</code> | <p>The address of the pool.</p> |
|
|
579
|
+
| userAddress | <code>string</code> | <p>The address of the user.</p> |
|
|
580
|
+
|
|
551
581
|
<a name="defaultWrapper"></a>
|
|
552
582
|
|
|
553
583
|
## defaultWrapper()
|
|
554
584
|
<p>All built-in and custom scalars, mapped to their actual values</p>
|
|
555
585
|
|
|
556
586
|
**Kind**: global function
|
|
587
|
+
<a name="approveERC20AllowanceIfInsufficient"></a>
|
|
588
|
+
|
|
589
|
+
## approveERC20AllowanceIfInsufficient(signer, tokenAddress, spenderAddress, allowanceAmount, [gasOpts]) ⇒ <code>Promise.<(TransactionResponse\|null)></code>
|
|
590
|
+
<p>Approves an ERC20 allowance for a spender address, if the current allowance is insufficient.
|
|
591
|
+
Allowance is required to do certain actions on the Huma protocol (e.g. makePayment)</p>
|
|
592
|
+
|
|
593
|
+
**Kind**: global function
|
|
594
|
+
**Returns**: <code>Promise.<(TransactionResponse\|null)></code> - <ul>
|
|
595
|
+
<li>A Promise of the transaction response, or null if the allowance was already sufficient.</li>
|
|
596
|
+
</ul>
|
|
597
|
+
|
|
598
|
+
| Param | Type | Description |
|
|
599
|
+
| --- | --- | --- |
|
|
600
|
+
| signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
|
|
601
|
+
| tokenAddress | <code>string</code> | <p>The address of the ERC20 token to approve.</p> |
|
|
602
|
+
| spenderAddress | <code>string</code> | <p>The address of the spender to approve an allowance for.</p> |
|
|
603
|
+
| allowanceAmount | <code>BigNumber</code> | <p>The amount of tokens to approve, if applicable. Denominated in the ERC20 tokens.</p> |
|
|
604
|
+
| [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
|
|
605
|
+
|
|
557
606
|
<a name="getERC20TransferableReceivableContract"></a>
|
|
558
607
|
|
|
559
608
|
## getERC20TransferableReceivableContract(signerOrProvider, chainId) ⇒ <code>Contract</code> \| <code>null</code>
|
|
@@ -710,6 +759,91 @@ associated with the given pool name on the current chain.</p>
|
|
|
710
759
|
| signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The provider or signer instance to use for the contract.</p> |
|
|
711
760
|
| chainId | <code>number</code> | <p>The chain id where the contract instance exists</p> |
|
|
712
761
|
|
|
762
|
+
<a name="getReceivableBackedCreditLineContractV2"></a>
|
|
763
|
+
|
|
764
|
+
## getReceivableBackedCreditLineContractV2(signerOrProvider, poolName) ⇒ <code>ReceivableBackedCreditLine</code> \| <code>null</code>
|
|
765
|
+
<p>Returns an ethers contract instance for the V2 Receivable contract
|
|
766
|
+
associated with the given pool name on the current chain.</p>
|
|
767
|
+
|
|
768
|
+
**Kind**: global function
|
|
769
|
+
**Returns**: <code>ReceivableBackedCreditLine</code> \| <code>null</code> - <p>A contract instance for the ReceivableBackedCreditLine contract or null if it could not be found.</p>
|
|
770
|
+
|
|
771
|
+
| Param | Type | Description |
|
|
772
|
+
| --- | --- | --- |
|
|
773
|
+
| signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The provider or signer instance to use for the contract.</p> |
|
|
774
|
+
| poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool to get the contract instance for.</p> |
|
|
775
|
+
|
|
776
|
+
<a name="drawdownWithReceivable"></a>
|
|
777
|
+
|
|
778
|
+
## drawdownWithReceivable(signer, poolName, receivableId, drawdownAmount, [gasOpts]) ⇒ <code>Promise.<TransactionResponse></code>
|
|
779
|
+
<p>Draws down from a pool using a receivable.</p>
|
|
780
|
+
|
|
781
|
+
**Kind**: global function
|
|
782
|
+
**Returns**: <code>Promise.<TransactionResponse></code> - <ul>
|
|
783
|
+
<li>A Promise of the transaction response.</li>
|
|
784
|
+
</ul>
|
|
785
|
+
|
|
786
|
+
| Param | Type | Description |
|
|
787
|
+
| --- | --- | --- |
|
|
788
|
+
| signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
|
|
789
|
+
| poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool to drawdown from.</p> |
|
|
790
|
+
| receivableId | <code>BigNumberish</code> | <p>The ID of the receivable.</p> |
|
|
791
|
+
| drawdownAmount | <code>BigNumberish</code> | <p>The amount to drawdown.</p> |
|
|
792
|
+
| [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
|
|
793
|
+
|
|
794
|
+
<a name="makePaymentWithReceivable"></a>
|
|
795
|
+
|
|
796
|
+
## makePaymentWithReceivable(signer, poolName, receivableId, paymentAmount, principalOnly, [gasOpts]) ⇒ <code>Promise.<TransactionResponse></code>
|
|
797
|
+
<p>Makes a payment with a receivable.</p>
|
|
798
|
+
|
|
799
|
+
**Kind**: global function
|
|
800
|
+
**Returns**: <code>Promise.<TransactionResponse></code> - <ul>
|
|
801
|
+
<li>A Promise of the transaction response.</li>
|
|
802
|
+
</ul>
|
|
803
|
+
|
|
804
|
+
| Param | Type | Description |
|
|
805
|
+
| --- | --- | --- |
|
|
806
|
+
| signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
|
|
807
|
+
| poolName | <code>POOL\_NAME</code> | <p>The name of the pool to interact with.</p> |
|
|
808
|
+
| receivableId | <code>BigNumberish</code> | <p>The ID of the receivable.</p> |
|
|
809
|
+
| paymentAmount | <code>BigNumberish</code> | <p>The amount to payback.</p> |
|
|
810
|
+
| principalOnly | <code>boolean</code> | <p>Whether this payment should ONLY apply to the principal</p> |
|
|
811
|
+
| [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
|
|
812
|
+
|
|
813
|
+
<a name="makePrincipalPaymentAndDrawdownWithReceivable"></a>
|
|
814
|
+
|
|
815
|
+
## makePrincipalPaymentAndDrawdownWithReceivable(signer, poolName, paymentReceivableId, paymentAmount, drawdownReceivableId, drawdownAmount, [gasOpts]) ⇒ <code>Promise.<TransactionResponse></code>
|
|
816
|
+
<p>Makes a principal payment and drawdown with receivables.</p>
|
|
817
|
+
|
|
818
|
+
**Kind**: global function
|
|
819
|
+
**Returns**: <code>Promise.<TransactionResponse></code> - <ul>
|
|
820
|
+
<li>A Promise of the transaction response.</li>
|
|
821
|
+
</ul>
|
|
822
|
+
|
|
823
|
+
| Param | Type | Description |
|
|
824
|
+
| --- | --- | --- |
|
|
825
|
+
| signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
|
|
826
|
+
| poolName | <code>POOL\_NAME</code> | <p>The name of the pool to interact with.</p> |
|
|
827
|
+
| paymentReceivableId | <code>BigNumberish</code> | <p>The ID of the receivable for payment.</p> |
|
|
828
|
+
| paymentAmount | <code>BigNumberish</code> | <p>The amount to payback.</p> |
|
|
829
|
+
| drawdownReceivableId | <code>BigNumberish</code> | <p>The ID of the drawdown receivable.</p> |
|
|
830
|
+
| drawdownAmount | <code>BigNumberish</code> | <p>The amount to drawdown.</p> |
|
|
831
|
+
| [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
|
|
832
|
+
|
|
833
|
+
<a name="getReceivableContractV2"></a>
|
|
834
|
+
|
|
835
|
+
## getReceivableContractV2(signerOrProvider, chainId) ⇒ <code>Contract</code> \| <code>null</code>
|
|
836
|
+
<p>Returns an ethers contract instance for the V2 Receivable contract
|
|
837
|
+
associated with the given pool name on the current chain.</p>
|
|
838
|
+
|
|
839
|
+
**Kind**: global function
|
|
840
|
+
**Returns**: <code>Contract</code> \| <code>null</code> - <p>A contract instance for the Receivable contract or null if it could not be found.</p>
|
|
841
|
+
|
|
842
|
+
| Param | Type | Description |
|
|
843
|
+
| --- | --- | --- |
|
|
844
|
+
| signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The provider or signer instance to use for the contract.</p> |
|
|
845
|
+
| chainId | <code>number</code> | <p>The chain id where the contract instance exists</p> |
|
|
846
|
+
|
|
713
847
|
<a name="useContract"></a>
|
|
714
848
|
|
|
715
849
|
## useContract(address, ABI, signerOrProvider) ⇒ <code>T</code> \| <code>null</code>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BigNumberish, Overrides, ethers } from 'ethers';
|
|
2
|
+
import { TransactionResponse } from '@ethersproject/providers';
|
|
3
|
+
/**
|
|
4
|
+
* Approves an ERC20 allowance for a spender address, if the current allowance is insufficient.
|
|
5
|
+
* Allowance is required to do certain actions on the Huma protocol (e.g. makePayment)
|
|
6
|
+
*
|
|
7
|
+
* @async
|
|
8
|
+
* @function
|
|
9
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
10
|
+
* @param {string} tokenAddress - The address of the ERC20 token to approve.
|
|
11
|
+
* @param {string} spenderAddress - The address of the spender to approve an allowance for.
|
|
12
|
+
* @param {BigNumber} allowanceAmount - The amount of tokens to approve, if applicable. Denominated in the ERC20 tokens.
|
|
13
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
14
|
+
* @returns {Promise<TransactionResponse | null>} - A Promise of the transaction response, or null if the allowance was already sufficient.
|
|
15
|
+
*/
|
|
16
|
+
export declare function approveERC20AllowanceIfInsufficient(signer: ethers.Signer, tokenAddress: string, spenderAddress: string, allowanceAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse | null>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.approveERC20AllowanceIfInsufficient = void 0;
|
|
4
|
+
const shared_1 = require("@huma-finance/shared");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
/**
|
|
7
|
+
* Approves an ERC20 allowance for a spender address, if the current allowance is insufficient.
|
|
8
|
+
* Allowance is required to do certain actions on the Huma protocol (e.g. makePayment)
|
|
9
|
+
*
|
|
10
|
+
* @async
|
|
11
|
+
* @function
|
|
12
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
13
|
+
* @param {string} tokenAddress - The address of the ERC20 token to approve.
|
|
14
|
+
* @param {string} spenderAddress - The address of the spender to approve an allowance for.
|
|
15
|
+
* @param {BigNumber} allowanceAmount - The amount of tokens to approve, if applicable. Denominated in the ERC20 tokens.
|
|
16
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
17
|
+
* @returns {Promise<TransactionResponse | null>} - A Promise of the transaction response, or null if the allowance was already sufficient.
|
|
18
|
+
*/
|
|
19
|
+
async function approveERC20AllowanceIfInsufficient(signer, tokenAddress, spenderAddress, allowanceAmount, gasOpts = {}) {
|
|
20
|
+
const chainId = await (0, shared_1.getChainIdFromSignerOrProvider)(signer);
|
|
21
|
+
if (!chainId) {
|
|
22
|
+
throw new Error('Could not find chain ID');
|
|
23
|
+
}
|
|
24
|
+
const tokenContract = (0, utils_1.getERC20Contract)(tokenAddress, signer);
|
|
25
|
+
const allowance = await tokenContract.allowance(await signer.getAddress(), spenderAddress);
|
|
26
|
+
if (allowance.lt(allowanceAmount)) {
|
|
27
|
+
gasOpts = await (0, utils_1.getDefaultGasOptions)(gasOpts, chainId);
|
|
28
|
+
return tokenContract.approve(spenderAddress, allowanceAmount, gasOpts);
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
exports.approveERC20AllowanceIfInsufficient = approveERC20AllowanceIfInsufficient;
|
|
33
|
+
//# sourceMappingURL=ERC20ContractHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ERC20ContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/ERC20ContractHelper.ts"],"names":[],"mappings":";;;AACA,iDAAqE;AAErE,oCAAiE;AAEjE;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,mCAAmC,CACvD,MAAqB,EACrB,YAAoB,EACpB,cAAsB,EACtB,eAA6B,EAC7B,UAAqB,EAAE;IAEvB,MAAM,OAAO,GAAG,MAAM,IAAA,uCAA8B,EAAC,MAAM,CAAC,CAAA;IAE5D,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;KAC3C;IAED,MAAM,aAAa,GAAG,IAAA,wBAAgB,EAAC,YAAY,EAAE,MAAM,CAAC,CAAA;IAE5D,MAAM,SAAS,GAAG,MAAM,aAAa,CAAC,SAAS,CAC7C,MAAM,MAAM,CAAC,UAAU,EAAE,EACzB,cAAc,CACf,CAAA;IACD,IAAI,SAAS,CAAC,EAAE,CAAC,eAAe,CAAC,EAAE;QACjC,OAAO,GAAG,MAAM,IAAA,4BAAoB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACtD,OAAO,aAAa,CAAC,OAAO,CAAC,cAAc,EAAE,eAAe,EAAE,OAAO,CAAC,CAAA;KACvE;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAzBD,kFAyBC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
|
-
import { BigNumberish,
|
|
3
|
-
import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
|
|
2
|
+
import { BigNumberish, Overrides, ethers } from 'ethers';
|
|
3
|
+
import { BaseCreditPool, POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
|
|
4
4
|
import { TransactionResponse } from '@ethersproject/providers';
|
|
5
5
|
/**
|
|
6
6
|
* Returns an ethers contract instance for a Huma pool contract
|
|
@@ -11,7 +11,7 @@ import { TransactionResponse } from '@ethersproject/providers';
|
|
|
11
11
|
* @param {POOL_TYPE} poolType The type of the pool contract to get.
|
|
12
12
|
* @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
|
|
13
13
|
*/
|
|
14
|
-
export declare function getPoolContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE):
|
|
14
|
+
export declare function getPoolContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): BaseCreditPool | null;
|
|
15
15
|
/**
|
|
16
16
|
* Return type of getCreditRecord
|
|
17
17
|
*
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.approvePoolAllowance = exports.makePaymentToPool = exports.drawdownFromPool = exports.getTotalDue = exports.getCreditRecord = exports.getPoolContract = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
|
+
const ERC20ContractHelper_1 = require("./ERC20ContractHelper");
|
|
5
6
|
/**
|
|
6
7
|
* Returns an ethers contract instance for a Huma pool contract
|
|
7
8
|
*
|
|
@@ -75,7 +76,6 @@ async function drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmo
|
|
|
75
76
|
throw new Error('Could not find pool contract');
|
|
76
77
|
}
|
|
77
78
|
gasOpts = await (0, utils_1.getDefaultGasOptions)(gasOpts, chainId);
|
|
78
|
-
// TODO: Generate typechain for pool contract
|
|
79
79
|
return poolContract.drawdown(drawdownAmount, gasOpts);
|
|
80
80
|
}
|
|
81
81
|
exports.drawdownFromPool = drawdownFromPool;
|
|
@@ -98,19 +98,16 @@ async function makePaymentToPool(signer, chainId, poolName, poolType, paymentAmo
|
|
|
98
98
|
if (!(poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.poolUnderlyingToken.address)) {
|
|
99
99
|
throw new Error('Could not find pool underlying token address');
|
|
100
100
|
}
|
|
101
|
-
const poolTokenContract = (0, utils_1.getERC20Contract)(poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.poolUnderlyingToken.address, signer);
|
|
102
101
|
const poolContract = getPoolContract(signer, chainId, poolName, poolType);
|
|
103
102
|
if (!poolContract) {
|
|
104
103
|
throw new Error('Could not find pool contract');
|
|
105
104
|
}
|
|
106
105
|
gasOpts = await (0, utils_1.getDefaultGasOptions)(gasOpts, chainId);
|
|
107
|
-
const
|
|
108
|
-
if (
|
|
109
|
-
const approvalTx = await poolTokenContract.approve(poolContract.address, paymentAmount, gasOpts);
|
|
106
|
+
const approvalTx = await (0, ERC20ContractHelper_1.approveERC20AllowanceIfInsufficient)(signer, poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.poolUnderlyingToken.address, poolContract.address, paymentAmount, gasOpts);
|
|
107
|
+
if (approvalTx) {
|
|
110
108
|
// Wait for 5 block confirmations since this is required for makePayment
|
|
111
109
|
await approvalTx.wait(5);
|
|
112
110
|
}
|
|
113
|
-
// TODO: Generate typechain for pool contract
|
|
114
111
|
return poolContract.makePayment(await signer.getAddress(), paymentAmount, gasOpts);
|
|
115
112
|
}
|
|
116
113
|
exports.makePaymentToPool = makePaymentToPool;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":";;;AAKA,oCAKiB;
|
|
1
|
+
{"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":";;;AAKA,oCAKiB;AACjB,+DAA2E;AAE3E;;;;;;;;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,EAChB,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,OAAO,EAChB,gBAAgB,CACjB,CAAA;AACH,CAAC;AAfD,0CAeC;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,OAA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E,OAAO,CAAC,CAAA;IAEtD,OAAO,iBAAiB,CAAC,OAAO,CAC9B,YAAY,CAAC,OAAO,EACpB,eAAe,EACf,OAAO,CACR,CAAA;AACH,CAAC;AA7BD,oDA6BC"}
|
|
@@ -4,4 +4,6 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
tslib_1.__exportStar(require("./RealWorldReceivableContractHelper"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./ERC20TransferableReceivableContractHelper"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./PoolContractHelper"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./v2/ReceivableContractHelper"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./v2/ReceivableBackedCreditLineContractHelper"), exports);
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":";;;AAAA,8EAAmD;AACnD,sFAA2D;AAC3D,+DAAoC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":";;;AAAA,8EAAmD;AACnD,sFAA2D;AAC3D,+DAAoC;AACpC,wEAA6C;AAC7C,wFAA6D"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { JsonRpcProvider, TransactionResponse, Web3Provider } from '@ethersproject/providers';
|
|
2
|
+
import { POOL_NAME } from '@huma-finance/shared';
|
|
3
|
+
import { ReceivableBackedCreditLine } from '@huma-finance/shared/src/v2/abis/types';
|
|
4
|
+
import { BigNumberish, ethers, Overrides } from 'ethers';
|
|
5
|
+
/**
|
|
6
|
+
* Returns an ethers contract instance for the V2 Receivable contract
|
|
7
|
+
* associated with the given pool name on the current chain.
|
|
8
|
+
*
|
|
9
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
10
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
11
|
+
* @returns {ReceivableBackedCreditLine | null} A contract instance for the ReceivableBackedCreditLine contract or null if it could not be found.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getReceivableBackedCreditLineContractV2(poolName: POOL_NAME, signerOrProvider: JsonRpcProvider | Web3Provider | ethers.Signer): Promise<ReceivableBackedCreditLine | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Draws down from a pool using a receivable.
|
|
16
|
+
*
|
|
17
|
+
* @async
|
|
18
|
+
* @function
|
|
19
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
20
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to drawdown from.
|
|
21
|
+
* @param {BigNumberish} receivableId - The ID of the receivable.
|
|
22
|
+
* @param {BigNumberish} drawdownAmount - The amount to drawdown.
|
|
23
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
24
|
+
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
25
|
+
*/
|
|
26
|
+
export declare function drawdownWithReceivable(signer: ethers.Signer, poolName: POOL_NAME, receivableId: BigNumberish, drawdownAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* Makes a payment with a receivable.
|
|
29
|
+
*
|
|
30
|
+
* @async
|
|
31
|
+
* @function
|
|
32
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
33
|
+
* @param {POOL_NAME} poolName - The name of the pool to interact with.
|
|
34
|
+
* @param {BigNumberish} receivableId - The ID of the receivable.
|
|
35
|
+
* @param {BigNumberish} paymentAmount - The amount to payback.
|
|
36
|
+
* @param {boolean} principalOnly - Whether this payment should ONLY apply to the principal
|
|
37
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
38
|
+
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
39
|
+
*/
|
|
40
|
+
export declare function makePaymentWithReceivable(signer: ethers.Signer, poolName: POOL_NAME, receivableId: BigNumberish, paymentAmount: BigNumberish, principalOnly: boolean, gasOpts?: Overrides): Promise<TransactionResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Makes a principal payment and drawdown with receivables.
|
|
43
|
+
*
|
|
44
|
+
* @async
|
|
45
|
+
* @function
|
|
46
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
47
|
+
* @param {POOL_NAME} poolName - The name of the pool to interact with.
|
|
48
|
+
* @param {BigNumberish} paymentReceivableId - The ID of the receivable for payment.
|
|
49
|
+
* @param {BigNumberish} paymentAmount - The amount to payback.
|
|
50
|
+
* @param {BigNumberish} drawdownReceivableId - The ID of the drawdown receivable.
|
|
51
|
+
* @param {BigNumberish} drawdownAmount - The amount to drawdown.
|
|
52
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
53
|
+
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
54
|
+
*/
|
|
55
|
+
export declare function makePrincipalPaymentAndDrawdownWithReceivable(signer: ethers.Signer, poolName: POOL_NAME, paymentReceivableId: BigNumberish, paymentAmount: BigNumberish, drawdownReceivableId: BigNumberish, drawdownAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makePrincipalPaymentAndDrawdownWithReceivable = exports.makePaymentWithReceivable = exports.drawdownWithReceivable = exports.getReceivableBackedCreditLineContractV2 = void 0;
|
|
4
|
+
const shared_1 = require("@huma-finance/shared");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const ERC20ContractHelper_1 = require("../ERC20ContractHelper");
|
|
7
|
+
/**
|
|
8
|
+
* Returns an ethers contract instance for the V2 Receivable contract
|
|
9
|
+
* associated with the given pool name on the current chain.
|
|
10
|
+
*
|
|
11
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
12
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
13
|
+
* @returns {ReceivableBackedCreditLine | null} A contract instance for the ReceivableBackedCreditLine contract or null if it could not be found.
|
|
14
|
+
*/
|
|
15
|
+
async function getReceivableBackedCreditLineContractV2(poolName, signerOrProvider) {
|
|
16
|
+
const chainId = await (0, shared_1.getChainIdFromSignerOrProvider)(signerOrProvider);
|
|
17
|
+
const poolInfo = (0, shared_1.getPoolInfoV2)(poolName, chainId);
|
|
18
|
+
if (!poolInfo || poolInfo.poolType !== shared_1.POOL_TYPE.ReceivableBackedCreditLine) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return (0, utils_1.getContract)(poolInfo.poolCredit, shared_1.RECEIVABLE_BACKED_CREDIT_LINE_V2_ABI, signerOrProvider);
|
|
22
|
+
}
|
|
23
|
+
exports.getReceivableBackedCreditLineContractV2 = getReceivableBackedCreditLineContractV2;
|
|
24
|
+
/**
|
|
25
|
+
* Draws down from a pool using a receivable.
|
|
26
|
+
*
|
|
27
|
+
* @async
|
|
28
|
+
* @function
|
|
29
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
30
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to drawdown from.
|
|
31
|
+
* @param {BigNumberish} receivableId - The ID of the receivable.
|
|
32
|
+
* @param {BigNumberish} drawdownAmount - The amount to drawdown.
|
|
33
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
34
|
+
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
35
|
+
*/
|
|
36
|
+
async function drawdownWithReceivable(signer, poolName, receivableId, drawdownAmount, gasOpts = {}) {
|
|
37
|
+
const creditContract = await getReceivableBackedCreditLineContractV2(poolName, signer);
|
|
38
|
+
if (!creditContract) {
|
|
39
|
+
throw new Error('Could not find credit contract');
|
|
40
|
+
}
|
|
41
|
+
return creditContract.drawdownWithReceivable(await signer.getAddress(), receivableId, drawdownAmount, gasOpts);
|
|
42
|
+
}
|
|
43
|
+
exports.drawdownWithReceivable = drawdownWithReceivable;
|
|
44
|
+
/**
|
|
45
|
+
* Makes a payment with a receivable.
|
|
46
|
+
*
|
|
47
|
+
* @async
|
|
48
|
+
* @function
|
|
49
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
50
|
+
* @param {POOL_NAME} poolName - The name of the pool to interact with.
|
|
51
|
+
* @param {BigNumberish} receivableId - The ID of the receivable.
|
|
52
|
+
* @param {BigNumberish} paymentAmount - The amount to payback.
|
|
53
|
+
* @param {boolean} principalOnly - Whether this payment should ONLY apply to the principal
|
|
54
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
55
|
+
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
56
|
+
*/
|
|
57
|
+
async function makePaymentWithReceivable(signer, poolName, receivableId, paymentAmount, principalOnly, gasOpts = {}) {
|
|
58
|
+
const creditContract = await getReceivableBackedCreditLineContractV2(poolName, signer);
|
|
59
|
+
if (!creditContract) {
|
|
60
|
+
throw new Error('Could not find credit contract');
|
|
61
|
+
}
|
|
62
|
+
const underlyingToken = await (0, shared_1.getPoolUnderlyingTokenContractV2)(poolName, signer.provider);
|
|
63
|
+
if (underlyingToken) {
|
|
64
|
+
await (0, ERC20ContractHelper_1.approveERC20AllowanceIfInsufficient)(signer, underlyingToken.address, creditContract.address, paymentAmount, gasOpts);
|
|
65
|
+
}
|
|
66
|
+
let paymentTx;
|
|
67
|
+
if (principalOnly) {
|
|
68
|
+
paymentTx = await creditContract.makePrincipalPaymentWithReceivable(await signer.getAddress(), receivableId, paymentAmount, gasOpts);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
paymentTx = await creditContract.makePaymentWithReceivable(await signer.getAddress(), receivableId, paymentAmount, gasOpts);
|
|
72
|
+
}
|
|
73
|
+
return paymentTx;
|
|
74
|
+
}
|
|
75
|
+
exports.makePaymentWithReceivable = makePaymentWithReceivable;
|
|
76
|
+
/**
|
|
77
|
+
* Makes a principal payment and drawdown with receivables.
|
|
78
|
+
*
|
|
79
|
+
* @async
|
|
80
|
+
* @function
|
|
81
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
82
|
+
* @param {POOL_NAME} poolName - The name of the pool to interact with.
|
|
83
|
+
* @param {BigNumberish} paymentReceivableId - The ID of the receivable for payment.
|
|
84
|
+
* @param {BigNumberish} paymentAmount - The amount to payback.
|
|
85
|
+
* @param {BigNumberish} drawdownReceivableId - The ID of the drawdown receivable.
|
|
86
|
+
* @param {BigNumberish} drawdownAmount - The amount to drawdown.
|
|
87
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
88
|
+
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
89
|
+
*/
|
|
90
|
+
async function makePrincipalPaymentAndDrawdownWithReceivable(signer, poolName, paymentReceivableId, paymentAmount, drawdownReceivableId, drawdownAmount, gasOpts = {}) {
|
|
91
|
+
const creditContract = await getReceivableBackedCreditLineContractV2(poolName, signer);
|
|
92
|
+
if (!creditContract) {
|
|
93
|
+
throw new Error('Could not find credit contract');
|
|
94
|
+
}
|
|
95
|
+
const underlyingToken = await (0, shared_1.getPoolUnderlyingTokenContractV2)(poolName, signer.provider);
|
|
96
|
+
if (underlyingToken) {
|
|
97
|
+
await (0, ERC20ContractHelper_1.approveERC20AllowanceIfInsufficient)(signer, underlyingToken.address, creditContract.address, paymentAmount, gasOpts);
|
|
98
|
+
}
|
|
99
|
+
return creditContract.makePrincipalPaymentAndDrawdownWithReceivable(await signer.getAddress(), paymentReceivableId, paymentAmount, drawdownReceivableId, drawdownAmount, gasOpts);
|
|
100
|
+
}
|
|
101
|
+
exports.makePrincipalPaymentAndDrawdownWithReceivable = makePrincipalPaymentAndDrawdownWithReceivable;
|
|
102
|
+
//# sourceMappingURL=ReceivableBackedCreditLineContractHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReceivableBackedCreditLineContractHelper.js","sourceRoot":"","sources":["../../../../src/helpers/v2/ReceivableBackedCreditLineContractHelper.ts"],"names":[],"mappings":";;;AAKA,iDAO6B;AAG7B,uCAAyC;AACzC,gEAA4E;AAE5E;;;;;;;GAOG;AACI,KAAK,UAAU,uCAAuC,CAC3D,QAAmB,EACnB,gBAAgE;IAEhE,MAAM,OAAO,GAAG,MAAM,IAAA,uCAA8B,EAAC,gBAAgB,CAAC,CAAA;IACtE,MAAM,QAAQ,GAAG,IAAA,sBAAa,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IACjD,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ,KAAK,kBAAS,CAAC,0BAA0B,EAAE;QAC3E,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,IAAA,mBAAW,EAChB,QAAQ,CAAC,UAAU,EACnB,6CAAoC,EACpC,gBAAgB,CACjB,CAAA;AACH,CAAC;AAfD,0FAeC;AAED;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,sBAAsB,CAC1C,MAAqB,EACrB,QAAmB,EACnB,YAA0B,EAC1B,cAA4B,EAC5B,UAAqB,EAAE;IAEvB,MAAM,cAAc,GAAG,MAAM,uCAAuC,CAClE,QAAQ,EACR,MAAM,CACP,CAAA;IAED,IAAI,CAAC,cAAc,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;KAClD;IAED,OAAO,cAAc,CAAC,sBAAsB,CAC1C,MAAM,MAAM,CAAC,UAAU,EAAE,EACzB,YAAY,EACZ,cAAc,EACd,OAAO,CACR,CAAA;AACH,CAAC;AAtBD,wDAsBC;AAED;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,yBAAyB,CAC7C,MAAqB,EACrB,QAAmB,EACnB,YAA0B,EAC1B,aAA2B,EAC3B,aAAsB,EACtB,UAAqB,EAAE;IAEvB,MAAM,cAAc,GAAG,MAAM,uCAAuC,CAClE,QAAQ,EACR,MAAM,CACP,CAAA;IAED,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AAA;KACF;IAED,OAAO,cAAc,CAAC,6CAA6C,CACjE,MAAM,MAAM,CAAC,UAAU,EAAE,EACzB,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,OAAO,CACR,CAAA;AACH,CAAC;AAzCD,sGAyCC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BigNumber, ethers } from 'ethers';
|
|
2
|
+
import { POOL_NAME, v2Contracts } from '@huma-finance/shared';
|
|
3
|
+
import { JsonRpcProvider, Web3Provider } from '@ethersproject/providers';
|
|
4
|
+
/**
|
|
5
|
+
* Returns an ethers contract instance for the V2 Receivable contract
|
|
6
|
+
* associated with the given pool name on the current chain.
|
|
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
|
+
* @returns {Contract | null} A contract instance for the Receivable contract or null if it could not be found.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getReceivableContractV2(poolName: POOL_NAME, signerOrProvider: JsonRpcProvider | Web3Provider | ethers.Signer): Promise<v2Contracts.Receivable | null>;
|
|
13
|
+
export declare function getReceivableTokenIdFromReferenceId(referenceId: string, creator: string, poolName: POOL_NAME, provider: JsonRpcProvider | Web3Provider): Promise<BigNumber>;
|
|
14
|
+
export declare function getReceivableReferenceAlreadyExists(referenceId: string, signerAddress: string, poolName: POOL_NAME, provider: JsonRpcProvider | Web3Provider): Promise<boolean>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getReceivableReferenceAlreadyExists = exports.getReceivableTokenIdFromReferenceId = exports.getReceivableContractV2 = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const shared_1 = require("@huma-finance/shared");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
/**
|
|
8
|
+
* Returns an ethers contract instance for the V2 Receivable contract
|
|
9
|
+
* associated with the given pool name on the current chain.
|
|
10
|
+
*
|
|
11
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
12
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
13
|
+
* @returns {Contract | null} A contract instance for the Receivable contract or null if it could not be found.
|
|
14
|
+
*/
|
|
15
|
+
async function getReceivableContractV2(poolName, signerOrProvider) {
|
|
16
|
+
let provider;
|
|
17
|
+
if (signerOrProvider instanceof ethers_1.ethers.Signer) {
|
|
18
|
+
provider = signerOrProvider.provider;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
provider = signerOrProvider;
|
|
22
|
+
}
|
|
23
|
+
const poolConfigContract = await (0, shared_1.getPoolConfigContractV2)(poolName, provider);
|
|
24
|
+
if (!poolConfigContract) {
|
|
25
|
+
throw new Error('Could not find PoolConfig contract');
|
|
26
|
+
}
|
|
27
|
+
const receivableAsset = await poolConfigContract.receivableAsset();
|
|
28
|
+
return (0, utils_1.getContract)(receivableAsset, shared_1.RECEIVABLE_V2_ABI, signerOrProvider);
|
|
29
|
+
}
|
|
30
|
+
exports.getReceivableContractV2 = getReceivableContractV2;
|
|
31
|
+
async function getReceivableTokenIdFromReferenceId(referenceId, creator, poolName, provider) {
|
|
32
|
+
const contract = await getReceivableContractV2(poolName, provider);
|
|
33
|
+
if (!contract) {
|
|
34
|
+
throw new Error('Could not find Receivable contract');
|
|
35
|
+
}
|
|
36
|
+
const referenceIdHash = await contract.getReferenceIdHash(referenceId, creator);
|
|
37
|
+
return contract.referenceIdHashToTokenId(referenceIdHash);
|
|
38
|
+
}
|
|
39
|
+
exports.getReceivableTokenIdFromReferenceId = getReceivableTokenIdFromReferenceId;
|
|
40
|
+
async function getReceivableReferenceAlreadyExists(referenceId, signerAddress, poolName, provider) {
|
|
41
|
+
const tokenId = await getReceivableTokenIdFromReferenceId(referenceId, signerAddress, poolName, provider);
|
|
42
|
+
return !tokenId.isZero();
|
|
43
|
+
}
|
|
44
|
+
exports.getReceivableReferenceAlreadyExists = getReceivableReferenceAlreadyExists;
|
|
45
|
+
//# sourceMappingURL=ReceivableContractHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReceivableContractHelper.js","sourceRoot":"","sources":["../../../../src/helpers/v2/ReceivableContractHelper.ts"],"names":[],"mappings":";;;AAAA,mCAA0C;AAC1C,iDAK6B;AAG7B,uCAAyC;AAEzC;;;;;;;GAOG;AACI,KAAK,UAAU,uBAAuB,CAC3C,QAAmB,EACnB,gBAAgE;IAEhE,IAAI,QAAQ,CAAA;IACZ,IAAI,gBAAgB,YAAY,eAAM,CAAC,MAAM,EAAE;QAC7C,QAAQ,GAAG,gBAAgB,CAAC,QAA0C,CAAA;KACvE;SAAM;QACL,QAAQ,GAAG,gBAAgB,CAAA;KAC5B;IAED,MAAM,kBAAkB,GAAG,MAAM,IAAA,gCAAuB,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAE5E,IAAI,CAAC,kBAAkB,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;KACtD;IAED,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAAC,eAAe,EAAE,CAAA;IAElE,OAAO,IAAA,mBAAW,EAChB,eAAe,EACf,0BAAiB,EACjB,gBAAgB,CACjB,CAAA;AACH,CAAC;AAxBD,0DAwBC;AAEM,KAAK,UAAU,mCAAmC,CACvD,WAAmB,EACnB,OAAe,EACf,QAAmB,EACnB,QAAwC;IAExC,MAAM,QAAQ,GAAG,MAAM,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAClE,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;KACtD;IAED,MAAM,eAAe,GAAG,MAAM,QAAQ,CAAC,kBAAkB,CACvD,WAAW,EACX,OAAO,CACR,CAAA;IAED,OAAO,QAAQ,CAAC,wBAAwB,CAAC,eAAe,CAAC,CAAA;AAC3D,CAAC;AAjBD,kFAiBC;AAEM,KAAK,UAAU,mCAAmC,CACvD,WAAmB,EACnB,aAAqB,EACrB,QAAmB,EACnB,QAAwC;IAExC,MAAM,OAAO,GAAG,MAAM,mCAAmC,CACvD,WAAW,EACX,aAAa,EACb,QAAQ,EACR,QAAQ,CACT,CAAA;IAED,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,CAAA;AAC1B,CAAC;AAdD,kFAcC"}
|
|
@@ -49,7 +49,6 @@ async function getTokenIdByURI(signer, uri) {
|
|
|
49
49
|
uri,
|
|
50
50
|
});
|
|
51
51
|
if (!((_b = receivablesData === null || receivablesData === void 0 ? void 0 : receivablesData.rwreceivables) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
52
|
-
console.log('No receivables found with this URI.');
|
|
53
52
|
return null;
|
|
54
53
|
}
|
|
55
54
|
if (((_c = receivablesData === null || receivablesData === void 0 ? void 0 : receivablesData.rwreceivables) === null || _c === void 0 ? void 0 : _c.length) > 1) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReceivableService.js","sourceRoot":"","sources":["../../../src/services/ReceivableService.ts"],"names":[],"mappings":";;;AACA,mCAAwD;AACxD,iDAS6B;AAC7B,qDAA8C;AAE9C,qDAAiD;AACjD,wCAA2D;AAC3D,oCAA+E;AAE/E,uDAA+D;AAE/D;;;;;;;;;GASG;AACH,KAAK,UAAU,eAAe,CAC5B,MAAqB,EACrB,GAAkB;;IAElB,IAAI,GAAG,KAAK,IAAI,EAAE;QAChB,OAAO,IAAI,CAAA;KACZ;IAED,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,CAA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