Conversation
5e4d02c to
ea91a14
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
v2 Typescript SDK (ring0 only)
This PR implements the Typescript SDK for ring0 direct matches.
Note that the Typescript SDK already supports external matches.
It also deletes unused v1 packages, though should still be available via NPM. The
price_reporter,token, andcorepackages remain.Interface
Users should have this
package.jsondependency:BTW,
@renegade-fi/renegade-sdkalso exposesExternalMatchClient:Publishing
Follow these instructions to publish to NPM after this PR is merged:
The
changeset:publishscript runs./wasm_v2/build.sh(Schnorr keyderivation WASM), builds all packages, then publishes to npm. The WASM binary
is bundled inside
@renegade-fi/direct-match's tarball.Packages must be published in dependency order (
direct-matchandexternal-matchbeforerenegade-sdk). Changesets handles this automatically.Quick start
In
typescript-sdk/, run:Next, set private key environment variables which correspond to Base Sepolia
EOAs that should be funded with ETH, dummy WETH
(
0x31a5552AF53C35097Fdb20FFf294c56dc66FA04c), and dummy USDC(
0xD9961Bb4Cb27192f8dAd20a662be081f546b0E74).Not all the tests require these keys.
For the quoter match test (
matchQuoterOrders.test.ts), you also need to belogged in to the AWS CLI (
aws login). The test fetchesQUOTERS_API_KEYandRELAYER_ADMIN_KEYfrom Secrets Manager. Alternatively, set them asenvironment variables:
The Base Sepolia v2 WETH quoters must be funded and rebalanced for the quoter
match test to work.
Next, run the tests:
DirectMatchClientThe
DirectMatchClientclass is the starting point to creating, placing,updating, and cancelling direct match orders to a Renegade relayer. Like the
Rust SDK, the Typescript SDK provides convenience functions to instantiate
DirectMatchClientto specific chains:Clients can be instantiated via:
newArbitrumOneClient()newArbitrumSepoliaClient()newBaseMainnetClient()newBaseSepoliaClient()Supported client functions
Only ring0-relevant functions are currently supported.
createAccount()create_account()createAndGetAccount.test.tsgetAccount()get_account()createAndGetAccount.test.tssyncAccount()sync_account()getBalances()get_balances()getBalances.test.tsgetBalanceByMint(mint)get_balance_by_mint(mint)getBalanceByMint.test.tsplaceOrder(params)place_order(built_order)getOrderAndPlaceOrder.test.tsplaceOrderInPool(params, pool, adminKey)admin_place_order_in_pool()matchQuoterOrders.test.tsgetOrder(orderId)get_order(order_id)getOrderAndPlaceOrder.test.tsgetOrders(includeHistoric)get_orders(include_historic)getOrders.test.tscancelOrder(orderId)cancel_order(order_id)cancelOrder.test.tsupdateOrder(params)update_order(config)updateOrder.test.tsSchnorr public key generation
Although ring0 trades do not rely on the account's Schnorr public key, the
relayer expects a valid curve point during account creation. This PR provides
WASM code to do this. The function to derive this public key is in
wasm_v2/src/lib.rs.I considered writing a pure-Typescript version of this function but decided to
stick to using WASM because the v1 Typescript SDK already uses WASM for many
cryptographic functions, and it's much more straighforward to follow that
pattern even though we only need one function for now. The WASM integration to
Typescript works just fine. Furthermore, it's safer to rely on existing
cryptographic libraries (i.e.
ark-ed-on-bn254) than to write my own.What's missing
updateOrder: implemented client-side but relayer returns 501record-ring0-fill-details)