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

How can I use ickbDeposit to generate deposit transaction? #17

Open
ashuralyk opened this issue Oct 21, 2024 · 5 comments
Open

How can I use ickbDeposit to generate deposit transaction? #17

ashuralyk opened this issue Oct 21, 2024 · 5 comments

Comments

@ashuralyk
Copy link

from the demostration of v1-interface, I saw you used a function named base to build a basic transaction, which contains some order melt instructions, and then use this generated basic transaction to call ickbDeposit function in this repo.

so, I guess this ickbDeposit interface only works with base function together, which means this function isn't independent for integration of other apps, is that right?

note: https://github.com/ickb/v1-interface/blob/master/src/transaction.ts#L38

need help: I only decide to use v1-core and lumos-utils repos to make integration, please give me some ideas.

@ashuralyk
Copy link
Author

until now, I feel like I should copy plenty of code from v1-interface to do integration, if you @phroi have a better plan which is more simple, please tell me.

@phroi
Copy link
Member

phroi commented Oct 21, 2024

Hey @ashuralyk, thank you for publicly expressing your interest in iCKB as part of the integration of iCKB in NervDAO, I personally appreciate a lot!! 🙏

from the demostration of v1-interface, I saw you used a function named base to build a basic transaction, which contains some order melt instructions

Yes, you can find examples of Base function in all iCKB based scripts: v1-interface, v1-bot, v1-tester...

The idea is simple, Base is a function to create the base tx, this tx consumes:

  • All capacities
  • All iCKB xUDT cells
  • All intermediate states ready to be consumed:
    • iCKB Receipts (which will be converted to iCKB xUDT)
    • Matured Withdrawal Requests (which will be be converted to capacity cells)
    • Fulfilled Orders (which will be decomposed into their capacity cell and iCKB xUDT counterparts)
    • Open Orders (this happens only in the interface because of this underlying assumption: in the interface at every moment at maxmum of a single iCKB conversion order can exists for each user)

A base tx with all user cells accounted for allow to account for CKB and iCKB xUDT balances easily.

@phroi
Copy link
Member

phroi commented Oct 21, 2024

use this generated basic transaction to call ickbDeposit function in this repo.

I'd like to point out one small but crucial detail about ickbDeposit:

ickbDeposit calls need to be followed by a addIckbUdtChange call when closing the tx
otherwise those deposits do not have a receipt, so they're not credited to the user
and basically get burned

Given how easy is to misuse, I also added a comment to the code: 55755e9

@phroi
Copy link
Member

phroi commented Oct 21, 2024

I guess this ickbDeposit interface only works with base function together

Not really. Base is a nice abstraction, but ickbDeposit doesn't depend on it. The only implicit dependency ickbDeposithas is addIckbUdtChange and that config is populated (hopefully with the Config Adapter logic: https://github.com/ickb/lumos-utils/blob/master/src/config.ts )

which means this function isn't independent for integration of other apps, is that right?

Not really. Then again, you cannot disregard the underlying Lumos foundation and hope that it works.
These iCKB libraries are built on top of Lumos as CCC until a while ago did not exist.
Porting them to CCC may be non-trivial as it needs deep understanding of CCC, iCKB and Lumos.

@phroi
Copy link
Member

phroi commented Oct 21, 2024

I only decide to use v1-core and lumos-utils repos to make integration

That's how they are supposed to be used, then again I clearly warn in the README of both lumos-utils and v1-core:

It's advised against building on top of this library outside iCKB and related Phroi's projects. The absence of docs, the unstable API and the future possibility of it becoming unmaintained make it suitable only as internal library.

So watch out: the libraries are not stable and they will break in the future, possibly for switching to CCC.

please give me some ideas

Sure, here three alternative ideas:

  1. Wait for an OTX based limit order to come around, then integrate by rewriting bottom-up the iCKB_Logic integration in CCC. Possibly by that time iCKB libraries will already use CCC.
  2. Rewrite bottom up the iCKB libraries to use CCC and then integrate.
  3. Team up with me: I do the re-writing, you give fast feedback on their CCC integration (I have to re-evaluate the goodness of CCC first tho)

until now, I feel like I should copy plenty of code from v1-interface to do integration, if you @phroi have a better plan which is more simple, please tell me.

Sure sure, you can copy as much as you like, feel free to credit (or not, it's ok 🤣)

Just watch out, I'll not edit your copies: you are forking, you keep them up to date with the undocumented breaking changes...

Love & Peace, Phroi

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

No branches or pull requests

2 participants