Skip to content

Commit

Permalink
draft: try makeStoredNotifierKit
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jun 30, 2022
1 parent 1fc2194 commit 662351c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
24 changes: 13 additions & 11 deletions packages/run-protocol/src/vaultFactory/vaultManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
*/
import '@agoric/zoe/exported.js';

import { E } from '@endo/eventual-send';
import { AmountMath } from '@agoric/ertp';
import { Nat } from '@agoric/nat';
import { makeStoredNotifierKit, observeNotifier } from '@agoric/notifier';
import { defineKindMulti, pickFacet } from '@agoric/vat-data';
import {
assertProposalShape,
ceilDivideBy,
Expand All @@ -26,16 +28,13 @@ import {
makeRatio,
makeRatioFromAmounts,
} from '@agoric/zoe/src/contractSupport/index.js';
import { makeNotifierKit, observeNotifier } from '@agoric/notifier';
import { AmountMath } from '@agoric/ertp';

import { defineKindMulti, pickFacet } from '@agoric/vat-data';
import { makeVault, Phase } from './vault.js';
import { makePrioritizedVaults } from './prioritizedVaults.js';
import { liquidate } from './liquidation.js';
import { makeTracer } from '../makeTracer.js';
import { chargeInterest } from '../interest.js';
import { E } from '@endo/eventual-send';
import { checkDebtLimit, makeMetricsPublisherKit } from '../contractSupport.js';
import { chargeInterest } from '../interest.js';
import { makeTracer } from '../makeTracer.js';
import { liquidate } from './liquidation.js';
import { makePrioritizedVaults } from './prioritizedVaults.js';
import { makeVault, Phase } from './vault.js';

const { details: X } = assert;

Expand Down Expand Up @@ -190,7 +189,10 @@ const initState = (
// timestamp of most recent update to interest
const latestInterestUpdate = startTimeStamp;

const { updater: assetUpdater, notifier: assetNotifier } = makeNotifierKit(
/** @type {import('@agoric/notifier').StoredNotifierKit<AssetState>} */
const { updater: assetUpdater, notifier: assetNotifier } =
makeStoredNotifierKit(storageNode, marshaller, 'asset');
assetUpdater.updateState(
harden({
compoundedInterest,
interestRate: fixed.factoryPowers.getGovernedParams().getInterestRate(),
Expand Down
5 changes: 4 additions & 1 deletion packages/run-protocol/test/vaultFactory/test-vaultFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ test('vaultFactory display collateral', async t => {
});
});

test('interest on multiple vaults', async t => {
test.only('interest on multiple vaults', async t => {
const { zoe, aeth, run, rates: defaultRates } = t.context;
const rates = {
...defaultRates,
Expand Down Expand Up @@ -965,8 +965,11 @@ test('interest on multiple vaults', async t => {
await manualTimer.tickN(8);
await eventLoopIteration();

console.log('DEBUG getUpdateSince() on assetNotifier');
const assetUpdate = await E(assetNotifier).getUpdateSince();
console.log('DEBUG getUpdateSince() on aliceNotifier');
const aliceUpdate = await E(aliceNotifier).getUpdateSince();
console.log('DEBUG getUpdateSince() on bobNotifier');
const bobUpdate = await E(bobNotifier).getUpdateSince();

// 160n is initial fee. interest is ~3n/week. compounding is in the noise.
Expand Down

0 comments on commit 662351c

Please sign in to comment.