A code snippet to demostrate how to generate the signature required when making offers
function encodeOffer_v3({
expiry,
lender,
amount,
repayment,
nftAddress,
tokenId,
duration,
erc20Address,
itemType,
size,
counter,
chainId,
loanContractAddress
}) {
try {
const offerPack = ethers.utils.solidityPack(
['uint8', 'address', 'uint256', 'uint256', 'address', 'uint256', 'uint32', 'uint32', 'uint32'],
[+itemType, erc20Address, amount, repayment, nftAddress, tokenId, duration, expiry, size])
let message = null
message = ethers.utils.solidityKeccak256(
['bytes', 'address', 'uint256', 'address', 'uint256'],
[offerPack, loanContractAddress, chainId, lender, +counter])
return message
//const signature = await wallet.signMessage(ethers.utils.arrayify(message))
} catch (e) {
logger.error('signature encode', e.message)
}
return ''
}
Send transaction example(Borrow, Repay, Refinance, Approve)
//txRequest from borrow/repay/refinance interface
async function sendTx(txRequest, wallet) {
txRequest['from'] = wallet.address
const tx = await wallet.sendTransaction(txRequest)
const receipt = await tx.wait()
return receipt
}