-
Notifications
You must be signed in to change notification settings - Fork 226
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
[Zoe] Sparse Keywords Spec #800
Comments
One consequence of this change - users should look at what keywords are expected by the contracts for each position, since Zoe no longer fills in all keywords for the users. For instance, in Autoswap, when Alice removed liquidity, she didn't specify what she wanted in return, because in this test, she supposedly didn't care. However, now the Autoswap contract does expect a user to specify the two tokens they want, because it will not be filled in by Zoe. |
Additionally, we can get rid of the |
@DavidBruant suggested calling |
Zoe currently has the concept of
keywords
which are used as indexes in place of the array indexes that we had previously. The keywords are used to matchproposal
elements,payments
,amounts
in the offerRecord within Zoe, andpayouts
to the user. Keywords are per contract, and are currently objective: they are the same for all users of a contract.We expect that future contracts (specifically multipool Autoswap #391) will have many keywords, potentially hundreds. Therefore, we want to ensure that the
keywordRecords
(records using keywords as keys) throughout Zoe are sparse, much sparser than all the keywords for a contract.The question is where a subset of these keywords should be used, and how this subset is derived at different points.
Below are key points in Zoe where keywords are used:
User
Zoe
offer.proposal
(the user's offer proposal)offer.amounts
(the current allocation)Contract
offer.proposal
(the user's offer proposal, possibly altered in the query)offer.amounts
(the current allocation, possibly altered in the query)newAmountKeywordRecord
arguments tozcf.reallocate
The current Zoe makes this easy by filling all the keywords that the contract has at the time that the user escrows with Zoe, so at no point after that step do any partial keywords exist. However, that strategy will not work for contracts with hundreds of keywords.
We decided March 27th that the solution, the "sparse keywords" PR, should include the following:
allKeywords
*sparseKeywords
*offerRecord
will still includeproposal
andamounts
. However, the Zoe Contract Facet (zcf) API will change.zcf.getOffers
andzcf.getOffer
will only returnproposal
,handle
, andinstanceHandle
, notamounts
zcf.getAmounts
andzcf.getAmountsForOffer
, which will take as argumentsofferHandles
, andsparseKeywords
. The representation of amounts that is returned should have filled in empty values for all thesparseKeywords
and anything not listed insparseKeywords
is dropped. Note that nothing changes in Zoe's offerRecord table. This is merely changing what the contract gets as a response to the query.proposal.give
. Zoe will check that these match, but will not do any additional filling.offerRecord.amounts
after depositing the user's payments, Zoe will fill in thewants
of the user's offer with empty. Zoe will not fill in all keywords, just the ones mentioned by the user.zcf.reallocate
will have a similar signature tozcf.getAmounts
:offerHandles
,sparseKeywords
andnewAmountKeywordRecords
will be the arguments.zcf.reallocate
will throw an error if any of thenewAmountKeywordRecords
do not have a value for all the keywords insparseKeywords
. An error will also be thrown if anynewAmountKeywordRecords
have keywords that are not insparseKeywords
. We expect that contracts will be usingzcf.getAmounts
and then callingzcf.reallocate
, so these requirements should not be burdensome if the samesparseKeywords
is used in both calls, sincezcf.getAmounts
fills in the values appropriately.zcf.reallocate
will change the keywords inofferRecord.amounts
offerRecord.amounts
for that user, because that is what our offer safety and rights conservation checks were made over.Asterisk: Kate's late addition
The text was updated successfully, but these errors were encountered: