From dff0dcfbaa93dc9448cb93a55c006f1081eb35b3 Mon Sep 17 00:00:00 2001 From: gs8nrv <55771972+GuillaumeNervoXS@users.noreply.github.com> Date: Tue, 23 Apr 2024 11:59:40 +0200 Subject: [PATCH] fix all tests --- .../angle-staked-stable-events.test.ts | 3 +- .../angle-staked-stable-integration.test.ts | 14 ++++---- .../angle-staked-stable-pool.ts | 33 ++++++++++++++----- .../angle-staked-stable.ts | 2 ++ 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/dex/angle-staked-stable/angle-staked-stable-events.test.ts b/src/dex/angle-staked-stable/angle-staked-stable-events.test.ts index 30381effe..1e4a485a8 100644 --- a/src/dex/angle-staked-stable/angle-staked-stable-events.test.ts +++ b/src/dex/angle-staked-stable/angle-staked-stable-events.test.ts @@ -90,8 +90,9 @@ describe('AngleStakedStable EventPool Mainnet', () => { dexKey, network, dexHelper, + AngleStakedStableConfig[dexKey][network].stEUR, + AngleStakedStableConfig[dexKey][network].EURA, logger, - AngleStakedStableConfig[dexKey][network], ); }); diff --git a/src/dex/angle-staked-stable/angle-staked-stable-integration.test.ts b/src/dex/angle-staked-stable/angle-staked-stable-integration.test.ts index 4d4aa7ee7..3575ad871 100644 --- a/src/dex/angle-staked-stable/angle-staked-stable-integration.test.ts +++ b/src/dex/angle-staked-stable/angle-staked-stable-integration.test.ts @@ -82,12 +82,14 @@ async function checkOnChainPricing( ); // No exact computation because of the bigInt approx - // for (let i = 0; i < expectedPrices.length; ++i) { - // expect(prices[i]).toBeGreaterThanOrEqual(expectedPrices[i] - 1n); - // expect(prices[i]).toBeLessThanOrEqual(expectedPrices[i] + 1n); - // } - - expect(prices).toEqual(expectedPrices); + for (let i = 0; i < expectedPrices.length; ++i) { + expect(prices[i]).toBeGreaterThanOrEqual( + (expectedPrices[i] * 99999n) / 100000n, + ); + expect(prices[i]).toBeLessThanOrEqual( + (expectedPrices[i] * 100001n) / 100000n, + ); + } } async function testPricingOnNetwork( diff --git a/src/dex/angle-staked-stable/angle-staked-stable-pool.ts b/src/dex/angle-staked-stable/angle-staked-stable-pool.ts index bae13a934..fcdfd1733 100644 --- a/src/dex/angle-staked-stable/angle-staked-stable-pool.ts +++ b/src/dex/angle-staked-stable/angle-staked-stable-pool.ts @@ -10,6 +10,7 @@ import { StatefulEventSubscriber } from '../../stateful-event-subscriber'; import type { IDexHelper } from '../../dex-helper/idex-helper'; import type { DexParams, PoolState } from './types'; import StakedStableABI from '../../abi/angle/stagToken.json'; +import ERC20ABI from '../../abi/erc20.json'; export class AngleStakedStableEventPool extends StatefulEventSubscriber { handlers: { @@ -22,6 +23,7 @@ export class AngleStakedStableEventPool extends StatefulEventSubscriber any; @@ -36,6 +38,7 @@ export class AngleStakedStableEventPool extends StatefulEventSubscriber 0) return amount; + if (exp === 0n || rate === 0n) return amount; const expMinusOne = exp - 1n; const expMinusTwo = exp > 2n ? exp - 2n : 0n; const basePowerTwo = (rate * rate + this.HALF_BASE_27) / this.BASE_27; @@ -236,7 +253,7 @@ export class AngleStakedStableEventPool extends StatefulEventSubscriber, blockHeader: BlockHeader, ): DeepReadonly | null { - state.lastUpdate = bigIntify(blockHeader.timestamp); + state.rate = bigIntify(event.args.newRate); return state; } diff --git a/src/dex/angle-staked-stable/angle-staked-stable.ts b/src/dex/angle-staked-stable/angle-staked-stable.ts index e7ba3c289..8805c217b 100644 --- a/src/dex/angle-staked-stable/angle-staked-stable.ts +++ b/src/dex/angle-staked-stable/angle-staked-stable.ts @@ -70,6 +70,7 @@ export class AngleStakedStable this.network, this.dexHelper, this.config.stEUR, + this.config.EURA, this.logger, ); await this.eventPools[this.config.stEUR].initialize(blockNumber); @@ -79,6 +80,7 @@ export class AngleStakedStable this.network, this.dexHelper, this.config.stUSD, + this.config.USDA, this.logger, ); await this.eventPools[this.config.stUSD].initialize(blockNumber);