Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
meomeocoj committed Aug 12, 2024
0 parents commit 614499e
Show file tree
Hide file tree
Showing 51 changed files with 18,022 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.data/
dist/
build/

## env
.env
10 changes: 10 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
bin
pkg
target
coverage
dist
build
packages/contracts-{build,sdk}
packages/oraidex-common-ui

47 changes: 47 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"root": true,
"env": {
"node": true,
"commonjs": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:security/recommended",
"plugin:import/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest"
},
"settings": {
"import/resolver": {
"node": true,
"typescript": true
}
},
"plugins": ["@typescript-eslint"],
"rules": {
"no-console": "off",
"quotes": ["error", "double"],
"semi": ["error", "always"]
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"rules": {
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": ["warn", { "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }],
"security/detect-object-injection": "off",
"@typescript-eslint/ban-ts-comment": "off"
}
},
{
"files": ["*.js"],
"rules": {
"@typescript-eslint/no-var-requires": "warn"
}
}
]
}
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Ignore environment variables file
.env

.npmrc
build

dist
.DS_Store
cache/

coverage

.nx
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn test
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": false,
"trailingComma": "none",
"jsxSingleQuote": false,
"printWidth": 120
}
24 changes: 24 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.formatOnPaste": false,
"prettier.useEditorConfig": false,
"prettier.useTabs": false,
"prettier.trailingComma": "none",
"prettier.tabWidth": 2,
"prettier.printWidth": 120,
"prettier.semi": true,
"prettier.singleQuote": true,
"typescript.tsdk": "node_modules/typescript/lib",
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"cSpell.words": [
"chaintypes",
"Datasource",
"subql"
]
}
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM node:20.12.0 AS builder

ARG CONTRACT_ADDRESS
ARG RPC_URL
ENV AMM_V3_CONTRACT_ADDRESS=$CONTRACT_ADDRESS
ENV RPC_URL=$RPC_URL
WORKDIR /app
COPY ./package.json ./yarn.lock ./lerna.json ./
COPY packages/libs/package.json /app/packages/libs/package.json
COPY packages/amm-v3/package.json /app/packages/amm-v3/package.json
COPY packages/tx-history/package.json /app/packages/tx-history/package.json
RUN yarn
COPY packages/libs/ /app/packages/libs/
COPY packages/amm-v3/ /app/packages/amm-v3/
COPY packages/tx-history/ /app/packages/tx-history/
COPY ./tsconfig.json /app/tsconfig.json

RUN yarn prebuild && yarn build

FROM subquerynetwork/subql-node-cosmos:v4.0.1 AS base-node

FROM base-node AS ammv3-indexer

COPY --from=builder /app/packages/amm-v3 /app

17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Oraichain Indexer

## How to build

```bash
docker build . \
--build-arg CONTRACT_ADDRESS=$AMM_V3_CONTRACT_ADDRESS \
--build-arg RPC_URL=$RPC_URL \
--target ammv3-indexer \
-t oraichain/defi_ammv3-indexer
```

## How to run

```bash
cd packages/${project} && docker-compose up --remove-orphans
```
11 changes: 11 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// jest.config.js
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testPathIgnorePatterns: ["/node_modules/", "/dist/", "/build/"],
transform: {
"^.+\\.tsx?$": "ts-jest"
},
transformIgnorePatterns: ["/node_modules/(?!oraidex-contracts-sdk|react-day-picker)"],

};
10 changes: 10 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"npmClient": "yarn",
"version": "1.0.7",
"command": {
"publish": {
"registry": "https://registry.npmjs.org/"
}
}
}
25 changes: 25 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"tasksRunnerOptions": {
"default": {
"options": {}
}
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"cache": true
},
"cli": {
"packageManager": "yarn"
},
"test": {
"cache": true
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"sharedGlobals": [],
"production": ["default"]
},
"cacheDirectory": "node_modules/.cache"
}
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@oraichain/indexer",
"private": true,
"workspaces": [
"packages/*"
],
"repository": "github:oraichain/oraichain-indexer",
"scripts": {
"postinstall": "patch-package",
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"prepare": "husky",
"prebuild": "lerna run codegen --concurrency 1",
"build": "lerna run build --concurrency 1"
},
"dependencies": {
"@types/node": "^17.0.21",
"typescript": "^5.2.2"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"eslint": "^8.57.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-security": "^2.1.1",
"husky": "^9.1.4",
"jest": "^29.7.0",
"lerna": "^8.1.7",
"nx": "19.5.6",
"patch-package": "^8.0.0",
"ts-jest": "^29.2.3"
}
}
59 changes: 59 additions & 0 deletions packages/libs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

# These are some examples of commonly ignored file patterns.
# You should customize this list as applicable to your project.
# Learn more about .gitignore:
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore

# Node artifact files
node_modules/
dist/

# lock files
yarn.lock
package-lock.json

# Compiled Java class files
*.class

# Compiled Python bytecode
*.py[cod]

# Log files
*.log

# Package files
*.jar

# Generated files
target/
dist/
src/types
project.yaml

# JetBrains IDE
.idea/

# Unit test reports
TEST*.xml

# Generated by MacOS
.DS_Store

# Generated by Windows
Thumbs.db

# Applications
*.app
*.exe
*.war

# Large media files
*.mp4
*.tiff
*.avi
*.flv
*.mov
*.wmv

.data
dist
30 changes: 30 additions & 0 deletions packages/libs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@oraichain/libs-indexer",
"version": "0.0.1",
"description": "This project can be use as a starting point for developing your Oraichain based SubQuery project",
"main": "dist/index.js",
"scripts": {
"build": "tsc -p tsconfig.build.json"
},
"files": [
"dist"
],
"license": "MIT",
"devDependencies": {
"@subql/cli": "latest",
"@subql/node-cosmos": "latest",
"@subql/testing": "latest",
"@types/ejs": "^3.1.5",
"@types/node-fetch": "^2.6.11",
"typescript": "^5.2.2"
},
"dependencies": {
"@cosmjs/stargate": "^0.32.3",
"@subql/types-cosmos": "latest",
"@types/node": "^20.14.12",
"node-fetch": "^2.7.0",
"pino": "^7.8.0",
"ts-proto": "^1.112.1",
"tslib": "=2.3.1"
}
}
34 changes: 34 additions & 0 deletions packages/libs/src/amm-v3/claimFee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { CosmosEvent } from "@subql/types-cosmos";
import { AMM_V3_ACTIONS } from "../utils/constant";
import { ContractAddressAttribute, parseEventToAmmV3Action } from "./common";

export type ClaimFeeEvent = ContractAddressAttribute & {
action: AMM_V3_ACTIONS.CLAIM_FEE;
owner: string;
pool_key: string;
position_token_id: string;
amount_x: string;
amount_y: string;
incentives_token_address: string;
incentives_amount: string;
};

export function createClaimFeeId(txHash: string, positionId: string): string {
return `${txHash}-claimFee-${positionId}`;
}

export function extractClaimFeeEvent(event: CosmosEvent, ammV3: string) {
return parseEventToAmmV3Action<ClaimFeeEvent>(event, AMM_V3_ACTIONS.CLAIM_FEE, ammV3);
}

export function parseIncentivesAttr(incentives: string) {
return incentives.split(",");
}

export function parseIncentiveReward(incentive: string) {
return incentive.split(",");
}

export function createClaimFeeIncentiveTokenId(claimFeeId: string, incentiveToken: string) {
return `${claimFeeId}-${incentiveToken}`;
}
Loading

0 comments on commit 614499e

Please sign in to comment.