From 60b58def4d7d758c2e9a7c2c6d377cc814da6fa7 Mon Sep 17 00:00:00 2001 From: Michael Liu Date: Wed, 11 Sep 2024 19:06:09 -0400 Subject: [PATCH] Docs --- packages/huma-sdk/API.md | 961 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 961 insertions(+) diff --git a/packages/huma-sdk/API.md b/packages/huma-sdk/API.md index e69de29..0c4213d 100644 --- a/packages/huma-sdk/API.md +++ b/packages/huma-sdk/API.md @@ -0,0 +1,961 @@ +## Objects + +
+
ARWeaveService : object
+

An object that contains functions to interact with Huma-related data stored on ARWeave

+
EAService : object
+

An object that contains functions to interact with Huma's EAVerse service.

+
ReceivableService : object
+

An object that contains functions to interact with Huma's receivables.

+
SubgraphService : object
+

An object that contains functions to interact with Huma's Subgraph storage.

+
+ +## Functions + +
+
defaultWrapper()
+

All built-in and custom scalars, mapped to their actual values

+
approveERC20AllowanceIfInsufficient(signer, tokenAddress, spenderAddress, allowanceAmount, [gasOpts])Promise.<(TransactionResponse|null)>
+

Approves an ERC20 allowance for a spender address, if the current allowance is insufficient. +Allowance is required to do certain actions on the Huma protocol (e.g. makePayment)

+
getERC20TransferableReceivableContract(signerOrProvider, chainId)Contract | null
+

Returns an ethers contract instance for the ERC20TransferableReceivable contract +associated with the given pool name on the current chain.

+
getPoolContract(signerOrProvider, chainId, poolName, poolType)Contract | null
+

Returns an ethers contract instance for a Huma pool contract

+
getCreditRecord(address, signerOrProvider, chainId, poolName, poolType)Promise.<CreditRecord>
+

Gets the credit record of a wallet in a Huma pool. Denominated in the ERC20 tokens of the pool.

+
getTotalDue(address, signerOrProvider, chainId, poolName, poolType)Promise.<BigNumber>
+

Gets the total due for a Huma pool of the given wallet. Denominated in the ERC20 tokens of the pool.

+
drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, [gasOpts])Promise.<TransactionResponse>
+

Calls drawdown on a Huma pool contract

+
makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, [gasOpts])Promise.<TransactionResponse>
+

Calls makePayment on a Huma pool contract. If the pool does not have sufficient allowance to complete the operation, +attempt to first increase the allowance of the pool.

+
approvePoolAllowance(signer, chainId, poolName, poolType, allowanceAmount, [gasOpts])Promise.<TransactionResponse>
+

Approves an allowance for a Huma pool contract, which is required to do certain actions (e.g. makePayment)

+
getRealWorldReceivableContract(signerOrProvider, chainId)Contract | null
+

Returns an ethers contract instance for the RealWorldReceivable contract +associated with the given pool name on the current chain.

+
getAvailableBalanceForPool(poolName, provider)
+

Returns the current pool balance available for borrowing

+
getCreditRecordForPool(poolName, borrower, provider)
+

Returns the credit record of the borrower

+
getAvailableCreditForPool(borrower, poolName, provider)
+

Returns the borrower's remaining credit they can use for borrowing. Note that this might not be +currently available for borrowing as the credit limit might exceed the available pool balance. Use +getPoolBalance() to get the current available pool balance.

+
getReceivableBackedCreditLineContractV2(signerOrProvider, poolName)ReceivableBackedCreditLine | null
+

Returns an ethers contract instance for the V2 Receivable contract +associated with the given pool name on the current chain.

+
getTotalDueV2(provider, poolName)BigNumber | null
+

Returns account's total due amount in BigNumber format +associated with the given pool name on the current chain.

+
drawdownWithReceivable(signer, poolName, receivableId, drawdownAmount, [gasOpts])Promise.<TransactionResponse>
+

Draws down from a pool using a receivable.

+
makePaymentWithReceivable(signer, poolName, receivableId, paymentAmount, principalOnly, [gasOpts])Promise.<TransactionResponse>
+

Makes a payment with a receivable.

+
makePrincipalPaymentAndDrawdownWithReceivable(signer, poolName, paymentReceivableId, paymentAmount, drawdownReceivableId, drawdownAmount, [gasOpts])Promise.<TransactionResponse>
+

Makes a principal payment and drawdown with receivables.

+
getReceivableContractV2(poolName, signer)Contract | null
+

Returns an ethers contract instance for the V2 Receivable contract +associated with the given pool name on the current chain.

+
getReceivableTokenIdFromReferenceId(referenceId, creator, poolName, signer)
+

Retrieves the receivable token ID associated with a given reference ID.

+
preapprove(payload, chainId)Promise.<Approval>
+

Checks whether or not a credit underwriting request to Huma's EAVerse would be approved. +Note that this does not approve a creditline in Huma's pools and an approve call is still required.

+
getChainIdFromJsonSignerOrProvider(signerOrProvider)number
+

Get the chain ID from a signer or provider object.

+
getChainIdFromSignerOrProvider(signerOrProvider)number
+

Get the chain ID from a signer or provider object.

+
getPoolInfo(poolName, poolType)PoolInfoType | undefined
+

Returns the pool info based on the provided pool name and type, using the same chain ID as the provider/signer given

+
+ +## Typedefs + +
+
IrysConstructorArgs : Object
+

Represents the constructor arguments for the Irys service.

+
ApprovalResult : Object
+

Object representing the response to the underwriting approval request.

+
EAPayload : Object
+

Object representing an invoice payload for underwriting approval.

+
CreditEventPayload : Object
+

Represents the payload of a credit event.

+
Pagination : Object
+

Represents the pagination options for a query.

+
+ + + +## ARWeaveService : object +

An object that contains functions to interact with Huma-related data stored on ARWeave

+ +**Kind**: global namespace + +* [ARWeaveService](#ARWeaveService) : object + * [.getIrysNetworkConfig(chainId)](#ARWeaveService.getIrysNetworkConfig) ⇒ [IrysConstructorArgs](#IrysConstructorArgs) + * [.getIrysInstance(config, privateKey)](#ARWeaveService.getIrysInstance) ⇒ + * [.prefundIrys(config, privateKey, amount)](#ARWeaveService.prefundIrys) ⇒ Promise.<FundResponse> + * [.storeData(config, privateKey, data, tags, [lazyFund])](#ARWeaveService.storeData) ⇒ Promise.<UploadResponse> + * [.queryForMetadata(chainId, sender, referenceId)](#ARWeaveService.queryForMetadata) ⇒ Promise.<any> + * [.fetchMetadataFromUrl(url)](#ARWeaveService.fetchMetadataFromUrl) ⇒ Promise.<JSON> + * [.getURIFromARWeaveId(arweaveId)](#ARWeaveService.getURIFromARWeaveId) ⇒ string + * [.BundlrConfig](#ARWeaveService.BundlrConfig) : Object + + + +### ARWeaveService.getIrysNetworkConfig(chainId) ⇒ [IrysConstructorArgs](#IrysConstructorArgs) +

Get the configuration for the Irys network given a chain ID

+ +**Kind**: static method of [ARWeaveService](#ARWeaveService) +**Returns**: [IrysConstructorArgs](#IrysConstructorArgs) - + +| Param | Type | Description | +| --- | --- | --- | +| chainId | number |

The chain ID.

| + + + +### ARWeaveService.getIrysInstance(config, privateKey) ⇒ +

Get an Irys instance for a specific network

+ +**Kind**: static method of [ARWeaveService](#ARWeaveService) +**Returns**:

The Bundlr instance

+ +| Param | Type | Description | +| --- | --- | --- | +| config | BundlrConfig |

The configuration for the Bundlr network.

| +| privateKey | string |

The private key of the wallet to use Bundlr with.

| + + + +### ARWeaveService.prefundIrys(config, privateKey, amount) ⇒ Promise.<FundResponse> +

Prefund the Irys network with the specified amount. Required if not lazy funding. +Important note: The amount is denominated in the base unit of currency for that network. +If you want to upload 5 Matic to the Irys node, pass in an amount of 5.

+ +**Kind**: static method of [ARWeaveService](#ARWeaveService) +**Returns**: Promise.<FundResponse> - + +| Param | Type | Description | +| --- | --- | --- | +| config | [IrysConstructorArgs](#IrysConstructorArgs) |

The configuration for the Bundlr network.

| +| privateKey | string |

The private key of the wallet to send funds from.

| +| amount | number |

The amount to fund, denoted in whatever currency specified by the config (e.g. MATIC, ETH)

| + + + +### ARWeaveService.storeData(config, privateKey, data, tags, [lazyFund]) ⇒ Promise.<UploadResponse> +

Store data on ARWeave using the Irys Network.

+ +**Kind**: static method of [ARWeaveService](#ARWeaveService) +**Returns**: Promise.<UploadResponse> -

Promise resolving with the upload response.

+ +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| config | [IrysConstructorArgs](#IrysConstructorArgs) | |

Configuration object for the Irys instance.

| +| privateKey | string | |

Private key used for interacting with the Irys instance.

| +| data | Record.<string, unknown> | |

The data to store in the Irys instance.

| +| tags | Array.<{name: string, value: string}> | |

Array of tag objects with name and value properties.

| +| [lazyFund] | boolean | true |

Optional flag to fund the Irys instance lazily. If set to false, the Irys node should already be funded or else uploads will fail.

| + + + +### ARWeaveService.queryForMetadata(chainId, sender, referenceId) ⇒ Promise.<any> +

Helper method to query the Arweave network for receivables metadata previously uploaded.

+ +**Kind**: static method of [ARWeaveService](#ARWeaveService) +**Returns**: Promise.<any> -

Promise resolving with the queried data.

+ +| Param | Type | Description | +| --- | --- | --- | +| chainId | number |

The chain ID.

| +| sender | string |

The sender tag to query.

| +| referenceId | string |

The referenceId tag to query, whatever was used when uploading the metadata.

| + + + +### ARWeaveService.fetchMetadataFromUrl(url) ⇒ Promise.<JSON> +

Helper method to fetch data from an ARWeave URL.

+ +**Kind**: static method of [ARWeaveService](#ARWeaveService) +**Returns**: Promise.<JSON> -

Promise resolving with the queried data.

+ +| Param | Type | Description | +| --- | --- | --- | +| url | string |

The ARWeave metadata URL to query.

| + + + +### ARWeaveService.getURIFromARWeaveId(arweaveId) ⇒ string +

Helper method to get an ARWeave URI from an ARWeave ID.

+ +**Kind**: static method of [ARWeaveService](#ARWeaveService) +**Returns**: string -

The ARWeave URI.

+ +| Param | Type | Description | +| --- | --- | --- | +| arweaveId | string |

The ARWeave metadata ID.

| + + + +### ARWeaveService.BundlrConfig : Object +

The configuration for Bundlr network instances

+ +**Kind**: static typedef of [ARWeaveService](#ARWeaveService) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| nodeUrl | string |

The Bundlr node URL to use.

| +| currency | string |

The currency to pay for uploads with. Please see https://docs.bundlr.network/sdk/using-other-currencies for all the supported currencies

| +| [providerUrl] | string |

The provider URL, required for devnets.

| + + + +## EAService : object +

An object that contains functions to interact with Huma's EAVerse service.

+ +**Kind**: global namespace + + +### EAService.approve(payload, chainId) ⇒ Promise.<Approval> +

Submits a credit underwriting request to Huma's EAVerse. This approves a creditline +in Huma's pools that can be drawn down by the borrower.

+ +**Kind**: static method of [EAService](#EAService) +**Returns**: Promise.<Approval> -

Promise that returns the approval on success.

+**Throws**: + +- EARejectionError

If the underwrite approval is rejected.

+ + +| Param | Type | Description | +| --- | --- | --- | +| payload | [EAPayload](#EAPayload) |

The payload for the underwrite approval.

| +| chainId | number |

The chain ID.

| + + + +## ReceivableService : object +

An object that contains functions to interact with Huma's receivables.

+ +**Kind**: global namespace + +* [ReceivableService](#ReceivableService) : object + * [.getTokenIdByURI(signer, arweaveId)](#ReceivableService.getTokenIdByURI) ⇒ Promise.<(string\|null\|undefined)> + * [.declareReceivablePaymentByReferenceId(signer, referenceId, paymentAmount, [gasOpts])](#ReceivableService.declareReceivablePaymentByReferenceId) ⇒ Promise.<TransactionResponse> + * [.declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount, [gasOpts])](#ReceivableService.declareReceivablePaymentByTokenId) ⇒ Promise.<TransactionResponse> + * [.createReceivable(signer, poolName, poolType, currencyCode, receivableAmount, maturityDate, uri, [gasOpts])](#ReceivableService.createReceivable) ⇒ Promise.<(TransactionResponse\|null)> + * [.uploadOrFetchMetadataURI(signer, privateKey, chainId, poolName, poolType, metadata, referenceId, extraTags, [lazyFund])](#ReceivableService.uploadOrFetchMetadataURI) ⇒ Promise.<string> + * [.createReceivableWithMetadata(signer, privateKey, chainId, poolName, poolType, currencyCode, receivableAmount, maturityDate, metadata, referenceId, extraTags, [lazyFund], [gasOpts])](#ReceivableService.createReceivableWithMetadata) ⇒ Promise.<TransactionResponse> + * [.loadReceivablesOfOwnerWithMetadata(chainID, owner, poolName, poolType, pagination)](#ReceivableService.loadReceivablesOfOwnerWithMetadata) ⇒ Promise.<Array.<RealWorldReceivableInfo>> + * [.getTotalCountOfReceivables(provider, owner)](#ReceivableService.getTotalCountOfReceivables) ⇒ Promise.<number> + + + +### ReceivableService.getTokenIdByURI(signer, arweaveId) ⇒ Promise.<(string\|null\|undefined)> +

Fetches the tokenId of a RealWorldReceivable, or null if it doesn't exist, given a metadata URI

+ +**Kind**: static method of [ReceivableService](#ReceivableService) +**Returns**: Promise.<(string\|null\|undefined)> - + +| Param | Type | Description | +| --- | --- | --- | +| signer | ethers.Signer |

The signer used to lookup metadata uploads for

| +| arweaveId | string |

The internal ARWeave identifier to lookup a token by

| + + + +### ReceivableService.declareReceivablePaymentByReferenceId(signer, referenceId, paymentAmount, [gasOpts]) ⇒ Promise.<TransactionResponse> +

Declares a payment on a RealWorldReceivable given a reference Id of the receivable, which was used as an index for ARWeave data.

+ +**Kind**: static method of [ReceivableService](#ReceivableService) +**Returns**: Promise.<TransactionResponse> - + +| Param | Type | Description | +| --- | --- | --- | +| signer | ethers.Signer |

The signer used to send the transaction. Note only the receivable owner can pay the receivable.

| +| referenceId | string |

An internal identifier value added as a tag on ARWeave

| +| paymentAmount | number |

The amount to declare paid to the receivable.

| +| [gasOpts] | Overrides |

The gas options to use for the transaction.

| + + + +### ReceivableService.declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount, [gasOpts]) ⇒ Promise.<TransactionResponse> +

Declares a payment on a RealWorldReceivable given a tokenId of the receivable.

+ +**Kind**: static method of [ReceivableService](#ReceivableService) +**Returns**: Promise.<TransactionResponse> - +**Throws**: + +- Error + + +| Param | Type | Description | +| --- | --- | --- | +| signer | ethers.Signer |

The signer used to send the transaction. Note only the receivable owner can pay the receivable.

| +| receivableTokenId | BigNumberish |

The Id of the receivable token to pay.

| +| paymentAmount | number |

The amount to pay the receivable.

| +| [gasOpts] | Overrides |

The gas options to use for the transaction.

| + + + +### ReceivableService.createReceivable(signer, poolName, poolType, currencyCode, receivableAmount, maturityDate, uri, [gasOpts]) ⇒ Promise.<(TransactionResponse\|null)> +

Creates a new RealWorldReceivable token on the given chain of the signer

+ +**Kind**: static method of [ReceivableService](#ReceivableService) +**Returns**: Promise.<(TransactionResponse\|null)> - +**Throws**: + +- Error + + +| Param | Type | Description | +| --- | --- | --- | +| signer | ethers.Signer |

The signer used to send the transaction.

| +| poolName | POOL\_NAME |

The name of the credit pool to mint the receivable token from. Used to lookup the pool address.

| +| poolType | POOL\_TYPE |

The type of the credit pool to mint the receivable token from. Used to lookup the pool address.

| +| currencyCode | number |

The ISO 4217 currency code that the receivable is denominated in

| +| receivableAmount | number |

The amount of the receivable token to mint.

| +| maturityDate | number |

The maturity date of the receivable token, in UNIX timestamp format.

| +| uri | string |

The URI of the receivable token metadata.

| +| [gasOpts] | Overrides |

The gas options to use for the transaction.

| + + + +### ReceivableService.uploadOrFetchMetadataURI(signer, privateKey, chainId, poolName, poolType, metadata, referenceId, extraTags, [lazyFund]) ⇒ Promise.<string> +

Uploads metadata onto ARWeave (or fetches the existing metadata with the same reference Id) and returns the ARWeave URL

+ +**Kind**: static method of [ReceivableService](#ReceivableService) +**Returns**: Promise.<string> - + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| signer | ethers.Signer | |

An ethers.signer instance used to de-dupe metadata uploads.

| +| privateKey | string | |

Private key of the wallet used to upload metadata to ARWeave.

| +| chainId | number | |

The chain ID to mint the receivable token on and pay ARWeave funds from.

| +| poolName | POOL\_NAME | |

The pool name. Used to lookup the pool address to pay to.

| +| poolType | POOL\_TYPE | |

The pool type. Used to lookup the pool address to pay to.

| +| metadata | Record.<string, any> | |

The metadata in JSON format. This will be uploaded onto ARWeave

| +| referenceId | string | |

An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.

| +| extraTags | Array.<{name: string, value: string}> | |

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.

| +| [lazyFund] | boolean | true |

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.

| + + + +### ReceivableService.createReceivableWithMetadata(signer, privateKey, chainId, poolName, poolType, currencyCode, receivableAmount, maturityDate, metadata, referenceId, extraTags, [lazyFund], [gasOpts]) ⇒ Promise.<TransactionResponse> +

Creates a RealWorldReceivable token with metadata uploaded onto ARWeave

+ +**Kind**: static method of [ReceivableService](#ReceivableService) +**Returns**: Promise.<TransactionResponse> - + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| signer | ethers.Signer | |

An ethers.signer instance used to de-dupe metadata uploads.

| +| privateKey | string | |

Private key of the wallet used to upload metadata to ARWeave.

| +| chainId | number | |

The chain ID to mint the receivable token on and pay ARWeave funds from.

| +| poolName | POOL\_NAME | |

The pool name. Used to lookup the pool address to pay to.

| +| poolType | POOL\_TYPE | |

The pool type. Used to lookup the pool address to pay to.

| +| currencyCode | number | |

The ISO 4217 currency code that the receivable is denominated in

| +| receivableAmount | number | |

The receivable amount.

| +| maturityDate | number | |

The maturity date of the receivable, in UNIX timestamp format.

| +| metadata | Record.<string, any> | |

The metadata in JSON format. This will be uploaded onto ARWeave

| +| referenceId | string | |

An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.

| +| extraTags | Array.<{name: string, value: string}> | |

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.

| +| [lazyFund] | boolean | true |

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.

| +| [gasOpts] | Overrides | |

Optional gas overrides for the transaction.

| + + + +### ReceivableService.loadReceivablesOfOwnerWithMetadata(chainID, owner, poolName, poolType, pagination) ⇒ Promise.<Array.<RealWorldReceivableInfo>> +

Loads all RWRs belonging to the specified owner, including the RWR metadata

+ +**Kind**: static method of [ReceivableService](#ReceivableService) +**Returns**: Promise.<Array.<RealWorldReceivableInfo>> - + +| Param | Type | Description | +| --- | --- | --- | +| chainID | number |

The chain to query for receivables

| +| owner | string |

The receivable token owner to query from.

| +| poolName | POOL\_NAME |

The pool name. Used to lookup the pool address to pay to.

| +| poolType | POOL\_TYPE |

The pool type. Used to lookup the pool address to pay to.

| +| pagination | [Pagination](#Pagination) |

The pagination option.

| + + + +### ReceivableService.getTotalCountOfReceivables(provider, owner) ⇒ Promise.<number> +

Get the total count of all RWRs belonging to the specified owner

+ +**Kind**: static method of [ReceivableService](#ReceivableService) +**Returns**: Promise.<number> - + +| Param | Type | Description | +| --- | --- | --- | +| provider | ethers.providers.Provider |

The provider used to query the chain.

| +| owner | string |

The receivable token owner to query from.

| + + + +## SubgraphService : object +

An object that contains functions to interact with Huma's Subgraph storage.

+ +**Kind**: global namespace + +* [SubgraphService](#SubgraphService) : object + * [.getSubgraphUrlForChainId(chainId)](#SubgraphService.getSubgraphUrlForChainId) ⇒ string + * [.getCreditEventsForUser(userAddress, chainId, poolName, poolType, event)](#SubgraphService.getCreditEventsForUser) ⇒ Promise.<Array.<CreditEventPayload>> + * [.getLastFactorizedAmountFromPool(userAddress, chainId, poolName, poolType)](#SubgraphService.getLastFactorizedAmountFromPool) ⇒ Promise.<number> + * [.getRWReceivableInfo(userAddress, chainId, poolName, poolType, pagination)](#SubgraphService.getRWReceivableInfo) ⇒ Promise.<RealWorldReceivableInfoBase> + * [.getReceivableV2Info(userAddress, chainId, poolName, poolType, pagination)](#SubgraphService.getReceivableV2Info) ⇒ Promise.<RealWorldReceivableInfoBase> + * [.checkBorrowAndLendHistory(chainId, pool, userAddress)](#SubgraphService.checkBorrowAndLendHistory) ⇒ Promise.<{hasBorrowHistory: boolean, hasLendHistory: boolean}> + + + +### SubgraphService.getSubgraphUrlForChainId(chainId) ⇒ string +

Returns the subgraph URL for a given chain ID.

+ +**Kind**: static method of [SubgraphService](#SubgraphService) +**Returns**: string -

The subgraph URL for the given chain ID.

+ +| Param | Type | Description | +| --- | --- | --- | +| chainId | number |

The ID of the chain.

| + + + +### SubgraphService.getCreditEventsForUser(userAddress, chainId, poolName, poolType, event) ⇒ Promise.<Array.<CreditEventPayload>> +

Returns the credit events for a given user.

+ +**Kind**: static method of [SubgraphService](#SubgraphService) +**Returns**: Promise.<Array.<CreditEventPayload>> -

The credit events for the given user.

+ +| Param | Type | Description | +| --- | --- | --- | +| userAddress | string |

The address of the user.

| +| chainId | number |

The ID of the chain.

| +| poolName | POOL\_NAME |

The name of the pool.

| +| poolType | POOL\_TYPE |

The type of the pool.

| +| event | Array.<number> |

The event types to filter by.

| + + + +### SubgraphService.getLastFactorizedAmountFromPool(userAddress, chainId, poolName, poolType) ⇒ Promise.<number> +

Returns the last factorized amount for a given user and pool.

+ +**Kind**: static method of [SubgraphService](#SubgraphService) +**Returns**: Promise.<number> -

The last factorized amount for the given user and pool.

+ +| Param | Type | Description | +| --- | --- | --- | +| userAddress | string |

The address of the user.

| +| chainId | number |

The ID of the chain.

| +| poolName | POOL\_NAME |

The name of the pool.

| +| poolType | POOL\_TYPE |

The type of the pool.

| + + + +### SubgraphService.getRWReceivableInfo(userAddress, chainId, poolName, poolType, pagination) ⇒ Promise.<RealWorldReceivableInfoBase> +

Returns the paginated real world receivables' info.

+ +**Kind**: static method of [SubgraphService](#SubgraphService) +**Returns**: Promise.<RealWorldReceivableInfoBase> -

The paginated real world receivables' info.

+ +| Param | Type | Description | +| --- | --- | --- | +| userAddress | string |

The address of the user.

| +| chainId | number |

The ID of the chain.

| +| poolName | POOL\_NAME |

The name of the pool.

| +| poolType | POOL\_TYPE |

The type of the pool.

| +| pagination | [Pagination](#Pagination) |

The pagination option.

| + + + +### SubgraphService.getReceivableV2Info(userAddress, chainId, poolName, poolType, pagination) ⇒ Promise.<RealWorldReceivableInfoBase> +

Returns the paginated V2 receivables' info for the original creator.

+ +**Kind**: static method of [SubgraphService](#SubgraphService) +**Returns**: Promise.<RealWorldReceivableInfoBase> -

The paginated real world receivables' info.

+ +| Param | Type | Description | +| --- | --- | --- | +| userAddress | string |

The address of the original creator.

| +| chainId | number |

The ID of the chain.

| +| poolName | POOL\_NAME |

The name of the pool.

| +| poolType | POOL\_TYPE |

The type of the pool.

| +| pagination | [Pagination](#Pagination) |

The pagination option.

| + + + +### SubgraphService.checkBorrowAndLendHistory(chainId, pool, userAddress) ⇒ Promise.<{hasBorrowHistory: boolean, hasLendHistory: boolean}> +

Returns if user has borrow or lend history.

+ +**Kind**: static method of [SubgraphService](#SubgraphService) +**Returns**: Promise.<{hasBorrowHistory: boolean, hasLendHistory: boolean}> -

If user has borrow or lend history.

+ +| Param | Type | Description | +| --- | --- | --- | +| chainId | number |

The ID of the chain.

| +| pool | string |

The address of the pool.

| +| userAddress | string |

The address of the user.

| + + + +## defaultWrapper() +

All built-in and custom scalars, mapped to their actual values

+ +**Kind**: global function + + +## approveERC20AllowanceIfInsufficient(signer, tokenAddress, spenderAddress, allowanceAmount, [gasOpts]) ⇒ Promise.<(TransactionResponse\|null)> +

Approves an ERC20 allowance for a spender address, if the current allowance is insufficient. +Allowance is required to do certain actions on the Huma protocol (e.g. makePayment)

+ +**Kind**: global function +**Returns**: Promise.<(TransactionResponse\|null)> - + +| Param | Type | Description | +| --- | --- | --- | +| signer | ethers.Signer |

The signer used to send the transaction.

| +| tokenAddress | string |

The address of the ERC20 token to approve.

| +| spenderAddress | string |

The address of the spender to approve an allowance for.

| +| allowanceAmount | BigNumber |

The amount of tokens to approve, if applicable. Denominated in the ERC20 tokens.

| +| [gasOpts] | Overrides |

The gas options to use for the transaction.

| + + + +## getERC20TransferableReceivableContract(signerOrProvider, chainId) ⇒ Contract \| null +

Returns an ethers contract instance for the ERC20TransferableReceivable contract +associated with the given pool name on the current chain.

+ +**Kind**: global function +**Returns**: Contract \| null -

A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.

+ +| Param | Type | Description | +| --- | --- | --- | +| signerOrProvider | ethers.providers.Provider \| ethers.Signer |

The provider or signer instance to use for the contract.

| +| chainId | number |

The chain id where the contract instance exists

| + + + +## getPoolContract(signerOrProvider, chainId, poolName, poolType) ⇒ Contract \| null +

Returns an ethers contract instance for a Huma pool contract

+ +**Kind**: global function +**Returns**: Contract \| null -

A contract instance for the Pool contract or null if it could not be found.

+ +| Param | Type | Description | +| --- | --- | --- | +| signerOrProvider | ethers.providers.Provider \| ethers.Signer |

The provider or signer instance to use for the contract.

| +| chainId | number |

The chain id where the contract instance exists

| +| poolName | POOL\_NAME |

The name of the pool contract to get.

| +| poolType | POOL\_TYPE |

The type of the pool contract to get.

| + + + +## getCreditRecord(address, signerOrProvider, chainId, poolName, poolType) ⇒ Promise.<CreditRecord> +

Gets the credit record of a wallet in a Huma pool. Denominated in the ERC20 tokens of the pool.

+ +**Kind**: global function +**Returns**: Promise.<CreditRecord> - + +| Param | Type | Description | +| --- | --- | --- | +| address | string |

The address to lookup.

| +| signerOrProvider | ethers.providers.Provider \| ethers.Signer |

The signer or provider used to read data.

| +| chainId | number |

The chain ID of the pool. Used to lookup the pool address.

| +| poolName | POOL\_NAME |

The name of the credit pool. Used to lookup the pool address.

| +| poolType | POOL\_TYPE |

The type of the credit pool. Used to lookup the pool address.

| + + + +### getCreditRecord.CreditRecord : Object +

Return type of getCreditRecord

+ +**Kind**: static typedef of [getCreditRecord](#getCreditRecord) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| unbilledPrincipal | BigNumber |

The amount of principal not included in the bill

| +| dueDate | BigNumber |

Unix timestamp due date of the next payment

| +| correction | BigNumber |

the adjustment of interest over or under-counted because of drawdown or principal payment in the middle of a billing period

| +| totalDue | BigNumber |

The due amount of the next payment

| +| feesAndInterestDue | BigNumber |

Interest and fees due for the next payment

| +| missedPeriods | number |

of consecutive missed payments, for default processing

| +| remainingPeriods | number |

of payment periods until the maturity of the credit line

| +| state | number |

status of the credit line. For more info: https://github.com/00labs/huma-contracts/blob/b075a8f957de281e0885e37dbd72a422b6a54a38/contracts/libraries/BaseStructs.sol#L49

| + + + +## getTotalDue(address, signerOrProvider, chainId, poolName, poolType) ⇒ Promise.<BigNumber> +

Gets the total due for a Huma pool of the given wallet. Denominated in the ERC20 tokens of the pool.

+ +**Kind**: global function +**Returns**: Promise.<BigNumber> - + +| Param | Type | Description | +| --- | --- | --- | +| address | string |

The address to lookup.

| +| signerOrProvider | ethers.providers.Provider \| ethers.Signer |

The signer or provider used to read data.

| +| chainId | number |

The chain ID of the pool. Used to lookup the pool address.

| +| poolName | POOL\_NAME |

The name of the credit pool. Used to lookup the pool address.

| +| poolType | POOL\_TYPE |

The type of the credit pool. Used to lookup the pool address.

| + + + +## drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, [gasOpts]) ⇒ Promise.<TransactionResponse> +

Calls drawdown on a Huma pool contract

+ +**Kind**: global function +**Returns**: Promise.<TransactionResponse> - + +| Param | Type | Description | +| --- | --- | --- | +| signer | ethers.Signer |

The signer used to send the transaction.

| +| chainId | number |

The chain ID of the pool to call drawdown on. Used to lookup the pool address.

| +| poolName | POOL\_NAME |

The name of the credit pool to mint the receivable token from. Used to lookup the pool address.

| +| poolType | POOL\_TYPE |

The type of the credit pool to mint the receivable token from. Used to lookup the pool address.

| +| drawdownAmount | BigNumberish |

The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.

| +| [gasOpts] | Overrides |

The gas options to use for the transaction.

| + + + +## makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, [gasOpts]) ⇒ Promise.<TransactionResponse> +

Calls makePayment on a Huma pool contract. If the pool does not have sufficient allowance to complete the operation, +attempt to first increase the allowance of the pool.

+ +**Kind**: global function +**Returns**: Promise.<TransactionResponse> - + +| Param | Type | Description | +| --- | --- | --- | +| signer | ethers.Signer |

The signer used to send the transaction.

| +| chainId | number |

The chain ID of the pool to call drawdown on. Used to lookup the pool address.

| +| poolName | POOL\_NAME |

The name of the credit pool to mint the receivable token from. Used to lookup the pool address.

| +| poolType | POOL\_TYPE |

The type of the credit pool to mint the receivable token from. Used to lookup the pool address.

| +| paymentAmount | BigNumberish |

The amount of tokens to payback, denominated in the ERC20 tokens of the pool.

| +| [gasOpts] | Overrides |

The gas options to use for the transaction.

| + + + +## approvePoolAllowance(signer, chainId, poolName, poolType, allowanceAmount, [gasOpts]) ⇒ Promise.<TransactionResponse> +

Approves an allowance for a Huma pool contract, which is required to do certain actions (e.g. makePayment)

+ +**Kind**: global function +**Returns**: Promise.<TransactionResponse> - + +| Param | Type | Description | +| --- | --- | --- | +| signer | ethers.Signer |

The signer used to send the transaction.

| +| chainId | number |

The chain ID of the pool to call drawdown on. Used to lookup the pool address.

| +| poolName | POOL\_NAME |

The name of the credit pool to mint the receivable token from. Used to lookup the pool address.

| +| poolType | POOL\_TYPE |

The type of the credit pool to mint the receivable token from. Used to lookup the pool address.

| +| allowanceAmount | BigNumberish |

The amount of tokens to payback, denominated in the ERC20 tokens of the pool.

| +| [gasOpts] | Overrides |

The gas options to use for the transaction.

| + + + +## getRealWorldReceivableContract(signerOrProvider, chainId) ⇒ Contract \| null +

Returns an ethers contract instance for the RealWorldReceivable contract +associated with the given pool name on the current chain.

+ +**Kind**: global function +**Returns**: Contract \| null -

A contract instance for the RealWorldReceivable contract or null if it could not be found.

+ +| Param | Type | Description | +| --- | --- | --- | +| signerOrProvider | ethers.providers.Provider \| ethers.Signer |

The provider or signer instance to use for the contract.

| +| chainId | number |

The chain id where the contract instance exists

| + + + +## getAvailableBalanceForPool(poolName, provider) +

Returns the current pool balance available for borrowing

+ +**Kind**: global function + +| Param | Type | Description | +| --- | --- | --- | +| poolName | POOL\_NAME |

The name of the credit pool to get the contract instance for.

| +| provider | JsonRpcProvider \| Web3Provider |

The provider instance to use for reading from the contract.

| + + + +## getCreditRecordForPool(poolName, borrower, provider) +

Returns the credit record of the borrower

+ +**Kind**: global function + +| Param | Type | Description | +| --- | --- | --- | +| poolName | POOL\_NAME |

The name of the credit pool to get the contract instance for.

| +| borrower | string |

The address of the borrower to check the credit record for

| +| provider | JsonRpcProvider \| Web3Provider |

The provider instance to use for reading from the contract.

| + + + +## getAvailableCreditForPool(borrower, poolName, provider) +

Returns the borrower's remaining credit they can use for borrowing. Note that this might not be +currently available for borrowing as the credit limit might exceed the available pool balance. Use +getPoolBalance() to get the current available pool balance.

+ +**Kind**: global function + +| Param | Type | Description | +| --- | --- | --- | +| borrower | string |

The address of the borrower to check the available credit for.

| +| poolName | POOL\_NAME |

The name of the credit pool to get the contract instance for.

| +| provider | JsonRpcProvider \| Web3Provider |

The provider instance to use for reading from the contract.

| + + + +## getReceivableBackedCreditLineContractV2(signerOrProvider, poolName) ⇒ ReceivableBackedCreditLine \| null +

Returns an ethers contract instance for the V2 Receivable contract +associated with the given pool name on the current chain.

+ +**Kind**: global function +**Returns**: ReceivableBackedCreditLine \| null -

A contract instance for the ReceivableBackedCreditLine contract or null if it could not be found.

+ +| Param | Type | Description | +| --- | --- | --- | +| signerOrProvider | ethers.providers.Provider \| ethers.Signer |

The provider or signer instance to use for the contract.

| +| poolName | POOL\_NAME |

The name of the credit pool to get the contract instance for.

| + + + +## getTotalDueV2(provider, poolName) ⇒ BigNumber \| null +

Returns account's total due amount in BigNumber format +associated with the given pool name on the current chain.

+ +**Kind**: global function +**Returns**: BigNumber \| null -

The account's total due amount in BigNumber format

+ +| Param | Type | Description | +| --- | --- | --- | +| provider | JsonRpcProvider \| Web3Provider |

The provider instance to use for the contract.

| +| poolName | POOL\_NAME |

The name of the credit pool to get the contract instance for.

| + + + +## drawdownWithReceivable(signer, poolName, receivableId, drawdownAmount, [gasOpts]) ⇒ Promise.<TransactionResponse> +

Draws down from a pool using a receivable.

+ +**Kind**: global function +**Returns**: Promise.<TransactionResponse> - + +| Param | Type | Description | +| --- | --- | --- | +| signer | ethers.Signer |

The signer used to send the transaction.

| +| poolName | POOL\_NAME |

The name of the credit pool to drawdown from.

| +| receivableId | BigNumberish |

The ID of the receivable.

| +| drawdownAmount | BigNumberish |

The amount to drawdown.

| +| [gasOpts] | Overrides |

The gas options to use for the transaction.

| + + + +## makePaymentWithReceivable(signer, poolName, receivableId, paymentAmount, principalOnly, [gasOpts]) ⇒ Promise.<TransactionResponse> +

Makes a payment with a receivable.

+ +**Kind**: global function +**Returns**: Promise.<TransactionResponse> - + +| Param | Type | Description | +| --- | --- | --- | +| signer | ethers.Signer |

The signer used to send the transaction.

| +| poolName | POOL\_NAME |

The name of the pool to interact with.

| +| receivableId | BigNumberish |

The ID of the receivable.

| +| paymentAmount | BigNumberish |

The amount to payback.

| +| principalOnly | boolean |

Whether this payment should ONLY apply to the principal

| +| [gasOpts] | Overrides |

The gas options to use for the transaction.

| + + + +## makePrincipalPaymentAndDrawdownWithReceivable(signer, poolName, paymentReceivableId, paymentAmount, drawdownReceivableId, drawdownAmount, [gasOpts]) ⇒ Promise.<TransactionResponse> +

Makes a principal payment and drawdown with receivables.

+ +**Kind**: global function +**Returns**: Promise.<TransactionResponse> - + +| Param | Type | Description | +| --- | --- | --- | +| signer | ethers.Signer |

The signer used to send the transaction.

| +| poolName | POOL\_NAME |

The name of the pool to interact with.

| +| paymentReceivableId | BigNumberish |

The ID of the receivable for payment.

| +| paymentAmount | BigNumberish |

The amount to payback.

| +| drawdownReceivableId | BigNumberish |

The ID of the drawdown receivable.

| +| drawdownAmount | BigNumberish |

The amount to drawdown.

| +| [gasOpts] | Overrides |

The gas options to use for the transaction.

| + + + +## getReceivableContractV2(poolName, signer) ⇒ Contract \| null +

Returns an ethers contract instance for the V2 Receivable contract +associated with the given pool name on the current chain.

+ +**Kind**: global function +**Returns**: Contract \| null -

A contract instance for the Receivable contract or null if it could not be found.

+ +| Param | Type | Description | +| --- | --- | --- | +| poolName | POOL\_NAME |

The name of the pool.

| +| signer | ethers.Signer |

The signer instance to use for the contract.

| + + + +## getReceivableTokenIdFromReferenceId(referenceId, creator, poolName, signer) ⇒ +

Retrieves the receivable token ID associated with a given reference ID.

+ +**Kind**: global function +**Returns**:

A promise that resolves to the receivable token ID.

+ +| Param | Description | +| --- | --- | +| referenceId |

The reference ID of the receivable.

| +| creator |

The creator of the receivable.

| +| poolName |

The name of the pool.

| +| signer |

The signer used for the contract interaction.

| + + + +## preapprove(payload, chainId) ⇒ Promise.<Approval> +

Checks whether or not a credit underwriting request to Huma's EAVerse would be approved. +Note that this does not approve a creditline in Huma's pools and an approve call is still required.

+ +**Kind**: global function +**Returns**: Promise.<Approval> -

Promise that returns the approval on success.

+ +| Param | Type | Description | +| --- | --- | --- | +| payload | EAPreapprovalPayload |

The payload for the underwrite approval.

| +| chainId | number |

The chain ID.

| + + + +## getChainIdFromJsonSignerOrProvider(signerOrProvider) ⇒ number +

Get the chain ID from a signer or provider object.

+ +**Kind**: global function +**Returns**: number - + +| Param | Type | Description | +| --- | --- | --- | +| signerOrProvider | JsonRpcProvider \| JsonRpcSigner |

The signer or provider object to get the chain ID from.

| + + + +## getChainIdFromSignerOrProvider(signerOrProvider) ⇒ number +

Get the chain ID from a signer or provider object.

+ +**Kind**: global function +**Returns**: number - + +| Param | Type | Description | +| --- | --- | --- | +| signerOrProvider | ethers.provider.Provider \| ethers.Signer |

The signer or provider object to get the chain ID from.

| + + + +## getPoolInfo(poolName, poolType) ⇒ PoolInfoType \| undefined +

Returns the pool info based on the provided pool name and type, using the same chain ID as the provider/signer given

+ +**Kind**: global function +**Returns**: PoolInfoType \| undefined - + +| Param | Type | Description | +| --- | --- | --- | +| poolName | POOL\_NAME |

The name of the pool.

| +| poolType | POOL\_TYPE |

The type of the pool.

| + + + +## IrysConstructorArgs : Object +

Represents the constructor arguments for the Irys service.

+ +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| [url] | string |

The URL of the Irys service.

| +| [network] | Network |

The network configuration for the Irys service. Can be mainnet or devnet.

| +| token | string |

The token for authentication.

| +| [key] | string |

The key for encryption.

| +| [config] | IrysConfig |

Additional configuration options for the Irys service.

| + + + +## ApprovalResult : Object +

Object representing the response to the underwriting approval request.

+ +**Kind**: global typedef + + +## EAPayload : Object +

Object representing an invoice payload for underwriting approval.

+ +**Kind**: global typedef + + +## CreditEventPayload : Object +

Represents the payload of a credit event.

+ +**Kind**: global typedef + + +## Pagination : Object +

Represents the pagination options for a query.

+ +**Kind**: global typedef