Skip to content

Commit

Permalink
fix cetus, added cronos-token project
Browse files Browse the repository at this point in the history
  • Loading branch information
ye-sentio committed Nov 3, 2023
1 parent 432d352 commit e1614e8
Show file tree
Hide file tree
Showing 11 changed files with 1,544 additions and 47 deletions.
6 changes: 3 additions & 3 deletions projects/cetus/src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" })
Expand Down Expand Up @@ -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" })
Expand Down Expand Up @@ -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 })



Expand Down
296 changes: 296 additions & 0 deletions projects/cronos-token-holder/abis/eth/x2y2.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
8 changes: 8 additions & 0 deletions projects/cronos-token-holder/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
export default {
preset: 'ts-jest/presets/default-esm',
modulePathIgnorePatterns: ['<rootDir>/dist/'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
}
13 changes: 13 additions & 0 deletions projects/cronos-token-holder/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
1 change: 1 addition & 0 deletions projects/cronos-token-holder/sentio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
project: cronos-token-holder
28 changes: 28 additions & 0 deletions projects/cronos-token-holder/src/processor.test.ts
Original file line number Diff line number Diff line change
@@ -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)
})
})
Loading

0 comments on commit e1614e8

Please sign in to comment.