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

style(run-protocol): @jessie-check for runStake #5148

Merged
merged 1 commit into from
Apr 19, 2022
Merged

Conversation

dckc
Copy link
Member

@dckc dckc commented Apr 19, 2022

refs: #3788

Zoe API design question: The only part of this code that wasn't already in Jessie was an attempt to have a single-source of truth for keywords in the contract: proposal.give[KW.Attestation]. proposal.give.Attestation looks nicer, but it's a use that is not checked against any defining occurrence.

@dckc dckc added Zoe package: Zoe Zoe Contract Contracts within Zoe Inter-protocol Overarching Inter Protocol labels Apr 19, 2022
@dckc dckc requested review from erights and samsiegart April 19, 2022 04:58
@dckc dckc requested a review from turadg as a code owner April 19, 2022 04:58
@dckc
Copy link
Member Author

dckc commented Apr 19, 2022

I notice the reserve contract has collateralSeat.getCurrentAllocation()[collateralKeyword].

cc @Chris-Hibbert


// new = after the transaction gets applied
const newCollateral = addSubtract(collateral, giveColl, wantColl);
// max debt supported by current Collateral as modified by proposal
const { amountLiened, maxDebt: newMaxDebt } =
manager.maxDebtForLien(newCollateral);

const giveRUN = AmountMath.min(proposal.give[KW.Debt] || emptyDebt, debt);
const wantRUN = proposal.want[KW.Debt] || emptyDebt;
const giveRUN = AmountMath.min(proposal.give.Debt || emptyDebt, debt);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

proposal.give.Attestation looks nicer, but it's a use that is not checked against any defining occurrence.

So now someone could type proposal.give.Debt and get no error, whereas proposal.give[KW.Debte] would have said KW doesn't have that key. But in both cases give doesn't constrain the keys.

I think where we want to get to is that you can validate the proposal with pattern matching so that the type system has a guarantee from some runtime validation as to what's in give. So imo let's work towards that and not invest in the stop-gap.

@dckc dckc added the automerge:rebase Automatically rebase updates, then merge label Apr 19, 2022
@mergify mergify bot merged commit 07f6d05 into master Apr 19, 2022
@mergify mergify bot deleted the dc-runStake-jessie branch April 19, 2022 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge Inter-protocol Overarching Inter Protocol Zoe Contract Contracts within Zoe Zoe package: Zoe
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants