-
Notifications
You must be signed in to change notification settings - Fork 212
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
RUNstake: borrow RUN against staked BLD #3788
Comments
With @JimLarson and @Chris-Hibbert , I drew a sequence diagram on a whiteboard. I'm trying to refine it closer to the details of our platform. @startuml runLoC
treasury -> walletBridge: getPurseBalance("BLD")
walletBridge --> treasury: 5000
treasury -> attestation: getMax(ag123)
attestation -> golang: getAccountState(ag123)
golang --> attestation: "4000 BLD liened"
attestation --> treasury: "4000 BLD liened"
treasury -> attestation: getReturnableAttestation(450 RUN)
attestation -> golang: setLienedAmount(4500 BLD)
golang --> attestation: yes
treasury -> attestation: give: 0; want: attestation 450
attestation --> walletBridge: attestation
walletBridge -> runLoC: attestation
runLoC -> priceAuthority: BLD price?
priceAuthority --> runLoC: 0.50RUN
runLoC -> mintRUN: mintGains(450)
mintRUN --> runLoC: 450RUN
runLoC --> walletBridge: 450RUN
@enduml
|
refined in discussion...
amount borrowed vs. amount lienedamount borrowed should be adjustable independent of amount liened. hm. authority to create a lienin the user bundle? |
1st draft of run LoC: https://github.com/Agoric/agoric-sdk/blob/dc-run-loc/packages/treasury/src/runLoC.js TODOs are tracked in the comment description |
I had the impression that getting a RUN LoC would require the user to accept 2 offers:
and then another 2 to release the lien:
After discussion with @Chris-Hibbert and reviewing the code, we determined that getting an attestation doesn't involve an offer. Just like the wallet takes offer descriptions from dapps and makes them into actual offers by filling in payments taken from purses, the wallet should fill in an attestation payment by getting an attestation. (IOU a separate wallet issue.) Bootstrap will have to provide the wallet with an The attestation contract currently uses invitations / offers to return attestations, but it might as well just have a public API method to do so. Then, just like the wallet takes payouts and puts them in a user's purse, it should recognize attestation payouts and return them using the public method. |
Brainstorm: Virtual Purses for Extendable Liensthe main limitation of the existing attestation-based design, that the lien has to be paid off before it can be extended, has been escalated to its own issue: #4245 notes from discussion with @samsiegart on novel purse in place of // both do
publicLienableBLDBrand = board.get...;
// wallet does
purse2 = home.myBLDVirtualPurse
purse3 = home.myLienableBLDVirtualPurse
purse3.getCurrentAmount() === { brand: home.myPersonalBrand, value: 6000n };
display(purse3.getCurrentAmount()) // cross golang bridge
// display 0 liened instead of 6000 lienable?
// dapp does
attAmount = {brand: publicLienableBLDBrand, value: 4000n};
walletBridge.suggestOffer({ give: { Attestation: attAmount });
// wallet does
if (amount.brand === publicLienableBLDBrand) { // or: if (invitation is from RunLoC) { ...?
const myAmount = { brand: home.myPersonalBrand, value: amount.value}
}
pmt = purse3.withdraw(myAmount) // golang setLien(4000)
E(zoe).offer(... { give: { Lien: pmt }, want: { RUN: run(100) }});
purse3.getCurrentAmount() === { brand: home.myPersonalBrand, value: 2000n };
// to release the lien:
purse3.deposit({ brand: home.myPersonalBrand, value: 4000n]})
// to decrease the lien:
purse3.deposit({ brand: home.myPersonalBrand, value: 1500n]}) p.s. switching out the brand wouldn't preserve offer-safety. The dApp would have to use myPersonalBrand too. |
Note that attempting to decrease or release the lien could fail unless the current debt is low enough. Also, the available-to-lien balance is |
sync'd up with @samsiegart . For a getRUN demo, we have a bunch of pieces missing:
|
@michaelfig and I worked out an approach using
That version of bootstrap starts the economy. Then we start our
We get provisioned with 13BLD (13_000_000 ubld). We stake 9BLD:
Now we can get an attestation in the REPL:
|
I spent a little time this week with @andrey-kuprianov of @informalsystems building a diagram. Thanks, @arirubinstein , for transcribing it to mermaid: |
My new security pitch about diagramming in five words: Agoric: We have art projects 🎨 |
Another diagrams (from #4741 (comment) ) sequenceDiagram
actor dapp
participant walletBridge
participant attestation
participant runStake
participant golang
note right of dapp: How dapp finds the current state
note right of walletBridge: walletBridge is provided to dapps and controlled by Wallet UI
dapp ->>+ walletBridge: getPurseBalance("BLD")
dapp -->> walletBridge: 5000
note right of attestation: ag123 is a cosmos address
dapp ->> attestation: getMax(ag123)
attestation ->> golang: getAccountState(ag123)
note right of golang: Cosmos supports lien
golang -->> attestation: account status in which 4000 BLD liened
attestation -->> dapp: account status in which 4000 BLD liened
note right of dapp: Treasury now knows
note right of dapp: Want to get 450 RUN by liening 500 BLD
dapp ->> walletBridge: getReturnableAttestation(want: 450 RUN, give: 500 BLD-Att)
note right of walletBridge: Blocks on user approval in wallet
walletBridge ->> attestation: makeAttestation(500 BLD)
attestation ->> golang: setLienedAmount(4000 + 500 BLD)
golang -->> attestation: ACK or throws
attestation -->> walletBridge: Payment of 500 BLD-Att liened on ag123
walletBridge ->> runStake: offer w/payment for {give: 500 BLD-Att, want: 450 RUN}
runStake --> walletBridge: Payment for 450RUN and offerResult
walletBridge --> dapp: notifiers from offerResult
|
I don't think so, but that's a product requirements question; it's not my role to decide.
Good question. I'm struggling to figure out the scope of this issue. It could be as small as the contract component (which is done, or at least: merged to master) or it could include integration with the wallet and bootstrap. More later... |
+1 for smaller scoped issues, it's easier to understand what is and isn't done that way |
empty bug: https://gist.github.com/samsiegart/da0a5a519cc20ec343d962abae1317ef notifiers need to look like: publicNotifiers: {
vault: vault.getNotifier(),
asset: assetNotifier,
}, |
What is the Problem Being Solved?
per RUNStake User Stories section by @rowgraus and co 5 Apr:
As a BLD staker with no RUNstake position, I need to be able to open a position by placing a lien on my staked BLD and receiving RUN
As a BLD staker with an existing RUNStake position, I need to be able to manage it; that is: adjust my RUN debt and BLD lien within the bounds of the contract.
As a BLD staker with an existing RUNStake position, I need to be able to close it entirely
Description of the Design
Like vaultFactory, the runStake contract provides loans and charges interest and minting fees; differences include:
Design notes in runStake/README.md include a sequence diagram of interactions between a user/dapp, walletBridge, runStake (and attestation), and Cosmos SDK.
We use a semi-fungible
copyBag
token to represent lien attestations: the items is the address where BLD is staked and the quantity is the lien (delta).getLiened()
to attMaker so the wallet can get it before taking out a loan.related work:
Security Considerations
Test Plan
attestationMaker
to eachhome.wallet
as in RUNstake: borrow RUN against staked BLD #3788 (comment)local-chain
governance testing documentationnice to have:
The text was updated successfully, but these errors were encountered: