Skip to content

Commit 6a81324

Browse files
committed
migrate plugin to 1.x
1 parent cab415b commit 6a81324

62 files changed

Lines changed: 5935 additions & 2911 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/npm-deploy.yml

Lines changed: 94 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,112 @@
1-
name: Release to NPM
1+
name: Publish Package
22

33
on:
44
push:
5-
branches: [main, 1.x]
5+
branches:
6+
- 1.x
7+
workflow_dispatch:
68

79
jobs:
8-
release:
10+
verify_version:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
should_publish: ${{ steps.check.outputs.should_publish }}
14+
version: ${{ steps.check.outputs.version }}
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Check if package.json version changed
22+
id: check
23+
run: |
24+
echo "Current branch: ${{ github.ref }}"
25+
26+
# Get current version
27+
CURRENT_VERSION=$(jq -r .version package.json)
28+
echo "Current version: $CURRENT_VERSION"
29+
30+
# Get previous commit hash
31+
git rev-parse HEAD~1 || git rev-parse HEAD
32+
PREV_COMMIT=$(git rev-parse HEAD~1 2>/dev/null || git rev-parse HEAD)
33+
34+
# Check if package.json changed
35+
if git diff --name-only HEAD~1 HEAD | grep "package.json"; then
36+
echo "Package.json was changed in this commit"
37+
38+
# Get previous version if possible
39+
if git show "$PREV_COMMIT:package.json" 2>/dev/null; then
40+
PREV_VERSION=$(git show "$PREV_COMMIT:package.json" | jq -r .version)
41+
echo "Previous version: $PREV_VERSION"
42+
43+
if [ "$CURRENT_VERSION" != "$PREV_VERSION" ]; then
44+
echo "Version changed from $PREV_VERSION to $CURRENT_VERSION"
45+
echo "should_publish=true" >> $GITHUB_OUTPUT
46+
else
47+
echo "Version unchanged"
48+
echo "should_publish=false" >> $GITHUB_OUTPUT
49+
fi
50+
else
51+
echo "First commit with package.json, will publish"
52+
echo "should_publish=true" >> $GITHUB_OUTPUT
53+
fi
54+
else
55+
echo "Package.json not changed in this commit"
56+
echo "should_publish=false" >> $GITHUB_OUTPUT
57+
fi
58+
59+
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
60+
61+
publish:
62+
needs: verify_version
63+
if: needs.verify_version.outputs.should_publish == 'true'
964
runs-on: ubuntu-latest
1065
permissions:
11-
contents: read
12-
packages: write
66+
contents: write
1367
steps:
14-
- uses: actions/checkout@v4
68+
- name: Checkout repository
69+
uses: actions/checkout@v4
70+
with:
71+
fetch-depth: 0
72+
73+
- name: Create Git tag
74+
run: |
75+
git config user.name "github-actions[bot]"
76+
git config user.email "github-actions[bot]@users.noreply.github.com"
77+
git tag -a "v${{ needs.verify_version.outputs.version }}" -m "Release v${{ needs.verify_version.outputs.version }}"
78+
git push origin "v${{ needs.verify_version.outputs.version }}"
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1581

1682
- name: Setup Bun
17-
uses: oven-sh/setup-bun@v1
18-
with:
19-
bun-version: latest
83+
uses: oven-sh/setup-bun@v2
2084

2185
- name: Install dependencies
2286
run: bun install
2387

24-
- name: Build
88+
- name: Build package
2589
run: bun run build
2690

27-
- name: Run tests
28-
run: bun test
29-
30-
- name: Type check
31-
run: bunx tsc --noEmit
91+
- name: Publish to npm
92+
run: bun publish
93+
env:
94+
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
3295

33-
- name: Publish to NPM
34-
run: npm publish --access public
96+
create_release:
97+
needs: [verify_version, publish]
98+
if: needs.verify_version.outputs.should_publish == 'true'
99+
runs-on: ubuntu-latest
100+
permissions:
101+
contents: write
102+
steps:
103+
- name: Create GitHub Release
104+
uses: actions/create-release@v1
35105
env:
36-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
with:
108+
tag_name: "v${{ needs.verify_version.outputs.version }}"
109+
release_name: "v${{ needs.verify_version.outputs.version }}"
110+
body: "Release v${{ needs.verify_version.outputs.version }}"
111+
draft: false
112+
prerelease: false

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,10 @@ coverage/
3434
# Temporary files
3535
*.tmp
3636
*.temp
37-
.cache/
37+
.cache/
38+
39+
# ElizaOS specific
40+
.elizadb
41+
.turbo
42+
.turbo-tsconfig.json
43+
tsconfig.tsbuildinfo

.npmignore

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,7 @@
1-
# Source files
2-
src/
3-
__tests__/
1+
*
42

5-
# Configuration files
6-
tsconfig.json
7-
tsup.config.ts
8-
bunfig.toml
9-
vitest.config.ts
10-
.prettierrc
11-
.eslintrc*
12-
13-
# IDE
14-
.vscode/
15-
.idea/
16-
17-
# Environment
18-
.env
19-
.env.*
20-
21-
# Logs
22-
logs/
23-
*.log
24-
25-
# OS
26-
.DS_Store
27-
Thumbs.db
28-
29-
# Test coverage
30-
coverage/
31-
.nyc_output/
32-
33-
# Git
34-
.git/
35-
.gitignore
36-
37-
# Docs
38-
*.md
39-
docs/
40-
examples/
41-
migration-guides/
42-
43-
# CI/CD
44-
.github/
3+
!dist/**
4+
!package.json
5+
!README.md
6+
!tsup.config.ts
7+
!LICENSE

.prettierrc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"semi": true,
3-
"trailingComma": "es5",
4-
"singleQuote": false,
5-
"printWidth": 80,
6-
"tabWidth": 4,
7-
"useTabs": false,
8-
"arrowParens": "always",
9-
"endOfLine": "lf"
10-
}
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": false,
5+
"printWidth": 80,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"arrowParens": "always",
9+
"endOfLine": "lf"
10+
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 ElizaOS Contributors
3+
Copyright (c) 2025 Shaw Walters and elizaOS Contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The ElizaOS Arbitrage Plugin monitors multiple decentralized exchanges (DEXs) li
2626
## Installation
2727

2828
```bash
29-
npm install @elizaos-plugins/plugin-arbitrage
29+
bun install @elizaos/plugin-arbitrage
3030
```
3131

3232
## Configuration
@@ -35,34 +35,29 @@ To use the plugin, you need to configure your ElizaOS character with the necessa
3535

3636
```json
3737
{
38-
"name": "Trader",
39-
"settings": {
40-
"secrets": {
41-
"EVM_PRIVATE_KEY": "YOUR_PRIVATE_KEY_HERE",
42-
"FLASHBOTS_RELAY_SIGNING_KEY": "YOUR_FLASHBOTS_KEY_HERE",
43-
"BUNDLE_EXECUTOR_ADDRESS": "YOUR_EXECUTOR_ADDRESS_HERE"
44-
},
45-
"arbitrage": {
46-
"ethereumWsUrl": "YOUR_ETH_WSS_URL",
47-
"rpcUrl": "YOUR_ETH_RPC_URL"
48-
}
38+
"name": "Trader",
39+
"settings": {
40+
"secrets": {
41+
"ARBITRAGE_EVM_PRIVATE_KEY": "YOUR_PRIVATE_KEY_HERE",
42+
"FLASHBOTS_RELAY_SIGNING_KEY": "YOUR_FLASHBOTS_KEY_HERE",
43+
"BUNDLE_EXECUTOR_ADDRESS": "YOUR_EXECUTOR_ADDRESS_HERE"
4944
},
50-
"plugins": [
51-
"@elizaos/plugin-arbitrage",
52-
"@elizaos/plugin-evm"
53-
]
45+
"ARBITRAGE_ETHEREUM_WS_URL": "YOUR_ETH_WSS_URL",
46+
"ARBITRAGE_EVM_PROVIDER_URL": "YOUR_ETH_RPC_URL"
47+
},
48+
"plugins": ["@elizaos/plugin-arbitrage"]
5449
}
5550
```
5651

5752
### Required Settings
5853

59-
| Setting | Description |
60-
|---------|-------------|
61-
| `EVM_PRIVATE_KEY` | Private key for your Ethereum wallet (keep this secure!) |
62-
| `FLASHBOTS_RELAY_SIGNING_KEY` | Signing key for Flashbots bundles |
63-
| `BUNDLE_EXECUTOR_ADDRESS` | Address of your bundle executor contract |
64-
| `ethereumWsUrl` | WebSocket URL for your Ethereum node |
65-
| `rpcUrl` | RPC URL for your Ethereum node |
54+
| Setting | Description |
55+
| ----------------------------- | ------------------------------------------------------------------- |
56+
| `ARBITRAGE_EVM_PRIVATE_KEY` | Private key for your Ethereum wallet (keep this secure!) |
57+
| `FLASHBOTS_RELAY_SIGNING_KEY` | Signing key for Flashbots bundles |
58+
| `BUNDLE_EXECUTOR_ADDRESS` | Address of your bundle executor contract |
59+
| `ARBITRAGE_ETHEREUM_WS_URL` | WebSocket URL for your Ethereum node (optional if RPC URL provided) |
60+
| `ARBITRAGE_EVM_PROVIDER_URL` | RPC URL for your Ethereum node (fallback if WS not provided) |
6661

6762
## Usage
6863

@@ -89,10 +84,10 @@ You can customize trading parameters by modifying the thresholds in `src/config/
8984

9085
```typescript
9186
export const DEFAULT_THRESHOLDS: MarketThresholds = {
92-
minProfitThreshold: BigNumber.from("100000000000000"), // 0.0001 ETH
93-
maxTradeSize: BigNumber.from("1000000000000000000"), // 1 ETH
94-
gasLimit: 500000,
95-
minerRewardPercentage: 90
87+
minProfitThreshold: BigNumber.from("100000000000000"), // 0.0001 ETH
88+
maxTradeSize: BigNumber.from("1000000000000000000"), // 1 ETH
89+
gasLimit: 500000,
90+
minerRewardPercentage: 90,
9691
};
9792
```
9893

__tests__/.DS_Store

-6 KB
Binary file not shown.

0 commit comments

Comments
 (0)