-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat!: use contractGovernor to govern Treasury using ParamManager extract params to a separate file integrate contract governance into treasury swingset test for treasury governance closes #3189 closes #3473 * chore: minor cleanups: drop extra logs, standardize asserts, tsc fix * chore: improve typescript declarations * feat: add noAction electorate for assurance of no governance changes * chore: validate() in test checks the installations * fix: import types.js into params so bundle is usable in tests * fix: remove spurious distinction in naming of Liquidity keyword Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
1372ee8
commit c19f141
Showing
30 changed files
with
1,758 additions
and
643 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// @ts-check | ||
|
||
import { Far } from '@agoric/marshal'; | ||
import { makeSubscriptionKit } from '@agoric/notifier'; | ||
import { makePromiseKit } from '@agoric/promise-kit'; | ||
|
||
/** | ||
* This Electorate visibly has no members, takes no votes, and approves no | ||
* changes. | ||
* | ||
* @type {ContractStartFn} | ||
*/ | ||
const start = zcf => { | ||
const { subscription } = makeSubscriptionKit(); | ||
|
||
/** @type {ElectoratePublic} */ | ||
const publicFacet = Far('publicFacet', { | ||
getQuestionSubscription: () => subscription, | ||
getOpenQuestions: () => { | ||
/** @type {Handle<'Question'>[]} */ | ||
const noQuestions = []; | ||
const questionsPromise = makePromiseKit(); | ||
questionsPromise.resolve(noQuestions); | ||
return questionsPromise.promise; | ||
}, | ||
getName: () => 'no Action electorate', | ||
getInstance: zcf.getInstance, | ||
getQuestion: () => { | ||
throw Error(`noActionElectorate doesn't have questions.`); | ||
}, | ||
}); | ||
|
||
/** @type {ElectorateCreatorFacet} */ | ||
const creatorFacet = Far('creatorFacet', { | ||
getPoserInvitation: () => { | ||
return zcf.makeInvitation(() => {}, | ||
`noActionElectorate doesn't allow posing questions`); | ||
}, | ||
addQuestion() { | ||
throw Error(`noActionElectorate doesn't add questions.`); | ||
}, | ||
getVoterInvitations: () => { | ||
throw Error(`No Action Electorate doesn't have invitations.`); | ||
}, | ||
getQuestionSubscription: () => subscription, | ||
getPublicFacet: () => publicFacet, | ||
}); | ||
|
||
return { publicFacet, creatorFacet }; | ||
}; | ||
|
||
harden(start); | ||
export { start }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// @ts-check | ||
|
||
import './types.js'; | ||
|
||
import { buildParamManager, ParamType } from '@agoric/governance'; | ||
|
||
export const POOL_FEE_KEY = 'PoolFee'; | ||
export const PROTOCOL_FEE_KEY = 'ProtocolFee'; | ||
|
||
export const CHARGING_PERIOD_KEY = 'ChargingPeriod'; | ||
export const RECORDING_PERIOD_KEY = 'RecordingPeriod'; | ||
|
||
export const INITIAL_MARGIN_KEY = 'InitialMargin'; | ||
export const LIQUIDATION_MARGIN_KEY = 'LiquidationMargin'; | ||
export const INTEREST_RATE_KEY = 'InterestRate'; | ||
export const LOAN_FEE_KEY = 'LoanFee'; | ||
|
||
export const governedParameterTerms = { | ||
loanParams: [POOL_FEE_KEY, PROTOCOL_FEE_KEY], | ||
poolParams: [ | ||
CHARGING_PERIOD_KEY, | ||
RECORDING_PERIOD_KEY, | ||
INITIAL_MARGIN_KEY, | ||
LIQUIDATION_MARGIN_KEY, | ||
INTEREST_RATE_KEY, | ||
LOAN_FEE_KEY, | ||
], | ||
}; | ||
|
||
/** @type {{ FEE: 'fee', POOL: 'pool' }} */ | ||
export const ParamKey = { | ||
FEE: 'fee', | ||
POOL: 'pool', | ||
}; | ||
|
||
/** @type {MakeFeeParamManager} */ | ||
export const makeFeeParamManager = ammFees => { | ||
// @ts-ignore buildParamManager doesn't describe all the update methods | ||
return buildParamManager([ | ||
{ | ||
name: POOL_FEE_KEY, | ||
value: ammFees.poolFee, | ||
type: ParamType.NAT, | ||
}, | ||
{ | ||
name: PROTOCOL_FEE_KEY, | ||
value: ammFees.protocolFee, | ||
type: ParamType.NAT, | ||
}, | ||
]); | ||
}; | ||
|
||
/** @type {MakePoolParamManager} */ | ||
export const makePoolParamManager = (loanParams, rates) => { | ||
// @ts-ignore buildParamManager doesn't describe all the update methods | ||
return buildParamManager([ | ||
{ | ||
name: CHARGING_PERIOD_KEY, | ||
value: loanParams.chargingPeriod, | ||
type: ParamType.NAT, | ||
}, | ||
{ | ||
name: RECORDING_PERIOD_KEY, | ||
value: loanParams.recordingPeriod, | ||
type: ParamType.NAT, | ||
}, | ||
{ | ||
name: INITIAL_MARGIN_KEY, | ||
value: rates.initialMargin, | ||
type: ParamType.RATIO, | ||
}, | ||
{ | ||
name: LIQUIDATION_MARGIN_KEY, | ||
value: rates.liquidationMargin, | ||
type: ParamType.RATIO, | ||
}, | ||
{ | ||
name: INTEREST_RATE_KEY, | ||
value: rates.interestRate, | ||
type: ParamType.RATIO, | ||
}, | ||
{ | ||
name: LOAN_FEE_KEY, | ||
value: rates.loanFee, | ||
type: ParamType.RATIO, | ||
}, | ||
]); | ||
}; |
Oops, something went wrong.