-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c951b6f
commit dc4612b
Showing
10 changed files
with
193 additions
and
11 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
File renamed without changes.
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,56 @@ | ||
import { | ||
GetUserScoreSnapshotParams, | ||
GetUserScoreSnapshotResponse, | ||
SentioApiParams, | ||
} from "src/interface"; | ||
import { Fetch } from "src/utils/Fetch"; | ||
|
||
interface sqlQueryParams { | ||
sqlQuery: { | ||
sql: string; | ||
size: number; | ||
}; | ||
} | ||
|
||
export class SentioQuery extends Fetch { | ||
private apiKey: string; | ||
|
||
constructor({ url, apiKey }: SentioApiParams) { | ||
super(url); | ||
this.apiKey = apiKey; | ||
} | ||
|
||
async getUserScoreSnapshotQuery({ | ||
userAddress, | ||
blockDate, | ||
}: GetUserScoreSnapshotParams): Promise<GetUserScoreSnapshotResponse> { | ||
const sqlQuery: sqlQueryParams = { | ||
sqlQuery: { | ||
sql: `SELECT total_value_locked_score, tradeVolume, block_date FROM UserScoreSnapshot_raw WHERE user_address = '${userAddress}' AND timestamp > '${blockDate}' ORDER BY timestamp;`, | ||
size: 1000, | ||
}, | ||
}; | ||
const headers: Record<string, string> = { | ||
"api-key": this.apiKey, | ||
}; | ||
return await this.post<GetUserScoreSnapshotResponse>( | ||
sqlQuery, | ||
"same-origin", | ||
headers, | ||
); | ||
} | ||
} | ||
|
||
export const getUserScoreSnapshotQuery = async ({ | ||
userAddress, | ||
blockDate, | ||
url, | ||
apiKey, | ||
}: GetUserScoreSnapshotParams & | ||
SentioApiParams): Promise<GetUserScoreSnapshotResponse> => { | ||
const sentioQuery = new SentioQuery({ url, apiKey }); | ||
return await sentioQuery.getUserScoreSnapshotQuery({ | ||
userAddress, | ||
blockDate, | ||
}); | ||
}; |
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,21 @@ | ||
import { getUserScoreSnapshotQuery } from "./query/sentioQuery"; | ||
import { GetUserScoreSnapshotParams, SentioApiParams } from "./interface"; | ||
|
||
export class SentioApi { | ||
private url: string; | ||
private apiKey: string; | ||
|
||
constructor({ url, apiKey }: SentioApiParams) { | ||
this.url = url; | ||
this.apiKey = apiKey; | ||
} | ||
|
||
getUserScoreSnapshot = (params: GetUserScoreSnapshotParams) => { | ||
return getUserScoreSnapshotQuery({ | ||
userAddress: params.userAddress, | ||
blockDate: params.blockDate, | ||
url: this.url, | ||
apiKey: this.apiKey, | ||
}); | ||
}; | ||
} |
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