-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(run-protocol)!: centralSupply contract for bootstrapPayment
closes #4021 BREAKING CHANGE: removes getBootstrapPayment from VaultFactory
- Loading branch information
Showing
6 changed files
with
76 additions
and
142 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
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,57 @@ | ||
// @ts-check | ||
|
||
import { AmountMath } from '@agoric/ertp'; | ||
import { E, Far } from '@endo/far'; | ||
|
||
const { details: X } = assert; | ||
|
||
/** | ||
* The sole purpose of this contract is to mint the initial | ||
* supply of the central currency, RUN. | ||
* | ||
* @param {ContractFacet} zcf | ||
* @param {Object} privateArgs | ||
* @param {FeeMintAccess} privateArgs.feeMintAccess | ||
*/ | ||
export const start = async (zcf, { feeMintAccess }) => { | ||
const { bootstrapPaymentValue } = zcf.getTerms(); | ||
assert.typeof(bootstrapPaymentValue, 'bigint'); | ||
|
||
const runMint = await zcf.registerFeeMint('RUN', feeMintAccess); | ||
const { brand: runBrand } = await E(runMint).getIssuerRecord(); | ||
const mintBootstrapPayment = () => { | ||
const { zcfSeat: bootstrapZCFSeat, userSeat: bootstrapUserSeat } = | ||
zcf.makeEmptySeatKit(); | ||
const bootstrapAmount = AmountMath.make(runBrand, bootstrapPaymentValue); | ||
runMint.mintGains( | ||
harden({ | ||
Bootstrap: bootstrapAmount, | ||
}), | ||
bootstrapZCFSeat, | ||
); | ||
bootstrapZCFSeat.exit(); | ||
const bootstrapPayment = E(bootstrapUserSeat).getPayout('Bootstrap'); | ||
|
||
/** | ||
* @param {Amount=} expectedAmount - if provided, assert that the bootstrap | ||
* payment is at least the expected amount | ||
*/ | ||
const getBootstrapPayment = expectedAmount => { | ||
if (expectedAmount) { | ||
assert( | ||
AmountMath.isGTE(bootstrapAmount, expectedAmount), | ||
X`${bootstrapAmount} is not at least ${expectedAmount}`, | ||
); | ||
} | ||
return bootstrapPayment; | ||
}; | ||
return getBootstrapPayment; | ||
}; | ||
|
||
return { | ||
creatorFacet: Far('creator', { | ||
getBootstrapPayment: mintBootstrapPayment(), | ||
}), | ||
}; | ||
}; | ||
harden(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