diff --git a/projects/cetus/src/processor.ts b/projects/cetus/src/processor.ts index fa831a27..06d6d330 100644 --- a/projects/cetus/src/processor.ts +++ b/projects/cetus/src/processor.ts @@ -9,7 +9,7 @@ import * as helper from './helper/cetus-clmm.js' factory.bind({ // address: constant.CLMM_MAINNET, // network: SuiNetwork.MAIN_NET, - startCheckpoint: 1500000n + // startCheckpoint: 1500000n }) .onEventCreatePoolEvent(async (event, ctx) => { ctx.meter.Counter("create_pool_counter").add(1, { project: "cetus" }) @@ -39,7 +39,7 @@ factory.bind({ pool.bind({ // address: constant.CLMM_MAINNET, // network: SuiNetwork.MAIN_NET, - startCheckpoint: 10926530n + // startCheckpoint: 10926530n }) .onEventSwapEvent(async (event, ctx) => { ctx.meter.Counter("swap_counter").add(1, { project: "cetus" }) @@ -238,7 +238,7 @@ const template = new SuiObjectProcessorTemplate() catch (e) { console.log(`${e.message} error at ${JSON.stringify(self)}`) } - }, 10, 60, undefined, { owned: false }) + }, 10, 1440, undefined, { owned: false }) diff --git a/projects/cronos-token-holder/abis/eth/x2y2.json b/projects/cronos-token-holder/abis/eth/x2y2.json new file mode 100644 index 00000000..dabaa6ae --- /dev/null +++ b/projects/cronos-token-holder/abis/eth/x2y2.json @@ -0,0 +1,296 @@ +[ + { + "inputs": [ + { "internalType": "address", "name": "_x2y2Token", "type": "address" }, + { + "internalType": "address", + "name": "_tokenSplitter", + "type": "address" + }, + { "internalType": "uint256", "name": "_startBlock", "type": "uint256" }, + { + "internalType": "uint256[]", + "name": "_rewardsPerBlockForStaking", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_rewardsPerBlockForOthers", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_periodLengthesInBlocks", + "type": "uint256[]" + }, + { "internalType": "uint256", "name": "_numberPeriods", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "harvestedAmount", + "type": "uint256" + } + ], + "name": "Compound", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "harvestedAmount", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "currentPhase", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "startBlock", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rewardPerBlockForStaking", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rewardPerBlockForOthers", + "type": "uint256" + } + ], + "name": "NewRewardsPerBlock", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "harvestedAmount", + "type": "uint256" + } + ], + "name": "Withdraw", + "type": "event" + }, + { + "inputs": [], + "name": "NUMBER_PERIODS", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PRECISION_FACTOR", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "START_BLOCK", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "accTokenPerShare", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "user", "type": "address" }], + "name": "calculatePendingRewards", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "currentPhase", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }], + "name": "deposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "endBlock", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "harvestAndCompound", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "lastRewardBlock", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardPerBlockForOthers", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardPerBlockForStaking", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "name": "stakingPeriod", + "outputs": [ + { + "internalType": "uint256", + "name": "rewardPerBlockForStaking", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardPerBlockForOthers", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "periodLengthInBlock", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tokenSplitter", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalAmountStaked", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "updatePool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "userInfo", + "outputs": [ + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "uint256", "name": "rewardDebt", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "x2y2Token", + "outputs": [ + { + "internalType": "contract IMintableERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/projects/cronos-token-holder/jest.config.ts b/projects/cronos-token-holder/jest.config.ts new file mode 100644 index 00000000..a1663671 --- /dev/null +++ b/projects/cronos-token-holder/jest.config.ts @@ -0,0 +1,8 @@ +/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ +export default { + preset: 'ts-jest/presets/default-esm', + modulePathIgnorePatterns: ['/dist/'], + moduleNameMapper: { + '^(\\.{1,2}/.*)\\.js$': '$1', + }, +} diff --git a/projects/cronos-token-holder/package.json b/projects/cronos-token-holder/package.json new file mode 100644 index 00000000..1494489a --- /dev/null +++ b/projects/cronos-token-holder/package.json @@ -0,0 +1,13 @@ +{ + "private": true, + "name": "cronos-token-holder", + "version": "1.0.0", + "type": "module", + "scripts": { + "build": "sentio build", + "gen": "sentio gen", + "test": "sentio test", + "upload": "sentio upload", + "postinstall": "sentio gen" + } +} \ No newline at end of file diff --git a/projects/cronos-token-holder/sentio.yaml b/projects/cronos-token-holder/sentio.yaml new file mode 100644 index 00000000..4b0f9820 --- /dev/null +++ b/projects/cronos-token-holder/sentio.yaml @@ -0,0 +1 @@ +project: cronos-token-holder diff --git a/projects/cronos-token-holder/src/processor.test.ts b/projects/cronos-token-holder/src/processor.test.ts new file mode 100644 index 00000000..a1a779a3 --- /dev/null +++ b/projects/cronos-token-holder/src/processor.test.ts @@ -0,0 +1,28 @@ +import { TestProcessorServer, firstCounterValue } from '@sentio/sdk/testing' +import { mockTransferLog } from '@sentio/sdk/eth/builtin/erc20' + +describe('Test Processor', () => { + const service = new TestProcessorServer(() => import('./processor.js')) + + beforeAll(async () => { + await service.start() + }) + + test('has valid config', async () => { + const config = await service.getConfig({}) + expect(config.contractConfigs.length > 0).toBeTruthy() + }) + + test('check transfer event handling', async () => { + const resp = await service.eth.testLog( + mockTransferLog('0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9', { + from: '0x0000000000000000000000000000000000000000', + to: '0xb329e39ebefd16f40d38f07643652ce17ca5bac1', + value: 10n ** 18n * 10n, + }) + ) + + const tokenCounter = firstCounterValue(resp.result, 'token') + expect(tokenCounter).toEqual(10n) + }) +}) diff --git a/projects/cronos-token-holder/src/processor.ts b/projects/cronos-token-holder/src/processor.ts new file mode 100644 index 00000000..ebf78908 --- /dev/null +++ b/projects/cronos-token-holder/src/processor.ts @@ -0,0 +1,88 @@ +import { EthChainId, GlobalContext, GlobalProcessor } from "@sentio/sdk/eth"; +import { ERC20Processor } from "@sentio/sdk/eth/builtin"; +import { ERC20Context } from "@sentio/sdk/eth/builtin/erc20"; +import { TransactionResponseParams } from "ethers"; + +const WETH = "0xe44fd7fcb2b1581822d0c862b68222998a0c299a" +const WCRO = "0x5c7f8a570d578ed84e63fdfa7b1ee72deae1ae23" +const VVS = "0x2d03bece6747adc00e1a131bba1469c15fd11e03" + +const address1 = "0xeadf7c01da7e93fdb5f16b0aa9ee85f978e89e95".toLowerCase() +const address2 = "0x543F4Db9BD26C9Eb6aD4DD1C33522c966C625774".toLowerCase() +const address3 = "0xE09f3B486c6d45CF7017d5D45DFB3ab35f8a51b8".toLowerCase() + + +const transferEventHandler = async (event: any, ctx: any) => { + ctx.eventLogger.emit("transferEvent", { + distinctId: event.args.from, + from: event.args.from, + to: event.args.to, + value: event.args.value + }) +} + +const transactionHandler = async (tx: TransactionResponseParams, ctx: GlobalContext) => { + if (tx.from.toLowerCase() == address1 || tx.to?.toLowerCase() == address1) { + ctx.eventLogger.emit("transferEvent", { + distinctId: tx.from, + from: tx.from, + to: tx.to, + value: tx.value + }) + } +} + + +const filter1_to = ERC20Processor.filters.Transfer( + null, + address1 +) + +const filter1_from = ERC20Processor.filters.Transfer( + address1, + null +) + +const filter2_to = ERC20Processor.filters.Transfer( + null, + address2 +) + +const filter2_from = ERC20Processor.filters.Transfer( + address2, + null +) + +const filter3_to = ERC20Processor.filters.Transfer( + null, + address3 +) + +const filter3_from = ERC20Processor.filters.Transfer( + address3, + null +) + + +ERC20Processor.bind({ + address: WETH, + network: EthChainId.CRONOS +}) + .onEventTransfer(transferEventHandler, [filter2_from, filter2_to]) + + +ERC20Processor.bind({ + address: WCRO, + network: EthChainId.CRONOS +}) + .onEventTransfer(transferEventHandler, [filter3_from, filter3_to]) + +ERC20Processor.bind({ + address: VVS, + network: EthChainId.CRONOS +}) + .onEventTransfer(transferEventHandler, [filter3_from, filter3_to]) + + +GlobalProcessor.bind({ network: EthChainId.CRONOS }) + .onTransaction(transactionHandler) \ No newline at end of file diff --git a/projects/cronos-token-holder/tsconfig.json b/projects/cronos-token-holder/tsconfig.json new file mode 100644 index 00000000..8fc700b4 --- /dev/null +++ b/projects/cronos-token-holder/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "importHelpers": true, + "alwaysStrict": true, + "sourceMap": true, + "target": "esnext", + "esModuleInterop": true, + "noImplicitReturns": true, + "noImplicitAny": true, + "module": "nodenext", + "moduleResolution": "nodenext", + "strictNullChecks": true, + "stripInternal": true, + "noFallthroughCasesInSwitch": true, + "noEmitOnError": false, + "rootDir": "./src", + "outDir": "./dist", + "skipLibCheck": true + }, + "exclude": ["dist", "jest.config.ts"] +} diff --git a/projects/fulcrom/abis/eth/Vester.json b/projects/fulcrom/abis/eth/Vester.json new file mode 100644 index 00000000..c4fb76db --- /dev/null +++ b/projects/fulcrom/abis/eth/Vester.json @@ -0,0 +1,1052 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Claim", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "PairTransfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "gov", + "type": "address" + } + ], + "name": "UpdateGov", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "claimedAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "name": "Withdraw", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balances", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "bonusRewards", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "claim", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_receiver", + "type": "address" + } + ], + "name": "claimForAccount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "claimable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "claimableToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "claimedAmounts", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "cumulativeClaimAmounts", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "cumulativeRewardDeductions", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "depositForAccount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "esToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "getCombinedAverageStakedAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "getMaxVestableAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_esAmount", + "type": "uint256" + } + ], + "name": "getPairAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "getTotalVested", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "getVestedAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gov", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hasMaxVestableAmount", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hasPairToken", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hasRewardTracker", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "_vestingDuration", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_esToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_pairToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_claimableToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_rewardTracker", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isHandler", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "lastVestingTimes", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "pairAmounts", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pairSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pairToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardTracker", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "setBonusRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "setCumulativeRewardDeductions", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_gov", + "type": "address" + } + ], + "name": "setGov", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_handler", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isActive", + "type": "bool" + } + ], + "name": "setHandler", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "_hasMaxVestableAmount", + "type": "bool" + } + ], + "name": "setHasMaxVestableAmount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "setTransferredAverageStakedAmounts", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "setTransferredCumulativeRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_sender", + "type": "address" + }, + { + "internalType": "address", + "name": "_receiver", + "type": "address" + } + ], + "name": "transferStakeValues", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "transferredAverageStakedAmounts", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "transferredCumulativeRewards", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "vestingDuration", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "withdrawToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/projects/fulcrom/src/processor.ts b/projects/fulcrom/src/processor.ts index 38f0aee0..a96ba8bc 100644 --- a/projects/fulcrom/src/processor.ts +++ b/projects/fulcrom/src/processor.ts @@ -7,6 +7,7 @@ import { gaugeTokenAum, gaugeStakedAssets } from './helper/fulcrom-helper.js'; import { getERC20ContractOnContext } from '@sentio/sdk/eth/builtin/erc20' import { FUL_ADDRESS_MAP, sFUL_ADDRESS_MAP, esFUL_ADDRESS_MAP, vFLP_ADDRESS_MAP, vFUL_ADDRESS_MAP, VAULT_ADDRESS_MAP, FUL_MANAGER_ADDRESS_MAP, REWARD_ROUTER_ADDRESS_MAP, CHAINS } from './helper/constant.js' import { getOrCreateCoin } from './helper/fulcrom-helper.js'; +import { VesterProcessor } from './types/eth/vester.js'; CHAINS.forEach(chain => { @@ -213,4 +214,24 @@ CHAINS.forEach(chain => { ctx.meter.Gauge("unstake_esful_gauge").record(Number(evt.args.amount) / Math.pow(10, 18)) } }) + + + + const dauEventHandler = async (evt: any, ctx: any) => { + ctx.eventLogger.emit(`${evt.name}`, { + //@ts-ignore + distinctId: ctx.transaction.from + }) + } + + VesterProcessor.bind({ address: vFUL_ADDRESS_MAP.get(chain)!, network: chain }) + .onEventClaim(dauEventHandler, [], { transaction: true }) + .onEventDeposit(dauEventHandler, [], { transaction: true }) + .onEventWithdraw(dauEventHandler, [], { transaction: true }) + + VesterProcessor.bind({ address: vFLP_ADDRESS_MAP.get(chain)!, network: chain }) + .onEventClaim(dauEventHandler, [], { transaction: true }) + .onEventDeposit(dauEventHandler, [], { transaction: true }) + .onEventWithdraw(dauEventHandler, [], { transaction: true }) + }) diff --git a/projects/tomo/src/processor.ts b/projects/tomo/src/processor.ts index cc2bc352..13f5c0c4 100644 --- a/projects/tomo/src/processor.ts +++ b/projects/tomo/src/processor.ts @@ -3,7 +3,7 @@ import { BindSubjectEvent, RewardClaimedEvent, SubjectRewardSetEvent, TomoContex import { ethers } from "ethers" import * as dotenv from 'dotenv' import { TWITTER_ENDPOINT } from "./twitterEndpoint.js"; -import { scaleDown } from "@sentio/sdk"; +import { BigDecimal, scaleDown } from "@sentio/sdk"; import { Client } from "twitter-api-sdk"; const TOMO_CONTRACT = "0x9E813d7661D7B56CBCd3F73E958039B208925Ef8" @@ -21,46 +21,6 @@ interface profileInfo { const tradeEventHandler = async (event: TradeEvent, ctx: TomoContext) => { const subject = ethers.decodeBytes32String(ethers.zeroPadBytes(ethers.stripZerosLeft(event.args.tradeEvent.subject), 32)) - - if (subject.slice(0, 2) == "x@") { - let profileInfo: profileInfo = { - username: "unk", - name: "unk", - followers_count: -1, - friends_count: -1, - profile_image_url_https: "unk", - description: "unk" - } - - //check whether in sql table - const sqlResult = await getSqlResult(subject) - console.log(`get sqlResult in trade ${JSON.stringify(sqlResult)}`) - if (sqlResult) { - console.log(`found in sql ${subject}`) - profileInfo = getFields(sqlResult) - } - else { - //if not, retrieve from twitter api - let try_counter = 0 - while (Number(profileInfo.followers_count) == -1 && try_counter < MAX_FETCH_TRY) { - profileInfo = await fetchX(ctx, subject.slice(2,)) - try_counter++ - if (!profileInfo && try_counter < MAX_FETCH_TRY) { - await sleep(try_counter * 1000) - } - } - ctx.eventLogger.emit("subjectInfo", { - distinctId: subject, - username: subject, - name: profileInfo.name, - followers_count: Number(profileInfo.followers_count), - friends_count: Number(profileInfo.friends_count), - profile_image_url_https: profileInfo.profile_image_url_https, - description: profileInfo.description - }) - } - } - ctx.eventLogger.emit("tradeEvent", { distinctId: event.args.tradeEvent.trader, eventIndex: event.args.tradeEvent.eventIndex, @@ -80,6 +40,13 @@ const tradeEventHandler = async (event: TradeEvent, ctx: TomoContext) => { const bindSubjectEventHandler = async (event: BindSubjectEvent, ctx: TomoContext) => { const subject = ethers.decodeBytes32String(ethers.zeroPadBytes(ethers.stripZerosLeft(event.args.subject), 32)) + let balance = BigDecimal(-1) + try { + balance = scaleDown(await ctx.contract.provider.getBalance(event.args.owner), 18) + } + catch (e) { + console.log(`get wallet balance failed for ${event.args.owner}`) + } if (subject.slice(0, 2) == "x@") { let profileInfo: profileInfo = { @@ -129,7 +96,8 @@ const bindSubjectEventHandler = async (event: BindSubjectEvent, ctx: TomoContext followers_count: Number(profileInfo.followers_count), friends_count: Number(profileInfo.friends_count), profile_image_url_https: profileInfo.profile_image_url_https, - description: profileInfo.description + description: profileInfo.description, + balance }) } else { @@ -138,7 +106,8 @@ const bindSubjectEventHandler = async (event: BindSubjectEvent, ctx: TomoContext ts: event.args.ts, subject, subjectBytes32: event.args.subject, - owner: event.args.owner + owner: event.args.owner, + balance }) } } @@ -202,7 +171,7 @@ async function sleep(milliseconds: number): Promise { export async function fetchResults(subject: string) { const url = new URL( - "/api/v1/analytics/ye/tomo/sql/execute", + "/api/v1/analytics/sentio/tomo/sql/execute", "https://app.sentio.xyz" )