Created
January 21, 2024 17:11
-
-
Save fourcolors/b72ebd3355e91c58a5d264d5c12319d8 to your computer and use it in GitHub Desktop.
smart contract for rentdi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//the tenants borrow gho and pays to the pool and the RentalApp contract owner keeps the moneys and earns interest | |
function paySecurityDeposit(address tokenAddress) public { | |
require( | |
tokenAddress == ghoAddress, | |
"Only gho token can be used to pay rent" | |
); | |
require(msg.sender == tenant, "Only tenant can pay security deposit"); | |
require(leaseActive, "Lease is active"); | |
require( | |
block.timestamp <= leaseStart + securityDepositDueDate, | |
"Security Deposit is not late" | |
); | |
POOL.borrow(ghoAddress, securityDeposit * 10 18, 2, 0, msg.sender); | |
// gho.approve(dexContractAddress, securityDeposit * 10 18); | |
gho.transfer(owner, securityDeposit * 10 18); | |
emit PaidSecurityDeposit( | |
owner, | |
landlord, | |
tenant, | |
securityDeposit, | |
block.timestamp, | |
securityDepositDueDate, | |
leasingAgreementId | |
); | |
} | |
//the tenants borrow gho and pays the landlord | |
function payMonthlyRent(address tokenAddress) public { | |
require( | |
tokenAddress == ghoAddress, | |
"Only gho token can be used to pay rent (for now)" | |
); | |
require(msg.sender == tenant, "Only tenant can pay rent"); | |
require(leaseActive, "Lease is active"); | |
require( | |
block.timestamp <= leaseStart + monthlyDueDate * 3600 * 24, | |
"Rent is not late" | |
); | |
POOL.borrow(ghoAddress, rentAmount * 10 18, 2, 0, msg.sender); | |
gho.transfer(landlord, rentAmount * 10 ** 18); | |
emit PaidMonthlyRent( | |
landlord, | |
tenant, | |
securityDeposit, | |
block.timestamp, | |
leasingAgreementId | |
); | |
} | |
modifier onlyOwner() { | |
require( | |
msg.sender == owner, | |
"Only the contract owner can call this function" | |
); | |
_; | |
} | |
receive() external payable {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment