@huma-finance/sdk 0.0.77-beta.1026 → 0.0.77

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.
Files changed (2) hide show
  1. package/API.md +971 -0
  2. package/package.json +3 -3
package/API.md CHANGED
@@ -0,0 +1,971 @@
1
+ ## Objects
2
+
3
+ <dl>
4
+ <dt><a href="#ARWeaveService">ARWeaveService</a> : <code>object</code></dt>
5
+ <dd><p>An object that contains functions to interact with Huma-related data stored on ARWeave</p></dd>
6
+ <dt><a href="#EAService">EAService</a> : <code>object</code></dt>
7
+ <dd><p>An object that contains functions to interact with Huma's EAVerse service.</p></dd>
8
+ <dt><a href="#ReceivableService">ReceivableService</a> : <code>object</code></dt>
9
+ <dd><p>An object that contains functions to interact with Huma's receivables.</p></dd>
10
+ <dt><a href="#SubgraphService">SubgraphService</a> : <code>object</code></dt>
11
+ <dd><p>An object that contains functions to interact with Huma's Subgraph storage.</p></dd>
12
+ </dl>
13
+
14
+ ## Functions
15
+
16
+ <dl>
17
+ <dt><a href="#defaultWrapper">defaultWrapper()</a></dt>
18
+ <dd><p>All built-in and custom scalars, mapped to their actual values</p></dd>
19
+ <dt><a href="#approveERC20AllowanceIfInsufficient">approveERC20AllowanceIfInsufficient(signer, tokenAddress, spenderAddress, allowanceAmount, [gasOpts])</a> ⇒ <code>Promise.&lt;(TransactionResponse|null)&gt;</code></dt>
20
+ <dd><p>Approves an ERC20 allowance for a spender address, if the current allowance is insufficient.
21
+ Allowance is required to do certain actions on the Huma protocol (e.g. makePayment)</p></dd>
22
+ <dt><a href="#getERC20TransferableReceivableContract">getERC20TransferableReceivableContract(signerOrProvider, chainId)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
23
+ <dd><p>Returns an ethers contract instance for the ERC20TransferableReceivable contract
24
+ associated with the given pool name on the current chain.</p></dd>
25
+ <dt><a href="#getPoolContract">getPoolContract(signerOrProvider, chainId, poolName, poolType)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
26
+ <dd><p>Returns an ethers contract instance for a Huma pool contract</p></dd>
27
+ <dt><a href="#getCreditRecord">getCreditRecord(address, signerOrProvider, chainId, poolName, poolType)</a> ⇒ <code>Promise.&lt;CreditRecord&gt;</code></dt>
28
+ <dd><p>Gets the credit record of a wallet in a Huma pool. Denominated in the ERC20 tokens of the pool.</p></dd>
29
+ <dt><a href="#getTotalDue">getTotalDue(address, signerOrProvider, chainId, poolName, poolType)</a> ⇒ <code>Promise.&lt;BigNumber&gt;</code></dt>
30
+ <dd><p>Gets the total due for a Huma pool of the given wallet. Denominated in the ERC20 tokens of the pool.</p></dd>
31
+ <dt><a href="#drawdownFromPool">drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, [gasOpts])</a> ⇒ <code>Promise.&lt;TransactionResponse&gt;</code></dt>
32
+ <dd><p>Calls drawdown on a Huma pool contract</p></dd>
33
+ <dt><a href="#makePaymentToPool">makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, [gasOpts])</a> ⇒ <code>Promise.&lt;TransactionResponse&gt;</code></dt>
34
+ <dd><p>Calls makePayment on a Huma pool contract. If the pool does not have sufficient allowance to complete the operation,
35
+ attempt to first increase the allowance of the pool.</p></dd>
36
+ <dt><a href="#approvePoolAllowance">approvePoolAllowance(signer, chainId, poolName, poolType, allowanceAmount, [gasOpts])</a> ⇒ <code>Promise.&lt;TransactionResponse&gt;</code></dt>
37
+ <dd><p>Approves an allowance for a Huma pool contract, which is required to do certain actions (e.g. makePayment)</p></dd>
38
+ <dt><a href="#getRealWorldReceivableContract">getRealWorldReceivableContract(signerOrProvider, chainId)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
39
+ <dd><p>Returns an ethers contract instance for the RealWorldReceivable contract
40
+ associated with the given pool name on the current chain.</p></dd>
41
+ <dt><a href="#getAvailableBalanceForPool">getAvailableBalanceForPool(poolName, provider)</a></dt>
42
+ <dd><p>Returns the current pool balance available for borrowing</p></dd>
43
+ <dt><a href="#getCreditRecordForPool">getCreditRecordForPool(poolName, borrower, provider)</a></dt>
44
+ <dd><p>Returns the credit record of the borrower</p></dd>
45
+ <dt><a href="#getAvailableCreditForPool">getAvailableCreditForPool(borrower, poolName, provider)</a></dt>
46
+ <dd><p>Returns the borrower's remaining credit they can use for borrowing. Note that this might not be
47
+ currently available for borrowing as the credit limit might exceed the available pool balance. Use
48
+ getPoolBalance() to get the current available pool balance.</p></dd>
49
+ <dt><a href="#getReceivableBackedCreditLineContractV2">getReceivableBackedCreditLineContractV2(signerOrProvider, poolName)</a> ⇒ <code>ReceivableBackedCreditLine</code> | <code>null</code></dt>
50
+ <dd><p>Returns an ethers contract instance for the V2 Receivable contract
51
+ associated with the given pool name on the current chain.</p></dd>
52
+ <dt><a href="#getTotalDueV2">getTotalDueV2(provider, poolName)</a> ⇒ <code>BigNumber</code> | <code>null</code></dt>
53
+ <dd><p>Returns account's total due amount in BigNumber format
54
+ associated with the given pool name on the current chain.</p></dd>
55
+ <dt><a href="#drawdownWithReceivable">drawdownWithReceivable(signer, poolName, receivableId, drawdownAmount, [gasOpts])</a> ⇒ <code>Promise.&lt;TransactionResponse&gt;</code></dt>
56
+ <dd><p>Draws down from a pool using a receivable.</p></dd>
57
+ <dt><a href="#makePaymentWithReceivable">makePaymentWithReceivable(signer, poolName, receivableId, paymentAmount, principalOnly, [gasOpts])</a> ⇒ <code>Promise.&lt;TransactionResponse&gt;</code></dt>
58
+ <dd><p>Makes a payment with a receivable.</p></dd>
59
+ <dt><a href="#makePrincipalPaymentAndDrawdownWithReceivable">makePrincipalPaymentAndDrawdownWithReceivable(signer, poolName, paymentReceivableId, paymentAmount, drawdownReceivableId, drawdownAmount, [gasOpts])</a> ⇒ <code>Promise.&lt;TransactionResponse&gt;</code></dt>
60
+ <dd><p>Makes a principal payment and drawdown with receivables.</p></dd>
61
+ <dt><a href="#getReceivableContractV2">getReceivableContractV2(poolName, signer)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
62
+ <dd><p>Returns an ethers contract instance for the V2 Receivable contract
63
+ associated with the given pool name on the current chain.</p></dd>
64
+ <dt><a href="#getReceivableTokenIdFromReferenceId">getReceivableTokenIdFromReferenceId(referenceId, creator, poolName, signer)</a> ⇒</dt>
65
+ <dd><p>Retrieves the receivable token ID associated with a given reference ID.</p></dd>
66
+ <dt><a href="#preapprove">preapprove(payload, chainId)</a> ⇒ <code>Promise.&lt;Approval&gt;</code></dt>
67
+ <dd><p>Checks whether or not a credit underwriting request to Huma's EAVerse would be approved.
68
+ Note that this does not approve a creditline in Huma's pools and an approve call is still required.</p></dd>
69
+ <dt><a href="#getChainIdFromJsonSignerOrProvider">getChainIdFromJsonSignerOrProvider(signerOrProvider)</a> ⇒ <code>number</code></dt>
70
+ <dd><p>Get the chain ID from a signer or provider object.</p></dd>
71
+ <dt><a href="#getChainIdFromSignerOrProvider">getChainIdFromSignerOrProvider(signerOrProvider)</a> ⇒ <code>number</code></dt>
72
+ <dd><p>Get the chain ID from a signer or provider object.</p></dd>
73
+ <dt><a href="#getPoolInfo">getPoolInfo(poolName, poolType)</a> ⇒ <code>PoolInfoType</code> | <code>undefined</code></dt>
74
+ <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>
75
+ <dt><a href="#isSetComputeLimitInstruction">isSetComputeLimitInstruction()</a></dt>
76
+ <dd><p>Check if a given instruction is a SetComputeUnitLimit instruction
77
+ See https://github.com/solana-program/compute-budget/blob/main/clients/js/src/generated/programs/computeBudget.ts#L29</p></dd>
78
+ </dl>
79
+
80
+ ## Typedefs
81
+
82
+ <dl>
83
+ <dt><a href="#IrysConstructorArgs">IrysConstructorArgs</a> : <code>Object</code></dt>
84
+ <dd><p>Represents the constructor arguments for the Irys service.</p></dd>
85
+ <dt><a href="#ApprovalResult">ApprovalResult</a> : <code>Object</code></dt>
86
+ <dd><p>Object representing the response to the underwriting approval request.</p></dd>
87
+ <dt><a href="#EAPayload">EAPayload</a> : <code>Object</code></dt>
88
+ <dd><p>Object representing an invoice payload for underwriting approval.</p></dd>
89
+ <dt><a href="#CreditEventPayload">CreditEventPayload</a> : <code>Object</code></dt>
90
+ <dd><p>Represents the payload of a credit event.</p></dd>
91
+ <dt><a href="#Pagination">Pagination</a> : <code>Object</code></dt>
92
+ <dd><p>Represents the pagination options for a query.</p></dd>
93
+ </dl>
94
+
95
+ <a name="ARWeaveService"></a>
96
+
97
+ ## ARWeaveService : <code>object</code>
98
+ <p>An object that contains functions to interact with Huma-related data stored on ARWeave</p>
99
+
100
+ **Kind**: global namespace
101
+
102
+ * [ARWeaveService](#ARWeaveService) : <code>object</code>
103
+ * [.getIrysNetworkConfig(chainId)](#ARWeaveService.getIrysNetworkConfig) ⇒ [<code>IrysConstructorArgs</code>](#IrysConstructorArgs)
104
+ * [.getIrysInstance(config, privateKey)](#ARWeaveService.getIrysInstance) ⇒
105
+ * [.prefundIrys(config, privateKey, amount)](#ARWeaveService.prefundIrys) ⇒ <code>Promise.&lt;FundResponse&gt;</code>
106
+ * [.storeData(config, privateKey, data, tags, [lazyFund])](#ARWeaveService.storeData) ⇒ <code>Promise.&lt;UploadResponse&gt;</code>
107
+ * [.queryForMetadata(chainId, sender, referenceId)](#ARWeaveService.queryForMetadata) ⇒ <code>Promise.&lt;any&gt;</code>
108
+ * [.fetchMetadataFromUrl(url)](#ARWeaveService.fetchMetadataFromUrl) ⇒ <code>Promise.&lt;JSON&gt;</code>
109
+ * [.getURIFromARWeaveId(arweaveId)](#ARWeaveService.getURIFromARWeaveId) ⇒ <code>string</code>
110
+ * [.BundlrConfig](#ARWeaveService.BundlrConfig) : <code>Object</code>
111
+
112
+ <a name="ARWeaveService.getIrysNetworkConfig"></a>
113
+
114
+ ### ARWeaveService.getIrysNetworkConfig(chainId) ⇒ [<code>IrysConstructorArgs</code>](#IrysConstructorArgs)
115
+ <p>Get the configuration for the Irys network given a chain ID</p>
116
+
117
+ **Kind**: static method of [<code>ARWeaveService</code>](#ARWeaveService)
118
+ **Returns**: [<code>IrysConstructorArgs</code>](#IrysConstructorArgs) - <ul>
119
+ <li>The configuration for the Irys network.</li>
120
+ </ul>
121
+
122
+ | Param | Type | Description |
123
+ | --- | --- | --- |
124
+ | chainId | <code>number</code> | <p>The chain ID.</p> |
125
+
126
+ <a name="ARWeaveService.getIrysInstance"></a>
127
+
128
+ ### ARWeaveService.getIrysInstance(config, privateKey) ⇒
129
+ <p>Get an Irys instance for a specific network</p>
130
+
131
+ **Kind**: static method of [<code>ARWeaveService</code>](#ARWeaveService)
132
+ **Returns**: <p>The Bundlr instance</p>
133
+
134
+ | Param | Type | Description |
135
+ | --- | --- | --- |
136
+ | config | <code>BundlrConfig</code> | <p>The configuration for the Bundlr network.</p> |
137
+ | privateKey | <code>string</code> | <p>The private key of the wallet to use Bundlr with.</p> |
138
+
139
+ <a name="ARWeaveService.prefundIrys"></a>
140
+
141
+ ### ARWeaveService.prefundIrys(config, privateKey, amount) ⇒ <code>Promise.&lt;FundResponse&gt;</code>
142
+ <p>Prefund the Irys network with the specified amount. Required if not lazy funding.
143
+ Important note: The amount is denominated in the base unit of currency for that network.
144
+ If you want to upload 5 Matic to the Irys node, pass in an amount of 5.</p>
145
+
146
+ **Kind**: static method of [<code>ARWeaveService</code>](#ARWeaveService)
147
+ **Returns**: <code>Promise.&lt;FundResponse&gt;</code> - <ul>
148
+ <li>The fund response.</li>
149
+ </ul>
150
+
151
+ | Param | Type | Description |
152
+ | --- | --- | --- |
153
+ | config | [<code>IrysConstructorArgs</code>](#IrysConstructorArgs) | <p>The configuration for the Bundlr network.</p> |
154
+ | privateKey | <code>string</code> | <p>The private key of the wallet to send funds from.</p> |
155
+ | amount | <code>number</code> | <p>The amount to fund, denoted in whatever currency specified by the config (e.g. MATIC, ETH)</p> |
156
+
157
+ <a name="ARWeaveService.storeData"></a>
158
+
159
+ ### ARWeaveService.storeData(config, privateKey, data, tags, [lazyFund]) ⇒ <code>Promise.&lt;UploadResponse&gt;</code>
160
+ <p>Store data on ARWeave using the Irys Network.</p>
161
+
162
+ **Kind**: static method of [<code>ARWeaveService</code>](#ARWeaveService)
163
+ **Returns**: <code>Promise.&lt;UploadResponse&gt;</code> - <p>Promise resolving with the upload response.</p>
164
+
165
+ | Param | Type | Default | Description |
166
+ | --- | --- | --- | --- |
167
+ | config | [<code>IrysConstructorArgs</code>](#IrysConstructorArgs) | | <p>Configuration object for the Irys instance.</p> |
168
+ | privateKey | <code>string</code> | | <p>Private key used for interacting with the Irys instance.</p> |
169
+ | data | <code>Record.&lt;string, unknown&gt;</code> | | <p>The data to store in the Irys instance.</p> |
170
+ | tags | <code>Array.&lt;{name: string, value: string}&gt;</code> | | <p>Array of tag objects with <code>name</code> and <code>value</code> properties.</p> |
171
+ | [lazyFund] | <code>boolean</code> | <code>true</code> | <p>Optional flag to fund the Irys instance lazily. If set to <code>false</code>, the Irys node should already be funded or else uploads will fail.</p> |
172
+
173
+ <a name="ARWeaveService.queryForMetadata"></a>
174
+
175
+ ### ARWeaveService.queryForMetadata(chainId, sender, referenceId) ⇒ <code>Promise.&lt;any&gt;</code>
176
+ <p>Helper method to query the Arweave network for receivables metadata previously uploaded.</p>
177
+
178
+ **Kind**: static method of [<code>ARWeaveService</code>](#ARWeaveService)
179
+ **Returns**: <code>Promise.&lt;any&gt;</code> - <p>Promise resolving with the queried data.</p>
180
+
181
+ | Param | Type | Description |
182
+ | --- | --- | --- |
183
+ | chainId | <code>number</code> | <p>The chain ID.</p> |
184
+ | sender | <code>string</code> | <p>The sender tag to query.</p> |
185
+ | referenceId | <code>string</code> | <p>The referenceId tag to query, whatever was used when uploading the metadata.</p> |
186
+
187
+ <a name="ARWeaveService.fetchMetadataFromUrl"></a>
188
+
189
+ ### ARWeaveService.fetchMetadataFromUrl(url) ⇒ <code>Promise.&lt;JSON&gt;</code>
190
+ <p>Helper method to fetch data from an ARWeave URL.</p>
191
+
192
+ **Kind**: static method of [<code>ARWeaveService</code>](#ARWeaveService)
193
+ **Returns**: <code>Promise.&lt;JSON&gt;</code> - <p>Promise resolving with the queried data.</p>
194
+
195
+ | Param | Type | Description |
196
+ | --- | --- | --- |
197
+ | url | <code>string</code> | <p>The ARWeave metadata URL to query.</p> |
198
+
199
+ <a name="ARWeaveService.getURIFromARWeaveId"></a>
200
+
201
+ ### ARWeaveService.getURIFromARWeaveId(arweaveId) ⇒ <code>string</code>
202
+ <p>Helper method to get an ARWeave URI from an ARWeave ID.</p>
203
+
204
+ **Kind**: static method of [<code>ARWeaveService</code>](#ARWeaveService)
205
+ **Returns**: <code>string</code> - <p>The ARWeave URI.</p>
206
+
207
+ | Param | Type | Description |
208
+ | --- | --- | --- |
209
+ | arweaveId | <code>string</code> | <p>The ARWeave metadata ID.</p> |
210
+
211
+ <a name="ARWeaveService.BundlrConfig"></a>
212
+
213
+ ### ARWeaveService.BundlrConfig : <code>Object</code>
214
+ <p>The configuration for Bundlr network instances</p>
215
+
216
+ **Kind**: static typedef of [<code>ARWeaveService</code>](#ARWeaveService)
217
+ **Properties**
218
+
219
+ | Name | Type | Description |
220
+ | --- | --- | --- |
221
+ | nodeUrl | <code>string</code> | <p>The Bundlr node URL to use.</p> |
222
+ | currency | <code>string</code> | <p>The currency to pay for uploads with. Please see https://docs.bundlr.network/sdk/using-other-currencies for all the supported currencies</p> |
223
+ | [providerUrl] | <code>string</code> | <p>The provider URL, required for devnets.</p> |
224
+
225
+ <a name="EAService"></a>
226
+
227
+ ## EAService : <code>object</code>
228
+ <p>An object that contains functions to interact with Huma's EAVerse service.</p>
229
+
230
+ **Kind**: global namespace
231
+ <a name="EAService.approve"></a>
232
+
233
+ ### EAService.approve(payload, chainId) ⇒ <code>Promise.&lt;Approval&gt;</code>
234
+ <p>Submits a credit underwriting request to Huma's EAVerse. This approves a creditline
235
+ in Huma's pools that can be drawn down by the borrower.</p>
236
+
237
+ **Kind**: static method of [<code>EAService</code>](#EAService)
238
+ **Returns**: <code>Promise.&lt;Approval&gt;</code> - <p>Promise that returns the approval on success.</p>
239
+ **Throws**:
240
+
241
+ - <code>EARejectionError</code> <p>If the underwrite approval is rejected.</p>
242
+
243
+
244
+ | Param | Type | Description |
245
+ | --- | --- | --- |
246
+ | payload | [<code>EAPayload</code>](#EAPayload) | <p>The payload for the underwrite approval.</p> |
247
+ | chainId | <code>number</code> | <p>The chain ID.</p> |
248
+
249
+ <a name="ReceivableService"></a>
250
+
251
+ ## ReceivableService : <code>object</code>
252
+ <p>An object that contains functions to interact with Huma's receivables.</p>
253
+
254
+ **Kind**: global namespace
255
+
256
+ * [ReceivableService](#ReceivableService) : <code>object</code>
257
+ * [.getTokenIdByURI(signer, arweaveId)](#ReceivableService.getTokenIdByURI) ⇒ <code>Promise.&lt;(string\|null\|undefined)&gt;</code>
258
+ * [.declareReceivablePaymentByReferenceId(signer, referenceId, paymentAmount, [gasOpts])](#ReceivableService.declareReceivablePaymentByReferenceId) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
259
+ * [.declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount, [gasOpts])](#ReceivableService.declareReceivablePaymentByTokenId) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
260
+ * [.createReceivable(signer, poolName, poolType, currencyCode, receivableAmount, maturityDate, uri, [gasOpts])](#ReceivableService.createReceivable) ⇒ <code>Promise.&lt;(TransactionResponse\|null)&gt;</code>
261
+ * [.uploadOrFetchMetadataURI(signer, privateKey, chainId, poolName, poolType, metadata, referenceId, extraTags, [lazyFund])](#ReceivableService.uploadOrFetchMetadataURI) ⇒ <code>Promise.&lt;string&gt;</code>
262
+ * [.createReceivableWithMetadata(signer, privateKey, chainId, poolName, poolType, currencyCode, receivableAmount, maturityDate, metadata, referenceId, extraTags, [lazyFund], [gasOpts])](#ReceivableService.createReceivableWithMetadata) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
263
+ * [.loadReceivablesOfOwnerWithMetadata(chainID, owner, poolName, poolType, pagination)](#ReceivableService.loadReceivablesOfOwnerWithMetadata) ⇒ <code>Promise.&lt;Array.&lt;RealWorldReceivableInfo&gt;&gt;</code>
264
+ * [.getTotalCountOfReceivables(provider, owner)](#ReceivableService.getTotalCountOfReceivables) ⇒ <code>Promise.&lt;number&gt;</code>
265
+
266
+ <a name="ReceivableService.getTokenIdByURI"></a>
267
+
268
+ ### ReceivableService.getTokenIdByURI(signer, arweaveId) ⇒ <code>Promise.&lt;(string\|null\|undefined)&gt;</code>
269
+ <p>Fetches the tokenId of a RealWorldReceivable, or null if it doesn't exist, given a metadata URI</p>
270
+
271
+ **Kind**: static method of [<code>ReceivableService</code>](#ReceivableService)
272
+ **Returns**: <code>Promise.&lt;(string\|null\|undefined)&gt;</code> - <ul>
273
+ <li>Either the token Id or null if no token was found.</li>
274
+ </ul>
275
+
276
+ | Param | Type | Description |
277
+ | --- | --- | --- |
278
+ | signer | <code>ethers.Signer</code> | <p>The signer used to lookup metadata uploads for</p> |
279
+ | arweaveId | <code>string</code> | <p>The internal ARWeave identifier to lookup a token by</p> |
280
+
281
+ <a name="ReceivableService.declareReceivablePaymentByReferenceId"></a>
282
+
283
+ ### ReceivableService.declareReceivablePaymentByReferenceId(signer, referenceId, paymentAmount, [gasOpts]) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
284
+ <p>Declares a payment on a RealWorldReceivable given a reference Id of the receivable, which was used as an index for ARWeave data.</p>
285
+
286
+ **Kind**: static method of [<code>ReceivableService</code>](#ReceivableService)
287
+ **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
288
+ <li>A Promise of the transaction receipt.</li>
289
+ </ul>
290
+
291
+ | Param | Type | Description |
292
+ | --- | --- | --- |
293
+ | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction. Note only the receivable owner can pay the receivable.</p> |
294
+ | referenceId | <code>string</code> | <p>An internal identifier value added as a tag on ARWeave</p> |
295
+ | paymentAmount | <code>number</code> | <p>The amount to declare paid to the receivable.</p> |
296
+ | [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
297
+
298
+ <a name="ReceivableService.declareReceivablePaymentByTokenId"></a>
299
+
300
+ ### ReceivableService.declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount, [gasOpts]) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
301
+ <p>Declares a payment on a RealWorldReceivable given a tokenId of the receivable.</p>
302
+
303
+ **Kind**: static method of [<code>ReceivableService</code>](#ReceivableService)
304
+ **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
305
+ <li>A Promise of the transaction receipt.</li>
306
+ </ul>
307
+ **Throws**:
308
+
309
+ - <code>Error</code> <ul>
310
+ <li>Throws an error if the RealWorldReceivable contract is not available on the network.</li>
311
+ </ul>
312
+
313
+
314
+ | Param | Type | Description |
315
+ | --- | --- | --- |
316
+ | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction. Note only the receivable owner can pay the receivable.</p> |
317
+ | receivableTokenId | <code>BigNumberish</code> | <p>The Id of the receivable token to pay.</p> |
318
+ | paymentAmount | <code>number</code> | <p>The amount to pay the receivable.</p> |
319
+ | [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
320
+
321
+ <a name="ReceivableService.createReceivable"></a>
322
+
323
+ ### ReceivableService.createReceivable(signer, poolName, poolType, currencyCode, receivableAmount, maturityDate, uri, [gasOpts]) ⇒ <code>Promise.&lt;(TransactionResponse\|null)&gt;</code>
324
+ <p>Creates a new RealWorldReceivable token on the given chain of the signer</p>
325
+
326
+ **Kind**: static method of [<code>ReceivableService</code>](#ReceivableService)
327
+ **Returns**: <code>Promise.&lt;(TransactionResponse\|null)&gt;</code> - <ul>
328
+ <li>A Promise of the transaction response.</li>
329
+ </ul>
330
+ **Throws**:
331
+
332
+ - <code>Error</code> <ul>
333
+ <li>Throws an error if the RealWorldReceivable contract is not available on the network, or if a token already exists with the same metadata URI.</li>
334
+ </ul>
335
+
336
+
337
+ | Param | Type | Description |
338
+ | --- | --- | --- |
339
+ | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
340
+ | 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> |
341
+ | 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> |
342
+ | currencyCode | <code>number</code> | <p>The ISO 4217 currency code that the receivable is denominated in</p> |
343
+ | receivableAmount | <code>number</code> | <p>The amount of the receivable token to mint.</p> |
344
+ | maturityDate | <code>number</code> | <p>The maturity date of the receivable token, in UNIX timestamp format.</p> |
345
+ | uri | <code>string</code> | <p>The URI of the receivable token metadata.</p> |
346
+ | [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
347
+
348
+ <a name="ReceivableService.uploadOrFetchMetadataURI"></a>
349
+
350
+ ### ReceivableService.uploadOrFetchMetadataURI(signer, privateKey, chainId, poolName, poolType, metadata, referenceId, extraTags, [lazyFund]) ⇒ <code>Promise.&lt;string&gt;</code>
351
+ <p>Uploads metadata onto ARWeave (or fetches the existing metadata with the same reference Id) and returns the ARWeave URL</p>
352
+
353
+ **Kind**: static method of [<code>ReceivableService</code>](#ReceivableService)
354
+ **Returns**: <code>Promise.&lt;string&gt;</code> - <ul>
355
+ <li>The ARWeave metadata URI.</li>
356
+ </ul>
357
+
358
+ | Param | Type | Default | Description |
359
+ | --- | --- | --- | --- |
360
+ | signer | <code>ethers.Signer</code> | | <p>An ethers.signer instance used to de-dupe metadata uploads.</p> |
361
+ | privateKey | <code>string</code> | | <p>Private key of the wallet used to upload metadata to ARWeave.</p> |
362
+ | chainId | <code>number</code> | | <p>The chain ID to mint the receivable token on and pay ARWeave funds from.</p> |
363
+ | poolName | <code>POOL\_NAME</code> | | <p>The pool name. Used to lookup the pool address to pay to.</p> |
364
+ | poolType | <code>POOL\_TYPE</code> | | <p>The pool type. Used to lookup the pool address to pay to.</p> |
365
+ | metadata | <code>Record.&lt;string, any&gt;</code> | | <p>The metadata in JSON format. This will be uploaded onto ARWeave</p> |
366
+ | referenceId | <code>string</code> | | <p>An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.</p> |
367
+ | extraTags | <code>Array.&lt;{name: string, value: string}&gt;</code> | | <p>Any extraTags you'd like to tag your metadata with. Note that metadata on ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.</p> |
368
+ | [lazyFund] | <code>boolean</code> | <code>true</code> | <p>Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.</p> |
369
+
370
+ <a name="ReceivableService.createReceivableWithMetadata"></a>
371
+
372
+ ### ReceivableService.createReceivableWithMetadata(signer, privateKey, chainId, poolName, poolType, currencyCode, receivableAmount, maturityDate, metadata, referenceId, extraTags, [lazyFund], [gasOpts]) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
373
+ <p>Creates a RealWorldReceivable token with metadata uploaded onto ARWeave</p>
374
+
375
+ **Kind**: static method of [<code>ReceivableService</code>](#ReceivableService)
376
+ **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
377
+ <li>The transaction receipt.</li>
378
+ </ul>
379
+
380
+ | Param | Type | Default | Description |
381
+ | --- | --- | --- | --- |
382
+ | signer | <code>ethers.Signer</code> | | <p>An ethers.signer instance used to de-dupe metadata uploads.</p> |
383
+ | privateKey | <code>string</code> | | <p>Private key of the wallet used to upload metadata to ARWeave.</p> |
384
+ | chainId | <code>number</code> | | <p>The chain ID to mint the receivable token on and pay ARWeave funds from.</p> |
385
+ | poolName | <code>POOL\_NAME</code> | | <p>The pool name. Used to lookup the pool address to pay to.</p> |
386
+ | poolType | <code>POOL\_TYPE</code> | | <p>The pool type. Used to lookup the pool address to pay to.</p> |
387
+ | currencyCode | <code>number</code> | | <p>The ISO 4217 currency code that the receivable is denominated in</p> |
388
+ | receivableAmount | <code>number</code> | | <p>The receivable amount.</p> |
389
+ | maturityDate | <code>number</code> | | <p>The maturity date of the receivable, in UNIX timestamp format.</p> |
390
+ | metadata | <code>Record.&lt;string, any&gt;</code> | | <p>The metadata in JSON format. This will be uploaded onto ARWeave</p> |
391
+ | referenceId | <code>string</code> | | <p>An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.</p> |
392
+ | extraTags | <code>Array.&lt;{name: string, value: string}&gt;</code> | | <p>Any extraTags you'd like to tag your metadata with. Note that metadata on ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.</p> |
393
+ | [lazyFund] | <code>boolean</code> | <code>true</code> | <p>Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.</p> |
394
+ | [gasOpts] | <code>Overrides</code> | | <p>Optional gas overrides for the transaction.</p> |
395
+
396
+ <a name="ReceivableService.loadReceivablesOfOwnerWithMetadata"></a>
397
+
398
+ ### ReceivableService.loadReceivablesOfOwnerWithMetadata(chainID, owner, poolName, poolType, pagination) ⇒ <code>Promise.&lt;Array.&lt;RealWorldReceivableInfo&gt;&gt;</code>
399
+ <p>Loads all RWRs belonging to the specified owner, including the RWR metadata</p>
400
+
401
+ **Kind**: static method of [<code>ReceivableService</code>](#ReceivableService)
402
+ **Returns**: <code>Promise.&lt;Array.&lt;RealWorldReceivableInfo&gt;&gt;</code> - <ul>
403
+ <li>An array of receivables owned by the owner for the pool.</li>
404
+ </ul>
405
+
406
+ | Param | Type | Description |
407
+ | --- | --- | --- |
408
+ | chainID | <code>number</code> | <p>The chain to query for receivables</p> |
409
+ | owner | <code>string</code> | <p>The receivable token owner to query from.</p> |
410
+ | poolName | <code>POOL\_NAME</code> | <p>The pool name. Used to lookup the pool address to pay to.</p> |
411
+ | poolType | <code>POOL\_TYPE</code> | <p>The pool type. Used to lookup the pool address to pay to.</p> |
412
+ | pagination | [<code>Pagination</code>](#Pagination) | <p>The pagination option.</p> |
413
+
414
+ <a name="ReceivableService.getTotalCountOfReceivables"></a>
415
+
416
+ ### ReceivableService.getTotalCountOfReceivables(provider, owner) ⇒ <code>Promise.&lt;number&gt;</code>
417
+ <p>Get the total count of all RWRs belonging to the specified owner</p>
418
+
419
+ **Kind**: static method of [<code>ReceivableService</code>](#ReceivableService)
420
+ **Returns**: <code>Promise.&lt;number&gt;</code> - <ul>
421
+ <li>Total count of receivables owned by the owner for the pool.</li>
422
+ </ul>
423
+
424
+ | Param | Type | Description |
425
+ | --- | --- | --- |
426
+ | provider | <code>ethers.providers.Provider</code> | <p>The provider used to query the chain.</p> |
427
+ | owner | <code>string</code> | <p>The receivable token owner to query from.</p> |
428
+
429
+ <a name="SubgraphService"></a>
430
+
431
+ ## SubgraphService : <code>object</code>
432
+ <p>An object that contains functions to interact with Huma's Subgraph storage.</p>
433
+
434
+ **Kind**: global namespace
435
+
436
+ * [SubgraphService](#SubgraphService) : <code>object</code>
437
+ * [.getSubgraphUrlForChainId(chainId)](#SubgraphService.getSubgraphUrlForChainId) ⇒ <code>string</code>
438
+ * [.getCreditEventsForUser(userAddress, chainId, poolName, poolType, event)](#SubgraphService.getCreditEventsForUser) ⇒ <code>Promise.&lt;Array.&lt;CreditEventPayload&gt;&gt;</code>
439
+ * [.getLastFactorizedAmountFromPool(userAddress, chainId, poolName, poolType)](#SubgraphService.getLastFactorizedAmountFromPool) ⇒ <code>Promise.&lt;number&gt;</code>
440
+ * [.getRWReceivableInfo(userAddress, chainId, poolName, poolType, pagination)](#SubgraphService.getRWReceivableInfo) ⇒ <code>Promise.&lt;RealWorldReceivableInfoBase&gt;</code>
441
+ * [.getReceivableV2Info(userAddress, chainId, poolName, poolType, pagination)](#SubgraphService.getReceivableV2Info) ⇒ <code>Promise.&lt;RealWorldReceivableInfoBase&gt;</code>
442
+ * [.checkBorrowAndLendHistory(chainId, pool, userAddress)](#SubgraphService.checkBorrowAndLendHistory) ⇒ <code>Promise.&lt;{hasBorrowHistory: boolean, hasLendHistory: boolean}&gt;</code>
443
+
444
+ <a name="SubgraphService.getSubgraphUrlForChainId"></a>
445
+
446
+ ### SubgraphService.getSubgraphUrlForChainId(chainId) ⇒ <code>string</code>
447
+ <p>Returns the subgraph URL for a given chain ID.</p>
448
+
449
+ **Kind**: static method of [<code>SubgraphService</code>](#SubgraphService)
450
+ **Returns**: <code>string</code> - <p>The subgraph URL for the given chain ID.</p>
451
+
452
+ | Param | Type | Description |
453
+ | --- | --- | --- |
454
+ | chainId | <code>number</code> | <p>The ID of the chain.</p> |
455
+
456
+ <a name="SubgraphService.getCreditEventsForUser"></a>
457
+
458
+ ### SubgraphService.getCreditEventsForUser(userAddress, chainId, poolName, poolType, event) ⇒ <code>Promise.&lt;Array.&lt;CreditEventPayload&gt;&gt;</code>
459
+ <p>Returns the credit events for a given user.</p>
460
+
461
+ **Kind**: static method of [<code>SubgraphService</code>](#SubgraphService)
462
+ **Returns**: <code>Promise.&lt;Array.&lt;CreditEventPayload&gt;&gt;</code> - <p>The credit events for the given user.</p>
463
+
464
+ | Param | Type | Description |
465
+ | --- | --- | --- |
466
+ | userAddress | <code>string</code> | <p>The address of the user.</p> |
467
+ | chainId | <code>number</code> | <p>The ID of the chain.</p> |
468
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the pool.</p> |
469
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool.</p> |
470
+ | event | <code>Array.&lt;number&gt;</code> | <p>The event types to filter by.</p> |
471
+
472
+ <a name="SubgraphService.getLastFactorizedAmountFromPool"></a>
473
+
474
+ ### SubgraphService.getLastFactorizedAmountFromPool(userAddress, chainId, poolName, poolType) ⇒ <code>Promise.&lt;number&gt;</code>
475
+ <p>Returns the last factorized amount for a given user and pool.</p>
476
+
477
+ **Kind**: static method of [<code>SubgraphService</code>](#SubgraphService)
478
+ **Returns**: <code>Promise.&lt;number&gt;</code> - <p>The last factorized amount for the given user and pool.</p>
479
+
480
+ | Param | Type | Description |
481
+ | --- | --- | --- |
482
+ | userAddress | <code>string</code> | <p>The address of the user.</p> |
483
+ | chainId | <code>number</code> | <p>The ID of the chain.</p> |
484
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the pool.</p> |
485
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool.</p> |
486
+
487
+ <a name="SubgraphService.getRWReceivableInfo"></a>
488
+
489
+ ### SubgraphService.getRWReceivableInfo(userAddress, chainId, poolName, poolType, pagination) ⇒ <code>Promise.&lt;RealWorldReceivableInfoBase&gt;</code>
490
+ <p>Returns the paginated real world receivables' info.</p>
491
+
492
+ **Kind**: static method of [<code>SubgraphService</code>](#SubgraphService)
493
+ **Returns**: <code>Promise.&lt;RealWorldReceivableInfoBase&gt;</code> - <p>The paginated real world receivables' info.</p>
494
+
495
+ | Param | Type | Description |
496
+ | --- | --- | --- |
497
+ | userAddress | <code>string</code> | <p>The address of the user.</p> |
498
+ | chainId | <code>number</code> | <p>The ID of the chain.</p> |
499
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the pool.</p> |
500
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool.</p> |
501
+ | pagination | [<code>Pagination</code>](#Pagination) | <p>The pagination option.</p> |
502
+
503
+ <a name="SubgraphService.getReceivableV2Info"></a>
504
+
505
+ ### SubgraphService.getReceivableV2Info(userAddress, chainId, poolName, poolType, pagination) ⇒ <code>Promise.&lt;RealWorldReceivableInfoBase&gt;</code>
506
+ <p>Returns the paginated V2 receivables' info for the original creator.</p>
507
+
508
+ **Kind**: static method of [<code>SubgraphService</code>](#SubgraphService)
509
+ **Returns**: <code>Promise.&lt;RealWorldReceivableInfoBase&gt;</code> - <p>The paginated real world receivables' info.</p>
510
+
511
+ | Param | Type | Description |
512
+ | --- | --- | --- |
513
+ | userAddress | <code>string</code> | <p>The address of the original creator.</p> |
514
+ | chainId | <code>number</code> | <p>The ID of the chain.</p> |
515
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the pool.</p> |
516
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool.</p> |
517
+ | pagination | [<code>Pagination</code>](#Pagination) | <p>The pagination option.</p> |
518
+
519
+ <a name="SubgraphService.checkBorrowAndLendHistory"></a>
520
+
521
+ ### SubgraphService.checkBorrowAndLendHistory(chainId, pool, userAddress) ⇒ <code>Promise.&lt;{hasBorrowHistory: boolean, hasLendHistory: boolean}&gt;</code>
522
+ <p>Returns if user has borrow or lend history.</p>
523
+
524
+ **Kind**: static method of [<code>SubgraphService</code>](#SubgraphService)
525
+ **Returns**: <code>Promise.&lt;{hasBorrowHistory: boolean, hasLendHistory: boolean}&gt;</code> - <p>If user has borrow or lend history.</p>
526
+
527
+ | Param | Type | Description |
528
+ | --- | --- | --- |
529
+ | chainId | <code>number</code> | <p>The ID of the chain.</p> |
530
+ | pool | <code>string</code> | <p>The address of the pool.</p> |
531
+ | userAddress | <code>string</code> | <p>The address of the user.</p> |
532
+
533
+ <a name="defaultWrapper"></a>
534
+
535
+ ## defaultWrapper()
536
+ <p>All built-in and custom scalars, mapped to their actual values</p>
537
+
538
+ **Kind**: global function
539
+ <a name="approveERC20AllowanceIfInsufficient"></a>
540
+
541
+ ## approveERC20AllowanceIfInsufficient(signer, tokenAddress, spenderAddress, allowanceAmount, [gasOpts]) ⇒ <code>Promise.&lt;(TransactionResponse\|null)&gt;</code>
542
+ <p>Approves an ERC20 allowance for a spender address, if the current allowance is insufficient.
543
+ Allowance is required to do certain actions on the Huma protocol (e.g. makePayment)</p>
544
+
545
+ **Kind**: global function
546
+ **Returns**: <code>Promise.&lt;(TransactionResponse\|null)&gt;</code> - <ul>
547
+ <li>A Promise of the transaction response, or null if the allowance was already sufficient.</li>
548
+ </ul>
549
+
550
+ | Param | Type | Description |
551
+ | --- | --- | --- |
552
+ | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
553
+ | tokenAddress | <code>string</code> | <p>The address of the ERC20 token to approve.</p> |
554
+ | spenderAddress | <code>string</code> | <p>The address of the spender to approve an allowance for.</p> |
555
+ | allowanceAmount | <code>BigNumber</code> | <p>The amount of tokens to approve, if applicable. Denominated in the ERC20 tokens.</p> |
556
+ | [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
557
+
558
+ <a name="getERC20TransferableReceivableContract"></a>
559
+
560
+ ## getERC20TransferableReceivableContract(signerOrProvider, chainId) ⇒ <code>Contract</code> \| <code>null</code>
561
+ <p>Returns an ethers contract instance for the ERC20TransferableReceivable contract
562
+ associated with the given pool name on the current chain.</p>
563
+
564
+ **Kind**: global function
565
+ **Returns**: <code>Contract</code> \| <code>null</code> - <p>A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.</p>
566
+
567
+ | Param | Type | Description |
568
+ | --- | --- | --- |
569
+ | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The provider or signer instance to use for the contract.</p> |
570
+ | chainId | <code>number</code> | <p>The chain id where the contract instance exists</p> |
571
+
572
+ <a name="getPoolContract"></a>
573
+
574
+ ## getPoolContract(signerOrProvider, chainId, poolName, poolType) ⇒ <code>Contract</code> \| <code>null</code>
575
+ <p>Returns an ethers contract instance for a Huma pool contract</p>
576
+
577
+ **Kind**: global function
578
+ **Returns**: <code>Contract</code> \| <code>null</code> - <p>A contract instance for the Pool contract or null if it could not be found.</p>
579
+
580
+ | Param | Type | Description |
581
+ | --- | --- | --- |
582
+ | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The provider or signer instance to use for the contract.</p> |
583
+ | chainId | <code>number</code> | <p>The chain id where the contract instance exists</p> |
584
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the pool contract to get.</p> |
585
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool contract to get.</p> |
586
+
587
+ <a name="getCreditRecord"></a>
588
+
589
+ ## getCreditRecord(address, signerOrProvider, chainId, poolName, poolType) ⇒ <code>Promise.&lt;CreditRecord&gt;</code>
590
+ <p>Gets the credit record of a wallet in a Huma pool. Denominated in the ERC20 tokens of the pool.</p>
591
+
592
+ **Kind**: global function
593
+ **Returns**: <code>Promise.&lt;CreditRecord&gt;</code> - <ul>
594
+ <li>A Promise of the transaction response.</li>
595
+ </ul>
596
+
597
+ | Param | Type | Description |
598
+ | --- | --- | --- |
599
+ | address | <code>string</code> | <p>The address to lookup.</p> |
600
+ | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The signer or provider used to read data.</p> |
601
+ | chainId | <code>number</code> | <p>The chain ID of the pool. Used to lookup the pool address.</p> |
602
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool. Used to lookup the pool address.</p> |
603
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the credit pool. Used to lookup the pool address.</p> |
604
+
605
+ <a name="getCreditRecord.CreditRecord"></a>
606
+
607
+ ### getCreditRecord.CreditRecord : <code>Object</code>
608
+ <p>Return type of getCreditRecord</p>
609
+
610
+ **Kind**: static typedef of [<code>getCreditRecord</code>](#getCreditRecord)
611
+ **Properties**
612
+
613
+ | Name | Type | Description |
614
+ | --- | --- | --- |
615
+ | unbilledPrincipal | <code>BigNumber</code> | <p>The amount of principal not included in the bill</p> |
616
+ | dueDate | <code>BigNumber</code> | <p>Unix timestamp due date of the next payment</p> |
617
+ | 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> |
618
+ | totalDue | <code>BigNumber</code> | <p>The due amount of the next payment</p> |
619
+ | feesAndInterestDue | <code>BigNumber</code> | <p>Interest and fees due for the next payment</p> |
620
+ | missedPeriods | <code>number</code> | <h1>of consecutive missed payments, for default processing</h1> |
621
+ | remainingPeriods | <code>number</code> | <h1>of payment periods until the maturity of the credit line</h1> |
622
+ | 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> |
623
+
624
+ <a name="getTotalDue"></a>
625
+
626
+ ## getTotalDue(address, signerOrProvider, chainId, poolName, poolType) ⇒ <code>Promise.&lt;BigNumber&gt;</code>
627
+ <p>Gets the total due for a Huma pool of the given wallet. Denominated in the ERC20 tokens of the pool.</p>
628
+
629
+ **Kind**: global function
630
+ **Returns**: <code>Promise.&lt;BigNumber&gt;</code> - <ul>
631
+ <li>A Promise of the transaction response.</li>
632
+ </ul>
633
+
634
+ | Param | Type | Description |
635
+ | --- | --- | --- |
636
+ | address | <code>string</code> | <p>The address to lookup.</p> |
637
+ | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The signer or provider used to read data.</p> |
638
+ | chainId | <code>number</code> | <p>The chain ID of the pool. Used to lookup the pool address.</p> |
639
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool. Used to lookup the pool address.</p> |
640
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the credit pool. Used to lookup the pool address.</p> |
641
+
642
+ <a name="drawdownFromPool"></a>
643
+
644
+ ## drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, [gasOpts]) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
645
+ <p>Calls drawdown on a Huma pool contract</p>
646
+
647
+ **Kind**: global function
648
+ **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
649
+ <li>A Promise of the transaction response.</li>
650
+ </ul>
651
+
652
+ | Param | Type | Description |
653
+ | --- | --- | --- |
654
+ | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
655
+ | chainId | <code>number</code> | <p>The chain ID of the pool to call drawdown on. Used to lookup the pool address.</p> |
656
+ | 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> |
657
+ | 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> |
658
+ | drawdownAmount | <code>BigNumberish</code> | <p>The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.</p> |
659
+ | [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
660
+
661
+ <a name="makePaymentToPool"></a>
662
+
663
+ ## makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, [gasOpts]) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
664
+ <p>Calls makePayment on a Huma pool contract. If the pool does not have sufficient allowance to complete the operation,
665
+ attempt to first increase the allowance of the pool.</p>
666
+
667
+ **Kind**: global function
668
+ **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
669
+ <li>A Promise of the transaction response.</li>
670
+ </ul>
671
+
672
+ | Param | Type | Description |
673
+ | --- | --- | --- |
674
+ | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
675
+ | chainId | <code>number</code> | <p>The chain ID of the pool to call drawdown on. Used to lookup the pool address.</p> |
676
+ | 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> |
677
+ | 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> |
678
+ | paymentAmount | <code>BigNumberish</code> | <p>The amount of tokens to payback, denominated in the ERC20 tokens of the pool.</p> |
679
+ | [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
680
+
681
+ <a name="approvePoolAllowance"></a>
682
+
683
+ ## approvePoolAllowance(signer, chainId, poolName, poolType, allowanceAmount, [gasOpts]) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
684
+ <p>Approves an allowance for a Huma pool contract, which is required to do certain actions (e.g. makePayment)</p>
685
+
686
+ **Kind**: global function
687
+ **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
688
+ <li>A Promise of the transaction response.</li>
689
+ </ul>
690
+
691
+ | Param | Type | Description |
692
+ | --- | --- | --- |
693
+ | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
694
+ | chainId | <code>number</code> | <p>The chain ID of the pool to call drawdown on. Used to lookup the pool address.</p> |
695
+ | 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> |
696
+ | 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> |
697
+ | allowanceAmount | <code>BigNumberish</code> | <p>The amount of tokens to payback, denominated in the ERC20 tokens of the pool.</p> |
698
+ | [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
699
+
700
+ <a name="getRealWorldReceivableContract"></a>
701
+
702
+ ## getRealWorldReceivableContract(signerOrProvider, chainId) ⇒ <code>Contract</code> \| <code>null</code>
703
+ <p>Returns an ethers contract instance for the RealWorldReceivable contract
704
+ associated with the given pool name on the current chain.</p>
705
+
706
+ **Kind**: global function
707
+ **Returns**: <code>Contract</code> \| <code>null</code> - <p>A contract instance for the RealWorldReceivable contract or null if it could not be found.</p>
708
+
709
+ | Param | Type | Description |
710
+ | --- | --- | --- |
711
+ | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The provider or signer instance to use for the contract.</p> |
712
+ | chainId | <code>number</code> | <p>The chain id where the contract instance exists</p> |
713
+
714
+ <a name="getAvailableBalanceForPool"></a>
715
+
716
+ ## getAvailableBalanceForPool(poolName, provider)
717
+ <p>Returns the current pool balance available for borrowing</p>
718
+
719
+ **Kind**: global function
720
+
721
+ | Param | Type | Description |
722
+ | --- | --- | --- |
723
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool to get the contract instance for.</p> |
724
+ | provider | <code>JsonRpcProvider</code> \| <code>Web3Provider</code> | <p>The provider instance to use for reading from the contract.</p> |
725
+
726
+ <a name="getCreditRecordForPool"></a>
727
+
728
+ ## getCreditRecordForPool(poolName, borrower, provider)
729
+ <p>Returns the credit record of the borrower</p>
730
+
731
+ **Kind**: global function
732
+
733
+ | Param | Type | Description |
734
+ | --- | --- | --- |
735
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool to get the contract instance for.</p> |
736
+ | borrower | <code>string</code> | <p>The address of the borrower to check the credit record for</p> |
737
+ | provider | <code>JsonRpcProvider</code> \| <code>Web3Provider</code> | <p>The provider instance to use for reading from the contract.</p> |
738
+
739
+ <a name="getAvailableCreditForPool"></a>
740
+
741
+ ## getAvailableCreditForPool(borrower, poolName, provider)
742
+ <p>Returns the borrower's remaining credit they can use for borrowing. Note that this might not be
743
+ currently available for borrowing as the credit limit might exceed the available pool balance. Use
744
+ getPoolBalance() to get the current available pool balance.</p>
745
+
746
+ **Kind**: global function
747
+
748
+ | Param | Type | Description |
749
+ | --- | --- | --- |
750
+ | borrower | <code>string</code> | <p>The address of the borrower to check the available credit for.</p> |
751
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool to get the contract instance for.</p> |
752
+ | provider | <code>JsonRpcProvider</code> \| <code>Web3Provider</code> | <p>The provider instance to use for reading from the contract.</p> |
753
+
754
+ <a name="getReceivableBackedCreditLineContractV2"></a>
755
+
756
+ ## getReceivableBackedCreditLineContractV2(signerOrProvider, poolName) ⇒ <code>ReceivableBackedCreditLine</code> \| <code>null</code>
757
+ <p>Returns an ethers contract instance for the V2 Receivable contract
758
+ associated with the given pool name on the current chain.</p>
759
+
760
+ **Kind**: global function
761
+ **Returns**: <code>ReceivableBackedCreditLine</code> \| <code>null</code> - <p>A contract instance for the ReceivableBackedCreditLine contract or null if it could not be found.</p>
762
+
763
+ | Param | Type | Description |
764
+ | --- | --- | --- |
765
+ | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The provider or signer instance to use for the contract.</p> |
766
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool to get the contract instance for.</p> |
767
+
768
+ <a name="getTotalDueV2"></a>
769
+
770
+ ## getTotalDueV2(provider, poolName) ⇒ <code>BigNumber</code> \| <code>null</code>
771
+ <p>Returns account's total due amount in BigNumber format
772
+ associated with the given pool name on the current chain.</p>
773
+
774
+ **Kind**: global function
775
+ **Returns**: <code>BigNumber</code> \| <code>null</code> - <p>The account's total due amount in BigNumber format</p>
776
+
777
+ | Param | Type | Description |
778
+ | --- | --- | --- |
779
+ | provider | <code>JsonRpcProvider</code> \| <code>Web3Provider</code> | <p>The provider instance to use for the contract.</p> |
780
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool to get the contract instance for.</p> |
781
+
782
+ <a name="drawdownWithReceivable"></a>
783
+
784
+ ## drawdownWithReceivable(signer, poolName, receivableId, drawdownAmount, [gasOpts]) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
785
+ <p>Draws down from a pool using a receivable.</p>
786
+
787
+ **Kind**: global function
788
+ **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
789
+ <li>A Promise of the transaction response.</li>
790
+ </ul>
791
+
792
+ | Param | Type | Description |
793
+ | --- | --- | --- |
794
+ | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
795
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool to drawdown from.</p> |
796
+ | receivableId | <code>BigNumberish</code> | <p>The ID of the receivable.</p> |
797
+ | drawdownAmount | <code>BigNumberish</code> | <p>The amount to drawdown.</p> |
798
+ | [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
799
+
800
+ <a name="makePaymentWithReceivable"></a>
801
+
802
+ ## makePaymentWithReceivable(signer, poolName, receivableId, paymentAmount, principalOnly, [gasOpts]) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
803
+ <p>Makes a payment with a receivable.</p>
804
+
805
+ **Kind**: global function
806
+ **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
807
+ <li>A Promise of the transaction response.</li>
808
+ </ul>
809
+
810
+ | Param | Type | Description |
811
+ | --- | --- | --- |
812
+ | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
813
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the pool to interact with.</p> |
814
+ | receivableId | <code>BigNumberish</code> | <p>The ID of the receivable.</p> |
815
+ | paymentAmount | <code>BigNumberish</code> | <p>The amount to payback.</p> |
816
+ | principalOnly | <code>boolean</code> | <p>Whether this payment should ONLY apply to the principal</p> |
817
+ | [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
818
+
819
+ <a name="makePrincipalPaymentAndDrawdownWithReceivable"></a>
820
+
821
+ ## makePrincipalPaymentAndDrawdownWithReceivable(signer, poolName, paymentReceivableId, paymentAmount, drawdownReceivableId, drawdownAmount, [gasOpts]) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
822
+ <p>Makes a principal payment and drawdown with receivables.</p>
823
+
824
+ **Kind**: global function
825
+ **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
826
+ <li>A Promise of the transaction response.</li>
827
+ </ul>
828
+
829
+ | Param | Type | Description |
830
+ | --- | --- | --- |
831
+ | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
832
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the pool to interact with.</p> |
833
+ | paymentReceivableId | <code>BigNumberish</code> | <p>The ID of the receivable for payment.</p> |
834
+ | paymentAmount | <code>BigNumberish</code> | <p>The amount to payback.</p> |
835
+ | drawdownReceivableId | <code>BigNumberish</code> | <p>The ID of the drawdown receivable.</p> |
836
+ | drawdownAmount | <code>BigNumberish</code> | <p>The amount to drawdown.</p> |
837
+ | [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
838
+
839
+ <a name="getReceivableContractV2"></a>
840
+
841
+ ## getReceivableContractV2(poolName, signer) ⇒ <code>Contract</code> \| <code>null</code>
842
+ <p>Returns an ethers contract instance for the V2 Receivable contract
843
+ associated with the given pool name on the current chain.</p>
844
+
845
+ **Kind**: global function
846
+ **Returns**: <code>Contract</code> \| <code>null</code> - <p>A contract instance for the Receivable contract or null if it could not be found.</p>
847
+
848
+ | Param | Type | Description |
849
+ | --- | --- | --- |
850
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the pool.</p> |
851
+ | signer | <code>ethers.Signer</code> | <p>The signer instance to use for the contract.</p> |
852
+
853
+ <a name="getReceivableTokenIdFromReferenceId"></a>
854
+
855
+ ## getReceivableTokenIdFromReferenceId(referenceId, creator, poolName, signer) ⇒
856
+ <p>Retrieves the receivable token ID associated with a given reference ID.</p>
857
+
858
+ **Kind**: global function
859
+ **Returns**: <p>A promise that resolves to the receivable token ID.</p>
860
+
861
+ | Param | Description |
862
+ | --- | --- |
863
+ | referenceId | <p>The reference ID of the receivable.</p> |
864
+ | creator | <p>The creator of the receivable.</p> |
865
+ | poolName | <p>The name of the pool.</p> |
866
+ | signer | <p>The signer used for the contract interaction.</p> |
867
+
868
+ <a name="preapprove"></a>
869
+
870
+ ## preapprove(payload, chainId) ⇒ <code>Promise.&lt;Approval&gt;</code>
871
+ <p>Checks whether or not a credit underwriting request to Huma's EAVerse would be approved.
872
+ Note that this does not approve a creditline in Huma's pools and an approve call is still required.</p>
873
+
874
+ **Kind**: global function
875
+ **Returns**: <code>Promise.&lt;Approval&gt;</code> - <p>Promise that returns the approval on success.</p>
876
+
877
+ | Param | Type | Description |
878
+ | --- | --- | --- |
879
+ | payload | <code>EAPreapprovalPayload</code> | <p>The payload for the underwrite approval.</p> |
880
+ | chainId | <code>number</code> | <p>The chain ID.</p> |
881
+
882
+ <a name="getChainIdFromJsonSignerOrProvider"></a>
883
+
884
+ ## getChainIdFromJsonSignerOrProvider(signerOrProvider) ⇒ <code>number</code>
885
+ <p>Get the chain ID from a signer or provider object.</p>
886
+
887
+ **Kind**: global function
888
+ **Returns**: <code>number</code> - <ul>
889
+ <li>The chain ID.</li>
890
+ </ul>
891
+
892
+ | Param | Type | Description |
893
+ | --- | --- | --- |
894
+ | signerOrProvider | <code>JsonRpcProvider</code> \| <code>JsonRpcSigner</code> | <p>The signer or provider object to get the chain ID from.</p> |
895
+
896
+ <a name="getChainIdFromSignerOrProvider"></a>
897
+
898
+ ## getChainIdFromSignerOrProvider(signerOrProvider) ⇒ <code>number</code>
899
+ <p>Get the chain ID from a signer or provider object.</p>
900
+
901
+ **Kind**: global function
902
+ **Returns**: <code>number</code> - <ul>
903
+ <li>The chain ID.</li>
904
+ </ul>
905
+
906
+ | Param | Type | Description |
907
+ | --- | --- | --- |
908
+ | signerOrProvider | <code>ethers.provider.Provider</code> \| <code>ethers.Signer</code> | <p>The signer or provider object to get the chain ID from.</p> |
909
+
910
+ <a name="getPoolInfo"></a>
911
+
912
+ ## getPoolInfo(poolName, poolType) ⇒ <code>PoolInfoType</code> \| <code>undefined</code>
913
+ <p>Returns the pool info based on the provided pool name and type, using the same chain ID as the provider/signer given</p>
914
+
915
+ **Kind**: global function
916
+ **Returns**: <code>PoolInfoType</code> \| <code>undefined</code> - <ul>
917
+ <li>The pool info or undefined if the chain ID is not supported.</li>
918
+ </ul>
919
+
920
+ | Param | Type | Description |
921
+ | --- | --- | --- |
922
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the pool.</p> |
923
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool.</p> |
924
+
925
+ <a name="isSetComputeLimitInstruction"></a>
926
+
927
+ ## isSetComputeLimitInstruction()
928
+ <p>Check if a given instruction is a SetComputeUnitLimit instruction
929
+ See https://github.com/solana-program/compute-budget/blob/main/clients/js/src/generated/programs/computeBudget.ts#L29</p>
930
+
931
+ **Kind**: global function
932
+ <a name="IrysConstructorArgs"></a>
933
+
934
+ ## IrysConstructorArgs : <code>Object</code>
935
+ <p>Represents the constructor arguments for the Irys service.</p>
936
+
937
+ **Kind**: global typedef
938
+ **Properties**
939
+
940
+ | Name | Type | Description |
941
+ | --- | --- | --- |
942
+ | [url] | <code>string</code> | <p>The URL of the Irys service.</p> |
943
+ | [network] | <code>Network</code> | <p>The network configuration for the Irys service. Can be mainnet or devnet.</p> |
944
+ | token | <code>string</code> | <p>The token for authentication.</p> |
945
+ | [key] | <code>string</code> | <p>The key for encryption.</p> |
946
+ | [config] | <code>IrysConfig</code> | <p>Additional configuration options for the Irys service.</p> |
947
+
948
+ <a name="ApprovalResult"></a>
949
+
950
+ ## ApprovalResult : <code>Object</code>
951
+ <p>Object representing the response to the underwriting approval request.</p>
952
+
953
+ **Kind**: global typedef
954
+ <a name="EAPayload"></a>
955
+
956
+ ## EAPayload : <code>Object</code>
957
+ <p>Object representing an invoice payload for underwriting approval.</p>
958
+
959
+ **Kind**: global typedef
960
+ <a name="CreditEventPayload"></a>
961
+
962
+ ## CreditEventPayload : <code>Object</code>
963
+ <p>Represents the payload of a credit event.</p>
964
+
965
+ **Kind**: global typedef
966
+ <a name="Pagination"></a>
967
+
968
+ ## Pagination : <code>Object</code>
969
+ <p>Represents the pagination options for a query.</p>
970
+
971
+ **Kind**: global typedef
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huma-finance/sdk",
3
- "version": "0.0.77-beta.1026+a882364",
3
+ "version": "0.0.77",
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/bignumber": "^5.6.0",
29
29
  "@ethersproject/constants": "^5.7.0",
30
30
  "@ethersproject/contracts": "^5.7.0",
31
- "@huma-finance/shared": "^0.0.77-beta.1026+a882364",
31
+ "@huma-finance/shared": "^0.0.77",
32
32
  "@irys/sdk": "^0.2.11",
33
33
  "axios": "^1.4.0",
34
34
  "bignumber.js": "^9.1.1",
@@ -113,5 +113,5 @@
113
113
  "optionalDependencies": {
114
114
  "encoding": "^0.1.13"
115
115
  },
116
- "gitHead": "a882364d8a88745d37c45ae136588a3009c04efe"
116
+ "gitHead": "5de994106ccdbf81425fcad00e42e111838caf6e"
117
117
  }