The following code example is provided to help you understand the business process. For commercial use, you must handle parameter validation and exception handling on your own.
This example is tested on the Polygon-Amoy chain. Information used in the example can be retrieved from the Source directory. All ERC20 assets in the example have been pre-approved (authorized) to the contract amoy_contract_approveTrade. For any amounts involved, precision should be converted using toWei(amount, "decimal").
Loan/OTC Collateral - Assets Token (Assets): Only supports ERC20 and ERC721, network native tokens are not supported.
Loan/OTC Payment Token (Currency): Only supports ERC20 and network native tokens, ERC721 is not supported.
Nonce: Nonce must be retrieved from the contract using Contract.methods.nonces(account).call(). Do not skip this step, even if the nonce is 0.
Signature: Be cautious with hardware wallets, as they may require special handling for signatures.
Assets: Only ERC20 and ERC721 assets are supported as collateral items.
Currency: Only ERC20 tokens and network native tokens are supported as the currency for borrowing.
This example can be used as a starting point for creating loan orders on the Polygon-Amoy chain. Be sure to customize it according to your project's requirements.