Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
feat: Extract uniswap-v2 to Studio (#218)
Browse files Browse the repository at this point in the history
* feat: Extract Uniswap-V2 to Studio

* fix: updated uniswap-v2 dependencies

* chore: splitted past,present and final query logic from gql request
  • Loading branch information
wpoulin authored Apr 22, 2022
1 parent 3f4da77 commit 8c2bbec
Show file tree
Hide file tree
Showing 20 changed files with 3,390 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/app-toolkit/helpers/the-graph/the-graph.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,25 @@ type RequestParams = {
headers?: Record<string, string>;
};

type RequestGraphParams = {
endpoint: string;
query: string | { present: string; past: string };
variables?: Variables;
headers?: Record<string, string>;
};

@Injectable()
export class TheGraphHelper {
async request<T>({ endpoint, query, variables, headers }: RequestParams) {
const client = new GraphQLClient(endpoint, { headers });
return client.request<T>(query, variables);
}

async requestGraph<T>({ endpoint, query, variables = {} }: RequestGraphParams) {
const presentQuery = typeof query === 'string' ? query : query.present;
const pastQuery = typeof query === 'string' ? null : query.past;
const finalQuery = typeof variables.blockTag === 'number' && pastQuery ? pastQuery : presentQuery;

return this.request<T>({ endpoint, query: finalQuery, variables });
}
}
97 changes: 97 additions & 0 deletions src/apps/uniswap-v2/contracts/abis/uniswap-factory.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
[
{
"inputs": [{ "internalType": "address", "name": "_feeToSetter", "type": "address" }],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "token0", "type": "address" },
{ "indexed": true, "internalType": "address", "name": "token1", "type": "address" },
{ "indexed": false, "internalType": "address", "name": "pair", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "", "type": "uint256" }
],
"name": "PairCreated",
"type": "event"
},
{
"constant": true,
"inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"name": "allPairs",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "allPairsLength",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{ "internalType": "address", "name": "tokenA", "type": "address" },
{ "internalType": "address", "name": "tokenB", "type": "address" }
],
"name": "createPair",
"outputs": [{ "internalType": "address", "name": "pair", "type": "address" }],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "feeTo",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "feeToSetter",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "address", "name": "", "type": "address" }
],
"name": "getPair",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [{ "internalType": "address", "name": "_feeTo", "type": "address" }],
"name": "setFeeTo",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [{ "internalType": "address", "name": "_feeToSetter", "type": "address" }],
"name": "setFeeToSetter",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
]
Loading

0 comments on commit 8c2bbec

Please sign in to comment.