diff --git a/README.md b/README.md index 6695f58..f0b4973 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,15 @@ const nemeosPoolClient = nemeosSdk.getNemeosPoolClient({ }) ``` +#### Get Pool Balance + +Retrieve the current balance of the pool smart contract in native token in wei (if balance is 1 ETH, will return `1000000000000000000`). + +```ts +const poolBalance = await nemeosPoolClient.getPoolBalance() +console.log('Pool Balance:', poolBalance) +``` + ### Preview a loan ```ts diff --git a/package.json b/package.json index de052ab..a496ffe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nemeos-sdk", - "version": "0.1.6", + "version": "0.1.7", "type": "module", "description": "Nemeos SDK to facilitate integration with the Nemeos platform", "license": "MIT", diff --git a/src/Pool/NemeosPoolClient.ts b/src/Pool/NemeosPoolClient.ts index d6681a0..54fb033 100644 --- a/src/Pool/NemeosPoolClient.ts +++ b/src/Pool/NemeosPoolClient.ts @@ -17,6 +17,11 @@ export abstract class NemeosPoolClient { this.poolContract = new ethers.Contract(nemeosPoolAddress, nemeosPoolInterface, signer) } + public async getPoolBalance(): Promise { + const balance = await this.signer.provider!.getBalance(this.nemeosPoolAddress) + return balance.toString() + } + public async retrieveLoan(nftId: string): Promise { const borrowerAddress = await this.signer.getAddress() diff --git a/tests/test.mjs b/tests/test.mjs index e42cc2e..8ebab63 100644 --- a/tests/test.mjs +++ b/tests/test.mjs @@ -60,19 +60,28 @@ async function main() { nemeosPoolMode: NemeosSDK.NemeosPoolMode.BuyOpenSea, }) + const poolBalance = await nemeosPoolBuyOpenSeaClient.getPoolBalance() + console.log('Pool balance:', poolBalance) + console.log('Calling previewLoan...') const loan1 = await nemeosPoolBuyOpenSeaClient.previewLoan(nftId1, loanDurationDays1) console.dir(loan1, { depth: null }) + console.log('Calling startLoan...') await nemeosPoolBuyOpenSeaClient.startLoan(nftId1, loanDurationDays1) await new Promise(res => setTimeout(res, 10_000)) + console.log('Calling retrieveLoan 1...') await nemeosPoolBuyOpenSeaClient.retrieveLoan(nftId1) + console.log('Calling payNextLoanStep 1...') await nemeosPoolBuyOpenSeaClient.payNextLoanStep(nftId1) await new Promise(res => setTimeout(res, 3_000)) + console.log('Calling retrieveLoan 2...') await nemeosPoolBuyOpenSeaClient.retrieveLoan(nftId1) + console.log('Calling payNextLoanStep 2...') await nemeosPoolBuyOpenSeaClient.payNextLoanStep(nftId1) await new Promise(res => setTimeout(res, 3_000)) + console.log('Calling retrieveLoan 3...') await nemeosPoolBuyOpenSeaClient.retrieveLoan(nftId1) //