Skip to content

Commit

Permalink
Remove assertProposalShape & update makeInvitation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge-Lopes committed Sep 15, 2022
1 parent 1cc00ca commit e319cd6
Showing 1 changed file with 39 additions and 17 deletions.
56 changes: 39 additions & 17 deletions contract/src/stopLoss.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,8 @@ const start = async (zcf) => {
}); // Notify user

const makeLockLPTokensInvitation = () => {
const lockLPTokens = (creatorSeat) => {
assertProposalShape(creatorSeat, {
give: { LpToken: null },
});

const lockLPTokens = (creatorSeat) => {
assertScheduledOrActive(phaseSnapshot);

const {
Expand All @@ -166,21 +163,24 @@ const start = async (zcf) => {
return `LP Tokens locked in the value of ${lpTokenAmount.value}`;
};


// TODO: find the correct way to get lpTokenAmount.value for the give : ...
// const proposalShape = harden({
// want: {},
// give: {LpToken: AmountMath.make(lpTokenBrand, VALUE_???},
// exit: { onDemand: null },
// });

return zcf.makeInvitation(
lockLPTokens,
'Lock LP Tokens in stopLoss contract',
// undefined,
// proposalShape,
);
};

const makeWithdrawLiquidityInvitation = () => {
const withdrawLiquidity = async (creatorSeat) => {
assertProposalShape(creatorSeat, {
want: {
Central: null,
Secondary: null,
},
});

await removeLiquidityFromAmm();
assertAllocationStatePhase(phaseSnapshot, ALLOCATION_PHASE.REMOVED);

Expand Down Expand Up @@ -211,15 +211,25 @@ const start = async (zcf) => {
return `Liquidity withdraw to creator seat`;
};

return zcf.makeInvitation(withdrawLiquidity, 'withdraw Liquidity');
const proposalShape = harden({
want: {
Central: AmountMath.makeEmpty(centralBrand),
Secondary: AmountMath.makeEmpty(secondaryBrand),
},
give: {},
exit: { onDemand: null },
});

return zcf.makeInvitation(
withdrawLiquidity,
'withdraw Liquidity',
undefined,
proposalShape,
);
};

const makeWithdrawLpTokensInvitation = () => {
const withdrawLpTokens = (creatorSeat) => {
assertProposalShape(creatorSeat, {
want: { LpToken: null },
});

assertAllocationStatePhase(phaseSnapshot, ALLOCATION_PHASE.ACTIVE);

const lpTokenAmountAllocated = stopLossSeat.getAmountAllocated(
Expand All @@ -240,7 +250,18 @@ const start = async (zcf) => {
return `LP Tokens withdraw to creator seat`;
};

return zcf.makeInvitation(withdrawLpTokens, 'withdraw Lp Tokens');
const proposalShape = harden({
want: { LpToken: AmountMath.makeEmpty(lpTokenBrand) },
give: {},
exit: { onDemand: null },
});

return zcf.makeInvitation(
withdrawLpTokens,
'withdraw Lp Tokens',
undefined,
proposalShape,
);
};

const removeLiquidityFromAmm = async () => {
Expand Down Expand Up @@ -323,3 +344,4 @@ const start = async (zcf) => {
};
harden(start);
export { start };

1 comment on commit e319cd6

@Jorge-Lopes
Copy link
Owner Author

Choose a reason for hiding this comment

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

Related to issue #29

Please sign in to comment.