diff --git a/README.md b/README.md index fa3741e..7c59cf3 100644 --- a/README.md +++ b/README.md @@ -143,13 +143,312 @@ const nemeosPoolClient = nemeosSdk.getNemeosPoolClient({ }) ``` +### Preview a loan + +```ts +try { + // Preview loan for Nemeos Pool `BuyOpenSea` mode + const nftId = 231 + const loanDurationDays = 61 + const loanData = await nemeosPoolBuyOpenSeaClient.previewLoan(nftId, loanDurationDays) + + // Preview loan for Nemeos Pool `DirectMint` mode + const loanDurationDays = 61 + const loanData2 = await nemeosPoolDirectMintClient.previewLoan(loanDurationDays) + + console.log('Preview loanData:', loanData) + console.log('Preview loanData2:', loanData2) +} catch (error) { + console.error('Preview loan failed!', error.message) + throw error +} +``` + +
+Click to show type: Loan preview for Nemeos Pool `BuyOpenSea` mode + +```ts +export type NftLivePriceBuyOpenSeaData = { + nftFullLivePriceData: { + /** @example "231" */ + nftId: string + /** @example "4000000000000000000" */ + openSeaNftPrice: string + /** @example "4" */ + openSeaNftPriceHuman: string + /** @example "4" */ + openSeaNftPriceHumanShortRound: string + /** @example "12686.2" */ + openSeaNftPriceHumanUSD: string + /** @example "160000000000000003" */ + nemeosOracleNftCollectionFloorPrice: string + /** @example "0.16" */ + nemeosOracleNftCollectionFloorPriceHuman: string + /** @example "0.16" */ + nemeosOracleNftCollectionFloorPriceHumanShortRound: string + /** @example "507.45" */ + nemeosOracleNftCollectionFloorPriceHumanUSD: string + /** @example "3880000000000000000" */ + proposedUpfrontPaymentGivenPrices: string + /** @example "3.88" */ + proposedUpfrontPaymentGivenPricesHuman: string + /** @example "3.88" */ + proposedUpfrontPaymentGivenPricesHumanShortRound: string + /** @example "12305.61" */ + proposedUpfrontPaymentGivenPricesHumanUSD: string + /** @example "4000000000000000000" */ + openSeaNftCollectionFloorPrice: string + /** @example "4" */ + openSeaNftCollectionFloorPriceHuman: string + /** @example "4" */ + openSeaNftCollectionFloorPriceHumanShortRound: string + /** @example "12686.2" */ + openSeaNftCollectionFloorPriceHumanUSD: string + /** @example "3171.55" */ + exchangeRateToUSD: string + /** @example "120000000000000000" */ + remainingToPayPrice: string + /** @example "0.12" */ + remainingToPayPriceHuman: string + /** @example "0.12" */ + remainingToPayPriceHumanShortRound: string + /** @example "380.59" */ + remainingToPayPriceHumanUSD: string + /** @example "121464000000000000" */ + remainingToPayPriceWithInterests: string + /** @example "0.121464" */ + remainingToPayPriceWithInterestsHuman: string + /** @example "0.121" */ + remainingToPayPriceWithInterestsHumanShortRound: string + /** @example "385.23" */ + remainingToPayPriceWithInterestsHumanUSD: string + /** @example "1464000000000000" */ + interestsToPay: string + /** @example "0.001464" */ + interestsToPayHuman: string + /** @example "0.001" */ + interestsToPayHumanShortRound: string + /** @example "4.64" */ + interestsToPayHumanUSD: string + /** @example "4001464000000000000" */ + totalLoanPrice: string + /** @example "4.001464" */ + totalLoanPriceHuman: string + /** @example "4.001" */ + totalLoanPriceHumanShortRound: string + /** @example "12690.84" */ + totalLoanPriceHumanUSD: string + /** @example 3 */ + numberOfInstallments: number + paySchedule: Array<{ + /** @example "3880000000000000000" */ + toPay: string + /** @example "3.88" */ + toPayHuman: string + /** @example "3.88" */ + toPayHumanShortRound: string + /** @example "12305.61" */ + toPayHumanUSD: string + /** @example "1721947310346" */ + unixTimestampMs: string + /** @example "Friday, July 26" */ + dateTimeHuman: string + /** @example "2024-07-25T22:41:50.346Z" */ + dateTimeJSON: string + }> + } + nftPoolLiveData: { + /** @example "0x3a668917C167dfa823b2816e782704444503078D" */ + nftPoolAddress: string + /** @example "25" */ + minimalDepositPercent: string + /** @example "25" */ + minimalDepositPercentHuman: string + /** @example "7" */ + yearlyInterestPercent: string + /** @example "7" */ + yearlyInterestPercentHuman: string + /** @example "5.6000000000000005" */ + yearlyLiquidityProviderProfitsEstimationPercent: string + /** @example "5.6" */ + yearlyLiquidityProviderProfitsEstimationPercentHuman: string + /** @example "309586878710840000" */ + availableLiquidity: string + /** @example "0.30958687871084" */ + availableLiquidityHuman: string + /** @example "0.31" */ + availableLiquidityHumanShortRound: string + /** @example "981.87" */ + availableLiquidityHumanUSD: string + /** @example "0" */ + liquidityLockedInLoans: string + /** @example "0" */ + liquidityLockedInLoansHuman: string + /** @example "0" */ + liquidityLockedInLoansHumanShortRound: string + /** @example "0" */ + liquidityLockedInLoansHumanUSD: string + /** @example "309586878710840000" */ + totalValueLocked: string + /** @example "0.30958687871084" */ + totalValueLockedHuman: string + /** @example "0.31" */ + totalValueLockedHumanShortRound: string + /** @example "981.87" */ + totalValueLockedHumanUSD: string + /** @example "3650" */ + maxYearlyLoanRate: string + /** @example "43200" */ + vestingTimePerBasisPoint: string + /** @example 0 */ + currentOngoingLoansCount: number + /** @example 3 */ + allTimeLoansCount: number + } +} +``` +
+ +
+Click to show type: Loan preview for Nemeos Pool `DirectMint` mode + +```ts +export type NftLivePriceDirectMintData = { + nftFullLivePriceData: { + /** @example "100000000000000000" */ + mintPrice: string + /** @example "0.1" */ + mintPriceHuman: string + /** @example "0.1" */ + mintPriceHumanShortRound: string + /** @example "316.55" */ + mintPriceHumanUSD: string + /** @example "25000000000000000" */ + proposedUpfrontPaymentGivenPrices: string + /** @example "0.025" */ + proposedUpfrontPaymentGivenPricesHuman: string + /** @example "0.025" */ + proposedUpfrontPaymentGivenPricesHumanShortRound: string + /** @example "79.14" */ + proposedUpfrontPaymentGivenPricesHumanUSD: string + /** @example "3165.45" */ + exchangeRateToUSD: string + /** @example "75000000000000000" */ + remainingToPayPrice: string + /** @example "0.075" */ + remainingToPayPriceHuman: string + /** @example "0.075" */ + remainingToPayPriceHumanShortRound: string + /** @example "237.41" */ + remainingToPayPriceHumanUSD: string + /** @example "76372500000000000" */ + remainingToPayPriceWithInterests: string + /** @example "0.0763725" */ + remainingToPayPriceWithInterestsHuman: string + /** @example "0.076" */ + remainingToPayPriceWithInterestsHumanShortRound: string + /** @example "241.75" */ + remainingToPayPriceWithInterestsHumanUSD: string + /** @example "1372500000000000" */ + interestsToPay: string + /** @example "0.0013725" */ + interestsToPayHuman: string + /** @example "0.001" */ + interestsToPayHumanShortRound: string + /** @example "4.34" */ + interestsToPayHumanUSD: string + /** @example "101372500000000000" */ + totalLoanPrice: string + /** @example "0.1013725" */ + totalLoanPriceHuman: string + /** @example "0.101" */ + totalLoanPriceHumanShortRound: string + /** @example "320.89" */ + totalLoanPriceHumanUSD: string + /** @example 3 */ + numberOfInstallments: number + paySchedule: Array<{ + /** @example "25000000000000000" */ + toPay: string + /** @example "0.025" */ + toPayHuman: string + /** @example "0.025" */ + toPayHumanShortRound: string + /** @example "79.14" */ + toPayHumanUSD: string + /** @example "1721946366176" */ + unixTimestampMs: string + /** @example "Friday, July 26" */ + dateTimeHuman: string + /** @example "2024-07-25T22:26:06.176Z" */ + dateTimeJSON: string + }> + } + nftPoolLiveData: { + /** @example "0xf4180C986Aec6f8fAdc6eFe4A0eC237c819AC074" */ + nftPoolAddress: string + /** @example "25" */ + minimalDepositPercent: string + /** @example "25" */ + minimalDepositPercentHuman: string + /** @example "10" */ + yearlyInterestPercent: string + /** @example "10" */ + yearlyInterestPercentHuman: string + /** @example "8" */ + yearlyLiquidityProviderProfitsEstimationPercent: string + /** @example "8" */ + yearlyLiquidityProviderProfitsEstimationPercentHuman: string + /** @example "100000000000000000" */ + availableLiquidity: string + /** @example "0.1" */ + availableLiquidityHuman: string + /** @example "0.1" */ + availableLiquidityHumanShortRound: string + /** @example "316.55" */ + availableLiquidityHumanUSD: string + /** @example "0" */ + liquidityLockedInLoans: string + /** @example "0" */ + liquidityLockedInLoansHuman: string + /** @example "0" */ + liquidityLockedInLoansHumanShortRound: string + /** @example "0" */ + liquidityLockedInLoansHumanUSD: string + /** @example "100000000000000000" */ + totalValueLocked: string + /** @example "0.1" */ + totalValueLockedHuman: string + /** @example "0.1" */ + totalValueLockedHumanShortRound: string + /** @example "316.55" */ + totalValueLockedHumanUSD: string + /** @example "3650" */ + maxYearlyLoanRate: string + /** @example "43200" */ + vestingTimePerBasisPoint: string + /** @example 0 */ + currentOngoingLoansCount: number + /** @example 0 */ + allTimeLoansCount: number + } +} +``` +
+ #### Start a loan ```ts try { + // Start loan for Nemeos Pool `BuyOpenSea` mode const nftId = 224 const loanDurationDays = 90 - const tx = await nemeosPoolClient.startLoan(nftId, loanDurationDays) + const tx = await nemeosPoolBuyOpenSeaClient.startLoan(nftId, loanDurationDays) + + // Start loan for Nemeos Pool `DirectMint` mode + const loanDurationDays = 90 + const whitelistProof = ['0x1234567890123456789012345678901234567890'] // Optional, necessary if there is a whitelist + const tx2 = await nemeosPoolDirectMintClient.startLoan(loanDurationDays, whitelistProof) console.log('Starting loan success! Transaction hash:', tx.hash) } catch (error) { @@ -165,6 +464,9 @@ const nftId = 224 const loan = await nemeosPoolClient.retrieveLoan(nftId) ``` +
+Type: Loan + ```ts type Loan = { /** Borrower address */ @@ -193,6 +495,7 @@ type Loan = { isInLiquidation: boolean } ``` +
#### Pay the next loan step @@ -221,9 +524,11 @@ pnpm build ### Test script ```bash +# touch .env, or set the environment variables in the command line export NODE_ENV=development # to connect to Nemeos backend at http://localhost:3000 export WALLET_PRIVATE_KEY=43ac571235456515454565645445454546123121454848791215488877897123 export INFURA_ENDPOINT_WITH_API_KEY=https://sepolia.infura.io/v3/b3866123121321321231212132131123 + node tests/test.mjs ``` diff --git a/package.json b/package.json index 3141126..57ace7f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nemeos-sdk", - "version": "0.1.4", + "version": "0.1.5", "type": "module", "description": "Nemeos SDK to facilitate integration with the Nemeos platform", "license": "MIT",