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

Main escrow contract #1

Open
adambor opened this issue Dec 13, 2024 · 0 comments
Open

Main escrow contract #1

adambor opened this issue Dec 13, 2024 · 0 comments

Comments

@adambor
Copy link
Member

adambor commented Dec 13, 2024

Create main escrow contract and claim/refund interfaces for starknet.

Main escrow contract for starknet, it should be able to:

  • manage LP vaults (funds deposited to the contract to save on execution steps for LPs)
  • tracking reputation of LPs
  • manage escrows:
    • create escrows funded externally and from LP vaults
    • claim escrows based on the specified claim handler
    • refund escrows based on the specific refund handler
    • cooperatively refund escrows based on signatures from both parties
    • execute action on claim (TBD)

Claim handler interface

Handles verification for claiming of the escrow, could be hash-lock or proof-lock (utilizing the specific light client contract), with more possible extensions in the future.

Example interface in Solidity

interface ClaimHandler {
    function claim(bytes32 claimData, bytes calldata witness) external;
}

Refund handler interface

Handles verification to determine whether an escrow is refundable, could be time-lock or blockheight-lock, with more possibilities in the future.

Example interface in Solidity

interface RefundHandler {
    function refund(bytes32 refundData, bytes calldata witness) external;
}

Escrow contract

Responsible for managing escrow funds & LP vault. Each escrow specifies which claim handler and refund handler interface they use, easily allowing HTLC (combination of hash-lock claim handler & blockheight-lock refund handler), PTLC (combination of proof-lock claim handler & blockheight-lock refund handler) & whatever other future locks will be required in the future. Also, escrow state contains the call address and calldata that will be called during claim, this needs to be handled in a "try-catch" block, as to not invalidate the whole claim tx when the claim action fails.

Example escrow struct in Solidity

struct EscrowState {
    address offerer;
    address claimer;
    
    address token;
    uint256 amount;

    bytes32 claimData;
    address claimHandler;

    bytes32 refundData;
    address refundHandler;

    uint256 securityDeposit;
    uint256 claimerBounty;

    address claimActionContract;
    bytes claimActionCalldata;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

1 participant