Skip to content

Commit

Permalink
filtering only active offers
Browse files Browse the repository at this point in the history
  • Loading branch information
franco-gondi committed Mar 6, 2024
1 parent 255afca commit a471660
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/trader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as dotenv from 'dotenv';
import { Gondi, LoanStatusType } from 'gondi';
import { Gondi, LoanStatusType, OfferStatus } from 'gondi';

import { approveNFT, approveToken, sleep, testCurrency, wallets } from './common';

Expand Down Expand Up @@ -151,7 +151,7 @@ async function lend(gondi: Gondi, collections: Collection[]) {
const nfts = (await gondi.ownedNfts()).ownedNfts;
if (nfts.length == 0) return;
const nft = nfts[Math.floor(Math.random() * nfts.length)];
const { offers } = await gondi.offers({ filterBy: { nft: Number(nft.id) } });
const { offers } = await gondi.offers({ filterBy: { nft: Number(nft.id), status: [OfferStatus.Active] } });
let skipOffers = Math.random() * offers.length;
for (const offer of offers) {
if (--skipOffers >= 0) continue;
Expand Down

0 comments on commit a471660

Please sign in to comment.