Skip to content

Rewrite Gateway Contract for Solana #1

Open
@chibie

Description

@chibie

User Story

As a blockchain developer, I want to port the Gateway EVM contract to Solana, maintaining the same core functionality while leveraging Solana's native features and optimizations, ensure comprehensive test coverage, and demonstrate its functionality on testnet.

Acceptance Criteria

  1. Code Implementation
  • GIVEN the Gateway contract is deployed on Solana
    WHEN users interact with the contract
    THEN all core functionality from EVM version works equivalently

  • GIVEN contract state management in Solana
    WHEN implementing the Order struct and mappings
    THEN use appropriate Solana account structures

  • GIVEN protocol settings management
    WHEN implementing admin controls
    THEN maintain same permission levels as EVM version

  1. Test Coverage
  • Order Creation Tests

    • Create order with valid params succeeds
    • Create order with invalid token fails
    • Create order with zero amount fails
    • Create order with invalid refund address fails
    • Verify correct token transfers
    • Verify correct event emission
  • Refund Tests

    • Refund unfulfilled order succeeds
    • Refund with fee calculation is correct
    • Refund fulfilled order fails
    • Refund already refunded order fails
    • Verify correct token transfers
    • Verify state updates
  • Settlement Tests

    • Settle order with valid params succeeds
    • Partial settlement updates state correctly
    • Complete settlement marks order fulfilled
    • Settlement of fulfilled order fails
    • Settlement of refunded order fails
    • Protocol fee calculation and transfer
    • LP fee calculation and transfer
  1. Demonstration
  • GIVEN the contract is deployed to Solana Devnet
    WHEN demonstrating functionality
    THEN record video showing interaction with all core functions:
    • Creating an order
    • Setting protocol fees and supported tokens
    • Settling an order
    • Refunding an order

Tech Details

  • Implementation components:

    • Order PDA (Program Derived Account) structure
    • Token handling using SPL Token program
    • Admin/settings management using access control
    • Events as Solana program logs
    • State management via PDAs
    • Cross-program invocation for token transfers
    • Account validation
  • Testing framework:

    • Use Anchor testing framework
    • Program setup and deployment tests
    • Account creation and PDA derivation tests
    • Token account handling tests
    • Transaction signing and submission tests
    • State verification tests
    • Error condition tests
    • Helper functions for test setup and verification
  • Deployment and Demo:

    • Deploy to Solana Devnet
    • Create test token and accounts
    • Record demonstration video with narration
    • Show transaction confirmations

Notes/Assumptions

  • Use Anchor framework for development
  • Replace ERC20 with SPL Token program
  • State/storage handled via PDAs instead of mappings
  • Replace OpenZeppelin upgradeable pattern with Solana upgrade pattern
  • Use Solana program logs instead of Ethereum events
  • Tests will use local validator
  • Create mock SPL tokens for testing
  • Simulate multiple users/roles
  • Test both success and failure paths
  • Demo video should be narrated and show transaction confirmations

Open Questions

  • How to handle upgrades in Solana efficiently?
  • What's the equivalent pattern for OpenZeppelin's 2-step ownership?
  • Which wallet/tool should we use for the demo video?

REWARD: $500-$800

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions