@@ -34,7 +34,13 @@ import {
34
34
} from '../supports.js' ;
35
35
import { unsafeMakeBundleCache } from '../bundleTool.js' ;
36
36
37
- /** @type {import('ava').TestInterface<any> } */
37
+ /** @typedef {Record<string, any> & {
38
+ * aethKit: IssuerKit,
39
+ * reserveCreatorFacet: AssetReserveCreatorFacet,
40
+ * runKit: IssuerKit,
41
+ * }} Context */
42
+ /** @type {import('ava').TestInterface<Context> } */
43
+ // @ts -expect-error cast
38
44
const test = unknownTest ;
39
45
40
46
// #region Support
@@ -45,6 +51,7 @@ const contractRoots = {
45
51
liquidate : './src/vaultFactory/liquidateIncrementally.js' ,
46
52
VaultFactory : './src/vaultFactory/vaultFactory.js' ,
47
53
amm : './src/vpool-xyk-amm/multipoolMarketMaker.js' ,
54
+ reserve : './src/reserve/assetReserve.js' ,
48
55
} ;
49
56
50
57
/** @typedef {import('../../src/vaultFactory/vaultFactory').VaultFactoryContract } VFC */
@@ -285,6 +292,7 @@ const setupServices = async (
285
292
iProduce . reserve . resolve ( t . context . installation . reserve ) ;
286
293
// produce the reserve instance in the space
287
294
await setupReserve ( space ) ;
295
+ t . context . reserveCreatorFacet = space . consume . reserveCreatorFacet ;
288
296
iProduce . VaultFactory . resolve ( t . context . installation . VaultFactory ) ;
289
297
iProduce . liquidate . resolve ( t . context . installation . liquidate ) ;
290
298
await startVaultFactory ( space , { loanParams : loanTiming } , minInitialDebt ) ;
@@ -818,3 +826,30 @@ test('amm stopAfter - want too much', async t => {
818
826
Out : expectedRUN ,
819
827
} ) ;
820
828
} ) ;
829
+
830
+ test ( 'penalties to reserve' , async t => {
831
+ const {
832
+ aethKit : { brand : aethBrand } ,
833
+ runKit : { brand : runBrand } ,
834
+ } = t . context ;
835
+
836
+ const d = await makeDriver (
837
+ t ,
838
+ AmountMath . make ( runBrand , 1000n ) ,
839
+ AmountMath . make ( aethBrand , 900n ) ,
840
+ ) ;
841
+ // Create a loan for 270 RUN with 400 aeth collateral
842
+ const collateralAmount = AmountMath . make ( aethBrand , 400n ) ;
843
+ const loanAmount = AmountMath . make ( runBrand , 270n ) ;
844
+ await d . makeVaultDriver ( collateralAmount , loanAmount ) ;
845
+
846
+ // liquidate
847
+ d . setPrice ( AmountMath . make ( runBrand , 636n ) ) ;
848
+ await waitForPromisesToSettle ( ) ;
849
+
850
+ const { reserveCreatorFacet } = t . context ;
851
+ const reserveAllocations = await E ( reserveCreatorFacet ) . getAllocations ( ) ;
852
+ t . deepEqual ( reserveAllocations , {
853
+ RUN : { brand : runBrand , value : 29n } ,
854
+ } ) ;
855
+ } ) ;
0 commit comments