forked from Agoric/agoric-3-proposals
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(default-params): Add new CM with new default `LiquidationMargin…
…` value TODO: Clear core-eval-support.js Refs: #12
- Loading branch information
1 parent
494c0c5
commit 93cf83e
Showing
6 changed files
with
1,140 additions
and
5 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,115 @@ | ||
/* global process */ | ||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
|
||
import { getManifestForAddAssetToVault } from '../src/proposals/addAssetToVault.js'; | ||
import { getManifestForPsm } from '../src/proposals/startPSM.js'; | ||
import { makeInstallCache } from '../src/proposals/utils.js'; | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */ | ||
export const defaultProposalBuilder = async ( | ||
{ publishRef, install: install0, wrapInstall }, | ||
{ | ||
debtLimitValue = undefined, | ||
interestRateValue = undefined, | ||
liquidationMarginValue = undefined, | ||
interchainAssetOptions = /** @type {object} */ ({}), | ||
} = {}, | ||
{ env = process.env } = {}, | ||
) => { | ||
/** @type {import('../src/proposals/addAssetToVault.js').InterchainAssetOptions} */ | ||
const { | ||
issuerBoardId = env.INTERCHAIN_ISSUER_BOARD_ID, | ||
denom = env.INTERCHAIN_DENOM, | ||
oracleBrand = 'ATOM', | ||
decimalPlaces = 6, | ||
keyword = 'ATOM', | ||
proposedName = oracleBrand, | ||
initialPrice = undefined, | ||
} = interchainAssetOptions; | ||
|
||
if (!denom) { | ||
assert(issuerBoardId, 'INTERCHAIN_ISSUER_BOARD_ID is required'); | ||
} | ||
|
||
const install = wrapInstall ? wrapInstall(install0) : install0; | ||
|
||
return harden({ | ||
sourceSpec: '../src/proposals/addAssetToVault.js', | ||
getManifestCall: [ | ||
getManifestForAddAssetToVault.name, | ||
{ | ||
debtLimitValue: debtLimitValue && BigInt(debtLimitValue), | ||
interestRateValue: interestRateValue && BigInt(interestRateValue), | ||
liquidationMarginValue: liquidationMarginValue && BigInt(liquidationMarginValue), | ||
interchainAssetOptions: { | ||
denom, | ||
issuerBoardId, | ||
decimalPlaces, | ||
initialPrice, | ||
keyword, | ||
proposedName, | ||
oracleBrand, | ||
}, | ||
scaledPriceAuthorityRef: publishRef( | ||
install( | ||
'@agoric/zoe/src/contracts/scaledPriceAuthority.js', | ||
'../bundles/bundle-scaledPriceAuthority.js', | ||
{ persist: true }, | ||
), | ||
), | ||
}, | ||
], | ||
}); | ||
}; | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */ | ||
export const psmProposalBuilder = async ( | ||
{ publishRef, install: install0, wrapInstall }, | ||
{ anchorOptions = /** @type {object} */ ({}) } = {}, | ||
{ env = process.env } = {}, | ||
) => { | ||
const { denom = env.ANCHOR_DENOM, decimalPlaces = 6 } = anchorOptions; | ||
|
||
assert(denom, 'ANCHOR_DENOM is required'); | ||
|
||
const install = wrapInstall ? wrapInstall(install0) : install0; | ||
|
||
return harden({ | ||
sourceSpec: '../src/proposals/startPSM.js', | ||
getManifestCall: [ | ||
getManifestForPsm.name, | ||
{ | ||
anchorOptions: { | ||
...anchorOptions, | ||
denom, | ||
decimalPlaces, | ||
}, | ||
installKeys: { | ||
psm: publishRef( | ||
install('../src/psm/psm.js', '../bundles/bundle-psm.js'), | ||
), | ||
mintHolder: publishRef( | ||
install( | ||
'@agoric/vats/src/mintHolder.js', | ||
'../../vats/bundles/bundle-mintHolder.js', | ||
), | ||
), | ||
}, | ||
}, | ||
], | ||
}); | ||
}; | ||
|
||
export default async (homeP, endowments) => { | ||
const { writeCoreProposal } = await makeHelpers(homeP, endowments); | ||
|
||
const tool = await makeInstallCache(homeP, { | ||
loadBundle: spec => import(spec), | ||
}); | ||
|
||
await writeCoreProposal('gov-add-collateral', defaultProposalBuilder); | ||
await writeCoreProposal('gov-start-psm', opts => | ||
// @ts-expect-error XXX makeInstallCache types | ||
psmProposalBuilder({ ...opts, wrapInstall: tool.wrapInstall }), | ||
); | ||
}; |
Oops, something went wrong.