Skip to content

Commit

Permalink
refactor: rename fake trades
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Nov 6, 2020
1 parent 4dea2f1 commit d32f416
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions packages/cosmic-swingset/lib/ag-solo/vats/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function buildRootObject(vatPowers, vatParameters) {
* @property {Array<any>} [issuerArgs]
* @property {string} pursePetname
* @property {number} mintValue
* @property {Array<[number, number]>} tradesGivenCentral
* @property {Array<[number, number]>} [fakeTradesGivenCentral]
*/
/** @type {Map<string, IssuerRecord>} */
const issuerNameToRecord = new Map(
Expand All @@ -75,7 +75,7 @@ export function buildRootObject(vatPowers, vatParameters) {
issuerArgs: [undefined, { decimalPlaces: 3 }],
mintValue: 20000,
pursePetname: 'Local currency',
tradesGivenCentral: [[1, 1]],
fakeTradesGivenCentral: [[1, 1]],
},
],
[
Expand All @@ -84,7 +84,7 @@ export function buildRootObject(vatPowers, vatParameters) {
issuerArgs: [undefined, { decimalPlaces: 6 }],
mintValue: 7 * 10 ** 6,
pursePetname: 'Oracle fee',
tradesGivenCentral: [
fakeTradesGivenCentral: [
[1000, 3000000],
[1000, 2500000],
[1000, 2750000],
Expand All @@ -96,7 +96,7 @@ export function buildRootObject(vatPowers, vatParameters) {
{
mintValue: 1900,
pursePetname: 'Fun budget',
tradesGivenCentral: [
fakeTradesGivenCentral: [
[10, 1],
[13, 1],
[12, 1],
Expand All @@ -110,7 +110,7 @@ export function buildRootObject(vatPowers, vatParameters) {
{
mintValue: 1900,
pursePetname: 'Nest egg',
tradesGivenCentral: [
fakeTradesGivenCentral: [
[2135, 50],
[2172, 50],
[2124, 50],
Expand Down Expand Up @@ -165,17 +165,22 @@ export function buildRootObject(vatPowers, vatParameters) {
// Create priceAuthority pairs for centralIssuerIndex based on the
// FakePriceAuthority.
console.debug(`Creating ${issuerNames[i]}-${CENTRAL_ISSUER_NAME}`);
const { tradesGivenCentral } = issuerNameToRecord.get(issuerNames[i]);
const tradesGivenOther =
const { fakeTradesGivenCentral } = issuerNameToRecord.get(
issuerNames[i],
);
if (!fakeTradesGivenCentral) {
return;
}
const fakeTradesGivenOther =
centralIssuer !== issuer &&
tradesGivenCentral.map(([valueCentral, valueOther]) => [
fakeTradesGivenCentral.map(([valueCentral, valueOther]) => [
valueOther,
valueCentral,
]);
await Promise.all([
makeFakePriceAuthority(centralIssuer, issuer, tradesGivenCentral),
tradesGivenOther &&
makeFakePriceAuthority(issuer, centralIssuer, tradesGivenOther),
makeFakePriceAuthority(centralIssuer, issuer, fakeTradesGivenCentral),
fakeTradesGivenOther &&
makeFakePriceAuthority(issuer, centralIssuer, fakeTradesGivenOther),
]);
}),
);
Expand Down

0 comments on commit d32f416

Please sign in to comment.