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 to add an offer, getOfferResult via wallet / wallet bridge #671

Open
dckc opened this issue May 5, 2022 · 1 comment
Open

How to add an offer, getOfferResult via wallet / wallet bridge #671

dckc opened this issue May 5, 2022 · 1 comment
Labels
beta pre-smart wallet; beta ag-solo / mailbox architecture documentation

Comments

@dckc
Copy link
Member

dckc commented May 5, 2022

Docs for E(walletBridge).addOffer(offer) are incomplete; there's no documentation on the OfferState type.

I learned how to do it from the REPL last night; the example I cribbed from was:

https://github.com/Agoric/dapp-amm/blob/32b4cb59bdb7d252630742094e2cfaf1dc1d6db7/ui/src/services/liquidity.service.js#L281-L308

but note that the instance and installation can be specified directly, without going via the board.

Screenshot at 2022-05-04 21-56-04

REPL transcript:

command[171]
E(home.wallet).getPurses()
history[171]
[["ATOM",[Object Alleged: Virtual Purse]{}],["Agoric RUN currency",[Object Alleged: Virtual Purse]{}],["Agoric staking token",[Object Alleged: Virtual Purse]{}],["Default Zoe invite purse",[Object Alleged: Zoe Invitation purse]{}],["USDC Anchor",[Object Alleged: Virtual Purse]{}],[["AgoricAMM","AUSDLiquidity"],[Object Alleged: AUSDLiquidity purse]{}]]
command[172]
USDC.name='USDC Anchor'
history[172]
"USDC Anchor"
command[173]
RUN.name='Agoric RUN currency'
history[173]
"Agoric RUN currency"
command[174]
mkw= (kit, qty) => ({pursePetname: kit.name, value: qty * kit.unit})
history[174]
[Function mkw]
command[175]
proposalTemplate = { give: {Secondary: mkw(USDC, 2n)}, {Central: mkw(RUN, 2n)}}
history[175]
exception: [SyntaxError: missing identifier]
command[176]
proposalTemplate = { give: {Secondary: mkw(USDC, 2n), Central: mkw(RUN, 2n)}}
history[176]
{"give":{"Secondary":{"pursePetname":"USDC Anchor","value":2000000n},"Central":{"pursePetname":"Agoric RUN currency","value":2000000n}}}
command[177]
E(amm.pub).makeAddLiquidityInvitation().then(invitation=> (offerConfig = { id: '4927', invitation, installationHandle: amm.installation, instanceHandle: amm.instance, proposalTemplate }
history[177]
exception: [SyntaxError: missing )]
command[178]
E(amm.pub).makeAddLiquidityInvitation().then(invitation=> (offerConfig = { id: '4927', invitation, installationHandle: amm.installation, instanceHandle: amm.instance, proposalTemplate })
history[178]
exception: [SyntaxError: missing ,]
command[179]
E(amm.pub).makeAddLiquidityInvitation().then(invitation=> (offerConfig = { id: '4927', invitation, installationHandle: amm.installation, instanceHandle: amm.instance, proposalTemplate }))
history[179]
{"id":"4927","invitation":[Object Alleged: Zoe Invitation payment]{},"installationHandle":[Object Alleged: Installation]{},"instanceHandle":[Object Alleged: InstanceHandle]{},"proposalTemplate":{"give":{"Secondary":{"pursePetname":"USDC Anchor","value":2000000n},"Central":{"pursePetname":"Agoric RUN currency","value":2000000n}}}}
command[180]
offerConfig
history[180]
undefined
command[181]
E(wb).addOffer(offerConfig)
history[181]
"4927"
command[182]
E(amm.pub).makeAddLiquidityInvitation().then(invitation=> (offerConfig = { id: '4928', invitation, installationHandle: amm.installation, instanceHandle: amm.instance, proposalTemplate }))
history[182]
{"id":"4928","invitation":[Object Alleged: Zoe Invitation payment]{},"installationHandle":[Object Alleged: Installation]{},"instanceHandle":[Object Alleged: InstanceHandle]{},"proposalTemplate":{"give":{"Secondary":{"pursePetname":"USDC Anchor","value":2000000n},"Central":{"pursePetname":"Agoric RUN currency","value":2000000n}}}}
command[183]
E(wb).addOffer(offerConfig)
history[183]
"4928"
command[184]
ALiq.name = ["AgoricAMM","AUSDLiquidity"]
history[184]
["AgoricAMM","AUSDLiquidity"]
command[185]
proposalTemplate = { give: {Secondary: mkw(USDC, 2n), Central: mkw(RUN, 2n)}, want: { Liquidity: mkw(ALiq, 0n) }}
history[185]
{"give":{"Secondary":{"pursePetname":"USDC Anchor","value":2000000n},"Central":{"pursePetname":"Agoric RUN currency","value":2000000n}},"want":{"Liquidity":{"pursePetname":["AgoricAMM","AUSDLiquidity"],"value":0n}}}
command[186]
E(amm.pub).makeAddLiquidityInvitation().then(invitation=> (offerConfig = { id: '4955', invitation, installationHandle: amm.installation, instanceHandle: amm.instance, proposalTemplate }))
history[186]
{"id":"4955","invitation":[Object Alleged: Zoe Invitation payment]{},"installationHandle":[Object Alleged: Installation]{},"instanceHandle":[Object Alleged: InstanceHandle]{},"proposalTemplate":{"give":{"Secondary":{"pursePetname":"USDC Anchor","value":2000000n},"Central":{"pursePetname":"Agoric RUN currency","value":2000000n}},"want":{"Liquidity":{"pursePetname":["AgoricAMM","AUSDLiquidity"],"value":0n}}}}
command[187]
E(wb).addOffer(offerConfig)
history[187]
"4955"
command[188]
E(amm.pub).getPoolAllocation(USDC.brand)
history[188]
{"Central":{"brand":[Object Alleged: RUN brand]{},"value":83146636n},"Liquidity":{"brand":[Object Alleged: AUSDLiquidity brand]{},"value":0n},"Secondary":{"brand":[Object Alleged: AUSD brand]{},"value":80861958n}}
command[189]
E(home.wallet).lookup('offerResult', '4955')
history[189]
Promise.reject("Error: \"id\" not found: (a string)")
command[190]
E(home.wallet).lookup('offerResult', '4928')
history[190]
Promise.reject("Error: \"id\" not found: (a string)")
command[191]
E(home.wallet).lookup('offerResultXX', '4928')
history[191]
Promise.reject("Error: \"lookups\" not found: (a string)")
command[192]
E(home.wallet).lookup('offerResult')
history[192]
[Object Alleged: offerResultLookup]{}
command[193]
E(home.wallet).lookup('offerResultXX', 'undefined#4928')
history[193]
Promise.reject("Error: \"lookups\" not found: (a string)")
command[194]
E(home.wallet).lookup('offerResultXX', '#4928')
history[194]
Promise.reject("Error: \"lookups\" not found: (a string)")
command[195]
E(home.wallet).lookup('offerResultXX', 'unknown#4928')
history[195]
Promise.reject("Error: \"lookups\" not found: (a string)")
command[196]
E(home.wallet).lookup('offerResultXX', 'http://127.0.0.1:8000/#4928')
history[196]
Promise.reject("Error: \"lookups\" not found: (a string)")
command[197]
E(home.wallet).lookup('offerResult', 'unknown#4955')
history[197]
"Added liquidity."
@Tyrosine22
Copy link
Contributor

I'll take care of this when I document Smart Wallet. (see #748)

@dckc dckc added the beta pre-smart wallet; beta ag-solo / mailbox architecture label Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta pre-smart wallet; beta ag-solo / mailbox architecture documentation
Projects
None yet
Development

No branches or pull requests

4 participants