Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: stop loss with autonomy on-chain bot #846

Open
wants to merge 71 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
c9f6599
feat: stop-loss view
unbreakablery Apr 17, 2022
d2a0805
Merge branch 'master' of github.com-unbreakablery:sushiswap/sushiswap…
unbreakablery Apr 17, 2022
fe34527
feat: integrate autonomy for stop-loss
unbreakablery Apr 18, 2022
383efbb
fix: autonomy addresses
unbreakablery Apr 18, 2022
dd46442
fix: autonomy validation
unbreakablery Apr 18, 2022
a5aa1a0
feat: add autonomy reg of avax
unbreakablery Apr 19, 2022
301aec7
fix: stop-loss by autonomy bot
unbreakablery Apr 26, 2022
bb18012
feat: update stopLimitOrder ui
unbreakablery Apr 26, 2022
bfa56b7
feat: prepareOracleData for stopPrice
unbreakablery Apr 26, 2022
c30c160
feat: implement stopLimitOrder
unbreakablery Apr 27, 2022
be92943
refactor: stopLimitOrder
unbreakablery Apr 27, 2022
63652ad
feat: update stopLimitOrderWrapper address
unbreakablery Apr 27, 2022
2b421f3
fix: avax chainlinkV2 addr
unbreakablery Apr 27, 2022
b21d5cf
fix: oracleData in stopLimitOrder
unbreakablery Apr 28, 2022
8afebfa
fix: stopLimitOrder slippage as 10%
unbreakablery Apr 28, 2022
c6699c3
fix: stopLimitOrder ui
unbreakablery Apr 28, 2022
dacd9e7
fix: stopLimitOrder ui/ux
unbreakablery Apr 28, 2022
58fc603
refactor: stopLimitOrder ui
unbreakablery May 2, 2022
a223eb2
refactor: stop-limit-order
unbreakablery May 3, 2022
b29d0fb
refactor: stop-limit-order
unbreakablery May 3, 2022
45547b3
fix: stopLimitOrderWrapper address
unbreakablery May 3, 2022
7aac349
refactor: stop loss order hooks
unbreakablery May 6, 2022
0111d99
feat: stop limit order ui popup
unbreakablery May 18, 2022
dd9df02
feat: customize stop-loss ui
unbreakablery May 19, 2022
baf0ee9
feat: fetch stop-loss-order history
unbreakablery May 20, 2022
854e95f
fix: useStopLossOrders
unbreakablery May 20, 2022
df78e9a
feat: parse stopLossOrder
unbreakablery May 20, 2022
40f9500
fix: fetch history from moralis
unbreakablery May 23, 2022
e4d7933
fix: fetch stop-loss-orders
unbreakablery May 23, 2022
5c16bd1
feat: fetch exec stop-loss-orders
unbreakablery May 24, 2022
df066e8
fix: fetching stop-loss-orders
unbreakablery May 24, 2022
19b82b6
fix: stop-loss-orders ui
unbreakablery May 25, 2022
91db9cf
fix: open orders list
unbreakablery May 25, 2022
f12a954
Merge branch 'master' of github.com-unbreakablery:sushiswap/sushiswap…
unbreakablery May 26, 2022
52011bc
feat: show open/history of stop-loss-orders
unbreakablery May 27, 2022
75fd7c5
feat: cancel stop-loss orders
unbreakablery May 30, 2022
cb5792f
feat: update stop-loss orders ui
unbreakablery May 30, 2022
2467f17
fix: env var for stop-loss
unbreakablery May 30, 2022
e17dcc2
Merge branch 'master' of github.com-unbreakablery:sushiswap/sushiswap…
unbreakablery May 31, 2022
b825dbc
Merge branch 'master' into feat/stop-loss-with-autonomy-bot
unbreakablery Jun 21, 2022
7f49911
Merge branch 'master' of github.com-unbreakablery:sushiswap/sushiswap…
unbreakablery Jul 17, 2022
e6016a3
fix: add explainer in stop-loss ui
unbreakablery Jul 18, 2022
31fa95f
Merge branch 'master' of github.com-unbreakablery:sushiswap/sushiswap…
unbreakablery Jul 28, 2022
f36a2d8
feat: add input validation in stop-loss ui
unbreakablery Aug 2, 2022
89d74ab
fix: stop-loss orders ui
unbreakablery Aug 2, 2022
38b4f81
feat: add amount validation in stop-loss ui
unbreakablery Aug 3, 2022
fb2b207
fix: margin rate validation in stop-loss order
unbreakablery Aug 4, 2022
d1e9956
refactor: stop and minimum rate validation in stop-loss
unbreakablery Aug 4, 2022
690dfd0
fix: amountExternal in stop-loss
unbreakablery Aug 5, 2022
2528a36
chore: moralis version
unbreakablery Aug 5, 2022
b1183ae
fix: moralis version
unbreakablery Aug 5, 2022
18830db
fix: stop-loss order params
unbreakablery Aug 5, 2022
613ee23
fix: stop-loss validation
unbreakablery Aug 5, 2022
0c776b2
fix: stop-loss validation
unbreakablery Aug 8, 2022
57c3bac
fix: pagination in stop-loss ui
unbreakablery Aug 8, 2022
b66d786
fix: stop-loss orders pagination
unbreakablery Aug 8, 2022
b763dd2
feat: expert mode in stop-loss
unbreakablery Aug 9, 2022
6806495
Merge branch 'master' of github.com-unbreakablery:sushiswap/sushiswap…
unbreakablery Aug 9, 2022
3dda0ca
fix: stop loss ui
unbreakablery Aug 11, 2022
c2ba3a0
Merge branch 'master' of github.com-unbreakablery:sushiswap/sushiswap…
unbreakablery Aug 11, 2022
5ef81cc
fix: stop-loss zero-division issue
unbreakablery Aug 11, 2022
eb96493
feat: add more validation in stop-loss ui
unbreakablery Aug 12, 2022
a468b7e
fix: stop-loss overflow
unbreakablery Aug 12, 2022
c3523fa
Merge branch 'master' of github.com-unbreakablery:sushiswap/sushiswap…
unbreakablery Aug 16, 2022
74eeb94
fix: dependency of moralis
unbreakablery Aug 16, 2022
a77beb3
fix: moralis version
unbreakablery Aug 16, 2022
32ccf13
Merge branch 'master' of github.com-unbreakablery:sushiswap/sushiswap…
unbreakablery Aug 22, 2022
f28b4ca
fix: npm dependency
unbreakablery Sep 8, 2022
8169b73
fix: trade nav header
unbreakablery Sep 9, 2022
62c7c78
feat: add more stopLimitOrder wrapper
unbreakablery Sep 13, 2022
ed0b5f4
Merge branch 'master' of github.com-unbreakablery:sushiswap/sushiswap…
unbreakablery Oct 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,5 +247,9 @@
"entrypoints": [
"src/pages"
]
},
"dependencies": {
"@sushiswap/default-token-list": "^28.0.0",
"moralis": "^1.7.0"
}
}
2 changes: 1 addition & 1 deletion sentry.client.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The config you add here will be used whenever a page is visited.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from '@sentry/nextjs';
import * as Sentry from '@sentry/nextjs'

const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN

Expand Down
2 changes: 1 addition & 1 deletion sentry.server.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ Sentry.init({
// Note: if you want to override the automatic release value, do not set a
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
// that it will also get attached to your source maps
})
})
12 changes: 12 additions & 0 deletions src/components/Header/useMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ const useMenu: UseMenu = () => {
link: '/limit-order',
disabled: !featureEnabled(Feature.LIMIT_ORDERS, chainId),
},
{
key: 'stop',
title: i18n._(t`Stop loss`),
link: '/stop-loss',
disabled: !featureEnabled(Feature.STOP_LOSSES, chainId),
},
]

const liquidity = [
Expand Down Expand Up @@ -95,6 +101,12 @@ const useMenu: UseMenu = () => {
link: '/limit-order',
disabled: !featureEnabled(Feature.LIMIT_ORDERS, chainId),
},
{
key: 'stop',
title: i18n._(t`Stop loss`),
link: '/stop-loss',
disabled: !featureEnabled(Feature.STOP_LOSSES, chainId),
},
].filter((item) => !item.disabled),
})

Expand Down
4 changes: 4 additions & 0 deletions src/config/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const features: FeatureMap = {
Feature.INARI,
Feature.VESTING,
Feature.LIMIT_ORDERS,
Feature.STOP_LOSSES,
Feature.SUSHIGUARD,
],
[ChainId.ROPSTEN]: [Feature.AMM, Feature.LIQUIDITY_MINING, Feature.BENTOBOX, Feature.KASHI, Feature.MISO],
Expand All @@ -36,6 +37,7 @@ const features: FeatureMap = {
Feature.AMM,
Feature.ANALYTICS,
Feature.LIMIT_ORDERS,
Feature.STOP_LOSSES,
Feature.LIQUIDITY_MINING,
Feature.ANALYTICS,
Feature.BENTOBOX,
Expand All @@ -51,6 +53,7 @@ const features: FeatureMap = {
Feature.MIGRATE,
Feature.ANALYTICS,
Feature.LIMIT_ORDERS,
Feature.STOP_LOSSES,
Feature.TRIDENT,
Feature.TRIDENT_MIGRATION,
Feature.MISO,
Expand All @@ -63,6 +66,7 @@ const features: FeatureMap = {
Feature.BENTOBOX,
Feature.KASHI,
Feature.LIMIT_ORDERS,
Feature.STOP_LOSSES,
Feature.ANALYTICS,
Feature.MISO,
Feature.MIGRATE,
Expand Down
1 change: 1 addition & 0 deletions src/constants/abis/autonomy/registry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"contract IStakeManager","name":"stakeMan","type":"address"},{"internalType":"contract IOracle","name":"oracle","type":"address"},{"internalType":"contract IForwarder","name":"userForwarder","type":"address"},{"internalType":"contract IForwarder","name":"gasForwarder","type":"address"},{"internalType":"contract IForwarder","name":"userGasForwarder","type":"address"},{"internalType":"string","name":"tokenName","type":"string"},{"internalType":"string","name":"tokenSymbol","type":"string"},{"internalType":"uint256","name":"totalAUTOSupply","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"address payable","name":"referer","type":"address"},{"indexed":false,"internalType":"bytes","name":"callData","type":"bytes"},{"indexed":false,"internalType":"uint112","name":"initEthSent","type":"uint112"},{"indexed":false,"internalType":"uint112","name":"ethForCall","type":"uint112"},{"indexed":false,"internalType":"bool","name":"verifyUser","type":"bool"},{"indexed":false,"internalType":"bool","name":"insertFeeAmount","type":"bool"},{"indexed":false,"internalType":"bool","name":"payWithAUTO","type":"bool"},{"indexed":false,"internalType":"bool","name":"isAlive","type":"bool"}],"name":"HashedReqAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"HashedReqCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"bool","name":"wasRemoved","type":"bool"}],"name":"HashedReqExecuted","type":"event"},{"inputs":[],"name":"BASE_BPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GAS_OVERHEAD_AUTO","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GAS_OVERHEAD_ETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAY_AUTO_BPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAY_ETH_BPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"components":[{"internalType":"address payable","name":"user","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"address payable","name":"referer","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"uint112","name":"initEthSent","type":"uint112"},{"internalType":"uint112","name":"ethForCall","type":"uint112"},{"internalType":"bool","name":"verifyUser","type":"bool"},{"internalType":"bool","name":"insertFeeAmount","type":"bool"},{"internalType":"bool","name":"payWithAUTO","type":"bool"},{"internalType":"bool","name":"isAlive","type":"bool"}],"internalType":"struct IRegistry.Request","name":"r","type":"tuple"}],"name":"cancelHashedReq","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"components":[{"internalType":"address payable","name":"user","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"address payable","name":"referer","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"uint112","name":"initEthSent","type":"uint112"},{"internalType":"uint112","name":"ethForCall","type":"uint112"},{"internalType":"bool","name":"verifyUser","type":"bool"},{"internalType":"bool","name":"insertFeeAmount","type":"bool"},{"internalType":"bool","name":"payWithAUTO","type":"bool"},{"internalType":"bool","name":"isAlive","type":"bool"}],"internalType":"struct IRegistry.Request","name":"r","type":"tuple"},{"internalType":"uint256","name":"expectedGas","type":"uint256"}],"name":"executeHashedReq","outputs":[{"internalType":"uint256","name":"gasUsed","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAUTOAddr","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getExecCountOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGasForwarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getHashedReq","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getHashedReqs","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getHashedReqsLen","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"startIdx","type":"uint256"},{"internalType":"uint256","name":"endIdx","type":"uint256"}],"name":"getHashedReqsSlice","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getReferalCountOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address payable","name":"user","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"address payable","name":"referer","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"uint112","name":"initEthSent","type":"uint112"},{"internalType":"uint112","name":"ethForCall","type":"uint112"},{"internalType":"bool","name":"verifyUser","type":"bool"},{"internalType":"bool","name":"insertFeeAmount","type":"bool"},{"internalType":"bool","name":"payWithAUTO","type":"bool"},{"internalType":"bool","name":"isAlive","type":"bool"}],"internalType":"struct IRegistry.Request","name":"r","type":"tuple"}],"name":"getReqBytes","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getReqCountOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStakeManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUserForwarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUserGasForwarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"uint256","name":"expectedGas","type":"uint256"},{"internalType":"uint256","name":"startIdx","type":"uint256"}],"name":"insertToCallData","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"address payable","name":"referer","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"uint112","name":"ethForCall","type":"uint112"},{"internalType":"bool","name":"verifyUser","type":"bool"},{"internalType":"bool","name":"insertFeeAmount","type":"bool"},{"internalType":"bool","name":"isAlive","type":"bool"}],"name":"newReq","outputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"address payable","name":"referer","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"uint112","name":"ethForCall","type":"uint112"},{"internalType":"bool","name":"verifyUser","type":"bool"},{"internalType":"bool","name":"insertFeeAmount","type":"bool"},{"internalType":"bool","name":"payWithAUTO","type":"bool"},{"internalType":"bool","name":"isAlive","type":"bool"}],"name":"newReqPaySpecific","outputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]
1 change: 1 addition & 0 deletions src/constants/abis/autonomy/stop-limit-order-wrapper.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"address payable","name":"registry_","type":"address"},{"internalType":"address","name":"gasFeeForwarder_","type":"address"},{"internalType":"address","name":"bentoBox_","type":"address"},{"internalType":"address","name":"stopLimitOrderContract_","type":"address"},{"internalType":"address","name":"WETH_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bentoBox","outputs":[{"internalType":"contract IBentoBoxV1","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"stopPrice","type":"uint256"},{"internalType":"contract IOracle","name":"oracleAddress","type":"address"},{"internalType":"bytes","name":"oracleData","type":"bytes"},{"internalType":"uint256","name":"amountToFill","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct OrderArgs","name":"order","type":"tuple"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"fillOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"gasFeeForwarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registry","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stopLimitOrderContract","outputs":[{"internalType":"contract IStopLimitOrder","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
33 changes: 33 additions & 0 deletions src/constants/autonomy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { AddressMap, ChainId } from '@sushiswap/core-sdk'

export const QUERY_REQUEST_LIMIT = 10000

export const AUTONOMY_REGISTRY_ADDRESSES: AddressMap = {
[ChainId.BSC]: '0x18d087F8D22D409D3CD366AF00BD7AeF0BF225Db',
[ChainId.AVALANCHE]: '0x68FCbECa74A7E5D386f74E14682c94DE0e1bC56b',
}

export const STOP_LIMIT_ORDER_WRAPPER_ADDRESSES: AddressMap = {
[ChainId.AVALANCHE]: '0x2f57dabe3dd1ecAed3F79a0D6d2530fCa5A11912',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the wrapper address is only set for avalanche, why is the feature enabled on avalance, bsc, fantom and ethereum? How does this work

Copy link
Author

@unbreakablery unbreakablery Jul 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we would like to deploy wrapper contract in other networks also.

}

export const CHAINLINK_ORACLE_ADDRESS: AddressMap = {
[ChainId.BSC]: '0x00632CFe43d8F9f8E6cD0d39Ffa3D4fa7ec73CFB',
[ChainId.AVALANCHE]: '0x232d595594585613F48aaE9c85861E4aB06CE3E5',
}

interface MoralisInfo {
serverURL: string
key: string
}

export const MORALIS_INFO: { [chainId: number]: MoralisInfo } = {
[ChainId.AVALANCHE]: {
serverURL: process.env.NEXT_PUBLIC_AUTONOMY_MORALIS_URL_AVAX || '',
key: process.env.NEXT_PUBLIC_AUTONOMY_MORALIS_KEY_AVAX || '',
},
[ChainId.BSC]: {
serverURL: process.env.NEXT_PUBLIC_AUTONOMY_MORALIS_URL_BSC || '',
key: process.env.NEXT_PUBLIC_AUTONOMY_MORALIS_KEY_BSC || '',
},
}
1 change: 1 addition & 0 deletions src/enums/Feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export enum Feature {
TRIDENT = 'Trident',
TRIDENT_MIGRATION = 'Trident Migration',
LIMIT_ORDERS = 'LimitOrders',
STOP_LOSSES = 'StopLosses',
INARI = 'Inari',
MEOWSHI = 'MEOWSHI',
VESTING = 'Vesting',
Expand Down
118 changes: 118 additions & 0 deletions src/features/stop-loss/CompletedOrders.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { t } from '@lingui/macro'
import { useLingui } from '@lingui/react'
import Typography from 'app/components/Typography'
import { useCompletedOrdersTableConfig } from 'app/features/stop-loss/useCompletedOrdersTableConfig'
import {
TABLE_TABLE_CLASSNAME,
TABLE_TBODY_TD_CLASSNAME,
TABLE_TBODY_TR_CLASSNAME,
TABLE_TR_TH_CLASSNAME,
TABLE_WRAPPER_DIV_CLASSNAME,
} from 'app/features/trident/constants'
import { classNames } from 'app/functions'
import { useActiveWeb3React } from 'app/services/web3'
import Link from 'next/link'
import React, { FC } from 'react'
import { useFlexLayout, usePagination, useSortBy, useTable } from 'react-table'

import useStopLossOrders from './useStopLossOrders'

const CompletedOrders: FC = () => {
const { i18n } = useLingui()
const { account } = useActiveWeb3React()
const { loading, completed } = useStopLossOrders()
const { config } = useCompletedOrdersTableConfig({ orders: completed })

// @ts-ignore TYPE NEEDS FIXING
const { getTableProps, getTableBodyProps, headerGroups, prepareRow, page } = useTable(
// @ts-ignore TYPE NEEDS FIXING
config,
useSortBy,
usePagination,
useFlexLayout
)

return (
<div className="flex flex-col gap-3">
<div className={TABLE_WRAPPER_DIV_CLASSNAME}>
<table id="asset-balances-table" {...getTableProps()} className={TABLE_TABLE_CLASSNAME}>
<thead>
{headerGroups.map((headerGroup, i) => (
<tr {...headerGroup.getHeaderGroupProps()} key={i}>
{headerGroup.headers.map((column, i) => (
<th
// @ts-ignore TYPE NEEDS FIXING
{...column.getHeaderProps(column.getSortByToggleProps())}
key={i}
className={TABLE_TR_TH_CLASSNAME(i, headerGroup.headers.length)}
>
{column.render('Header')}
</th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
{page.length > 0 ? (
// @ts-ignore TYPE NEEDS FIXING
page.map((row, i) => {
prepareRow(row)
return (
<tr {...row.getRowProps()} key={i} className={TABLE_TBODY_TR_CLASSNAME}>
{/*@ts-ignore TYPE NEEDS FIXING*/}
{row.cells.map((cell, i) => {
return (
<td
key={i}
{...cell.getCellProps()}
className={classNames(
TABLE_TBODY_TD_CLASSNAME(i, row.cells.length),
'cursor-default whitespace-nowrap'
)}
>
{cell.render('Cell')}
</td>
)
})}
</tr>
)
})
) : (
<tr className={TABLE_TBODY_TR_CLASSNAME}>
<td colSpan={4} className={classNames(TABLE_TBODY_TD_CLASSNAME(0, 1), 'justify-center cursor-default')}>
<Typography
variant="xs"
className="text-center text-low-emphesis h-[60px] flex items-center justify-center"
component="span"
>
{loading ? i18n._(t`Loading executed orders...`) : i18n._(t`No order history`)}
</Typography>
</td>
</tr>
)}
</tbody>
<tfoot>
<tr className={classNames(TABLE_TBODY_TR_CLASSNAME)}>
<td
colSpan={4}
className={classNames(TABLE_TBODY_TD_CLASSNAME(0, 1), 'justify-center cursor-default py-4')}
>
<Typography variant="xs" className="italic text-center text-low-emphesis">
Funds will be received in your{' '}
<Link href={`/account/${account}`} passHref={true}>
<Typography variant="xs" className="text-blue" component="span">
BentoBox
</Typography>
</Link>{' '}
after order execution
</Typography>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
)
}

export default CompletedOrders
Loading