cowprotocol / cow-sdk

CoW protocol SDK
https://docs.cow.fi/cow-protocol/reference/sdks/cow-sdk
Other
31 stars 9 forks source link

🧠 Brain Dump on 2.0 SDK Review (low prio) #117

Open anxolin opened 1 year ago

anxolin commented 1 year ago

The new version of the SDK is great. I really like the examples and seems easy to use.

Just some notes on things we could improve or consider. We should give more prio to any feedback we receive from people integrating it. In principle, I consider all of these low prios unless we see projects taking interest on having it, or we see potential.

Pending

Docs

Review of https://docs.cow.fi/cow-sdk/getting-started-with-the-sdk

OrderBookApi - provides the ability to retrieve orders and trades from the CowSap order-book, as well as add and cancel them

I think i mentioned in on PR, but probably lost.

OrderSigningUtils - serves to sign orders and cancel them using EIP-712

Why limited to EIP712, shouldn't this util facilitate also pre-sign?

Pre-sign Flow

Ideally, we would add this flow to make it super easy.

One more thing, I think the util that pre-sign, should send the pre-sign using the provider, but also provide a version which returns the call-data so an integration could use it on their own stack (like use it for proposing a multisig, etc)

Not sure: Should we include Wrap/Unwrap/Approval

To have a fully fledge API, we might want to add either to SigniningUtil or export a new Util, for Wraps/Unwraps or token approvals

Polling to await for execution (maybe even emit some intermediate events!)

It would be nice to have a utility that provides a simple interface (return Promise), and maybe even combines with an event emitter too (https://www.jpwilliams.dev/using-eventemitters-to-resolve-promises-from-afar-in-nodejs) just to get some intermediate events (like partial fills)

See: https://github.com/cowprotocol/cow-sdk/issues/83

List of tokens

It might be convenient to give easy access the list of tokens.

Would be nice to explore the options, but one low-hanging is to return https://files.cow.fi/tokens/CowSwap.json wrapped by a fetch method and give some nice types to it.

If we implement a API, also nice to consider exposing it here.

Eth Flow

I guess is missing for now.

What would be the plan to add it?

Smart quote

We might want to consider moving the smart quote here. Alternatively we can move it to some other central module to reuse in the explorer

Gnosis Safe / Multisigs considerations

Maybe is nice to add some additional methods that would be tailored for Multisigs.

We could explore this possibility.