CRYPTO NEWS

NFT lending protocol , repay function reverts second time it is used

So, I am writing this contract wherein you can collateralize your NFT asset for usdc and after you repay, you can get your assets back.

The borrow function is as under , which is running fine: // Borrower needs to ‘set Approval for All’ to contract in NFT contract

   function _generateCollateral(IERC721 _nft, uint256 _tokenId, uint256 _price) internal {         nft = IERC721(_nft);         require(nft.ownerOf(_tokenId) == msg.sender, "Only owner of NFT can collateralize");         stake[_tokenId] = Collateral( nft,_price);     } function borrow (IERC721 _nft,uint256 _tokenId, uint256 _price, uint32 _endTime) public   returns(uint256 LoanId) {         _generateCollateral(_nft,_tokenId,_price);         uint256 weiAmount = stake[_tokenId].price *70/100;         require(usdc.balanceOf(address(this))>=weiAmount, "Error :: Not enough balance USDC to lend");         nft.transferFrom(msg.sender,address(this),_tokenId);         usdc.transfer(msg.sender,weiAmount);         loanId++;         loans[loanId] = Loan(msg.sender,uint32(block.timestamp),_endTime,interest,weiAmount,_tokenId,true);         npa[loanId] = false;         emit Loans(msg.sender,loanId);         return loanId;     } 

Next , if the borrower pays back the loan within time period, function rePay is as follows: // Borrower needs to approve contract for transferFrom of USDC amount in USDC contract.

function rePay(uint256 _loanId) public {         require(block.timestamp<loans[_loanId].endTime, "Error: Repayment time expired");         require(msg.sender == loans[_loanId].borrower);         require(loans[_loanId].isActive, "This loan is no longer active");         nft = stake[_loanId].nftAddress;         uint32 elapsedTime = uint32(block.timestamp) - loans[_loanId].startTime;         uint256 rePayAmount = loans[_loanId].principal + loans[_loanId].principal*loans[_loanId].rate * elapsedTime/(60*60*24*365*100);         usdc.transferFrom(msg.sender, address(this), rePayAmount);         nft.transferFrom(address(this), msg.sender, loans[_loanId].tokenId);         loans[_loanId].isActive = false;     } 

This function runs fine the first time but reverts every time after that. My guess is that it fails in nft.transferFrom stage.

Can someone guide whats going on here ? Complete contract code at https://github.com/ashishk74/lendMyNFT/blob/master/contracts/lendMyNFT.sol

Thanks, Ashish

Ripple Sits at a Long-Term Support Following 30% Weekly Crash, Rebound In Sight? (XRP Technical Analysis)

The market is still in shock due to the deep collapse in recent days. Investors are skeptical, and it remains to be seen when the bulls will return to the market. Technical Analysis By Grizzly The Daily Chart The bears were able to push the price down to critical horizontal support at $0.33. This level::Listen

The market is still in shock due to the deep collapse in recent days. Investors are skeptical, and it remains to be seen when the bulls will return to the market.

Technical Analysis

By Grizzly

The Daily Chart

The bears were able to push the price down to critical horizontal support at $0.33. This level has played an essential role for XRP since 2019.

1
Source: TradingView

The sharp upward trend in 2021 occurred after breaking this level. If the bulls can defend it, one can expect XRP to move towards the resistance at $0.5, which is the first challenge for the bulls. However, given the macroeconomic conditions in the market,  one must remain very careful and cautious.

Key Support Levels: $0.23 & $0.17

Key Resistance Levels: $0.51 & $0.77

Moving Averages:

MA20: $0.56

MA50: $0.69

MA100: $0.73

MA200: $0.81

The XRP/BTC Chart

Against BTC, the price has lost the critical support at 1550 SATS, which has now turned into resistance. Considering the huge sell-off, returning the price to higher levels will not be easy. First, the selling pressure must be reduced. Then market usually enters an accumulation or transition phase until the next major leg. There is still selling pressure in the market now, although not as much as in the past few days.

1
Source: TradingView

NFT lending protocol , repay function reverts second time it is used

Shopping cart
There are no products in the cart!
Continue shopping
0