Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

chore: update to latest ERTP #26

Merged
merged 1 commit into from
Nov 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/src/priceAuthority/linear.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import '@agoric/zoe/exported';
* Create a price authority which uses linear-scaled latest quotes from the
* underlying quote stream to answer queries.
*
* So, if the quote stream produces `[moola(2), simolean(3)]`, and the caller
* asks what it would get if it sold `moola(6)`, then we'll return
* `simoleans(4)`.
* So, if the quote stream produces `[moola(2n), simolean(3n)]`, and the caller
* asks what it would get if it sold `moola(6n)`, then we'll return
* `simoleans(4n)`.
*
* @param {BasePriceAuthorityOptions} options
* @returns {Promise<PriceAuthority>}
Expand Down
19 changes: 11 additions & 8 deletions api/src/priceAuthority/single.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,17 @@ export async function makeSinglePriceAuthority(options) {
* @returns {PriceQuote}
*/
const makeQuote = (amountIn, amountOut, quoteTime) => {
const quoteAmount = AmountMath.make(quoteBrand, [
{
amountIn,
amountOut,
timer,
timestamp: quoteTime,
},
]);
const quoteAmount = AmountMath.make(
quoteBrand,
harden([
{
amountIn,
amountOut,
timer,
timestamp: quoteTime,
},
]),
);
const quote = harden({
quotePayment: E(quoteMint).mintPayment(quoteAmount),
quoteAmount,
Expand Down
22 changes: 11 additions & 11 deletions api/test/test-fakePriceAuthority.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ test('priceAuthority quoteAtTime', async t => {
});

const done = E(priceAuthority)
.quoteAtTime(3n, moola(5), bucksBrand)
.quoteAtTime(3n, moola(5n), bucksBrand)
.then(async quote => {
t.deepEqual(
moola(5),
moola(5n),
quote.quoteAmount.value[0].amountIn,
'amountIn match',
);
t.deepEqual(bucks(55 * 5), quote.quoteAmount.value[0].amountOut);
t.deepEqual(bucks(55n * 5n), quote.quoteAmount.value[0].amountOut);
t.is(3n, quote.quoteAmount.value[0].timestamp);
});

Expand All @@ -66,7 +66,7 @@ test('priceAuthority quoteGiven', async t => {
});

await E(manualTimer).tick();
const quote = await E(priceAuthority).quoteGiven(moola(37), bucksBrand);
const quote = await E(priceAuthority).quoteGiven(moola(37n), bucksBrand);
const quoteAmount = quote.quoteAmount.value[0];
t.is(1n, quoteAmount.timestamp);
t.deepEqual(bucks(37n * 20n), quoteAmount.amountOut);
Expand All @@ -83,7 +83,7 @@ test('priceAuthority quoteWanted', async t => {
});

await E(manualTimer).tick();
const quote = await E(priceAuthority).quoteWanted(moolaBrand, bucks(400));
const quote = await E(priceAuthority).quoteWanted(moolaBrand, bucks(400n));
const quoteAmount = quote.quoteAmount.value[0];
t.is(1n, quoteAmount.timestamp);
t.deepEqual(bucks(400n), quoteAmount.amountOut);
Expand Down Expand Up @@ -129,13 +129,13 @@ test('priceAuthority quoteWhenGTE', async t => {
});

const expected = E(priceAuthority)
.quoteWhenGTE(moola(1), bucks(40))
.quoteWhenGTE(moola(1n), bucks(40n))
.then(quote => {
const quoteInAmount = quote.quoteAmount.value[0];
t.is(4n, manualTimer.getCurrentTimestamp());
t.is(4n, quoteInAmount.timestamp);
t.deepEqual(bucks(40), quoteInAmount.amountOut);
t.deepEqual(moola(1), quoteInAmount.amountIn);
t.deepEqual(bucks(40n), quoteInAmount.amountOut);
t.deepEqual(moola(1n), quoteInAmount.amountIn);
});

await E(manualTimer).tick();
Expand All @@ -155,13 +155,13 @@ test('priceAuthority quoteWhenLT', async t => {
});

const expected = E(priceAuthority)
.quoteWhenLT(moola(1), bucks(30))
.quoteWhenLT(moola(1n), bucks(30n))
.then(quote => {
const quoteInAmount = quote.quoteAmount.value[0];
t.is(3n, manualTimer.getCurrentTimestamp());
t.is(3n, quoteInAmount.timestamp);
t.deepEqual(bucks(29), quoteInAmount.amountOut);
t.deepEqual(moola(1), quoteInAmount.amountIn);
t.deepEqual(bucks(29n), quoteInAmount.amountOut);
t.deepEqual(moola(1n), quoteInAmount.amountIn);
});

await E(manualTimer).tick();
Expand Down