-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update package scripts and enhance queries for interest rates calcula…
…tion Removed the "tsc" and "watch" scripts from the scripts section of various package.json files and added new "dev" scripts for development mode. Improved the GraphQL query in MorphoBlueSubgraph for fetching the interest rates by introducing pagination logic. Enhanced the 'get-apy-function' to calculate APY for various time periods and include a detailed breakdown.
- Loading branch information
1 parent
26b19f7
commit f7113d2
Showing
34 changed files
with
350 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
/** @type {import("eslint").Linter.Config} */ | ||
module.exports = { | ||
root: true, | ||
ignorePatterns: ['src/types/graphql/**'], | ||
ignorePatterns: ['src/types/graphql/**', 'jest.config.js'], | ||
extends: ['@summerfi/eslint-config/library.cjs'], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: true, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const { pathsToModuleNameMapper } = require('ts-jest') | ||
|
||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
roots: ['<rootDir>/src'], | ||
testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'], | ||
silent: true, | ||
maxWorkers: 1, | ||
testTimeout: 10000, | ||
testEnvironment: 'node', | ||
setupFilesAfterEnv: ['jest-expect-message'], | ||
testPathIgnorePatterns: ['dist', 'node_modules'], | ||
moduleNameMapper: pathsToModuleNameMapper({ | ||
'@summerfi/serverless-shared': ['<rootDir>/../../packages/serverless-shared/src/index.ts'], | ||
'@summerfi/serverless-shared/*': ['<rootDir>/../../packages/serverless-shared/src/*'], | ||
'@summerfi/triggers-shared': ['<rootDir>/../../packages/triggers-shared/src/index.ts'], | ||
}), | ||
transform: { | ||
'^.+\\.(ts|tsx)$': [ | ||
'ts-jest', | ||
{ | ||
tsconfig: '<rootDir>/tsconfig.test.json', | ||
}, | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { getMorphoBlueSubgraphClient, MorphoBlueSubgraphClient } from '.' | ||
import { Logger } from '@aws-lambda-powertools/logger' | ||
import { ChainId } from '@summerfi/serverless-shared' | ||
|
||
const logger = new Logger({ | ||
serviceName: 'moorpho-blue-subgraph-tests', | ||
environment: 'dev', | ||
logLevel: 'debug', | ||
}) | ||
|
||
function getTimestampInSeconds(unixTimestamp: number): number { | ||
return Math.floor(unixTimestamp / 1000) | ||
} | ||
|
||
describe.skip('Exploration test MorphoBlue InterestRates', () => { | ||
let client: MorphoBlueSubgraphClient | ||
const wstETH_ETH_marketId: `0x${string}` = | ||
'0xd0e50cdac92fe2172043f5e0c36532c6369d24947e40968f34a5e8819ca9ec5d' | ||
const fromTimestamp_2024_04_01 = getTimestampInSeconds(new Date().setFullYear(2024, 3, 1)) | ||
const toTimestamp_2024_04_15 = getTimestampInSeconds(new Date().setFullYear(2024, 3, 15)) | ||
|
||
beforeAll(() => { | ||
client = getMorphoBlueSubgraphClient({ | ||
chainId: ChainId.MAINNET, | ||
urlBase: '', // set your urlBase here | ||
logger, | ||
}) | ||
}) | ||
it('should return arrays of interest rates', async () => { | ||
logger.debug('Fetching interest rates', { | ||
marketId: wstETH_ETH_marketId, | ||
fromTimestamp: fromTimestamp_2024_04_01, | ||
toTimestamp: toTimestamp_2024_04_15, | ||
}) | ||
|
||
const result = await client.getInterestRate({ | ||
marketId: wstETH_ETH_marketId, | ||
fromTimestamp: fromTimestamp_2024_04_01, | ||
toTimestamp: toTimestamp_2024_04_15, | ||
}) | ||
|
||
expect(result.debtToken.symbol).toBe('WETH') | ||
expect(result.collateralToken.symbol).toBe('wstETH') | ||
|
||
expect(result.interestRates.borrow[0].fromTimestamp).toBe(fromTimestamp_2024_04_01) | ||
}) | ||
}) |
Oops, something went wrong.