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

Feature/dd tools #144

Merged
merged 12 commits into from
Jul 10, 2023
Merged

Feature/dd tools #144

merged 12 commits into from
Jul 10, 2023

Conversation

EvgenKor
Copy link
Collaborator

@EvgenKor EvgenKor commented Jul 4, 2023

The changes introduced by that PR are intended to support direct deposits

  • Implemented a universal method directDeposit to deposit funds to the current account via direct deposit scheme (both token and native scheme are supported through the type parameter: DirectDepositType.Token\DirectDepositType.Native).
public async directDeposit(
    type: DirectDepositType, // DirectDepositType.Token or DirectDepositType.Native
    fromAddress: string,  // sender address to check approval and using as fallback address
    amount: bigint, // in pool resolution
    sendTxCallback: (tx: PreparedTransaction) => Promise<string>, // should returns txHash
  ): Promise<void>;

sendTxCallback will invoked to send transaction and PreparedTransaction is defined as following:

export interface PreparedTransaction {
    to: string; // dd queue contract address
    amount: bigint; // nonzero for native direct deposits
    data: string; // 0x-based hex string of encoded transaction
}
  • introduced new optional parameters in Pool configuration: isNative (boolean, should be set as true for WETH-pools to accept native direct deposits) and ddSubgraph (string, the subgraph name to fetching pending direct deposits, currently supported zkbob-bob-goerli, zkbob-eth-goerli and zkbob-bob-goerli-opt)
  • added method getPendingDDs to fetch pending direct deposits in the queue (available just for pools with configured subgraphs). It returns an array of DirectDeposit objects:
interface DirectDeposit {
    id: bigint;           // DD queue unique identifier
    state: DirectDepositState; // getPendingDDs will always return records
                               // with `DirectDepositState.Queued` state
    amount: bigint;       // in pool resolution
    destination: string;  // zk-addresss
    fallback: string;     // 0x-address to refund DD
    timestamp: number;    // when it was created
    queueTxHash: string;  // transaction hash to the queue
}
  • added method directDepositFee which returns fee for the direct deposit in pool resolution (as returned by queue contract)
  • added method directDepositContract to retrieve DD queue contract address from the pool
  • added method tokenSellerContract to retrieve token seller contract address from the pool (also available in account-lessmode)

This PR can be tested with associated console branch. Pending direct deposits are currently fetched in BOB-goerli, WETH-goerli and BOB-op-goerli pool

Please note BOB-goerli pool is currently migrated on USDC and require associated changes in denominator processing, implemented in #147, so testing that branch on BOB-goerli pool is undesirable

src/dd.ts Outdated Show resolved Hide resolved
src/networks/evm.ts Outdated Show resolved Hide resolved
src/dd.ts Outdated Show resolved Hide resolved
EvgenKor and others added 3 commits July 6, 2023 15:20
@EvgenKor
Copy link
Collaborator Author

EvgenKor commented Jul 7, 2023

The latest changes:

  • added support for the direct deposit limits (the data fetched from the contract directly until relayer doesn't support it)
  • added ability to use subgraph with arbitrary name. Currently deployed and tested: zkbob-bob-goerli, zkbob-eth-goerli and zkbob-bob-goerli-opt

@EvgenKor EvgenKor requested a review from k1rill-fedoseev July 7, 2023 13:52
src/client.ts Show resolved Hide resolved
src/dd/index.ts Show resolved Hide resolved
Copy link

@AllFi AllFi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

src/dd/index.ts Outdated Show resolved Hide resolved
Co-authored-by: Alexander Filippov <aleksander.fill@gmail.com>
@akolotov akolotov merged commit 2505fd3 into develop Jul 10, 2023
@akolotov akolotov deleted the feature/dd-tools branch July 10, 2023 18:28
akolotov added a commit that referenced this pull request Jul 10, 2023
This merge contains the following set of changes:
  - Tooling for Direct Deposits (#144)
  - Support of USDC pool migrated from BOB (#147)
  - Added ability to redeem gift-card for exact value (#148)
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

Successfully merging this pull request may close these issues.

5 participants