Filter everything with users (#16)

* Filter everything with users

* Fix backtests and user management

* Add cursor rules

* Fix backtest and bots

* Update configs names

* Sign until unauth

* Setup delegate

* Setup delegate and sign

* refact

* Enhance Privy signature generation with improved cryptographic methods

* Add Fastify backend

* Add Fastify backend routes for privy

* fix privy signing

* fix privy client

* Fix tests

* add gmx core

* fix merging sdk

* Fix tests

* add gmx core

* add gmx core

* add privy to boilerplate

* clean

* fix

* add fastify

* Remove Managing.Fastify submodule

* Add Managing.Fastify as regular directory instead of submodule

* Update .gitignore to exclude Managing.Fastify dist and node_modules directories

* Add token approval functionality to Privy plugin

- Introduced a new endpoint `/approve-token` for approving ERC20 tokens.
- Added `approveToken` method to the Privy plugin for handling token approvals.
- Updated `signPrivyMessage` to differentiate between message signing and token approval requests.
- Enhanced the plugin with additional schemas for input validation.
- Included new utility functions for token data retrieval and message construction.
- Updated tests to verify the new functionality and ensure proper request decoration.

* Add PrivyApproveTokenResponse model for token approval response

- Created a new class `PrivyApproveTokenResponse` to encapsulate the response structure for token approval requests.
- The class includes properties for `Success` status and a transaction `Hash`.

* Refactor trading commands and enhance API routes

- Updated `OpenPositionCommandHandler` to use asynchronous methods for opening trades and canceling orders.
- Introduced new Fastify routes for opening positions and canceling orders with appropriate request validation.
- Modified `EvmManager` to handle both Privy and non-Privy wallet operations, utilizing the Fastify API for Privy wallets.
- Adjusted test configurations to reflect changes in account types and added helper methods for testing Web3 proxy services.

* Enhance GMX trading functionality and update dependencies

- Updated `dev:start` script in `package.json` to include the `-d` flag for Fastify.
- Upgraded `fastify-cli` dependency to version 7.3.0.
- Added `sourceMap` option to `tsconfig.json`.
- Refactored GMX plugin to improve position opening logic, including enhanced error handling and validation.
- Introduced a new method `getMarketInfoFromTicker` for better market data retrieval.
- Updated account type in `PrivateKeys.cs` to use `Privy`.
- Adjusted `EvmManager` to utilize the `direction` enum directly for trade direction handling.

* Refactor GMX plugin for improved trading logic and market data retrieval

- Enhanced the `openGmxPositionImpl` function to utilize the `TradeDirection` enum for trade direction handling.
- Introduced `getTokenDataFromTicker` and `getMarketByIndexToken` functions for better market and token data retrieval.
- Updated collateral calculation and logging for clarity.
- Adjusted `EvmManager` to ensure proper handling of price values in trade requests.

* Refactor GMX plugin and enhance testing for position opening

- Updated `test:single` script in `package.json` to include TypeScript compilation before running tests.
- Removed `this` context from `getClientForAddress` function and replaced logging with `console.error`.
- Improved collateral calculation in `openGmxPositionImpl` for better precision.
- Adjusted type casting for `direction` in the API route to utilize `TradeDirection` enum.
- Added a new test for opening a long position in GMX, ensuring functionality and correctness.

* Update sdk

* Update

* update fastify

* Refactor start script in package.json to simplify command execution

- Removed the build step from the start script, allowing for a more direct launch of the Fastify server.

* Update package.json for Web3Proxy

- Changed the name from "Web3Proxy" to "web3-proxy".
- Updated version from "0.0.0" to "1.0.0".
- Modified the description to "The official Managing Web3 Proxy".

* Update Dockerfile for Web3Proxy

- Upgraded Node.js base image from 18-alpine to 22.14.0-alpine.
- Added NODE_ENV environment variable set to production.

* Refactor Dockerfile and package.json for Web3Proxy

- Removed the build step from the Dockerfile to streamline the image creation process.
- Updated the start script in package.json to include the build step, ensuring the application is built before starting the server.

* Add fastify-tsconfig as a development dependency in Dockerfile-web3proxy

* Remove fastify-tsconfig extension from tsconfig.json for Web3Proxy

* Add PrivyInitAddressResponse model for handling initialization responses

- Introduced a new class `PrivyInitAddressResponse` to encapsulate the response structure for Privy initialization, including properties for success status, USDC hash, order vault hash, and error message.

* Update

* Update

* Remove fastify-tsconfig installation from Dockerfile-web3proxy

* Add build step to Dockerfile-web3proxy

- Included `npm run build` in the Dockerfile to ensure the application is built during the image creation process.

* Update

* approvals

* Open position from front embedded wallet

* Open position from front embedded wallet

* Open position from front embedded wallet

* Fix call contracts

* Fix limit price

* Close position

* Fix close position

* Fix close position

* add pinky

* Refactor position handling logic

* Update Dockerfile-pinky to copy package.json and source code from the correct directory

* Implement password protection modal and enhance UI with new styles; remove unused audio elements and update package dependencies.

* add cancel orders

* Update callContract function to explicitly cast account address as Address type

* Update callContract function to cast transaction parameters as any type for compatibility

* Cast transaction parameters as any type in approveTokenImpl for compatibility

* Cast wallet address and transaction parameters as Address type in approveTokenImpl for type safety

* Add .env configuration file for production setup including database and server settings

* Refactor home route to update welcome message and remove unused SDK configuration code

* add referral code

* fix referral

* Add sltp

* Fix typo

* Fix typo

* setup sltp on backtend

* get orders

* get positions with slp

* fixes

* fixes close position

* fixes

* Remove MongoDB project references from Dockerfiles for managing and worker APIs

* Comment out BotManagerWorker service registration and remove MongoDB project reference from Dockerfile

* fixes
This commit is contained in:
Oda
2025-04-20 22:18:27 +07:00
committed by GitHub
parent 0ae96a3278
commit 528c62a0a1
400 changed files with 94446 additions and 1635 deletions

BIN
src/Managing.Web3Proxy/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,31 @@
# Must always set to production
# @see {@link https://www.youtube.com/watch?v=HMM7GJC5E2o}
NODE_ENV=production
PORT=4111
CAN_CREATE_DATABASE=0
CAN_DROP_DATABASE=0
CAN_SEED_DATABASE=0
# Database
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_DATABASE=test_db
MYSQL_USER=test_user
MYSQL_PASSWORD=test_password
# Server
FASTIFY_CLOSE_GRACE_DELAY=1000
LOG_LEVEL=info
# Security
COOKIE_SECRET=25wwYu5AgxArU7djgvQEuioc9YSdGY3WN3r1dmXftPfH33KfGVfzopW3vqoPFjy1b8wS2gkDDZ9iQ8yxSo9Vi4iN
COOKIE_NAME=test_cookie_name
COOKIE_SECURED=true
RATE_LIMIT_MAX=4 # 4 for tests
PRIVY_APP_ID=cm7u09v0u002zrkuf2yjjr58p
PRIVY_APP_SECRET=25wwYu5AgxArU7djgvQEuioc9YSdGY3WN3r1dmXftPfH33KfGVfzopW3vqoPFjy1b8wS2gkDDZ9iQ8yxSo9Vi4iN
PRIVY_AUTHORIZATION_KEY=wallet-auth:MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQggpJ65PCo4E6NYpY867AyE6p1KxOrs8LJqHZw+t+076yhRANCAAS2EM23CtIfQRmHWTxcqb1j5yfrVePjZyBOZZ2RoPZHb9bDGLos206fTuVA3zgLVomlOoHTeYifkBASCn9Mfg3b
API_URL=http://localhost:5000
ARBITRUM_RPC_URL=https://arbitrum-one.publicnode.com

View File

@@ -0,0 +1 @@
sonar.exclusions=test/**/*,scripts/seed-database.ts

View File

@@ -0,0 +1,16 @@
declare global {
namespace NodeJS {
interface ProcessEnv {
PORT: number;
LOG_LEVEL: string;
FASTIFY_CLOSE_GRACE_DELAY: number;
MYSQL_HOST: string
MYSQL_PORT: number
MYSQL_DATABASE: string
MYSQL_USER: string
MYSQL_PASSWORD: string
}
}
}
export {}

View File

@@ -0,0 +1,22 @@
# Use an official Node.js image as the base
FROM node:22.14.0-alpine
# Set the working directory in the container
WORKDIR /app
# COPY package*.json ./
COPY /src/Managing.Web3Proxy/package.json ./
# Declaring env
ENV NODE_ENV production
# Install dependencies with the --legacy-peer-deps flag to bypass peer dependency conflicts
RUN npm install
COPY src/Managing.Web3Proxy/ .
RUN npm run build
EXPOSE 4111
CMD ["npm", "run", "start"]

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Fastify
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,77 @@
# Fastify Official Demo
The aim of this repository is to provide a concrete example of a Fastify application using what are considered best practices by the Fastify community.
**Prerequisites:** You need to have Node.js version 22 or higher installed.
## Getting started
Install the dependencies:
```bash
npm install
```
### Database
You can run a MySQL instance with Docker:
```bash
docker compose up
```
To run it in the background:
```bash
docker compose up -d
```
To create and update the database schema, run the migrations:
```bash
npm run db:migrate
```
To populate the database with initial data, run:
```bash
npm run db:seed
```
### TypeScript
To build the project:
```bash
npm run build
```
### Start the server
In dev mode:
```bash
npm run dev
```
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
In production mode:
```bash
npm run start
```
### Testing
To run the tests:
```bash
npm run test
```
### Standalone
`dev` and `start` leverage [fastify-cli](https://github.com/fastify/fastify-cli),
but you can run the demo as a standalone executable (see [server.ts](./src/server.ts)):
```bash
npm run standalone
```
### Linting
To check for linting errors:
```bash
npm run lint
```
To check and automatically fix linting errors:
```bash
npm run lint:fix
```
## Learn More
To learn more about Fastify, check out the [Fastify documentation](https://www.fastify.io/docs/latest/).

View File

@@ -0,0 +1,20 @@
services:
db:
image: mysql:8.4
environment:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- 3306:3306
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-u${MYSQL_USER}", "-p${MYSQL_PASSWORD}"]
interval: 10s
timeout: 5s
retries: 3
volumes:
- db_data:/var/lib/mysql
volumes:
db_data:

View File

@@ -0,0 +1,18 @@
import neo from 'neostandard'
export default [
...neo({
ts: true
}),
{
rules: {
'@stylistic/comma-dangle': ['error', {
arrays: 'never',
objects: 'never',
imports: 'never',
exports: 'never',
functions: 'never'
}]
}
}
]

View File

@@ -0,0 +1,8 @@
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

View File

@@ -0,0 +1 @@
DROP TABLE IF EXISTS users;

View File

@@ -0,0 +1,12 @@
CREATE TABLE tasks (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
author_id INT NOT NULL,
assigned_user_id INT,
filename VARCHAR(255),
status VARCHAR(50) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (author_id) REFERENCES users(id),
FOREIGN KEY (assigned_user_id) REFERENCES users(id)
);

View File

@@ -0,0 +1 @@
DROP TABLE IF EXISTS tasks;

View File

@@ -0,0 +1,7 @@
CREATE TABLE user_tasks (
user_id INT NOT NULL,
task_id INT NOT NULL,
PRIMARY KEY (user_id, task_id),
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (task_id) REFERENCES tasks(id)
);

View File

@@ -0,0 +1 @@
DROP TABLE IF EXISTS user_tasks;

View File

@@ -0,0 +1,4 @@
CREATE TABLE roles (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL
);

View File

@@ -0,0 +1 @@
DROP TABLE IF EXISTS roles;

View File

@@ -0,0 +1,7 @@
CREATE TABLE user_roles (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
role_id INT NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE
);

View File

@@ -0,0 +1 @@
DROP TABLE IF EXISTS user_roles;

7363
src/Managing.Web3Proxy/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,74 @@
{
"name": "web3-proxy",
"version": "1.0.0",
"description": "The official Managing Web3 Proxy",
"main": "app.js",
"type": "module",
"directories": {
"test": "test"
},
"scripts": {
"start": "fastify start -l info dist/app.js",
"build": "tsc",
"watch": "tsc -w",
"dev": "npm run build && concurrently -k -p \"[{name}]\" -n \"TypeScript,App\" -c \"yellow.bold,cyan.bold\" \"npm:watch\" \"npm:dev:start\"",
"dev:start": "npm run build && fastify start -d --ignore-watch=.ts$ -w -l info -P dist/app.js",
"test": "npm run db:seed && c8 npm run test:run",
"test:run": "tsx --test ./test/**/*.ts",
"test:single": "tsc && tsx --test",
"standalone": "npm run build && node --env-file=.env dist/server.js",
"lint": "eslint --ignore-pattern=dist",
"lint:fix": "npm run lint -- --fix",
"db:create": "tsx --env-file=.env ./scripts/create-database.ts",
"db:drop": "tsx --env-file=.env ./scripts/drop-database.ts",
"db:migrate": "tsx --env-file=.env ./scripts/migrate.ts",
"db:seed": "tsx --env-file=.env ./scripts/seed-database.ts"
},
"keywords": [],
"author": "Oda",
"license": "MIT",
"dependencies": {
"@fastify/autoload": "^6.0.0",
"@fastify/cookie": "^11.0.1",
"@fastify/cors": "^11.0.0",
"@fastify/env": "^5.0.1",
"@fastify/helmet": "^13.0.0",
"@fastify/multipart": "^9.0.1",
"@fastify/rate-limit": "^10.0.1",
"@fastify/sensible": "^6.0.1",
"@fastify/session": "^11.0.1",
"@fastify/static": "^8.0.2",
"@fastify/swagger": "^9.0.0",
"@fastify/swagger-ui": "^5.0.1",
"@fastify/type-provider-typebox": "^5.0.0",
"@fastify/under-pressure": "^9.0.1",
"@privy-io/server-auth": "^1.18.12",
"@sinclair/typebox": "^0.34.11",
"canonicalize": "^2.0.0",
"concurrently": "^9.0.1",
"cross-fetch": "^4.1.0",
"csv-stringify": "^6.5.2",
"ethers": "^6.13.5",
"fastify": "^5.0.0",
"fastify-cli": "^7.3.0",
"fastify-plugin": "^5.0.1",
"form-data": "^4.0.1",
"knex": "^3.1.0",
"mysql2": "^3.11.3",
"postgrator": "^8.0.0",
"query-string": "^9.1.1",
"viem": "^2.23.15",
"vitest": "^3.0.8",
"zod": "^3.24.2"
},
"devDependencies": {
"@types/node": "^22.5.5",
"c8": "^10.1.3",
"eslint": "^9.11.0",
"fastify-tsconfig": "^3.0.0",
"glob": "^11.0.0",
"neostandard": "^0.12.0",
"tsx": "^4.19.1",
"typescript": "~5.8.2"
}
}

BIN
src/Managing.Web3Proxy/src/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,90 @@
/**
* If you would like to turn your application into a standalone executable, look at server.js file
*/
import path from 'node:path'
import fastifyAutoload from '@fastify/autoload'
import {FastifyInstance, FastifyPluginOptions} from 'fastify'
export const options = {
ajv: {
customOptions: {
coerceTypes: 'array',
removeAdditional: 'all'
}
}
}
export default async function serviceApp (
fastify: FastifyInstance,
opts: FastifyPluginOptions
) {
delete opts.skipOverride // This option only serves testing purpose
// This loads all external plugins defined in plugins/external
// those should be registered first as your custom plugins might depend on them
// await fastify.register(fastifyAutoload, {
// dir: path.join(import.meta.dirname, 'plugins/external'),
// options: { ...opts }
// })
// This loads all your custom plugins defined in plugins/custom
// those should be support plugins that are reused
// through your application
fastify.register(fastifyAutoload, {
dir: path.join(import.meta.dirname, 'plugins/custom'),
options: { ...opts }
})
// This loads all plugins defined in routes
// define your routes in one of these
fastify.register(fastifyAutoload, {
dir: path.join(import.meta.dirname, 'routes'),
autoHooks: true,
cascadeHooks: true,
options: { ...opts }
})
fastify.setErrorHandler((err, request, reply) => {
fastify.log.error(
{
err,
request: {
method: request.method,
url: request.url,
query: request.query,
params: request.params
}
},
'Unhandled error occurred'
)
reply.code(err.statusCode ?? 500)
let message = 'Internal Server Error'
if (err.statusCode && err.statusCode < 500) {
message = err.message
}
return { message }
})
// An attacker could search for valid URLs if your 404 error handling is not rate limited.
fastify.setNotFoundHandler(
(request, reply) => {
request.log.warn(
{
request: {
method: request.method,
url: request.url,
query: request.query,
params: request.params
}
},
'Resource not found'
)
reply.code(404)
return { message: 'Not Found' }
})
}

Binary file not shown.

View File

@@ -0,0 +1,590 @@
//----------------------
// <auto-generated>
// Generated using the NSwag toolchain v14.2.0.0 (NJsonSchema v11.1.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
// </auto-generated>
//----------------------
/* tslint:disable */
/* eslint-disable */
// ReSharper disable InconsistentNaming
export interface Account {
name: string;
exchange: TradingExchanges;
type: AccountType;
key?: string | null;
secret?: string | null;
user?: User | null;
balances?: Balance[] | null;
}
export enum TradingExchanges {
Binance = "Binance",
Kraken = "Kraken",
Ftx = "Ftx",
Evm = "Evm",
GmxV2 = "GmxV2",
}
export enum AccountType {
Cex = "Cex",
Trader = "Trader",
Watch = "Watch",
Auth = "Auth",
Privy = "Privy",
}
export interface User {
name?: string | null;
accounts?: Account[] | null;
}
export interface Balance {
tokenImage?: string | null;
tokenName?: string | null;
amount?: number;
price?: number;
value?: number;
tokenAdress?: string | null;
chain?: Chain | null;
}
export interface Chain {
id?: string | null;
rpcUrl?: string | null;
name?: string | null;
chainId?: number;
}
export interface Backtest {
id: string;
finalPnl: number;
winRate: number;
growthPercentage: number;
hodlPercentage: number;
ticker: Ticker;
scenario: string;
positions: Position[];
signals: Signal[];
timeframe: Timeframe;
botType: BotType;
accountName: string;
candles: Candle[];
startDate: Date;
endDate: Date;
statistics: PerformanceMetrics;
fees: number;
walletBalances: KeyValuePairOfDateTimeAndDecimal[];
optimizedMoneyManagement: MoneyManagement;
moneyManagement: MoneyManagement;
user: User;
strategiesValues: { [key in keyof typeof StrategyType]?: StrategiesResultBase; };
score: number;
}
export enum Ticker {
AAVE = "AAVE",
ADA = "ADA",
APE = "APE",
ALGO = "ALGO",
ARB = "ARB",
ATOM = "ATOM",
AVAX = "AVAX",
BNB = "BNB",
BTC = "BTC",
BAL = "BAL",
CHZ = "CHZ",
COMP = "COMP",
CRO = "CRO",
CRV = "CRV",
DOGE = "DOGE",
DOT = "DOT",
DYDX = "DYDX",
ENS = "ENS",
ETC = "ETC",
ETH = "ETH",
FIL = "FIL",
FLM = "FLM",
FTM = "FTM",
GALA = "GALA",
GMX = "GMX",
GRT = "GRT",
IMX = "IMX",
JASMY = "JASMY",
KSM = "KSM",
LDO = "LDO",
LINK = "LINK",
LRC = "LRC",
LTC = "LTC",
MANA = "MANA",
MATIC = "MATIC",
MKR = "MKR",
NEAR = "NEAR",
OP = "OP",
PEPE = "PEPE",
QTUM = "QTUM",
REN = "REN",
ROSE = "ROSE",
RSR = "RSR",
RUNE = "RUNE",
SAND = "SAND",
SOL = "SOL",
SRM = "SRM",
SUSHI = "SUSHI",
THETA = "THETA",
UNI = "UNI",
USDC = "USDC",
USDT = "USDT",
WIF = "WIF",
XMR = "XMR",
XRP = "XRP",
XTZ = "XTZ",
SHIB = "SHIB",
STX = "STX",
ORDI = "ORDI",
Unknown = "Unknown",
}
export interface Position {
accountName: string;
date: Date;
originDirection: TradeDirection;
ticker: Ticker;
moneyManagement: MoneyManagement;
open: Trade;
stopLoss: Trade;
takeProfit1: Trade;
takeProfit2?: Trade | null;
profitAndLoss?: ProfitAndLoss | null;
status: PositionStatus;
signalIdentifier?: string | null;
identifier: string;
initiator: PositionInitiator;
user?: User | null;
}
export enum TradeDirection {
None = "None",
Short = "Short",
Long = "Long",
}
export interface MoneyManagement {
name: string;
timeframe: Timeframe;
balanceAtRisk: number;
stopLoss: number;
takeProfit: number;
leverage: number;
user?: User | null;
}
export enum Timeframe {
FiveMinutes = "FiveMinutes",
FifteenMinutes = "FifteenMinutes",
ThirtyMinutes = "ThirtyMinutes",
OneHour = "OneHour",
FourHour = "FourHour",
OneDay = "OneDay",
}
export interface Trade {
fee?: number;
date: Date;
direction: TradeDirection;
status: TradeStatus;
tradeType: TradeType;
ticker: Ticker;
quantity: number;
price: number;
leverage?: number;
exchangeOrderId: string;
message?: string | null;
}
export enum TradeStatus {
PendingOpen = "PendingOpen",
Requested = "Requested",
Cancelled = "Cancelled",
Filled = "Filled",
}
export enum TradeType {
Limit = "Limit",
Market = "Market",
StopMarket = "StopMarket",
StopLimit = "StopLimit",
StopLoss = "StopLoss",
TakeProfit = "TakeProfit",
StopLossProfit = "StopLossProfit",
StopLossProfitLimit = "StopLossProfitLimit",
StopLossLimit = "StopLossLimit",
TakeProfitLimit = "TakeProfitLimit",
TrailingStop = "TrailingStop",
TrailingStopLimit = "TrailingStopLimit",
StopLossAndLimit = "StopLossAndLimit",
SettlePosition = "SettlePosition",
}
export interface ProfitAndLoss {
realized?: number;
net?: number;
averageOpenPrice?: number;
}
export enum PositionStatus {
New = "New",
Canceled = "Canceled",
Rejected = "Rejected",
Updating = "Updating",
PartiallyFilled = "PartiallyFilled",
Filled = "Filled",
Flipped = "Flipped",
Finished = "Finished",
}
export enum PositionInitiator {
PaperTrading = "PaperTrading",
Bot = "Bot",
User = "User",
CopyTrading = "CopyTrading",
}
export interface ValueObject {
}
export interface Signal extends ValueObject {
status: SignalStatus;
direction: TradeDirection;
confidence: Confidence;
timeframe: Timeframe;
date: Date;
candle: Candle;
identifier: string;
ticker: Ticker;
exchange: TradingExchanges;
strategyType: StrategyType;
signalType: SignalType;
user?: User | null;
}
export enum SignalStatus {
WaitingForPosition = "WaitingForPosition",
PositionOpen = "PositionOpen",
Expired = "Expired",
}
export enum Confidence {
Low = "Low",
Medium = "Medium",
High = "High",
None = "None",
}
export interface Candle {
exchange: TradingExchanges;
ticker: string;
openTime: Date;
date: Date;
open: number;
close: number;
volume?: number;
high: number;
low: number;
baseVolume?: number;
quoteVolume?: number;
tradeCount?: number;
takerBuyBaseVolume?: number;
takerBuyQuoteVolume?: number;
timeframe: Timeframe;
}
export enum StrategyType {
RsiDivergence = "RsiDivergence",
RsiDivergenceConfirm = "RsiDivergenceConfirm",
MacdCross = "MacdCross",
EmaCross = "EmaCross",
ThreeWhiteSoldiers = "ThreeWhiteSoldiers",
SuperTrend = "SuperTrend",
ChandelierExit = "ChandelierExit",
EmaTrend = "EmaTrend",
Composite = "Composite",
StochRsiTrend = "StochRsiTrend",
Stc = "Stc",
StDev = "StDev",
LaggingStc = "LaggingStc",
SuperTrendCrossEma = "SuperTrendCrossEma",
}
export enum SignalType {
Signal = "Signal",
Trend = "Trend",
Context = "Context",
}
export enum BotType {
SimpleBot = "SimpleBot",
ScalpingBot = "ScalpingBot",
FlippingBot = "FlippingBot",
}
export interface PerformanceMetrics {
count?: number;
sharpeRatio?: number;
maxDrawdown?: number;
maxDrawdownPc?: number;
maxDrawdownRecoveryTime?: string;
winningTrades?: number;
loosingTrades?: number;
totalPnL?: number;
}
export interface KeyValuePairOfDateTimeAndDecimal {
key?: Date;
value?: number;
}
export interface StrategiesResultBase {
ema?: EmaResult[] | null;
macd?: MacdResult[] | null;
rsi?: RsiResult[] | null;
stoch?: StochResult[] | null;
stochRsi?: StochRsiResult[] | null;
bollingerBands?: BollingerBandsResult[] | null;
chandelierShort?: ChandelierResult[] | null;
stc?: StcResult[] | null;
stdDev?: StdDevResult[] | null;
superTrend?: SuperTrendResult[] | null;
chandelierLong?: ChandelierResult[] | null;
}
export interface ResultBase {
date?: Date;
}
export interface EmaResult extends ResultBase {
ema?: number | null;
"skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}
export interface MacdResult extends ResultBase {
macd?: number | null;
signal?: number | null;
histogram?: number | null;
fastEma?: number | null;
slowEma?: number | null;
"skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}
export interface RsiResult extends ResultBase {
rsi?: number | null;
"skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}
/** Stochastic indicator results includes aliases for those who prefer the simpler K,D,J outputs. See documentation for more information. */
export interface StochResult extends ResultBase {
oscillator?: number | null;
signal?: number | null;
percentJ?: number | null;
k?: number | null;
d?: number | null;
j?: number | null;
"skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}
export interface StochRsiResult extends ResultBase {
stochRsi?: number | null;
signal?: number | null;
"skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}
export interface BollingerBandsResult extends ResultBase {
sma?: number | null;
upperBand?: number | null;
lowerBand?: number | null;
percentB?: number | null;
zScore?: number | null;
width?: number | null;
"skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}
export interface ChandelierResult extends ResultBase {
chandelierExit?: number | null;
"skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}
export interface StcResult extends ResultBase {
stc?: number | null;
"skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}
export interface StdDevResult extends ResultBase {
stdDev?: number | null;
mean?: number | null;
zScore?: number | null;
stdDevSma?: number | null;
"skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}
export interface SuperTrendResult extends ResultBase {
superTrend?: number | null;
upperBand?: number | null;
lowerBand?: number | null;
}
export interface StartBotRequest {
botType: BotType;
botName: string;
ticker: Ticker;
timeframe: Timeframe;
isForWatchOnly: boolean;
scenario: string;
accountName: string;
moneyManagementName: string;
}
export interface TradingBot {
name: string;
status: string;
signals: Signal[];
positions: Position[];
candles: Candle[];
winRate: number;
profitAndLoss: number;
timeframe: Timeframe;
ticker: Ticker;
scenario: string;
isForWatchingOnly: boolean;
botType: BotType;
accountName: string;
moneyManagement: MoneyManagement;
}
export interface SpotlightOverview {
spotlights: Spotlight[];
dateTime: Date;
identifier?: string;
scenarioCount?: number;
}
export interface Spotlight {
scenario: Scenario;
tickerSignals: TickerSignal[];
}
export interface Scenario {
name?: string | null;
strategies?: Strategy[] | null;
loopbackPeriod?: number | null;
user?: User | null;
}
export interface Strategy {
name?: string | null;
type?: StrategyType;
signalType?: SignalType;
minimumHistory?: number;
period?: number | null;
fastPeriods?: number | null;
slowPeriods?: number | null;
signalPeriods?: number | null;
multiplier?: number | null;
smoothPeriods?: number | null;
stochPeriods?: number | null;
cyclePeriods?: number | null;
user?: User | null;
}
export interface TickerSignal {
ticker: Ticker;
fiveMinutes: Signal[];
fifteenMinutes: Signal[];
oneHour: Signal[];
fourHour: Signal[];
oneDay: Signal[];
}
export enum RiskLevel {
Low = "Low",
Medium = "Medium",
High = "High",
Adaptive = "Adaptive",
}
export interface LoginRequest {
name: string;
address: string;
signature: string;
message: string;
}
export interface Workflow {
name: string;
usage: WorkflowUsage;
flows: IFlow[];
description: string;
}
export enum WorkflowUsage {
Trading = "Trading",
Task = "Task",
}
export interface IFlow {
id: string;
name: string;
type: FlowType;
description: string;
acceptedInputs: FlowOutput[];
children?: IFlow[] | null;
parameters: FlowParameter[];
parentId?: string;
output?: string | null;
outputTypes: FlowOutput[];
}
export enum FlowType {
RsiDivergence = "RsiDivergence",
FeedTicker = "FeedTicker",
OpenPosition = "OpenPosition",
}
export enum FlowOutput {
Signal = "Signal",
Candles = "Candles",
Position = "Position",
MoneyManagement = "MoneyManagement",
}
export interface FlowParameter {
value?: any | null;
name?: string | null;
}
export interface SyntheticWorkflow {
name: string;
usage: WorkflowUsage;
description: string;
flows: SyntheticFlow[];
}
export interface SyntheticFlow {
id: string;
parentId?: string | null;
type: FlowType;
parameters: SyntheticFlowParameter[];
}
export interface SyntheticFlowParameter {
value: string;
name: string;
}
export interface FileResponse {
data: Blob;
status: number;
fileName?: string;
headers?: { [name: string]: any };
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,442 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "ERC721",
"sourceName": "contracts/libraries/token/ERC721/ERC721.sol",
"abi": [
{
"inputs": [
{
"internalType": "string",
"name": "name",
"type": "string"
},
{
"internalType": "string",
"name": "symbol",
"type": "string"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "approved",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "operator",
"type": "address"
},
{
"indexed": false,
"internalType": "bool",
"name": "approved",
"type": "bool"
}
],
"name": "ApprovalForAll",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "approve",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "baseURI",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "getApproved",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "operator",
"type": "address"
}
],
"name": "isApprovedForAll",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "mint",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "ownerOf",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "safeTransferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "_data",
"type": "bytes"
}
],
"name": "safeTransferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "operator",
"type": "address"
},
{
"internalType": "bool",
"name": "approved",
"type": "bool"
}
],
"name": "setApprovalForAll",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes4",
"name": "interfaceId",
"type": "bytes4"
}
],
"name": "supportsInterface",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "index",
"type": "uint256"
}
],
"name": "tokenByIndex",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "uint256",
"name": "index",
"type": "uint256"
}
],
"name": "tokenOfOwnerByIndex",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "tokenURI",
"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": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,522 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "GMT",
"sourceName": "contracts/gambit-token/GMT.sol",
"abi": [
{
"inputs": [
{
"internalType": "uint256",
"name": "_initialSupply",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"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": 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"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "addAdmin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_recipient",
"type": "address"
}
],
"name": "addBlockedRecipient",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_msgSender",
"type": "address"
}
],
"name": "addMsgSender",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "admins",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_owner",
"type": "address"
},
{
"internalType": "address",
"name": "_spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "allowances",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "allowedMsgSenders",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"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": [],
"name": "beginMigration",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "blockedRecipients",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "endMigration",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "gov",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "hasActiveMigration",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "migrationTime",
"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": "_account",
"type": "address"
}
],
"name": "removeAdmin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_recipient",
"type": "address"
}
],
"name": "removeBlockedRecipient",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_msgSender",
"type": "address"
}
],
"name": "removeMsgSender",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_gov",
"type": "address"
}
],
"name": "setGov",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_migrationTime",
"type": "uint256"
}
],
"name": "setNextMigrationTime",
"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": "_recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_sender",
"type": "address"
},
{
"internalType": "address",
"name": "_recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"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"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -0,0 +1,592 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "GlpManager",
"sourceName": "contracts/core/GlpManager.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_usdg",
"type": "address"
},
{
"internalType": "address",
"name": "_glp",
"type": "address"
},
{
"internalType": "uint256",
"name": "_cooldownDuration",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "account",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "token",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "aumInUsdg",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "glpSupply",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "usdgAmount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "mintAmount",
"type": "uint256"
}
],
"name": "AddLiquidity",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "account",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "token",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "glpAmount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "aumInUsdg",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "glpSupply",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "usdgAmount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountOut",
"type": "uint256"
}
],
"name": "RemoveLiquidity",
"type": "event"
},
{
"inputs": [],
"name": "MAX_COOLDOWN_DURATION",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "PRICE_PRECISION",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "USDG_DECIMALS",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_token",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_minUsdg",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_minGlp",
"type": "uint256"
}
],
"name": "addLiquidity",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_fundingAccount",
"type": "address"
},
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address",
"name": "_token",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_minUsdg",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_minGlp",
"type": "uint256"
}
],
"name": "addLiquidityForAccount",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "aumAddition",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "aumDeduction",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "cooldownDuration",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bool",
"name": "maximise",
"type": "bool"
}
],
"name": "getAum",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bool",
"name": "maximise",
"type": "bool"
}
],
"name": "getAumInUsdg",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getAums",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "glp",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gov",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "inPrivateMode",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"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": "lastAddedAt",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_tokenOut",
"type": "address"
},
{
"internalType": "uint256",
"name": "_glpAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_minOut",
"type": "uint256"
},
{
"internalType": "address",
"name": "_receiver",
"type": "address"
}
],
"name": "removeLiquidity",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address",
"name": "_tokenOut",
"type": "address"
},
{
"internalType": "uint256",
"name": "_glpAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_minOut",
"type": "uint256"
},
{
"internalType": "address",
"name": "_receiver",
"type": "address"
}
],
"name": "removeLiquidityForAccount",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_aumAddition",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_aumDeduction",
"type": "uint256"
}
],
"name": "setAumAdjustment",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_cooldownDuration",
"type": "uint256"
}
],
"name": "setCooldownDuration",
"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": "_inPrivateMode",
"type": "bool"
}
],
"name": "setInPrivateMode",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "usdg",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "vault",
"outputs": [
{
"internalType": "contract IVault",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,707 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "GlvRouter",
"sourceName": "contracts/router/GlvRouter.sol",
"abi": [
{
"inputs": [
{
"internalType": "contract Router",
"name": "_router",
"type": "address"
},
{
"internalType": "contract RoleStore",
"name": "_roleStore",
"type": "address"
},
{
"internalType": "contract DataStore",
"name": "_dataStore",
"type": "address"
},
{
"internalType": "contract EventEmitter",
"name": "_eventEmitter",
"type": "address"
},
{
"internalType": "contract IGlvHandler",
"name": "_glvHandler",
"type": "address"
},
{
"internalType": "contract IExternalHandler",
"name": "_externalHandler",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "EmptyGlvDeposit",
"type": "error"
},
{
"inputs": [],
"name": "EmptyGlvWithdrawal",
"type": "error"
},
{
"inputs": [],
"name": "EmptyHoldingAddress",
"type": "error"
},
{
"inputs": [],
"name": "EmptyReceiver",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "token",
"type": "address"
}
],
"name": "EmptyTokenTranferGasLimit",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "msgSender",
"type": "address"
}
],
"name": "InvalidNativeTokenSender",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "TokenTransferError",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "msgSender",
"type": "address"
},
{
"internalType": "string",
"name": "role",
"type": "string"
}
],
"name": "Unauthorized",
"type": "error"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
}
],
"name": "cancelGlvDeposit",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
}
],
"name": "cancelGlvWithdrawal",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"components": [
{
"internalType": "address",
"name": "glv",
"type": "address"
},
{
"internalType": "address",
"name": "market",
"type": "address"
},
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "address",
"name": "callbackContract",
"type": "address"
},
{
"internalType": "address",
"name": "uiFeeReceiver",
"type": "address"
},
{
"internalType": "address",
"name": "initialLongToken",
"type": "address"
},
{
"internalType": "address",
"name": "initialShortToken",
"type": "address"
},
{
"internalType": "address[]",
"name": "longTokenSwapPath",
"type": "address[]"
},
{
"internalType": "address[]",
"name": "shortTokenSwapPath",
"type": "address[]"
},
{
"internalType": "uint256",
"name": "minGlvTokens",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "executionFee",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "callbackGasLimit",
"type": "uint256"
},
{
"internalType": "bool",
"name": "shouldUnwrapNativeToken",
"type": "bool"
},
{
"internalType": "bool",
"name": "isMarketTokenDeposit",
"type": "bool"
}
],
"internalType": "struct GlvDepositUtils.CreateGlvDepositParams",
"name": "params",
"type": "tuple"
}
],
"name": "createGlvDeposit",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"components": [
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "address",
"name": "callbackContract",
"type": "address"
},
{
"internalType": "address",
"name": "uiFeeReceiver",
"type": "address"
},
{
"internalType": "address",
"name": "market",
"type": "address"
},
{
"internalType": "address",
"name": "glv",
"type": "address"
},
{
"internalType": "address[]",
"name": "longTokenSwapPath",
"type": "address[]"
},
{
"internalType": "address[]",
"name": "shortTokenSwapPath",
"type": "address[]"
},
{
"internalType": "uint256",
"name": "minLongTokenAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "minShortTokenAmount",
"type": "uint256"
},
{
"internalType": "bool",
"name": "shouldUnwrapNativeToken",
"type": "bool"
},
{
"internalType": "uint256",
"name": "executionFee",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "callbackGasLimit",
"type": "uint256"
}
],
"internalType": "struct GlvWithdrawalUtils.CreateGlvWithdrawalParams",
"name": "params",
"type": "tuple"
}
],
"name": "createGlvWithdrawal",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "dataStore",
"outputs": [
{
"internalType": "contract DataStore",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "eventEmitter",
"outputs": [
{
"internalType": "contract EventEmitter",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "externalHandler",
"outputs": [
{
"internalType": "contract IExternalHandler",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "glvHandler",
"outputs": [
{
"internalType": "contract IGlvHandler",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "externalCallTargets",
"type": "address[]"
},
{
"internalType": "bytes[]",
"name": "externalCallDataList",
"type": "bytes[]"
},
{
"internalType": "address[]",
"name": "refundTokens",
"type": "address[]"
},
{
"internalType": "address[]",
"name": "refundReceivers",
"type": "address[]"
}
],
"name": "makeExternalCalls",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes[]",
"name": "data",
"type": "bytes[]"
}
],
"name": "multicall",
"outputs": [
{
"internalType": "bytes[]",
"name": "results",
"type": "bytes[]"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "roleStore",
"outputs": [
{
"internalType": "contract RoleStore",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "router",
"outputs": [
{
"internalType": "contract Router",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "sendNativeToken",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "sendTokens",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "sendWnt",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
},
{
"components": [
{
"internalType": "address[]",
"name": "primaryTokens",
"type": "address[]"
},
{
"components": [
{
"internalType": "uint256",
"name": "min",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "max",
"type": "uint256"
}
],
"internalType": "struct Price.Props[]",
"name": "primaryPrices",
"type": "tuple[]"
},
{
"internalType": "uint256",
"name": "minTimestamp",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "maxTimestamp",
"type": "uint256"
}
],
"internalType": "struct OracleUtils.SimulatePricesParams",
"name": "simulatedOracleParams",
"type": "tuple"
}
],
"name": "simulateExecuteGlvDeposit",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
},
{
"components": [
{
"internalType": "address[]",
"name": "primaryTokens",
"type": "address[]"
},
{
"components": [
{
"internalType": "uint256",
"name": "min",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "max",
"type": "uint256"
}
],
"internalType": "struct Price.Props[]",
"name": "primaryPrices",
"type": "tuple[]"
},
{
"internalType": "uint256",
"name": "minTimestamp",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "maxTimestamp",
"type": "uint256"
}
],
"internalType": "struct OracleUtils.SimulatePricesParams",
"name": "simulatedOracleParams",
"type": "tuple"
}
],
"name": "simulateExecuteGlvWithdrawal",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"components": [
{
"internalType": "address[]",
"name": "primaryTokens",
"type": "address[]"
},
{
"components": [
{
"internalType": "uint256",
"name": "min",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "max",
"type": "uint256"
}
],
"internalType": "struct Price.Props[]",
"name": "primaryPrices",
"type": "tuple[]"
},
{
"internalType": "uint256",
"name": "minTimestamp",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "maxTimestamp",
"type": "uint256"
}
],
"internalType": "struct OracleUtils.SimulatePricesParams",
"name": "simulatedOracleParams",
"type": "tuple"
}
],
"name": "simulateExecuteLatestGlvDeposit",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"components": [
{
"internalType": "address[]",
"name": "primaryTokens",
"type": "address[]"
},
{
"components": [
{
"internalType": "uint256",
"name": "min",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "max",
"type": "uint256"
}
],
"internalType": "struct Price.Props[]",
"name": "primaryPrices",
"type": "tuple[]"
},
{
"internalType": "uint256",
"name": "minTimestamp",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "maxTimestamp",
"type": "uint256"
}
],
"internalType": "struct OracleUtils.SimulatePricesParams",
"name": "simulatedOracleParams",
"type": "tuple"
}
],
"name": "simulateExecuteLatestGlvWithdrawal",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
}
]
}

View File

@@ -0,0 +1,657 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "GmxMigrator",
"sourceName": "contracts/gmx/GmxMigrator.sol",
"abi": [
{
"inputs": [
{
"internalType": "uint256",
"name": "_minAuthorizations",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "bytes32",
"name": "action",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "uint256",
"name": "nonce",
"type": "uint256"
}
],
"name": "ClearAction",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "bytes32",
"name": "action",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "uint256",
"name": "nonce",
"type": "uint256"
}
],
"name": "SignAction",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "token",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "action",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "uint256",
"name": "nonce",
"type": "uint256"
}
],
"name": "SignalApprove",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "bytes32",
"name": "action",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "uint256",
"name": "nonce",
"type": "uint256"
}
],
"name": "SignalPendingAction",
"type": "event"
},
{
"inputs": [],
"name": "actionsNonce",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "admin",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "ammRouter",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_token",
"type": "address"
},
{
"internalType": "address",
"name": "_spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_nonce",
"type": "uint256"
}
],
"name": "approve",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "caps",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "endMigration",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_token",
"type": "address"
}
],
"name": "getIouToken",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getTokenAmounts",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_token",
"type": "address"
}
],
"name": "getTokenPrice",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gmxPrice",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_ammRouter",
"type": "address"
},
{
"internalType": "uint256",
"name": "_gmxPrice",
"type": "uint256"
},
{
"internalType": "address[]",
"name": "_signers",
"type": "address[]"
},
{
"internalType": "address[]",
"name": "_whitelistedTokens",
"type": "address[]"
},
{
"internalType": "address[]",
"name": "_iouTokens",
"type": "address[]"
},
{
"internalType": "uint256[]",
"name": "_prices",
"type": "uint256[]"
},
{
"internalType": "uint256[]",
"name": "_caps",
"type": "uint256[]"
},
{
"internalType": "address[]",
"name": "_lpTokens",
"type": "address[]"
},
{
"internalType": "address[]",
"name": "_lpTokenAs",
"type": "address[]"
},
{
"internalType": "address[]",
"name": "_lpTokenBs",
"type": "address[]"
}
],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "iouTokens",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "isInitialized",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "isMigrationActive",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "isSigner",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "lpTokenAs",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "lpTokenBs",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "lpTokens",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_token",
"type": "address"
},
{
"internalType": "uint256",
"name": "_tokenAmount",
"type": "uint256"
}
],
"name": "migrate",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "minAuthorizations",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"name": "pendingActions",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "prices",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_token",
"type": "address"
},
{
"internalType": "address",
"name": "_spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_nonce",
"type": "uint256"
}
],
"name": "signApprove",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_token",
"type": "address"
},
{
"internalType": "address",
"name": "_spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "signalApprove",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"name": "signedActions",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "signers",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "tokenAmounts",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "whitelistedTokens",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,696 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "MintableBaseToken",
"sourceName": "contracts/tokens/MintableBaseToken.sol",
"abi": [
{
"inputs": [
{
"internalType": "string",
"name": "_name",
"type": "string"
},
{
"internalType": "string",
"name": "_symbol",
"type": "string"
},
{
"internalType": "uint256",
"name": "_initialSupply",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"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": 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"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "addAdmin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "addNonStakingAccount",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "admins",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_owner",
"type": "address"
},
{
"internalType": "address",
"name": "_spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "allowances",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"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": "_account",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "burn",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_receiver",
"type": "address"
}
],
"name": "claim",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gov",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "inPrivateTransferMode",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"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": "isMinter",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "mint",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "nonStakingAccounts",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "nonStakingSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address",
"name": "_receiver",
"type": "address"
}
],
"name": "recoverClaim",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "removeAdmin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "removeNonStakingAccount",
"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": "_inPrivateTransferMode",
"type": "bool"
}
],
"name": "setInPrivateTransferMode",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "_name",
"type": "string"
},
{
"internalType": "string",
"name": "_symbol",
"type": "string"
}
],
"name": "setInfo",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_minter",
"type": "address"
},
{
"internalType": "bool",
"name": "_isActive",
"type": "bool"
}
],
"name": "setMinter",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_yieldTrackers",
"type": "address[]"
}
],
"name": "setYieldTrackers",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "stakedBalance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalStaked",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_sender",
"type": "address"
},
{
"internalType": "address",
"name": "_recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"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"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "yieldTrackers",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -0,0 +1,333 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Multicall2",
"sourceName": "contracts/mock/Multicall2.sol",
"abi": [
{
"inputs": [
{
"components": [
{
"internalType": "address",
"name": "target",
"type": "address"
},
{
"internalType": "bytes",
"name": "callData",
"type": "bytes"
}
],
"internalType": "struct Multicall2.Call[]",
"name": "calls",
"type": "tuple[]"
}
],
"name": "aggregate",
"outputs": [
{
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
},
{
"internalType": "bytes[]",
"name": "returnData",
"type": "bytes[]"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"components": [
{
"internalType": "address",
"name": "target",
"type": "address"
},
{
"internalType": "bytes",
"name": "callData",
"type": "bytes"
}
],
"internalType": "struct Multicall2.Call[]",
"name": "calls",
"type": "tuple[]"
}
],
"name": "blockAndAggregate",
"outputs": [
{
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
},
{
"internalType": "bytes32",
"name": "blockHash",
"type": "bytes32"
},
{
"components": [
{
"internalType": "bool",
"name": "success",
"type": "bool"
},
{
"internalType": "bytes",
"name": "returnData",
"type": "bytes"
}
],
"internalType": "struct Multicall2.Result[]",
"name": "returnData",
"type": "tuple[]"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
}
],
"name": "getBlockHash",
"outputs": [
{
"internalType": "bytes32",
"name": "blockHash",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getBlockNumber",
"outputs": [
{
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getCurrentBlockCoinbase",
"outputs": [
{
"internalType": "address",
"name": "coinbase",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getCurrentBlockDifficulty",
"outputs": [
{
"internalType": "uint256",
"name": "difficulty",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getCurrentBlockGasLimit",
"outputs": [
{
"internalType": "uint256",
"name": "gaslimit",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getCurrentBlockTimestamp",
"outputs": [
{
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "addr",
"type": "address"
}
],
"name": "getEthBalance",
"outputs": [
{
"internalType": "uint256",
"name": "balance",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getL1BlockNumber",
"outputs": [
{
"internalType": "uint256",
"name": "l1BlockNumber",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getLastBlockHash",
"outputs": [
{
"internalType": "bytes32",
"name": "blockHash",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bool",
"name": "requireSuccess",
"type": "bool"
},
{
"components": [
{
"internalType": "address",
"name": "target",
"type": "address"
},
{
"internalType": "bytes",
"name": "callData",
"type": "bytes"
}
],
"internalType": "struct Multicall2.Call[]",
"name": "calls",
"type": "tuple[]"
}
],
"name": "tryAggregate",
"outputs": [
{
"components": [
{
"internalType": "bool",
"name": "success",
"type": "bool"
},
{
"internalType": "bytes",
"name": "returnData",
"type": "bytes"
}
],
"internalType": "struct Multicall2.Result[]",
"name": "returnData",
"type": "tuple[]"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bool",
"name": "requireSuccess",
"type": "bool"
},
{
"components": [
{
"internalType": "address",
"name": "target",
"type": "address"
},
{
"internalType": "bytes",
"name": "callData",
"type": "bytes"
}
],
"internalType": "struct Multicall2.Call[]",
"name": "calls",
"type": "tuple[]"
}
],
"name": "tryBlockAndAggregate",
"outputs": [
{
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
},
{
"internalType": "bytes32",
"name": "blockHash",
"type": "bytes32"
},
{
"components": [
{
"internalType": "bool",
"name": "success",
"type": "bool"
},
{
"internalType": "bytes",
"name": "returnData",
"type": "bytes"
}
],
"internalType": "struct Multicall2.Result[]",
"name": "returnData",
"type": "tuple[]"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,111 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "OrderBookReader",
"sourceName": "contracts/peripherals/OrderBookReader.sol",
"abi": [
{
"inputs": [
{
"internalType": "address payable",
"name": "_orderBookAddress",
"type": "address"
},
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "uint256[]",
"name": "_indices",
"type": "uint256[]"
}
],
"name": "getDecreaseOrders",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
},
{
"internalType": "address[]",
"name": "",
"type": "address[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address payable",
"name": "_orderBookAddress",
"type": "address"
},
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "uint256[]",
"name": "_indices",
"type": "uint256[]"
}
],
"name": "getIncreaseOrders",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
},
{
"internalType": "address[]",
"name": "",
"type": "address[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address payable",
"name": "_orderBookAddress",
"type": "address"
},
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "uint256[]",
"name": "_indices",
"type": "uint256[]"
}
],
"name": "getSwapOrders",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
},
{
"internalType": "address[]",
"name": "",
"type": "address[]"
}
],
"stateMutability": "view",
"type": "function"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -0,0 +1,122 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "OrderExecutor",
"sourceName": "contracts/core/OrderExecutor.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_orderBook",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [
{
"internalType": "address",
"name": "_address",
"type": "address"
},
{
"internalType": "uint256",
"name": "_orderIndex",
"type": "uint256"
},
{
"internalType": "address payable",
"name": "_feeReceiver",
"type": "address"
}
],
"name": "executeDecreaseOrder",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_address",
"type": "address"
},
{
"internalType": "uint256",
"name": "_orderIndex",
"type": "uint256"
},
{
"internalType": "address payable",
"name": "_feeReceiver",
"type": "address"
}
],
"name": "executeIncreaseOrder",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "uint256",
"name": "_orderIndex",
"type": "uint256"
},
{
"internalType": "address payable",
"name": "_feeReceiver",
"type": "address"
}
],
"name": "executeSwapOrder",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "orderBook",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "vault",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
],
"bytecode": "",
"deployedBytecode": "",
"linkReferences": {},
"deployedLinkReferences": {}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,355 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Reader",
"sourceName": "contracts/peripherals/Reader.sol",
"abi": [
{
"inputs": [],
"name": "BASIS_POINTS_DIVISOR",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract IVault",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_tokenIn",
"type": "address"
},
{
"internalType": "address",
"name": "_tokenOut",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amountIn",
"type": "uint256"
}
],
"name": "getAmountOut",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_vault",
"type": "address"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getFees",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_weth",
"type": "address"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getFundingRates",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract IVault",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_tokenIn",
"type": "address"
},
{
"internalType": "address",
"name": "_tokenOut",
"type": "address"
}
],
"name": "getMaxAmountIn",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_factory",
"type": "address"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getPairInfo",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address[]",
"name": "_collateralTokens",
"type": "address[]"
},
{
"internalType": "address[]",
"name": "_indexTokens",
"type": "address[]"
},
{
"internalType": "bool[]",
"name": "_isLong",
"type": "bool[]"
}
],
"name": "getPositions",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address[]",
"name": "_yieldTrackers",
"type": "address[]"
}
],
"name": "getStakingInfo",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getTokenBalances",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getTokenBalancesWithSupplies",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract IERC20",
"name": "_token",
"type": "address"
},
{
"internalType": "address[]",
"name": "_excludedAccounts",
"type": "address[]"
}
],
"name": "getTokenSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_yieldTokens",
"type": "address[]"
}
],
"name": "getTotalStaked",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_weth",
"type": "address"
},
{
"internalType": "uint256",
"name": "_usdgAmount",
"type": "uint256"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getVaultTokenInfo",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -0,0 +1,630 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Reader",
"sourceName": "contracts/peripherals/Reader.sol",
"abi": [
{
"inputs": [],
"name": "BASIS_POINTS_DIVISOR",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "POSITION_PROPS_LENGTH",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "PRICE_PRECISION",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "USDG_DECIMALS",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract IVault",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_tokenIn",
"type": "address"
},
{
"internalType": "address",
"name": "_tokenOut",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amountIn",
"type": "uint256"
}
],
"name": "getAmountOut",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract IVault",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_tokenIn",
"type": "address"
},
{
"internalType": "address",
"name": "_tokenOut",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amountIn",
"type": "uint256"
}
],
"name": "getFeeBasisPoints",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_vault",
"type": "address"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getFees",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_weth",
"type": "address"
},
{
"internalType": "uint256",
"name": "_usdgAmount",
"type": "uint256"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getFullVaultTokenInfo",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_weth",
"type": "address"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getFundingRates",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract IVault",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_tokenIn",
"type": "address"
},
{
"internalType": "address",
"name": "_tokenOut",
"type": "address"
}
],
"name": "getMaxAmountIn",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_factory",
"type": "address"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getPairInfo",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address[]",
"name": "_collateralTokens",
"type": "address[]"
},
{
"internalType": "address[]",
"name": "_indexTokens",
"type": "address[]"
},
{
"internalType": "bool[]",
"name": "_isLong",
"type": "bool[]"
}
],
"name": "getPositions",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract IVaultPriceFeed",
"name": "_priceFeed",
"type": "address"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getPrices",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address[]",
"name": "_yieldTrackers",
"type": "address[]"
}
],
"name": "getStakingInfo",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getTokenBalances",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getTokenBalancesWithSupplies",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract IERC20",
"name": "_token",
"type": "address"
},
{
"internalType": "address[]",
"name": "_excludedAccounts",
"type": "address[]"
}
],
"name": "getTokenSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract IERC20",
"name": "_token",
"type": "address"
},
{
"internalType": "address[]",
"name": "_accounts",
"type": "address[]"
}
],
"name": "getTotalBalance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_yieldTokens",
"type": "address[]"
}
],
"name": "getTotalStaked",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_weth",
"type": "address"
},
{
"internalType": "uint256",
"name": "_usdgAmount",
"type": "uint256"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getVaultTokenInfo",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_weth",
"type": "address"
},
{
"internalType": "uint256",
"name": "_usdgAmount",
"type": "uint256"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getVaultTokenInfoV2",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address[]",
"name": "_vesters",
"type": "address[]"
}
],
"name": "getVestingInfo",
"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": "hasMaxGlobalShortSizes",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bool",
"name": "_hasMaxGlobalShortSizes",
"type": "bool"
}
],
"name": "setConfig",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_gov",
"type": "address"
}
],
"name": "setGov",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -0,0 +1,507 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "ReferralStorage",
"sourceName": "contracts/referrals/ReferralStorage.sol",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "bytes32",
"name": "code",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "address",
"name": "newAccount",
"type": "address"
}
],
"name": "GovSetCodeOwner",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "account",
"type": "address"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "code",
"type": "bytes32"
}
],
"name": "RegisterCode",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "account",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "newAccount",
"type": "address"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "code",
"type": "bytes32"
}
],
"name": "SetCodeOwner",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "handler",
"type": "address"
},
{
"indexed": false,
"internalType": "bool",
"name": "isActive",
"type": "bool"
}
],
"name": "SetHandler",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "referrer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "discountShare",
"type": "uint256"
}
],
"name": "SetReferrerDiscountShare",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "referrer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "tierId",
"type": "uint256"
}
],
"name": "SetReferrerTier",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "tierId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "totalRebate",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "discountShare",
"type": "uint256"
}
],
"name": "SetTier",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "account",
"type": "address"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "code",
"type": "bytes32"
}
],
"name": "SetTraderReferralCode",
"type": "event"
},
{
"inputs": [],
"name": "BASIS_POINTS",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"name": "codeOwners",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "getTraderReferralInfo",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gov",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "_code",
"type": "bytes32"
},
{
"internalType": "address",
"name": "_newAccount",
"type": "address"
}
],
"name": "govSetCodeOwner",
"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": "referrerDiscountShares",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "referrerTiers",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "_code",
"type": "bytes32"
}
],
"name": "registerCode",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "_code",
"type": "bytes32"
},
{
"internalType": "address",
"name": "_newAccount",
"type": "address"
}
],
"name": "setCodeOwner",
"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": "uint256",
"name": "_discountShare",
"type": "uint256"
}
],
"name": "setReferrerDiscountShare",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_referrer",
"type": "address"
},
{
"internalType": "uint256",
"name": "_tierId",
"type": "uint256"
}
],
"name": "setReferrerTier",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_tierId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_totalRebate",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_discountShare",
"type": "uint256"
}
],
"name": "setTier",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "bytes32",
"name": "_code",
"type": "bytes32"
}
],
"name": "setTraderReferralCode",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "_code",
"type": "bytes32"
}
],
"name": "setTraderReferralCodeByUser",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "tiers",
"outputs": [
{
"internalType": "uint256",
"name": "totalRebate",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "discountShare",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "traderReferralCodes",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -0,0 +1,86 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "RewardReader",
"sourceName": "contracts/peripherals/RewardReader.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address[]",
"name": "_depositTokens",
"type": "address[]"
},
{
"internalType": "address[]",
"name": "_rewardTrackers",
"type": "address[]"
}
],
"name": "getDepositBalances",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address[]",
"name": "_rewardTrackers",
"type": "address[]"
}
],
"name": "getStakingInfo",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address[]",
"name": "_vesters",
"type": "address[]"
}
],
"name": "getVestingInfoV2",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,918 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "RewardTracker",
"sourceName": "contracts/staking/RewardTracker.sol",
"abi": [
{
"inputs": [
{
"internalType": "string",
"name": "_name",
"type": "string"
},
{
"internalType": "string",
"name": "_symbol",
"type": "string"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"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": 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"
},
{
"inputs": [],
"name": "BASIS_POINTS_DIVISOR",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "PRECISION",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_owner",
"type": "address"
},
{
"internalType": "address",
"name": "_spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "allowances",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "averageStakedAmounts",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"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": "_receiver",
"type": "address"
}
],
"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": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "claimableReward",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "cumulativeRewardPerToken",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "cumulativeRewards",
"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": "address",
"name": "",
"type": "address"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "depositBalances",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "distributor",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gov",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "inPrivateClaimingMode",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "inPrivateStakingMode",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "inPrivateTransferMode",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_depositTokens",
"type": "address[]"
},
{
"internalType": "address",
"name": "_distributor",
"type": "address"
}
],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "isDepositToken",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "isHandler",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "isInitialized",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "previousCumulatedRewardPerToken",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "rewardToken",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_depositToken",
"type": "address"
},
{
"internalType": "bool",
"name": "_isDepositToken",
"type": "bool"
}
],
"name": "setDepositToken",
"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": "_inPrivateClaimingMode",
"type": "bool"
}
],
"name": "setInPrivateClaimingMode",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bool",
"name": "_inPrivateStakingMode",
"type": "bool"
}
],
"name": "setInPrivateStakingMode",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bool",
"name": "_inPrivateTransferMode",
"type": "bool"
}
],
"name": "setInPrivateTransferMode",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_depositToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "stake",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_fundingAccount",
"type": "address"
},
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address",
"name": "_depositToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "stakeForAccount",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "stakedAmounts",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "tokensPerInterval",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "totalDepositSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_sender",
"type": "address"
},
{
"internalType": "address",
"name": "_recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_depositToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "unstake",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address",
"name": "_depositToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
},
{
"internalType": "address",
"name": "_receiver",
"type": "address"
}
],
"name": "unstakeForAccount",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "updateRewards",
"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"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -0,0 +1,605 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Router",
"sourceName": "contracts/core/Router.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_usdg",
"type": "address"
},
{
"internalType": "address",
"name": "_weth",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "account",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "tokenIn",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "tokenOut",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountIn",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountOut",
"type": "uint256"
}
],
"name": "Swap",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "_plugin",
"type": "address"
}
],
"name": "addPlugin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_plugin",
"type": "address"
}
],
"name": "approvePlugin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "approvedPlugins",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_collateralToken",
"type": "address"
},
{
"internalType": "address",
"name": "_indexToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "_collateralDelta",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_sizeDelta",
"type": "uint256"
},
{
"internalType": "bool",
"name": "_isLong",
"type": "bool"
},
{
"internalType": "address",
"name": "_receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "_price",
"type": "uint256"
}
],
"name": "decreasePosition",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_collateralToken",
"type": "address"
},
{
"internalType": "address",
"name": "_indexToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "_collateralDelta",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_sizeDelta",
"type": "uint256"
},
{
"internalType": "bool",
"name": "_isLong",
"type": "bool"
},
{
"internalType": "address payable",
"name": "_receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "_price",
"type": "uint256"
}
],
"name": "decreasePositionETH",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_plugin",
"type": "address"
}
],
"name": "denyPlugin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_token",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "directPoolDeposit",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "gov",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_path",
"type": "address[]"
},
{
"internalType": "address",
"name": "_indexToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amountIn",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_minOut",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_sizeDelta",
"type": "uint256"
},
{
"internalType": "bool",
"name": "_isLong",
"type": "bool"
},
{
"internalType": "uint256",
"name": "_price",
"type": "uint256"
}
],
"name": "increasePosition",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_path",
"type": "address[]"
},
{
"internalType": "address",
"name": "_indexToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "_minOut",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_sizeDelta",
"type": "uint256"
},
{
"internalType": "bool",
"name": "_isLong",
"type": "bool"
},
{
"internalType": "uint256",
"name": "_price",
"type": "uint256"
}
],
"name": "increasePositionETH",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address",
"name": "_collateralToken",
"type": "address"
},
{
"internalType": "address",
"name": "_indexToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "_collateralDelta",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_sizeDelta",
"type": "uint256"
},
{
"internalType": "bool",
"name": "_isLong",
"type": "bool"
},
{
"internalType": "address",
"name": "_receiver",
"type": "address"
}
],
"name": "pluginDecreasePosition",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address",
"name": "_collateralToken",
"type": "address"
},
{
"internalType": "address",
"name": "_indexToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "_sizeDelta",
"type": "uint256"
},
{
"internalType": "bool",
"name": "_isLong",
"type": "bool"
}
],
"name": "pluginIncreasePosition",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_token",
"type": "address"
},
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address",
"name": "_receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "pluginTransfer",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "plugins",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_plugin",
"type": "address"
}
],
"name": "removePlugin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_gov",
"type": "address"
}
],
"name": "setGov",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_path",
"type": "address[]"
},
{
"internalType": "uint256",
"name": "_amountIn",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_minOut",
"type": "uint256"
},
{
"internalType": "address",
"name": "_receiver",
"type": "address"
}
],
"name": "swap",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_path",
"type": "address[]"
},
{
"internalType": "uint256",
"name": "_minOut",
"type": "uint256"
},
{
"internalType": "address",
"name": "_receiver",
"type": "address"
}
],
"name": "swapETHToTokens",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_path",
"type": "address[]"
},
{
"internalType": "uint256",
"name": "_amountIn",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_minOut",
"type": "uint256"
},
{
"internalType": "address payable",
"name": "_receiver",
"type": "address"
}
],
"name": "swapTokensToETH",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "usdg",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "vault",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "weth",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -0,0 +1,605 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Router",
"sourceName": "contracts/core/Router.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_usdg",
"type": "address"
},
{
"internalType": "address",
"name": "_weth",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "account",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "tokenIn",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "tokenOut",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountIn",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountOut",
"type": "uint256"
}
],
"name": "Swap",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "_plugin",
"type": "address"
}
],
"name": "addPlugin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_plugin",
"type": "address"
}
],
"name": "approvePlugin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "approvedPlugins",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_collateralToken",
"type": "address"
},
{
"internalType": "address",
"name": "_indexToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "_collateralDelta",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_sizeDelta",
"type": "uint256"
},
{
"internalType": "bool",
"name": "_isLong",
"type": "bool"
},
{
"internalType": "address",
"name": "_receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "_price",
"type": "uint256"
}
],
"name": "decreasePosition",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_collateralToken",
"type": "address"
},
{
"internalType": "address",
"name": "_indexToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "_collateralDelta",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_sizeDelta",
"type": "uint256"
},
{
"internalType": "bool",
"name": "_isLong",
"type": "bool"
},
{
"internalType": "address payable",
"name": "_receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "_price",
"type": "uint256"
}
],
"name": "decreasePositionETH",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_plugin",
"type": "address"
}
],
"name": "denyPlugin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_token",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "directPoolDeposit",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "gov",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_path",
"type": "address[]"
},
{
"internalType": "address",
"name": "_indexToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amountIn",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_minOut",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_sizeDelta",
"type": "uint256"
},
{
"internalType": "bool",
"name": "_isLong",
"type": "bool"
},
{
"internalType": "uint256",
"name": "_price",
"type": "uint256"
}
],
"name": "increasePosition",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_path",
"type": "address[]"
},
{
"internalType": "address",
"name": "_indexToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "_minOut",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_sizeDelta",
"type": "uint256"
},
{
"internalType": "bool",
"name": "_isLong",
"type": "bool"
},
{
"internalType": "uint256",
"name": "_price",
"type": "uint256"
}
],
"name": "increasePositionETH",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address",
"name": "_collateralToken",
"type": "address"
},
{
"internalType": "address",
"name": "_indexToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "_collateralDelta",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_sizeDelta",
"type": "uint256"
},
{
"internalType": "bool",
"name": "_isLong",
"type": "bool"
},
{
"internalType": "address",
"name": "_receiver",
"type": "address"
}
],
"name": "pluginDecreasePosition",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address",
"name": "_collateralToken",
"type": "address"
},
{
"internalType": "address",
"name": "_indexToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "_sizeDelta",
"type": "uint256"
},
{
"internalType": "bool",
"name": "_isLong",
"type": "bool"
}
],
"name": "pluginIncreasePosition",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_token",
"type": "address"
},
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address",
"name": "_receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "pluginTransfer",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "plugins",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_plugin",
"type": "address"
}
],
"name": "removePlugin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_gov",
"type": "address"
}
],
"name": "setGov",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_path",
"type": "address[]"
},
{
"internalType": "uint256",
"name": "_amountIn",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_minOut",
"type": "uint256"
},
{
"internalType": "address",
"name": "_receiver",
"type": "address"
}
],
"name": "swap",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_path",
"type": "address[]"
},
{
"internalType": "uint256",
"name": "_minOut",
"type": "uint256"
},
{
"internalType": "address",
"name": "_receiver",
"type": "address"
}
],
"name": "swapETHToTokens",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_path",
"type": "address[]"
},
{
"internalType": "uint256",
"name": "_amountIn",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_minOut",
"type": "uint256"
},
{
"internalType": "address payable",
"name": "_receiver",
"type": "address"
}
],
"name": "swapTokensToETH",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "usdg",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "vault",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "weth",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -0,0 +1,658 @@
{
"address": "0xe5485a4fD6527911e9b82A75A1bFEd6e47BE2241",
"abi": [
{
"inputs": [
{
"internalType": "contract Router",
"name": "_router",
"type": "address"
},
{
"internalType": "contract RoleStore",
"name": "_roleStore",
"type": "address"
},
{
"internalType": "contract DataStore",
"name": "_dataStore",
"type": "address"
},
{
"internalType": "contract EventEmitter",
"name": "_eventEmitter",
"type": "address"
},
{
"internalType": "contract IOrderHandler",
"name": "_orderHandler",
"type": "address"
},
{
"internalType": "contract OrderVault",
"name": "_orderVault",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
}
],
"name": "DisabledFeature",
"type": "error"
},
{
"inputs": [],
"name": "EmptyHoldingAddress",
"type": "error"
},
{
"inputs": [],
"name": "EmptyOrder",
"type": "error"
},
{
"inputs": [],
"name": "EmptyReceiver",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "token",
"type": "address"
}
],
"name": "EmptyTokenTranferGasLimit",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "msgSender",
"type": "address"
}
],
"name": "InvalidNativeTokenSender",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "address",
"name": "expectedReceiver",
"type": "address"
}
],
"name": "InvalidReceiverForSubaccountOrder",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
},
{
"internalType": "address",
"name": "subaccount",
"type": "address"
},
{
"internalType": "uint256",
"name": "count",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "maxCount",
"type": "uint256"
}
],
"name": "MaxSubaccountActionCountExceeded",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
},
{
"internalType": "address",
"name": "subaccount",
"type": "address"
}
],
"name": "SubaccountNotAuthorized",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "TokenTransferError",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "subaccount",
"type": "address"
}
],
"name": "addSubaccount",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
}
],
"name": "cancelOrder",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
},
{
"components": [
{
"components": [
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "address",
"name": "cancellationReceiver",
"type": "address"
},
{
"internalType": "address",
"name": "callbackContract",
"type": "address"
},
{
"internalType": "address",
"name": "uiFeeReceiver",
"type": "address"
},
{
"internalType": "address",
"name": "market",
"type": "address"
},
{
"internalType": "address",
"name": "initialCollateralToken",
"type": "address"
},
{
"internalType": "address[]",
"name": "swapPath",
"type": "address[]"
}
],
"internalType": "struct IBaseOrderUtils.CreateOrderParamsAddresses",
"name": "addresses",
"type": "tuple"
},
{
"components": [
{
"internalType": "uint256",
"name": "sizeDeltaUsd",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "initialCollateralDeltaAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "triggerPrice",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "acceptablePrice",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "executionFee",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "callbackGasLimit",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "minOutputAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "validFromTime",
"type": "uint256"
}
],
"internalType": "struct IBaseOrderUtils.CreateOrderParamsNumbers",
"name": "numbers",
"type": "tuple"
},
{
"internalType": "enum Order.OrderType",
"name": "orderType",
"type": "uint8"
},
{
"internalType": "enum Order.DecreasePositionSwapType",
"name": "decreasePositionSwapType",
"type": "uint8"
},
{
"internalType": "bool",
"name": "isLong",
"type": "bool"
},
{
"internalType": "bool",
"name": "shouldUnwrapNativeToken",
"type": "bool"
},
{
"internalType": "bool",
"name": "autoCancel",
"type": "bool"
},
{
"internalType": "bytes32",
"name": "referralCode",
"type": "bytes32"
}
],
"internalType": "struct IBaseOrderUtils.CreateOrderParams",
"name": "params",
"type": "tuple"
}
],
"name": "createOrder",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "dataStore",
"outputs": [
{
"internalType": "contract DataStore",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "eventEmitter",
"outputs": [
{
"internalType": "contract EventEmitter",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes[]",
"name": "data",
"type": "bytes[]"
}
],
"name": "multicall",
"outputs": [
{
"internalType": "bytes[]",
"name": "results",
"type": "bytes[]"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "orderHandler",
"outputs": [
{
"internalType": "contract IOrderHandler",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "orderVault",
"outputs": [
{
"internalType": "contract OrderVault",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "subaccount",
"type": "address"
}
],
"name": "removeSubaccount",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "roleStore",
"outputs": [
{
"internalType": "contract RoleStore",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "router",
"outputs": [
{
"internalType": "contract Router",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "sendNativeToken",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "sendTokens",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "sendWnt",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "subaccount",
"type": "address"
},
{
"internalType": "bytes32",
"name": "actionType",
"type": "bytes32"
},
{
"internalType": "uint256",
"name": "maxAllowedCount",
"type": "uint256"
}
],
"name": "setMaxAllowedSubaccountActionCount",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "subaccount",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "setSubaccountAutoTopUpAmount",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "key",
"type": "bytes32"
},
{
"internalType": "uint256",
"name": "sizeDeltaUsd",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "acceptablePrice",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "triggerPrice",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "minOutputAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "validFromTime",
"type": "uint256"
},
{
"internalType": "bool",
"name": "autoCancel",
"type": "bool"
}
],
"name": "updateOrder",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
}
],
"transactionHash": "0xe5b71c86f938f547820ca3262678fb70c379c15ef02430fbb773ee4d37e86e09",
"receipt": {
"to": null,
"from": "0xE7BfFf2aB721264887230037940490351700a068",
"contractAddress": "0xe5485a4fD6527911e9b82A75A1bFEd6e47BE2241",
"transactionIndex": 0,
"gasUsed": "3707710",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"blockHash": "0x00c9beda5865106776abea90f56310f05628852d29d91b7c235c44a20123b601",
"transactionHash": "0xe5b71c86f938f547820ca3262678fb70c379c15ef02430fbb773ee4d37e86e09",
"logs": [],
"blockNumber": 46822607,
"cumulativeGasUsed": "3707710",
"status": 1,
"byzantium": true
},
"args": [
"0x820F5FfC5b525cD4d88Cd91aCf2c28F16530Cc68",
"0xA44F830B6a2B6fa76657a3B92C1fe74fcB7C6AfD",
"0x2F0b22339414ADeD7D5F06f9D604c7fF5b2fe3f6",
"0xDb17B211c34240B014ab6d61d4A31FA0C0e20c26",
"0x32A0258007a6ea78265a5AE4DBb28f176be4a8EB",
"0xD3D60D22d415aD43b7e64b510D86A30f19B1B12C"
],
"numDeployments": 3,
"solcInputHash": "95ed34927f843d6700c121bcc6faf594",
"libraries": {
"OrderStoreUtils": "0x805a15bf16582eC8d76841062A47dFfEa7903131"
},
"devdoc": {
"kind": "dev",
"methods": {
"multicall(bytes[])": {
"details": "Receives and executes a batch of function calls on this contract."
}
},
"version": 1
},
"userdoc": {
"kind": "user",
"methods": {},
"version": 1
},
"storageLayout": {
"storage": [
{
"astId": 115,
"contract": "contracts/router/SubaccountRouter.sol:SubaccountRouter",
"label": "_status",
"offset": 0,
"slot": "0",
"type": "t_uint256"
}
],
"types": {
"t_uint256": {
"encoding": "inplace",
"label": "uint256",
"numberOfBytes": "32"
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,77 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Router",
"sourceName": "contracts/router/Router.sol",
"abi": [
{
"inputs": [
{
"internalType": "contract RoleStore",
"name": "_roleStore",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [
{
"internalType": "address",
"name": "msgSender",
"type": "address"
},
{
"internalType": "string",
"name": "role",
"type": "string"
}
],
"name": "Unauthorized",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "account",
"type": "address"
},
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "pluginTransfer",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "roleStore",
"outputs": [
{
"internalType": "contract RoleStore",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,345 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Token",
"sourceName": "contracts/tokens/Token.sol",
"abi": [
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"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": 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"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"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": [],
"name": "decimals",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "subtractedValue",
"type": "uint256"
}
],
"name": "decreaseAllowance",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "deposit",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "addedValue",
"type": "uint256"
}
],
"name": "increaseAllowance",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "mint",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"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": "recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "address",
"name": "recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"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"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -0,0 +1,411 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Treasury",
"sourceName": "contracts/gambit-token/Treasury.sol",
"abi": [
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "addLiquidity",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_accounts",
"type": "address[]"
}
],
"name": "addWhitelists",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "busd",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "busdBasisPoints",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "busdHardCap",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "busdReceived",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "busdSlotCap",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "endSwap",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_unlockTime",
"type": "uint256"
}
],
"name": "extendUnlockTime",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "fund",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gmt",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gmtListingPrice",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gmtPresalePrice",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gov",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_busdBasisPoints",
"type": "uint256"
}
],
"name": "increaseBusdBasisPoints",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_addresses",
"type": "address[]"
},
{
"internalType": "uint256[]",
"name": "_values",
"type": "uint256[]"
}
],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "isInitialized",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "isLiquidityAdded",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "isSwapActive",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_accounts",
"type": "address[]"
}
],
"name": "removeWhitelists",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "router",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_fund",
"type": "address"
}
],
"name": "setFund",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_gov",
"type": "address"
}
],
"name": "setGov",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_busdAmount",
"type": "uint256"
}
],
"name": "swap",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "swapAmounts",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "swapWhitelist",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "unlockTime",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "prevAccount",
"type": "address"
},
{
"internalType": "address",
"name": "nextAccount",
"type": "address"
}
],
"name": "updateWhitelist",
"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"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -0,0 +1,89 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "UniPool",
"sourceName": "contracts/amm/UniPool.sol",
"abi": [
{
"inputs": [
{
"internalType": "uint32[]",
"name": "",
"type": "uint32[]"
}
],
"name": "observe",
"outputs": [
{
"internalType": "int56[]",
"name": "tickCumulatives",
"type": "int56[]"
},
{
"internalType": "uint160[]",
"name": "secondsPerLiquidityCumulativeX128s",
"type": "uint160[]"
}
],
"stateMutability": "pure",
"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": [],
"name": "tickSpacing",
"outputs": [
{
"internalType": "int24",
"name": "",
"type": "int24"
}
],
"stateMutability": "pure",
"type": "function"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,87 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "VaultReader",
"sourceName": "contracts/peripherals/VaultReader.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_positionManager",
"type": "address"
},
{
"internalType": "address",
"name": "_weth",
"type": "address"
},
{
"internalType": "uint256",
"name": "_usdgAmount",
"type": "uint256"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getVaultTokenInfoV3",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_vault",
"type": "address"
},
{
"internalType": "address",
"name": "_positionManager",
"type": "address"
},
{
"internalType": "address",
"name": "_weth",
"type": "address"
},
{
"internalType": "uint256",
"name": "_usdgAmount",
"type": "uint256"
},
{
"internalType": "address[]",
"name": "_tokens",
"type": "address[]"
}
],
"name": "getVaultTokenInfoV4",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,320 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "WETH",
"sourceName": "contracts/tokens/WETH.sol",
"abi": [
{
"inputs": [
{
"internalType": "string",
"name": "name",
"type": "string"
},
{
"internalType": "string",
"name": "symbol",
"type": "string"
},
{
"internalType": "uint8",
"name": "decimals",
"type": "uint8"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"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": 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"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"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": [],
"name": "decimals",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "subtractedValue",
"type": "uint256"
}
],
"name": "decreaseAllowance",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "deposit",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "addedValue",
"type": "uint256"
}
],
"name": "increaseAllowance",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"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": "recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "address",
"name": "recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "withdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -0,0 +1,599 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "YieldFarm",
"sourceName": "contracts/tokens/YieldFarm.sol",
"abi": [
{
"inputs": [
{
"internalType": "string",
"name": "_name",
"type": "string"
},
{
"internalType": "string",
"name": "_symbol",
"type": "string"
},
{
"internalType": "address",
"name": "_stakingToken",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"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": 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"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "addAdmin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "addNonStakingAccount",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "admins",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_owner",
"type": "address"
},
{
"internalType": "address",
"name": "_spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "allowances",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"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": "_receiver",
"type": "address"
}
],
"name": "claim",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gov",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "nonStakingAccounts",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "nonStakingSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address",
"name": "_receiver",
"type": "address"
}
],
"name": "recoverClaim",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "removeAdmin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "removeNonStakingAccount",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_gov",
"type": "address"
}
],
"name": "setGov",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "_name",
"type": "string"
},
{
"internalType": "string",
"name": "_symbol",
"type": "string"
}
],
"name": "setInfo",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_yieldTrackers",
"type": "address[]"
}
],
"name": "setYieldTrackers",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "stake",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "stakedBalance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "stakingToken",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalStaked",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_sender",
"type": "address"
},
{
"internalType": "address",
"name": "_recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "unstake",
"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"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "yieldTrackers",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -0,0 +1,560 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "YieldToken",
"sourceName": "contracts/tokens/YieldToken.sol",
"abi": [
{
"inputs": [
{
"internalType": "string",
"name": "_name",
"type": "string"
},
{
"internalType": "string",
"name": "_symbol",
"type": "string"
},
{
"internalType": "uint256",
"name": "_initialSupply",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"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": 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"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "addAdmin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "addNonStakingAccount",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "admins",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_owner",
"type": "address"
},
{
"internalType": "address",
"name": "_spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "allowances",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"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": "_receiver",
"type": "address"
}
],
"name": "claim",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gov",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "nonStakingAccounts",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "nonStakingSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
},
{
"internalType": "address",
"name": "_receiver",
"type": "address"
}
],
"name": "recoverClaim",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "removeAdmin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "removeNonStakingAccount",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_gov",
"type": "address"
}
],
"name": "setGov",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "_name",
"type": "string"
},
{
"internalType": "string",
"name": "_symbol",
"type": "string"
}
],
"name": "setInfo",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "_yieldTrackers",
"type": "address[]"
}
],
"name": "setYieldTrackers",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_account",
"type": "address"
}
],
"name": "stakedBalance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalStaked",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_sender",
"type": "address"
},
{
"internalType": "address",
"name": "_recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"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"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "yieldTrackers",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
],
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -0,0 +1,136 @@
import type { JsonFragment } from "ethers";
import { Abi, erc20Abi } from "viem";
import CustomErrors from "./CustomErrors.json" with { type: "json" };
import DataStore from "./DataStore.json" with { type: "json" };
import ERC721 from "./ERC721.json" with { type: "json" };
import EventEmitter from "./EventEmitter.json" with { type: "json" };
import ExchangeRouter from "./ExchangeRouter.json" with { type: "json" };
import GlpManager from "./GlpManager.json" with { type: "json" };
import GlvReader from "./GlvReader.json" with { type: "json" };
import GlvRouter from "./GlvRouter.json" with { type: "json" };
import GMT from "./GMT.json" with { type: "json" };
import GmxMigrator from "./GmxMigrator.json" with { type: "json" };
import GovToken from "./GovToken.json" with { type: "json" };
import MintableBaseToken from "./MintableBaseToken.json" with { type: "json" };
import Multicall from "./Multicall.json" with { type: "json" };
import OrderBook from "./OrderBook.json" with { type: "json" };
import OrderBookReader from "./OrderBookReader.json" with { type: "json" };
import OrderExecutor from "./OrderExecutor.json" with { type: "json" };
import PositionManager from "./PositionManager.json" with { type: "json" };
import PositionRouter from "./PositionRouter.json" with { type: "json" };
import Reader from "./Reader.json" with { type: "json" };
import ReaderV2 from "./ReaderV2.json" with { type: "json" };
import ReferralStorage from "./ReferralStorage.json" with { type: "json" };
import RewardReader from "./RewardReader.json" with { type: "json" };
import RewardRouter from "./RewardRouter.json" with { type: "json" };
import RewardTracker from "./RewardTracker.json" with { type: "json" };
import RouterV2 from "./Router-v2.json" with { type: "json" };
import Router from "./Router.json" with { type: "json" };
import SubaccountRouter from "./SubaccountRouter.json" with { type: "json" };
import SyntheticsReader from "./SyntheticsReader.json" with { type: "json" };
import SyntheticsRouter from "./SyntheticsRouter.json" with { type: "json" };
import Timelock from "./Timelock.json" with { type: "json" };
import Token from "./Token.json" with { type: "json" };
import Treasury from "./Treasury.json" with { type: "json" };
import UniPool from "./UniPool.json" with { type: "json" };
import UniswapV2 from "./UniswapV2.json" with { type: "json" };
import Vault from "./Vault.json" with { type: "json" };
import VaultReader from "./VaultReader.json" with { type: "json" };
import VaultV2 from "./VaultV2.json" with { type: "json" };
import VaultV2b from "./VaultV2b.json" with { type: "json" };
import Vester from "./Vester.json" with { type: "json" };
import WETH from "./WETH.json" with { type: "json" };
import YieldFarm from "./YieldFarm.json" with { type: "json" };
import YieldToken from "./YieldToken.json" with { type: "json" };
export type AbiId =
| "CustomErrors"
| "DataStore"
| "ERC721"
| "ERC20"
| "EventEmitter"
| "ExchangeRouter"
| "GlpManager"
| "GlvReader"
| "GlvRouter"
| "GMT"
| "GmxMigrator"
| "GovToken"
| "MintableBaseToken"
| "Multicall"
| "OrderBook"
| "OrderBookReader"
| "OrderExecutor"
| "PositionManager"
| "PositionRouter"
| "Reader"
| "ReaderV2"
| "ReferralStorage"
| "RewardReader"
| "RewardRouter"
| "RewardTracker"
| "Router-v2"
| "Router"
| "SubaccountRouter"
| "SyntheticsReader"
| "SyntheticsRouter"
| "Timelock"
| "Token"
| "Treasury"
| "UniPool"
| "UniswapV2"
| "Vault"
| "VaultReader"
| "VaultV2"
| "VaultV2b"
| "Vester"
| "WETH"
| "YieldFarm"
| "YieldToken";
export const abis: Record<AbiId, readonly (Abi[number] & JsonFragment)[]> = {
CustomErrors: CustomErrors.abi,
DataStore: DataStore.abi,
ERC721: ERC721.abi,
ERC20: erc20Abi,
EventEmitter: EventEmitter.abi,
ExchangeRouter: ExchangeRouter.abi,
GlpManager: GlpManager.abi,
GlvReader: GlvReader.abi,
GlvRouter: GlvRouter.abi,
GMT: GMT.abi,
GmxMigrator: GmxMigrator.abi,
GovToken: GovToken.abi,
MintableBaseToken: MintableBaseToken.abi,
Multicall: Multicall.abi,
OrderBook: OrderBook.abi,
OrderBookReader: OrderBookReader.abi,
OrderExecutor: OrderExecutor.abi,
PositionManager: PositionManager.abi,
PositionRouter: PositionRouter.abi,
Reader: Reader.abi,
ReaderV2: ReaderV2.abi,
ReferralStorage: ReferralStorage.abi,
RewardReader: RewardReader.abi,
RewardRouter: RewardRouter.abi,
RewardTracker: RewardTracker.abi,
RouterV2: RouterV2.abi,
Router: Router.abi,
SubaccountRouter: SubaccountRouter.abi,
SyntheticsReader: SyntheticsReader.abi,
SyntheticsRouter: SyntheticsRouter.abi,
Timelock: Timelock.abi,
Token: Token.abi,
Treasury: Treasury.abi,
UniPool: UniPool.abi,
UniswapV2: UniswapV2.abi,
Vault: Vault.abi,
VaultReader: VaultReader.abi,
VaultV2: VaultV2.abi,
VaultV2b: VaultV2b.abi,
Vester: Vester.abi,
WETH: WETH.abi,
YieldFarm: YieldFarm.abi,
YieldToken: YieldToken.abi,
} as any;

View File

@@ -0,0 +1,47 @@
import {ClientConfig, MulticallBatchOptions} from "viem";
import {ARBITRUM, AVALANCHE, AVALANCHE_FUJI} from "./chains.js";
export const BATCH_CONFIGS: Record<
number,
{
http: MulticallBatchOptions;
client: ClientConfig["batch"];
}
> = {
[ARBITRUM]: {
http: {
batchSize: 0, // disable batches, here batchSize is the number of eth_calls in a batch
wait: 0, // keep this setting in case batches are enabled in future
},
client: {
multicall: {
batchSize: 1024 * 1024, // here batchSize is the number of bytes in a multicall
wait: 0, // zero delay means formation of a batch in the current macro-task, like setTimeout(fn, 0)
},
},
},
[AVALANCHE]: {
http: {
batchSize: 0,
wait: 0,
},
client: {
multicall: {
batchSize: 1024 * 1024,
wait: 0,
},
},
},
[AVALANCHE_FUJI]: {
http: {
batchSize: 40,
wait: 0,
},
client: {
multicall: {
batchSize: 1024 * 1024,
wait: 0,
},
},
},
};

View File

@@ -0,0 +1,110 @@
import {arbitrum, avalanche, avalancheFuji, Chain} from "viem/chains";
export const AVALANCHE = 43114;
export const AVALANCHE_FUJI = 43113;
export const ARBITRUM = 42161;
export const BSС_MAINNET = 56;
export const BSС_TESTNET = 97;
export const ETH_MAINNET = 1;
export const SUPPORTED_CHAIN_IDS = [ARBITRUM, AVALANCHE];
export const SUPPORTED_CHAIN_IDS_DEV = [...SUPPORTED_CHAIN_IDS, AVALANCHE_FUJI];
export const HIGH_EXECUTION_FEES_MAP = {
[ARBITRUM]: 5, // 5 USD
[AVALANCHE]: 5, // 5 USD
[AVALANCHE_FUJI]: 5, // 5 USD
};
// added to maxPriorityFeePerGas
// applied to EIP-1559 transactions only
// is not applied to execution fee calculation
export const MAX_FEE_PER_GAS_MAP = {
[AVALANCHE]: 200000000000n, // 200 gwei
};
// added to maxPriorityFeePerGas
// applied to EIP-1559 transactions only
// is also applied to the execution fee calculation
export const GAS_PRICE_PREMIUM_MAP = {
[ARBITRUM]: 0n,
[AVALANCHE]: 6000000000n, // 6 gwei
};
/*
that was a constant value in ethers v5, after ethers v6 migration we use it as a minimum for maxPriorityFeePerGas
*/
export const MAX_PRIORITY_FEE_PER_GAS_MAP: Record<number, bigint | undefined> = {
[ARBITRUM]: 1500000000n,
[AVALANCHE]: 1500000000n,
[AVALANCHE_FUJI]: 1500000000n,
};
export const EXCESSIVE_EXECUTION_FEES_MAP = {
[ARBITRUM]: 10, // 10 USD
[AVALANCHE]: 10, // 10 USD
[AVALANCHE_FUJI]: 10, // 10 USD
};
// added to gasPrice
// applied to *non* EIP-1559 transactions only
//
// it is *not* applied to the execution fee calculation, and in theory it could cause issues
// if gas price used in the execution fee calculation is lower
// than the gas price used in the transaction (e.g. create order transaction)
// then the transaction will fail with InsufficientExecutionFee error.
// it is not an issue on Arbitrum though because the passed gas price does not affect the paid gas price.
// for example if current gas price is 0.1 gwei and UI passes 0.5 gwei the transaction
// Arbitrum will still charge 0.1 gwei per gas
//
// it doesn't make much sense to set this buffer higher than the execution fee buffer
// because if the paid gas price is higher than the gas price used in the execution fee calculation
// and the transaction will still fail with InsufficientExecutionFee
//
// this buffer could also cause issues on a blockchain that uses passed gas price
// especially if execution fee buffer and lower than gas price buffer defined bellow
export const GAS_PRICE_BUFFER_MAP = {
[ARBITRUM]: 2000n, // 20%
};
const CHAIN_BY_CHAIN_ID = {
[AVALANCHE_FUJI]: avalancheFuji,
[ARBITRUM]: arbitrum,
[AVALANCHE]: avalanche,
};
export const getChain = (chainId: number): Chain => {
return CHAIN_BY_CHAIN_ID[chainId];
};
export function getHighExecutionFee(chainId) {
return HIGH_EXECUTION_FEES_MAP[chainId] ?? 5;
}
export function getExcessiveExecutionFee(chainId) {
return EXCESSIVE_EXECUTION_FEES_MAP[chainId] ?? 10;
}
export function isSupportedChain(chainId: number, dev = false) {
return (dev ? SUPPORTED_CHAIN_IDS_DEV : SUPPORTED_CHAIN_IDS).includes(chainId);
}
export const EXECUTION_FEE_CONFIG_V2: {
[chainId: number]: {
shouldUseMaxPriorityFeePerGas: boolean;
defaultBufferBps?: number;
};
} = {
[AVALANCHE]: {
shouldUseMaxPriorityFeePerGas: true,
defaultBufferBps: 1000, // 10%
},
[AVALANCHE_FUJI]: {
shouldUseMaxPriorityFeePerGas: true,
defaultBufferBps: 1000, // 10%
},
[ARBITRUM]: {
shouldUseMaxPriorityFeePerGas: false,
defaultBufferBps: 3000, // 30%
},
};

View File

@@ -0,0 +1,281 @@
import {type Address, zeroAddress} from "viem";
import {ARBITRUM, AVALANCHE, AVALANCHE_FUJI, BSС_MAINNET, BSС_TESTNET} from "./chains.js";
export const CONTRACTS = {
[BSС_MAINNET]: {
// bsc mainnet
Treasury: "0xa44E7252a0C137748F523F112644042E5987FfC7",
BUSD: "0xe9e7cea3dedca5984780bafc599bd69add087d56",
GMT: "0x99e92123eB77Bc8f999316f622e5222498438784",
Vault: "0xc73A8DcAc88498FD4b4B1b2AaA37b0a2614Ff67B",
Router: "0xD46B23D042E976F8666F554E928e0Dc7478a8E1f",
Reader: "0x087A618fD25c92B61254DBe37b09E5E8065FeaE7",
AmmFactory: "0xBCfCcbde45cE874adCB698cC183deBcF17952812",
AmmFactoryV2: "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73",
OrderBook: "0x1111111111111111111111111111111111111111",
OrderBookReader: "0x1111111111111111111111111111111111111111",
GmxMigrator: "0xDEF2af818514c1Ca1A9bBe2a4D45E28f260063f9",
USDG: "0x85E76cbf4893c1fbcB34dCF1239A91CE2A4CF5a7",
NATIVE_TOKEN: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
XGMT: "0xe304ff0983922787Fd84BC9170CD21bF78B16B10",
GMT_USDG_PAIR: "0xa41e57459f09a126F358E118b693789d088eA8A0",
XGMT_USDG_PAIR: "0x0b622208fc0691C2486A3AE6B7C875b4A174b317",
GMT_USDG_FARM: "0x3E8B08876c791dC880ADC8f965A02e53Bb9C0422",
XGMT_USDG_FARM: "0x68D7ee2A16AB7c0Ee1D670BECd144166d2Ae0759",
USDG_YIELD_TRACKER: "0x0EF0Cf825B8e9F89A43FfD392664131cFB4cfA89",
XGMT_YIELD_TRACKER: "0x82A012A9b3003b18B6bCd6052cbbef7Fa4892e80",
GMT_USDG_FARM_TRACKER_XGMT: "0x08FAb024BEfcb6068847726b2eccEAd18b6c23Cd",
GMT_USDG_FARM_TRACKER_NATIVE: "0xd8E26637B34B2487Cad1f91808878a391134C5c2",
XGMT_USDG_FARM_TRACKER_XGMT: "0x026A02F7F26C1AFccb9Cba7C4df3Dc810F4e92e8",
XGMT_USDG_FARM_TRACKER_NATIVE: "0x22458CEbD14a9679b2880147d08CA1ce5aa40E84",
AUTO: "0xa184088a740c695E156F91f5cC086a06bb78b827",
AUTO_USDG_PAIR: "0x0523FD5C53ea5419B4DAF656BC1b157dDFE3ce50",
AUTO_USDG_FARM: "0xE6958298328D02051769282628a3b4178D0F3A47",
AUTO_USDG_FARM_TRACKER_XGMT: "0x093b8be41c1A30704De84a9521632f9a139c08bd",
AUTO_USDG_FARM_TRACKER_NATIVE: "0x23ed48E5dce3acC7704d0ce275B7b9a0e346b63A",
GMT_GMX_IOU: "0x47052469970C2484729875CC9E2dd2683fcE71fb",
XGMT_GMX_IOU: "0xeB3733DFe3b68C9d26898De2493A3Bb59FDb4A7B",
GMT_USDG_GMX_IOU: "0x481312655F81b5e249780A6a49735335BF6Ca7f4",
XGMT_USDG_GMX_IOU: "0x8095F1A92526C304623483018aA28cC6E62EB1e1",
},
[BSС_TESTNET]: {
// bsc testnet
Vault: "0x1B183979a5cd95FAF392c8002dbF0D5A1C687D9a",
Router: "0x10800f683aa564534497a5b67F45bE3556a955AB",
Reader: "0x98D4742F1B6a821bae672Cd8721283b91996E454",
AmmFactory: "0x6725f303b657a9451d8ba641348b6761a6cc7a17",
AmmFactoryV2: "0x1111111111111111111111111111111111111111",
OrderBook: "0x9afD7B4f0b58d65F6b2978D3581383a06b2ac4e9",
OrderBookReader: "0x0713562970D1A802Fa3FeB1D15F9809943982Ea9",
GmxMigrator: "0xDEF2af818514c1Ca1A9bBe2a4D45E28f260063f9",
USDG: "0x2D549bdBf810523fe9cd660cC35fE05f0FcAa028",
GMT: "0xedba0360a44f885ed390fad01aa34d00d2532817",
NATIVE_TOKEN: "0x612777Eea37a44F7a95E3B101C39e1E2695fa6C2",
XGMT: "0x28cba798eca1a3128ffd1b734afb93870f22e613",
GMT_USDG_PAIR: "0xe0b0a315746f51932de033ab27223d85114c6b85",
XGMT_USDG_PAIR: "0x0108de1eea192ce8448080c3d90a1560cf643fa0",
GMT_USDG_FARM: "0xbe3cB06CE03cA692b77902040479572Ba8D01b0B",
XGMT_USDG_FARM: "0x138E92195D4B99CE3618092D3F9FA830d9A69B4b",
USDG_YIELD_TRACKER: "0x62B49Bc3bF252a5DB26D88ccc7E61119e3179B4f",
XGMT_YIELD_TRACKER: "0x5F235A582e0993eE9466FeEb8F7B4682993a57d0",
GMT_USDG_FARM_TRACKER_XGMT: "0x4f8EE3aE1152422cbCaFACd4e3041ba2D859913C",
GMT_USDG_FARM_TRACKER_NATIVE: "0xd691B26E544Fe370f39A776964c991363aF72e56",
XGMT_USDG_FARM_TRACKER_XGMT: "0xfd5617CFB082Ba9bcD62d654603972AE312bC695",
XGMT_USDG_FARM_TRACKER_NATIVE: "0x0354387DD85b7D8aaD1611B3D167A384d6AE0c28",
GMT_GMX_IOU: "0x47052469970C2484729875CC9E2dd2683fcE71fb",
XGMT_GMX_IOU: "0xeB3733DFe3b68C9d26898De2493A3Bb59FDb4A7B",
GMT_USDG_GMX_IOU: "0x481312655F81b5e249780A6a49735335BF6Ca7f4",
XGMT_USDG_GMX_IOU: "0x8095F1A92526C304623483018aA28cC6E62EB1e1",
},
[ARBITRUM]: {
// arbitrum mainnet
Vault: "0x489ee077994B6658eAfA855C308275EAd8097C4A",
Router: "0xaBBc5F99639c9B6bCb58544ddf04EFA6802F4064",
VaultReader: "0xfebB9f4CAC4cD523598fE1C5771181440143F24A",
Reader: "0x2b43c90D1B727cEe1Df34925bcd5Ace52Ec37694",
GlpManager: "0x3963FfC9dff443c2A94f21b129D429891E32ec18",
RewardRouter: "0x5E4766F932ce00aA4a1A82d3Da85adf15C5694A1",
GlpRewardRouter: "0xB95DB5B167D75e6d04227CfFFA61069348d271F5",
RewardReader: "0x8BFb8e82Ee4569aee78D03235ff465Bd436D40E0",
GovToken: "0x2A29D3a792000750807cc401806d6fd539928481",
NATIVE_TOKEN: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
GLP: "0x4277f8F2c384827B5273592FF7CeBd9f2C1ac258",
GMX: "0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a",
ES_GMX: "0xf42Ae1D54fd613C9bb14810b0588FaAa09a426cA",
BN_GMX: "0x35247165119B69A40edD5304969560D0ef486921",
USDG: "0x45096e7aA921f27590f8F19e457794EB09678141",
ES_GMX_IOU: "0x6260101218eC4cCfFF1b778936C6f2400f95A954",
StakedGmxTracker: "0x908C4D94D34924765f1eDc22A1DD098397c59dD4",
BonusGmxTracker: "0x4d268a7d4C16ceB5a606c173Bd974984343fea13",
FeeGmxTracker: "0xd2D1162512F927a7e282Ef43a362659E4F2a728F",
StakedGlpTracker: "0x1aDDD80E6039594eE970E5872D247bf0414C8903",
FeeGlpTracker: "0x4e971a87900b931fF39d1Aad67697F49835400b6",
ExtendedGmxTracker: "0x0755D33e45eD2B874c9ebF5B279023c8Bd1e5E93",
StakedGmxDistributor: "0x23208B91A98c7C1CD9FE63085BFf68311494F193",
StakedGlpDistributor: "0x60519b48ec4183a61ca2B8e37869E675FD203b34",
GmxVester: "0x199070DDfd1CFb69173aa2F7e20906F26B363004",
GlpVester: "0xA75287d2f8b217273E7FCD7E86eF07D33972042E",
AffiliateVester: "0x7c100c0F55A15221A4c1C5a25Db8C98A81df49B2",
OrderBook: "0x09f77E8A13De9a35a7231028187e9fD5DB8a2ACB",
OrderExecutor: "0x7257ac5D0a0aaC04AA7bA2AC0A6Eb742E332c3fB",
OrderBookReader: "0xa27C20A7CF0e1C68C0460706bB674f98F362Bc21",
PositionRouter: "0xb87a436B93fFE9D75c5cFA7bAcFff96430b09868",
PositionManager: "0x75E42e6f01baf1D6022bEa862A28774a9f8a4A0C",
UniswapGmxEthPool: "0x80A9ae39310abf666A87C743d6ebBD0E8C42158E",
ReferralStorage: "0xe6fab3f0c7199b0d34d7fbe83394fc0e0d06e99d",
ReferralReader: "0x8Aa382760BCdCe8644C33e6C2D52f6304A76F5c8",
Timelock: "0xaa50bD556CE0Fe61D4A57718BA43177a3aB6A597",
// Synthetics
DataStore: "0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8",
EventEmitter: "0xC8ee91A54287DB53897056e12D9819156D3822Fb",
SubaccountRouter: "0xa329221a77BE08485f59310b873b14815c82E10D",
ExchangeRouter: "0x5ac4e27341e4cccb3e5fd62f9e62db2adf43dd57",
DepositVault: "0xF89e77e8Dc11691C9e8757e84aaFbCD8A67d7A55",
WithdrawalVault: "0x0628D46b5D145f183AdB6Ef1f2c97eD1C4701C55",
OrderVault: "0x31eF83a530Fde1B38EE9A18093A333D8Bbbc40D5",
ShiftVault: "0xfe99609C4AA83ff6816b64563Bdffd7fa68753Ab",
SyntheticsReader: "0x0537C767cDAC0726c76Bb89e92904fe28fd02fE1",
SyntheticsRouter: "0x7452c558d45f8afC8c83dAe62C3f8A5BE19c71f6",
GlvReader: "0x6a9505D0B44cFA863d9281EA5B0b34cB36243b45",
GlvRouter: "0x994c598e3b0661bb805d53c6fa6b4504b23b68dd",
GlvVault: "0x393053B58f9678C9c28c2cE941fF6cac49C3F8f9",
ExternalHandler: "0x389CEf541397e872dC04421f166B5Bc2E0b374a5",
OpenOceanRouter: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
Multicall: "0x842ec2c7d803033edf55e478f461fc547bc54eb2",
},
[AVALANCHE]: {
// avalanche
Vault: "0x9ab2De34A33fB459b538c43f251eB825645e8595",
Router: "0x5F719c2F1095F7B9fc68a68e35B51194f4b6abe8",
VaultReader: "0x66eC8fc33A26feAEAe156afA3Cb46923651F6f0D",
Reader: "0x2eFEE1950ededC65De687b40Fd30a7B5f4544aBd",
GlpManager: "0xD152c7F25db7F4B95b7658323c5F33d176818EE4",
RewardRouter: "0x091eD806490Cc58Fd514441499e58984cCce0630",
GlpRewardRouter: "0xB70B91CE0771d3f4c81D87660f71Da31d48eB3B3",
RewardReader: "0x04Fc11Bd28763872d143637a7c768bD96E44c1b6",
GovToken: "0x0ff183E29f1924ad10475506D7722169010CecCb",
NATIVE_TOKEN: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
GLP: "0x01234181085565ed162a948b6a5e88758CD7c7b8",
GMX: "0x62edc0692BD897D2295872a9FFCac5425011c661",
ES_GMX: "0xFf1489227BbAAC61a9209A08929E4c2a526DdD17",
BN_GMX: "0x8087a341D32D445d9aC8aCc9c14F5781E04A26d2",
USDG: "0xc0253c3cC6aa5Ab407b5795a04c28fB063273894",
ES_GMX_IOU: "0x6260101218eC4cCfFF1b778936C6f2400f95A954", // placeholder address
StakedGmxTracker: "0x2bD10f8E93B3669b6d42E74eEedC65dd1B0a1342",
BonusGmxTracker: "0x908C4D94D34924765f1eDc22A1DD098397c59dD4",
FeeGmxTracker: "0x4d268a7d4C16ceB5a606c173Bd974984343fea13",
StakedGlpTracker: "0x9e295B5B976a184B14aD8cd72413aD846C299660",
FeeGlpTracker: "0xd2D1162512F927a7e282Ef43a362659E4F2a728F",
ExtendedGmxTracker: "0xB0D12Bf95CC1341d6C845C978daaf36F70b5910d",
StakedGmxDistributor: "0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a",
StakedGlpDistributor: "0xDd593Cf40734199afc9207eBe9ffF23dA4Bf7720",
GmxVester: "0x472361d3cA5F49c8E633FB50385BfaD1e018b445",
GlpVester: "0x62331A7Bd1dfB3A7642B7db50B5509E57CA3154A",
AffiliateVester: "0x754eC029EF9926184b4CFDeA7756FbBAE7f326f7",
OrderBook: "0x4296e307f108B2f583FF2F7B7270ee7831574Ae5",
OrderExecutor: "0x4296e307f108B2f583FF2F7B7270ee7831574Ae5",
OrderBookReader: "0xccFE3E576f8145403d3ce8f3c2f6519Dae40683B",
PositionRouter: "0xffF6D276Bc37c61A23f06410Dce4A400f66420f8",
PositionManager: "0xA21B83E579f4315951bA658654c371520BDcB866",
TraderJoeGmxAvaxPool: "0x0c91a070f862666bbcce281346be45766d874d98",
ReferralStorage: "0x827ed045002ecdabeb6e2b0d1604cf5fc3d322f8",
ReferralReader: "0x505Ce16D3017be7D76a7C2631C0590E71A975083",
Timelock: "0x8A68a039D555599Fd745f9343e8dE20C9eaFca75",
// Synthetics
DataStore: "0x2F0b22339414ADeD7D5F06f9D604c7fF5b2fe3f6",
EventEmitter: "0xDb17B211c34240B014ab6d61d4A31FA0C0e20c26",
SubaccountRouter: "0x5aEb6AD978f59e220aA9099e09574e1c5E03AafD",
ExchangeRouter: "0xe37d052e1deb99901de205e7186e31a36e4ef70c",
DepositVault: "0x90c670825d0C62ede1c5ee9571d6d9a17A722DFF",
WithdrawalVault: "0xf5F30B10141E1F63FC11eD772931A8294a591996",
OrderVault: "0xD3D60D22d415aD43b7e64b510D86A30f19B1B12C",
ShiftVault: "0x7fC46CCb386e9bbBFB49A2639002734C3Ec52b39",
SyntheticsReader: "0x618fCEe30D9A26e8533C3B244CAd2D6486AFf655",
SyntheticsRouter: "0x820F5FfC5b525cD4d88Cd91aCf2c28F16530Cc68",
GlvReader: "0xae9596a1C438675AcC75f69d32E21Ac9c8fF99bD",
GlvRouter: "0x16500c1d8ffe2f695d8dcadf753f664993287ae4",
GlvVault: "0x527FB0bCfF63C47761039bB386cFE181A92a4701",
OpenOceanRouter: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
ExternalHandler: "0xD149573a098223a9185433290a5A5CDbFa54a8A9",
Multicall: "0xcA11bde05977b3631167028862bE2a173976CA11",
},
[AVALANCHE_FUJI]: {
Vault: zeroAddress,
Router: zeroAddress,
VaultReader: zeroAddress,
Reader: zeroAddress,
GlpManager: zeroAddress,
RewardRouter: zeroAddress,
RewardReader: zeroAddress,
GlpRewardRouter: zeroAddress,
NATIVE_TOKEN: "0x1D308089a2D1Ced3f1Ce36B1FcaF815b07217be3",
GLP: zeroAddress,
GMX: zeroAddress,
ES_GMX: zeroAddress,
BN_GMX: zeroAddress,
USDG: zeroAddress,
ES_GMX_IOU: zeroAddress,
StakedGmxTracker: zeroAddress,
BonusGmxTracker: zeroAddress,
FeeGmxTracker: zeroAddress,
StakedGlpTracker: zeroAddress,
FeeGlpTracker: zeroAddress,
ExtendedGmxTracker: zeroAddress,
StakedGmxDistributor: zeroAddress,
StakedGlpDistributor: zeroAddress,
GmxVester: zeroAddress,
GlpVester: zeroAddress,
AffiliateVester: zeroAddress,
OrderBook: zeroAddress,
OrderExecutor: zeroAddress,
OrderBookReader: zeroAddress,
PositionRouter: zeroAddress,
PositionManager: zeroAddress,
TraderJoeGmxAvaxPool: zeroAddress,
ReferralStorage: "0x58726dB901C9DF3654F45a37DD307a0C44b6420e",
ReferralReader: zeroAddress,
// Synthetics
DataStore: "0xEA1BFb4Ea9A412dCCd63454AbC127431eBB0F0d4",
EventEmitter: "0xc67D98AC5803aFD776958622CeEE332A0B2CabB9",
ExchangeRouter: "0x52A1c10c462ca4e5219d0Eb4da5052cc73F9050D",
SubaccountRouter: "0x0595f01860aa5c4C6091EED096515b4b9FE372CE",
DepositVault: "0x2964d242233036C8BDC1ADC795bB4DeA6fb929f2",
WithdrawalVault: "0x74d49B6A630Bf519bDb6E4efc4354C420418A6A2",
OrderVault: "0x25D23e8E655727F2687CC808BB9589525A6F599B",
ShiftVault: "0x257D0EA0B040E2Cd1D456fB4C66d7814102aD346",
SyntheticsReader: "0x16Fb5b8846fbfAe09c034fCdF3D3F9492484DA80",
SyntheticsRouter: "0x5e7d61e4C52123ADF651961e4833aCc349b61491",
Timelock: zeroAddress,
GlvReader: "0x4599Ed5939C673505B7AFcd020E1d603b0dCAf69",
GlvRouter: "0x377d979AB35Cd848497707ffa6Ee91783f925b80",
GlvVault: "0x76f93b5240DF811a3fc32bEDd58daA5784e46C96",
OpenOceanRouter: zeroAddress,
ExternalHandler: "0x0d9F90c66C392c4d0e70EE0d399c43729B942512",
Multicall: "0x0f53e512b49202a37c81c6085417C9a9005F2196",
},
};
export function getContract(chainId: number, name: string): Address {
if (!CONTRACTS[chainId]) {
throw new Error(`Unknown chainId ${chainId}`);
}
if (!CONTRACTS[chainId][name]) {
throw new Error(`Unknown contract "${name}" for chainId ${chainId}`);
}
return CONTRACTS[chainId][name];
}

View File

@@ -0,0 +1,358 @@
import {hashData, hashString} from "../utils/hash.js";
export const POSITION_IMPACT_FACTOR_KEY = hashString("POSITION_IMPACT_FACTOR");
export const MAX_POSITION_IMPACT_FACTOR_KEY = hashString("MAX_POSITION_IMPACT_FACTOR");
export const POSITION_IMPACT_EXPONENT_FACTOR_KEY = hashString("POSITION_IMPACT_EXPONENT_FACTOR");
export const POSITION_FEE_FACTOR_KEY = hashString("POSITION_FEE_FACTOR");
export const SWAP_IMPACT_FACTOR_KEY = hashString("SWAP_IMPACT_FACTOR");
export const SWAP_IMPACT_EXPONENT_FACTOR_KEY = hashString("SWAP_IMPACT_EXPONENT_FACTOR");
export const SWAP_FEE_FACTOR_KEY = hashString("SWAP_FEE_FACTOR");
export const FEE_RECEIVER_DEPOSIT_FACTOR_KEY = hashString("FEE_RECEIVER_DEPOSIT_FACTOR");
export const BORROWING_FEE_RECEIVER_FACTOR_KEY = hashString("BORROWING_FEE_RECEIVER_FACTOR");
export const FEE_RECEIVER_WITHDRAWAL_FACTOR_KEY = hashString("FEE_RECEIVER_WITHDRAWAL_FACTOR");
export const FEE_RECEIVER_SWAP_FACTOR_KEY = hashString("FEE_RECEIVER_SWAP_FACTOR");
export const FEE_RECEIVER_POSITION_FACTOR_KEY = hashString("FEE_RECEIVER_POSITION_FACTOR");
export const OPEN_INTEREST_KEY = hashString("OPEN_INTEREST");
export const OPEN_INTEREST_IN_TOKENS_KEY = hashString("OPEN_INTEREST_IN_TOKENS");
export const POOL_AMOUNT_KEY = hashString("POOL_AMOUNT");
export const MAX_POOL_USD_FOR_DEPOSIT_KEY = hashString("MAX_POOL_USD_FOR_DEPOSIT");
export const MAX_POOL_AMOUNT_KEY = hashString("MAX_POOL_AMOUNT");
export const RESERVE_FACTOR_KEY = hashString("RESERVE_FACTOR");
export const OPEN_INTEREST_RESERVE_FACTOR_KEY = hashString("OPEN_INTEREST_RESERVE_FACTOR");
export const MAX_OPEN_INTEREST_KEY = hashString("MAX_OPEN_INTEREST");
export const NONCE_KEY = hashString("NONCE");
export const BORROWING_FACTOR_KEY = hashString("BORROWING_FACTOR");
export const BORROWING_EXPONENT_FACTOR_KEY = hashString("BORROWING_EXPONENT_FACTOR");
export const CUMULATIVE_BORROWING_FACTOR_KEY = hashString("CUMULATIVE_BORROWING_FACTOR");
export const TOTAL_BORROWING_KEY = hashString("TOTAL_BORROWING");
export const FUNDING_FACTOR_KEY = hashString("FUNDING_FACTOR");
export const FUNDING_EXPONENT_FACTOR_KEY = hashString("FUNDING_EXPONENT_FACTOR");
export const FUNDING_INCREASE_FACTOR_PER_SECOND = hashString("FUNDING_INCREASE_FACTOR_PER_SECOND");
export const FUNDING_DECREASE_FACTOR_PER_SECOND = hashString("FUNDING_DECREASE_FACTOR_PER_SECOND");
export const MIN_FUNDING_FACTOR_PER_SECOND = hashString("MIN_FUNDING_FACTOR_PER_SECOND");
export const MAX_FUNDING_FACTOR_PER_SECOND = hashString("MAX_FUNDING_FACTOR_PER_SECOND");
export const THRESHOLD_FOR_STABLE_FUNDING = hashString("THRESHOLD_FOR_STABLE_FUNDING");
export const THRESHOLD_FOR_DECREASE_FUNDING = hashString("THRESHOLD_FOR_DECREASE_FUNDING");
export const MAX_PNL_FACTOR_KEY = hashString("MAX_PNL_FACTOR");
export const MAX_PNL_FACTOR_FOR_WITHDRAWALS_KEY = hashString("MAX_PNL_FACTOR_FOR_WITHDRAWALS");
export const MAX_PNL_FACTOR_FOR_DEPOSITS_KEY = hashString("MAX_PNL_FACTOR_FOR_DEPOSITS");
export const MAX_PNL_FACTOR_FOR_TRADERS_KEY = hashString("MAX_PNL_FACTOR_FOR_TRADERS");
export const MAX_POSITION_IMPACT_FACTOR_FOR_LIQUIDATIONS_KEY = hashString(
"MAX_POSITION_IMPACT_FACTOR_FOR_LIQUIDATIONS"
);
export const POSITION_IMPACT_POOL_AMOUNT_KEY = hashString("POSITION_IMPACT_POOL_AMOUNT");
export const MIN_POSITION_IMPACT_POOL_AMOUNT_KEY = hashString("MIN_POSITION_IMPACT_POOL_AMOUNT");
export const POSITION_IMPACT_POOL_DISTRIBUTION_RATE_KEY = hashString("POSITION_IMPACT_POOL_DISTRIBUTION_RATE");
export const SWAP_IMPACT_POOL_AMOUNT_KEY = hashString("SWAP_IMPACT_POOL_AMOUNT");
export const MIN_COLLATERAL_USD_KEY = hashString("MIN_COLLATERAL_USD");
export const MIN_COLLATERAL_FACTOR_KEY = hashString("MIN_COLLATERAL_FACTOR");
export const MIN_COLLATERAL_FACTOR_FOR_OPEN_INTEREST_MULTIPLIER_KEY = hashString(
"MIN_COLLATERAL_FACTOR_FOR_OPEN_INTEREST_MULTIPLIER"
);
export const MIN_POSITION_SIZE_USD_KEY = hashString("MIN_POSITION_SIZE_USD");
export const MAX_LEVERAGE_KEY = hashString("MAX_LEVERAGE");
export const DEPOSIT_GAS_LIMIT_KEY = hashString("DEPOSIT_GAS_LIMIT");
export const WITHDRAWAL_GAS_LIMIT_KEY = hashString("WITHDRAWAL_GAS_LIMIT");
export const INCREASE_ORDER_GAS_LIMIT_KEY = hashString("INCREASE_ORDER_GAS_LIMIT");
export const DECREASE_ORDER_GAS_LIMIT_KEY = hashString("DECREASE_ORDER_GAS_LIMIT");
export const SWAP_ORDER_GAS_LIMIT_KEY = hashString("SWAP_ORDER_GAS_LIMIT");
export const SHIFT_GAS_LIMIT_KEY = hashString("SHIFT_GAS_LIMIT");
export const SINGLE_SWAP_GAS_LIMIT_KEY = hashString("SINGLE_SWAP_GAS_LIMIT");
export const TOKEN_TRANSFER_GAS_LIMIT_KEY = hashString("TOKEN_TRANSFER_GAS_LIMIT");
export const NATIVE_TOKEN_TRANSFER_GAS_LIMIT_KEY = hashString("NATIVE_TOKEN_TRANSFER_GAS_LIMIT");
export const ESTIMATED_GAS_FEE_BASE_AMOUNT_V2_1 = hashString("ESTIMATED_GAS_FEE_BASE_AMOUNT_V2_1");
export const ESTIMATED_GAS_FEE_PER_ORACLE_PRICE = hashString("ESTIMATED_GAS_FEE_PER_ORACLE_PRICE");
export const ESTIMATED_GAS_FEE_MULTIPLIER_FACTOR = hashString("ESTIMATED_GAS_FEE_MULTIPLIER_FACTOR");
export const MARKET_LIST_KEY = hashString("MARKET_LIST");
export const POSITION_LIST_KEY = hashString("POSITION_LIST");
export const ORDER_LIST_KEY = hashString("ORDER_LIST");
export const ACCOUNT_ORDER_LIST_KEY = hashString("ACCOUNT_ORDER_LIST");
export const CLAIMABLE_FUNDING_AMOUNT = hashString("CLAIMABLE_FUNDING_AMOUNT");
export const VIRTUAL_TOKEN_ID_KEY = hashString("VIRTUAL_TOKEN_ID");
export const VIRTUAL_MARKET_ID_KEY = hashString("VIRTUAL_MARKET_ID");
export const VIRTUAL_INVENTORY_FOR_POSITIONS_KEY = hashString("VIRTUAL_INVENTORY_FOR_POSITIONS");
export const VIRTUAL_INVENTORY_FOR_SWAPS_KEY = hashString("VIRTUAL_INVENTORY_FOR_SWAPS");
export const POOL_AMOUNT_ADJUSTMENT_KEY = hashString("POOL_AMOUNT_ADJUSTMENT");
export const AFFILIATE_REWARD_KEY = hashString("AFFILIATE_REWARD");
export const IS_MARKET_DISABLED_KEY = hashString("IS_MARKET_DISABLED");
export const UI_FEE_FACTOR = hashString("UI_FEE_FACTOR");
export const SUBACCOUNT_LIST_KEY = hashString("SUBACCOUNT_LIST");
export const MAX_ALLOWED_SUBACCOUNT_ACTION_COUNT = hashString("MAX_ALLOWED_SUBACCOUNT_ACTION_COUNT");
export const SUBACCOUNT_ACTION_COUNT = hashString("SUBACCOUNT_ACTION_COUNT");
export const SUBACCOUNT_ORDER_ACTION = hashString("SUBACCOUNT_ORDER_ACTION");
export const SUBACCOUNT_AUTO_TOP_UP_AMOUNT = hashString("SUBACCOUNT_AUTO_TOP_UP_AMOUNT");
export const GLV_MAX_MARKET_TOKEN_BALANCE_USD = hashString("GLV_MAX_MARKET_TOKEN_BALANCE_USD");
export const GLV_MAX_MARKET_TOKEN_BALANCE_AMOUNT = hashString("GLV_MAX_MARKET_TOKEN_BALANCE_AMOUNT");
export const IS_GLV_MARKET_DISABLED = hashString("IS_GLV_MARKET_DISABLED");
export const GLV_SHIFT_LAST_EXECUTED_AT = hashString("GLV_SHIFT_LAST_EXECUTED_AT");
export const GLV_SHIFT_MIN_INTERVAL = hashString("GLV_SHIFT_MIN_INTERVAL");
export const GLV_DEPOSIT_GAS_LIMIT = hashString("GLV_DEPOSIT_GAS_LIMIT");
export const GLV_WITHDRAWAL_GAS_LIMIT = hashString("GLV_WITHDRAWAL_GAS_LIMIT");
export const GLV_PER_MARKET_GAS_LIMIT = hashString("GLV_PER_MARKET_GAS_LIMIT");
export const MAX_AUTO_CANCEL_ORDERS_KEY = hashString("MAX_AUTO_CANCEL_ORDERS");
export const OPTIMAL_USAGE_FACTOR = hashString("OPTIMAL_USAGE_FACTOR");
export const BASE_BORROWING_FACTOR = hashString("BASE_BORROWING_FACTOR");
export const ABOVE_OPTIMAL_USAGE_BORROWING_FACTOR = hashString("ABOVE_OPTIMAL_USAGE_BORROWING_FACTOR");
export function glvShiftLastExecutedAtKey(glvAddress: string) {
return hashData(["bytes32", "address"], [GLV_SHIFT_LAST_EXECUTED_AT, glvAddress]);
}
export function glvShiftMinIntervalKey(glvAddress: string) {
return hashData(["bytes32", "address"], [GLV_SHIFT_MIN_INTERVAL, glvAddress]);
}
export function glvMaxMarketTokenBalanceUsdKey(glvAddress: string, market: string) {
return hashData(["bytes32", "address", "address"], [GLV_MAX_MARKET_TOKEN_BALANCE_USD, glvAddress, market]);
}
export function glvMaxMarketTokenBalanceAmountKey(glvAddress: string, market: string) {
return hashData(["bytes32", "address", "address"], [GLV_MAX_MARKET_TOKEN_BALANCE_AMOUNT, glvAddress, market]);
}
export function isGlvDisabledKey(glvAddress: string, market: string) {
return hashData(["bytes32", "address", "address"], [IS_GLV_MARKET_DISABLED, glvAddress, market]);
}
export function positionImpactFactorKey(market: string, isPositive: boolean) {
return hashData(["bytes32", "address", "bool"], [POSITION_IMPACT_FACTOR_KEY, market, isPositive]);
}
export function positionImpactExponentFactorKey(market: string) {
return hashData(["bytes32", "address"], [POSITION_IMPACT_EXPONENT_FACTOR_KEY, market]);
}
export function maxPositionImpactFactorKey(market: string, isPositive: boolean) {
return hashData(["bytes32", "address", "bool"], [MAX_POSITION_IMPACT_FACTOR_KEY, market, isPositive]);
}
export function positionFeeFactorKey(market: string, forPositiveImpact: boolean) {
return hashData(["bytes32", "address", "bool"], [POSITION_FEE_FACTOR_KEY, market, forPositiveImpact]);
}
export function swapImpactFactorKey(market: string, isPositive: boolean) {
return hashData(["bytes32", "address", "bool"], [SWAP_IMPACT_FACTOR_KEY, market, isPositive]);
}
export function swapImpactExponentFactorKey(market: string) {
return hashData(["bytes32", "address"], [SWAP_IMPACT_EXPONENT_FACTOR_KEY, market]);
}
export function swapFeeFactorKey(market: string, forPositiveImpact: boolean) {
return hashData(["bytes32", "address", "bool"], [SWAP_FEE_FACTOR_KEY, market, forPositiveImpact]);
}
export function openInterestKey(market: string, collateralToken: string, isLong: boolean) {
return hashData(["bytes32", "address", "address", "bool"], [OPEN_INTEREST_KEY, market, collateralToken, isLong]);
}
export function openInterestInTokensKey(market: string, collateralToken: string, isLong: boolean) {
return hashData(
["bytes32", "address", "address", "bool"],
[OPEN_INTEREST_IN_TOKENS_KEY, market, collateralToken, isLong]
);
}
export function poolAmountKey(market: string, token: string) {
return hashData(["bytes32", "address", "address"], [POOL_AMOUNT_KEY, market, token]);
}
export function reserveFactorKey(market: string, isLong: boolean) {
return hashData(["bytes32", "address", "bool"], [RESERVE_FACTOR_KEY, market, isLong]);
}
export function openInterestReserveFactorKey(market: string, isLong: boolean) {
return hashData(["bytes32", "address", "bool"], [OPEN_INTEREST_RESERVE_FACTOR_KEY, market, isLong]);
}
export function maxOpenInterestKey(market: string, isLong: boolean) {
return hashData(["bytes32", "address", "bool"], [MAX_OPEN_INTEREST_KEY, market, isLong]);
}
export function borrowingFactorKey(market: string, isLong: boolean) {
return hashData(["bytes32", "address", "bool"], [BORROWING_FACTOR_KEY, market, isLong]);
}
export function borrowingExponentFactorKey(market: string, isLong: boolean) {
return hashData(["bytes32", "address", "bool"], [BORROWING_EXPONENT_FACTOR_KEY, market, isLong]);
}
export function cumulativeBorrowingFactorKey(market: string, isLong: boolean) {
return hashData(["bytes32", "address", "bool"], [CUMULATIVE_BORROWING_FACTOR_KEY, market, isLong]);
}
export function totalBorrowingKey(market: string, isLong: boolean) {
return hashData(["bytes32", "address", "bool"], [TOTAL_BORROWING_KEY, market, isLong]);
}
export function fundingFactorKey(market: string) {
return hashData(["bytes32", "address"], [FUNDING_FACTOR_KEY, market]);
}
export function fundingExponentFactorKey(market: string) {
return hashData(["bytes32", "address"], [FUNDING_EXPONENT_FACTOR_KEY, market]);
}
export function fundingIncreaseFactorPerSecondKey(market: string) {
return hashData(["bytes32", "address"], [FUNDING_INCREASE_FACTOR_PER_SECOND, market]);
}
export function fundingDecreaseFactorPerSecondKey(market: string) {
return hashData(["bytes32", "address"], [FUNDING_DECREASE_FACTOR_PER_SECOND, market]);
}
export function minFundingFactorPerSecondKey(market: string) {
return hashData(["bytes32", "address"], [MIN_FUNDING_FACTOR_PER_SECOND, market]);
}
export function maxFundingFactorPerSecondKey(market: string) {
return hashData(["bytes32", "address"], [MAX_FUNDING_FACTOR_PER_SECOND, market]);
}
export function thresholdForStableFundingKey(market: string) {
return hashData(["bytes32", "address"], [THRESHOLD_FOR_STABLE_FUNDING, market]);
}
export function thresholdForDecreaseFundingKey(market: string) {
return hashData(["bytes32", "address"], [THRESHOLD_FOR_DECREASE_FUNDING, market]);
}
export function maxPnlFactorKey(pnlFactorType: string, market: string, isLong: boolean) {
return hashData(["bytes32", "bytes32", "address", "bool"], [MAX_PNL_FACTOR_KEY, pnlFactorType, market, isLong]);
}
export function positionImpactPoolAmountKey(market: string) {
return hashData(["bytes32", "address"], [POSITION_IMPACT_POOL_AMOUNT_KEY, market]);
}
export function minPositionImpactPoolAmountKey(market: string) {
return hashData(["bytes32", "address"], [MIN_POSITION_IMPACT_POOL_AMOUNT_KEY, market]);
}
export function positionImpactPoolDistributionRateKey(market: string) {
return hashData(["bytes32", "address"], [POSITION_IMPACT_POOL_DISTRIBUTION_RATE_KEY, market]);
}
export function maxPositionImpactFactorForLiquidationsKey(market: string) {
return hashData(["bytes32", "address"], [MAX_POSITION_IMPACT_FACTOR_FOR_LIQUIDATIONS_KEY, market]);
}
export function swapImpactPoolAmountKey(market: string, token: string) {
return hashData(["bytes32", "address", "address"], [SWAP_IMPACT_POOL_AMOUNT_KEY, market, token]);
}
export function orderKey(dataStoreAddress: string, nonce: bigint) {
return hashData(["address", "uint256"], [dataStoreAddress, nonce]);
}
export function depositGasLimitKey() {
return DEPOSIT_GAS_LIMIT_KEY;
}
export function withdrawalGasLimitKey() {
return hashData(["bytes32"], [WITHDRAWAL_GAS_LIMIT_KEY]);
}
export function shiftGasLimitKey() {
return SHIFT_GAS_LIMIT_KEY;
}
export function singleSwapGasLimitKey() {
return SINGLE_SWAP_GAS_LIMIT_KEY;
}
export function increaseOrderGasLimitKey() {
return INCREASE_ORDER_GAS_LIMIT_KEY;
}
export function decreaseOrderGasLimitKey() {
return DECREASE_ORDER_GAS_LIMIT_KEY;
}
export function swapOrderGasLimitKey() {
return SWAP_ORDER_GAS_LIMIT_KEY;
}
export function accountOrderListKey(account: string) {
return hashData(["bytes32", "address"], [ACCOUNT_ORDER_LIST_KEY, account]);
}
export function minCollateralFactorKey(market: string) {
return hashData(["bytes32", "address"], [MIN_COLLATERAL_FACTOR_KEY, market]);
}
export function minCollateralFactorForOpenInterest(market: string, isLong: boolean) {
return hashData(
["bytes32", "address", "bool"],
[MIN_COLLATERAL_FACTOR_FOR_OPEN_INTEREST_MULTIPLIER_KEY, market, isLong]
);
}
export function hashedPositionKey(account: string, market: string, collateralToken: string, isLong: boolean) {
return hashData(["address", "address", "address", "bool"], [account, market, collateralToken, isLong]);
}
export function claimableFundingAmountKey(market: string, token: string, account: string) {
return hashData(["bytes32", "address", "address", "address"], [CLAIMABLE_FUNDING_AMOUNT, market, token, account]);
}
export function virtualTokenIdKey(token: string) {
return hashData(["bytes32", "address"], [VIRTUAL_TOKEN_ID_KEY, token]);
}
export function virtualMarketIdKey(market: string) {
return hashData(["bytes32", "address"], [VIRTUAL_MARKET_ID_KEY, market]);
}
export function virtualInventoryForSwapsKey(virtualMarketId: string, token: string) {
return hashData(["bytes32", "bytes32", "address"], [VIRTUAL_INVENTORY_FOR_SWAPS_KEY, virtualMarketId, token]);
}
export function virtualInventoryForPositionsKey(virtualTokenId: string) {
return hashData(["bytes32", "bytes32"], [VIRTUAL_INVENTORY_FOR_POSITIONS_KEY, virtualTokenId]);
}
export function poolAmountAdjustmentKey(market: string, token: string) {
return hashData(["bytes32", "address", "address"], [POOL_AMOUNT_ADJUSTMENT_KEY, market, token]);
}
export function affiliateRewardKey(market: string, token: string, account: string) {
return hashData(["bytes32", "address", "address", "address"], [AFFILIATE_REWARD_KEY, market, token, account]);
}
export function isMarketDisabledKey(market: string) {
return hashData(["bytes32", "address"], [IS_MARKET_DISABLED_KEY, market]);
}
export function maxPoolUsdForDepositKey(market: string, token: string) {
return hashData(["bytes32", "address", "address"], [MAX_POOL_USD_FOR_DEPOSIT_KEY, market, token]);
}
export function maxPoolAmountKey(market: string, token: string) {
return hashData(["bytes32", "address", "address"], [MAX_POOL_AMOUNT_KEY, market, token]);
}
export function uiFeeFactorKey(address: string) {
return hashData(["bytes32", "address"], [UI_FEE_FACTOR, address]);
}
export function subaccountListKey(account: string) {
return hashData(["bytes32", "address"], [SUBACCOUNT_LIST_KEY, account]);
}
export function maxAllowedSubaccountActionCountKey(account: string, subaccount: string, actionType: string) {
return hashData(
["bytes32", "address", "address", "bytes32"],
[MAX_ALLOWED_SUBACCOUNT_ACTION_COUNT, account, subaccount, actionType]
);
}
export function subaccountActionCountKey(account: string, subaccount: string, actionType: string) {
return hashData(
["bytes32", "address", "address", "bytes32"],
[SUBACCOUNT_ACTION_COUNT, account, subaccount, actionType]
);
}
export function subaccountAutoTopUpAmountKey(account: string, subaccount: string) {
return hashData(["bytes32", "address", "address"], [SUBACCOUNT_AUTO_TOP_UP_AMOUNT, account, subaccount]);
}

View File

@@ -0,0 +1,13 @@
export const USD_DECIMALS = 30;
export const BASIS_POINTS_DIVISOR = 10000;
export const BASIS_POINTS_DIVISOR_BIGINT = 10000n;
// V2
export const HIGH_PRICE_IMPACT_BPS = 80; // 0.8%
export const HIGH_POSITION_IMPACT_BPS = 50; // 0.5%
export const HIGH_COLLATERAL_IMPACT_BPS = 500; // 5%
export const HIGH_SWAP_IMPACT_BPS = 50; // 0.5%
export const DEFAULT_ACCEPTABLE_PRICE_IMPACT_BUFFER = 30; // 0.3%
export const HIGH_ALLOWED_SWAP_SLIPPAGE_BPS = 20; // 0.2%
export const DEFAULT_ALLOWED_SWAP_SLIPPAGE_BPS = 100n; // 1%

View File

@@ -0,0 +1,846 @@
/*
This files is used to pre-build data during the build process.
Avoid adding client-side code here, as it can break the build process.
*/
import {ARBITRUM, AVALANCHE, AVALANCHE_FUJI} from "./chains.js";
export const SWAP_GRAPH_MAX_MARKETS_PER_TOKEN = 5;
export type MarketConfig = {
marketTokenAddress: string;
indexTokenAddress: string;
longTokenAddress: string;
shortTokenAddress: string;
};
/*
ATTENTION
When adding new markets, please add them also to the end of the list in ./src/configs/static/sortedMarkets.ts
*/
export const MARKETS: Record<string, Record<string, MarketConfig>> = {
[ARBITRUM]: {
// BTC/USD [WBTC.e-USDC]
"0x47c031236e19d024b42f8AE6780E44A573170703": {
marketTokenAddress: "0x47c031236e19d024b42f8AE6780E44A573170703",
indexTokenAddress: "0x47904963fc8b2340414262125aF798B9655E58Cd",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// ETH/USD [WETH-USDC]
"0x70d95587d40A2caf56bd97485aB3Eec10Bee6336": {
marketTokenAddress: "0x70d95587d40A2caf56bd97485aB3Eec10Bee6336",
indexTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// DOGE/USD [WETH-USDC]
"0x6853EA96FF216fAb11D2d930CE3C508556A4bdc4": {
marketTokenAddress: "0x6853EA96FF216fAb11D2d930CE3C508556A4bdc4",
indexTokenAddress: "0xC4da4c24fd591125c3F47b340b6f4f76111883d8",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// SOL/USD [SOL-USDC]
"0x09400D9DB990D5ed3f35D7be61DfAEB900Af03C9": {
marketTokenAddress: "0x09400D9DB990D5ed3f35D7be61DfAEB900Af03C9",
indexTokenAddress: "0x2bcC6D6CdBbDC0a4071e48bb3B969b06B3330c07",
longTokenAddress: "0x2bcC6D6CdBbDC0a4071e48bb3B969b06B3330c07",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// LTC/USD [WETH-USDC]
"0xD9535bB5f58A1a75032416F2dFe7880C30575a41": {
marketTokenAddress: "0xD9535bB5f58A1a75032416F2dFe7880C30575a41",
indexTokenAddress: "0xB46A094Bc4B0adBD801E14b9DB95e05E28962764",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// UNI/USD [UNI-USDC]
"0xc7Abb2C5f3BF3CEB389dF0Eecd6120D451170B50": {
marketTokenAddress: "0xc7Abb2C5f3BF3CEB389dF0Eecd6120D451170B50",
indexTokenAddress: "0xFa7F8980b0f1E64A2062791cc3b0871572f1F7f0",
longTokenAddress: "0xFa7F8980b0f1E64A2062791cc3b0871572f1F7f0",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// LINK/USD [LINK-USDC]
"0x7f1fa204bb700853D36994DA19F830b6Ad18455C": {
marketTokenAddress: "0x7f1fa204bb700853D36994DA19F830b6Ad18455C",
indexTokenAddress: "0xf97f4df75117a78c1A5a0DBb814Af92458539FB4",
longTokenAddress: "0xf97f4df75117a78c1A5a0DBb814Af92458539FB4",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// ARB/USD [ARB-USDC]
"0xC25cEf6061Cf5dE5eb761b50E4743c1F5D7E5407": {
marketTokenAddress: "0xC25cEf6061Cf5dE5eb761b50E4743c1F5D7E5407",
indexTokenAddress: "0x912CE59144191C1204E64559FE8253a0e49E6548",
longTokenAddress: "0x912CE59144191C1204E64559FE8253a0e49E6548",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// SWAP-ONLY [USDC-USDC.e]
"0x9C2433dFD71096C435Be9465220BB2B189375eA7": {
marketTokenAddress: "0x9C2433dFD71096C435Be9465220BB2B189375eA7",
indexTokenAddress: "0x0000000000000000000000000000000000000000",
longTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
shortTokenAddress: "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
},
// SWAP-ONLY [USDC-USDT]
"0xB686BcB112660343E6d15BDb65297e110C8311c4": {
marketTokenAddress: "0xB686BcB112660343E6d15BDb65297e110C8311c4",
indexTokenAddress: "0x0000000000000000000000000000000000000000",
longTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
shortTokenAddress: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
},
// SWAP-ONLY [USDC-DAI]
"0xe2fEDb9e6139a182B98e7C2688ccFa3e9A53c665": {
marketTokenAddress: "0xe2fEDb9e6139a182B98e7C2688ccFa3e9A53c665",
indexTokenAddress: "0x0000000000000000000000000000000000000000",
longTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
shortTokenAddress: "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
},
// XRP/USD [WETH-USDC]
"0x0CCB4fAa6f1F1B30911619f1184082aB4E25813c": {
marketTokenAddress: "0x0CCB4fAa6f1F1B30911619f1184082aB4E25813c",
indexTokenAddress: "0xc14e065b0067dE91534e032868f5Ac6ecf2c6868",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// BNB/USD [BNB-USDC]
"0x2d340912Aa47e33c90Efb078e69E70EFe2B34b9B": {
marketTokenAddress: "0x2d340912Aa47e33c90Efb078e69E70EFe2B34b9B",
indexTokenAddress: "0xa9004A5421372E1D83fB1f85b0fc986c912f91f3",
longTokenAddress: "0xa9004A5421372E1D83fB1f85b0fc986c912f91f3",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// AAVE [AAVE-USDC]
"0x1CbBa6346F110c8A5ea739ef2d1eb182990e4EB2": {
marketTokenAddress: "0x1CbBa6346F110c8A5ea739ef2d1eb182990e4EB2",
indexTokenAddress: "0xba5DdD1f9d7F570dc94a51479a000E3BCE967196",
longTokenAddress: "0xba5DdD1f9d7F570dc94a51479a000E3BCE967196",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// ATOM [WETH-USDC]
"0x248C35760068cE009a13076D573ed3497A47bCD4": {
marketTokenAddress: "0x248C35760068cE009a13076D573ed3497A47bCD4",
indexTokenAddress: "0x7D7F1765aCbaF847b9A1f7137FE8Ed4931FbfEbA",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// NEAR [WETH-USDC]
"0x63Dc80EE90F26363B3FCD609007CC9e14c8991BE": {
marketTokenAddress: "0x63Dc80EE90F26363B3FCD609007CC9e14c8991BE",
indexTokenAddress: "0x1FF7F3EFBb9481Cbd7db4F932cBCD4467144237C",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// AVAX [WAVAX-USDC]
"0x7BbBf946883a5701350007320F525c5379B8178A": {
marketTokenAddress: "0x7BbBf946883a5701350007320F525c5379B8178A",
indexTokenAddress: "0x565609fAF65B92F7be02468acF86f8979423e514",
longTokenAddress: "0x565609fAF65B92F7be02468acF86f8979423e514",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// OP [OP-USDC]
"0x4fDd333FF9cA409df583f306B6F5a7fFdE790739": {
marketTokenAddress: "0x4fDd333FF9cA409df583f306B6F5a7fFdE790739",
indexTokenAddress: "0xaC800FD6159c2a2CB8fC31EF74621eB430287a5A",
longTokenAddress: "0xaC800FD6159c2a2CB8fC31EF74621eB430287a5A",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// BTC/USD [WBTC.e-WBTC.e]
"0x7C11F78Ce78768518D743E81Fdfa2F860C6b9A77": {
marketTokenAddress: "0x7C11F78Ce78768518D743E81Fdfa2F860C6b9A77",
indexTokenAddress: "0x47904963fc8b2340414262125aF798B9655E58Cd",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
},
// ETH/USD [WETH-WETH]
"0x450bb6774Dd8a756274E0ab4107953259d2ac541": {
marketTokenAddress: "0x450bb6774Dd8a756274E0ab4107953259d2ac541",
indexTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
},
// GMX/USD [GMX-USDC]
"0x55391D178Ce46e7AC8eaAEa50A72D1A5a8A622Da": {
marketTokenAddress: "0x55391D178Ce46e7AC8eaAEa50A72D1A5a8A622Da",
indexTokenAddress: "0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a",
longTokenAddress: "0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// PEPE [PEPE-USDC]
"0x2b477989A149B17073D9C9C82eC9cB03591e20c6": {
marketTokenAddress: "0x2b477989A149B17073D9C9C82eC9cB03591e20c6",
indexTokenAddress: "0x25d887Ce7a35172C62FeBFD67a1856F20FaEbB00",
longTokenAddress: "0x25d887Ce7a35172C62FeBFD67a1856F20FaEbB00",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// WIF [WIF-USDC]
"0x0418643F94Ef14917f1345cE5C460C37dE463ef7": {
marketTokenAddress: "0x0418643F94Ef14917f1345cE5C460C37dE463ef7",
indexTokenAddress: "0xA1b91fe9FD52141Ff8cac388Ce3F10BFDc1dE79d",
longTokenAddress: "0xA1b91fe9FD52141Ff8cac388Ce3F10BFDc1dE79d",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// ETH/USD [wstETH-USDe]
"0x0Cf1fb4d1FF67A3D8Ca92c9d6643F8F9be8e03E5": {
marketTokenAddress: "0x0Cf1fb4d1FF67A3D8Ca92c9d6643F8F9be8e03E5",
indexTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
longTokenAddress: "0x5979D7b546E38E414F7E9822514be443A4800529",
shortTokenAddress: "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34",
},
// SWAP-ONLY [wstETH-WETH]
"0xb56E5E2eB50cf5383342914b0C85Fe62DbD861C8": {
marketTokenAddress: "0xb56E5E2eB50cf5383342914b0C85Fe62DbD861C8",
indexTokenAddress: "0x0000000000000000000000000000000000000000",
longTokenAddress: "0x5979D7b546E38E414F7E9822514be443A4800529",
shortTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
},
// SWAP-ONLY [USDe-USDC]
"0x45aD16Aaa28fb66Ef74d5ca0Ab9751F2817c81a4": {
marketTokenAddress: "0x45aD16Aaa28fb66Ef74d5ca0Ab9751F2817c81a4",
indexTokenAddress: "0x0000000000000000000000000000000000000000",
longTokenAddress: "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// SHIB/USD [WETH-USDC]
"0xB62369752D8Ad08392572db6d0cc872127888beD": {
marketTokenAddress: "0xB62369752D8Ad08392572db6d0cc872127888beD",
indexTokenAddress: "0x3E57D02f9d196873e55727382974b02EdebE6bfd",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// STX/USD [wBTC-USDC]
"0xD9377d9B9a2327C7778867203deeA73AB8a68b6B": {
marketTokenAddress: "0xD9377d9B9a2327C7778867203deeA73AB8a68b6B",
indexTokenAddress: "0xBaf07cF91D413C0aCB2b7444B9Bf13b4e03c9D71",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// ORDI/USD [wBTC-USDC]
"0x93385F7C646A3048051914BDFaC25F4d620aeDF1": {
marketTokenAddress: "0x93385F7C646A3048051914BDFaC25F4d620aeDF1",
indexTokenAddress: "0x1E15d08f3CA46853B692EE28AE9C7a0b88a9c994",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// BTC/USD [tBTC]
"0xd62068697bCc92AF253225676D618B0C9f17C663": {
marketTokenAddress: "0xd62068697bCc92AF253225676D618B0C9f17C663",
indexTokenAddress: "0x47904963fc8b2340414262125aF798B9655E58Cd",
longTokenAddress: "0x6c84a8f1c29108F47a79964b5Fe888D4f4D0dE40",
shortTokenAddress: "0x6c84a8f1c29108F47a79964b5Fe888D4f4D0dE40",
},
// EIGEN/USD [WETH-USDC]
"0xD4b737892baB8446Ea1e8Bb901db092fb1EC1791": {
marketTokenAddress: "0xD4b737892baB8446Ea1e8Bb901db092fb1EC1791",
indexTokenAddress: "0x606C3e5075e5555e79Aa15F1E9FACB776F96C248",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// SATS/USD [WBTC-USDC]
"0x8ea4Fb801493DaD8724F90Fb2e279534fa591366": {
marketTokenAddress: "0x8ea4Fb801493DaD8724F90Fb2e279534fa591366",
indexTokenAddress: "0x2cD2eB61D17b78239Fcd19aafF72981B5D5eF319",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// POL/USD [ETH-USDC]
"0xD0a1AFDDE31Eb51e8b53bdCE989EB8C2404828a4": {
marketTokenAddress: "0xD0a1AFDDE31Eb51e8b53bdCE989EB8C2404828a4",
indexTokenAddress: "0x9c74772b713a1B032aEB173E28683D937E51921c",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// AAVE/USD [ETH-USDC]
"0x77B2eC357b56c7d05a87971dB0188DBb0C7836a5": {
marketTokenAddress: "0x77B2eC357b56c7d05a87971dB0188DBb0C7836a5",
indexTokenAddress: "0xba5DdD1f9d7F570dc94a51479a000E3BCE967196",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// PEPE/USD [ETH-USDC]
"0x0Bb2a83F995E1E1eae9D7fDCE68Ab1ac55b2cc85": {
marketTokenAddress: "0x0Bb2a83F995E1E1eae9D7fDCE68Ab1ac55b2cc85",
indexTokenAddress: "0x25d887Ce7a35172C62FeBFD67a1856F20FaEbB00",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// UNI/USD [ETH-USDC]
"0xD8471b9Ea126272E6d32B5e4782Ed76DB7E554a4": {
marketTokenAddress: "0xD8471b9Ea126272E6d32B5e4782Ed76DB7E554a4",
indexTokenAddress: "0xFa7F8980b0f1E64A2062791cc3b0871572f1F7f0",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// APE/USD [APE-USDC]
"0xdAB21c4d1F569486334C93685Da2b3F9b0A078e8": {
marketTokenAddress: "0xdAB21c4d1F569486334C93685Da2b3F9b0A078e8",
indexTokenAddress: "0x7f9FBf9bDd3F4105C478b996B648FE6e828a1e98",
longTokenAddress: "0x7f9FBf9bDd3F4105C478b996B648FE6e828a1e98",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// SUI/USD [WETH-USDC]
"0x6Ecf2133E2C9751cAAdCb6958b9654baE198a797": {
marketTokenAddress: "0x6Ecf2133E2C9751cAAdCb6958b9654baE198a797",
indexTokenAddress: "0x197aa2DE1313c7AD50184234490E12409B2a1f95",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// SEI/USD [WETH-USDC]
"0xB489711B1cB86afDA48924730084e23310EB4883": {
marketTokenAddress: "0xB489711B1cB86afDA48924730084e23310EB4883",
indexTokenAddress: "0x55e85A147a1029b985384822c0B2262dF8023452",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// APT/USD [WETH-USDC]
"0x66A69c8eb98A7efE22A22611d1967dfec786a708": {
marketTokenAddress: "0x66A69c8eb98A7efE22A22611d1967dfec786a708",
indexTokenAddress: "0x3f8f0dCE4dCE4d0D1d0871941e79CDA82cA50d0B",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// TIA/USD [WETH-USDC]
"0xBeB1f4EBC9af627Ca1E5a75981CE1AE97eFeDA22": {
marketTokenAddress: "0xBeB1f4EBC9af627Ca1E5a75981CE1AE97eFeDA22",
indexTokenAddress: "0x38676f62d166f5CE7De8433F51c6B3D6D9d66C19",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// TRX/USD [WETH-USDC]
"0x3680D7bFE9260D3c5DE81AEB2194c119a59A99D1": {
marketTokenAddress: "0x3680D7bFE9260D3c5DE81AEB2194c119a59A99D1",
indexTokenAddress: "0xb06aa7E4af937C130dDade66f6ed7642716fe07A",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// TON/USD [WETH-USDC]
"0x15c6eBD4175ffF9EE3c2615c556fCf62D2d9499c": {
marketTokenAddress: "0x15c6eBD4175ffF9EE3c2615c556fCf62D2d9499c",
indexTokenAddress: "0xB2f7cefaeEb08Aa347705ac829a7b8bE2FB560f3",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// WLD/USD [WETH-USDC]
"0x872b5D567a2469Ed92D252eaCB0EB3BB0769e05b": {
marketTokenAddress: "0x872b5D567a2469Ed92D252eaCB0EB3BB0769e05b",
indexTokenAddress: "0x75B9AdD873641b253718810E6c65dB6d72311FD0",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// BONK/USD [WETH-USDC]
"0xFaC5fF56c269432706d47DC82Ab082E9AE7D989E": {
marketTokenAddress: "0xFaC5fF56c269432706d47DC82Ab082E9AE7D989E",
indexTokenAddress: "0x1FD10E767187A92f0AB2ABDEEF4505e319cA06B2",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// TAO/USD [WBTC-USDC]
"0xe55e1A29985488A2c8846a91E925c2B7C6564db1": {
marketTokenAddress: "0xe55e1A29985488A2c8846a91E925c2B7C6564db1",
indexTokenAddress: "0x938aef36CAaFbcB37815251B602168087eC14648",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// BOME/USD [WBTC/USDC]
"0x71237F8C3d1484495A136022E16840b70fF84a69": {
marketTokenAddress: "0x71237F8C3d1484495A136022E16840b70fF84a69",
indexTokenAddress: "0x3Eea56A1ccCdbfB70A26aD381C71Ee17E4c8A15F",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// FLOKI/USD [WBTC/USDC]
"0xfD46a5702D4d97cE0164375744c65F0c31A3901b": {
marketTokenAddress: "0xfD46a5702D4d97cE0164375744c65F0c31A3901b",
indexTokenAddress: "0x6792c5B8962ffbDD020c6b6FD0Be7b182e0e33a3",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// MEME/USD [WBTC/USDC]
"0x6CB901Cc64c024C3Fe4404c940FF9a3Acc229D2C": {
marketTokenAddress: "0x6CB901Cc64c024C3Fe4404c940FF9a3Acc229D2C",
indexTokenAddress: "0xaF770F03518686a365300ab35AD860e99967B2f0",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// MEW/USD [WBTC/USDC]
"0x71B7fF592a974e2B501D8A7a11f5c42DcD365244": {
marketTokenAddress: "0x71B7fF592a974e2B501D8A7a11f5c42DcD365244",
indexTokenAddress: "0x5503CF72f54b6d692d36BBCD391516A7dE068687",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// GMX [GMX]
"0xbD48149673724f9cAeE647bb4e9D9dDaF896Efeb": {
marketTokenAddress: "0xbD48149673724f9cAeE647bb4e9D9dDaF896Efeb",
indexTokenAddress: "0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a",
longTokenAddress: "0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a",
shortTokenAddress: "0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a",
},
// PENDLE/USD [PENDLE/USDC]
"0x784292E87715d93afD7cb8C941BacaFAAA9A5102": {
marketTokenAddress: "0x784292E87715d93afD7cb8C941BacaFAAA9A5102",
indexTokenAddress: "0x0c880f6761F1af8d9Aa9C466984b80DAb9a8c9e8",
longTokenAddress: "0x0c880f6761F1af8d9Aa9C466984b80DAb9a8c9e8",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// ADA/USD [WBTC/USDC]
"0xcaCb964144f9056A8f99447a303E60b4873Ca9B4": {
marketTokenAddress: "0xcaCb964144f9056A8f99447a303E60b4873Ca9B4",
indexTokenAddress: "0x53186c8419BEB83fE4Da74F7875041a1287337ED",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// BCH/USD [WBTC/USDC]
"0x62feB8Ec060A7dE5b32BbbF4AC70050f8a043C17": {
marketTokenAddress: "0x62feB8Ec060A7dE5b32BbbF4AC70050f8a043C17",
indexTokenAddress: "0xc33D9C096e74aa4f571E9417b69a19C4A1e72ef2",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// DOT/USD [WBTC/USDC]
"0x7B2D09fca2395713dcc2F67323e4876F27b9ecB2": {
marketTokenAddress: "0x7B2D09fca2395713dcc2F67323e4876F27b9ecB2",
indexTokenAddress: "0xE958f107b467d5172573F761d26931D658C1b436",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// ICP/USD [WBTC/USDC]
"0xdc4e96A251Ff43Eeac710462CD8A9D18Dc802F18": {
marketTokenAddress: "0xdc4e96A251Ff43Eeac710462CD8A9D18Dc802F18",
indexTokenAddress: "0xdaf0A71608938F762e37eC5F72F670Cc44703454",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// XLM/USD [WBTC/USDC]
"0xe902D1526c834D5001575b2d0Ef901dfD0aa097A": {
marketTokenAddress: "0xe902D1526c834D5001575b2d0Ef901dfD0aa097A",
indexTokenAddress: "0xc5dbD52Ae5a927Cf585B884011d0C7631C9974c6",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// RENDER/USD [WETH/USDC]
"0x4c505e0062459cf8F60FfF13279c92ea15aE6e2D": {
marketTokenAddress: "0x4c505e0062459cf8F60FfF13279c92ea15aE6e2D",
indexTokenAddress: "0x82BB89fcc64c5d4016C5Ed1AB016bB0D1C20D6C3",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// SOL/USD [SOL]
"0xf22CFFA7B4174554FF9dBf7B5A8c01FaaDceA722": {
marketTokenAddress: "0xf22CFFA7B4174554FF9dBf7B5A8c01FaaDceA722",
indexTokenAddress: "0x2bcC6D6CdBbDC0a4071e48bb3B969b06B3330c07",
longTokenAddress: "0x2bcC6D6CdBbDC0a4071e48bb3B969b06B3330c07",
shortTokenAddress: "0x2bcC6D6CdBbDC0a4071e48bb3B969b06B3330c07",
},
// FIL/USD [WBTC/USDC]
"0x262B5203f0fe00D9fe86ffecE01D0f54fC116180": {
marketTokenAddress: "0x262B5203f0fe00D9fe86ffecE01D0f54fC116180",
indexTokenAddress: "0x3AeBb98f57081DcBEb0B8EA823Cf84900A31e5D8",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// DYDX/USD [WBTC-USDC]
"0x467C4A46287F6C4918dDF780D4fd7b46419c2291": {
marketTokenAddress: "0x467C4A46287F6C4918dDF780D4fd7b46419c2291",
indexTokenAddress: "0x0739Ad7AeA69aD36EdEb91b0e55cAC140427c632",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// INJ/USD [WBTC-USDC]
"0x16466a03449CB9218EB6A980Aa4a44aaCEd27C25": {
marketTokenAddress: "0x16466a03449CB9218EB6A980Aa4a44aaCEd27C25",
indexTokenAddress: "0xfdE73EddbE6c5712A12B72c470F8FE5c77A7fF17",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// TRUMP/USD [ETH-USDC]
"0xFec8f404FBCa3b11aFD3b3f0c57507C2a06dE636": {
marketTokenAddress: "0xFec8f404FBCa3b11aFD3b3f0c57507C2a06dE636",
indexTokenAddress: "0x30021aFA4767Ad66aA52A06dF8a5AB3acA9371fD",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// MELANIA/USD [WETH-USDC]
"0x12fD1A4BdB96219E637180Ff5293409502b2951D": {
marketTokenAddress: "0x12fD1A4BdB96219E637180Ff5293409502b2951D",
indexTokenAddress: "0xfa4F8E582214eBCe1A08eB2a65e08082053E441F",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// ENA/USD [WETH-USDC]
"0x9F159014CC218e942E9E9481742fE5BFa9ac5A2C": {
marketTokenAddress: "0x9F159014CC218e942E9E9481742fE5BFa9ac5A2C",
indexTokenAddress: "0xfe1Aac2CD9C5cC77b58EeCfE75981866ed0c8b7a",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// AI16Z/USD [WBTC.e-USDC]
"0xD60f1BA6a76979eFfE706BF090372Ebc0A5bF169": {
marketTokenAddress: "0xD60f1BA6a76979eFfE706BF090372Ebc0A5bF169",
indexTokenAddress: "0xBb69bd9dc152C2c0F083507641a46193d2B61EBb",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// ANIME/USD [ANIME-USDC]
"0x5707673D95a8fD317e2745C4217aCD64ca021B68": {
marketTokenAddress: "0x5707673D95a8fD317e2745C4217aCD64ca021B68",
indexTokenAddress: "0x37a645648dF29205C6261289983FB04ECD70b4B3",
longTokenAddress: "0x37a645648dF29205C6261289983FB04ECD70b4B3",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// FARTCOIN/USD [WBTC.e-USDC]
"0xe2730Ffe2136aA549327EBce93D58160df7821CB": {
marketTokenAddress: "0xe2730Ffe2136aA549327EBce93D58160df7821CB",
indexTokenAddress: "0xaca341E61aB6177B0b0Df46a612e4311F8a7605f",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// BERA/USD [WETH-USDC]
"0x876Ff160d63809674e03f82DC4D3C3Ae8B0acF28": {
marketTokenAddress: "0x876Ff160d63809674e03f82DC4D3C3Ae8B0acF28",
indexTokenAddress: "0x67ADABbAd211eA9b3B4E2fd0FD165E593De1e983",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// LDO/USD [WETH-USDC]
"0xE61e608Ba010fF48A7dcE8eDd8B906744263d33E": {
marketTokenAddress: "0xE61e608Ba010fF48A7dcE8eDd8B906744263d33E",
indexTokenAddress: "0x9D678B4Dd38a6E01df8090aEB7974aD71142b05f",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// VIRTUAL/USD [WBTC-USDC]
"0x75F190E0Be6E8B933A01423EFE398c6C721A5CfF": {
marketTokenAddress: "0x75F190E0Be6E8B933A01423EFE398c6C721A5CfF",
indexTokenAddress: "0xB6672496214C90134A9223894e709F26A5eED362",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// PENGU/USD [WBTC-USDC]
"0x0c11Ed89889Fd03394E8d9d685cC5b85be569C99": {
marketTokenAddress: "0x0c11Ed89889Fd03394E8d9d685cC5b85be569C99",
indexTokenAddress: "0x4C1dac9b6eAf122Fe3DE824c1C2220413F3aC197",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// ONDO/USD [WETH-USDC]
"0xa8A455Ed94b315460CfF7d96966d91330f6A3bA0": {
marketTokenAddress: "0xa8A455Ed94b315460CfF7d96966d91330f6A3bA0",
indexTokenAddress: "0xEcFB4718aD19b626A77491895a2f99ea0cedEd08",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// FET/USD [WETH-USDC]
"0x970e578fF01589Bb470CE38a2f1753152A009366": {
marketTokenAddress: "0x970e578fF01589Bb470CE38a2f1753152A009366",
indexTokenAddress: "0x83D5944E7f5EF1d8432002d3cb062e1012f6F8e6",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// AIXBT/USD [WETH-USDC]
"0x04DecfB37e46075189324817df80a32D22b9eD8D": {
marketTokenAddress: "0x04DecfB37e46075189324817df80a32D22b9eD8D",
indexTokenAddress: "0xcA543Cb8bCC76e4E0A034F56EB40a1029bDFd70E",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// S/USD [WBTC-USDC]
"0x4d9bA415649c4B3c703562770C8ff3033478Cea1": {
marketTokenAddress: "0x4d9bA415649c4B3c703562770C8ff3033478Cea1",
indexTokenAddress: "0x8F6cCb99d4Fd0B4095915147b5ae3bbDb8075394",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// CAKE/USD [WBTC-USDC]
"0xdE967676db7b1ccdBA2bD94B01B5b19DE4b563e4": {
marketTokenAddress: "0xdE967676db7b1ccdBA2bD94B01B5b19DE4b563e4",
indexTokenAddress: "0x580b373Ac16803BB0133356F470f3c7EEF54151B",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// HYPE/USD [WBTC-USDC]
"0xBcb8FE13d02b023e8f94f6881Cc0192fd918A5C0": {
marketTokenAddress: "0xBcb8FE13d02b023e8f94f6881Cc0192fd918A5C0",
indexTokenAddress: "0xfDFA0A749dA3bCcee20aE0B4AD50E39B26F58f7C",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// JUP/USD [WBTC-USDC]
"0x7DE8E1A1fbA845A330A6bD91118AfDA09610fB02": {
marketTokenAddress: "0x7DE8E1A1fbA845A330A6bD91118AfDA09610fB02",
indexTokenAddress: "0xfEd500Df379427Fbc48BDaf3b511b519c7eCCD26",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// MKR/USD [WETH-USDC]
"0x2aE5c5Cd4843cf588AA8D1289894318130acc823": {
marketTokenAddress: "0x2aE5c5Cd4843cf588AA8D1289894318130acc823",
indexTokenAddress: "0x8904De84c3bB3B7D2383F934Af40FcB3Ef82F28b",
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
// OM/USD [WBTC-USDC]
"0x89EB78679921499632fF16B1be3ee48295cfCD91": {
marketTokenAddress: "0x89EB78679921499632fF16B1be3ee48295cfCD91",
indexTokenAddress: "0x1f3407Ea067DfBDF6dEb6bBFdA4869215fB0ab77",
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
},
[AVALANCHE]: {
// BTC/USD [BTC-USDC]
"0xFb02132333A79C8B5Bd0b64E3AbccA5f7fAf2937": {
marketTokenAddress: "0xFb02132333A79C8B5Bd0b64E3AbccA5f7fAf2937",
indexTokenAddress: "0x152b9d0FdC40C096757F570A51E494bd4b943E50",
longTokenAddress: "0x152b9d0FdC40C096757F570A51E494bd4b943E50",
shortTokenAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
},
// ETH/USD [ETH-USDC]
"0xB7e69749E3d2EDd90ea59A4932EFEa2D41E245d7": {
marketTokenAddress: "0xB7e69749E3d2EDd90ea59A4932EFEa2D41E245d7",
indexTokenAddress: "0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",
longTokenAddress: "0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",
shortTokenAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
},
// DOGE/USD [WAVAX-USDC]
"0x8970B527E84aA17a33d38b65e9a5Ab5817FC0027": {
marketTokenAddress: "0x8970B527E84aA17a33d38b65e9a5Ab5817FC0027",
indexTokenAddress: "0xC301E6fe31062C557aEE806cc6A841aE989A3ac6",
longTokenAddress: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
shortTokenAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
},
// SOL/USD [SOL-USDC]
"0xd2eFd1eA687CD78c41ac262B3Bc9B53889ff1F70": {
marketTokenAddress: "0xd2eFd1eA687CD78c41ac262B3Bc9B53889ff1F70",
indexTokenAddress: "0xFE6B19286885a4F7F55AdAD09C3Cd1f906D2478F",
longTokenAddress: "0xFE6B19286885a4F7F55AdAD09C3Cd1f906D2478F",
shortTokenAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
},
// LTC/USD [WAVAX-USDC]
"0xA74586743249243D3b77335E15FE768bA8E1Ec5A": {
marketTokenAddress: "0xA74586743249243D3b77335E15FE768bA8E1Ec5A",
indexTokenAddress: "0x8E9C35235C38C44b5a53B56A41eaf6dB9a430cD6",
longTokenAddress: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
shortTokenAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
},
// AVAX/USD [WAVAX-USDC]
"0x913C1F46b48b3eD35E7dc3Cf754d4ae8499F31CF": {
marketTokenAddress: "0x913C1F46b48b3eD35E7dc3Cf754d4ae8499F31CF",
indexTokenAddress: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
longTokenAddress: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
shortTokenAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
},
// SWAP-ONLY [USDC-USDT.e]
"0xf3652Eba45DC761e7ADd4091627d5Cda21F61613": {
marketTokenAddress: "0xf3652Eba45DC761e7ADd4091627d5Cda21F61613",
indexTokenAddress: "0x0000000000000000000000000000000000000000",
longTokenAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
shortTokenAddress: "0xc7198437980c041c805A1EDcbA50c1Ce5db95118",
},
// SWAP-ONLY [USDC-USDC.e]
"0x297e71A931C5825867E8Fb937Ae5cda9891C2E99": {
marketTokenAddress: "0x297e71A931C5825867E8Fb937Ae5cda9891C2E99",
indexTokenAddress: "0x0000000000000000000000000000000000000000",
longTokenAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
shortTokenAddress: "0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664",
},
// SWAP-ONLY [USDT-USDT.e]
"0xA7b768d6a1f746fd5a513D440DF2970ff099B0fc": {
marketTokenAddress: "0xA7b768d6a1f746fd5a513D440DF2970ff099B0fc",
indexTokenAddress: "0x0000000000000000000000000000000000000000",
longTokenAddress: "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",
shortTokenAddress: "0xc7198437980c041c805A1EDcbA50c1Ce5db95118",
},
// SWAP-ONLY [USDC-DAI.e]
"0xDf8c9BD26e7C1A331902758Eb013548B2D22ab3b": {
marketTokenAddress: "0xDf8c9BD26e7C1A331902758Eb013548B2D22ab3b",
indexTokenAddress: "0x0000000000000000000000000000000000000000",
longTokenAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
shortTokenAddress: "0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",
},
// XRP/USD [WAVAX-USDC]
"0xD1cf931fa12783c1dd5AbB77a0706c27CF352f25": {
marketTokenAddress: "0xD1cf931fa12783c1dd5AbB77a0706c27CF352f25",
indexTokenAddress: "0x34B2885D617cE2ddeD4F60cCB49809fc17bb58Af",
longTokenAddress: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
shortTokenAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
},
// BTC/USD [BTC-BTC]
"0x3ce7BCDB37Bf587d1C17B930Fa0A7000A0648D12": {
marketTokenAddress: "0x3ce7BCDB37Bf587d1C17B930Fa0A7000A0648D12",
indexTokenAddress: "0x152b9d0FdC40C096757F570A51E494bd4b943E50",
longTokenAddress: "0x152b9d0FdC40C096757F570A51E494bd4b943E50",
shortTokenAddress: "0x152b9d0FdC40C096757F570A51E494bd4b943E50",
},
// ETH/USD [ETH-ETH]
"0x2A3Cf4ad7db715DF994393e4482D6f1e58a1b533": {
marketTokenAddress: "0x2A3Cf4ad7db715DF994393e4482D6f1e58a1b533",
indexTokenAddress: "0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",
longTokenAddress: "0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",
shortTokenAddress: "0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",
},
// AVAX/USD [AVAX-AVAX]
"0x08b25A2a89036d298D6dB8A74ace9d1ce6Db15E5": {
marketTokenAddress: "0x08b25A2a89036d298D6dB8A74ace9d1ce6Db15E5",
indexTokenAddress: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
longTokenAddress: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
shortTokenAddress: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
},
// TRUMP/USD [WAVAX-USDC]
"0xfB626c4e3E153947A6A94041814c25E449064dAD": {
marketTokenAddress: "0xfB626c4e3E153947A6A94041814c25E449064dAD",
indexTokenAddress: "0x2f6d7be53fab5538065a226BA091015d422a7528",
longTokenAddress: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
shortTokenAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
},
// MELANIA/USD [WAVAX-USDC]
"0xe19da27Bf9733c429445E289B662bECDCa6ce10b": {
marketTokenAddress: "0xe19da27Bf9733c429445E289B662bECDCa6ce10b",
indexTokenAddress: "0xd42C991a4FAb293C57a7bf25C2E2ec5aE1dB1714",
longTokenAddress: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
shortTokenAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
},
},
[AVALANCHE_FUJI]: {
// AVAX/USD [WAVAX-USDC]
"0xD996ff47A1F763E1e55415BC4437c59292D1F415": {
marketTokenAddress: "0xD996ff47A1F763E1e55415BC4437c59292D1F415",
indexTokenAddress: "0x1D308089a2D1Ced3f1Ce36B1FcaF815b07217be3",
longTokenAddress: "0x1D308089a2D1Ced3f1Ce36B1FcaF815b07217be3",
shortTokenAddress: "0x3eBDeaA0DB3FfDe96E7a0DBBAFEC961FC50F725F",
},
// ETH/USD [ETH-USDC]
"0xbf338a6C595f06B7Cfff2FA8c958d49201466374": {
marketTokenAddress: "0xbf338a6C595f06B7Cfff2FA8c958d49201466374",
indexTokenAddress: "0x82F0b3695Ed2324e55bbD9A9554cB4192EC3a514",
longTokenAddress: "0x82F0b3695Ed2324e55bbD9A9554cB4192EC3a514",
shortTokenAddress: "0x3eBDeaA0DB3FfDe96E7a0DBBAFEC961FC50F725F",
},
// ETH/USD [ETH-DAI]
"0xDdF708B284C5C26BE67Adf9C51DFa935b5035bF8": {
marketTokenAddress: "0xDdF708B284C5C26BE67Adf9C51DFa935b5035bF8",
indexTokenAddress: "0x82F0b3695Ed2324e55bbD9A9554cB4192EC3a514",
longTokenAddress: "0x82F0b3695Ed2324e55bbD9A9554cB4192EC3a514",
shortTokenAddress: "0x51290cb93bE5062A6497f16D9cd3376Adf54F920",
},
// ETH/USD [USDC]
"0xe28323955C05B75E25B56C1c996C1354Eb5Aa13D": {
marketTokenAddress: "0xe28323955C05B75E25B56C1c996C1354Eb5Aa13D",
indexTokenAddress: "0x82F0b3695Ed2324e55bbD9A9554cB4192EC3a514",
longTokenAddress: "0x3eBDeaA0DB3FfDe96E7a0DBBAFEC961FC50F725F",
shortTokenAddress: "0x3eBDeaA0DB3FfDe96E7a0DBBAFEC961FC50F725F",
},
// WBTC/USD [WBTC-USDC]
"0x79E6e0E454dE82fA98c02dB012a2A69103630B07": {
marketTokenAddress: "0x79E6e0E454dE82fA98c02dB012a2A69103630B07",
indexTokenAddress: "0x3Bd8e00c25B12E6E60fc8B6f1E1E2236102073Ca",
longTokenAddress: "0x3Bd8e00c25B12E6E60fc8B6f1E1E2236102073Ca",
shortTokenAddress: "0x3eBDeaA0DB3FfDe96E7a0DBBAFEC961FC50F725F",
},
// WBTC/USD [WBTC-DAI]
"0x4b6ccF6E429f038087A26b13DD6ab4304F7E5DF1": {
marketTokenAddress: "0x4b6ccF6E429f038087A26b13DD6ab4304F7E5DF1",
indexTokenAddress: "0x3Bd8e00c25B12E6E60fc8B6f1E1E2236102073Ca",
longTokenAddress: "0x3Bd8e00c25B12E6E60fc8B6f1E1E2236102073Ca",
shortTokenAddress: "0x51290cb93bE5062A6497f16D9cd3376Adf54F920",
},
// SOL/USD [ETH-USDC]
"0xEDF9Be35bE84cD1e39Bda59Bd7ae8A704C12e06f": {
marketTokenAddress: "0xEDF9Be35bE84cD1e39Bda59Bd7ae8A704C12e06f",
indexTokenAddress: "0x137f4a7336df4f3f11894718528516edaaD0B082",
longTokenAddress: "0x82F0b3695Ed2324e55bbD9A9554cB4192EC3a514",
shortTokenAddress: "0x3eBDeaA0DB3FfDe96E7a0DBBAFEC961FC50F725F",
},
// SWAP-ONLY [USDC-USDT]
"0xeE8827D67C054cAa89C9d6058Fdddccd1C499c74": {
marketTokenAddress: "0xeE8827D67C054cAa89C9d6058Fdddccd1C499c74",
indexTokenAddress: "0x0000000000000000000000000000000000000000",
longTokenAddress: "0x3eBDeaA0DB3FfDe96E7a0DBBAFEC961FC50F725F",
shortTokenAddress: "0x50df4892Bd13f01E4e1Cd077ff394A8fa1A3fD7c",
},
// DOGE/USD [ETH-DAI]
"0xAC2c6C1b0cd1CabF78B4e8ad58aA9d43375318Cb": {
marketTokenAddress: "0xAC2c6C1b0cd1CabF78B4e8ad58aA9d43375318Cb",
indexTokenAddress: "0x2265F317eA5f47A684E5B26c50948617c945d986",
longTokenAddress: "0x82F0b3695Ed2324e55bbD9A9554cB4192EC3a514",
shortTokenAddress: "0x51290cb93bE5062A6497f16D9cd3376Adf54F920",
},
// LINK/USD [ETH-DAI]
"0xeDf53322e288F597436f5d5849771662AEe16A1C": {
marketTokenAddress: "0xeDf53322e288F597436f5d5849771662AEe16A1C",
indexTokenAddress: "0x6BD09E8D65AD5cc761DF62454452d4EC1545e647",
longTokenAddress: "0x82F0b3695Ed2324e55bbD9A9554cB4192EC3a514",
shortTokenAddress: "0x51290cb93bE5062A6497f16D9cd3376Adf54F920",
},
// BNB/USD [ETH-DAI]
"0x017de90B0fa830C592805C6148c089191716f04c": {
marketTokenAddress: "0x017de90B0fa830C592805C6148c089191716f04c",
indexTokenAddress: "0x110892Dd5fa73bE430c0ade694febD9a4CAc68Be",
longTokenAddress: "0x82F0b3695Ed2324e55bbD9A9554cB4192EC3a514",
shortTokenAddress: "0x51290cb93bE5062A6497f16D9cd3376Adf54F920",
},
// ADA/USD [ETH-DAI]
"0x695a07d3DD551b0E77A348cC6A873c1eb183FA98": {
marketTokenAddress: "0x695a07d3DD551b0E77A348cC6A873c1eb183FA98",
indexTokenAddress: "0xE64dfFF37Fa6Fe969b792B4146cEe2774Ef6e1a1",
longTokenAddress: "0x82F0b3695Ed2324e55bbD9A9554cB4192EC3a514",
shortTokenAddress: "0x51290cb93bE5062A6497f16D9cd3376Adf54F920",
},
// TRX/USD [ETH-DAI]
"0x927f31364b8836021e4F73B27a5d0EbB35C74679": {
marketTokenAddress: "0x927f31364b8836021e4F73B27a5d0EbB35C74679",
indexTokenAddress: "0x0D1495527C255068F2f6feE31C85d326D0A76FE8",
longTokenAddress: "0x82F0b3695Ed2324e55bbD9A9554cB4192EC3a514",
shortTokenAddress: "0x51290cb93bE5062A6497f16D9cd3376Adf54F920",
},
// MATIC/USD [ETH-USDC]
"0x62408de4cB1a499842EC53296EF8dD99A825CcEb": {
marketTokenAddress: "0x62408de4cB1a499842EC53296EF8dD99A825CcEb",
indexTokenAddress: "0xadc4698B257F78187Fd675FBf591a09f4c975240",
longTokenAddress: "0x82F0b3695Ed2324e55bbD9A9554cB4192EC3a514",
shortTokenAddress: "0x3eBDeaA0DB3FfDe96E7a0DBBAFEC961FC50F725F",
},
// DOT/USD [ETH-USDC]
"0xCc6AC193E1d1Ef102eCBBA864BBfE87E414a7A0D": {
marketTokenAddress: "0xCc6AC193E1d1Ef102eCBBA864BBfE87E414a7A0D",
indexTokenAddress: "0x65FFb5664a7B3377A5a27D9e59C72Fb1A5E94962",
longTokenAddress: "0x82F0b3695Ed2324e55bbD9A9554cB4192EC3a514",
shortTokenAddress: "0x3eBDeaA0DB3FfDe96E7a0DBBAFEC961FC50F725F",
},
// UNI/USD [ETH-USDC]
"0xE446E8f7074c0A97bb7cd448fA2CC3346045F514": {
marketTokenAddress: "0xE446E8f7074c0A97bb7cd448fA2CC3346045F514",
indexTokenAddress: "0xF62dC1d2452d0893735D22945Af53C290b158eAF",
longTokenAddress: "0x82F0b3695Ed2324e55bbD9A9554cB4192EC3a514",
shortTokenAddress: "0x3eBDeaA0DB3FfDe96E7a0DBBAFEC961FC50F725F",
},
// TEST/USD [ETH-USDC]
"0x1d9dC405CCEFA78b203BaD9CCe1b1623D2B25D9e": {
marketTokenAddress: "0x1d9dC405CCEFA78b203BaD9CCe1b1623D2B25D9e",
indexTokenAddress: "0x42DD131E1086FFCc59bAE9498D71E20E0C889B14",
longTokenAddress: "0x82F0b3695Ed2324e55bbD9A9554cB4192EC3a514",
shortTokenAddress: "0x3eBDeaA0DB3FfDe96E7a0DBBAFEC961FC50F725F",
},
// WBTC/USD [USDC-USDT]
"0xd783EB54407d6d3A4D5c94b634eC9BAE3F574098": {
marketTokenAddress: "0xd783EB54407d6d3A4D5c94b634eC9BAE3F574098",
indexTokenAddress: "0x3Bd8e00c25B12E6E60fc8B6f1E1E2236102073Ca",
longTokenAddress: "0x3eBDeaA0DB3FfDe96E7a0DBBAFEC961FC50F725F",
shortTokenAddress: "0x50df4892Bd13f01E4e1Cd077ff394A8fa1A3fD7c",
},
// ETH/USD [USDC-DAI]
"0x6d72D2787107c32a48bbA4687Eb8F9C19FE5e29C": {
marketTokenAddress: "0x6d72D2787107c32a48bbA4687Eb8F9C19FE5e29C",
indexTokenAddress: "0x82F0b3695Ed2324e55bbD9A9554cB4192EC3a514",
longTokenAddress: "0x3eBDeaA0DB3FfDe96E7a0DBBAFEC961FC50F725F",
shortTokenAddress: "0x51290cb93bE5062A6497f16D9cd3376Adf54F920",
},
// WBTC/USD [WBTC]
"0x3b649015Fe0a4d15617e57aA11c0FbbfA03A9e11": {
marketTokenAddress: "0x3b649015Fe0a4d15617e57aA11c0FbbfA03A9e11",
indexTokenAddress: "0x3Bd8e00c25B12E6E60fc8B6f1E1E2236102073Ca",
longTokenAddress: "0x3Bd8e00c25B12E6E60fc8B6f1E1E2236102073Ca",
shortTokenAddress: "0x3Bd8e00c25B12E6E60fc8B6f1E1E2236102073Ca",
},
},
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,27 @@
export const TRIGGER_PREFIX_ABOVE = ">";
export const TRIGGER_PREFIX_BELOW = "<";
export const TOAST_AUTO_CLOSE_TIME = 7000;
export const WS_LOST_FOCUS_TIMEOUT = 60_000;
export const TRADE_LOST_FOCUS_TIMEOUT = 15_000;
export const PERCENTAGE_SUGGESTIONS = [10, 25, 50, 75];
export const MAX_METAMASK_MOBILE_DECIMALS = 5;
export const INPUT_LABEL_SEPARATOR = ":";
export const TRADE_HISTORY_PER_PAGE = 25;
export const CLAIMS_HISTORY_PER_PAGE = 25;
export const DEFAULT_TOOLTIP_POSITION = "bottom-start";
export const TOOLTIP_OPEN_DELAY = 100; // ms
export const TOOLTIP_CLOSE_DELAY = 100; // ms
export const MARKET_STATS_DECIMALS = 4;
export const GM_POOL_PRICE_DECIMALS = 4;
export const GLP_PRICE_DECIMALS = 4;
export const GMX_PRICE_DECIMALS = 2;
export const DATA_LOAD_TIMEOUT_FOR_METRICS = 10000;
export const MAX_FEEDBACK_LENGTH = 500;

View File

@@ -0,0 +1,89 @@
import { Abi, Address, createPublicClient, createWalletClient, http, PublicClient, WalletClient } from "viem";
import {Accounts} from "./modules/accounts/accounts.js";
import {BATCH_CONFIGS} from "./configs/batch.js";
import {getChain} from "./configs/chains.js";
import {Markets} from "./modules/markets/index.js";
import {Oracle} from "./modules/oracle.js";
import {Orders} from "./modules/orders/orders.js";
import {Positions} from "./modules/positions/positions.js";
import {Tokens} from "./modules/tokens/tokens.js";
import {Trades} from "./modules/trades/trades.js";
import {Utils} from "./modules/utils/utils.js";
import {GmxSdkConfig} from "./types/sdk.js";
import {callContract, CallContractOpts} from "./utils/callContract.js";
import {MAX_TIMEOUT, Multicall, MulticallRequestConfig} from "./utils/multicall.js";
export class GmxSdk {
public readonly markets = new Markets(this);
public readonly tokens = new Tokens(this);
public readonly positions = new Positions(this);
public readonly orders = new Orders(this);
public readonly trades = new Trades(this);
public readonly accounts = new Accounts(this);
public readonly utils = new Utils(this);
public readonly oracle: Oracle;
public publicClient: PublicClient;
public walletClient: WalletClient;
constructor(public config: GmxSdkConfig) {
this.oracle = new Oracle(this);
if (config.publicClient) {
this.publicClient = config.publicClient;
} else {
// Use any to bypass TypeScript's deep type checking
const clientParams: any = {
transport: http(this.config.rpcUrl, {
retryCount: 0,
retryDelay: 10000000,
batch: BATCH_CONFIGS[this.config.chainId].http,
timeout: MAX_TIMEOUT,
}),
pollingInterval: undefined,
batch: BATCH_CONFIGS[this.config.chainId].client,
chain: getChain(this.config.chainId),
};
this.publicClient = createPublicClient(clientParams) as PublicClient;
}
this.walletClient =
config.walletClient ??
createWalletClient({
account: config.account as Address,
chain: getChain(config.chainId),
transport: http(config.rpcUrl, {
retryCount: 0,
retryDelay: 10000000,
batch: BATCH_CONFIGS[config.chainId].http,
timeout: MAX_TIMEOUT,
}),
});
}
setAccount(account: Address) {
this.config.account = account;
}
async executeMulticall<T = any>(request: MulticallRequestConfig<any>) {
const multicall = await Multicall.getInstance(this);
return multicall?.call(request, MAX_TIMEOUT) as Promise<T>;
}
async callContract(address: Address, abi: Abi, method: string, params: any[], opts?: CallContractOpts) {
return callContract(this, address, abi, method, params, opts);
}
get chainId() {
return this.config.chainId;
}
get chain() {
return getChain(this.chainId);
}
get account() {
return this.config.account as Address;
}
}

View File

@@ -0,0 +1,10 @@
import {describe, expect, it} from "vitest";
import {arbitrumSdk} from "../../utils/testUtil.js";
describe("Accounts", () => {
it("should be able to get delegates", async () => {
const delegates = await arbitrumSdk.accounts.getGovTokenDelegates();
expect(delegates).toBeDefined();
});
});

View File

@@ -0,0 +1,39 @@
import { getContract } from "../../configs/contracts.js";
import { Module } from "../base.js";
export class Accounts extends Module {
get govTokenAddress() {
let govTokenAddress;
try {
govTokenAddress = getContract(this.chainId, "GovToken");
} catch (e) {
govTokenAddress = null;
}
return govTokenAddress;
}
getGovTokenDelegates(account?: string) {
if (!this.govTokenAddress) {
return Promise.resolve([]);
}
return this.sdk
.executeMulticall({
govToken: {
contractAddress: this.govTokenAddress,
abiId: "GovToken",
calls: {
delegates: {
methodName: "delegates",
params: [account ?? this.account],
},
},
},
})
.then((res) => {
return res.data.govToken.delegates.returnValues[0];
});
}
}

View File

@@ -0,0 +1,19 @@
import type {GmxSdk} from "../index.js";
export class Module {
constructor(public sdk: GmxSdk) {
this.sdk = sdk;
}
get oracle() {
return this.sdk.oracle;
}
get chainId() {
return this.sdk.chainId;
}
get account() {
return this.sdk.account;
}
}

View File

@@ -0,0 +1,477 @@
import { zeroAddress } from "viem";
import {getContract} from "../../configs/contracts.js";
import {convertTokenAddress, getToken} from "../../configs/tokens.js";
import {ClaimableFundingData, MarketInfo, MarketsData, MarketSdkConfig, MarketsInfoData} from "../../types/markets.js";
import {TokensData} from "../../types/tokens.js";
import {TIMEZONE_OFFSET_SEC} from "../../utils/common.js";
import graphqlFetcher from "../../utils/graphqlFetcher.js";
import {getMarketDivisor, getMarketFullName} from "../../utils/markets.js";
import {getByKey} from "../../utils/objects.js";
import {Module} from "../base.js";
import {
buildClaimableFundingDataRequest,
buildMarketsConfigsRequest,
buildMarketsValuesRequest,
} from "./query-builders.js";
import {MarketConfig, MarketsInfoResult, MarketsResult, MarketValues} from "./types.js";
export class Markets extends Module {
private async getClaimableFundingData() {
const chainId = this.chainId;
const account = this.account;
if (!account) {
return {};
}
const { marketsAddresses, marketsData } = await this.getMarkets();
return this.sdk
.executeMulticall(
buildClaimableFundingDataRequest({
chainId,
account,
marketsAddresses,
marketsData,
})
)
.then((result) => {
return Object.entries(result.data).reduce(
(claimableFundingData, [marketAddress, callsResult]: [string, any]) => {
const market = getByKey(marketsData, marketAddress);
if (!market) {
return claimableFundingData;
}
const marketDivisor = getMarketDivisor(market);
claimableFundingData[marketAddress] = {
claimableFundingAmountLong: callsResult.claimableFundingAmountLong.returnValues[0] / marketDivisor,
claimableFundingAmountShort: callsResult.claimableFundingAmountShort.returnValues[0] / marketDivisor,
};
return claimableFundingData;
},
{} as ClaimableFundingData
);
});
}
private async getMarketsValues({
marketsAddresses,
marketsData,
tokensData,
}: {
account: string | undefined;
marketsAddresses: string[] | undefined;
marketsData: MarketsData | undefined;
tokensData: TokensData | undefined;
}): Promise<MarketsResult> {
const dataStoreAddress = getContract(this.chainId, "DataStore");
const syntheticsReaderAddress = getContract(this.chainId, "SyntheticsReader");
const request = await buildMarketsValuesRequest(this.chainId, {
marketsAddresses,
marketsData,
tokensData,
dataStoreAddress,
syntheticsReaderAddress,
});
return this.sdk.executeMulticall(request).then((res) => {
const result = marketsAddresses!.reduce(
(acc, marketAddress) => {
const readerErrors = res.errors[`${marketAddress}-reader`];
const dataStoreErrors = res.errors[`${marketAddress}-dataStore`];
const readerValues = res.data[`${marketAddress}-reader`];
const dataStoreValues = res.data[`${marketAddress}-dataStore`];
// Skip invalid market
if (!readerValues || !dataStoreValues || readerErrors || dataStoreErrors) {
// eslint-disable-next-line no-console
console.warn(`No market found ${marketAddress} in getMarketsValues`);
return acc;
}
const market = getByKey(marketsData, marketAddress)!;
const marketDivisor = market.isSameCollaterals ? 2n : 1n;
const longInterestUsingLongToken =
BigInt(dataStoreValues.longInterestUsingLongToken.returnValues[0]) / marketDivisor;
const longInterestUsingShortToken =
BigInt(dataStoreValues.longInterestUsingShortToken.returnValues[0]) / marketDivisor;
const shortInterestUsingLongToken =
BigInt(dataStoreValues.shortInterestUsingLongToken.returnValues[0]) / marketDivisor;
const shortInterestUsingShortToken =
BigInt(dataStoreValues.shortInterestUsingShortToken.returnValues[0]) / marketDivisor;
const longInterestUsd = longInterestUsingLongToken + longInterestUsingShortToken;
const shortInterestUsd = shortInterestUsingLongToken + shortInterestUsingShortToken;
const longInterestInTokensUsingLongToken =
BigInt(dataStoreValues.longInterestInTokensUsingLongToken.returnValues[0]) / marketDivisor;
const longInterestInTokensUsingShortToken =
BigInt(dataStoreValues.longInterestInTokensUsingShortToken.returnValues[0]) / marketDivisor;
const shortInterestInTokensUsingLongToken =
BigInt(dataStoreValues.shortInterestInTokensUsingLongToken.returnValues[0]) / marketDivisor;
const shortInterestInTokensUsingShortToken =
BigInt(dataStoreValues.shortInterestInTokensUsingShortToken.returnValues[0]) / marketDivisor;
const longInterestInTokens = longInterestInTokensUsingLongToken + longInterestInTokensUsingShortToken;
const shortInterestInTokens = shortInterestInTokensUsingLongToken + shortInterestInTokensUsingShortToken;
const { nextFunding, virtualInventory } = readerValues.marketInfo.returnValues;
const [, poolValueInfoMin] = readerValues.marketTokenPriceMin.returnValues as [
unknown,
{
poolValue: bigint;
longPnl: bigint;
shortPnl: bigint;
netPnl: bigint;
},
];
const [, poolValueInfoMax] = readerValues.marketTokenPriceMax.returnValues as [
unknown,
{ poolValue: bigint; totalBorrowingFees: bigint; longPnl: bigint; shortPnl: bigint; netPnl: bigint },
];
acc[marketAddress] = {
longInterestUsd,
shortInterestUsd,
longInterestInTokens,
shortInterestInTokens,
longPoolAmount: dataStoreValues.longPoolAmount.returnValues[0] / marketDivisor,
shortPoolAmount: dataStoreValues.shortPoolAmount.returnValues[0] / marketDivisor,
poolValueMin: poolValueInfoMin.poolValue,
poolValueMax: poolValueInfoMax.poolValue,
totalBorrowingFees: poolValueInfoMax.totalBorrowingFees,
positionImpactPoolAmount: dataStoreValues.positionImpactPoolAmount.returnValues[0],
swapImpactPoolAmountLong: dataStoreValues.swapImpactPoolAmountLong.returnValues[0],
swapImpactPoolAmountShort: dataStoreValues.swapImpactPoolAmountShort.returnValues[0],
borrowingFactorPerSecondForLongs: readerValues.marketInfo.returnValues.borrowingFactorPerSecondForLongs,
borrowingFactorPerSecondForShorts: readerValues.marketInfo.returnValues.borrowingFactorPerSecondForShorts,
fundingFactorPerSecond: nextFunding.fundingFactorPerSecond,
longsPayShorts: nextFunding.longsPayShorts,
virtualPoolAmountForLongToken: virtualInventory.virtualPoolAmountForLongToken,
virtualPoolAmountForShortToken: virtualInventory.virtualPoolAmountForShortToken,
virtualInventoryForPositions: virtualInventory.virtualInventoryForPositions,
};
return acc;
},
{} as {
[marketAddress: string]: MarketValues;
}
);
return result;
});
}
private async getMarketsConfigs({
marketsAddresses,
marketsData,
}: {
marketsAddresses: string[] | undefined;
marketsData: MarketsData | undefined;
}) {
const dataStoreAddress = getContract(this.chainId, "DataStore");
const request = await buildMarketsConfigsRequest(this.chainId, {
marketsData,
marketsAddresses,
dataStoreAddress,
});
return this.sdk.executeMulticall(request).then((res) => {
const result = marketsAddresses!.reduce(
(acc, marketAddress) => {
const dataStoreErrors = res.errors[`${marketAddress}-dataStore`];
const dataStoreValues = res.data[`${marketAddress}-dataStore`];
// Skip invalid market
if (!dataStoreValues || dataStoreErrors) {
// eslint-disable-next-line no-console
console.log("Market info error", marketAddress, dataStoreErrors, dataStoreValues);
return acc;
}
acc[marketAddress] = {
isDisabled: dataStoreValues.isDisabled.returnValues[0],
maxLongPoolUsdForDeposit: dataStoreValues.maxLongPoolUsdForDeposit.returnValues[0],
maxShortPoolUsdForDeposit: dataStoreValues.maxShortPoolUsdForDeposit.returnValues[0],
maxLongPoolAmount: dataStoreValues.maxLongPoolAmount.returnValues[0],
maxShortPoolAmount: dataStoreValues.maxShortPoolAmount.returnValues[0],
longPoolAmountAdjustment: dataStoreValues.longPoolAmountAdjustment.returnValues[0],
shortPoolAmountAdjustment: dataStoreValues.shortPoolAmountAdjustment.returnValues[0],
reserveFactorLong: dataStoreValues.reserveFactorLong.returnValues[0],
reserveFactorShort: dataStoreValues.reserveFactorShort.returnValues[0],
openInterestReserveFactorLong: dataStoreValues.openInterestReserveFactorLong.returnValues[0],
openInterestReserveFactorShort: dataStoreValues.openInterestReserveFactorShort.returnValues[0],
maxOpenInterestLong: dataStoreValues.maxOpenInterestLong.returnValues[0],
maxOpenInterestShort: dataStoreValues.maxOpenInterestShort.returnValues[0],
minPositionImpactPoolAmount: dataStoreValues.minPositionImpactPoolAmount.returnValues[0],
positionImpactPoolDistributionRate: dataStoreValues.positionImpactPoolDistributionRate.returnValues[0],
borrowingFactorLong: dataStoreValues.borrowingFactorLong.returnValues[0],
borrowingFactorShort: dataStoreValues.borrowingFactorShort.returnValues[0],
borrowingExponentFactorLong: dataStoreValues.borrowingExponentFactorLong.returnValues[0],
borrowingExponentFactorShort: dataStoreValues.borrowingExponentFactorShort.returnValues[0],
fundingFactor: dataStoreValues.fundingFactor.returnValues[0],
fundingExponentFactor: dataStoreValues.fundingExponentFactor.returnValues[0],
fundingIncreaseFactorPerSecond: dataStoreValues.fundingIncreaseFactorPerSecond.returnValues[0],
fundingDecreaseFactorPerSecond: dataStoreValues.fundingDecreaseFactorPerSecond.returnValues[0],
thresholdForDecreaseFunding: dataStoreValues.thresholdForDecreaseFunding.returnValues[0],
thresholdForStableFunding: dataStoreValues.thresholdForStableFunding.returnValues[0],
minFundingFactorPerSecond: dataStoreValues.minFundingFactorPerSecond.returnValues[0],
maxFundingFactorPerSecond: dataStoreValues.maxFundingFactorPerSecond.returnValues[0],
maxPnlFactorForTradersLong: dataStoreValues.maxPnlFactorForTradersLong.returnValues[0],
maxPnlFactorForTradersShort: dataStoreValues.maxPnlFactorForTradersShort.returnValues[0],
minCollateralFactor: dataStoreValues.minCollateralFactor.returnValues[0],
minCollateralFactorForOpenInterestLong:
dataStoreValues.minCollateralFactorForOpenInterestLong.returnValues[0],
minCollateralFactorForOpenInterestShort:
dataStoreValues.minCollateralFactorForOpenInterestShort.returnValues[0],
positionFeeFactorForPositiveImpact: dataStoreValues.positionFeeFactorForPositiveImpact.returnValues[0],
positionFeeFactorForNegativeImpact: dataStoreValues.positionFeeFactorForNegativeImpact.returnValues[0],
positionImpactFactorPositive: dataStoreValues.positionImpactFactorPositive.returnValues[0],
positionImpactFactorNegative: dataStoreValues.positionImpactFactorNegative.returnValues[0],
maxPositionImpactFactorPositive: dataStoreValues.maxPositionImpactFactorPositive.returnValues[0],
maxPositionImpactFactorNegative: dataStoreValues.maxPositionImpactFactorNegative.returnValues[0],
maxPositionImpactFactorForLiquidations:
dataStoreValues.maxPositionImpactFactorForLiquidations.returnValues[0],
positionImpactExponentFactor: dataStoreValues.positionImpactExponentFactor.returnValues[0],
swapFeeFactorForPositiveImpact: dataStoreValues.swapFeeFactorForPositiveImpact.returnValues[0],
swapFeeFactorForNegativeImpact: dataStoreValues.swapFeeFactorForNegativeImpact.returnValues[0],
swapImpactFactorPositive: dataStoreValues.swapImpactFactorPositive.returnValues[0],
swapImpactFactorNegative: dataStoreValues.swapImpactFactorNegative.returnValues[0],
swapImpactExponentFactor: dataStoreValues.swapImpactExponentFactor.returnValues[0],
virtualMarketId: dataStoreValues.virtualMarketId.returnValues[0],
virtualLongTokenId: dataStoreValues.virtualLongTokenId.returnValues[0],
virtualShortTokenId: dataStoreValues.virtualShortTokenId.returnValues[0],
};
return acc;
},
{} as {
[marketAddress: string]: MarketConfig;
}
);
return result;
});
}
private _marketsData: MarketsResult | undefined;
async getMarkets(offset = 0n, limit = 100n): Promise<MarketsResult> {
if (this._marketsData) {
return this._marketsData;
}
const readerAddress = getContract(this.chainId, "SyntheticsReader");
const dataStoreAddress = getContract(this.chainId, "DataStore");
const apiMarkets = await this.sdk.oracle.getMarkets();
const configMarkets = this.sdk.config.markets ?? {};
const marketsMap = apiMarkets.reduce(
(acc, market) => {
if (configMarkets[market.marketToken]?.isListed === false) {
return acc;
}
return {
...acc,
[market.marketToken]: market,
};
},
{} as { [marketToken: string]: MarketSdkConfig }
);
const markets = await this.sdk
.executeMulticall({
markets: {
contractAddress: readerAddress,
abiId: "SyntheticsReader",
calls: {
markets: {
methodName: "getMarkets",
params: [dataStoreAddress, offset, offset + limit],
},
},
},
})
.then((res) => {
return res.data.markets.markets.returnValues.map(
(market: { marketToken: string; indexToken: string; longToken: string; shortToken: string }) => {
return {
marketTokenAddress: market.marketToken,
indexTokenAddress: market.indexToken,
longTokenAddress: market.longToken,
shortTokenAddress: market.shortToken,
};
}
);
});
const chainId = this.chainId;
const marketsResult = markets.reduce(
(acc: MarketsResult, market) => {
try {
if (!marketsMap[market.marketTokenAddress]?.isListed) {
return acc;
}
const indexToken = getToken(chainId, convertTokenAddress(chainId, market.indexTokenAddress, "native"));
const longToken = getToken(chainId, market.longTokenAddress);
const shortToken = getToken(chainId, market.shortTokenAddress);
const isSameCollaterals = market.longTokenAddress === market.shortTokenAddress;
const isSpotOnly = market.indexTokenAddress === zeroAddress;
const name = getMarketFullName({ indexToken, longToken, shortToken, isSpotOnly });
acc.marketsAddresses!.push(market.marketTokenAddress);
acc.marketsData![market.marketTokenAddress] = {
...market,
isSameCollaterals,
isSpotOnly,
name,
data: "",
};
} catch (e) {
// eslint-disable-next-line no-console
console.warn(`Unsupported market ${market.marketTokenAddress}`, e);
}
return acc;
},
{ marketsData: {}, marketsAddresses: [] }
);
this._marketsData = marketsResult;
return marketsResult;
}
async getMarketsInfo(): Promise<MarketsInfoResult> {
const { marketsData, marketsAddresses } = await this.getMarkets();
const { tokensData, pricesUpdatedAt } = await this.sdk.tokens.getTokensData();
const [marketsValues, marketsConfigs, claimableFundingData] = await Promise.all([
this.getMarketsValues({
account: this.account,
marketsAddresses,
marketsData,
tokensData,
}),
this.getMarketsConfigs({
marketsAddresses,
marketsData,
}),
this.getClaimableFundingData(),
]);
if (!marketsValues || !marketsConfigs || !marketsAddresses || !claimableFundingData) {
return {
marketsInfoData: {},
tokensData,
pricesUpdatedAt,
};
}
// Manual merging to avoid cloning tokens as they are sometimes compared by reference
const marketsInfoData: MarketsInfoData = {};
for (const marketAddress of marketsAddresses) {
const market = marketsData?.[marketAddress];
const marketValues = marketsValues[marketAddress];
const marketConfig = marketsConfigs[marketAddress];
const longToken = getByKey(tokensData!, market?.longTokenAddress);
const shortToken = getByKey(tokensData!, market?.shortTokenAddress);
const indexToken = market
? getByKey(tokensData!, convertTokenAddress(this.chainId, market.indexTokenAddress, "native"))
: undefined;
if (!market || !marketValues || !marketConfig || !longToken || !shortToken || !indexToken) {
continue;
}
const fullMarketInfo: MarketInfo = {
...marketValues,
...marketConfig,
...claimableFundingData[marketAddress],
...market,
longToken,
shortToken,
indexToken,
};
marketsInfoData[marketAddress] = fullMarketInfo;
}
return {
marketsInfoData,
tokensData,
pricesUpdatedAt,
};
}
async getDailyVolumes(): Promise<Record<string, bigint> | undefined> {
const { marketsAddresses } = await this.getMarkets();
const endpoint = this.sdk.config.subsquidUrl;
if (!marketsAddresses || !endpoint) {
return;
}
const LAST_DAY_UNIX_TIMESTAMP = Math.floor(Date.now() / 1000) - 24 * 60 * 60;
const timestamp = LAST_DAY_UNIX_TIMESTAMP + TIMEZONE_OFFSET_SEC;
const variables = {
timestamp: timestamp,
};
return graphqlFetcher<PositionVolumeInfosResponse>(endpoint, POSITIONS_VOLUME_INFOS_QUERY, variables).then(
(data) => {
return data?.positionsVolume.length
? data?.positionsVolume.reduce((acc, { market, volume }) => {
return { ...acc, [market]: BigInt(volume) };
}, {})
: {};
}
);
}
}
type PositionVolumeInfosResponse = {
positionsVolume: {
market: string;
volume: string;
}[];
};
const POSITIONS_VOLUME_INFOS_QUERY = `
query PositionVolumeInfoResolver($timestamp: Float!) {
positionsVolume(where: {timestamp: $timestamp}) {
market
volume
}
}`;

View File

@@ -0,0 +1,42 @@
import {GmxSdk} from "../../index.js";
import {arbitrumSdk, arbitrumSdkConfig} from "../../utils/testUtil.js";
import {describe, expect, it} from "vitest";
describe("Markets", () => {
describe("getMarkets", () => {
it("should be able to get markets data", async () => {
const marketsData = await arbitrumSdk.markets.getMarkets();
expect(marketsData.marketsAddresses).toBeDefined();
expect(marketsData.marketsData).toBeDefined();
});
it("should respect config filters", async () => {
const sdk = new GmxSdk({
...arbitrumSdkConfig,
markets: {
"0x47c031236e19d024b42f8AE6780E44A573170703": {
isListed: false,
},
},
});
const baseSdkResponse = await arbitrumSdk.markets.getMarkets();
const sdkResponse = await sdk.markets.getMarkets();
expect(baseSdkResponse.marketsData?.["0x47c031236e19d024b42f8AE6780E44A573170703"]).toBeDefined();
expect(sdkResponse.marketsData?.["0x47c031236e19d024b42f8AE6780E44A573170703"]).not.toBeDefined();
});
});
describe("getMarketsInfo", () => {
it("should be able to get markets info", async () => {
const response = await arbitrumSdk.markets.getMarketsInfo();
expect(response).toBeDefined();
});
});
describe("getDailyVolumes", () => {
it("should be able to get daily volumes", async () => {
const response = await arbitrumSdk.markets.getDailyVolumes();
expect(response).toBeDefined();
}, 30_000);
});
});

View File

@@ -0,0 +1,447 @@
import {CLAIMABLE_FUNDING_AMOUNT, MAX_PNL_FACTOR_FOR_TRADERS_KEY} from "../../configs/dataStore.js";
import {HASHED_MARKET_CONFIG_KEYS, HASHED_MARKET_VALUES_KEYS} from "../../prebuilt/index.js";
import {MarketsData} from "../../types/markets.js";
import {TokensData} from "../../types/tokens.js";
import {hashDataMap} from "../../utils/hash.js";
import {hashMarketConfigKeys, hashMarketValuesKeys} from "../../utils/marketKeysAndConfigs.js";
import {getContractMarketPrices} from "../../utils/markets.js";
import {getByKey} from "../../utils/objects.js";
import {MarketConfigMulticallRequestConfig, MarketValuesMulticallRequestConfig} from "./types.js";
import {getContract} from "../../configs/contracts.js";
import { ContractCallsConfig } from "../../utils/multicall.js";
export function buildClaimableFundingDataRequest({
marketsAddresses,
marketsData,
chainId,
account,
}: {
marketsAddresses: string[] | undefined;
marketsData: MarketsData | undefined;
account: string;
chainId: number;
}) {
if (!marketsAddresses) {
return {};
}
return marketsAddresses.reduce((request, marketAddress) => {
const market = getByKey(marketsData, marketAddress);
if (!market) {
return request;
}
const keys = hashDataMap({
claimableFundingAmountLong: [
["bytes32", "address", "address", "address"],
[CLAIMABLE_FUNDING_AMOUNT, marketAddress, market.longTokenAddress, account],
],
claimableFundingAmountShort: [
["bytes32", "address", "address", "address"],
[CLAIMABLE_FUNDING_AMOUNT, marketAddress, market.shortTokenAddress, account],
],
});
request[marketAddress] = {
contractAddress: getContract(chainId, "DataStore"),
abiId: "DataStore",
calls: {
claimableFundingAmountLong: {
methodName: "getUint",
params: [keys.claimableFundingAmountLong],
},
claimableFundingAmountShort: {
methodName: "getUint",
params: [keys.claimableFundingAmountShort],
},
},
} satisfies ContractCallsConfig<any>;
return request;
}, {});
}
export async function buildMarketsValuesRequest(
chainId: number,
{
marketsAddresses,
marketsData,
tokensData,
dataStoreAddress,
syntheticsReaderAddress,
}: {
marketsAddresses: string[] | undefined;
marketsData: MarketsData | undefined;
tokensData: TokensData | undefined;
dataStoreAddress: string;
syntheticsReaderAddress: string;
}
) {
const request: MarketValuesMulticallRequestConfig = {};
for (const marketAddress of marketsAddresses || []) {
const market = getByKey(marketsData, marketAddress)!;
const marketPrices = getContractMarketPrices(tokensData!, market)!;
if (!marketPrices) {
// eslint-disable-next-line no-console
console.warn(`No market prices for ${marketAddress}, skipping market values request`);
continue;
}
const marketProps = {
marketToken: market.marketTokenAddress,
indexToken: market.indexTokenAddress,
longToken: market.longTokenAddress,
shortToken: market.shortTokenAddress,
};
request[`${marketAddress}-reader`] = {
contractAddress: syntheticsReaderAddress,
abiId: "SyntheticsReader",
calls: {
marketInfo: {
methodName: "getMarketInfo",
params: [dataStoreAddress, marketPrices, marketAddress],
},
marketTokenPriceMax: {
methodName: "getMarketTokenPrice",
params: [
dataStoreAddress,
marketProps,
marketPrices.indexTokenPrice,
marketPrices.longTokenPrice,
marketPrices.shortTokenPrice,
MAX_PNL_FACTOR_FOR_TRADERS_KEY,
true,
],
},
marketTokenPriceMin: {
methodName: "getMarketTokenPrice",
params: [
dataStoreAddress,
marketProps,
marketPrices.indexTokenPrice,
marketPrices.longTokenPrice,
marketPrices.shortTokenPrice,
MAX_PNL_FACTOR_FOR_TRADERS_KEY,
false,
],
},
},
} satisfies ContractCallsConfig<any>;
let prebuiltHashedKeys = HASHED_MARKET_VALUES_KEYS[chainId]?.[marketAddress];
if (!prebuiltHashedKeys) {
// eslint-disable-next-line no-console
console.warn(
`No pre-built hashed market keys found for the market ${marketAddress}. Run \`yarn prebuild\` to generate them.`
);
if (!marketsData?.[marketAddress]) {
throw new Error(`No market data found for the market ${marketAddress}`);
}
prebuiltHashedKeys = hashMarketValuesKeys(marketsData[marketAddress]);
}
const keys = {
...prebuiltHashedKeys,
};
request[`${marketAddress}-dataStore`] = {
contractAddress: dataStoreAddress,
abiId: "DataStore",
calls: {
longPoolAmount: {
methodName: "getUint",
params: [keys.longPoolAmount],
},
shortPoolAmount: {
methodName: "getUint",
params: [keys.shortPoolAmount],
},
positionImpactPoolAmount: {
methodName: "getUint",
params: [keys.positionImpactPoolAmount],
},
swapImpactPoolAmountLong: {
methodName: "getUint",
params: [keys.swapImpactPoolAmountLong],
},
swapImpactPoolAmountShort: {
methodName: "getUint",
params: [keys.swapImpactPoolAmountShort],
},
longInterestUsingLongToken: {
methodName: "getUint",
params: [keys.longInterestUsingLongToken],
},
longInterestUsingShortToken: {
methodName: "getUint",
params: [keys.longInterestUsingShortToken],
},
shortInterestUsingLongToken: {
methodName: "getUint",
params: [keys.shortInterestUsingLongToken],
},
shortInterestUsingShortToken: {
methodName: "getUint",
params: [keys.shortInterestUsingShortToken],
},
longInterestInTokensUsingLongToken: {
methodName: "getUint",
params: [keys.longInterestInTokensUsingLongToken],
},
longInterestInTokensUsingShortToken: {
methodName: "getUint",
params: [keys.longInterestInTokensUsingShortToken],
},
shortInterestInTokensUsingLongToken: {
methodName: "getUint",
params: [keys.shortInterestInTokensUsingLongToken],
},
shortInterestInTokensUsingShortToken: {
methodName: "getUint",
params: [keys.shortInterestInTokensUsingShortToken],
},
},
} satisfies ContractCallsConfig<any>;
}
return request;
}
export async function buildMarketsConfigsRequest(
chainId: number,
{
marketsData,
marketsAddresses,
dataStoreAddress,
}: {
marketsData: MarketsData | undefined;
marketsAddresses: string[] | undefined;
dataStoreAddress: string;
}
) {
const request: MarketConfigMulticallRequestConfig = {};
for (const marketAddress of marketsAddresses || []) {
let prebuiltHashedKeys = HASHED_MARKET_CONFIG_KEYS[chainId]?.[marketAddress];
if (!prebuiltHashedKeys) {
// eslint-disable-next-line no-console
console.warn(
`No pre-built hashed config keys found for the market ${marketAddress}. Run \`yarn prebuild\` to generate them.`
);
if (!marketsData?.[marketAddress]) {
throw new Error(`No market data found for the market ${marketAddress}`);
}
prebuiltHashedKeys = hashMarketConfigKeys(marketsData[marketAddress]);
}
request[`${marketAddress}-dataStore`] = {
contractAddress: dataStoreAddress,
abiId: "DataStore",
calls: {
isDisabled: {
methodName: "getBool",
params: [prebuiltHashedKeys.isDisabled],
},
maxLongPoolAmount: {
methodName: "getUint",
params: [prebuiltHashedKeys.maxLongPoolAmount],
},
maxShortPoolAmount: {
methodName: "getUint",
params: [prebuiltHashedKeys.maxShortPoolAmount],
},
maxLongPoolUsdForDeposit: {
methodName: "getUint",
params: [prebuiltHashedKeys.maxLongPoolUsdForDeposit],
},
maxShortPoolUsdForDeposit: {
methodName: "getUint",
params: [prebuiltHashedKeys.maxShortPoolUsdForDeposit],
},
longPoolAmountAdjustment: {
methodName: "getUint",
params: [prebuiltHashedKeys.longPoolAmountAdjustment],
},
shortPoolAmountAdjustment: {
methodName: "getUint",
params: [prebuiltHashedKeys.shortPoolAmountAdjustment],
},
reserveFactorLong: {
methodName: "getUint",
params: [prebuiltHashedKeys.reserveFactorLong],
},
reserveFactorShort: {
methodName: "getUint",
params: [prebuiltHashedKeys.reserveFactorShort],
},
openInterestReserveFactorLong: {
methodName: "getUint",
params: [prebuiltHashedKeys.openInterestReserveFactorLong],
},
openInterestReserveFactorShort: {
methodName: "getUint",
params: [prebuiltHashedKeys.openInterestReserveFactorShort],
},
maxOpenInterestLong: {
methodName: "getUint",
params: [prebuiltHashedKeys.maxOpenInterestLong],
},
maxOpenInterestShort: {
methodName: "getUint",
params: [prebuiltHashedKeys.maxOpenInterestShort],
},
minPositionImpactPoolAmount: {
methodName: "getUint",
params: [prebuiltHashedKeys.minPositionImpactPoolAmount],
},
positionImpactPoolDistributionRate: {
methodName: "getUint",
params: [prebuiltHashedKeys.positionImpactPoolDistributionRate],
},
borrowingFactorLong: {
methodName: "getUint",
params: [prebuiltHashedKeys.borrowingFactorLong],
},
borrowingFactorShort: {
methodName: "getUint",
params: [prebuiltHashedKeys.borrowingFactorShort],
},
borrowingExponentFactorLong: {
methodName: "getUint",
params: [prebuiltHashedKeys.borrowingExponentFactorLong],
},
borrowingExponentFactorShort: {
methodName: "getUint",
params: [prebuiltHashedKeys.borrowingExponentFactorShort],
},
fundingFactor: {
methodName: "getUint",
params: [prebuiltHashedKeys.fundingFactor],
},
fundingExponentFactor: {
methodName: "getUint",
params: [prebuiltHashedKeys.fundingExponentFactor],
},
fundingIncreaseFactorPerSecond: {
methodName: "getUint",
params: [prebuiltHashedKeys.fundingIncreaseFactorPerSecond],
},
fundingDecreaseFactorPerSecond: {
methodName: "getUint",
params: [prebuiltHashedKeys.fundingDecreaseFactorPerSecond],
},
thresholdForStableFunding: {
methodName: "getUint",
params: [prebuiltHashedKeys.thresholdForStableFunding],
},
thresholdForDecreaseFunding: {
methodName: "getUint",
params: [prebuiltHashedKeys.thresholdForDecreaseFunding],
},
minFundingFactorPerSecond: {
methodName: "getUint",
params: [prebuiltHashedKeys.minFundingFactorPerSecond],
},
maxFundingFactorPerSecond: {
methodName: "getUint",
params: [prebuiltHashedKeys.maxFundingFactorPerSecond],
},
maxPnlFactorForTradersLong: {
methodName: "getUint",
params: [prebuiltHashedKeys.maxPnlFactorForTradersLong],
},
maxPnlFactorForTradersShort: {
methodName: "getUint",
params: [prebuiltHashedKeys.maxPnlFactorForTradersShort],
},
positionFeeFactorForPositiveImpact: {
methodName: "getUint",
params: [prebuiltHashedKeys.positionFeeFactorForPositiveImpact],
},
positionFeeFactorForNegativeImpact: {
methodName: "getUint",
params: [prebuiltHashedKeys.positionFeeFactorForNegativeImpact],
},
positionImpactFactorPositive: {
methodName: "getUint",
params: [prebuiltHashedKeys.positionImpactFactorPositive],
},
positionImpactFactorNegative: {
methodName: "getUint",
params: [prebuiltHashedKeys.positionImpactFactorNegative],
},
maxPositionImpactFactorPositive: {
methodName: "getUint",
params: [prebuiltHashedKeys.maxPositionImpactFactorPositive],
},
maxPositionImpactFactorNegative: {
methodName: "getUint",
params: [prebuiltHashedKeys.maxPositionImpactFactorNegative],
},
maxPositionImpactFactorForLiquidations: {
methodName: "getUint",
params: [prebuiltHashedKeys.maxPositionImpactFactorForLiquidations],
},
minCollateralFactor: {
methodName: "getUint",
params: [prebuiltHashedKeys.minCollateralFactor],
},
minCollateralFactorForOpenInterestLong: {
methodName: "getUint",
params: [prebuiltHashedKeys.minCollateralFactorForOpenInterestLong],
},
minCollateralFactorForOpenInterestShort: {
methodName: "getUint",
params: [prebuiltHashedKeys.minCollateralFactorForOpenInterestShort],
},
positionImpactExponentFactor: {
methodName: "getUint",
params: [prebuiltHashedKeys.positionImpactExponentFactor],
},
swapFeeFactorForPositiveImpact: {
methodName: "getUint",
params: [prebuiltHashedKeys.swapFeeFactorForPositiveImpact],
},
swapFeeFactorForNegativeImpact: {
methodName: "getUint",
params: [prebuiltHashedKeys.swapFeeFactorForNegativeImpact],
},
swapImpactFactorPositive: {
methodName: "getUint",
params: [prebuiltHashedKeys.swapImpactFactorPositive],
},
swapImpactFactorNegative: {
methodName: "getUint",
params: [prebuiltHashedKeys.swapImpactFactorNegative],
},
swapImpactExponentFactor: {
methodName: "getUint",
params: [prebuiltHashedKeys.swapImpactExponentFactor],
},
virtualMarketId: {
methodName: "getBytes32",
params: [prebuiltHashedKeys.virtualMarketId],
},
virtualShortTokenId: {
methodName: "getBytes32",
params: [prebuiltHashedKeys.virtualShortTokenId],
},
virtualLongTokenId: {
methodName: "getBytes32",
params: [prebuiltHashedKeys.virtualLongTokenId],
},
},
} satisfies ContractCallsConfig<any>;
}
return request;
}

View File

@@ -0,0 +1,205 @@
import {MarketInfo, MarketsData, MarketsInfoData} from "../../types/markets.js";
import {TokensData} from "../../types/tokens.js";
import {MulticallRequestConfig} from "../../utils/multicall.js";
export type MarketsResult = {
marketsData?: MarketsData;
marketsAddresses?: string[];
error?: Error | undefined;
};
export type MarketsInfoResult = {
marketsInfoData?: MarketsInfoData;
tokensData?: TokensData;
pricesUpdatedAt?: number;
};
/**
* Updates frequently
*/
export type MarketValues = Pick<
MarketInfo,
| "longInterestUsd"
| "shortInterestUsd"
| "longInterestInTokens"
| "shortInterestInTokens"
| "longPoolAmount"
| "shortPoolAmount"
| "poolValueMin"
| "poolValueMax"
| "totalBorrowingFees"
| "positionImpactPoolAmount"
| "swapImpactPoolAmountLong"
| "swapImpactPoolAmountShort"
| "borrowingFactorPerSecondForLongs"
| "borrowingFactorPerSecondForShorts"
| "fundingFactorPerSecond"
| "longsPayShorts"
| "virtualPoolAmountForLongToken"
| "virtualPoolAmountForShortToken"
| "virtualInventoryForPositions"
>;
/**
* Updates seldom
*/
export type MarketConfig = Pick<
MarketInfo,
| "isDisabled"
| "maxLongPoolUsdForDeposit"
| "maxShortPoolUsdForDeposit"
| "maxLongPoolAmount"
| "maxShortPoolAmount"
| "longPoolAmountAdjustment"
| "shortPoolAmountAdjustment"
| "reserveFactorLong"
| "reserveFactorShort"
| "openInterestReserveFactorLong"
| "openInterestReserveFactorShort"
| "maxOpenInterestLong"
| "maxOpenInterestShort"
| "minPositionImpactPoolAmount"
| "positionImpactPoolDistributionRate"
| "borrowingFactorLong"
| "borrowingFactorShort"
| "borrowingExponentFactorLong"
| "borrowingExponentFactorShort"
| "fundingFactor"
| "fundingExponentFactor"
| "fundingIncreaseFactorPerSecond"
| "fundingDecreaseFactorPerSecond"
| "thresholdForDecreaseFunding"
| "thresholdForStableFunding"
| "minFundingFactorPerSecond"
| "maxFundingFactorPerSecond"
| "maxPnlFactorForTradersLong"
| "maxPnlFactorForTradersShort"
| "minCollateralFactor"
| "minCollateralFactorForOpenInterestLong"
| "minCollateralFactorForOpenInterestShort"
| "positionFeeFactorForPositiveImpact"
| "positionFeeFactorForNegativeImpact"
| "positionImpactFactorPositive"
| "positionImpactFactorNegative"
| "maxPositionImpactFactorPositive"
| "maxPositionImpactFactorNegative"
| "maxPositionImpactFactorForLiquidations"
| "positionImpactExponentFactor"
| "swapFeeFactorForPositiveImpact"
| "swapFeeFactorForNegativeImpact"
| "swapImpactFactorPositive"
| "swapImpactFactorNegative"
| "swapImpactExponentFactor"
| "virtualMarketId"
| "virtualLongTokenId"
| "virtualShortTokenId"
>;
export type MarketValuesMulticallRequestConfig = MulticallRequestConfig<{
[key: `${string}-reader`]: {
calls: Record<
"marketInfo" | "marketTokenPriceMax" | "marketTokenPriceMin",
{
methodName: string;
params: any[];
}
>;
};
[key: `${string}-dataStore`]: {
calls: Record<
| "longPoolAmount"
| "shortPoolAmount"
| "positionImpactPoolAmount"
| "swapImpactPoolAmountLong"
| "swapImpactPoolAmountShort"
| "longInterestUsingLongToken"
| "longInterestUsingShortToken"
| "shortInterestUsingLongToken"
| "shortInterestUsingShortToken"
| "longInterestInTokensUsingLongToken"
| "longInterestInTokensUsingShortToken"
| "shortInterestInTokensUsingLongToken"
| "shortInterestInTokensUsingShortToken",
{
methodName: string;
params: any[];
}
>;
};
}>;
export type MarketConfigMulticallRequestConfig = MulticallRequestConfig<{
[key: `${string}-dataStore`]: {
calls: Record<
| "isDisabled"
| "maxLongPoolAmount"
| "maxShortPoolAmount"
| "maxLongPoolUsdForDeposit"
| "maxShortPoolUsdForDeposit"
| "longPoolAmountAdjustment"
| "shortPoolAmountAdjustment"
| "reserveFactorLong"
| "reserveFactorShort"
| "openInterestReserveFactorLong"
| "openInterestReserveFactorShort"
| "maxOpenInterestLong"
| "maxOpenInterestShort"
| "minPositionImpactPoolAmount"
| "positionImpactPoolDistributionRate"
| "borrowingFactorLong"
| "borrowingFactorShort"
| "borrowingExponentFactorLong"
| "borrowingExponentFactorShort"
| "fundingFactor"
| "fundingExponentFactor"
| "fundingIncreaseFactorPerSecond"
| "fundingDecreaseFactorPerSecond"
| "thresholdForStableFunding"
| "thresholdForDecreaseFunding"
| "minFundingFactorPerSecond"
| "maxFundingFactorPerSecond"
| "maxPnlFactorForTradersLong"
| "maxPnlFactorForTradersShort"
| "positionFeeFactorForPositiveImpact"
| "positionFeeFactorForNegativeImpact"
| "positionImpactFactorPositive"
| "positionImpactFactorNegative"
| "maxPositionImpactFactorPositive"
| "maxPositionImpactFactorNegative"
| "maxPositionImpactFactorForLiquidations"
| "minCollateralFactor"
| "minCollateralFactorForOpenInterestLong"
| "minCollateralFactorForOpenInterestShort"
| "positionImpactExponentFactor"
| "swapFeeFactorForPositiveImpact"
| "swapFeeFactorForNegativeImpact"
| "swapImpactFactorPositive"
| "swapImpactFactorNegative"
| "swapImpactExponentFactor"
| "virtualMarketId"
| "virtualLongTokenId"
| "virtualShortTokenId",
{
methodName: string;
params: any[];
}
>;
};
}>;
export type KinkModelMarketRateMulticallRequestConfig = MulticallRequestConfig<{
[key: `${string}-dataStore`]: {
calls: Record<
| "optimalUsageFactorLong"
| "optimalUsageFactorShort"
| "baseBorrowingFactorLong"
| "baseBorrowingFactorShort"
| "aboveOptimalUsageBorrowingFactorLong"
| "aboveOptimalUsageBorrowingFactorShort",
{
methodName: string;
params: any[];
}
>;
};
}>;

View File

@@ -0,0 +1,67 @@
import fetch from "cross-fetch";
import type {GmxSdk} from "../index.js";
import {MarketSdkConfig} from "../types/markets.js";
import {buildUrl} from "../utils/buildUrl.js";
export type TickersResponse = {
minPrice: string;
maxPrice: string;
oracleDecimals: number;
tokenSymbol: string;
tokenAddress: string;
updatedAt: number;
}[];
export type TokensResponse = {
symbol: string;
address: string;
decimals: number;
synthetic: boolean;
}[];
export class Oracle {
private url: string;
constructor(public sdk: GmxSdk) {
this.url = sdk.config.oracleUrl;
}
getMarkets(): Promise<MarketSdkConfig[]> {
return fetch(buildUrl(this.url!, "/markets"))
.then((res) => res.json())
.then((res) => {
if (!res.markets || !res.markets.length) {
throw new Error("Invalid markets response");
}
return res.markets;
});
}
getTokens(): Promise<TokensResponse> {
return fetch(buildUrl(this.url!, "/tokens"))
.then((res) => res.json())
.then((res) =>
res.tokens.map(({ synthetic, ...rest }) => {
return {
...rest,
isSynthetic: synthetic,
};
})
);
}
getTickers(): Promise<TickersResponse> {
return fetch(buildUrl(this.url!, "/prices/tickers"))
.then((res) => res.json())
.then((res) => {
if (!res.length) {
throw new Error("Invalid tickers response");
}
return res;
});
}
}

View File

@@ -0,0 +1,118 @@
import { describe, it, expect, vi, beforeEach, beforeAll } from "vitest";
import * as swapPath from "../../utils/swap/swapPath.js";
import * as tradeAmounts from "../../utils/trade/amounts.js";
import { arbitrumSdk } from "../../utils/testUtil.js";
import { ARBITRUM } from "../../configs/chains.js";
import { getByKey } from "../../utils/objects.js";
import { MarketInfo, MarketsInfoData } from "../../types/markets.js";
import { TokenData, TokensData } from "../../types/tokens.js";
describe("increaseOrderHelper", () => {
let mockParams;
let createIncreaseOrderSpy;
let marketsInfoData: MarketsInfoData;
let tokensData: TokensData;
let market: MarketInfo;
let payToken: TokenData;
let collateralToken: TokenData;
beforeAll(async () => {
const result = await arbitrumSdk.markets.getMarketsInfo();
if (!result.marketsInfoData || !result.tokensData) {
throw new Error("Markets info data or tokens data is not available");
}
marketsInfoData = result.marketsInfoData;
tokensData = result.tokensData;
});
beforeEach(() => {
vi.clearAllMocks();
createIncreaseOrderSpy = vi.spyOn(arbitrumSdk.orders, "createIncreaseOrder").mockResolvedValue();
market = getByKey(marketsInfoData, "0x70d95587d40A2caf56bd97485aB3Eec10Bee6336")!;
if (!market) {
throw new Error("Market is not available");
}
payToken = market.indexToken;
collateralToken = market.shortToken;
mockParams = {
payAmount: 1000n,
marketAddress: "0x70d95587d40A2caf56bd97485aB3Eec10Bee6336",
payTokenAddress: market.indexToken.address,
collateralTokenAddress: market.shortToken.address,
allowedSlippageBps: 125,
leverage: 50000n,
marketsInfoData,
tokensData,
};
});
it("should call createIncreaseOrder with correct parameters for a market order with payAmount", async () => {
const findSwapPathSpy = vi.spyOn(swapPath, "createFindSwapPath");
const getIncreasePositionAmountsSpy = vi.spyOn(tradeAmounts, "getIncreasePositionAmounts");
await arbitrumSdk.orders.long(mockParams);
expect(findSwapPathSpy).toHaveBeenCalledWith(
expect.objectContaining({
chainId: ARBITRUM,
fromTokenAddress: payToken.address,
toTokenAddress: collateralToken.address,
marketsInfoData: expect.any(Object),
estimator: expect.any(Function),
allPaths: expect.any(Array),
})
);
expect(getIncreasePositionAmountsSpy).toHaveBeenCalledWith(
expect.objectContaining({
isLong: true,
initialCollateralAmount: 1000n,
leverage: 50000n,
strategy: "leverageByCollateral",
marketInfo: market,
})
);
expect(createIncreaseOrderSpy).toHaveBeenCalledWith(
expect.objectContaining({
marketsInfoData: expect.any(Object),
tokensData: expect.any(Object),
marketInfo: market,
indexToken: market.indexToken,
isLimit: false,
marketAddress: market.marketTokenAddress,
allowedSlippage: 125,
collateralTokenAddress: collateralToken.address,
collateralToken,
isLong: true,
receiveTokenAddress: collateralToken.address,
increaseAmounts: expect.objectContaining({
initialCollateralAmount: 1000n,
estimatedLeverage: 50000n,
triggerPrice: undefined,
acceptablePrice: 0n,
acceptablePriceDeltaBps: 0n,
positionFeeUsd: 0n,
uiFeeUsd: 0n,
swapUiFeeUsd: 0n,
feeDiscountUsd: 0n,
borrowingFeeUsd: 0n,
fundingFeeUsd: 0n,
positionPriceImpactDeltaUsd: 0n,
limitOrderType: undefined,
triggerThresholdType: undefined,
externalSwapQuote: undefined,
}),
})
);
});
});

View File

@@ -0,0 +1,479 @@
import { MarketsInfoData } from "../../types/markets.js";
import { DecreasePositionSwapType, OrderType } from "../../types/orders.js";
import { TokenData, TokensData, TokensRatio } from "../../types/tokens.js";
import { DecreasePositionAmounts, FindSwapPath, SwapAmounts, TriggerThresholdType } from "../../types/trade.js";
import { getByKey } from "../../utils/objects.js";
import { createFindSwapPath, findAllSwapPaths, getWrappedAddress } from "../../utils/swap/swapPath.js";
import { convertToUsd, getIsUnwrap, getIsWrap, getTokensRatioByPrice } from "../../utils/tokens.js";
import { getIncreasePositionAmounts } from "../../utils/trade/amounts.js";
import type { GmxSdk } from "../..";
import { createSwapEstimator, getMarketsGraph } from "../../utils/swap/swapRouting.js";
import { getSwapAmountsByFromValue, getSwapAmountsByToValue } from "../../utils/swap/index.js";
import { EntryField, SidecarSlTpOrderEntryValid } from "../../types/sidecarOrders.js";
import { bigMath } from "../../utils/bigmath.js";
/** Base Optional params for helpers, allows to avoid calling markets, tokens and uiFeeFactor methods if they are already passed */
interface BaseOptionalParams {
marketsInfoData?: MarketsInfoData;
tokensData?: TokensData;
uiFeeFactor?: bigint;
}
export type PositionIncreaseParams = (
| {
/** Increase amounts will be calculated based on collateral amount */
payAmount: bigint;
}
| {
/** Increase amounts will be calculated based on position size amount */
sizeAmount: bigint;
}
) & {
marketAddress: string;
payTokenAddress: string;
collateralTokenAddress: string;
/** @default 100 */
allowedSlippageBps?: number;
referralCodeForTxn?: string;
leverage?: bigint;
/** If presented, then it's limit order */
limitPrice?: bigint;
acceptablePriceImpactBuffer?: number;
fixedAcceptablePriceImpactBps?: bigint;
skipSimulation?: boolean;
stopLossPrice?: bigint;
takeProfitPrice?: bigint;
} & BaseOptionalParams;
async function getAndValidateBaseParams(sdk: GmxSdk, params: BaseOptionalParams) {
let tokensData: TokensData | undefined = params.tokensData;
let marketsInfoData: MarketsInfoData | undefined = params.marketsInfoData;
if (!params.marketsInfoData && !params.tokensData) {
const result = await sdk.markets.getMarketsInfo();
marketsInfoData = result.marketsInfoData;
tokensData = result.tokensData;
}
if (!tokensData) {
throw new Error("Tokens data is not available");
}
if (!marketsInfoData) {
throw new Error("Markets info data is not available");
}
let uiFeeFactor = params.uiFeeFactor;
if (!uiFeeFactor) {
uiFeeFactor = await sdk.utils.getUiFeeFactor();
}
return {
tokensData,
marketsInfoData,
uiFeeFactor,
};
}
export async function increaseOrderHelper(
sdk: GmxSdk,
params: PositionIncreaseParams & {
isLong: boolean;
}
) {
const { tokensData, marketsInfoData, uiFeeFactor } = await getAndValidateBaseParams(sdk, params);
const isLimit = Boolean(params.limitPrice);
const fromToken = tokensData[params.payTokenAddress];
const collateralToken = tokensData[params.collateralTokenAddress];
if (!fromToken) {
throw new Error("From token is not available");
}
if (!collateralToken) {
throw new Error("Collateral token is not available");
}
const marketInfo = getByKey(marketsInfoData, params.marketAddress);
if (!marketInfo) {
throw new Error("Market info is not available");
}
const collateralTokenAddress = collateralToken.address;
const allowedSlippage = params.allowedSlippageBps ?? 100;
const graph = getMarketsGraph(Object.values(marketsInfoData));
const wrappedFromAddress = getWrappedAddress(sdk.chainId, params.payTokenAddress);
const wrappedToAddress = getWrappedAddress(sdk.chainId, collateralTokenAddress);
const allPaths = findAllSwapPaths({
chainId: sdk.chainId,
fromTokenAddress: params.payTokenAddress,
toTokenAddress: collateralTokenAddress,
marketsInfoData,
graph,
wrappedFromAddress,
wrappedToAddress,
});
const estimator = createSwapEstimator(marketsInfoData);
const findSwapPath = createFindSwapPath({
chainId: sdk.chainId,
fromTokenAddress: params.payTokenAddress,
toTokenAddress: collateralTokenAddress,
marketsInfoData,
estimator,
allPaths,
});
const payOrSizeAmount = "payAmount" in params ? params.payAmount : params.sizeAmount;
const increaseAmounts = getIncreasePositionAmounts({
marketInfo,
indexToken: marketInfo.indexToken,
initialCollateralToken: fromToken,
collateralToken,
isLong: params.isLong,
initialCollateralAmount: payOrSizeAmount,
position: undefined,
indexTokenAmount: payOrSizeAmount,
leverage: params.leverage,
triggerPrice: params.limitPrice,
limitOrderType: params.limitPrice ? OrderType.LimitIncrease : undefined,
userReferralInfo: undefined,
strategy: "payAmount" in params ? "leverageByCollateral" : "leverageBySize",
findSwapPath: findSwapPath,
uiFeeFactor,
acceptablePriceImpactBuffer: params.acceptablePriceImpactBuffer,
fixedAcceptablePriceImpactBps: params.fixedAcceptablePriceImpactBps,
externalSwapQuote: undefined,
});
const createSltpEntries: SidecarSlTpOrderEntryValid[] = [
]
let stopLossDecreaseAmounts: DecreasePositionAmounts | undefined;
if (params.stopLossPrice) {
const stopLossCollateralDeltaUsd = convertToUsd(increaseAmounts.collateralDeltaAmount, collateralToken.decimals, params.stopLossPrice);
stopLossDecreaseAmounts = {
isFullClose: true,
sizeDeltaUsd: increaseAmounts.sizeDeltaUsd,
sizeDeltaInTokens: increaseAmounts.sizeDeltaInTokens,
collateralDeltaUsd: stopLossCollateralDeltaUsd,
collateralDeltaAmount: increaseAmounts.collateralDeltaAmount,
indexPrice: 0n,
collateralPrice: 0n,
acceptablePrice: params.stopLossPrice,
acceptablePriceDeltaBps: 0n,
recommendedAcceptablePriceDeltaBps: 0n,
estimatedPnl: 0n,
estimatedPnlPercentage: 0n,
realizedPnl: 0n,
realizedPnlPercentage: 0n,
positionFeeUsd: 0n,
uiFeeUsd: 0n,
swapUiFeeUsd: 0n,
feeDiscountUsd: 0n,
borrowingFeeUsd: 0n,
fundingFeeUsd: 0n,
swapProfitFeeUsd: 0n,
positionPriceImpactDeltaUsd: 0n,
priceImpactDiffUsd: 0n,
payedRemainingCollateralAmount: 0n,
payedOutputUsd: 0n,
payedRemainingCollateralUsd: 0n,
receiveTokenAmount: 0n,
receiveUsd: 0n,
decreaseSwapType: DecreasePositionSwapType.NoSwap,
triggerOrderType: OrderType.LimitDecrease,
triggerPrice: params.stopLossPrice,
}
const stopLossEntry: SidecarSlTpOrderEntryValid = {
decreaseAmounts: stopLossDecreaseAmounts,
id: "sl-order",
price: {
input: params.stopLossPrice?.toString() ?? "",
value: params.stopLossPrice,
error: null,
} as EntryField,
sizeUsd: {
input: increaseAmounts.sizeDeltaUsd.toString(),
value: increaseAmounts.sizeDeltaUsd,
error: null,
} as EntryField,
percentage: {
input: "100",
value: 100n,
error: null,
} as EntryField,
txnType: "create",
mode: "keepSize",
order: null,
increaseAmounts: undefined
}
createSltpEntries.push(stopLossEntry)
}
let takeProfitDecreaseAmounts: DecreasePositionAmounts | undefined;
if (params.takeProfitPrice) {
const takeProfitCollateralDeltaUsd = convertToUsd(increaseAmounts.collateralDeltaAmount, collateralToken.decimals, params.takeProfitPrice);
takeProfitDecreaseAmounts = {
isFullClose: true,
sizeDeltaUsd: increaseAmounts.sizeDeltaUsd,
sizeDeltaInTokens: increaseAmounts.sizeDeltaInTokens,
collateralDeltaUsd: takeProfitCollateralDeltaUsd,
collateralDeltaAmount: increaseAmounts.collateralDeltaAmount,
indexPrice: 0n,
collateralPrice: 0n,
acceptablePrice: params.takeProfitPrice,
acceptablePriceDeltaBps: 0n,
recommendedAcceptablePriceDeltaBps: 0n,
estimatedPnl: 0n,
estimatedPnlPercentage: 0n,
realizedPnl: 0n,
realizedPnlPercentage: 0n,
positionFeeUsd: 0n,
uiFeeUsd: 0n,
swapUiFeeUsd: 0n,
feeDiscountUsd: 0n,
borrowingFeeUsd: 0n,
fundingFeeUsd: 0n,
swapProfitFeeUsd: 0n,
positionPriceImpactDeltaUsd: 0n,
priceImpactDiffUsd: 0n,
payedRemainingCollateralAmount: 0n,
payedOutputUsd: 0n,
payedRemainingCollateralUsd: 0n,
receiveTokenAmount: 0n,
receiveUsd: 0n,
decreaseSwapType: DecreasePositionSwapType.NoSwap,
triggerOrderType: OrderType.LimitDecrease,
triggerPrice: params.takeProfitPrice,
}
const takeProfitEntry: SidecarSlTpOrderEntryValid = {
decreaseAmounts: takeProfitDecreaseAmounts,
id: "tp-order",
price: {
input: params.takeProfitPrice?.toString() ?? "",
value: params.takeProfitPrice,
error: null,
} as EntryField,
sizeUsd: {
input: increaseAmounts.sizeDeltaUsd.toString(),
value: increaseAmounts.sizeDeltaUsd,
error: null,
} as EntryField,
percentage: {
input: "100",
value: 100n,
error: null,
} as EntryField,
txnType: "create",
mode: "keepSize",
order: null,
increaseAmounts: undefined
}
createSltpEntries.push(takeProfitEntry)
}
const createIncreaseOrderParams: Parameters<typeof sdk.orders.createIncreaseOrder>[0] = {
marketsInfoData,
tokensData,
isLimit,
marketAddress: params.marketAddress,
fromToken: tokensData[params.payTokenAddress],
allowedSlippage,
collateralToken,
referralCodeForTxn: params.referralCodeForTxn,
triggerPrice: params.limitPrice,
collateralTokenAddress: collateralToken.address,
isLong: true,
receiveTokenAddress: collateralTokenAddress,
indexToken: marketInfo.indexToken,
marketInfo,
skipSimulation: params.skipSimulation,
increaseAmounts,
createSltpEntries: createSltpEntries.length > 0 ? createSltpEntries : undefined,
};
return sdk.orders.createIncreaseOrder(createIncreaseOrderParams);
}
function getTriggerRatio({
toToken,
fromToken,
triggerPrice,
}: {
toToken: TokenData;
fromToken: TokenData;
triggerPrice: bigint;
}) {
const fromTokenPrice = fromToken?.prices.minPrice;
const markPrice = toToken.prices.minPrice;
const markRatio = getTokensRatioByPrice({
fromToken,
toToken,
fromPrice: fromTokenPrice,
toPrice: markPrice,
});
const triggerRatio: TokensRatio = {
ratio: triggerPrice > 0 ? triggerPrice : markRatio.ratio,
largestToken: markRatio.largestToken,
smallestToken: markRatio.smallestToken,
};
return triggerRatio;
}
export type SwapParams = (
| {
fromAmount: bigint;
}
| {
toAmount: bigint;
}
) & {
fromTokenAddress: string;
toTokenAddress: string;
allowedSlippageBps?: number;
referralCodeForTxn?: string;
/** If presented, then it's limit swap order */
triggerPrice?: bigint;
} & BaseOptionalParams;
export async function swap(sdk: GmxSdk, params: SwapParams) {
const { tokensData, marketsInfoData, uiFeeFactor } = await getAndValidateBaseParams(sdk, params);
const fromToken = tokensData[params.fromTokenAddress];
const toToken = tokensData[params.toTokenAddress];
if (!fromToken || !toToken) {
throw new Error("From or to token is not available");
}
const isLimit = Boolean(params.triggerPrice);
if (!fromToken || !toToken) {
return undefined;
}
const graph = getMarketsGraph(Object.values(marketsInfoData));
const wrappedFromAddress = getWrappedAddress(sdk.chainId, params.fromTokenAddress);
const wrappedToAddress = getWrappedAddress(sdk.chainId, params.toTokenAddress);
const allPaths = findAllSwapPaths({
chainId: sdk.chainId,
fromTokenAddress: params.fromTokenAddress,
toTokenAddress: params.toTokenAddress,
marketsInfoData,
graph,
wrappedFromAddress,
wrappedToAddress,
});
const estimator = createSwapEstimator(marketsInfoData);
const findSwapPath = createFindSwapPath({
chainId: sdk.chainId,
fromTokenAddress: params.fromTokenAddress,
toTokenAddress: params.toTokenAddress,
marketsInfoData,
estimator,
allPaths,
});
const isWrapOrUnwrap = Boolean(
fromToken && toToken && (getIsWrap(fromToken, toToken) || getIsUnwrap(fromToken, toToken))
);
const swapOptimizationOrder: Parameters<FindSwapPath>[1]["order"] = isLimit ? ["length", "liquidity"] : undefined;
let swapAmounts: SwapAmounts | undefined;
const fromTokenPrice = fromToken.prices.minPrice;
const triggerRatio = params.triggerPrice
? getTriggerRatio({
fromToken,
toToken,
triggerPrice: params.triggerPrice,
})
: undefined;
if (isWrapOrUnwrap) {
const tokenAmount = "fromAmount" in params ? params.fromAmount : params.toAmount;
const usdAmount = convertToUsd(tokenAmount, fromToken.decimals, fromTokenPrice)!;
const price = fromTokenPrice;
swapAmounts = {
amountIn: tokenAmount,
usdIn: usdAmount!,
amountOut: tokenAmount,
usdOut: usdAmount!,
swapPathStats: undefined,
priceIn: price,
priceOut: price,
minOutputAmount: tokenAmount,
};
return swapAmounts;
} else if ("fromAmount" in params) {
swapAmounts = getSwapAmountsByFromValue({
tokenIn: fromToken,
tokenOut: toToken,
amountIn: params.fromAmount,
triggerRatio,
isLimit,
findSwapPath: findSwapPath,
uiFeeFactor,
swapOptimizationOrder,
allowedSwapSlippageBps: isLimit ? BigInt(params.allowedSlippageBps ?? 100) : undefined,
});
} else {
swapAmounts = getSwapAmountsByToValue({
tokenIn: fromToken,
tokenOut: toToken,
amountOut: params.toAmount,
triggerRatio,
isLimit: isLimit,
findSwapPath: findSwapPath,
uiFeeFactor,
swapOptimizationOrder,
allowedSwapSlippageBps: isLimit ? BigInt(params.allowedSlippageBps ?? 100) : undefined,
});
}
if (!swapAmounts) {
return undefined;
}
const createSwapOrderParams: Parameters<typeof sdk.orders.createSwapOrder>[0] = {
tokensData,
fromToken: tokensData[params.fromTokenAddress],
toToken: tokensData[params.toTokenAddress],
swapAmounts,
isLimit,
allowedSlippage: params.allowedSlippageBps ?? 100,
referralCodeForTxn: params.referralCodeForTxn,
triggerPrice: params.triggerPrice,
};
return sdk.orders.createSwapOrder(createSwapOrderParams);
}

View File

@@ -0,0 +1,20 @@
import {describe, expect, it} from "vitest";
import {arbitrumSdk} from "../../utils/testUtil.js";
describe("Positions", () => {
describe("read", () => {
it("should be able to get orders", async () => {
const { marketsInfoData, tokensData } = (await arbitrumSdk.markets.getMarketsInfo()) ?? {};
if (!tokensData || !marketsInfoData) {
throw new Error("Tokens data or markets info is not available");
}
const orders = await arbitrumSdk.orders.getOrders({
marketsInfoData,
tokensData,
});
expect(orders).toBeDefined();
});
});
});

View File

@@ -0,0 +1,429 @@
import { Address } from "viem";
import { getWrappedToken } from "../../configs/tokens.js";
import { MarketFilterLongShortItemData } from "../../modules/trades/trades.js";
import { MarketInfo, MarketsInfoData } from "../../types/markets.js";
import { Order, OrdersData, OrdersInfoData, OrderType, PositionOrderInfo } from "../../types/orders.js";
import { SidecarLimitOrderEntryValid, SidecarSlTpOrderEntryValid } from "../../types/sidecarOrders.js";
import { TokenData, TokensData } from "../../types/tokens.js";
import { DecreasePositionAmounts, IncreasePositionAmounts, SwapAmounts } from "../../types/trade.js";
import { getByKey } from "../../utils/objects.js";
import { getOrderInfo, isOrderForPositionByData, isVisibleOrder } from "../../utils/orders.js";
import { createDecreaseOrderTxn } from "./transactions/createDecreaseOrderTxn.js";
import { createIncreaseOrderTxn } from "./transactions/createIncreaseOrderTxn.js";
import { buildGetOrdersMulticall, getExecutionFeeAmountForEntry, matchByMarket, parseGetOrdersResponse } from "./utils.js";
import { Module } from "../base.js";
import { createSwapOrderTxn } from "./transactions/createSwapOrderTxn.js";
import { createWrapOrUnwrapTxn, WrapOrUnwrapParams } from "./transactions/createWrapOrUnwrapTxn.js";
import { cancelOrdersTxn } from "./transactions/cancelOrdersTxn.js";
import { PositionIncreaseParams, SwapParams, increaseOrderHelper, swap } from "./helpers.js";
export class Orders extends Module {
async getOrders({
account: _account,
marketsInfoData,
tokensData,
orderTypesFilter = [],
marketsDirectionsFilter = [],
}: {
account?: string;
marketsInfoData: MarketsInfoData;
tokensData: TokensData;
orderTypesFilter?: OrderType[];
marketsDirectionsFilter?: MarketFilterLongShortItemData[];
}) {
const account = _account || this.account;
if (!account) {
return {
count: 0,
ordersInfoData: {},
};
}
const nonSwapRelevantDefinedFiltersLowercased: MarketFilterLongShortItemData[] = marketsDirectionsFilter
.filter((filter) => filter.direction !== "swap" && filter.marketAddress !== "any")
.map((filter) => ({
marketAddress: filter.marketAddress.toLowerCase() as Address,
direction: filter.direction,
collateralAddress: filter.collateralAddress?.toLowerCase() as Address,
}));
const hasNonSwapRelevantDefinedMarkets = nonSwapRelevantDefinedFiltersLowercased.length > 0;
const pureDirectionFilters = marketsDirectionsFilter
.filter((filter) => filter.direction !== "any" && filter.marketAddress === "any")
.map((filter) => filter.direction);
const hasPureDirectionFilters = pureDirectionFilters.length > 0;
const swapRelevantDefinedMarketsLowercased = marketsDirectionsFilter
.filter((filter) => (filter.direction === "any" || filter.direction === "swap") && filter.marketAddress !== "any")
.map((filter) => filter.marketAddress.toLowerCase() as Address);
const hasSwapRelevantDefinedMarkets = swapRelevantDefinedMarketsLowercased.length > 0;
const orders = await this.sdk
.executeMulticall(buildGetOrdersMulticall(this.chainId, account))
.then(parseGetOrdersResponse);
const filteredOrders = orders.orders.filter((order) => {
if (!isVisibleOrder(order.orderType)) {
return false;
}
const matchByMarketResult = matchByMarket({
order,
nonSwapRelevantDefinedFiltersLowercased,
hasNonSwapRelevantDefinedMarkets,
pureDirectionFilters,
hasPureDirectionFilters,
swapRelevantDefinedMarketsLowercased,
hasSwapRelevantDefinedMarkets,
chainId: this.chainId,
marketsInfoData,
});
let matchByOrderType = true;
if (orderTypesFilter.length > 0) {
matchByOrderType = orderTypesFilter.includes(order.orderType);
}
return matchByMarketResult && matchByOrderType;
});
const ordersData = filteredOrders?.reduce((acc, order) => {
acc[order.key] = order;
return acc;
}, {} as OrdersData);
const wrappedToken = getWrappedToken(this.chainId);
const ordersInfoData = Object.keys(ordersData).reduce((acc: OrdersInfoData, orderKey: string) => {
const order = getByKey(ordersData, orderKey)!;
const orderInfo = getOrderInfo({
marketsInfoData,
tokensData,
wrappedNativeToken: wrappedToken,
order: order as Order,
});
if (!orderInfo) {
// eslint-disable-next-line no-console
console.warn(`OrderInfo parsing error`, order);
return acc;
}
acc[orderKey] = orderInfo;
return acc;
}, {} as OrdersInfoData);
return {
count: orders.count,
ordersInfoData,
};
}
async createIncreaseOrder({
isLimit,
marketAddress,
allowedSlippage,
collateralTokenAddress,
receiveTokenAddress,
fromToken,
triggerPrice,
referralCodeForTxn,
increaseAmounts,
collateralToken,
createSltpEntries,
cancelSltpEntries,
updateSltpEntries,
marketInfo,
isLong,
indexToken,
marketsInfoData,
tokensData,
skipSimulation,
}: {
marketsInfoData: MarketsInfoData;
tokensData: TokensData;
isLimit: boolean;
marketAddress: string;
fromToken: TokenData;
allowedSlippage: number;
collateralToken: TokenData;
referralCodeForTxn?: string;
triggerPrice?: bigint;
collateralTokenAddress: string;
receiveTokenAddress: string;
isLong: boolean;
createSltpEntries?: SidecarSlTpOrderEntryValid[];
cancelSltpEntries?: (SidecarSlTpOrderEntryValid | SidecarLimitOrderEntryValid)[];
updateSltpEntries?: (SidecarSlTpOrderEntryValid | SidecarLimitOrderEntryValid)[];
marketInfo: MarketInfo;
indexToken: TokenData;
increaseAmounts: IncreasePositionAmounts;
skipSimulation?: boolean;
}) {
const account = this.account;
if (!account) {
throw new Error("Account is not defined");
}
const gasLimits = await this.sdk.utils.getGasLimits();
const gasPrice = await this.sdk.utils.getGasPrice();
const executionFee = await this.sdk.utils.getExecutionFee("increase", tokensData, {
increaseAmounts,
});
if (!executionFee) {
throw new Error("Execution fee is not available");
}
const { ordersInfoData } = await this.sdk.orders.getOrders({
marketsInfoData,
tokensData,
});
const orders = Object.values(ordersInfoData || {});
const positionOrders = orders.filter((order) =>
isOrderForPositionByData(order, {
isLong,
marketAddress,
account,
collateralAddress: collateralToken.address,
})
);
const { autoCancelOrdersLimit } = await this.sdk.positions.getMaxAutoCancelOrders({
positionOrders,
});
const commonSecondaryOrderParams = {
account,
marketAddress,
swapPath: [],
allowedSlippage,
initialCollateralAddress: collateralTokenAddress,
receiveTokenAddress,
isLong,
indexToken,
};
return createIncreaseOrderTxn({
sdk: this.sdk,
createIncreaseOrderParams: {
account,
marketAddress: marketInfo.marketTokenAddress,
initialCollateralAddress: fromToken?.address,
initialCollateralAmount: increaseAmounts.initialCollateralAmount,
targetCollateralAddress: collateralToken.address,
collateralDeltaAmount: increaseAmounts.collateralDeltaAmount,
swapPath: increaseAmounts.swapPathStats?.swapPath || [],
sizeDeltaUsd: increaseAmounts.sizeDeltaUsd,
sizeDeltaInTokens: increaseAmounts.sizeDeltaInTokens,
triggerPrice: isLimit ? triggerPrice : undefined,
acceptablePrice: increaseAmounts.acceptablePrice,
isLong,
orderType: isLimit ? OrderType.LimitIncrease : OrderType.MarketIncrease,
executionFee: executionFee.feeTokenAmount,
allowedSlippage,
referralCode: referralCodeForTxn,
indexToken: marketInfo.indexToken,
tokensData,
skipSimulation: skipSimulation || isLimit,
},
createDecreaseOrderParams: createSltpEntries?.map((entry, i) => {
return {
...commonSecondaryOrderParams,
initialCollateralDeltaAmount: entry.decreaseAmounts.collateralDeltaAmount ?? 0n,
sizeDeltaUsd: entry.decreaseAmounts.sizeDeltaUsd,
sizeDeltaInTokens: entry.decreaseAmounts.sizeDeltaInTokens,
acceptablePrice: entry.decreaseAmounts.acceptablePrice,
triggerPrice: entry.decreaseAmounts.triggerPrice,
minOutputUsd: 0n,
decreasePositionSwapType: entry.decreaseAmounts.decreaseSwapType,
orderType: entry.decreaseAmounts.triggerOrderType!,
referralCode: referralCodeForTxn,
executionFee: getExecutionFeeAmountForEntry(this.sdk, entry, gasLimits, tokensData, gasPrice) ?? 0n,
tokensData,
txnType: entry.txnType!,
skipSimulation: isLimit,
autoCancel: i < autoCancelOrdersLimit,
};
}),
cancelOrderParams: cancelSltpEntries?.map((entry) => ({
...commonSecondaryOrderParams,
orderKey: entry.order!.key,
orderType: entry.order!.orderType,
minOutputAmount: 0n,
sizeDeltaUsd: entry.order!.sizeDeltaUsd,
txnType: entry.txnType!,
initialCollateralDeltaAmount: entry.order?.initialCollateralDeltaAmount ?? 0n,
})),
updateOrderParams: updateSltpEntries?.map((entry) => ({
...commonSecondaryOrderParams,
orderKey: entry.order!.key,
orderType: entry.order!.orderType,
sizeDeltaUsd: (entry.increaseAmounts?.sizeDeltaUsd || entry.decreaseAmounts?.sizeDeltaUsd)!,
acceptablePrice: (entry.increaseAmounts?.acceptablePrice || entry.decreaseAmounts?.acceptablePrice)!,
triggerPrice: (entry.increaseAmounts?.triggerPrice || entry.decreaseAmounts?.triggerPrice)!,
executionFee: getExecutionFeeAmountForEntry(this.sdk, entry, gasLimits, tokensData, gasPrice) ?? 0n,
minOutputAmount: 0n,
txnType: entry.txnType!,
initialCollateralDeltaAmount: entry.order?.initialCollateralDeltaAmount ?? 0n,
autoCancel: entry.order!.autoCancel,
})),
});
}
async createDecreaseOrder({
marketsInfoData,
tokensData,
marketInfo,
decreaseAmounts,
collateralToken,
allowedSlippage,
isLong,
referralCode,
}: {
marketInfo: MarketInfo;
marketsInfoData: MarketsInfoData;
tokensData: TokensData;
isLong: boolean;
allowedSlippage: number;
decreaseAmounts: DecreasePositionAmounts;
collateralToken: TokenData;
referralCode?: string;
}) {
const account = this.account;
if (!account) {
throw new Error("Account is not defined");
}
const executionFee = await this.sdk.utils.getExecutionFee("decrease", tokensData, {
decreaseAmounts,
});
if (!executionFee) {
throw new Error("Execution fee is not available");
}
if (decreaseAmounts?.triggerOrderType === undefined) {
throw new Error("Trigger order type is not defined");
}
const { ordersInfoData } = await this.sdk.orders.getOrders({
marketsInfoData,
tokensData,
});
const orders = Object.values(ordersInfoData || {});
const positionOrders = orders.filter((order) =>
isOrderForPositionByData(order, {
isLong,
marketAddress: marketInfo.marketTokenAddress,
account,
collateralAddress: collateralToken.address,
})
) as PositionOrderInfo[];
const { autoCancelOrdersLimit } = await this.sdk.positions.getMaxAutoCancelOrders({
positionOrders,
});
return createDecreaseOrderTxn(this.sdk, {
account,
marketAddress: marketInfo.marketTokenAddress,
swapPath: [],
initialCollateralDeltaAmount: decreaseAmounts.collateralDeltaAmount,
initialCollateralAddress: collateralToken.address,
receiveTokenAddress: collateralToken.address,
triggerPrice: decreaseAmounts.triggerPrice,
acceptablePrice: decreaseAmounts.acceptablePrice,
sizeDeltaUsd: decreaseAmounts.sizeDeltaUsd,
sizeDeltaInTokens: decreaseAmounts.sizeDeltaInTokens,
minOutputUsd: BigInt(0),
isLong,
decreasePositionSwapType: decreaseAmounts.decreaseSwapType,
orderType: decreaseAmounts?.triggerOrderType,
executionFee: executionFee.feeTokenAmount,
allowedSlippage,
referralCode,
skipSimulation: true,
indexToken: marketInfo.indexToken,
tokensData,
autoCancel: autoCancelOrdersLimit > 0,
});
}
async createSwapOrder({
isLimit,
swapAmounts,
allowedSlippage,
fromToken,
toToken,
referralCodeForTxn,
tokensData,
triggerPrice,
}: {
isLimit: boolean;
allowedSlippage: number;
swapAmounts: SwapAmounts;
fromToken: TokenData;
referralCodeForTxn?: string;
toToken: TokenData;
tokensData: TokensData;
triggerPrice?: bigint;
}) {
const orderType = isLimit ? OrderType.LimitSwap : OrderType.MarketSwap;
const executionFee = await this.sdk.utils.getExecutionFee("swap", tokensData, {
swapAmounts,
});
if (!swapAmounts?.swapPathStats || !executionFee) {
throw new Error("Swap data is not defined");
}
return createSwapOrderTxn(this.sdk, {
fromTokenAddress: fromToken.address,
fromTokenAmount: swapAmounts.amountIn,
swapPath: swapAmounts.swapPathStats?.swapPath,
toTokenAddress: toToken.address,
orderType,
minOutputAmount: swapAmounts.minOutputAmount,
referralCode: referralCodeForTxn,
executionFee: executionFee.feeTokenAmount,
allowedSlippage,
tokensData,
triggerPrice: isLimit && triggerPrice !== undefined ? triggerPrice : undefined,
});
}
async cancelOrders(orderKeys: string[]) {
return cancelOrdersTxn(this.sdk, {
orderKeys: orderKeys,
});
}
async createWrapOrUnwrapOrder(p: WrapOrUnwrapParams) {
return createWrapOrUnwrapTxn(this.sdk, p);
}
async long(params: PositionIncreaseParams) {
return increaseOrderHelper(this.sdk, { ...params, isLong: true });
}
async short(params: PositionIncreaseParams) {
return increaseOrderHelper(this.sdk, { ...params, isLong: false });
}
async swap(params: SwapParams) {
return swap(this.sdk, params);
}
}

View File

@@ -0,0 +1,26 @@
import { Abi, encodeFunctionData } from "viem";
import { abis } from "../../../abis/index.js";
import { getContract } from "../../../configs/contracts.js";
import type { GmxSdk } from "../../../index.js";
export type CancelOrderParams = {
orderKeys: string[];
};
export async function cancelOrdersTxn(sdk: GmxSdk, p: CancelOrderParams) {
const multicall = createCancelEncodedPayload(p.orderKeys);
const exchangeRouter = getContract(sdk.chainId, "ExchangeRouter");
return sdk.callContract(exchangeRouter, abis.ExchangeRouter as Abi, "multicall", [multicall]);
}
export function createCancelEncodedPayload(orderKeys: (string | null)[] = []) {
return orderKeys.filter(Boolean).map((orderKey) =>
encodeFunctionData({
abi: abis.ExchangeRouter as Abi,
functionName: "cancelOrder",
args: [orderKey],
})
);
}

View File

@@ -0,0 +1,154 @@
import { getContract } from "../../../configs/contracts.js";
import type { DecreasePositionSwapType, OrderType } from "../../../types/orders.js";
import type { Token, TokensData } from "../../../types/tokens.js";
import type { GmxSdk } from "../../../index.js";
import type { PriceOverrides } from "./createIncreaseOrderTxn.js";
import { abis } from "../../../abis/index.js";
import { convertTokenAddress, NATIVE_TOKEN_ADDRESS } from "../../../configs/tokens.js";
import { isMarketOrderType } from "../../../utils/orders.js";
import { simulateExecuteOrder } from "../../../utils/simulateExecuteOrder.js";
import { convertToContractPrice } from "../../../utils/tokens.js";
import { applySlippageToMinOut, applySlippageToPrice } from "../../../utils/trade/index.js";
import { Abi, encodeFunctionData, zeroAddress, zeroHash } from "viem";
export type DecreaseOrderParams = {
account: string;
marketAddress: string;
initialCollateralAddress: string;
initialCollateralDeltaAmount: bigint;
swapPath: string[];
receiveTokenAddress: string;
sizeDeltaUsd: bigint;
sizeDeltaInTokens: bigint;
acceptablePrice: bigint;
triggerPrice: bigint | undefined;
minOutputUsd: bigint;
isLong: boolean;
decreasePositionSwapType: DecreasePositionSwapType;
orderType: OrderType.MarketDecrease | OrderType.LimitDecrease | OrderType.StopLossDecrease;
executionFee: bigint;
allowedSlippage: number;
skipSimulation?: boolean;
referralCode?: string;
indexToken: Token;
tokensData: TokensData;
autoCancel: boolean;
};
export async function createDecreaseOrderTxn(sdk: GmxSdk, params: DecreaseOrderParams | DecreaseOrderParams[]) {
const chainId = sdk.chainId;
const ps = Array.isArray(params) ? params : [params];
const orderVaultAddress = getContract(chainId, "OrderVault");
const totalWntAmount = ps.reduce((acc, p) => acc + p.executionFee, 0n);
const encodedPayload = createDecreaseEncodedPayload({
sdk,
orderVaultAddress,
ps,
});
const simulationEncodedPayload = createDecreaseEncodedPayload({
sdk,
orderVaultAddress,
ps,
});
await Promise.all(
ps.map(async (p) => {
if (!p.skipSimulation) {
const primaryPriceOverrides: PriceOverrides = {};
if (p.triggerPrice != undefined) {
primaryPriceOverrides[p.indexToken.address] = {
minPrice: p.triggerPrice,
maxPrice: p.triggerPrice,
};
}
await simulateExecuteOrder(sdk, {
primaryPriceOverrides,
createMulticallPayload: simulationEncodedPayload,
value: totalWntAmount,
tokensData: p.tokensData,
});
}
})
);
const routerAddress = getContract(chainId, "ExchangeRouter");
await sdk.callContract(routerAddress, abis.ExchangeRouter as Abi, "multicall", [encodedPayload], {
value: totalWntAmount,
});
}
export function createDecreaseEncodedPayload({
sdk,
orderVaultAddress,
ps,
}: {
sdk: GmxSdk;
orderVaultAddress: string;
ps: DecreaseOrderParams[];
}) {
const multicall = [
...ps.flatMap((p) => {
const isNativeReceive = p.receiveTokenAddress === NATIVE_TOKEN_ADDRESS;
const initialCollateralTokenAddress = convertTokenAddress(sdk.chainId, p.initialCollateralAddress, "wrapped");
const shouldApplySlippage = isMarketOrderType(p.orderType);
const acceptablePrice = shouldApplySlippage
? applySlippageToPrice(p.allowedSlippage, p.acceptablePrice, false, p.isLong)
: p.acceptablePrice;
const minOutputAmount = shouldApplySlippage
? applySlippageToMinOut(p.allowedSlippage, p.minOutputUsd)
: p.minOutputUsd;
const orderParams = {
addresses: {
cancellationReceiver: zeroAddress,
receiver: p.account,
initialCollateralToken: initialCollateralTokenAddress,
callbackContract: zeroAddress,
market: p.marketAddress,
swapPath: p.swapPath,
uiFeeReceiver: zeroAddress,
},
numbers: {
sizeDeltaUsd: p.sizeDeltaUsd,
initialCollateralDeltaAmount: p.initialCollateralDeltaAmount,
triggerPrice: convertToContractPrice(p.triggerPrice ?? 0n, p.indexToken.decimals),
acceptablePrice: convertToContractPrice(acceptablePrice, p.indexToken.decimals),
executionFee: p.executionFee,
callbackGasLimit: 0n,
minOutputAmount,
validFromTime: 0n,
},
orderType: p.orderType,
decreasePositionSwapType: p.decreasePositionSwapType,
isLong: p.isLong,
shouldUnwrapNativeToken: isNativeReceive,
autoCancel: p.autoCancel,
referralCode: p.referralCode || zeroHash,
};
return [
{ method: "sendWnt", params: [orderVaultAddress, p.executionFee] },
{
method: "createOrder",
params: [orderParams],
},
];
}),
];
return multicall.filter(Boolean).map((call) =>
encodeFunctionData({
abi: abis.ExchangeRouter as Abi,
functionName: call!.method,
args: call!.params as any,
})
);
}

View File

@@ -0,0 +1,301 @@
import { abis } from "../../../abis/index.js";
import { getContract } from "../../../configs/contracts.js";
import { convertTokenAddress, NATIVE_TOKEN_ADDRESS } from "../../../configs/tokens.js";
import type { GmxSdk } from "../../../index.js";
import concat from "lodash/concat.js";
import { DecreasePositionSwapType, OrderTxnType, OrderType } from "../../../types/orders.js";
import { TokenData, TokenPrices, TokensData } from "../../../types/tokens.js";
import { isMarketOrderType } from "../../../utils/orders.js";
import { convertToContractPrice } from "../../../utils/tokens.js";
import { Abi, encodeFunctionData, zeroAddress, zeroHash } from "viem";
import { createCancelEncodedPayload } from "./cancelOrdersTxn.js";
import { createDecreaseEncodedPayload, DecreaseOrderParams } from "./createDecreaseOrderTxn.js";
import { createUpdateEncodedPayload } from "./updateOrderTxn.js";
import { simulateExecuteOrder } from "../../../utils/simulateExecuteOrder.js";
import { applySlippageToMinOut, applySlippageToPrice } from "../../../utils/trade/index.js";
export type PriceOverrides = {
[address: string]: TokenPrices | undefined;
};
type IncreaseOrderParams = {
account: string;
marketAddress: string;
initialCollateralAddress: string;
targetCollateralAddress: string;
initialCollateralAmount: bigint;
collateralDeltaAmount: bigint;
swapPath: string[];
sizeDeltaUsd: bigint;
sizeDeltaInTokens: bigint;
acceptablePrice: bigint;
triggerPrice: bigint | undefined;
isLong: boolean;
orderType: OrderType.MarketIncrease | OrderType.LimitIncrease;
executionFee: bigint;
allowedSlippage: number;
skipSimulation?: boolean;
referralCode: string | undefined;
indexToken: TokenData;
tokensData: TokensData;
};
type SecondaryOrderCommonParams = {
account: string;
marketAddress: string;
swapPath: string[];
allowedSlippage: number;
initialCollateralAddress: string;
receiveTokenAddress: string;
isLong: boolean;
indexToken: TokenData;
txnType: OrderTxnType;
orderType: OrderType;
sizeDeltaUsd: bigint;
initialCollateralDeltaAmount: bigint;
};
export type SecondaryDecreaseOrderParams = DecreaseOrderParams & SecondaryOrderCommonParams;
export type SecondaryCancelOrderParams = SecondaryOrderCommonParams & {
orderKey: string | null;
};
export type SecondaryUpdateOrderParams = SecondaryOrderCommonParams & {
orderKey: string;
sizeDeltaUsd: bigint;
acceptablePrice: bigint;
triggerPrice: bigint;
executionFee: bigint;
indexToken: TokenData;
minOutputAmount: bigint;
autoCancel: boolean;
};
export async function createIncreaseOrderTxn({
sdk,
createIncreaseOrderParams: p,
createDecreaseOrderParams,
cancelOrderParams,
updateOrderParams,
}: {
sdk: GmxSdk;
createIncreaseOrderParams: IncreaseOrderParams;
createDecreaseOrderParams?: SecondaryDecreaseOrderParams[];
cancelOrderParams?: SecondaryCancelOrderParams[];
updateOrderParams?: SecondaryUpdateOrderParams[];
}) {
const isNativePayment = p.initialCollateralAddress === NATIVE_TOKEN_ADDRESS;
const chainId = sdk.chainId;
const exchangeRouter = getContract(chainId, "ExchangeRouter");
const orderVaultAddress = getContract(chainId, "OrderVault");
const wntCollateralAmount = isNativePayment ? p.initialCollateralAmount : 0n;
const initialCollateralTokenAddress = convertTokenAddress(chainId, p.initialCollateralAddress, "wrapped");
const shouldApplySlippage = isMarketOrderType(p.orderType);
const acceptablePrice = shouldApplySlippage
? applySlippageToPrice(p.allowedSlippage, p.acceptablePrice, true, p.isLong)
: p.acceptablePrice;
const wntAmountToIncrease = wntCollateralAmount + p.executionFee;
const totalWntAmount = concat<undefined | SecondaryDecreaseOrderParams | SecondaryUpdateOrderParams>(
createDecreaseOrderParams,
updateOrderParams
).reduce((acc, p) => (p ? acc + p.executionFee : acc), wntAmountToIncrease);
const encodedPayload = await createEncodedPayload({
routerAbi: abis.ExchangeRouter as Abi,
orderVaultAddress,
totalWntAmount: wntAmountToIncrease,
p,
acceptablePrice,
isNativePayment,
initialCollateralTokenAddress,
});
const simulationEncodedPayload = await createEncodedPayload({
routerAbi: abis.ExchangeRouter as Abi,
orderVaultAddress,
totalWntAmount: wntAmountToIncrease,
p,
acceptablePrice,
isNativePayment,
initialCollateralTokenAddress,
});
const decreaseEncodedPayload = createDecreaseEncodedPayload({
sdk,
orderVaultAddress,
ps: createDecreaseOrderParams || [],
});
const cancelEncodedPayload = createCancelEncodedPayload(cancelOrderParams?.map(({ orderKey }) => orderKey) || []);
const updateEncodedPayload =
updateOrderParams?.reduce<string[]>(
(
acc,
{ orderKey, sizeDeltaUsd, executionFee, indexToken, acceptablePrice, triggerPrice, minOutputAmount, autoCancel }
) => {
return [
...acc,
...createUpdateEncodedPayload({
sdk,
orderKey,
sizeDeltaUsd,
executionFee,
indexToken,
acceptablePrice,
triggerPrice,
minOutputAmount,
autoCancel,
}),
];
},
[]
) ?? [];
const primaryPriceOverrides: PriceOverrides = {};
if (p.triggerPrice != undefined) {
primaryPriceOverrides[p.indexToken.address] = {
minPrice: p.triggerPrice,
maxPrice: p.triggerPrice,
};
}
if (!p.skipSimulation) {
await simulateExecuteOrder(sdk, {
tokensData: p.tokensData,
primaryPriceOverrides,
createMulticallPayload: simulationEncodedPayload,
value: totalWntAmount,
});
}
const finalPayload = [...encodedPayload, ...decreaseEncodedPayload, ...cancelEncodedPayload, ...updateEncodedPayload];
await sdk.callContract(exchangeRouter, abis.ExchangeRouter as Abi, "multicall", [finalPayload], {
value: totalWntAmount,
});
}
async function createEncodedPayload({
routerAbi,
orderVaultAddress,
totalWntAmount,
p,
acceptablePrice,
isNativePayment,
initialCollateralTokenAddress,
}: {
routerAbi: Abi;
orderVaultAddress: string;
totalWntAmount: bigint;
p: IncreaseOrderParams;
acceptablePrice: bigint;
isNativePayment: boolean;
initialCollateralTokenAddress: string;
}) {
const orderParams = createOrderParams({
p,
acceptablePrice,
initialCollateralTokenAddress,
isNativePayment,
});
const multicall = [
{ method: "sendWnt", params: [orderVaultAddress, totalWntAmount] },
!isNativePayment
? { method: "sendTokens", params: [p.initialCollateralAddress, orderVaultAddress, p.initialCollateralAmount] }
: undefined,
{
method: "createOrder",
params: [orderParams],
},
];
return multicall.filter(Boolean).map((call) =>
encodeFunctionData({
abi: routerAbi,
functionName: call!.method,
args: call!.params as any,
})
);
}
function createOrderParams({
p,
acceptablePrice,
initialCollateralTokenAddress,
isNativePayment,
}: {
p: IncreaseOrderParams;
acceptablePrice: bigint;
initialCollateralTokenAddress: string;
isNativePayment: boolean;
}) {
return {
addresses: {
cancellationReceiver: zeroAddress,
receiver: p.account,
initialCollateralToken: initialCollateralTokenAddress,
callbackContract: zeroAddress,
market: p.marketAddress,
swapPath: p.swapPath,
uiFeeReceiver: zeroAddress,
},
numbers: {
sizeDeltaUsd: p.sizeDeltaUsd,
initialCollateralDeltaAmount: 0n,
triggerPrice: convertToContractPrice(p.triggerPrice ?? 0n, p.indexToken.decimals),
acceptablePrice: convertToContractPrice(acceptablePrice, p.indexToken.decimals),
executionFee: p.executionFee,
callbackGasLimit: 0n,
minOutputAmount: 0n,
validFromTime: 0n,
},
orderType: p.orderType,
decreasePositionSwapType: DecreasePositionSwapType.NoSwap,
isLong: p.isLong,
shouldUnwrapNativeToken: isNativePayment,
autoCancel: false,
referralCode: p.referralCode || zeroHash,
};
}
export function getPendingOrderFromParams(
chainId: number,
txnType: OrderTxnType,
p: DecreaseOrderParams | SecondaryUpdateOrderParams | SecondaryCancelOrderParams
) {
const isNativeReceive = p.receiveTokenAddress === NATIVE_TOKEN_ADDRESS;
const shouldApplySlippage = isMarketOrderType(p.orderType);
let minOutputAmount = 0n;
if ("minOutputUsd" in p) {
shouldApplySlippage ? applySlippageToMinOut(p.allowedSlippage, p.minOutputUsd) : p.minOutputUsd;
}
if ("minOutputAmount" in p) {
minOutputAmount = p.minOutputAmount;
}
const initialCollateralTokenAddress = convertTokenAddress(chainId, p.initialCollateralAddress, "wrapped");
const orderKey = "orderKey" in p && p.orderKey ? p.orderKey : undefined;
return {
txnType,
account: p.account,
marketAddress: p.marketAddress,
initialCollateralTokenAddress,
initialCollateralDeltaAmount: p.initialCollateralDeltaAmount,
swapPath: p.swapPath,
sizeDeltaUsd: p.sizeDeltaUsd,
minOutputAmount: minOutputAmount,
isLong: p.isLong,
orderType: p.orderType,
shouldUnwrapNativeToken: isNativeReceive,
orderKey,
};
}

View File

@@ -0,0 +1,121 @@
import { Abi, encodeFunctionData, zeroAddress, zeroHash } from "viem";
import { abis } from "../../../abis/index.js";
import { getContract } from "../../../configs/contracts.js";
import { NATIVE_TOKEN_ADDRESS, convertTokenAddress } from "../../../configs/tokens.js";
import { DecreasePositionSwapType, OrderType } from "../../../types/orders.js";
import { TokensData } from "../../../types/tokens.js";
import { isMarketOrderType } from "../../../utils/orders.js";
import { applySlippageToMinOut } from "../../../utils/trade/index.js";
import { simulateExecuteOrder } from "../../../utils/simulateExecuteOrder.js";
import type { GmxSdk } from "../../..";
export type SwapOrderParams = {
fromTokenAddress: string;
fromTokenAmount: bigint;
toTokenAddress: string;
swapPath: string[];
referralCode?: string;
tokensData: TokensData;
minOutputAmount: bigint;
orderType: OrderType.MarketSwap | OrderType.LimitSwap;
executionFee: bigint;
allowedSlippage: number;
triggerPrice?: bigint;
};
export async function createSwapOrderTxn(sdk: GmxSdk, p: SwapOrderParams) {
const { encodedPayload, totalWntAmount } = await getParams(sdk, p);
const { encodedPayload: simulationEncodedPayload, totalWntAmount: sumaltionTotalWntAmount } = await getParams(sdk, p);
if (p.orderType !== OrderType.LimitSwap) {
await simulateExecuteOrder(sdk, {
primaryPriceOverrides: {},
createMulticallPayload: simulationEncodedPayload,
value: sumaltionTotalWntAmount,
tokensData: p.tokensData,
});
}
await sdk.callContract(
getContract(sdk.chainId, "ExchangeRouter"),
abis.ExchangeRouter as Abi,
"multicall",
[encodedPayload],
{
value: totalWntAmount,
}
);
}
async function getParams(sdk: GmxSdk, p: SwapOrderParams) {
const isNativePayment = p.fromTokenAddress === NATIVE_TOKEN_ADDRESS;
const isNativeReceive = p.toTokenAddress === NATIVE_TOKEN_ADDRESS;
const orderVaultAddress = getContract(sdk.chainId, "OrderVault");
const wntSwapAmount = isNativePayment ? p.fromTokenAmount : 0n;
const totalWntAmount = wntSwapAmount + p.executionFee;
const initialCollateralTokenAddress = convertTokenAddress(sdk.chainId, p.fromTokenAddress, "wrapped");
const shouldApplySlippage = isMarketOrderType(p.orderType);
const minOutputAmount = shouldApplySlippage
? applySlippageToMinOut(p.allowedSlippage, p.minOutputAmount)
: p.minOutputAmount;
const initialCollateralDeltaAmount = p.fromTokenAmount;
const createOrderParams = {
addresses: {
receiver: sdk.config.account,
cancellationReceiver: zeroAddress,
initialCollateralToken: initialCollateralTokenAddress,
callbackContract: zeroAddress,
market: zeroAddress,
swapPath: p.swapPath,
uiFeeReceiver: zeroAddress,
},
numbers: {
sizeDeltaUsd: 0n,
initialCollateralDeltaAmount,
triggerPrice: p.triggerPrice !== undefined ? p.triggerPrice : 0n,
acceptablePrice: 0n,
executionFee: p.executionFee,
callbackGasLimit: 0n,
minOutputAmount,
validFromTime: 0n,
},
autoCancel: false,
orderType: p.orderType,
decreasePositionSwapType: DecreasePositionSwapType.NoSwap,
isLong: false,
shouldUnwrapNativeToken: isNativeReceive,
referralCode: p.referralCode || zeroHash,
};
const multicall = [
{ method: "sendWnt", params: [orderVaultAddress, totalWntAmount] },
!isNativePayment
? { method: "sendTokens", params: [p.fromTokenAddress, orderVaultAddress, p.fromTokenAmount] }
: undefined,
{
method: "createOrder",
params: [createOrderParams],
},
];
return {
minOutputAmount,
totalWntAmount,
encodedPayload: multicall
.filter(Boolean)
.map((call) =>
encodeFunctionData({ abi: abis.ExchangeRouter as Abi, functionName: call!.method, args: call!.params as any })
),
};
}

View File

@@ -0,0 +1,23 @@
import { Abi, Address } from "viem";
import { getWrappedToken } from "../../../configs/tokens.js";
import { abis } from "../../../abis/index.js";
import type { GmxSdk } from "../../../index.js";
export type WrapOrUnwrapParams = {
amount: bigint;
isWrap: boolean;
};
export function createWrapOrUnwrapTxn(sdk: GmxSdk, p: WrapOrUnwrapParams) {
const wrappedToken = getWrappedToken(sdk.chainId);
if (p.isWrap) {
return sdk.callContract(wrappedToken.address as Address, abis.WETH as Abi, "deposit", [], {
value: p.amount,
});
} else {
return sdk.callContract(wrappedToken.address as Address, abis.WETH as Abi, "withdraw", [p.amount]);
}
}

View File

@@ -0,0 +1,100 @@
import { abis } from "../../../abis/index.js";
import { getContract } from "../../../configs/contracts.js";
import type { GmxSdk } from "../../../index.js";
import { Token } from "../../../types/tokens.js";
import { convertToContractPrice } from "../../../utils/tokens.js";
import { Abi, Address, encodeFunctionData } from "viem";
export type UpdateOrderParams = {
orderKey: string;
indexToken?: Token;
sizeDeltaUsd: bigint;
triggerPrice: bigint;
acceptablePrice: bigint;
minOutputAmount: bigint;
// used to top-up execution fee for frozen orders
executionFee?: bigint;
autoCancel: boolean;
};
export function updateOrderTxn(sdk: GmxSdk, p: UpdateOrderParams): Promise<Address> {
const {
orderKey,
sizeDeltaUsd,
triggerPrice,
acceptablePrice,
minOutputAmount,
executionFee,
indexToken,
autoCancel,
} = p;
const router = getContract(sdk.chainId, "ExchangeRouter");
const encodedPayload = createUpdateEncodedPayload({
sdk,
orderKey,
sizeDeltaUsd,
executionFee,
indexToken,
acceptablePrice,
triggerPrice,
minOutputAmount,
autoCancel,
});
return sdk.callContract(router, abis.ExchangeRouter as Abi, "multicall", [encodedPayload], {
value: executionFee != undefined && executionFee > 0 ? executionFee : undefined,
}) as Promise<Address>;
}
export function createUpdateEncodedPayload({
sdk,
orderKey,
sizeDeltaUsd,
executionFee,
indexToken,
acceptablePrice,
triggerPrice,
autoCancel,
minOutputAmount,
}: {
sdk: GmxSdk;
orderKey: string;
sizeDeltaUsd: bigint;
executionFee?: bigint;
indexToken?: Token;
acceptablePrice: bigint;
triggerPrice: bigint;
minOutputAmount: bigint;
autoCancel: boolean;
}) {
const orderVaultAddress = getContract(sdk.chainId, "OrderVault");
const multicall: { method: string; params: any[] }[] = [];
if (executionFee != undefined && executionFee > 0) {
multicall.push({ method: "sendWnt", params: [orderVaultAddress, executionFee] });
}
multicall.push({
method: "updateOrder",
params: [
orderKey,
sizeDeltaUsd,
acceptablePrice !== undefined ? convertToContractPrice(acceptablePrice, indexToken?.decimals || 0) : 0n,
triggerPrice !== undefined ? convertToContractPrice(triggerPrice, indexToken?.decimals || 0) : 0n,
minOutputAmount,
0n,
autoCancel,
],
});
return multicall.filter(Boolean).map((call) =>
encodeFunctionData({
abi: abis.ExchangeRouter as Abi,
functionName: call!.method,
args: call!.params,
})
);
}

View File

@@ -0,0 +1,223 @@
import { Address, isAddressEqual } from "viem";
import { GmxSdk } from "../../index.js";
import { accountOrderListKey } from "../../configs/dataStore.js";
import { getWrappedToken } from "../../configs/tokens.js";
import { GasLimitsConfig } from "../../types/fees.js";
import { MarketsInfoData } from "../../types/markets.js";
import { DecreasePositionSwapType, Order, OrderType } from "../../types/orders.js";
import { SidecarSlTpOrderEntry, SidecarLimitOrderEntry } from "../../types/sidecarOrders";
import { TokensData } from "../../types/tokens.js";
import { estimateExecuteDecreaseOrderGasLimit, estimateOrderOraclePriceCount, getExecutionFee } from "../../utils/fees/index.js";
import { isSwapOrderType, isLimitOrderType, isIncreaseOrderType, isTriggerDecreaseOrderType } from "../../utils/orders.js";
import { getSwapPathOutputAddresses } from "../../utils/swap/index.js";
import { MarketFilterLongShortItemData, MarketFilterLongShortDirection } from "../trades/trades.js";
import { MulticallRequestConfig, MulticallResult } from "../../utils/multicall.js";
import { getContract } from "../../configs/contracts.js";
export const getOrderExecutionFee = (
sdk: GmxSdk,
swapsCount: number,
decreasePositionSwapType: DecreasePositionSwapType | undefined,
gasLimits: GasLimitsConfig | undefined,
tokensData: TokensData | undefined,
gasPrice: bigint | undefined
) => {
if (!gasLimits || !tokensData || gasPrice === undefined) return;
const estimatedGas = estimateExecuteDecreaseOrderGasLimit(gasLimits, {
decreaseSwapType: decreasePositionSwapType,
swapsCount: swapsCount ?? 0,
});
const oraclePriceCount = estimateOrderOraclePriceCount(swapsCount);
return getExecutionFee(sdk.chainId, gasLimits, tokensData, estimatedGas, gasPrice, oraclePriceCount);
};
export const getExecutionFeeAmountForEntry = (
sdk: GmxSdk,
entry: SidecarSlTpOrderEntry | SidecarLimitOrderEntry,
gasLimits: GasLimitsConfig,
tokensData: TokensData,
gasPrice: bigint | undefined
) => {
if (!entry.txnType || entry.txnType === "cancel") return undefined;
const securedExecutionFee = entry.order?.executionFee ?? 0n;
let swapsCount = 0;
const executionFee = getOrderExecutionFee(
sdk,
swapsCount,
entry.decreaseAmounts?.decreaseSwapType,
gasLimits,
tokensData,
gasPrice
);
if (!executionFee || securedExecutionFee >= executionFee.feeTokenAmount) return undefined;
return executionFee.feeTokenAmount - securedExecutionFee;
};
export function matchByMarket({
order,
nonSwapRelevantDefinedFiltersLowercased,
hasNonSwapRelevantDefinedMarkets,
pureDirectionFilters,
hasPureDirectionFilters,
swapRelevantDefinedMarketsLowercased,
hasSwapRelevantDefinedMarkets,
marketsInfoData,
chainId,
}: {
order: ReturnType<typeof parseGetOrdersResponse>["orders"][number];
nonSwapRelevantDefinedFiltersLowercased: MarketFilterLongShortItemData[];
hasNonSwapRelevantDefinedMarkets: boolean;
pureDirectionFilters: MarketFilterLongShortDirection[];
hasPureDirectionFilters: boolean;
swapRelevantDefinedMarketsLowercased: Address[];
hasSwapRelevantDefinedMarkets: boolean;
marketsInfoData?: MarketsInfoData;
chainId: number;
}) {
if (!hasNonSwapRelevantDefinedMarkets && !hasSwapRelevantDefinedMarkets && !hasPureDirectionFilters) {
return true;
}
const isSwapOrder = isSwapOrderType(order.orderType);
const matchesPureDirectionFilter =
hasPureDirectionFilters &&
(isSwapOrder
? pureDirectionFilters.includes("swap")
: pureDirectionFilters.includes(order.isLong ? "long" : "short"));
if (hasPureDirectionFilters && !matchesPureDirectionFilter) {
return false;
}
if (!hasNonSwapRelevantDefinedMarkets && !hasSwapRelevantDefinedMarkets) {
return true;
}
if (isSwapOrder) {
const sourceMarketInSwapPath = swapRelevantDefinedMarketsLowercased.includes(
order.swapPath.at(0)!.toLowerCase() as Address
);
const destinationMarketInSwapPath = swapRelevantDefinedMarketsLowercased.includes(
order.swapPath.at(-1)!.toLowerCase() as Address
);
return sourceMarketInSwapPath || destinationMarketInSwapPath;
} else if (!isSwapOrder) {
return nonSwapRelevantDefinedFiltersLowercased.some((filter) => {
const marketMatch = filter.marketAddress === "any" || filter.marketAddress === order.marketAddress.toLowerCase();
const directionMath = filter.direction === "any" || filter.direction === (order.isLong ? "long" : "short");
const initialCollateralAddress = order.initialCollateralTokenAddress.toLowerCase();
let collateralMatch = true;
if (!filter.collateralAddress) {
collateralMatch = true;
} else if (isLimitOrderType(order.orderType)) {
const wrappedToken = getWrappedToken(chainId);
if (!marketsInfoData) {
collateralMatch = true;
} else {
const { outTokenAddress } = getSwapPathOutputAddresses({
marketsInfoData,
initialCollateralAddress,
isIncrease: isIncreaseOrderType(order.orderType),
shouldUnwrapNativeToken: order.shouldUnwrapNativeToken,
swapPath: order.swapPath,
wrappedNativeTokenAddress: wrappedToken.address,
});
collateralMatch =
outTokenAddress !== undefined && isAddressEqual(outTokenAddress as Address, filter.collateralAddress);
}
} else if (isTriggerDecreaseOrderType(order.orderType)) {
collateralMatch = isAddressEqual(order.initialCollateralTokenAddress as Address, filter.collateralAddress);
}
return marketMatch && directionMath && collateralMatch;
});
}
return false;
}
export const DEFAULT_COUNT = 1000;
export function buildGetOrdersMulticall(chainId: number, account: string) {
return {
dataStore: {
contractAddress: getContract(chainId, "DataStore"),
abiId: "DataStore",
calls: {
count: {
methodName: "getBytes32Count",
params: [accountOrderListKey(account!)],
},
keys: {
methodName: "getBytes32ValuesAt",
params: [accountOrderListKey(account!), 0, DEFAULT_COUNT],
},
},
},
reader: {
contractAddress: getContract(chainId, "SyntheticsReader"),
abiId: "SyntheticsReader",
calls: {
orders: {
methodName: "getAccountOrders",
params: [getContract(chainId, "DataStore"), account, 0, DEFAULT_COUNT],
},
},
},
} satisfies MulticallRequestConfig<any>;
}
export function parseGetOrdersResponse(res: MulticallResult<ReturnType<typeof buildGetOrdersMulticall>>) {
const count = Number(res.data.dataStore.count.returnValues[0]);
const orderKeys = res.data.dataStore.keys.returnValues;
const orders = res.data.reader.orders.returnValues as any[];
return {
count,
orders: orders.map((order, i) => {
const key = orderKeys[i];
const { data } = order;
const orderData: Order = {
key,
account: order.addresses.account as Address,
receiver: order.addresses.receiver as Address,
callbackContract: order.addresses.callbackContract as Address,
marketAddress: order.addresses.market as Address,
initialCollateralTokenAddress: order.addresses.initialCollateralToken as Address,
swapPath: order.addresses.swapPath as Address[],
sizeDeltaUsd: BigInt(order.numbers.sizeDeltaUsd),
initialCollateralDeltaAmount: BigInt(order.numbers.initialCollateralDeltaAmount),
contractTriggerPrice: BigInt(order.numbers.triggerPrice),
contractAcceptablePrice: BigInt(order.numbers.acceptablePrice),
executionFee: BigInt(order.numbers.executionFee),
callbackGasLimit: BigInt(order.numbers.callbackGasLimit),
minOutputAmount: BigInt(order.numbers.minOutputAmount),
updatedAtTime: BigInt(order.numbers.updatedAtTime),
isLong: order.flags.isLong as boolean,
shouldUnwrapNativeToken: order.flags.shouldUnwrapNativeToken as boolean,
isFrozen: order.flags.isFrozen as boolean,
orderType: order.numbers.orderType as OrderType,
decreasePositionSwapType: order.numbers.decreasePositionSwapType as DecreasePositionSwapType,
autoCancel: order.flags.autoCancel as boolean,
data,
};
return orderData;
}),
};
}

View File

@@ -0,0 +1,34 @@
import { arbitrumSdk } from "../../utils/testUtil.js";
import { describe, expect, it } from "vitest";
describe("Positions", () => {
describe("getPositions", () => {
it("should be able to get positions data", async () => {
const { marketsInfoData, tokensData } = (await arbitrumSdk.markets.getMarketsInfo()) ?? {};
if (!tokensData || !marketsInfoData) {
throw new Error("Tokens data or markets info is not available");
}
const positions = await arbitrumSdk.positions.getPositions({ tokensData, marketsData: marketsInfoData });
expect(positions).toBeDefined();
});
it("should be able to get positions info", async () => {
const { marketsInfoData, tokensData } = (await arbitrumSdk.markets.getMarketsInfo()) ?? {};
if (!tokensData || !marketsInfoData) {
throw new Error("Tokens data or markets info is not available");
}
const positions = await arbitrumSdk.positions.getPositionsInfo({
tokensData,
marketsInfoData,
showPnlInLeverage: true,
});
expect(positions).toBeDefined();
});
});
});

View File

@@ -0,0 +1,672 @@
import { zeroAddress, zeroHash } from "viem";
import { getContract } from "../../configs/contracts.js";
import {
hashedPositionKey,
MAX_AUTO_CANCEL_ORDERS_KEY,
MIN_COLLATERAL_USD_KEY,
MIN_POSITION_SIZE_USD_KEY,
uiFeeFactorKey,
} from "../../configs/dataStore.js";
import { ContractMarketPrices, MarketsData, MarketsInfoData } from "../../types/markets.js";
import { Position, PositionsData, PositionsInfoData } from "../../types/positions.js";
import { TokensData } from "../../types/tokens.js";
import {
getContractMarketPrices,
getMarketIndexName,
getMarketPoolName,
getMaxAllowedLeverageByMinCollateralFactor,
} from "../../utils/markets.js";
import { getByKey } from "../../utils/objects.js";
import {
getEntryPrice,
getLeverage,
getLiquidationPrice,
getPositionKey,
getPositionNetValue,
getPositionPnlUsd,
} from "../../utils/positions.js";
import { Module } from "../base.js";
import { UserReferralInfo } from "../../types/referrals.js";
import { getPositionFee, getPriceImpactForPosition } from "../../utils/fees/index.js";
import { basisPointsToFloat, getBasisPoints } from "../../utils/numbers.js";
import { getPositionPendingFeesUsd } from "../../utils/positions.js";
import { getMarkPrice } from "../../utils/prices.js";
import { decodeReferralCode } from "../../utils/referrals.js";
import { convertToTokenAmount, convertToUsd } from "../../utils/tokens.js";
import { OrderInfo } from "../../types/orders.js";
import type { MulticallRequestConfig } from "../../utils/multicall.js";
type PositionsResult = {
positionsData?: PositionsData;
allPossiblePositionsKeys?: string[];
error?: Error;
};
type PositionsConstantsResult = {
minCollateralUsd?: bigint;
minPositionSizeUsd?: bigint;
maxAutoCancelOrders?: bigint;
};
export class Positions extends Module {
static MAX_PENDING_UPDATE_AGE = 600 * 1000; // 10 minutes
private getKeysAndPricesParams(p: { marketsData: MarketsData | undefined; tokensData: TokensData | undefined }) {
const { marketsData, tokensData } = p;
const account = this.account;
const values = {
allPositionsKeys: [] as string[],
marketsPrices: [] as ContractMarketPrices[],
marketsKeys: [] as string[],
};
if (!account || !marketsData || !tokensData) {
return values;
}
const markets = Object.values(marketsData);
for (const market of markets) {
const marketPrices = getContractMarketPrices(tokensData, market);
if (!marketPrices || market.isSpotOnly) {
continue;
}
values.marketsKeys.push(market.marketTokenAddress);
values.marketsPrices.push(marketPrices);
const collaterals = market.isSameCollaterals
? [market.longTokenAddress]
: [market.longTokenAddress, market.shortTokenAddress];
for (const collateralAddress of collaterals) {
for (const isLong of [true, false]) {
const positionKey = getPositionKey(account, market.marketTokenAddress, collateralAddress, isLong);
values.allPositionsKeys.push(positionKey);
}
}
}
return values;
}
private getPositionsData(p: {
positionsData: PositionsData | undefined;
allPositionsKeys: string[] | undefined;
}): PositionsData | undefined {
const { positionsData, allPositionsKeys } = p;
if (!allPositionsKeys) {
return undefined;
}
return allPositionsKeys.reduce((acc, key) => {
let position: Position;
if (getByKey(positionsData, key)) {
position = { ...getByKey(positionsData, key)! };
} else {
return acc;
}
if (position.sizeInUsd > 0) {
acc[key] = position;
}
return acc;
}, {} as PositionsData);
}
async getPositions(p: {
marketsData: MarketsData;
tokensData: TokensData;
start?: number;
end?: number;
}): Promise<PositionsResult> {
const chainId = this.chainId;
const account = this.sdk.config.account;
const keysAndPrices = this.getKeysAndPricesParams(p);
const request = {
reader: {
contractAddress: getContract(chainId, "SyntheticsReader"),
abiId: "SyntheticsReader",
calls: {
positions: {
methodName: "getAccountPositionInfoList",
params: [
getContract(chainId, "DataStore"),
getContract(chainId, "ReferralStorage"),
account,
keysAndPrices.marketsKeys,
keysAndPrices.marketsPrices,
zeroAddress,
p.start ?? 0,
p.end ?? 1000,
],
},
},
},
} satisfies MulticallRequestConfig<any>;
const positions = await this.sdk.executeMulticall(request).then((res) => {
const positions = res.data.reader.positions.returnValues;
return positions.reduce((positionsMap: PositionsData, positionInfo) => {
const { position, fees, basePnlUsd } = positionInfo;
const { addresses, numbers, flags, data } = position;
const { account, market: marketAddress, collateralToken: collateralTokenAddress } = addresses;
// Empty position
if (numbers.increasedAtTime == 0n) {
return positionsMap;
}
const positionKey = getPositionKey(account, marketAddress, collateralTokenAddress, flags.isLong);
const contractPositionKey = hashedPositionKey(account, marketAddress, collateralTokenAddress, flags.isLong);
positionsMap[positionKey] = {
key: positionKey,
contractKey: contractPositionKey,
account,
marketAddress,
collateralTokenAddress,
sizeInUsd: numbers.sizeInUsd,
sizeInTokens: numbers.sizeInTokens,
collateralAmount: numbers.collateralAmount,
increasedAtTime: numbers.increasedAtTime,
decreasedAtTime: numbers.decreasedAtTime,
isLong: flags.isLong,
pendingBorrowingFeesUsd: fees.borrowing.borrowingFeeUsd,
fundingFeeAmount: fees.funding.fundingFeeAmount,
claimableLongTokenAmount: fees.funding.claimableLongTokenAmount,
claimableShortTokenAmount: fees.funding.claimableShortTokenAmount,
pnl: basePnlUsd,
positionFeeAmount: fees.positionFeeAmount,
traderDiscountAmount: fees.referral.traderDiscountAmount,
uiFeeAmount: fees.ui.uiFeeAmount,
data,
};
return positionsMap;
}, {} as PositionsData);
});
const positionsData = this.getPositionsData({
positionsData: positions,
allPositionsKeys: keysAndPrices?.allPositionsKeys,
});
return {
positionsData,
};
}
private getUiFeeFactorRequest(): Promise<bigint> {
if (!this.account) {
return Promise.resolve(0n);
}
return this.sdk
.executeMulticall({
dataStore: {
contractAddress: getContract(this.chainId, "DataStore"),
abiId: "DataStore",
calls: {
keys: {
methodName: "getUint",
params: [uiFeeFactorKey(this.account)],
},
},
},
})
.then((res) => {
return BigInt(res.data.dataStore.keys.returnValues[0] ?? 0n);
});
}
private _positionsConstants: PositionsConstantsResult | undefined = undefined;
async getPositionsConstants(): Promise<PositionsConstantsResult> {
if (this._positionsConstants) {
return this._positionsConstants;
}
const constants = await this.sdk
.executeMulticall({
dataStore: {
contractAddress: getContract(this.chainId, "DataStore"),
abiId: "DataStore",
calls: {
minCollateralUsd: {
methodName: "getUint",
params: [MIN_COLLATERAL_USD_KEY],
},
minPositionSizeUsd: {
methodName: "getUint",
params: [MIN_POSITION_SIZE_USD_KEY],
},
maxAutoCancelOrders: {
methodName: "getUint",
params: [MAX_AUTO_CANCEL_ORDERS_KEY],
},
},
},
})
.then((res) => {
return {
minCollateralUsd: res.data.dataStore.minCollateralUsd.returnValues[0],
minPositionSizeUsd: res.data.dataStore.minPositionSizeUsd.returnValues[0],
maxAutoCancelOrders: res.data.dataStore.maxAutoCancelOrders.returnValues[0],
};
});
this._positionsConstants = constants;
return constants;
}
async getMaxAutoCancelOrders({
draftOrdersCount = 0,
positionOrders = [],
}: {
positionOrders?: OrderInfo[];
draftOrdersCount?: number;
}) {
const constants = await this.getPositionsConstants();
const maxAutoCancelOrders = constants.maxAutoCancelOrders;
const existingAutoCancelOrders = positionOrders.filter((order) => order.autoCancel);
let warning = false;
let autoCancelOrdersLimit = 0;
if (maxAutoCancelOrders === undefined) {
return {
warning,
autoCancelOrdersLimit,
};
}
const allowedAutoCancelOrders = Number(maxAutoCancelOrders) - 1;
autoCancelOrdersLimit = allowedAutoCancelOrders - existingAutoCancelOrders.length;
const canAddAutoCancelOrder = autoCancelOrdersLimit - draftOrdersCount > 0;
if (!canAddAutoCancelOrder) {
warning = true;
}
return {
warning,
autoCancelOrdersLimit,
};
}
private async getCodeOwner(code: string | undefined): Promise<string | undefined> {
if (!code) {
return undefined;
}
const referralStorageAddress = getContract(this.chainId, "ReferralStorage");
return this.sdk
.executeMulticall({
referralStorage: {
contractAddress: referralStorageAddress,
abiId: "ReferralStorage",
calls: {
codeOwner: {
methodName: "codeOwners",
params: [code],
},
},
},
})
.then((res) => {
return res.data.referralStorage.codeOwner.returnValues[0];
});
}
private async getUserRefferalCode() {
const referralStorageAddress = getContract(this.chainId, "ReferralStorage");
const onChainCode = await this.sdk.executeMulticall({
referralStorage: {
contractAddress: referralStorageAddress,
abiId: "ReferralStorage",
calls: {
traderReferralCodes: {
methodName: "traderReferralCodes",
params: [this.account],
},
},
},
});
let attachedOnChain = false;
let userReferralCode: string | undefined = undefined;
let userReferralCodeString: string | undefined = undefined;
let referralCodeForTxn = zeroHash;
if (onChainCode && onChainCode === zeroHash) {
attachedOnChain = true;
userReferralCode = onChainCode;
userReferralCodeString = decodeReferralCode(onChainCode);
}
return {
attachedOnChain,
userReferralCode,
userReferralCodeString,
referralCodeForTxn,
};
}
private getAffiliateTier(): Promise<number | undefined> {
const referralStorageAddress = getContract(this.chainId, "ReferralStorage");
return this.sdk
.executeMulticall({
referralStorage: {
contractAddress: referralStorageAddress,
abiId: "ReferralStorage",
calls: {
referrerTiers: {
methodName: "referrerTiers",
params: [this.account],
},
},
},
})
.then((res) => {
return res.data.referralStorage.referrerTiers.returnValues[0];
});
}
private getTiers(tierLevel?: number) {
if (tierLevel === undefined) {
return {
totalRebate: 0n,
discountShare: 0n,
};
}
const referralStorageAddress = getContract(this.chainId, "ReferralStorage");
return this.sdk
.executeMulticall({
referralStorage: {
contractAddress: referralStorageAddress,
abiId: "ReferralStorage",
calls: {
tiers: {
methodName: "tiers",
params: [tierLevel],
},
},
},
})
.then((res) => {
const [totalRebate, discountShare] = res.data.referralStorage.tiers.returnValues ?? [];
return {
totalRebate,
discountShare,
};
});
}
private async getReferrerDiscountShare(owner?: string): Promise<bigint | undefined> {
if (!owner) {
return undefined;
}
return this.sdk
.executeMulticall({
referralStorage: {
contractAddress: getContract(this.chainId, "ReferralStorage"),
abiId: "ReferralStorage",
calls: {
referrerDiscountShares: {
methodName: "referrerDiscountShares",
params: [owner],
},
},
},
})
.then((res) => {
return res.data.referralStorage.referrerDiscountShares.returnValues[0];
});
}
private async getUserReferralInfo(): Promise<UserReferralInfo | undefined> {
const { userReferralCode, userReferralCodeString, attachedOnChain, referralCodeForTxn } =
await this.getUserRefferalCode();
const codeOwner = await this.getCodeOwner(userReferralCodeString);
const tierId = await this.getAffiliateTier();
const { totalRebate, discountShare } = await this.getTiers(tierId);
const customDiscountShare = await this.getReferrerDiscountShare(codeOwner);
const finalDiscountShare = (customDiscountShare ?? 0n) > 0 ? customDiscountShare : discountShare;
if (
!userReferralCode ||
!userReferralCodeString ||
!codeOwner ||
tierId === undefined ||
totalRebate === undefined ||
finalDiscountShare === undefined ||
!referralCodeForTxn
) {
return undefined;
}
return {
userReferralCode,
userReferralCodeString,
referralCodeForTxn,
attachedOnChain,
affiliate: codeOwner,
tierId,
totalRebate,
totalRebateFactor: basisPointsToFloat(totalRebate),
discountShare: finalDiscountShare,
discountFactor: basisPointsToFloat(finalDiscountShare),
};
}
async getPositionsInfo(p: {
marketsInfoData: MarketsInfoData;
tokensData: TokensData;
showPnlInLeverage: boolean;
}): Promise<PositionsInfoData> {
const { showPnlInLeverage, marketsInfoData, tokensData } = p;
const { positionsData } = await this.getPositions({
marketsData: marketsInfoData,
tokensData,
});
const { minCollateralUsd } = await this.getPositionsConstants();
const uiFeeFactor = await this.getUiFeeFactorRequest();
const userReferralInfo = await this.getUserReferralInfo();
if (!positionsData || minCollateralUsd === undefined) {
return {};
}
const positionsInfoData = Object.keys(positionsData).reduce((acc: PositionsInfoData, positionKey: string) => {
const position = getByKey(positionsData, positionKey)!;
const marketInfo = getByKey(marketsInfoData, position.marketAddress);
const indexToken = marketInfo?.indexToken;
const longToken = getByKey(tokensData, marketInfo?.longTokenAddress);
const shortToken = getByKey(tokensData, marketInfo?.shortTokenAddress);
const pnlToken = position.isLong ? marketInfo?.longToken : marketInfo?.shortToken;
const collateralToken = getByKey(tokensData, position.collateralTokenAddress);
if (!marketInfo || !indexToken || !pnlToken || !collateralToken || !longToken || !shortToken) {
return acc;
}
const markPrice = getMarkPrice({ prices: indexToken.prices, isLong: position.isLong, isIncrease: false });
const collateralMinPrice = collateralToken.prices.minPrice;
const entryPrice = getEntryPrice({
sizeInTokens: position.sizeInTokens,
sizeInUsd: position.sizeInUsd,
indexToken,
});
const pendingFundingFeesUsd = convertToUsd(
position.fundingFeeAmount,
collateralToken.decimals,
collateralToken.prices.minPrice
)!;
const pendingClaimableFundingFeesLongUsd = convertToUsd(
position.claimableLongTokenAmount,
marketInfo.longToken.decimals,
marketInfo.longToken.prices.minPrice
)!;
const pendingClaimableFundingFeesShortUsd = convertToUsd(
position.claimableShortTokenAmount,
marketInfo.shortToken.decimals,
marketInfo.shortToken.prices.minPrice
)!;
const pendingClaimableFundingFeesUsd = pendingClaimableFundingFeesLongUsd + pendingClaimableFundingFeesShortUsd;
const totalPendingFeesUsd = getPositionPendingFeesUsd({
pendingBorrowingFeesUsd: position.pendingBorrowingFeesUsd,
pendingFundingFeesUsd,
});
const closingPriceImpactDeltaUsd = getPriceImpactForPosition(
marketInfo,
position.sizeInUsd * -1n,
position.isLong,
{ fallbackToZero: true }
);
const positionFeeInfo = getPositionFee(
marketInfo,
position.sizeInUsd,
closingPriceImpactDeltaUsd > 0,
userReferralInfo,
uiFeeFactor
);
const closingFeeUsd = positionFeeInfo.positionFeeUsd;
const uiFeeUsd = positionFeeInfo.uiFeeUsd ?? 0n;
const collateralUsd = convertToUsd(position.collateralAmount, collateralToken.decimals, collateralMinPrice)!;
const remainingCollateralUsd = collateralUsd - totalPendingFeesUsd;
const remainingCollateralAmount = convertToTokenAmount(
remainingCollateralUsd,
collateralToken.decimals,
collateralMinPrice
)!;
const pnl = getPositionPnlUsd({
marketInfo: marketInfo,
sizeInUsd: position.sizeInUsd,
sizeInTokens: position.sizeInTokens,
markPrice,
isLong: position.isLong,
});
const pnlPercentage =
collateralUsd !== undefined && collateralUsd != 0n ? getBasisPoints(pnl, collateralUsd) : 0n;
const netValue = getPositionNetValue({
collateralUsd: collateralUsd,
pnl,
pendingBorrowingFeesUsd: position.pendingBorrowingFeesUsd,
pendingFundingFeesUsd: pendingFundingFeesUsd,
closingFeeUsd,
uiFeeUsd,
});
const pnlAfterFees = pnl - totalPendingFeesUsd - closingFeeUsd - uiFeeUsd;
const pnlAfterFeesPercentage =
collateralUsd != 0n ? getBasisPoints(pnlAfterFees, collateralUsd + closingFeeUsd) : 0n;
const leverage = getLeverage({
sizeInUsd: position.sizeInUsd,
collateralUsd: collateralUsd,
pnl: showPnlInLeverage ? pnl : undefined,
pendingBorrowingFeesUsd: position.pendingBorrowingFeesUsd,
pendingFundingFeesUsd: pendingFundingFeesUsd,
});
const leverageWithPnl = getLeverage({
sizeInUsd: position.sizeInUsd,
collateralUsd: collateralUsd,
pnl,
pendingBorrowingFeesUsd: position.pendingBorrowingFeesUsd,
pendingFundingFeesUsd: pendingFundingFeesUsd,
});
const maxAllowedLeverage = getMaxAllowedLeverageByMinCollateralFactor(marketInfo.minCollateralFactor);
const hasLowCollateral = (leverage !== undefined && leverage > maxAllowedLeverage) || false;
const liquidationPrice = getLiquidationPrice({
marketInfo,
collateralToken,
sizeInUsd: position.sizeInUsd,
sizeInTokens: position.sizeInTokens,
collateralUsd,
collateralAmount: position.collateralAmount,
userReferralInfo,
minCollateralUsd,
pendingBorrowingFeesUsd: position.pendingBorrowingFeesUsd,
pendingFundingFeesUsd,
isLong: position.isLong,
});
const indexName = getMarketIndexName({ indexToken, isSpotOnly: false });
const poolName = getMarketPoolName({ longToken, shortToken });
acc[positionKey] = {
...position,
market: marketInfo,
marketInfo,
indexName,
poolName,
indexToken,
collateralToken,
pnlToken,
longToken,
shortToken,
markPrice,
entryPrice,
liquidationPrice,
collateralUsd,
remainingCollateralUsd,
remainingCollateralAmount,
hasLowCollateral,
leverage,
leverageWithPnl,
pnl,
pnlPercentage,
pnlAfterFees,
pnlAfterFeesPercentage,
netValue,
closingFeeUsd,
uiFeeUsd,
pendingFundingFeesUsd,
pendingClaimableFundingFeesUsd,
};
return acc;
}, {} as PositionsInfoData);
return positionsInfoData;
}
}

View File

@@ -0,0 +1,33 @@
import { describe, expect, it } from "vitest";
import { GmxSdk } from "../..";
import { arbitrumSdk, arbitrumSdkConfig } from "../../utils/testUtil.js";
describe("Tokens", () => {
it("should be able to fetch tokens", async () => {
const response = await arbitrumSdk.oracle.getTokens();
expect(response).toBeDefined();
});
it("should respect passed config", async () => {
const ARB = "0x912CE59144191C1204E64559FE8253a0e49E6548";
const sdk = new GmxSdk({
...arbitrumSdkConfig,
tokens: {
[ARB]: {
symbol: "testARB",
},
},
});
const data = await sdk.tokens.getTokensData();
expect(sdk.tokens.tokensConfig[ARB]?.symbol).toBe("testARB");
expect(data.tokensData?.[ARB].symbol).toBe("testARB");
});
it("should be able to get tokens data", async () => {
const response = await arbitrumSdk.tokens.getTokensData();
expect(response).toBeDefined();
});
});

View File

@@ -0,0 +1,178 @@
import { getContract } from "../../configs/contracts.js";
import { NATIVE_TOKEN_ADDRESS, getToken, getTokensMap, getV2Tokens, getWrappedToken } from "../../configs/tokens.js";
import { TokenBalancesData, TokenPricesData, TokensData, Token as TToken } from "../../types/tokens.js";
import { Module } from "../base.js";
import { parseContractPrice } from "../../utils/tokens.js";
import type { ContractCallsConfig } from "../../utils/multicall.js";
type TokenPricesDataResult = {
pricesData?: TokenPricesData;
updatedAt?: number;
};
type TokensDataResult = {
tokensData?: TokensData;
pricesUpdatedAt?: number;
};
export class Tokens extends Module {
_tokensConfigs: { [key: string]: TToken } | undefined = undefined;
get tokensConfig() {
if (this._tokensConfigs) {
return this._tokensConfigs;
}
const tokenConfigs = this._tokensConfigs ?? getTokensMap(this.chainId);
Object.entries(this.sdk.config.tokens ?? []).forEach(([address, token]) => {
tokenConfigs[address] = {
...tokenConfigs[address],
...token,
};
});
this._tokensConfigs = tokenConfigs;
return tokenConfigs;
}
private getTokenRecentPrices(): Promise<TokenPricesDataResult> {
return this.oracle.getTickers().then((priceItems) => {
const result: TokenPricesData = {};
priceItems.forEach((priceItem) => {
let tokenConfig: any;
try {
tokenConfig = getToken(this.chainId, priceItem.tokenAddress);
} catch (e) {
// ignore unknown token errors
return;
}
result[tokenConfig.address] = {
minPrice: parseContractPrice(BigInt(priceItem.minPrice), tokenConfig.decimals),
maxPrice: parseContractPrice(BigInt(priceItem.maxPrice), tokenConfig.decimals),
};
});
const wrappedToken = getWrappedToken(this.chainId);
if (result[wrappedToken.address] && !result[NATIVE_TOKEN_ADDRESS]) {
result[NATIVE_TOKEN_ADDRESS] = result[wrappedToken.address];
}
return {
pricesData: result,
updatedAt: Date.now(),
};
});
}
private getTokensBalances(
account?: string,
tokensList?: {
address: string;
isSynthetic?: boolean;
}[]
) {
account = account || this.sdk.config.account;
tokensList = tokensList || getV2Tokens(this.chainId);
return this.sdk
.executeMulticall(
tokensList.reduce((acc, token) => {
// Skip synthetic tokens
if (token.isSynthetic) return acc;
const address = token.address;
if (address === NATIVE_TOKEN_ADDRESS) {
acc[address] = {
contractAddress: getContract(this.chainId, "Multicall"),
abiId: "Multicall",
calls: {
balance: {
methodName: "getEthBalance",
params: [account],
},
},
} satisfies ContractCallsConfig<any>;
} else {
acc[address] = {
contractAddress: address,
abiId: "Token",
calls: {
balance: {
methodName: "balanceOf",
params: [account],
},
},
} satisfies ContractCallsConfig<any>;
}
return acc;
}, {})
)
.then((res) => {
return Object.keys(res.data).reduce((tokenBalances: TokenBalancesData, tokenAddress) => {
tokenBalances[tokenAddress] = res.data[tokenAddress].balance.returnValues[0];
return tokenBalances;
}, {} as TokenBalancesData);
});
}
getNativeToken(): TToken {
return this.tokensConfig[NATIVE_TOKEN_ADDRESS];
}
async getTokensData(): Promise<TokensDataResult> {
const tokenConfigs = this.tokensConfig;
const [apiTokens, { pricesData, updatedAt: pricesUpdatedAt }] = await Promise.all([
this.sdk.oracle.getTokens(),
this.getTokenRecentPrices(),
]);
const nativeToken = this.getNativeToken();
const tokens = [nativeToken, ...apiTokens];
const { balancesData } = this.account
? await this.getTokensBalances(this.account, tokens)
: {
balancesData: {},
};
if (!pricesData) {
return {
tokensData: undefined,
pricesUpdatedAt: undefined,
};
}
return {
tokensData: tokens.reduce((acc: TokensData, token) => {
const tokenAddress = token.address;
const prices = pricesData[tokenAddress];
const balance = balancesData?.[tokenAddress];
const tokenConfig = tokenConfigs[tokenAddress];
if (!prices) {
return acc;
}
acc[tokenAddress] = {
...token,
...tokenConfig,
prices,
balance,
};
return acc;
}, {} as TokensData),
pricesUpdatedAt,
};
}
}

Some files were not shown because too many files have changed in this diff Show More