@huma-finance/sdk 0.0.36 → 0.0.38-beta.0
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 +0 -189
- package/package.json +3 -3
- package/dist/cjs/graphql/generatedTypes.d.ts +0 -40
- package/dist/cjs/graphql/generatedTypes.js +0 -9
- package/dist/cjs/graphql/generatedTypes.js.map +0 -1
- package/dist/cjs/graphql/index.d.ts +0 -1
- package/dist/cjs/graphql/index.js +0 -5
- package/dist/cjs/graphql/index.js.map +0 -1
- package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.d.ts +0 -10
- package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js +0 -22
- package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js.map +0 -1
- package/dist/cjs/helpers/PoolContractHelper.d.ts +0 -119
- package/dist/cjs/helpers/PoolContractHelper.js +0 -144
- package/dist/cjs/helpers/PoolContractHelper.js.map +0 -1
- package/dist/cjs/helpers/RealWorldReceivableContractHelper.d.ts +0 -10
- package/dist/cjs/helpers/RealWorldReceivableContractHelper.js +0 -22
- package/dist/cjs/helpers/RealWorldReceivableContractHelper.js.map +0 -1
- package/dist/cjs/helpers/index.d.ts +0 -3
- package/dist/cjs/helpers/index.js +0 -7
- package/dist/cjs/helpers/index.js.map +0 -1
- package/dist/cjs/hooks/index.d.ts +0 -4
- package/dist/cjs/hooks/index.js +0 -8
- package/dist/cjs/hooks/index.js.map +0 -1
- package/dist/cjs/hooks/useContract.d.ts +0 -13
- package/dist/cjs/hooks/useContract.js +0 -31
- package/dist/cjs/hooks/useContract.js.map +0 -1
- package/dist/cjs/hooks/useERC20TransferableReceivableContract.d.ts +0 -12
- package/dist/cjs/hooks/useERC20TransferableReceivableContract.js +0 -21
- package/dist/cjs/hooks/useERC20TransferableReceivableContract.js.map +0 -1
- package/dist/cjs/hooks/usePoolContract.d.ts +0 -60
- package/dist/cjs/hooks/usePoolContract.js +0 -54
- package/dist/cjs/hooks/usePoolContract.js.map +0 -1
- package/dist/cjs/hooks/useRealWorldReceivableContract.d.ts +0 -10
- package/dist/cjs/hooks/useRealWorldReceivableContract.js +0 -20
- package/dist/cjs/hooks/useRealWorldReceivableContract.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -4
- package/dist/cjs/index.js +0 -8
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/services/ARWeaveService.d.ts +0 -106
- package/dist/cjs/services/ARWeaveService.js +0 -191
- package/dist/cjs/services/ARWeaveService.js.map +0 -1
- package/dist/cjs/services/EAService.d.ts +0 -20
- package/dist/cjs/services/EAService.js +0 -34
- package/dist/cjs/services/EAService.js.map +0 -1
- package/dist/cjs/services/ReceivableService.d.ts +0 -104
- package/dist/cjs/services/ReceivableService.js +0 -309
- package/dist/cjs/services/ReceivableService.js.map +0 -1
- package/dist/cjs/services/SubgraphService.d.ts +0 -53
- package/dist/cjs/services/SubgraphService.js +0 -94
- package/dist/cjs/services/SubgraphService.js.map +0 -1
- package/dist/cjs/services/index.d.ts +0 -4
- package/dist/cjs/services/index.js +0 -8
- package/dist/cjs/services/index.js.map +0 -1
- package/dist/cjs/utils/chain.d.ts +0 -15
- package/dist/cjs/utils/chain.js +0 -38
- package/dist/cjs/utils/chain.js.map +0 -1
- package/dist/cjs/utils/index.d.ts +0 -4
- package/dist/cjs/utils/index.js +0 -8
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/cjs/utils/maticGasStation.d.ts +0 -3
- package/dist/cjs/utils/maticGasStation.js +0 -39
- package/dist/cjs/utils/maticGasStation.js.map +0 -1
- package/dist/cjs/utils/poolInfo.d.ts +0 -8
- package/dist/cjs/utils/poolInfo.js +0 -13
- package/dist/cjs/utils/poolInfo.js.map +0 -1
- package/dist/cjs/utils/web3.d.ts +0 -5
- package/dist/cjs/utils/web3.js +0 -34
- package/dist/cjs/utils/web3.js.map +0 -1
- package/dist/graphql/generatedTypes.d.ts +0 -40
- package/dist/graphql/generatedTypes.js +0 -5
- package/dist/graphql/generatedTypes.js.map +0 -1
- package/dist/graphql/index.d.ts +0 -1
- package/dist/graphql/index.js +0 -2
- package/dist/graphql/index.js.map +0 -1
- package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +0 -10
- package/dist/helpers/ERC20TransferableReceivableContractHelper.js +0 -18
- package/dist/helpers/ERC20TransferableReceivableContractHelper.js.map +0 -1
- package/dist/helpers/PoolContractHelper.d.ts +0 -119
- package/dist/helpers/PoolContractHelper.js +0 -135
- package/dist/helpers/PoolContractHelper.js.map +0 -1
- package/dist/helpers/RealWorldReceivableContractHelper.d.ts +0 -10
- package/dist/helpers/RealWorldReceivableContractHelper.js +0 -18
- package/dist/helpers/RealWorldReceivableContractHelper.js.map +0 -1
- package/dist/helpers/index.d.ts +0 -3
- package/dist/helpers/index.js +0 -4
- package/dist/helpers/index.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -4
- package/dist/hooks/index.js +0 -5
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/useContract.d.ts +0 -13
- package/dist/hooks/useContract.js +0 -27
- package/dist/hooks/useContract.js.map +0 -1
- package/dist/hooks/useERC20TransferableReceivableContract.d.ts +0 -12
- package/dist/hooks/useERC20TransferableReceivableContract.js +0 -17
- package/dist/hooks/useERC20TransferableReceivableContract.js.map +0 -1
- package/dist/hooks/usePoolContract.d.ts +0 -60
- package/dist/hooks/usePoolContract.js +0 -49
- package/dist/hooks/usePoolContract.js.map +0 -1
- package/dist/hooks/useRealWorldReceivableContract.d.ts +0 -10
- package/dist/hooks/useRealWorldReceivableContract.js +0 -16
- package/dist/hooks/useRealWorldReceivableContract.js.map +0 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -5
- package/dist/index.js.map +0 -1
- package/dist/services/ARWeaveService.d.ts +0 -106
- package/dist/services/ARWeaveService.js +0 -186
- package/dist/services/ARWeaveService.js.map +0 -1
- package/dist/services/EAService.d.ts +0 -20
- package/dist/services/EAService.js +0 -31
- package/dist/services/EAService.js.map +0 -1
- package/dist/services/ReceivableService.d.ts +0 -104
- package/dist/services/ReceivableService.js +0 -306
- package/dist/services/ReceivableService.js.map +0 -1
- package/dist/services/SubgraphService.d.ts +0 -53
- package/dist/services/SubgraphService.js +0 -91
- package/dist/services/SubgraphService.js.map +0 -1
- package/dist/services/index.d.ts +0 -4
- package/dist/services/index.js +0 -5
- package/dist/services/index.js.map +0 -1
- package/dist/tsconfig.cjs.tsbuildinfo +0 -1
- package/dist/utils/chain.d.ts +0 -15
- package/dist/utils/chain.js +0 -32
- package/dist/utils/chain.js.map +0 -1
- package/dist/utils/index.d.ts +0 -4
- package/dist/utils/index.js +0 -5
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/maticGasStation.d.ts +0 -3
- package/dist/utils/maticGasStation.js +0 -34
- package/dist/utils/maticGasStation.js.map +0 -1
- package/dist/utils/poolInfo.d.ts +0 -8
- package/dist/utils/poolInfo.js +0 -9
- package/dist/utils/poolInfo.js.map +0 -1
- package/dist/utils/web3.d.ts +0 -5
- package/dist/utils/web3.js +0 -28
- package/dist/utils/web3.js.map +0 -1
package/API.md
CHANGED
|
@@ -54,19 +54,6 @@ Note that this does not approve a creditline in Huma's pools and an approve call
|
|
|
54
54
|
<dd><p>Get the chain ID from a signer or provider object.</p></dd>
|
|
55
55
|
<dt><a href="#getPoolInfo">getPoolInfo(poolName, poolType)</a> ⇒ <code>PoolInfoType</code> | <code>undefined</code></dt>
|
|
56
56
|
<dd><p>Returns the pool info based on the provided pool name and type, using the same chain ID as the provider/signer given</p></dd>
|
|
57
|
-
<dt><a href="#getPoolContract">getPoolContract(signerOrProvider, chainId, poolName, poolType)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
|
|
58
|
-
<dd><p>Returns an ethers contract instance for a Huma pool contract</p></dd>
|
|
59
|
-
<dt><a href="#getCreditRecord">getCreditRecord(address, signerOrProvider, chainId, poolName, poolType)</a> ⇒ <code>Promise.<CreditRecord></code></dt>
|
|
60
|
-
<dd><p>Gets the credit record of a wallet in a Huma pool. Denominated in the ERC20 tokens of the pool.</p></dd>
|
|
61
|
-
<dt><a href="#getTotalDue">getTotalDue(address, signerOrProvider, chainId, poolName, poolType)</a> ⇒ <code>Promise.<BigNumber></code></dt>
|
|
62
|
-
<dd><p>Gets the total due for a Huma pool of the given wallet. Denominated in the ERC20 tokens of the pool.</p></dd>
|
|
63
|
-
<dt><a href="#drawdownFromPool">drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, [gasOpts])</a> ⇒ <code>Promise.<TransactionResponse></code></dt>
|
|
64
|
-
<dd><p>Calls drawdown on a Huma pool contract</p></dd>
|
|
65
|
-
<dt><a href="#makePaymentToPool">makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, [gasOpts])</a> ⇒ <code>Promise.<TransactionResponse></code></dt>
|
|
66
|
-
<dd><p>Calls makePayment on a Huma pool contract. If the pool does not have sufficient allowance to complete the operation,
|
|
67
|
-
attempt to first increase the allowance of the pool.</p></dd>
|
|
68
|
-
<dt><a href="#approvePoolAllowance">approvePoolAllowance(signer, chainId, poolName, poolType, allowanceAmount, [gasOpts])</a> ⇒ <code>Promise.<TransactionResponse></code></dt>
|
|
69
|
-
<dd><p>Approves an allowance for a Huma pool contract, which is required to do certain actions (e.g. makePayment)</p></dd>
|
|
70
57
|
</dl>
|
|
71
58
|
|
|
72
59
|
## Typedefs
|
|
@@ -417,30 +404,6 @@ associated with the given pool name on the current chain.</p>
|
|
|
417
404
|
| poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool. Used to lookup the pool address.</p> |
|
|
418
405
|
| poolType | <code>POOL\_TYPE</code> | <p>The type of the credit pool. Used to lookup the pool address.</p> |
|
|
419
406
|
|
|
420
|
-
|
|
421
|
-
* [getCreditRecord(address, signerOrProvider, chainId, poolName, poolType)](#getCreditRecord) ⇒ <code>Promise.<CreditRecord></code>
|
|
422
|
-
* [.CreditRecord](#getCreditRecord.CreditRecord) : <code>Object</code>
|
|
423
|
-
* [.CreditRecord](#getCreditRecord.CreditRecord) : <code>Object</code>
|
|
424
|
-
|
|
425
|
-
<a name="getCreditRecord.CreditRecord"></a>
|
|
426
|
-
|
|
427
|
-
### getCreditRecord.CreditRecord : <code>Object</code>
|
|
428
|
-
<p>Return type of getCreditRecord</p>
|
|
429
|
-
|
|
430
|
-
**Kind**: static typedef of [<code>getCreditRecord</code>](#getCreditRecord)
|
|
431
|
-
**Properties**
|
|
432
|
-
|
|
433
|
-
| Name | Type | Description |
|
|
434
|
-
| --- | --- | --- |
|
|
435
|
-
| unbilledPrincipal | <code>BigNumber</code> | <p>The amount of principal not included in the bill</p> |
|
|
436
|
-
| dueDate | <code>BigNumber</code> | <p>Unix timestamp due date of the next payment</p> |
|
|
437
|
-
| correction | <code>BigNumber</code> | <p>the adjustment of interest over or under-counted because of drawdown or principal payment in the middle of a billing period</p> |
|
|
438
|
-
| totalDue | <code>BigNumber</code> | <p>The due amount of the next payment</p> |
|
|
439
|
-
| feesAndInterestDue | <code>BigNumber</code> | <p>Interest and fees due for the next payment</p> |
|
|
440
|
-
| missedPeriods | <code>number</code> | <h1>of consecutive missed payments, for default processing</h1> |
|
|
441
|
-
| remainingPeriods | <code>number</code> | <h1>of payment periods until the maturity of the credit line</h1> |
|
|
442
|
-
| state | <code>number</code> | <p>status of the credit line. For more info: https://github.com/00labs/huma-contracts/blob/b075a8f957de281e0885e37dbd72a422b6a54a38/contracts/libraries/BaseStructs.sol#L49</p> |
|
|
443
|
-
|
|
444
407
|
<a name="getCreditRecord.CreditRecord"></a>
|
|
445
408
|
|
|
446
409
|
### getCreditRecord.CreditRecord : <code>Object</code>
|
|
@@ -650,158 +613,6 @@ Note that this does not approve a creditline in Huma's pools and an approve call
|
|
|
650
613
|
| poolName | <code>POOL\_NAME</code> | <p>The name of the pool.</p> |
|
|
651
614
|
| poolType | <code>POOL\_TYPE</code> | <p>The type of the pool.</p> |
|
|
652
615
|
|
|
653
|
-
<a name="getPoolContract"></a>
|
|
654
|
-
|
|
655
|
-
## getPoolContract(signerOrProvider, chainId, poolName, poolType) ⇒ <code>Contract</code> \| <code>null</code>
|
|
656
|
-
<p>Returns an ethers contract instance for a Huma pool contract</p>
|
|
657
|
-
|
|
658
|
-
**Kind**: global function
|
|
659
|
-
**Returns**: <code>Contract</code> \| <code>null</code> - <p>A contract instance for the Pool contract or null if it could not be found.</p>
|
|
660
|
-
|
|
661
|
-
| Param | Type | Description |
|
|
662
|
-
| --- | --- | --- |
|
|
663
|
-
| signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The provider or signer instance to use for the contract.</p> |
|
|
664
|
-
| chainId | <code>number</code> | <p>The chain id where the contract instance exists</p> |
|
|
665
|
-
| poolName | <code>POOL\_NAME</code> | <p>The name of the pool contract to get.</p> |
|
|
666
|
-
| poolType | <code>POOL\_TYPE</code> | <p>The type of the pool contract to get.</p> |
|
|
667
|
-
|
|
668
|
-
<a name="getCreditRecord"></a>
|
|
669
|
-
|
|
670
|
-
## getCreditRecord(address, signerOrProvider, chainId, poolName, poolType) ⇒ <code>Promise.<CreditRecord></code>
|
|
671
|
-
<p>Gets the credit record of a wallet in a Huma pool. Denominated in the ERC20 tokens of the pool.</p>
|
|
672
|
-
|
|
673
|
-
**Kind**: global function
|
|
674
|
-
**Returns**: <code>Promise.<CreditRecord></code> - <ul>
|
|
675
|
-
<li>A Promise of the transaction response.</li>
|
|
676
|
-
</ul>
|
|
677
|
-
|
|
678
|
-
| Param | Type | Description |
|
|
679
|
-
| --- | --- | --- |
|
|
680
|
-
| address | <code>string</code> | <p>The address to lookup.</p> |
|
|
681
|
-
| signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The signer or provider used to read data.</p> |
|
|
682
|
-
| chainId | <code>number</code> | <p>The chain ID of the pool. Used to lookup the pool address.</p> |
|
|
683
|
-
| poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool. Used to lookup the pool address.</p> |
|
|
684
|
-
| poolType | <code>POOL\_TYPE</code> | <p>The type of the credit pool. Used to lookup the pool address.</p> |
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
* [getCreditRecord(address, signerOrProvider, chainId, poolName, poolType)](#getCreditRecord) ⇒ <code>Promise.<CreditRecord></code>
|
|
688
|
-
* [.CreditRecord](#getCreditRecord.CreditRecord) : <code>Object</code>
|
|
689
|
-
* [.CreditRecord](#getCreditRecord.CreditRecord) : <code>Object</code>
|
|
690
|
-
|
|
691
|
-
<a name="getCreditRecord.CreditRecord"></a>
|
|
692
|
-
|
|
693
|
-
### getCreditRecord.CreditRecord : <code>Object</code>
|
|
694
|
-
<p>Return type of getCreditRecord</p>
|
|
695
|
-
|
|
696
|
-
**Kind**: static typedef of [<code>getCreditRecord</code>](#getCreditRecord)
|
|
697
|
-
**Properties**
|
|
698
|
-
|
|
699
|
-
| Name | Type | Description |
|
|
700
|
-
| --- | --- | --- |
|
|
701
|
-
| unbilledPrincipal | <code>BigNumber</code> | <p>The amount of principal not included in the bill</p> |
|
|
702
|
-
| dueDate | <code>BigNumber</code> | <p>Unix timestamp due date of the next payment</p> |
|
|
703
|
-
| correction | <code>BigNumber</code> | <p>the adjustment of interest over or under-counted because of drawdown or principal payment in the middle of a billing period</p> |
|
|
704
|
-
| totalDue | <code>BigNumber</code> | <p>The due amount of the next payment</p> |
|
|
705
|
-
| feesAndInterestDue | <code>BigNumber</code> | <p>Interest and fees due for the next payment</p> |
|
|
706
|
-
| missedPeriods | <code>number</code> | <h1>of consecutive missed payments, for default processing</h1> |
|
|
707
|
-
| remainingPeriods | <code>number</code> | <h1>of payment periods until the maturity of the credit line</h1> |
|
|
708
|
-
| state | <code>number</code> | <p>status of the credit line. For more info: https://github.com/00labs/huma-contracts/blob/b075a8f957de281e0885e37dbd72a422b6a54a38/contracts/libraries/BaseStructs.sol#L49</p> |
|
|
709
|
-
|
|
710
|
-
<a name="getCreditRecord.CreditRecord"></a>
|
|
711
|
-
|
|
712
|
-
### getCreditRecord.CreditRecord : <code>Object</code>
|
|
713
|
-
<p>Return type of getCreditRecord</p>
|
|
714
|
-
|
|
715
|
-
**Kind**: static typedef of [<code>getCreditRecord</code>](#getCreditRecord)
|
|
716
|
-
**Properties**
|
|
717
|
-
|
|
718
|
-
| Name | Type | Description |
|
|
719
|
-
| --- | --- | --- |
|
|
720
|
-
| unbilledPrincipal | <code>BigNumber</code> | <p>The amount of principal not included in the bill</p> |
|
|
721
|
-
| dueDate | <code>BigNumber</code> | <p>Unix timestamp due date of the next payment</p> |
|
|
722
|
-
| correction | <code>BigNumber</code> | <p>the adjustment of interest over or under-counted because of drawdown or principal payment in the middle of a billing period</p> |
|
|
723
|
-
| totalDue | <code>BigNumber</code> | <p>The due amount of the next payment</p> |
|
|
724
|
-
| feesAndInterestDue | <code>BigNumber</code> | <p>Interest and fees due for the next payment</p> |
|
|
725
|
-
| missedPeriods | <code>number</code> | <h1>of consecutive missed payments, for default processing</h1> |
|
|
726
|
-
| remainingPeriods | <code>number</code> | <h1>of payment periods until the maturity of the credit line</h1> |
|
|
727
|
-
| state | <code>number</code> | <p>status of the credit line. For more info: https://github.com/00labs/huma-contracts/blob/b075a8f957de281e0885e37dbd72a422b6a54a38/contracts/libraries/BaseStructs.sol#L49</p> |
|
|
728
|
-
|
|
729
|
-
<a name="getTotalDue"></a>
|
|
730
|
-
|
|
731
|
-
## getTotalDue(address, signerOrProvider, chainId, poolName, poolType) ⇒ <code>Promise.<BigNumber></code>
|
|
732
|
-
<p>Gets the total due for a Huma pool of the given wallet. Denominated in the ERC20 tokens of the pool.</p>
|
|
733
|
-
|
|
734
|
-
**Kind**: global function
|
|
735
|
-
**Returns**: <code>Promise.<BigNumber></code> - <ul>
|
|
736
|
-
<li>A Promise of the transaction response.</li>
|
|
737
|
-
</ul>
|
|
738
|
-
|
|
739
|
-
| Param | Type | Description |
|
|
740
|
-
| --- | --- | --- |
|
|
741
|
-
| address | <code>string</code> | <p>The address to lookup.</p> |
|
|
742
|
-
| signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The signer or provider used to read data.</p> |
|
|
743
|
-
| chainId | <code>number</code> | <p>The chain ID of the pool. Used to lookup the pool address.</p> |
|
|
744
|
-
| poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool. Used to lookup the pool address.</p> |
|
|
745
|
-
| poolType | <code>POOL\_TYPE</code> | <p>The type of the credit pool. Used to lookup the pool address.</p> |
|
|
746
|
-
|
|
747
|
-
<a name="drawdownFromPool"></a>
|
|
748
|
-
|
|
749
|
-
## drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, [gasOpts]) ⇒ <code>Promise.<TransactionResponse></code>
|
|
750
|
-
<p>Calls drawdown on a Huma pool contract</p>
|
|
751
|
-
|
|
752
|
-
**Kind**: global function
|
|
753
|
-
**Returns**: <code>Promise.<TransactionResponse></code> - <ul>
|
|
754
|
-
<li>A Promise of the transaction response.</li>
|
|
755
|
-
</ul>
|
|
756
|
-
|
|
757
|
-
| Param | Type | Description |
|
|
758
|
-
| --- | --- | --- |
|
|
759
|
-
| signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
|
|
760
|
-
| chainId | <code>number</code> | <p>The chain ID of the pool to call drawdown on. Used to lookup the pool address.</p> |
|
|
761
|
-
| poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool to mint the receivable token from. Used to lookup the pool address.</p> |
|
|
762
|
-
| poolType | <code>POOL\_TYPE</code> | <p>The type of the credit pool to mint the receivable token from. Used to lookup the pool address.</p> |
|
|
763
|
-
| drawdownAmount | <code>BigNumberish</code> | <p>The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.</p> |
|
|
764
|
-
| [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
|
|
765
|
-
|
|
766
|
-
<a name="makePaymentToPool"></a>
|
|
767
|
-
|
|
768
|
-
## makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, [gasOpts]) ⇒ <code>Promise.<TransactionResponse></code>
|
|
769
|
-
<p>Calls makePayment on a Huma pool contract. If the pool does not have sufficient allowance to complete the operation,
|
|
770
|
-
attempt to first increase the allowance of the pool.</p>
|
|
771
|
-
|
|
772
|
-
**Kind**: global function
|
|
773
|
-
**Returns**: <code>Promise.<TransactionResponse></code> - <ul>
|
|
774
|
-
<li>A Promise of the transaction response.</li>
|
|
775
|
-
</ul>
|
|
776
|
-
|
|
777
|
-
| Param | Type | Description |
|
|
778
|
-
| --- | --- | --- |
|
|
779
|
-
| signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
|
|
780
|
-
| chainId | <code>number</code> | <p>The chain ID of the pool to call drawdown on. Used to lookup the pool address.</p> |
|
|
781
|
-
| poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool to mint the receivable token from. Used to lookup the pool address.</p> |
|
|
782
|
-
| poolType | <code>POOL\_TYPE</code> | <p>The type of the credit pool to mint the receivable token from. Used to lookup the pool address.</p> |
|
|
783
|
-
| paymentAmount | <code>BigNumberish</code> | <p>The amount of tokens to payback, denominated in the ERC20 tokens of the pool.</p> |
|
|
784
|
-
| [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
|
|
785
|
-
|
|
786
|
-
<a name="approvePoolAllowance"></a>
|
|
787
|
-
|
|
788
|
-
## approvePoolAllowance(signer, chainId, poolName, poolType, allowanceAmount, [gasOpts]) ⇒ <code>Promise.<TransactionResponse></code>
|
|
789
|
-
<p>Approves an allowance for a Huma pool contract, which is required to do certain actions (e.g. makePayment)</p>
|
|
790
|
-
|
|
791
|
-
**Kind**: global function
|
|
792
|
-
**Returns**: <code>Promise.<TransactionResponse></code> - <ul>
|
|
793
|
-
<li>A Promise of the transaction response.</li>
|
|
794
|
-
</ul>
|
|
795
|
-
|
|
796
|
-
| Param | Type | Description |
|
|
797
|
-
| --- | --- | --- |
|
|
798
|
-
| signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
|
|
799
|
-
| chainId | <code>number</code> | <p>The chain ID of the pool to call drawdown on. Used to lookup the pool address.</p> |
|
|
800
|
-
| poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool to mint the receivable token from. Used to lookup the pool address.</p> |
|
|
801
|
-
| poolType | <code>POOL\_TYPE</code> | <p>The type of the credit pool to mint the receivable token from. Used to lookup the pool address.</p> |
|
|
802
|
-
| allowanceAmount | <code>BigNumberish</code> | <p>The amount of tokens to payback, denominated in the ERC20 tokens of the pool.</p> |
|
|
803
|
-
| [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
|
|
804
|
-
|
|
805
616
|
<a name="ApprovalResult"></a>
|
|
806
617
|
|
|
807
618
|
## ApprovalResult : <code>Object</code>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.38-beta.0+6ab0460",
|
|
4
4
|
"types": "./dist/index.d.ts",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@ethersproject/constants": "^5.7.0",
|
|
29
29
|
"@ethersproject/contracts": "^5.7.0",
|
|
30
30
|
"@ethersproject/providers": "^5.6.0",
|
|
31
|
-
"@huma-finance/shared": "^0.0.
|
|
31
|
+
"@huma-finance/shared": "^0.0.38-beta.0+6ab0460",
|
|
32
32
|
"arweave": "^1.13.5",
|
|
33
33
|
"axios": "^1.4.0",
|
|
34
34
|
"bignumber.js": "^9.1.1",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"optionalDependencies": {
|
|
111
111
|
"encoding": "^0.1.13"
|
|
112
112
|
},
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "6ab046042364e2516f1054e7e82c2811708b771d"
|
|
114
114
|
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { GraphQLClient } from 'graphql-request';
|
|
2
|
-
export type Maybe<T> = T | null;
|
|
3
|
-
export type InputMaybe<T> = Maybe<T>;
|
|
4
|
-
export type Exact<T extends {
|
|
5
|
-
[key: string]: unknown;
|
|
6
|
-
}> = {
|
|
7
|
-
[K in keyof T]: T[K];
|
|
8
|
-
};
|
|
9
|
-
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
|
|
10
|
-
[SubKey in K]?: Maybe<T[SubKey]>;
|
|
11
|
-
};
|
|
12
|
-
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
|
|
13
|
-
[SubKey in K]: Maybe<T[SubKey]>;
|
|
14
|
-
};
|
|
15
|
-
/** All built-in and custom scalars, mapped to their actual values */
|
|
16
|
-
export type Scalars = {
|
|
17
|
-
ID: string;
|
|
18
|
-
String: string;
|
|
19
|
-
Boolean: boolean;
|
|
20
|
-
Int: number;
|
|
21
|
-
Float: number;
|
|
22
|
-
};
|
|
23
|
-
export type Receivable = {
|
|
24
|
-
__typename?: 'Receivable';
|
|
25
|
-
creationDate?: Maybe<Scalars['String']>;
|
|
26
|
-
currencyCode?: Maybe<Scalars['String']>;
|
|
27
|
-
id?: Maybe<Scalars['String']>;
|
|
28
|
-
lastUpdate?: Maybe<Scalars['String']>;
|
|
29
|
-
maturityDate?: Maybe<Scalars['String']>;
|
|
30
|
-
owner?: Maybe<Scalars['String']>;
|
|
31
|
-
paidAmount?: Maybe<Scalars['String']>;
|
|
32
|
-
pool?: Maybe<Scalars['String']>;
|
|
33
|
-
receivableAmount?: Maybe<Scalars['String']>;
|
|
34
|
-
status?: Maybe<Scalars['String']>;
|
|
35
|
-
tokenId?: Maybe<Scalars['String']>;
|
|
36
|
-
uri?: Maybe<Scalars['String']>;
|
|
37
|
-
};
|
|
38
|
-
export type SdkFunctionWrapper = <T>(action: (requestHeaders?: Record<string, string>) => Promise<T>, operationName: string, operationType?: string) => Promise<T>;
|
|
39
|
-
export declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionWrapper): {};
|
|
40
|
-
export type Sdk = ReturnType<typeof getSdk>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSdk = void 0;
|
|
4
|
-
const defaultWrapper = (action, _operationName, _operationType) => action();
|
|
5
|
-
function getSdk(client, withWrapper = defaultWrapper) {
|
|
6
|
-
return {};
|
|
7
|
-
}
|
|
8
|
-
exports.getSdk = getSdk;
|
|
9
|
-
//# sourceMappingURL=generatedTypes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generatedTypes.js","sourceRoot":"","sources":["../../../src/graphql/generatedTypes.ts"],"names":[],"mappings":";;;AA8CA,MAAM,cAAc,GAAuB,CACzC,MAAM,EACN,cAAc,EACd,cAAc,EACd,EAAE,CAAC,MAAM,EAAE,CAAA;AAEb,SAAgB,MAAM,CACpB,MAAqB,EACrB,cAAkC,cAAc;IAEhD,OAAO,EAAE,CAAA;AACX,CAAC;AALD,wBAKC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './generatedTypes';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/graphql/index.ts"],"names":[],"mappings":";;;AAAA,2DAAgC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Contract, ethers } from 'ethers';
|
|
2
|
-
/**
|
|
3
|
-
* Returns an ethers contract instance for the ERC20TransferableReceivable contract
|
|
4
|
-
* associated with the given pool name on the current chain.
|
|
5
|
-
*
|
|
6
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
7
|
-
* @param {number} chainId The chain id where the contract instance exists
|
|
8
|
-
* @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getERC20TransferableReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getERC20TransferableReceivableContract = void 0;
|
|
4
|
-
const shared_1 = require("@huma-finance/shared");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
/**
|
|
7
|
-
* Returns an ethers contract instance for the ERC20TransferableReceivable contract
|
|
8
|
-
* associated with the given pool name on the current chain.
|
|
9
|
-
*
|
|
10
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
11
|
-
* @param {number} chainId The chain id where the contract instance exists
|
|
12
|
-
* @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
|
|
13
|
-
*/
|
|
14
|
-
function getERC20TransferableReceivableContract(signerOrProvider, chainId) {
|
|
15
|
-
var _a;
|
|
16
|
-
const erc20TransferableReceiable = (_a = shared_1.SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.SupplementaryContracts.ERC20TransferableReceivable];
|
|
17
|
-
if (!erc20TransferableReceiable)
|
|
18
|
-
return null;
|
|
19
|
-
return (0, utils_1.getContract)(erc20TransferableReceiable, shared_1.ERC20_TRANSFERABLE_RECEIVABLE_ABI, signerOrProvider);
|
|
20
|
-
}
|
|
21
|
-
exports.getERC20TransferableReceivableContract = getERC20TransferableReceivableContract;
|
|
22
|
-
//# sourceMappingURL=ERC20TransferableReceivableContractHelper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ERC20TransferableReceivableContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/ERC20TransferableReceivableContractHelper.ts"],"names":[],"mappings":";;;AACA,iDAI6B;AAE7B,oCAAsC;AAEtC;;;;;;;GAOG;AACH,SAAgB,sCAAsC,CACpD,gBAA2D,EAC3D,OAAe;;IAEf,MAAM,0BAA0B,GAC9B,MAAA,kCAAyB,CAAC,OAAO,CAAC,0CAChC,+BAAsB,CAAC,2BAA2B,CACnD,CAAA;IAEH,IAAI,CAAC,0BAA0B;QAAE,OAAO,IAAI,CAAA;IAE5C,OAAO,IAAA,mBAAW,EAChB,0BAA0B,EAC1B,0CAAiC,EACjC,gBAAgB,CACjB,CAAA;AACH,CAAC;AAhBD,wFAgBC"}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
|
-
import { BigNumberish, Contract, Overrides, ethers } from 'ethers';
|
|
3
|
-
import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
|
|
4
|
-
import { TransactionResponse } from '@ethersproject/providers';
|
|
5
|
-
/**
|
|
6
|
-
* Returns an ethers contract instance for a Huma pool contract
|
|
7
|
-
*
|
|
8
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
9
|
-
* @param {number} chainId The chain id where the contract instance exists
|
|
10
|
-
* @param {POOL_NAME} poolName The name of the pool contract to get.
|
|
11
|
-
* @param {POOL_TYPE} poolType The type of the pool contract to get.
|
|
12
|
-
* @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
|
|
13
|
-
*/
|
|
14
|
-
export declare function getPoolContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): Contract | null;
|
|
15
|
-
/**
|
|
16
|
-
* Return type of getCreditRecord
|
|
17
|
-
*
|
|
18
|
-
* @memberof getCreditRecord
|
|
19
|
-
* @typedef {Object} CreditRecord
|
|
20
|
-
* @property {BigNumber} unbilledPrincipal - The amount of principal not included in the bill
|
|
21
|
-
* @property {BigNumber} dueDate - Unix timestamp due date of the next payment
|
|
22
|
-
* @property {BigNumber} correction - the adjustment of interest over or under-counted because of drawdown
|
|
23
|
-
* or principal payment in the middle of a billing period
|
|
24
|
-
* @property {BigNumber} totalDue - The due amount of the next payment
|
|
25
|
-
* @property {BigNumber} feesAndInterestDue - Interest and fees due for the next payment
|
|
26
|
-
* @property {number} missedPeriods - # of consecutive missed payments, for default processing
|
|
27
|
-
* @property {number} remainingPeriods - # of payment periods until the maturity of the credit line
|
|
28
|
-
* @property {number} state - status of the credit line.
|
|
29
|
-
* For more info: https://github.com/00labs/huma-contracts/blob/b075a8f957de281e0885e37dbd72a422b6a54a38/contracts/libraries/BaseStructs.sol#L49
|
|
30
|
-
*/
|
|
31
|
-
export type CreditRecord = [
|
|
32
|
-
BigNumber,
|
|
33
|
-
BigNumber,
|
|
34
|
-
BigNumber,
|
|
35
|
-
BigNumber,
|
|
36
|
-
BigNumber,
|
|
37
|
-
number,
|
|
38
|
-
number,
|
|
39
|
-
number
|
|
40
|
-
] & {
|
|
41
|
-
unbilledPrincipal: BigNumber;
|
|
42
|
-
dueDate: BigNumber;
|
|
43
|
-
correction: BigNumber;
|
|
44
|
-
totalDue: BigNumber;
|
|
45
|
-
feesAndInterestDue: BigNumber;
|
|
46
|
-
missedPeriods: number;
|
|
47
|
-
remainingPeriods: number;
|
|
48
|
-
state: number;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Gets the credit record of a wallet in a Huma pool. Denominated in the ERC20 tokens of the pool.
|
|
52
|
-
*
|
|
53
|
-
* @namespace getCreditRecord
|
|
54
|
-
* @async
|
|
55
|
-
* @function
|
|
56
|
-
* @param {string} address - The address to lookup.
|
|
57
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to read data.
|
|
58
|
-
* @param {number} chainId - The chain ID of the pool. Used to lookup the pool address.
|
|
59
|
-
* @param {POOL_NAME} poolName - The name of the credit pool. Used to lookup the pool address.
|
|
60
|
-
* @param {POOL_TYPE} poolType - The type of the credit pool. Used to lookup the pool address.
|
|
61
|
-
* @returns {Promise<CreditRecord>} - A Promise of the transaction response.
|
|
62
|
-
*/
|
|
63
|
-
export declare function getCreditRecord(address: string, signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): Promise<CreditRecord>;
|
|
64
|
-
/**
|
|
65
|
-
* Gets the total due for a Huma pool of the given wallet. Denominated in the ERC20 tokens of the pool.
|
|
66
|
-
*
|
|
67
|
-
* @async
|
|
68
|
-
* @function
|
|
69
|
-
* @param {string} address - The address to lookup.
|
|
70
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to read data.
|
|
71
|
-
* @param {number} chainId - The chain ID of the pool. Used to lookup the pool address.
|
|
72
|
-
* @param {POOL_NAME} poolName - The name of the credit pool. Used to lookup the pool address.
|
|
73
|
-
* @param {POOL_TYPE} poolType - The type of the credit pool. Used to lookup the pool address.
|
|
74
|
-
* @returns {Promise<BigNumber>} - A Promise of the transaction response.
|
|
75
|
-
*/
|
|
76
|
-
export declare function getTotalDue(address: string, signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): Promise<BigNumber>;
|
|
77
|
-
/**
|
|
78
|
-
* Calls drawdown on a Huma pool contract
|
|
79
|
-
*
|
|
80
|
-
* @async
|
|
81
|
-
* @function
|
|
82
|
-
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
83
|
-
* @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
|
|
84
|
-
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
85
|
-
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
86
|
-
* @param {BigNumberish} drawdownAmount - The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.
|
|
87
|
-
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
88
|
-
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
89
|
-
*/
|
|
90
|
-
export declare function drawdownFromPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, drawdownAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
|
|
91
|
-
/**
|
|
92
|
-
* Calls makePayment on a Huma pool contract. If the pool does not have sufficient allowance to complete the operation,
|
|
93
|
-
* attempt to first increase the allowance of the pool.
|
|
94
|
-
*
|
|
95
|
-
* @async
|
|
96
|
-
* @function
|
|
97
|
-
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
98
|
-
* @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
|
|
99
|
-
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
100
|
-
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
101
|
-
* @param {BigNumberish} paymentAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
|
|
102
|
-
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
103
|
-
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
104
|
-
*/
|
|
105
|
-
export declare function makePaymentToPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, paymentAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
|
|
106
|
-
/**
|
|
107
|
-
* Approves an allowance for a Huma pool contract, which is required to do certain actions (e.g. makePayment)
|
|
108
|
-
*
|
|
109
|
-
* @async
|
|
110
|
-
* @function
|
|
111
|
-
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
112
|
-
* @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
|
|
113
|
-
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
114
|
-
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
115
|
-
* @param {BigNumberish} allowanceAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
|
|
116
|
-
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
117
|
-
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
118
|
-
*/
|
|
119
|
-
export declare function approvePoolAllowance(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, allowanceAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.approvePoolAllowance = exports.makePaymentToPool = exports.drawdownFromPool = exports.getTotalDue = exports.getCreditRecord = exports.getPoolContract = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
/**
|
|
6
|
-
* Returns an ethers contract instance for a Huma pool contract
|
|
7
|
-
*
|
|
8
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
9
|
-
* @param {number} chainId The chain id where the contract instance exists
|
|
10
|
-
* @param {POOL_NAME} poolName The name of the pool contract to get.
|
|
11
|
-
* @param {POOL_TYPE} poolType The type of the pool contract to get.
|
|
12
|
-
* @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
|
|
13
|
-
*/
|
|
14
|
-
function getPoolContract(signerOrProvider, chainId, poolName, poolType) {
|
|
15
|
-
const poolInfo = (0, utils_1.getPoolInfo)(chainId, poolName, poolType);
|
|
16
|
-
if (!poolInfo)
|
|
17
|
-
return null;
|
|
18
|
-
return (0, utils_1.getContract)(poolInfo.pool, poolInfo.poolAbi, signerOrProvider);
|
|
19
|
-
}
|
|
20
|
-
exports.getPoolContract = getPoolContract;
|
|
21
|
-
/**
|
|
22
|
-
* Gets the credit record of a wallet in a Huma pool. Denominated in the ERC20 tokens of the pool.
|
|
23
|
-
*
|
|
24
|
-
* @namespace getCreditRecord
|
|
25
|
-
* @async
|
|
26
|
-
* @function
|
|
27
|
-
* @param {string} address - The address to lookup.
|
|
28
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to read data.
|
|
29
|
-
* @param {number} chainId - The chain ID of the pool. Used to lookup the pool address.
|
|
30
|
-
* @param {POOL_NAME} poolName - The name of the credit pool. Used to lookup the pool address.
|
|
31
|
-
* @param {POOL_TYPE} poolType - The type of the credit pool. Used to lookup the pool address.
|
|
32
|
-
* @returns {Promise<CreditRecord>} - A Promise of the transaction response.
|
|
33
|
-
*/
|
|
34
|
-
async function getCreditRecord(address, signerOrProvider, chainId, poolName, poolType) {
|
|
35
|
-
const poolContract = getPoolContract(signerOrProvider, chainId, poolName, poolType);
|
|
36
|
-
if (!poolContract) {
|
|
37
|
-
throw new Error('Could not find pool contract');
|
|
38
|
-
}
|
|
39
|
-
return poolContract.creditRecordMapping(address);
|
|
40
|
-
}
|
|
41
|
-
exports.getCreditRecord = getCreditRecord;
|
|
42
|
-
/**
|
|
43
|
-
* Gets the total due for a Huma pool of the given wallet. Denominated in the ERC20 tokens of the pool.
|
|
44
|
-
*
|
|
45
|
-
* @async
|
|
46
|
-
* @function
|
|
47
|
-
* @param {string} address - The address to lookup.
|
|
48
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to read data.
|
|
49
|
-
* @param {number} chainId - The chain ID of the pool. Used to lookup the pool address.
|
|
50
|
-
* @param {POOL_NAME} poolName - The name of the credit pool. Used to lookup the pool address.
|
|
51
|
-
* @param {POOL_TYPE} poolType - The type of the credit pool. Used to lookup the pool address.
|
|
52
|
-
* @returns {Promise<BigNumber>} - A Promise of the transaction response.
|
|
53
|
-
*/
|
|
54
|
-
async function getTotalDue(address, signerOrProvider, chainId, poolName, poolType) {
|
|
55
|
-
const creditRecord = await getCreditRecord(address, signerOrProvider, chainId, poolName, poolType);
|
|
56
|
-
return creditRecord.totalDue;
|
|
57
|
-
}
|
|
58
|
-
exports.getTotalDue = getTotalDue;
|
|
59
|
-
/**
|
|
60
|
-
* Calls drawdown on a Huma pool contract
|
|
61
|
-
*
|
|
62
|
-
* @async
|
|
63
|
-
* @function
|
|
64
|
-
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
65
|
-
* @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
|
|
66
|
-
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
67
|
-
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
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.
|
|
70
|
-
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
71
|
-
*/
|
|
72
|
-
async function drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, gasOpts = {}) {
|
|
73
|
-
const poolContract = getPoolContract(signer, chainId, poolName, poolType);
|
|
74
|
-
if (!poolContract) {
|
|
75
|
-
throw new Error('Could not find pool contract');
|
|
76
|
-
}
|
|
77
|
-
gasOpts = await (0, utils_1.getDefaultGasOptions)(gasOpts, chainId);
|
|
78
|
-
// TODO: Generate typechain for pool contract
|
|
79
|
-
return poolContract.drawdown(drawdownAmount, gasOpts);
|
|
80
|
-
}
|
|
81
|
-
exports.drawdownFromPool = drawdownFromPool;
|
|
82
|
-
/**
|
|
83
|
-
* Calls makePayment on a Huma pool contract. If the pool does not have sufficient allowance to complete the operation,
|
|
84
|
-
* attempt to first increase the allowance of the pool.
|
|
85
|
-
*
|
|
86
|
-
* @async
|
|
87
|
-
* @function
|
|
88
|
-
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
89
|
-
* @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
|
|
90
|
-
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
91
|
-
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
92
|
-
* @param {BigNumberish} paymentAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
|
|
93
|
-
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
94
|
-
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
95
|
-
*/
|
|
96
|
-
async function makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, gasOpts = {}) {
|
|
97
|
-
const poolInfo = (0, utils_1.getPoolInfo)(chainId, poolName, poolType);
|
|
98
|
-
if (!(poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.poolUnderlyingToken.address)) {
|
|
99
|
-
throw new Error('Could not find pool underlying token address');
|
|
100
|
-
}
|
|
101
|
-
const poolTokenContract = (0, utils_1.getERC20Contract)(poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.poolUnderlyingToken.address, signer);
|
|
102
|
-
const poolContract = getPoolContract(signer, chainId, poolName, poolType);
|
|
103
|
-
if (!poolContract) {
|
|
104
|
-
throw new Error('Could not find pool contract');
|
|
105
|
-
}
|
|
106
|
-
gasOpts = await (0, utils_1.getDefaultGasOptions)(gasOpts, chainId);
|
|
107
|
-
const allowance = await poolTokenContract.allowance(await signer.getAddress(), poolContract.address);
|
|
108
|
-
if (allowance.lt(paymentAmount)) {
|
|
109
|
-
const approvalTx = await poolTokenContract.approve(poolContract.address, paymentAmount, gasOpts);
|
|
110
|
-
// Wait for 5 block confirmations since this is required for makePayment
|
|
111
|
-
await approvalTx.wait(5);
|
|
112
|
-
}
|
|
113
|
-
// TODO: Generate typechain for pool contract
|
|
114
|
-
return poolContract.makePayment(await signer.getAddress(), paymentAmount, gasOpts);
|
|
115
|
-
}
|
|
116
|
-
exports.makePaymentToPool = makePaymentToPool;
|
|
117
|
-
/**
|
|
118
|
-
* Approves an allowance for a Huma pool contract, which is required to do certain actions (e.g. makePayment)
|
|
119
|
-
*
|
|
120
|
-
* @async
|
|
121
|
-
* @function
|
|
122
|
-
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
123
|
-
* @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
|
|
124
|
-
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
125
|
-
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
126
|
-
* @param {BigNumberish} allowanceAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
|
|
127
|
-
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
128
|
-
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
129
|
-
*/
|
|
130
|
-
async function approvePoolAllowance(signer, chainId, poolName, poolType, allowanceAmount, gasOpts = {}) {
|
|
131
|
-
const poolInfo = (0, utils_1.getPoolInfo)(chainId, poolName, poolType);
|
|
132
|
-
if (!(poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.poolUnderlyingToken.address)) {
|
|
133
|
-
throw new Error('Could not find pool underlying token address');
|
|
134
|
-
}
|
|
135
|
-
const poolTokenContract = (0, utils_1.getERC20Contract)(poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.poolUnderlyingToken.address, signer);
|
|
136
|
-
const poolContract = getPoolContract(signer, chainId, poolName, poolType);
|
|
137
|
-
if (!poolContract) {
|
|
138
|
-
throw new Error('Could not find pool contract');
|
|
139
|
-
}
|
|
140
|
-
gasOpts = await (0, utils_1.getDefaultGasOptions)(gasOpts, chainId);
|
|
141
|
-
return poolTokenContract.approve(poolContract.address, allowanceAmount, gasOpts);
|
|
142
|
-
}
|
|
143
|
-
exports.approvePoolAllowance = approvePoolAllowance;
|
|
144
|
-
//# sourceMappingURL=PoolContractHelper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Contract, ethers } from 'ethers';
|
|
2
|
-
/**
|
|
3
|
-
* Returns an ethers contract instance for the RealWorldReceivable contract
|
|
4
|
-
* associated with the given pool name on the current chain.
|
|
5
|
-
*
|
|
6
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
7
|
-
* @param {number} chainId The chain id where the contract instance exists
|
|
8
|
-
* @returns {Contract | null} A contract instance for the RealWorldReceivable contract or null if it could not be found.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getRealWorldReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
|