Skip to content

Commit 06c7708

Browse files
authored
Merge branch 'main' into 43-fix-qt-value
2 parents b1ef4ea + 6af237d commit 06c7708

File tree

3 files changed

+9
-29
lines changed

3 files changed

+9
-29
lines changed

src/keeper.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,19 +268,24 @@ async function verifyBufferTarget(target: bigint): Promise<void> {
268268
// ============= Data Fetching =============
269269

270270
export async function _getKeeperData(): Promise<KeeperRunData> {
271-
const [buckets, bufferTotal, lup, htp, price, bufferTarget] = await Promise.all([
271+
const [initialBuckets, bufferTotal, lup, htp, price] = await Promise.all([
272272
getBuckets(),
273273
getBufferTotal(),
274274
getLup(),
275275
getHtp(),
276276
getPrice(),
277-
_calculateBufferTarget(),
278277
]);
279278

280-
const [lupIndex, htpIndex, optimalBucket] = await Promise.all([
279+
for (let i = 0; i < initialBuckets.length; i++) {
280+
await drain(initialBuckets[i]);
281+
}
282+
283+
const [lupIndex, htpIndex, optimalBucket, buckets, bufferTarget] = await Promise.all([
281284
getPriceToIndex(lup),
282285
getPriceToIndex(htp),
283286
_calculateOptimalBucket(price),
287+
getBuckets(),
288+
_calculateBufferTarget(),
284289
]);
285290

286291
return {

test/helpers/vaultHelpers.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { contract } from '../../src/utils/contract.ts';
22
import type { Address } from 'viem';
33

4-
const buffer = contract('buffer');
54
const vaultAuth = contract('vaultAuth');
65
const chronicle = contract('chronicle');
76
const poolInfoUtils = contract('poolInfoUtils');
@@ -11,8 +10,6 @@ const pool = contract('pool');
1110
export const setBufferRatio = (ratio: bigint) => vaultAuth().write.setBufferRatio([ratio]);
1211
export const setMinBucketIndex = (index: bigint) => vaultAuth().write.setMinBucketIndex([index]);
1312

14-
export const addToBuffer = (amount: bigint) => buffer().write.addToBuffer(amount);
15-
1613
export const setPaused = (status: boolean) => vault().write.setPaused(status);
1714

1815
const _setPrice = (price: bigint) => chronicle().write.setPrice(price);

test/integration/keeperSuccess.test.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect, beforeEach, beforeAll, afterAll } from 'vitest';
2-
import { addToBuffer, setBufferRatio, setMockState, useMocks } from '../helpers/vaultHelpers';
2+
import { setBufferRatio, setMockState, useMocks } from '../helpers/vaultHelpers';
33
import { getPrice } from '../../src/oracle/price';
44
import { getIndexToPrice } from '../../src/ajna/poolInfoUtils';
55
import { _calculateBufferTarget, run } from '../../src/keeper';
@@ -101,26 +101,4 @@ describe('keeper run success', () => {
101101
expectedMoveAmount - expectedBufferBalance,
102102
);
103103
});
104-
105-
it('moves buffer surplus into optimal bucket', async () => {
106-
await setBufferRatio(5000n);
107-
const bufferTarget = await _calculateBufferTarget();
108-
const expectedMoveAmount = 12n * 100000000000000000000n;
109-
110-
await addToBuffer(2n * bufferTarget);
111-
112-
const bufferTotalBefore = await getBufferTotal();
113-
const optimalBucketBalanceBefore = await lpToValue(4157n);
114-
115-
await run();
116-
117-
const bufferTotalAfter = await getBufferTotal();
118-
const optimalBucketBalanceAfter = await lpToValue(4157n);
119-
120-
expect(bufferTotalBefore).toBe(2n * bufferTarget);
121-
expect(bufferTotalAfter).toBe(bufferTarget);
122-
expect(optimalBucketBalanceAfter - optimalBucketBalanceBefore).toBe(
123-
bufferTarget + expectedMoveAmount,
124-
);
125-
});
126104
});

0 commit comments

Comments
 (0)