Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wphan committed Mar 27, 2024
1 parent 01dd267 commit 0fc5064
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,35 @@ Anyone can verify the whole setup after that:
```

## API
We can host API in local server:
Axum server under `/api` serves merkle proof for users. We add some more caching functionality and some helpers
to make it eaier to determine how much a user is eligible to claim.

* API server tries to cache account data locally
* it calls `getProgramAccounts` for each `Distributor` on startup and saves all `ClaimStatus` accounts
* calls `getProgramAccounts` for each `Distributor` on startup and saves all `ClaimStatus` accounts
* does `programSubscribe` on `ClaimStatus` accounts to update cache in real time
* _maybe we should do some smart cache updating based on calls to `/claim`_
* cache is backed `dashmap`, each key-value pair is about 180 bytes (excl overhead of structs and DashMap)
* 10_000 accounts: 1.8MB
* 100_000 accounts: 18MB
* 1_000_000 accounts: 180MB
* endpoints
* `GET /distributors` returns list of registered `MerkleDistributor`s
* `GET /user/:user_pubkey`: returns proof and unlocked amounts for a user
* `404` if user doesn't exist in the tree.
* `500` if user exists in tree but has no proof
* `GET /claim/:user_pubkey`: returns `ClaimStatus` info for user.
* `404` if `ClaimStatus` account doesn't exist (user did not claim yet or does not exist in tree)
* endpoints
* `GET /distributors` returns `MerkleDistributor` account info
* `GET /user/:user_pubkey`: returns merkle proof and amounts for a user
* `404` if user doesn't exist in the tree.
* `500` if user exists in tree but has no proof
* `GET /claim/:user_pubkey`: returns `ClaimStatus` info for user.
* `404` if `ClaimStatus` account doesn't exist (user did not claim yet or does not exist in tree)
* `GET /eligibility/:user_pubkey`: returns a combination of `/user` and `/claim` info
* `200` with claim info if user is in tree (`claimed_amount` is 0 if pending)
* `404` if user has no claim

```
cd api
cargo build
../target/debug/drift-airdrop-api --merkle-tree-path [PATH_TO_FOLDER_STORE_ALL_MERKLE_TREES] --rpc-url [RPC] --mint [TOKEN_MINT] --program-id [PROGRAM_ID]
../target/debug/drift-airdrop-api --merkle-tree-path [PATH_TO_FOLDER_STORE_ALL_MERKLE_TREES] \
--program-id E7HtfkEMhmn9uwL7EFNydcXBWy5WCYN1vFmKKjipEH1x \
--mint 4m9qg7yfJQcCLobNFgHCw6a9ZEBAYyxyy5YGef3ijknU \
--rpc-url https://your.rpc.com \
--ws-url wss://your.rpc.com
```

0 comments on commit 0fc5064

Please sign in to comment.