Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escrow Funds from Provider to Sender on Gateway Contract #46

Open
OnahProsperity opened this issue Sep 12, 2024 · 0 comments
Open

Escrow Funds from Provider to Sender on Gateway Contract #46

OnahProsperity opened this issue Sep 12, 2024 · 0 comments
Assignees

Comments

@OnahProsperity
Copy link
Collaborator

Objective:
Create a function that escrows assets from the provider to the sender in the Gateway contract as part of the on-ramping process.

Function Parameters:

/** 
 * @notice Escrowed assets from provider to the sender.
 * @param _orderId The ID of the transaction.
 * @param _signature The signature of the provider.
 * @param _provider The address of the provider.
 * @param _senderAddress The address of the sender.
 * @param _asset The address of the asset.
 * @param _amount The amount to be transferred.
 * @return bool the withdrawal is successful.
 */

Requirements:

  1. Functionality:
  • Implement a function that escrows assets from a provider to a sender’s address.
  • The function should verify that the provider has staked sufficient assets in the Gateway contract for the escrow.
  • The assets will be transferred from the provider’s locked balance (staked balance) to the sender as part of the onramping process.
  1. Checks:
  • Ensure the _signature provided is valid and signed by the provider.
  • Use ecrecover to validate the signature against the provider’s address.
  • Sufficient Balance Check:
  • Ensure the provider has enough staked assets to cover the amount being escrowed.
  • Use required statements to prevent escrowing more assets than the provider has locked.
  1. Order Validation:
  • Ensure the _orderId is unique and hasn’t been processed before, preventing double-spending of assets.
  1. Storage:
  • Keep a record of all processed orders to prevent re-processing.
    mapping(bytes32 => bool) public processedOrders;
  • Update the provider’s staked balance after a successful escrow.
  • Add a nonce to the signature to avoid a replay attack
  • Optionally, track escrowed balances in another mapping if needed.
  • Transfer the assets from the provider’s staked balance to the sender’s address.
  1. Event Emission:
  • Emit an Escrow event upon successful escrow completion.
    event Escrow(address indexed provider, address indexed sender, uint256 amount, bytes32 orderId);
  1. Return Value:
  • Return true if the escrow was successful and assets were transferred.

This task ensures the secure transfer of assets from a provider’s staked funds to a sender while checking for sufficient balance, signature validity, and preventing order replay.

@OnahProsperity OnahProsperity self-assigned this Sep 12, 2024
@OnahProsperity OnahProsperity mentioned this issue Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant