mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-07 16:34:06 +00:00
Implement data source templates (#106)
* Implement data source templates * Remove optional param from wasm instantiate * Add all types for solidity to typescript mapping * Set contract address in context for data source templates * Implement block handlers for data source templates
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
"asbuild:release": "asc assembly/index.ts --lib ./node_modules --exportRuntime --target release --runPasses asyncify",
|
||||
"asbuild": "yarn asbuild:debug && yarn asbuild:release",
|
||||
"test": "yarn asbuild:debug && DEBUG=vulcanize:* node --experimental-wasm-bigint node_modules/.bin/_mocha src/**/*.test.ts",
|
||||
"build:example": "cd test/subgraph/example1 && yarn && yarn build",
|
||||
"build:example": "cd test/subgraph/example1 && yarn && yarn codegen && yarn build",
|
||||
"watch": "DEBUG=vulcanize:* nodemon --watch src src/watcher.ts",
|
||||
"compare-entity": "node bin/compare-entity"
|
||||
},
|
||||
|
||||
@@ -71,7 +71,10 @@ describe('call handler in mapping code', () => {
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{ block: dummyEventData.block },
|
||||
{
|
||||
block: dummyEventData.block,
|
||||
contractAddress: dummyGraphData.dataSource.address
|
||||
},
|
||||
filePath,
|
||||
dummyGraphData
|
||||
);
|
||||
|
||||
@@ -9,7 +9,7 @@ import { utils } from 'ethers';
|
||||
import { BaseProvider } from '@ethersproject/providers';
|
||||
|
||||
import { instantiate } from './loader';
|
||||
import { getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||
import { Database } from './database';
|
||||
import { Indexer } from '../test/utils/indexer';
|
||||
|
||||
@@ -26,14 +26,18 @@ describe('crypto host api', () => {
|
||||
});
|
||||
|
||||
it('should load the subgraph example wasm', async () => {
|
||||
const dummyGraphData = getDummyGraphData();
|
||||
const filePath = path.resolve(__dirname, '../test/subgraph/example1/build/Example1/Example1.wasm');
|
||||
|
||||
const instance = await instantiate(
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{},
|
||||
filePath
|
||||
filePath,
|
||||
dummyGraphData
|
||||
);
|
||||
|
||||
exports = instance.exports;
|
||||
const { _start } = exports;
|
||||
|
||||
|
||||
@@ -89,7 +89,10 @@ describe('eden wasm loader tests', async () => {
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{ block: dummyEventData.block },
|
||||
{
|
||||
block: dummyEventData.block,
|
||||
contractAddress
|
||||
},
|
||||
filePath,
|
||||
data
|
||||
));
|
||||
@@ -205,7 +208,10 @@ describe('eden wasm loader tests', async () => {
|
||||
({ exports } = await instantiate(db,
|
||||
indexer,
|
||||
provider,
|
||||
{ block: dummyEventData.block },
|
||||
{
|
||||
block: dummyEventData.block,
|
||||
contractAddress
|
||||
},
|
||||
filePath,
|
||||
data
|
||||
));
|
||||
@@ -319,7 +325,10 @@ describe('eden wasm loader tests', async () => {
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{ block: dummyEventData.block },
|
||||
{
|
||||
block: dummyEventData.block,
|
||||
contractAddress
|
||||
},
|
||||
filePath,
|
||||
data
|
||||
));
|
||||
|
||||
@@ -8,7 +8,7 @@ import { expect } from 'chai';
|
||||
import { BaseProvider } from '@ethersproject/providers';
|
||||
|
||||
import { instantiate } from './loader';
|
||||
import { getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||
import { Database } from './database';
|
||||
import { Indexer } from '../test/utils/indexer';
|
||||
|
||||
@@ -26,14 +26,18 @@ describe('ethereum ABI encode decode', () => {
|
||||
});
|
||||
|
||||
it('should load the subgraph example wasm', async () => {
|
||||
const dummyGraphData = getDummyGraphData();
|
||||
const filePath = path.resolve(__dirname, '../test/subgraph/example1/build/Example1/Example1.wasm');
|
||||
|
||||
const instance = await instantiate(
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{},
|
||||
filePath
|
||||
filePath,
|
||||
dummyGraphData
|
||||
);
|
||||
|
||||
exports = instance.exports;
|
||||
const { _start } = exports;
|
||||
|
||||
|
||||
@@ -50,7 +50,10 @@ describe('eth-call wasm tests', () => {
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{ block: dummyEventData.block },
|
||||
{
|
||||
block: dummyEventData.block,
|
||||
contractAddress
|
||||
},
|
||||
filePath,
|
||||
data
|
||||
);
|
||||
|
||||
@@ -7,7 +7,7 @@ import path from 'path';
|
||||
import { BaseProvider } from '@ethersproject/providers';
|
||||
|
||||
import { instantiate } from './loader';
|
||||
import { getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||
import { Database } from './database';
|
||||
import { Indexer } from '../test/utils/indexer';
|
||||
|
||||
@@ -24,14 +24,18 @@ describe('json host api', () => {
|
||||
});
|
||||
|
||||
it('should load the subgraph example wasm', async () => {
|
||||
const dummyGraphData = getDummyGraphData();
|
||||
const filePath = path.resolve(__dirname, '../test/subgraph/example1/build/Example1/Example1.wasm');
|
||||
|
||||
const instance = await instantiate(
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{},
|
||||
filePath
|
||||
filePath,
|
||||
dummyGraphData
|
||||
);
|
||||
|
||||
exports = instance.exports;
|
||||
const { _start } = exports;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { utils } from 'ethers';
|
||||
import { BaseProvider } from '@ethersproject/providers';
|
||||
|
||||
import { instantiate } from './loader';
|
||||
import { getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||
import { Database } from './database';
|
||||
import { Indexer } from '../test/utils/indexer';
|
||||
|
||||
@@ -21,19 +21,23 @@ describe('wasm loader tests', () => {
|
||||
let indexer: Indexer;
|
||||
let provider: BaseProvider;
|
||||
let module: WebAssembly.Module;
|
||||
let dummyGraphData: any;
|
||||
|
||||
before(async () => {
|
||||
db = getTestDatabase();
|
||||
indexer = getTestIndexer();
|
||||
provider = getTestProvider();
|
||||
dummyGraphData = getDummyGraphData();
|
||||
|
||||
const filePath = path.resolve(__dirname, WASM_FILE_PATH);
|
||||
|
||||
const instance = await instantiate(
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{},
|
||||
filePath
|
||||
filePath,
|
||||
dummyGraphData
|
||||
);
|
||||
|
||||
exports = instance.exports;
|
||||
@@ -110,7 +114,8 @@ describe('wasm loader tests', () => {
|
||||
indexer,
|
||||
provider,
|
||||
{},
|
||||
module
|
||||
module,
|
||||
dummyGraphData
|
||||
);
|
||||
|
||||
exports = instance.exports;
|
||||
|
||||
@@ -38,14 +38,14 @@ type idOfType = (TypeId: number) => number
|
||||
|
||||
export interface GraphData {
|
||||
abis?: {[key: string]: ContractInterface};
|
||||
dataSource?: {
|
||||
address: string,
|
||||
dataSource: {
|
||||
network: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface Context {
|
||||
block?: Block
|
||||
contractAddress?: string
|
||||
}
|
||||
|
||||
const log = debug('vulcanize:graph-node');
|
||||
@@ -56,7 +56,7 @@ export const instantiate = async (
|
||||
provider: BaseProvider,
|
||||
context: Context,
|
||||
filePathOrModule: string | WebAssembly.Module,
|
||||
data: GraphData = {}
|
||||
data: GraphData
|
||||
): Promise<loader.ResultObject & { exports: any }> => {
|
||||
const { abis = {}, dataSource } = data;
|
||||
|
||||
@@ -108,8 +108,8 @@ export const instantiate = async (
|
||||
|
||||
// Create an auto-diff.
|
||||
assert(indexer.createDiffStaged);
|
||||
assert(dataSource?.address);
|
||||
await indexer.createDiffStaged(dataSource.address, context.block.blockHash, diffData);
|
||||
assert(context.contractAddress);
|
||||
await indexer.createDiffStaged(context.contractAddress, context.block.blockHash, diffData);
|
||||
},
|
||||
|
||||
'log.log': (level: number, msg: number) => {
|
||||
@@ -203,8 +203,9 @@ export const instantiate = async (
|
||||
const res = await __newArray(arrayEthereumValueId, resultPtrArray);
|
||||
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.log('eth_call error', err);
|
||||
} catch (err: any) {
|
||||
log('eth_call error', err.message);
|
||||
|
||||
return null;
|
||||
}
|
||||
},
|
||||
@@ -608,8 +609,8 @@ export const instantiate = async (
|
||||
},
|
||||
datasource: {
|
||||
'dataSource.address': async () => {
|
||||
assert(dataSource);
|
||||
const addressStringPtr = await __newString(dataSource.address);
|
||||
assert(context.contractAddress);
|
||||
const addressStringPtr = await __newString(context.contractAddress);
|
||||
return Address.fromString(addressStringPtr);
|
||||
},
|
||||
'dataSource.context': async () => {
|
||||
@@ -621,6 +622,15 @@ export const instantiate = async (
|
||||
'dataSource.network': async () => {
|
||||
assert(dataSource);
|
||||
return __newString(dataSource.network);
|
||||
},
|
||||
'dataSource.create': async (name: number, params: number) => {
|
||||
const [addressStringPtr] = __getArray(params);
|
||||
const addressString = __getString(addressStringPtr);
|
||||
const contractKind = __getString(name);
|
||||
|
||||
assert(indexer.watchContract);
|
||||
assert(context.block);
|
||||
await indexer.watchContract(utils.getAddress(addressString), contractKind, true, Number(context.block.blockNumber));
|
||||
}
|
||||
},
|
||||
json: {
|
||||
|
||||
@@ -10,7 +10,7 @@ import { GraphDecimal } from '@vulcanize/util';
|
||||
import { BaseProvider } from '@ethersproject/providers';
|
||||
|
||||
import { instantiate } from './loader';
|
||||
import { getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||
import { Database } from './database';
|
||||
import { Indexer } from '../test/utils/indexer';
|
||||
import {
|
||||
@@ -37,13 +37,16 @@ describe('numbers wasm tests', () => {
|
||||
indexer = getTestIndexer();
|
||||
provider = getTestProvider();
|
||||
|
||||
const dummyGraphData = getDummyGraphData();
|
||||
const filePath = path.resolve(__dirname, EXAMPLE_WASM_FILE_PATH);
|
||||
|
||||
const instance = await instantiate(
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{},
|
||||
filePath
|
||||
filePath,
|
||||
dummyGraphData
|
||||
);
|
||||
exports = instance.exports;
|
||||
const { _start } = exports;
|
||||
|
||||
@@ -9,7 +9,7 @@ import { utils, BigNumber } from 'ethers';
|
||||
import { BaseProvider } from '@ethersproject/providers';
|
||||
|
||||
import { instantiate } from './loader';
|
||||
import { getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||
import { getDummyGraphData, getTestDatabase, getTestIndexer, getTestProvider } from '../test/utils';
|
||||
import { Database } from './database';
|
||||
import { Indexer } from '../test/utils/indexer';
|
||||
|
||||
@@ -26,13 +26,16 @@ describe('typeConversion wasm tests', () => {
|
||||
indexer = getTestIndexer();
|
||||
provider = getTestProvider();
|
||||
|
||||
const dummyGraphData = getDummyGraphData();
|
||||
const filePath = path.resolve(__dirname, EXAMPLE_WASM_FILE_PATH);
|
||||
|
||||
const instance = await instantiate(
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{},
|
||||
filePath
|
||||
filePath,
|
||||
dummyGraphData
|
||||
);
|
||||
exports = instance.exports;
|
||||
const { _start } = exports;
|
||||
|
||||
@@ -47,12 +47,12 @@ export class GraphWatcher {
|
||||
}
|
||||
|
||||
async init () {
|
||||
const { dataSources } = await getSubgraphConfig(this._subgraphPath);
|
||||
this._dataSources = dataSources;
|
||||
const { dataSources, templates = [] } = await getSubgraphConfig(this._subgraphPath);
|
||||
this._dataSources = dataSources.concat(templates);
|
||||
|
||||
// Create wasm instance and contract interface for each dataSource in subgraph yaml.
|
||||
// Create wasm instance and contract interface for each dataSource and template in subgraph yaml.
|
||||
const dataPromises = this._dataSources.map(async (dataSource: any) => {
|
||||
const { source: { address, abi }, mapping, network } = dataSource;
|
||||
const { source: { abi }, mapping, network } = dataSource;
|
||||
const { abis, file } = mapping;
|
||||
|
||||
const abisMap = abis.reduce((acc: {[key: string]: ContractInterface}, abi: any) => {
|
||||
@@ -68,7 +68,6 @@ export class GraphWatcher {
|
||||
const data = {
|
||||
abis: abisMap,
|
||||
dataSource: {
|
||||
address,
|
||||
network
|
||||
}
|
||||
};
|
||||
@@ -94,8 +93,8 @@ export class GraphWatcher {
|
||||
// TODO: Check api version https://github.com/graphprotocol/graph-node/blob/6098daa8955bdfac597cec87080af5449807e874/runtime/wasm/src/module/mod.rs#L533
|
||||
instance.exports._start();
|
||||
|
||||
const { source: { address } } = dataSource;
|
||||
acc[address] = data[index];
|
||||
const { name } = dataSource;
|
||||
acc[name] = data[index];
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
@@ -110,10 +109,13 @@ export class GraphWatcher {
|
||||
for (const dataSource of this._dataSources) {
|
||||
const { source: { address, startBlock }, name } = dataSource;
|
||||
|
||||
const watchedContract = await this._indexer.isWatchedContract(address);
|
||||
// Skip for templates as they are added dynamically.
|
||||
if (address) {
|
||||
const watchedContract = await this._indexer.isWatchedContract(address);
|
||||
|
||||
if (!watchedContract) {
|
||||
await this._indexer.watchContract(address, name, true, startBlock);
|
||||
if (!watchedContract) {
|
||||
await this._indexer.watchContract(address, name, true, startBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,15 +130,21 @@ export class GraphWatcher {
|
||||
const blockData = this._context.block;
|
||||
assert(blockData);
|
||||
|
||||
assert(this._indexer && this._indexer.isWatchedContract);
|
||||
const watchedContract = await this._indexer.isWatchedContract(contract);
|
||||
assert(watchedContract);
|
||||
|
||||
// Get dataSource in subgraph yaml based on contract address.
|
||||
const dataSource = this._dataSources.find(dataSource => dataSource.source.address === contract);
|
||||
const dataSource = this._dataSources.find(dataSource => dataSource.name === watchedContract.kind);
|
||||
|
||||
if (!dataSource) {
|
||||
log(`Subgraph doesnt have configuration for contract ${contract}`);
|
||||
log(`Subgraph doesn't have configuration for contract ${contract}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const { instance, contractInterface } = this._dataSourceMap[contract];
|
||||
this._context.contractAddress = contract;
|
||||
|
||||
const { instance, contractInterface } = this._dataSourceMap[watchedContract.kind];
|
||||
assert(instance);
|
||||
const { exports: instanceExports } = instance;
|
||||
|
||||
@@ -172,7 +180,7 @@ export class GraphWatcher {
|
||||
// Create ethereum event to be passed to the wasm event handler.
|
||||
const ethereumEvent = await createEvent(instanceExports, contract, data);
|
||||
|
||||
await this._handleMemoryError(instanceExports[eventHandler.handler](ethereumEvent), dataSource.source.address);
|
||||
await this._handleMemoryError(instanceExports[eventHandler.handler](ethereumEvent), dataSource.name);
|
||||
}
|
||||
|
||||
async handleBlock (blockHash: string) {
|
||||
@@ -191,27 +199,47 @@ export class GraphWatcher {
|
||||
// https://stackoverflow.com/a/40453962
|
||||
// https://github.com/AssemblyScript/assemblyscript/pull/1268#issue-618411291
|
||||
// https://github.com/WebAssembly/memory64/blob/main/proposals/memory64/Overview.md#motivation
|
||||
await this._reInitWasm(dataSource.source.address);
|
||||
await this._reInitWasm(dataSource.name);
|
||||
}
|
||||
|
||||
// Check if block handler(s) are configured and start block has been reached.
|
||||
if (!dataSource.mapping.blockHandlers || blockData.blockNumber < dataSource.source.startBlock) {
|
||||
// Check if block handler(s) are configured.
|
||||
if (!dataSource.mapping.blockHandlers) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const { instance } = this._dataSourceMap[dataSource.source.address];
|
||||
const { instance } = this._dataSourceMap[dataSource.name];
|
||||
assert(instance);
|
||||
const { exports: instanceExports } = instance;
|
||||
|
||||
// Create ethereum block to be passed to a wasm block handler.
|
||||
const ethereumBlock = await createBlock(instanceExports, blockData);
|
||||
|
||||
// Call all the block handlers one after the another for a contract.
|
||||
const blockHandlerPromises = dataSource.mapping.blockHandlers.map(async (blockHandler: any): Promise<void> => {
|
||||
await instanceExports[blockHandler.handler](ethereumBlock);
|
||||
});
|
||||
let contractAddressList: string[] = [];
|
||||
|
||||
await this._handleMemoryError(Promise.all(blockHandlerPromises), dataSource.source.address);
|
||||
if (dataSource.source.address) {
|
||||
// Check if start block has been reached.
|
||||
if (blockData.blockNumber >= dataSource.source.startBlock) {
|
||||
contractAddressList.push(dataSource.source.address);
|
||||
}
|
||||
} else {
|
||||
// Data source templates will have multiple watched contracts.
|
||||
assert(this._indexer?.getContractsByKind);
|
||||
const watchedContracts = this._indexer.getContractsByKind(dataSource.name);
|
||||
|
||||
contractAddressList = watchedContracts.filter(contract => blockData.blockNumber >= contract.startingBlock)
|
||||
.map(contract => contract.address);
|
||||
}
|
||||
|
||||
for (const contractAddress of contractAddressList) {
|
||||
this._context.contractAddress = contractAddress;
|
||||
|
||||
// Call all the block handlers one after another for a contract.
|
||||
const blockHandlerPromises = dataSource.mapping.blockHandlers.map(async (blockHandler: any): Promise<void> => {
|
||||
await instanceExports[blockHandler.handler](ethereumBlock);
|
||||
});
|
||||
|
||||
await this._handleMemoryError(Promise.all(blockHandlerPromises), dataSource.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,20 +256,20 @@ export class GraphWatcher {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to reinstantiate WASM instance for specified contract address.
|
||||
* @param contractAddress
|
||||
* Method to reinstantiate WASM instance for specified dataSource.
|
||||
* @param dataSourceName
|
||||
*/
|
||||
async _reInitWasm (contractAddress: string): Promise<void> {
|
||||
const { data, instance } = this._dataSourceMap[contractAddress];
|
||||
async _reInitWasm (dataSourceName: string): Promise<void> {
|
||||
const { data, instance } = this._dataSourceMap[dataSourceName];
|
||||
|
||||
assert(instance);
|
||||
const { module } = instance;
|
||||
delete this._dataSourceMap[contractAddress].instance;
|
||||
delete this._dataSourceMap[dataSourceName].instance;
|
||||
|
||||
assert(this._indexer);
|
||||
|
||||
// Reinstantiate with existing module.
|
||||
this._dataSourceMap[contractAddress].instance = await instantiate(
|
||||
this._dataSourceMap[dataSourceName].instance = await instantiate(
|
||||
this._database,
|
||||
this._indexer,
|
||||
this._ethProvider,
|
||||
@@ -252,17 +280,17 @@ export class GraphWatcher {
|
||||
|
||||
// Important to call _start for built subgraphs on instantiation!
|
||||
// TODO: Check api version https://github.com/graphprotocol/graph-node/blob/6098daa8955bdfac597cec87080af5449807e874/runtime/wasm/src/module/mod.rs#L533
|
||||
this._dataSourceMap[contractAddress].instance!.exports._start();
|
||||
this._dataSourceMap[dataSourceName].instance!.exports._start();
|
||||
}
|
||||
|
||||
async _handleMemoryError (handlerPromise: Promise<any>, contractAddress: string): Promise<void> {
|
||||
async _handleMemoryError (handlerPromise: Promise<any>, dataSourceName: string): Promise<void> {
|
||||
try {
|
||||
await handlerPromise;
|
||||
} catch (error) {
|
||||
if (error instanceof WebAssembly.RuntimeError && error instanceof Error) {
|
||||
if (error.message === 'unreachable') {
|
||||
// Reintantiate WASM for out of memory error.
|
||||
this._reInitWasm(contractAddress);
|
||||
this._reInitWasm(dataSourceName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
build/
|
||||
node_modules/
|
||||
generated/
|
||||
|
||||
yarn-error.log
|
||||
@@ -0,0 +1,148 @@
|
||||
[
|
||||
{ "inputs": [], "stateMutability": "nonpayable", "type": "constructor" },
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "uint24",
|
||||
"name": "fee",
|
||||
"type": "uint24"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "int24",
|
||||
"name": "tickSpacing",
|
||||
"type": "int24"
|
||||
}
|
||||
],
|
||||
"name": "FeeAmountEnabled",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "oldOwner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "OwnerChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "token0",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "token1",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "uint24",
|
||||
"name": "fee",
|
||||
"type": "uint24"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "int24",
|
||||
"name": "tickSpacing",
|
||||
"type": "int24"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "pool",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "PoolCreated",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{ "internalType": "address", "name": "tokenA", "type": "address" },
|
||||
{ "internalType": "address", "name": "tokenB", "type": "address" },
|
||||
{ "internalType": "uint24", "name": "fee", "type": "uint24" }
|
||||
],
|
||||
"name": "createPool",
|
||||
"outputs": [
|
||||
{ "internalType": "address", "name": "pool", "type": "address" }
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{ "internalType": "uint24", "name": "fee", "type": "uint24" },
|
||||
{ "internalType": "int24", "name": "tickSpacing", "type": "int24" }
|
||||
],
|
||||
"name": "enableFeeAmount",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [{ "internalType": "uint24", "name": "", "type": "uint24" }],
|
||||
"name": "feeAmountTickSpacing",
|
||||
"outputs": [{ "internalType": "int24", "name": "", "type": "int24" }],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{ "internalType": "address", "name": "", "type": "address" },
|
||||
{ "internalType": "address", "name": "", "type": "address" },
|
||||
{ "internalType": "uint24", "name": "", "type": "uint24" }
|
||||
],
|
||||
"name": "getPool",
|
||||
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "parameters",
|
||||
"outputs": [
|
||||
{ "internalType": "address", "name": "factory", "type": "address" },
|
||||
{ "internalType": "address", "name": "token0", "type": "address" },
|
||||
{ "internalType": "address", "name": "token1", "type": "address" },
|
||||
{ "internalType": "uint24", "name": "fee", "type": "uint24" },
|
||||
{ "internalType": "int24", "name": "tickSpacing", "type": "int24" }
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{ "internalType": "address", "name": "_owner", "type": "address" }
|
||||
],
|
||||
"name": "setOwner",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,988 @@
|
||||
[
|
||||
{
|
||||
"inputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "int24",
|
||||
"name": "tickLower",
|
||||
"type": "int24"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "int24",
|
||||
"name": "tickUpper",
|
||||
"type": "int24"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint128",
|
||||
"name": "amount",
|
||||
"type": "uint128"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount0",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount1",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Burn",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "int24",
|
||||
"name": "tickLower",
|
||||
"type": "int24"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "int24",
|
||||
"name": "tickUpper",
|
||||
"type": "int24"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint128",
|
||||
"name": "amount0",
|
||||
"type": "uint128"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint128",
|
||||
"name": "amount1",
|
||||
"type": "uint128"
|
||||
}
|
||||
],
|
||||
"name": "Collect",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "sender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint128",
|
||||
"name": "amount0",
|
||||
"type": "uint128"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint128",
|
||||
"name": "amount1",
|
||||
"type": "uint128"
|
||||
}
|
||||
],
|
||||
"name": "CollectProtocol",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "sender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount0",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount1",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "paid0",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "paid1",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Flash",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint16",
|
||||
"name": "observationCardinalityNextOld",
|
||||
"type": "uint16"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint16",
|
||||
"name": "observationCardinalityNextNew",
|
||||
"type": "uint16"
|
||||
}
|
||||
],
|
||||
"name": "IncreaseObservationCardinalityNext",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint160",
|
||||
"name": "sqrtPriceX96",
|
||||
"type": "uint160"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "int24",
|
||||
"name": "tick",
|
||||
"type": "int24"
|
||||
}
|
||||
],
|
||||
"name": "Initialize",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "sender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "int24",
|
||||
"name": "tickLower",
|
||||
"type": "int24"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "int24",
|
||||
"name": "tickUpper",
|
||||
"type": "int24"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint128",
|
||||
"name": "amount",
|
||||
"type": "uint128"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount0",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount1",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Mint",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint8",
|
||||
"name": "feeProtocol0Old",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint8",
|
||||
"name": "feeProtocol1Old",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint8",
|
||||
"name": "feeProtocol0New",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint8",
|
||||
"name": "feeProtocol1New",
|
||||
"type": "uint8"
|
||||
}
|
||||
],
|
||||
"name": "SetFeeProtocol",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "sender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "int256",
|
||||
"name": "amount0",
|
||||
"type": "int256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "int256",
|
||||
"name": "amount1",
|
||||
"type": "int256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint160",
|
||||
"name": "sqrtPriceX96",
|
||||
"type": "uint160"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint128",
|
||||
"name": "liquidity",
|
||||
"type": "uint128"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "int24",
|
||||
"name": "tick",
|
||||
"type": "int24"
|
||||
}
|
||||
],
|
||||
"name": "Swap",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "int24",
|
||||
"name": "tickLower",
|
||||
"type": "int24"
|
||||
},
|
||||
{
|
||||
"internalType": "int24",
|
||||
"name": "tickUpper",
|
||||
"type": "int24"
|
||||
},
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "amount",
|
||||
"type": "uint128"
|
||||
}
|
||||
],
|
||||
"name": "burn",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amount0",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amount1",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "int24",
|
||||
"name": "tickLower",
|
||||
"type": "int24"
|
||||
},
|
||||
{
|
||||
"internalType": "int24",
|
||||
"name": "tickUpper",
|
||||
"type": "int24"
|
||||
},
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "amount0Requested",
|
||||
"type": "uint128"
|
||||
},
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "amount1Requested",
|
||||
"type": "uint128"
|
||||
}
|
||||
],
|
||||
"name": "collect",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "amount0",
|
||||
"type": "uint128"
|
||||
},
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "amount1",
|
||||
"type": "uint128"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "amount0Requested",
|
||||
"type": "uint128"
|
||||
},
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "amount1Requested",
|
||||
"type": "uint128"
|
||||
}
|
||||
],
|
||||
"name": "collectProtocol",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "amount0",
|
||||
"type": "uint128"
|
||||
},
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "amount1",
|
||||
"type": "uint128"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "factory",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "fee",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint24",
|
||||
"name": "",
|
||||
"type": "uint24"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "feeGrowthGlobal0X128",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "feeGrowthGlobal1X128",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amount0",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amount1",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "bytes",
|
||||
"name": "data",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "flash",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint16",
|
||||
"name": "observationCardinalityNext",
|
||||
"type": "uint16"
|
||||
}
|
||||
],
|
||||
"name": "increaseObservationCardinalityNext",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint160",
|
||||
"name": "sqrtPriceX96",
|
||||
"type": "uint160"
|
||||
}
|
||||
],
|
||||
"name": "initialize",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "liquidity",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "",
|
||||
"type": "uint128"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "maxLiquidityPerTick",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "",
|
||||
"type": "uint128"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "int24",
|
||||
"name": "tickLower",
|
||||
"type": "int24"
|
||||
},
|
||||
{
|
||||
"internalType": "int24",
|
||||
"name": "tickUpper",
|
||||
"type": "int24"
|
||||
},
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "amount",
|
||||
"type": "uint128"
|
||||
},
|
||||
{
|
||||
"internalType": "bytes",
|
||||
"name": "data",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "mint",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amount0",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amount1",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "index",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "observations",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint32",
|
||||
"name": "blockTimestamp",
|
||||
"type": "uint32"
|
||||
},
|
||||
{
|
||||
"internalType": "int56",
|
||||
"name": "tickCumulative",
|
||||
"type": "int56"
|
||||
},
|
||||
{
|
||||
"internalType": "uint160",
|
||||
"name": "secondsPerLiquidityCumulativeX128",
|
||||
"type": "uint160"
|
||||
},
|
||||
{
|
||||
"internalType": "bool",
|
||||
"name": "initialized",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint32[]",
|
||||
"name": "secondsAgos",
|
||||
"type": "uint32[]"
|
||||
}
|
||||
],
|
||||
"name": "observe",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "int56[]",
|
||||
"name": "tickCumulatives",
|
||||
"type": "int56[]"
|
||||
},
|
||||
{
|
||||
"internalType": "uint160[]",
|
||||
"name": "secondsPerLiquidityCumulativeX128s",
|
||||
"type": "uint160[]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "bytes32",
|
||||
"name": "key",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "positions",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "_liquidity",
|
||||
"type": "uint128"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "feeGrowthInside0LastX128",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "feeGrowthInside1LastX128",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "tokensOwed0",
|
||||
"type": "uint128"
|
||||
},
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "tokensOwed1",
|
||||
"type": "uint128"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "protocolFees",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "token0",
|
||||
"type": "uint128"
|
||||
},
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "token1",
|
||||
"type": "uint128"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint8",
|
||||
"name": "feeProtocol0",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"internalType": "uint8",
|
||||
"name": "feeProtocol1",
|
||||
"type": "uint8"
|
||||
}
|
||||
],
|
||||
"name": "setFeeProtocol",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "slot0",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint160",
|
||||
"name": "sqrtPriceX96",
|
||||
"type": "uint160"
|
||||
},
|
||||
{
|
||||
"internalType": "int24",
|
||||
"name": "tick",
|
||||
"type": "int24"
|
||||
},
|
||||
{
|
||||
"internalType": "uint16",
|
||||
"name": "observationIndex",
|
||||
"type": "uint16"
|
||||
},
|
||||
{
|
||||
"internalType": "uint16",
|
||||
"name": "observationCardinality",
|
||||
"type": "uint16"
|
||||
},
|
||||
{
|
||||
"internalType": "uint16",
|
||||
"name": "observationCardinalityNext",
|
||||
"type": "uint16"
|
||||
},
|
||||
{
|
||||
"internalType": "uint8",
|
||||
"name": "feeProtocol",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"internalType": "bool",
|
||||
"name": "unlocked",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "int24",
|
||||
"name": "tickLower",
|
||||
"type": "int24"
|
||||
},
|
||||
{
|
||||
"internalType": "int24",
|
||||
"name": "tickUpper",
|
||||
"type": "int24"
|
||||
}
|
||||
],
|
||||
"name": "snapshotCumulativesInside",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "int56",
|
||||
"name": "tickCumulativeInside",
|
||||
"type": "int56"
|
||||
},
|
||||
{
|
||||
"internalType": "uint160",
|
||||
"name": "secondsPerLiquidityInsideX128",
|
||||
"type": "uint160"
|
||||
},
|
||||
{
|
||||
"internalType": "uint32",
|
||||
"name": "secondsInside",
|
||||
"type": "uint32"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "bool",
|
||||
"name": "zeroForOne",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"internalType": "int256",
|
||||
"name": "amountSpecified",
|
||||
"type": "int256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint160",
|
||||
"name": "sqrtPriceLimitX96",
|
||||
"type": "uint160"
|
||||
},
|
||||
{
|
||||
"internalType": "bytes",
|
||||
"name": "data",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "swap",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "int256",
|
||||
"name": "amount0",
|
||||
"type": "int256"
|
||||
},
|
||||
{
|
||||
"internalType": "int256",
|
||||
"name": "amount1",
|
||||
"type": "int256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "int16",
|
||||
"name": "wordPosition",
|
||||
"type": "int16"
|
||||
}
|
||||
],
|
||||
"name": "tickBitmap",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "tickSpacing",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "int24",
|
||||
"name": "",
|
||||
"type": "int24"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "int24",
|
||||
"name": "tick",
|
||||
"type": "int24"
|
||||
}
|
||||
],
|
||||
"name": "ticks",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint128",
|
||||
"name": "liquidityGross",
|
||||
"type": "uint128"
|
||||
},
|
||||
{
|
||||
"internalType": "int128",
|
||||
"name": "liquidityNet",
|
||||
"type": "int128"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "feeGrowthOutside0X128",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "feeGrowthOutside1X128",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "int56",
|
||||
"name": "tickCumulativeOutside",
|
||||
"type": "int56"
|
||||
},
|
||||
{
|
||||
"internalType": "uint160",
|
||||
"name": "secondsPerLiquidityOutsideX128",
|
||||
"type": "uint160"
|
||||
},
|
||||
{
|
||||
"internalType": "uint32",
|
||||
"name": "secondsOutside",
|
||||
"type": "uint32"
|
||||
},
|
||||
{
|
||||
"internalType": "bool",
|
||||
"name": "initialized",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "token0",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "token1",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
||||
@@ -1,184 +0,0 @@
|
||||
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|
||||
import {
|
||||
ethereum,
|
||||
JSONValue,
|
||||
TypedMap,
|
||||
Entity,
|
||||
Bytes,
|
||||
Address,
|
||||
BigInt
|
||||
} from "@graphprotocol/graph-ts";
|
||||
|
||||
export class Test extends ethereum.Event {
|
||||
get params(): Test__Params {
|
||||
return new Test__Params(this);
|
||||
}
|
||||
}
|
||||
|
||||
export class Test__Params {
|
||||
_event: Test;
|
||||
|
||||
constructor(event: Test) {
|
||||
this._event = event;
|
||||
}
|
||||
|
||||
get param1(): string {
|
||||
return this._event.parameters[0].value.toString();
|
||||
}
|
||||
|
||||
get param2(): i32 {
|
||||
return this._event.parameters[1].value.toI32();
|
||||
}
|
||||
|
||||
get param3(): BigInt {
|
||||
return this._event.parameters[2].value.toBigInt();
|
||||
}
|
||||
}
|
||||
|
||||
export class Example1__structMethodResultValue0Struct extends ethereum.Tuple {
|
||||
get bidAmount1(): BigInt {
|
||||
return this[0].toBigInt();
|
||||
}
|
||||
|
||||
get bidAmount2(): BigInt {
|
||||
return this[1].toBigInt();
|
||||
}
|
||||
}
|
||||
|
||||
export class Example1 extends ethereum.SmartContract {
|
||||
static bind(address: Address): Example1 {
|
||||
return new Example1("Example1", address);
|
||||
}
|
||||
|
||||
addMethod(bidAmount1: BigInt, bidAmount2: BigInt): BigInt {
|
||||
let result = super.call(
|
||||
"addMethod",
|
||||
"addMethod(uint128,uint128):(uint256)",
|
||||
[
|
||||
ethereum.Value.fromUnsignedBigInt(bidAmount1),
|
||||
ethereum.Value.fromUnsignedBigInt(bidAmount2)
|
||||
]
|
||||
);
|
||||
|
||||
return result[0].toBigInt();
|
||||
}
|
||||
|
||||
try_addMethod(
|
||||
bidAmount1: BigInt,
|
||||
bidAmount2: BigInt
|
||||
): ethereum.CallResult<BigInt> {
|
||||
let result = super.tryCall(
|
||||
"addMethod",
|
||||
"addMethod(uint128,uint128):(uint256)",
|
||||
[
|
||||
ethereum.Value.fromUnsignedBigInt(bidAmount1),
|
||||
ethereum.Value.fromUnsignedBigInt(bidAmount2)
|
||||
]
|
||||
);
|
||||
if (result.reverted) {
|
||||
return new ethereum.CallResult();
|
||||
}
|
||||
let value = result.value;
|
||||
return ethereum.CallResult.fromValue(value[0].toBigInt());
|
||||
}
|
||||
|
||||
emitEvent(): boolean {
|
||||
let result = super.call("emitEvent", "emitEvent():(bool)", []);
|
||||
|
||||
return result[0].toBoolean();
|
||||
}
|
||||
|
||||
try_emitEvent(): ethereum.CallResult<boolean> {
|
||||
let result = super.tryCall("emitEvent", "emitEvent():(bool)", []);
|
||||
if (result.reverted) {
|
||||
return new ethereum.CallResult();
|
||||
}
|
||||
let value = result.value;
|
||||
return ethereum.CallResult.fromValue(value[0].toBoolean());
|
||||
}
|
||||
|
||||
getMethod(): string {
|
||||
let result = super.call("getMethod", "getMethod():(string)", []);
|
||||
|
||||
return result[0].toString();
|
||||
}
|
||||
|
||||
try_getMethod(): ethereum.CallResult<string> {
|
||||
let result = super.tryCall("getMethod", "getMethod():(string)", []);
|
||||
if (result.reverted) {
|
||||
return new ethereum.CallResult();
|
||||
}
|
||||
let value = result.value;
|
||||
return ethereum.CallResult.fromValue(value[0].toString());
|
||||
}
|
||||
|
||||
structMethod(
|
||||
bidAmount1: BigInt,
|
||||
bidAmount2: BigInt
|
||||
): Example1__structMethodResultValue0Struct {
|
||||
let result = super.call(
|
||||
"structMethod",
|
||||
"structMethod(uint128,uint128):((uint128,uint128))",
|
||||
[
|
||||
ethereum.Value.fromUnsignedBigInt(bidAmount1),
|
||||
ethereum.Value.fromUnsignedBigInt(bidAmount2)
|
||||
]
|
||||
);
|
||||
|
||||
return changetype<Example1__structMethodResultValue0Struct>(
|
||||
result[0].toTuple()
|
||||
);
|
||||
}
|
||||
|
||||
try_structMethod(
|
||||
bidAmount1: BigInt,
|
||||
bidAmount2: BigInt
|
||||
): ethereum.CallResult<Example1__structMethodResultValue0Struct> {
|
||||
let result = super.tryCall(
|
||||
"structMethod",
|
||||
"structMethod(uint128,uint128):((uint128,uint128))",
|
||||
[
|
||||
ethereum.Value.fromUnsignedBigInt(bidAmount1),
|
||||
ethereum.Value.fromUnsignedBigInt(bidAmount2)
|
||||
]
|
||||
);
|
||||
if (result.reverted) {
|
||||
return new ethereum.CallResult();
|
||||
}
|
||||
let value = result.value;
|
||||
return ethereum.CallResult.fromValue(
|
||||
changetype<Example1__structMethodResultValue0Struct>(value[0].toTuple())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class EmitEventCall extends ethereum.Call {
|
||||
get inputs(): EmitEventCall__Inputs {
|
||||
return new EmitEventCall__Inputs(this);
|
||||
}
|
||||
|
||||
get outputs(): EmitEventCall__Outputs {
|
||||
return new EmitEventCall__Outputs(this);
|
||||
}
|
||||
}
|
||||
|
||||
export class EmitEventCall__Inputs {
|
||||
_call: EmitEventCall;
|
||||
|
||||
constructor(call: EmitEventCall) {
|
||||
this._call = call;
|
||||
}
|
||||
}
|
||||
|
||||
export class EmitEventCall__Outputs {
|
||||
_call: EmitEventCall;
|
||||
|
||||
constructor(call: EmitEventCall) {
|
||||
this._call = call;
|
||||
}
|
||||
|
||||
get value0(): boolean {
|
||||
return this._call.outputValues[0].value.toBoolean();
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|
||||
// Re-exports
|
||||
import {
|
||||
BigDecimal,
|
||||
BigInt,
|
||||
ethereum,
|
||||
Address,
|
||||
ByteArray,
|
||||
Bytes,
|
||||
Entity,
|
||||
Value,
|
||||
JSONValue,
|
||||
TypedMap,
|
||||
JSONValueKind,
|
||||
Result,
|
||||
Wrapped
|
||||
} from '@graphprotocol/graph-ts';
|
||||
|
||||
// All exports are used in JS host API implementations.
|
||||
|
||||
/**
|
||||
* Class used to create TypedMap<string, JSONValue> instance in json fromBytes host API.
|
||||
*/
|
||||
export class JSONValueTypedMap extends TypedMap<string, JSONValue> {}
|
||||
|
||||
/**
|
||||
* Class used to create JSONValue instances from different value types.
|
||||
* Implementation is based on Value class in graph-ts. https://github.com/graphprotocol/graph-ts/blob/master/common/value.ts#L188
|
||||
*/
|
||||
export class CustomJSONValue extends JSONValue {
|
||||
static fromArray(input: Array<JSONValue>): JSONValue {
|
||||
const jsonValue = new JSONValue();
|
||||
jsonValue.kind = JSONValueKind.ARRAY;
|
||||
jsonValue.data = changetype<u32>(input);
|
||||
return jsonValue;
|
||||
}
|
||||
|
||||
static fromObject(object: TypedMap<string, JSONValue>): JSONValue {
|
||||
const jsonValue = new JSONValue();
|
||||
jsonValue.kind = JSONValueKind.OBJECT;
|
||||
jsonValue.data = changetype<u32>(object);
|
||||
return jsonValue;
|
||||
}
|
||||
|
||||
static fromNumber(n: string): JSONValue {
|
||||
const jsonValue = new JSONValue();
|
||||
jsonValue.kind = JSONValueKind.NUMBER;
|
||||
jsonValue.data = changetype<u32>(n);
|
||||
return jsonValue;
|
||||
}
|
||||
|
||||
static fromBoolean(b: boolean): JSONValue {
|
||||
const jsonValue = new JSONValue();
|
||||
jsonValue.kind = JSONValueKind.BOOL;
|
||||
jsonValue.data = b ? 1 : 0;
|
||||
return jsonValue;
|
||||
}
|
||||
|
||||
static fromString(s: string): JSONValue {
|
||||
const jsonValue = new JSONValue();
|
||||
jsonValue.kind = JSONValueKind.STRING;
|
||||
jsonValue.data = changetype<u32>(s);
|
||||
return jsonValue;
|
||||
}
|
||||
|
||||
static fromNull(): JSONValue {
|
||||
const jsonValue = new JSONValue();
|
||||
jsonValue.kind = JSONValueKind.NULL;
|
||||
return jsonValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class used to create Result instance in json try_fromBytes host API.
|
||||
*/
|
||||
export class JSONResult extends Result<JSONValue, boolean> {
|
||||
constructor (value: JSONValue | null) {
|
||||
super();
|
||||
|
||||
if (value) {
|
||||
this._value = new Wrapped(value);
|
||||
} else {
|
||||
this._error = new Wrapped(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
BigDecimal,
|
||||
BigInt,
|
||||
|
||||
ethereum,
|
||||
Entity,
|
||||
|
||||
Address,
|
||||
ByteArray,
|
||||
Bytes,
|
||||
Value,
|
||||
JSONValue
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
|
||||
import {
|
||||
TypedMap,
|
||||
Entity,
|
||||
Value,
|
||||
ValueKind,
|
||||
store,
|
||||
Address,
|
||||
Bytes,
|
||||
BigInt,
|
||||
BigDecimal
|
||||
} from "@graphprotocol/graph-ts";
|
||||
|
||||
export class Blog extends Entity {
|
||||
constructor(id: string) {
|
||||
super();
|
||||
this.set("id", Value.fromString(id));
|
||||
|
||||
this.set("kind", Value.fromString(""));
|
||||
this.set("isActive", Value.fromBoolean(false));
|
||||
this.set("reviews", Value.fromBigIntArray(new Array(0)));
|
||||
this.set("author", Value.fromString(""));
|
||||
this.set("categories", Value.fromStringArray(new Array(0)));
|
||||
}
|
||||
|
||||
save(): void {
|
||||
let id = this.get("id");
|
||||
assert(id != null, "Cannot save Blog entity without an ID");
|
||||
if (id) {
|
||||
assert(
|
||||
id.kind == ValueKind.STRING,
|
||||
"Cannot save Blog entity with non-string ID. " +
|
||||
'Considering using .toHex() to convert the "id" to a string.'
|
||||
);
|
||||
store.set("Blog", id.toString(), this);
|
||||
}
|
||||
}
|
||||
|
||||
static load(id: string): Blog | null {
|
||||
return changetype<Blog | null>(store.get("Blog", id));
|
||||
}
|
||||
|
||||
get id(): string {
|
||||
let value = this.get("id");
|
||||
return value!.toString();
|
||||
}
|
||||
|
||||
set id(value: string) {
|
||||
this.set("id", Value.fromString(value));
|
||||
}
|
||||
|
||||
get kind(): string {
|
||||
let value = this.get("kind");
|
||||
return value!.toString();
|
||||
}
|
||||
|
||||
set kind(value: string) {
|
||||
this.set("kind", Value.fromString(value));
|
||||
}
|
||||
|
||||
get isActive(): boolean {
|
||||
let value = this.get("isActive");
|
||||
return value!.toBoolean();
|
||||
}
|
||||
|
||||
set isActive(value: boolean) {
|
||||
this.set("isActive", Value.fromBoolean(value));
|
||||
}
|
||||
|
||||
get reviews(): Array<BigInt> {
|
||||
let value = this.get("reviews");
|
||||
return value!.toBigIntArray();
|
||||
}
|
||||
|
||||
set reviews(value: Array<BigInt>) {
|
||||
this.set("reviews", Value.fromBigIntArray(value));
|
||||
}
|
||||
|
||||
get author(): string {
|
||||
let value = this.get("author");
|
||||
return value!.toString();
|
||||
}
|
||||
|
||||
set author(value: string) {
|
||||
this.set("author", Value.fromString(value));
|
||||
}
|
||||
|
||||
get categories(): Array<string> {
|
||||
let value = this.get("categories");
|
||||
return value!.toStringArray();
|
||||
}
|
||||
|
||||
set categories(value: Array<string>) {
|
||||
this.set("categories", Value.fromStringArray(value));
|
||||
}
|
||||
}
|
||||
|
||||
export class Author extends Entity {
|
||||
constructor(id: string) {
|
||||
super();
|
||||
this.set("id", Value.fromString(id));
|
||||
|
||||
this.set("blogCount", Value.fromBigInt(BigInt.zero()));
|
||||
this.set("name", Value.fromString(""));
|
||||
this.set("rating", Value.fromBigDecimal(BigDecimal.zero()));
|
||||
this.set("paramInt", Value.fromI32(0));
|
||||
this.set("paramBigInt", Value.fromBigInt(BigInt.zero()));
|
||||
this.set("paramBytes", Value.fromBytes(Bytes.empty()));
|
||||
}
|
||||
|
||||
save(): void {
|
||||
let id = this.get("id");
|
||||
assert(id != null, "Cannot save Author entity without an ID");
|
||||
if (id) {
|
||||
assert(
|
||||
id.kind == ValueKind.STRING,
|
||||
"Cannot save Author entity with non-string ID. " +
|
||||
'Considering using .toHex() to convert the "id" to a string.'
|
||||
);
|
||||
store.set("Author", id.toString(), this);
|
||||
}
|
||||
}
|
||||
|
||||
static load(id: string): Author | null {
|
||||
return changetype<Author | null>(store.get("Author", id));
|
||||
}
|
||||
|
||||
get id(): string {
|
||||
let value = this.get("id");
|
||||
return value!.toString();
|
||||
}
|
||||
|
||||
set id(value: string) {
|
||||
this.set("id", Value.fromString(value));
|
||||
}
|
||||
|
||||
get blogCount(): BigInt {
|
||||
let value = this.get("blogCount");
|
||||
return value!.toBigInt();
|
||||
}
|
||||
|
||||
set blogCount(value: BigInt) {
|
||||
this.set("blogCount", Value.fromBigInt(value));
|
||||
}
|
||||
|
||||
get name(): string {
|
||||
let value = this.get("name");
|
||||
return value!.toString();
|
||||
}
|
||||
|
||||
set name(value: string) {
|
||||
this.set("name", Value.fromString(value));
|
||||
}
|
||||
|
||||
get rating(): BigDecimal {
|
||||
let value = this.get("rating");
|
||||
return value!.toBigDecimal();
|
||||
}
|
||||
|
||||
set rating(value: BigDecimal) {
|
||||
this.set("rating", Value.fromBigDecimal(value));
|
||||
}
|
||||
|
||||
get paramInt(): i32 {
|
||||
let value = this.get("paramInt");
|
||||
return value!.toI32();
|
||||
}
|
||||
|
||||
set paramInt(value: i32) {
|
||||
this.set("paramInt", Value.fromI32(value));
|
||||
}
|
||||
|
||||
get paramBigInt(): BigInt {
|
||||
let value = this.get("paramBigInt");
|
||||
return value!.toBigInt();
|
||||
}
|
||||
|
||||
set paramBigInt(value: BigInt) {
|
||||
this.set("paramBigInt", Value.fromBigInt(value));
|
||||
}
|
||||
|
||||
get paramBytes(): Bytes {
|
||||
let value = this.get("paramBytes");
|
||||
return value!.toBytes();
|
||||
}
|
||||
|
||||
set paramBytes(value: Bytes) {
|
||||
this.set("paramBytes", Value.fromBytes(value));
|
||||
}
|
||||
|
||||
get blogs(): Array<string> {
|
||||
let value = this.get("blogs");
|
||||
return value!.toStringArray();
|
||||
}
|
||||
|
||||
set blogs(value: Array<string>) {
|
||||
this.set("blogs", Value.fromStringArray(value));
|
||||
}
|
||||
}
|
||||
|
||||
export class Category extends Entity {
|
||||
constructor(id: string) {
|
||||
super();
|
||||
this.set("id", Value.fromString(id));
|
||||
|
||||
this.set("name", Value.fromString(""));
|
||||
this.set("count", Value.fromBigInt(BigInt.zero()));
|
||||
}
|
||||
|
||||
save(): void {
|
||||
let id = this.get("id");
|
||||
assert(id != null, "Cannot save Category entity without an ID");
|
||||
if (id) {
|
||||
assert(
|
||||
id.kind == ValueKind.STRING,
|
||||
"Cannot save Category entity with non-string ID. " +
|
||||
'Considering using .toHex() to convert the "id" to a string.'
|
||||
);
|
||||
store.set("Category", id.toString(), this);
|
||||
}
|
||||
}
|
||||
|
||||
static load(id: string): Category | null {
|
||||
return changetype<Category | null>(store.get("Category", id));
|
||||
}
|
||||
|
||||
get id(): string {
|
||||
let value = this.get("id");
|
||||
return value!.toString();
|
||||
}
|
||||
|
||||
set id(value: string) {
|
||||
this.set("id", Value.fromString(value));
|
||||
}
|
||||
|
||||
get name(): string {
|
||||
let value = this.get("name");
|
||||
return value!.toString();
|
||||
}
|
||||
|
||||
set name(value: string) {
|
||||
this.set("name", Value.fromString(value));
|
||||
}
|
||||
|
||||
get count(): BigInt {
|
||||
let value = this.get("count");
|
||||
return value!.toBigInt();
|
||||
}
|
||||
|
||||
set count(value: BigInt) {
|
||||
this.set("count", Value.fromBigInt(value));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { PoolCreated } from '../../generated/Factory/Factory';
|
||||
import { Pool as PoolTemplate } from '../../generated/templates';
|
||||
import { log } from '@graphprotocol/graph-ts';
|
||||
|
||||
export function handlePoolCreated (event: PoolCreated): void {
|
||||
log.debug('PoolCreated event', []);
|
||||
|
||||
// create the tracked contract based on the template
|
||||
PoolTemplate.create(event.params.pool);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { dataSource, ethereum, log } from '@graphprotocol/graph-ts';
|
||||
|
||||
import { Initialize } from '../../generated/templates/Pool/Pool';
|
||||
|
||||
export function handleInitialize (event: Initialize): void {
|
||||
log.debug('event.address: {}', [event.address.toHexString()]);
|
||||
log.debug('event.params.sqrtPriceX96: {}', [event.params.sqrtPriceX96.toString()]);
|
||||
log.debug('event.params.tick: {}', [event.params.tick.toString()]);
|
||||
}
|
||||
|
||||
export function handleBlock (block: ethereum.Block): void {
|
||||
log.debug('block info: {}', [block.number.toString()]);
|
||||
log.debug('dataSource address: {}', [dataSource.address().toHex()]);
|
||||
}
|
||||
@@ -24,3 +24,44 @@ dataSources:
|
||||
blockHandlers:
|
||||
- handler: handleBlock
|
||||
file: ./src/mapping.ts
|
||||
- kind: ethereum/contract
|
||||
name: Factory
|
||||
network: mainnet
|
||||
source:
|
||||
address: ""
|
||||
abi: Factory
|
||||
startBlock: 100
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.5
|
||||
language: wasm/assemblyscript
|
||||
entities: []
|
||||
abis:
|
||||
- name: Factory
|
||||
file: ./abis/factory.json
|
||||
- name: Pool
|
||||
file: ./abis/pool.json
|
||||
eventHandlers:
|
||||
- event: PoolCreated(indexed address,indexed address,indexed uint24,int24,address)
|
||||
handler: handlePoolCreated
|
||||
file: ./src/factory.ts
|
||||
templates:
|
||||
- kind: ethereum/contract
|
||||
name: Pool
|
||||
network: mainnet
|
||||
source:
|
||||
abi: Pool
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.5
|
||||
language: wasm/assemblyscript
|
||||
entities: []
|
||||
file: ./src/pool.ts
|
||||
abis:
|
||||
- name: Pool
|
||||
file: ./abis/pool.json
|
||||
blockHandlers:
|
||||
- handler: handleBlock
|
||||
eventHandlers:
|
||||
- event: Initialize(uint160,int24)
|
||||
handler: handleInitialize
|
||||
|
||||
Reference in New Issue
Block a user