Compare commits
20
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
234f3f2c93 | ||
|
|
086bb4d10a | ||
|
|
ae8631bf2c | ||
|
|
4a044da38f | ||
|
|
fbbfbc6580 | ||
|
|
2714c2b084 | ||
|
|
9979bc8a16 | ||
|
|
a958a59ea2 | ||
|
|
2bf9e66da5 | ||
|
|
2980144e40 | ||
|
|
5387fe8632 | ||
|
|
1132ea3bbd | ||
|
|
9188e08a4f | ||
|
|
941ef7f9dd | ||
|
|
b1ffa2e219 | ||
|
|
91ea68dc53 | ||
|
|
cf79528d05 | ||
|
|
ef81f9da57 | ||
|
|
60d59cd211 | ||
|
|
19d38378f3 |
+3
-3
@@ -39,9 +39,9 @@
|
||||
"@cosmjs/proto-signing": "^0.31.0",
|
||||
"@cosmjs/stargate": "^0.31.0",
|
||||
"@cosmjs/tendermint-rpc": "^0.31.0",
|
||||
"@dydxprotocol/v4-abacus": "^1.0.30",
|
||||
"@dydxprotocol/v4-client-js": "^1.0.0",
|
||||
"@dydxprotocol/v4-localization": "^1.0.8",
|
||||
"@dydxprotocol/v4-abacus": "^1.1.22",
|
||||
"@dydxprotocol/v4-client-js": "^1.0.11",
|
||||
"@dydxprotocol/v4-localization": "^1.0.18",
|
||||
"@ethersproject/providers": "^5.7.2",
|
||||
"@js-joda/core": "^5.5.3",
|
||||
"@radix-ui/react-checkbox": "^1.0.4",
|
||||
|
||||
Generated
+30
-17
@@ -1,5 +1,9 @@
|
||||
lockfileVersion: '6.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
dependencies:
|
||||
'@0xsquid/sdk':
|
||||
specifier: ^1.10.0
|
||||
@@ -23,14 +27,14 @@ dependencies:
|
||||
specifier: ^0.31.0
|
||||
version: 0.31.0
|
||||
'@dydxprotocol/v4-abacus':
|
||||
specifier: ^1.0.30
|
||||
version: 1.0.30
|
||||
specifier: ^1.1.22
|
||||
version: 1.1.22
|
||||
'@dydxprotocol/v4-client-js':
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
specifier: ^1.0.11
|
||||
version: 1.0.11
|
||||
'@dydxprotocol/v4-localization':
|
||||
specifier: ^1.0.8
|
||||
version: 1.0.8
|
||||
specifier: ^1.0.18
|
||||
version: 1.0.18
|
||||
'@ethersproject/providers':
|
||||
specifier: ^5.7.2
|
||||
version: 5.7.2
|
||||
@@ -984,12 +988,12 @@ packages:
|
||||
resolution: {integrity: sha512-RpfLEtTlyIxeNPGKcokS+p3BZII/Q3bYxryFRglh5H3A3T8q9fsLYm72VYAMEOOIBLEa8o93kFLiBDUWKrwXZA==}
|
||||
dev: true
|
||||
|
||||
/@dydxprotocol/v4-abacus@1.0.30:
|
||||
resolution: {integrity: sha512-zzJzNzMR3Stwv1Mu0XGUNlyo1V/ywo3yi3QSzE4mzUtXB+p5Shj5hRQCcwhHcNjLgp6a+T0BcRjBPa4QMETmwg==}
|
||||
/@dydxprotocol/v4-abacus@1.1.22:
|
||||
resolution: {integrity: sha512-txinqnKGblCEcn1FjMj5nW9Tv2446fbkRaquodwQSk0GTP92/78xl4VSOwMngc0f4heiVGbirlCKyHmtZUADmA==}
|
||||
dev: false
|
||||
|
||||
/@dydxprotocol/v4-client-js@1.0.0:
|
||||
resolution: {integrity: sha512-ehfHO+zQy795TcJRwtiawadFHZyh4HnpJNP26hCGsIjLE5q6LLHweQHpK/1N/sXU1PBOuQwc7iaJnFop6gYauQ==}
|
||||
/@dydxprotocol/v4-client-js@1.0.11:
|
||||
resolution: {integrity: sha512-rJNFGTO+HU1GQppXeRLKXNk4HWx/h+DjU2sUCieEv5mnRIMQpLw8dH/L+Uyhxx2oovccY1MaKB4Fr9IngdrF0A==}
|
||||
dependencies:
|
||||
'@cosmjs/amino': 0.30.1
|
||||
'@cosmjs/encoding': 0.31.1
|
||||
@@ -1009,15 +1013,15 @@ packages:
|
||||
ethers: 6.6.1
|
||||
long: 4.0.0
|
||||
protobufjs: 6.11.4
|
||||
ws: 8.13.0(bufferutil@4.0.7)(utf-8-validate@5.0.10)
|
||||
ws: 8.15.0
|
||||
transitivePeerDependencies:
|
||||
- bufferutil
|
||||
- debug
|
||||
- utf-8-validate
|
||||
dev: false
|
||||
|
||||
/@dydxprotocol/v4-localization@1.0.8:
|
||||
resolution: {integrity: sha512-h5CSkWHPct1BWmiwJBeX9vOauXSwlx8RK9ryOsaCipJWS4AnBni07p3/jj3L/HgmU1BZXwfcr2hBouXVxxZS8A==}
|
||||
/@dydxprotocol/v4-localization@1.0.18:
|
||||
resolution: {integrity: sha512-790ajXfGzqRs7JVA3vISCg0Vh4EEN7SlcI8u04iryPcBp1WwkQ5TFGllF32+YPs1+mgjMRhwrg6jP8zEGMQFyw==}
|
||||
dev: false
|
||||
|
||||
/@dydxprotocol/v4-proto@0.4.1:
|
||||
@@ -14033,6 +14037,19 @@ packages:
|
||||
utf-8-validate: 5.0.10
|
||||
dev: false
|
||||
|
||||
/ws@8.15.0:
|
||||
resolution: {integrity: sha512-H/Z3H55mrcrgjFwI+5jKavgXvwQLtfPCUEp6pi35VhoB0pfcHnSoyuTzkBEZpzq49g1193CUEwIvmsjcotenYw==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
peerDependencies:
|
||||
bufferutil: ^4.0.1
|
||||
utf-8-validate: '>=5.0.2'
|
||||
peerDependenciesMeta:
|
||||
bufferutil:
|
||||
optional: true
|
||||
utf-8-validate:
|
||||
optional: true
|
||||
dev: false
|
||||
|
||||
/ws@8.5.0:
|
||||
resolution: {integrity: sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
@@ -14136,7 +14153,3 @@ packages:
|
||||
/zwitch@2.0.4:
|
||||
resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
|
||||
dev: true
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[
|
||||
{
|
||||
"chainId": "42161",
|
||||
"tokenAddress": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
||||
"tokenAddress": "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
|
||||
"name": "Arbitrum"
|
||||
},
|
||||
{
|
||||
@@ -11,7 +11,7 @@
|
||||
},
|
||||
{
|
||||
"chainId": "8453",
|
||||
"tokenAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
||||
"tokenAddress": "0x66627F389ae46D881773B7131139b2411980E09E",
|
||||
"name": "Base"
|
||||
},
|
||||
{
|
||||
@@ -21,7 +21,7 @@
|
||||
},
|
||||
{
|
||||
"chainId": "10",
|
||||
"tokenAddress": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
||||
"tokenAddress": "0x7F5c764cBc14f9669B88837ca1490cCa17c31607",
|
||||
"name": "OP Mainnet"
|
||||
},
|
||||
{
|
||||
|
||||
+38
-22
@@ -42,7 +42,7 @@
|
||||
"ethereumChainId": "5",
|
||||
"dydxChainId": "dydxprotocol-testnet",
|
||||
"chainName": "dYdX Chain",
|
||||
"chainLogo": "dydx-chain.png",
|
||||
"chainLogo": "/dydx-chain.png",
|
||||
"squidIntegratorId": "dYdX-api",
|
||||
"isMainNet": false,
|
||||
"tokens": {
|
||||
@@ -71,6 +71,7 @@
|
||||
"https://validator.v4dev.dydx.exchange"
|
||||
],
|
||||
"0xsquid": "https://testnet.api.0xsquid.com",
|
||||
"nobleValidator": "https://rpc.testnet.noble.strange.love",
|
||||
"faucet": "https://faucet.v4dev.dydx.exchange"
|
||||
},
|
||||
"links": {
|
||||
@@ -115,7 +116,7 @@
|
||||
"ethereumChainId": "5",
|
||||
"dydxChainId": "dydxprotocol-testnet",
|
||||
"chainName": "dYdX Chain",
|
||||
"chainLogo": "dydx-chain.png",
|
||||
"chainLogo": "/dydx-chain.png",
|
||||
"squidIntegratorId": "dYdX-api",
|
||||
"isMainNet": false,
|
||||
"tokens": {
|
||||
@@ -143,7 +144,8 @@
|
||||
"validators": [
|
||||
"http://54.92.118.111"
|
||||
],
|
||||
"0xsquid": "https://testnet.api.0xsquid.com"
|
||||
"0xsquid": "https://testnet.api.0xsquid.com",
|
||||
"nobleValidator": "https://rpc.testnet.noble.strange.love"
|
||||
},
|
||||
"links": {
|
||||
"tos": "https://dydx.exchange/v4-terms",
|
||||
@@ -187,7 +189,7 @@
|
||||
"ethereumChainId": "5",
|
||||
"dydxChainId": "dydxprotocol-testnet",
|
||||
"chainName": "dYdX Chain",
|
||||
"chainLogo": "dydx-chain.png",
|
||||
"chainLogo": "/dydx-chain.png",
|
||||
"squidIntegratorId": "dYdX-api",
|
||||
"isMainNet": false,
|
||||
"tokens": {
|
||||
@@ -215,7 +217,8 @@
|
||||
"validators": [
|
||||
"http://validator.v4dev4.dydx.exchange"
|
||||
],
|
||||
"0xsquid": "https://testnet.api.0xsquid.com"
|
||||
"0xsquid": "https://testnet.api.0xsquid.com",
|
||||
"nobleValidator": "https://rpc.testnet.noble.strange.love"
|
||||
},
|
||||
"links": {
|
||||
"tos": "https://dydx.exchange/v4-terms",
|
||||
@@ -259,7 +262,7 @@
|
||||
"ethereumChainId": "5",
|
||||
"dydxChainId": "dydxprotocol-testnet",
|
||||
"chainName": "dYdX Chain",
|
||||
"chainLogo": "dydx-chain.png",
|
||||
"chainLogo": "/dydx-chain.png",
|
||||
"squidIntegratorId": "dYdX-api",
|
||||
"isMainNet": false,
|
||||
"tokens": {
|
||||
@@ -287,7 +290,8 @@
|
||||
"validators": [
|
||||
"http://18.223.78.50"
|
||||
],
|
||||
"0xsquid": "https://testnet.api.0xsquid.com"
|
||||
"0xsquid": "https://testnet.api.0xsquid.com",
|
||||
"nobleValidator": "https://rpc.testnet.noble.strange.love"
|
||||
},
|
||||
"links": {
|
||||
"tos": "https://dydx.exchange/v4-terms",
|
||||
@@ -331,7 +335,7 @@
|
||||
"ethereumChainId": "5",
|
||||
"dydxChainId": "dydxprotocol-testnet",
|
||||
"chainName": "dYdX Chain",
|
||||
"chainLogo": "dydx-chain.png",
|
||||
"chainLogo": "/dydx-chain.png",
|
||||
"squidIntegratorId": "dYdX-api",
|
||||
"isMainNet": false,
|
||||
"tokens": {
|
||||
@@ -360,7 +364,8 @@
|
||||
"validators": [
|
||||
"https://validator.v4staging.dydx.exchange"
|
||||
],
|
||||
"0xsquid": "https://testnet.api.squidrouter.com"
|
||||
"0xsquid": "https://testnet.api.squidrouter.com",
|
||||
"nobleValidator": "https://rpc.testnet.noble.strange.love"
|
||||
},
|
||||
"links": {
|
||||
"tos": "https://dydx.exchange/v4-terms",
|
||||
@@ -405,7 +410,8 @@
|
||||
"ethereumChainId": "5",
|
||||
"dydxChainId": "dydxprotocol-testnet",
|
||||
"chainName": "dYdX Chain",
|
||||
"chainLogo": "dydx-chain.png",
|
||||
"chainLogo": "/dydx-chain.png",
|
||||
"squidIntegratorId": "dYdX-api",
|
||||
"isMainNet": false,
|
||||
"tokens": {
|
||||
"chain": {
|
||||
@@ -433,7 +439,8 @@
|
||||
"validators": [
|
||||
"https://validator.v4staging.dydx.exchange"
|
||||
],
|
||||
"0xsquid": "https://testnet.api.squidrouter.com"
|
||||
"0xsquid": "https://testnet.api.squidrouter.com",
|
||||
"nobleValidator": "https://rpc.testnet.noble.strange.love"
|
||||
},
|
||||
"links": {
|
||||
"tos": "https://dydx.exchange/v4-terms",
|
||||
@@ -476,7 +483,7 @@
|
||||
"ethereumChainId": "5",
|
||||
"dydxChainId": "dydxprotocol-testnet",
|
||||
"chainName": "dYdX Chain",
|
||||
"chainLogo": "dydx-chain.png",
|
||||
"chainLogo": "/dydx-chain.png",
|
||||
"squidIntegratorId": "dYdX-api",
|
||||
"isMainNet": false,
|
||||
"tokens": {
|
||||
@@ -505,7 +512,8 @@
|
||||
"validators": [
|
||||
"https://validator-uswest1.v4staging.dydx.exchange"
|
||||
],
|
||||
"0xsquid": "https://testnet.api.squidrouter.com"
|
||||
"0xsquid": "https://testnet.api.squidrouter.com",
|
||||
"nobleValidator": "https://rpc.testnet.noble.strange.love"
|
||||
},
|
||||
"links": {
|
||||
"tos": "https://dydx.exchange/v4-terms",
|
||||
@@ -550,7 +558,7 @@
|
||||
"ethereumChainId": "5",
|
||||
"dydxChainId": "dydx-testnet-4",
|
||||
"chainName": "dYdX Chain",
|
||||
"chainLogo": "dydx-chain.png",
|
||||
"chainLogo": "/dydx-chain.png",
|
||||
"squidIntegratorId": "dYdX-api",
|
||||
"isMainNet": false,
|
||||
"tokens": {
|
||||
@@ -583,6 +591,7 @@
|
||||
"https://dydx-rpc.liquify.com/api=8878132/dydx"
|
||||
],
|
||||
"0xsquid": "https://testnet.api.squidrouter.com",
|
||||
"nobleValidator": "https://rpc.testnet.noble.strange.love",
|
||||
"faucet": "https://faucet.v4testnet.dydx.exchange"
|
||||
},
|
||||
"links": {
|
||||
@@ -628,7 +637,7 @@
|
||||
"ethereumChainId": "5",
|
||||
"dydxChainId": "dydx-testnet-4",
|
||||
"chainName": "dYdX Chain",
|
||||
"chainLogo": "dydx-chain.png",
|
||||
"chainLogo": "/dydx-chain.png",
|
||||
"squidIntegratorId": "dYdX-api",
|
||||
"isMainNet": false,
|
||||
"tokens": {
|
||||
@@ -657,6 +666,7 @@
|
||||
"https://validator.v4testnet.dydx.exchange"
|
||||
],
|
||||
"0xsquid": "https://testnet.api.squidrouter.com",
|
||||
"nobleValidator": "https://rpc.testnet.noble.strange.love",
|
||||
"faucet": "https://faucet.v4testnet.dydx.exchange"
|
||||
},
|
||||
"links": {
|
||||
@@ -703,7 +713,7 @@
|
||||
"ethereumChainId": "5",
|
||||
"dydxChainId": "dydx-testnet-4",
|
||||
"chainName": "dYdX Chain",
|
||||
"chainLogo": "dydx-chain.png",
|
||||
"chainLogo": "/dydx-chain.png",
|
||||
"squidIntegratorId": "dYdX-api",
|
||||
"isMainNet": false,
|
||||
"tokens": {
|
||||
@@ -732,6 +742,7 @@
|
||||
"https://dydx-testnet.nodefleet.org"
|
||||
],
|
||||
"0xsquid": "https://testnet.api.squidrouter.com",
|
||||
"nobleValidator": "https://rpc.testnet.noble.strange.love",
|
||||
"faucet": "https://faucet.v4testnet.dydx.exchange"
|
||||
},
|
||||
"links": {
|
||||
@@ -778,7 +789,7 @@
|
||||
"ethereumChainId": "5",
|
||||
"dydxChainId": "dydx-testnet-4",
|
||||
"chainName": "dYdX Chain",
|
||||
"chainLogo": "dydx-chain.png",
|
||||
"chainLogo": "/dydx-chain.png",
|
||||
"squidIntegratorId": "dYdX-api",
|
||||
"isMainNet": false,
|
||||
"tokens": {
|
||||
@@ -807,6 +818,7 @@
|
||||
"https://test-dydx.kingnodes.com"
|
||||
],
|
||||
"0xsquid": "https://testnet.api.squidrouter.com",
|
||||
"nobleValidator": "https://rpc.testnet.noble.strange.love",
|
||||
"faucet": "https://faucet.v4testnet.dydx.exchange"
|
||||
},
|
||||
"links": {
|
||||
@@ -853,7 +865,7 @@
|
||||
"ethereumChainId": "5",
|
||||
"dydxChainId": "dydx-testnet-4",
|
||||
"chainName": "dYdX Chain",
|
||||
"chainLogo": "dydx-chain.png",
|
||||
"chainLogo": "/dydx-chain.png",
|
||||
"squidIntegratorId": "dYdX-api",
|
||||
"isMainNet": false,
|
||||
"tokens": {
|
||||
@@ -882,6 +894,7 @@
|
||||
"https://dydx-rpc.liquify.com/api=8878132/dydx"
|
||||
],
|
||||
"0xsquid": "https://testnet.api.squidrouter.com",
|
||||
"nobleValidator": "https://rpc.testnet.noble.strange.love",
|
||||
"faucet": "https://faucet.v4testnet.dydx.exchange"
|
||||
},
|
||||
"links": {
|
||||
@@ -928,7 +941,7 @@
|
||||
"ethereumChainId": "5",
|
||||
"dydxChainId": "dydx-testnet-4",
|
||||
"chainName": "dYdX Chain",
|
||||
"chainLogo": "dydx-chain.png",
|
||||
"chainLogo": "/dydx-chain.png",
|
||||
"squidIntegratorId": "dYdX-api",
|
||||
"isMainNet": false,
|
||||
"tokens": {
|
||||
@@ -957,6 +970,7 @@
|
||||
"https://dydx-testnet-rpc.polkachu.com/"
|
||||
],
|
||||
"0xsquid": "https://testnet.api.squidrouter.com",
|
||||
"nobleValidator": "https://rpc.testnet.noble.strange.love",
|
||||
"faucet": "https://faucet.v4testnet.dydx.exchange"
|
||||
},
|
||||
"links": {
|
||||
@@ -994,7 +1008,7 @@
|
||||
"ethereumChainId": "5",
|
||||
"dydxChainId": "dydx-testnet-4",
|
||||
"chainName": "dYdX Chain",
|
||||
"chainLogo": "dydx-chain.png",
|
||||
"chainLogo": "/dydx-chain.png",
|
||||
"squidIntegratorId": "dYdX-api",
|
||||
"isMainNet": false,
|
||||
"tokens": {
|
||||
@@ -1023,6 +1037,7 @@
|
||||
"https://dydx-testnet-full-rpc.public.blastapi.io/"
|
||||
],
|
||||
"0xsquid": "https://testnet.api.squidrouter.com",
|
||||
"nobleValidator": "https://rpc.testnet.noble.strange.love",
|
||||
"faucet": "https://faucet.v4testnet.dydx.exchange"
|
||||
},
|
||||
"links": {
|
||||
@@ -1069,7 +1084,7 @@
|
||||
"ethereumChainId": "1",
|
||||
"dydxChainId": "[mainnet chain id]",
|
||||
"chainName": "dYdX Chain",
|
||||
"chainLogo": "dydx-chain.png",
|
||||
"chainLogo": "/dydx-chain.png",
|
||||
"squidIntegratorId": "[mainnet squid integrator id]",
|
||||
"isMainNet": true,
|
||||
"tokens": {
|
||||
@@ -1099,7 +1114,8 @@
|
||||
"[Validator endpoint 1",
|
||||
"[Validator endpoint n]"
|
||||
],
|
||||
"0xsquid": "[0xSquid endpoint for mainnet]"
|
||||
"0xsquid": "[0xSquid endpoint for mainnet]",
|
||||
"nobleValidator": "[noble validator endpoint for mainnet]"
|
||||
},
|
||||
"links": {
|
||||
"tos": "[HTTP link to TOS]",
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 300 KiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 9.6 KiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 481 KiB |
@@ -22,8 +22,6 @@ import { NotificationsProvider } from '@/hooks/useNotifications';
|
||||
import { LocalNotificationsProvider } from '@/hooks/useLocalNotifications';
|
||||
import { RestrictionProvider } from '@/hooks/useRestrictions';
|
||||
import { SubaccountProvider } from '@/hooks/useSubaccount';
|
||||
import { SquidProvider } from '@/hooks/useSquid';
|
||||
import { TestFlagsProvider } from '@/hooks/useTestFlags';
|
||||
|
||||
import { GuardedMobileRoute } from '@/components/GuardedMobileRoute';
|
||||
|
||||
@@ -124,13 +122,11 @@ const providers = [
|
||||
wrapProvider(QueryClientProvider, { client: queryClient }),
|
||||
wrapProvider(GrazProvider),
|
||||
wrapProvider(WagmiConfig, { config }),
|
||||
wrapProvider(TestFlagsProvider),
|
||||
wrapProvider(LocaleProvider),
|
||||
wrapProvider(RestrictionProvider),
|
||||
wrapProvider(DydxProvider),
|
||||
wrapProvider(AccountsProvider),
|
||||
wrapProvider(SubaccountProvider),
|
||||
wrapProvider(SquidProvider),
|
||||
wrapProvider(LocalNotificationsProvider),
|
||||
wrapProvider(NotificationsProvider),
|
||||
wrapProvider(DialogAreaProvider),
|
||||
|
||||
@@ -61,7 +61,7 @@ export const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonPr
|
||||
|
||||
return (
|
||||
<StyledBaseButton
|
||||
disabled={state[ButtonState.Disabled]}
|
||||
disabled={state[ButtonState.Disabled] || state[ButtonState.Loading]}
|
||||
{...{ ref, action, size, shape, state, ...otherProps }}
|
||||
>
|
||||
{
|
||||
|
||||
@@ -38,6 +38,7 @@ import {
|
||||
HelpCircleIcon,
|
||||
HideIcon,
|
||||
HistoryIcon,
|
||||
LeaderboardIcon,
|
||||
LinkOutIcon,
|
||||
LockIcon,
|
||||
LogoShortIcon,
|
||||
@@ -111,6 +112,7 @@ export enum IconName {
|
||||
HelpCircle = 'HelpCircle',
|
||||
Hide = 'Hide',
|
||||
History = 'History',
|
||||
Leaderboard = 'Leaderboard',
|
||||
LinkOut = 'LinkOut',
|
||||
Lock = 'Lock',
|
||||
LogoShort = 'LogoShort',
|
||||
@@ -185,6 +187,7 @@ const icons = {
|
||||
[IconName.HelpCircle]: HelpCircleIcon,
|
||||
[IconName.Hide]: HideIcon,
|
||||
[IconName.History]: HistoryIcon,
|
||||
[IconName.Leaderboard]: LeaderboardIcon,
|
||||
[IconName.LinkOut]: LinkOutIcon,
|
||||
[IconName.Lock]: LockIcon,
|
||||
[IconName.LogoShort]: LogoShortIcon,
|
||||
|
||||
+30
-20
@@ -10,7 +10,7 @@ import {
|
||||
USD_DECIMALS,
|
||||
} from '@/constants/numbers';
|
||||
|
||||
import { BIG_NUMBERS, MustBigNumber } from '@/lib/numbers';
|
||||
import { BIG_NUMBERS } from '@/lib/numbers';
|
||||
import { useLocaleSeparators } from '@/hooks';
|
||||
|
||||
export enum InputType {
|
||||
@@ -29,31 +29,38 @@ type StyleProps = {
|
||||
type ElementProps = {
|
||||
type?: InputType;
|
||||
value?: string | number | null;
|
||||
|
||||
allowNegative?: boolean;
|
||||
decimals?: number;
|
||||
disabled?: boolean;
|
||||
id?: string;
|
||||
max?: number;
|
||||
onBlur?: () => void;
|
||||
onChange?:
|
||||
| Dispatch<SetStateAction<string>>
|
||||
| React.ReactEventHandler<HTMLInputElement>
|
||||
| ((values: NumberFormatValues, e: SourceInfo) => void);
|
||||
onFocus?: () => void;
|
||||
onInput?: ({
|
||||
value,
|
||||
floatValue,
|
||||
formattedValue,
|
||||
}: {
|
||||
value: string;
|
||||
floatValue?: number;
|
||||
formattedValue: string;
|
||||
}) => void;
|
||||
placeholder?: string;
|
||||
};
|
||||
|
||||
export type InputProps = ElementProps & StyleProps;
|
||||
type ConditionalProps =
|
||||
| {
|
||||
allowNegative?: boolean;
|
||||
decimals?: number;
|
||||
max?: number;
|
||||
onChange?: (values: NumberFormatValues, e: SourceInfo) => void;
|
||||
onInput?: ({
|
||||
value,
|
||||
floatValue,
|
||||
formattedValue,
|
||||
}: {
|
||||
value: string;
|
||||
floatValue?: number;
|
||||
formattedValue: string;
|
||||
}) => void;
|
||||
}
|
||||
| {
|
||||
allowNegative?: never;
|
||||
decimals?: never;
|
||||
max?: never;
|
||||
onChange?: Dispatch<SetStateAction<string>> | React.ReactEventHandler<HTMLInputElement>;
|
||||
onInput?: (e: SyntheticInputEvent) => void;
|
||||
};
|
||||
|
||||
export type InputProps = ElementProps & StyleProps & ConditionalProps;
|
||||
|
||||
export const Input = forwardRef<HTMLInputElement, InputProps>(
|
||||
(
|
||||
@@ -129,6 +136,7 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
|
||||
placeholder={placeholder}
|
||||
value={value}
|
||||
// Other
|
||||
data-1p-ignore // prevent 1Password fill
|
||||
{...otherProps}
|
||||
/>
|
||||
) : (
|
||||
@@ -137,6 +145,7 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
|
||||
ref={ref as React.Ref<typeof NumericFormat<unknown>>}
|
||||
id={id}
|
||||
// NumericFormat
|
||||
valueIsNumericString
|
||||
allowNegative={allowNegative}
|
||||
decimalScale={decimals}
|
||||
decimalSeparator={LOCALE_DECIMAL_SEPARATOR}
|
||||
@@ -160,7 +169,7 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
|
||||
? undefined
|
||||
: Number(formattedValue.replace(',', '.'));
|
||||
|
||||
onInput?.({ value, floatValue, formattedValue });
|
||||
onInput?.({ value, floatValue, formattedValue, ...e });
|
||||
}}
|
||||
// Native
|
||||
disabled={disabled}
|
||||
@@ -168,6 +177,7 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
|
||||
value={formattedValue}
|
||||
autoComplete="off"
|
||||
autoCorrect="off"
|
||||
data-1p-ignore // prevent 1Password fill
|
||||
{...otherProps}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -3,6 +3,7 @@ export enum DialogTypes {
|
||||
Deposit = 'Deposit',
|
||||
DisconnectWallet = 'DisconnectWallet',
|
||||
ExchangeOffline = 'ExchangeOffline',
|
||||
ExternalLink = 'ExternalLink',
|
||||
FillDetails = 'FillDetails',
|
||||
Help = 'Help',
|
||||
ExternalNavKeplr = 'ExternalNavKeplr',
|
||||
|
||||
@@ -22,6 +22,7 @@ export enum LocalStorageKey {
|
||||
SelectedTheme = 'dydx.SelectedTheme',
|
||||
SelectedTradeLayout = 'dydx.SelectedTradeLayout',
|
||||
TradingViewChartConfig = 'dydx.TradingViewChartConfig',
|
||||
HasSeenLaunchIncentives = 'dydx.HasSeenLaunchIncentives',
|
||||
}
|
||||
|
||||
export const LOCAL_STORAGE_VERSIONS = {
|
||||
|
||||
@@ -26,7 +26,6 @@ export enum FundingDirection {
|
||||
ToShort = 'ToShort',
|
||||
ToLong = 'ToLong',
|
||||
}
|
||||
'test'
|
||||
|
||||
export const MARKETS_TO_DISPLAY = [
|
||||
'BTC-USD',
|
||||
@@ -37,4 +36,29 @@ export const MARKETS_TO_DISPLAY = [
|
||||
'ATOM-USD',
|
||||
'AVAX-USD',
|
||||
'APE-USD',
|
||||
'XRP-USD',
|
||||
'UNI-USD',
|
||||
'ADA-USD',
|
||||
'TRX-USD',
|
||||
'OP-USD',
|
||||
'MKR-USD',
|
||||
'DOGE-USD',
|
||||
'SHIB-USD',
|
||||
'COMP-USD',
|
||||
'LDO-USD',
|
||||
'NEAR-USD',
|
||||
'APT-USD',
|
||||
'SUI-USD',
|
||||
'DOT-USD',
|
||||
'ETC-USD',
|
||||
'ARB-USD',
|
||||
'CRV-USD',
|
||||
'BLUR-USD',
|
||||
'FIL-USD',
|
||||
'XLM-USD',
|
||||
'PEPE-USD',
|
||||
'WLD-USD',
|
||||
'SEI-USD',
|
||||
'LTC-USD',
|
||||
'BCH-USD',
|
||||
];
|
||||
|
||||
@@ -122,13 +122,20 @@ export type NotificationDisplayData = {
|
||||
toastDuration?: number;
|
||||
};
|
||||
|
||||
export enum TransferNotificationTypes {
|
||||
Withdrawal = 'withdrawal',
|
||||
Deposit = 'deposit',
|
||||
}
|
||||
|
||||
// Notification types
|
||||
export type TransferNotifcation = {
|
||||
txHash: string;
|
||||
type?: TransferNotificationTypes;
|
||||
toChainId?: string;
|
||||
fromChainId?: string;
|
||||
toAmount?: number;
|
||||
triggeredAt?: number;
|
||||
isCctp?: boolean;
|
||||
errorCount?: number;
|
||||
status?: StatusResponse;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useCallback, useContext, createContext, useEffect, useState, useMemo }
|
||||
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { AES, enc } from 'crypto-js';
|
||||
import { LocalWallet, type Subaccount } from '@dydxprotocol/v4-client-js';
|
||||
import { NOBLE_BECH32_PREFIX, LocalWallet, type Subaccount } from '@dydxprotocol/v4-client-js';
|
||||
|
||||
import { OnboardingGuard, OnboardingState, type EvmDerivedAddresses } from '@/constants/account';
|
||||
import { DialogTypes } from '@/constants/dialogs';
|
||||
@@ -219,6 +219,16 @@ const useAccountsContext = () => {
|
||||
else abacusStateManager.attemptDisconnectAccount();
|
||||
}, [localDydxWallet]);
|
||||
|
||||
useEffect(() => {
|
||||
const setNobleWallet = async () => {
|
||||
if (hdKey?.mnemonic) {
|
||||
const nobleWallet = await LocalWallet.fromMnemonic(hdKey.mnemonic, NOBLE_BECH32_PREFIX);
|
||||
abacusStateManager.setNobleWallet(nobleWallet);
|
||||
}
|
||||
};
|
||||
setNobleWallet();
|
||||
}, [hdKey?.mnemonic]);
|
||||
|
||||
// clear subaccounts when no dydxAddress is set
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { createContext, useContext, useCallback, useEffect, useMemo } from 'react';
|
||||
import { useQuery } from 'react-query';
|
||||
import type { StatusResponse } from '@0xsquid/sdk';
|
||||
|
||||
import { LOCAL_STORAGE_VERSIONS, LocalStorageKey } from '@/constants/localStorage';
|
||||
import { type TransferNotifcation } from '@/constants/notifications';
|
||||
import { useAccounts } from '@/hooks/useAccounts';
|
||||
import { STATUS_ERROR_GRACE_PERIOD, useSquid } from '@/hooks/useSquid';
|
||||
|
||||
import { fetchSquidStatus, STATUS_ERROR_GRACE_PERIOD } from '@/lib/squid';
|
||||
|
||||
import { useLocalStorage } from './useLocalStorage';
|
||||
|
||||
@@ -68,8 +68,6 @@ const useLocalNotificationsContext = () => {
|
||||
[transferNotifications]
|
||||
);
|
||||
|
||||
const squid = useSquid();
|
||||
|
||||
useQuery({
|
||||
queryKey: 'getTransactionStatus',
|
||||
queryFn: async () => {
|
||||
@@ -81,23 +79,27 @@ const useLocalNotificationsContext = () => {
|
||||
toChainId,
|
||||
fromChainId,
|
||||
triggeredAt,
|
||||
isCctp,
|
||||
errorCount,
|
||||
status: currentStatus,
|
||||
} = transferNotification;
|
||||
|
||||
// @ts-ignore status.errors is not in the type definition but can be returned
|
||||
// also error can some time come back as an empty object so we need to ignore for that
|
||||
const hasErrors = !!currentStatus?.errors ||
|
||||
(currentStatus?.error && Object.keys(currentStatus.error).length !== 0);
|
||||
|
||||
if (
|
||||
// @ts-ignore status.errors is not in the type definition but can be returned
|
||||
!currentStatus?.errors &&
|
||||
!currentStatus?.error &&
|
||||
!hasErrors &&
|
||||
(!currentStatus?.squidTransactionStatus ||
|
||||
currentStatus?.squidTransactionStatus === 'ongoing')
|
||||
) {
|
||||
try {
|
||||
const status = await squid?.getStatus({
|
||||
const status = await fetchSquidStatus({
|
||||
transactionId: txHash,
|
||||
toChainId,
|
||||
fromChainId,
|
||||
});
|
||||
}, isCctp);
|
||||
|
||||
if (status) {
|
||||
transferNotification.status = status;
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
MARKETS_TO_DISPLAY,
|
||||
} from '@/constants/markets';
|
||||
|
||||
import { testFlags } from '@/hooks/useTestFlags';
|
||||
import { testFlags } from '@/lib/testFlags';
|
||||
|
||||
import { getAssets } from '@/state/assetsSelectors';
|
||||
import { getPerpetualMarkets } from '@/state/perpetualsSelectors';
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
type NotificationTypeConfig,
|
||||
NotificationType,
|
||||
DEFAULT_TOAST_AUTO_CLOSE_MS,
|
||||
TransferNotificationTypes,
|
||||
} from '@/constants/notifications';
|
||||
|
||||
import { useSelectedNetwork, useStringGetter } from '@/hooks';
|
||||
@@ -152,20 +153,20 @@ export const notificationTypes: NotificationTypeConfig[] = [
|
||||
|
||||
useEffect(() => {
|
||||
for (const transfer of transferNotifications) {
|
||||
const { fromChainId, status, txHash, toAmount } = transfer;
|
||||
const { fromChainId, status, txHash, toAmount, type } = transfer;
|
||||
const isFinished = Boolean(status) && status?.squidTransactionStatus !== 'ongoing';
|
||||
const icon = <Icon iconName={isFinished ? IconName.Transfer : IconName.Clock} />;
|
||||
|
||||
const type =
|
||||
const transferType = type ??
|
||||
fromChainId === ENVIRONMENT_CONFIG_MAP[selectedNetwork].dydxChainId
|
||||
? 'withdrawal'
|
||||
: 'deposit';
|
||||
? TransferNotificationTypes.Withdrawal
|
||||
: TransferNotificationTypes.Deposit;
|
||||
|
||||
const title = stringGetter({
|
||||
key: {
|
||||
deposit: isFinished ? STRING_KEYS.DEPOSIT : STRING_KEYS.DEPOSIT_IN_PROGRESS,
|
||||
withdrawal: isFinished ? STRING_KEYS.WITHDRAW : STRING_KEYS.WITHDRAW_IN_PROGRESS,
|
||||
}[type],
|
||||
}[transferType],
|
||||
});
|
||||
|
||||
const toChainEta = status?.toChain?.chainData?.estimatedRouteDuration || 0;
|
||||
@@ -190,7 +191,7 @@ export const notificationTypes: NotificationTypeConfig[] = [
|
||||
slotIcon={icon}
|
||||
slotTitle={title}
|
||||
transfer={transfer}
|
||||
type={type}
|
||||
type={transferType}
|
||||
triggeredAt={transfer.triggeredAt}
|
||||
notification={notification}
|
||||
/>
|
||||
@@ -220,7 +221,7 @@ export const notificationTypes: NotificationTypeConfig[] = [
|
||||
body: stringGetter({
|
||||
key: 'NOTIFICATIONS.RELEASE_REWARDS_AND_FULL_TRADING.BODY',
|
||||
params: {
|
||||
BLOGPOST: (
|
||||
DOS_BLOGPOST: (
|
||||
<$Link
|
||||
href="https://www.dydxopsdao.com/blog/deep-dive-full-trading"
|
||||
target="_blank"
|
||||
@@ -229,8 +230,7 @@ export const notificationTypes: NotificationTypeConfig[] = [
|
||||
{stringGetter({ key: STRING_KEYS.HERE })}
|
||||
</$Link>
|
||||
),
|
||||
// todo: update localization to flip the two
|
||||
DOS_BLOGPOST: (
|
||||
TRADING_BLOGPOST: (
|
||||
<$Link
|
||||
href="https://dydx.exchange/blog/v4-full-trading"
|
||||
target="_blank"
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
import { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { Squid } from '@0xsquid/sdk';
|
||||
|
||||
import { ENVIRONMENT_CONFIG_MAP } from '@/constants/networks';
|
||||
|
||||
import { getSelectedNetwork } from '@/state/appSelectors';
|
||||
|
||||
export const NATIVE_TOKEN_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
||||
|
||||
export const STATUS_ERROR_GRACE_PERIOD = 300_000;
|
||||
|
||||
const useSquidContext = () => {
|
||||
const selectedNetwork = useSelector(getSelectedNetwork);
|
||||
const [_, setInitialized] = useState(false);
|
||||
|
||||
const initializeClient = async () => {
|
||||
setInitialized(false);
|
||||
if (!squid) return;
|
||||
await squid.init();
|
||||
setInitialized(true);
|
||||
};
|
||||
|
||||
const squid = useMemo(
|
||||
() =>
|
||||
new Squid({
|
||||
baseUrl: ENVIRONMENT_CONFIG_MAP[selectedNetwork]?.endpoints['0xsquid'],
|
||||
integratorId: ENVIRONMENT_CONFIG_MAP[selectedNetwork]?.squidIntegratorId,
|
||||
}),
|
||||
[selectedNetwork]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (squid) {
|
||||
initializeClient();
|
||||
}
|
||||
}, [squid]);
|
||||
|
||||
return squid;
|
||||
};
|
||||
|
||||
type SquidContextType = ReturnType<typeof useSquidContext>;
|
||||
const SquidContext = createContext<SquidContextType | undefined>(undefined);
|
||||
SquidContext.displayName = '0xSquid';
|
||||
|
||||
export const SquidProvider = ({ ...props }) => (
|
||||
<SquidContext.Provider value={useSquidContext()} {...props} />
|
||||
);
|
||||
|
||||
export const useSquid = () => useContext(SquidContext);
|
||||
@@ -31,6 +31,7 @@ import { log } from '@/lib/telemetry';
|
||||
import { useAccounts } from './useAccounts';
|
||||
import { useTokenConfigs } from './useTokenConfigs';
|
||||
import { useDydxClient } from './useDydxClient';
|
||||
import { hashFromTx } from '@/lib/hashfromTx';
|
||||
|
||||
type SubaccountContextType = ReturnType<typeof useSubaccountContext>;
|
||||
const SubaccountContext = createContext<SubaccountContextType>({} as SubaccountContextType);
|
||||
@@ -293,12 +294,29 @@ export const useSubaccountContext = ({ localDydxWallet }: { localDydxWallet?: Lo
|
||||
);
|
||||
|
||||
const sendSquidWithdraw = useCallback(
|
||||
async (amount: number, payload: string) => {
|
||||
async (amount: number, payload: string, isCctp?: boolean) => {
|
||||
|
||||
const cctpWithdraw = () => {
|
||||
return new Promise<string>((resolve, reject) =>
|
||||
abacusStateManager.cctpWithdraw((success, error, data) => {
|
||||
const parsedData = JSON.parse(data);
|
||||
if (success && parsedData?.code == 0) {
|
||||
resolve(parsedData?.transactionHash);
|
||||
} else {
|
||||
reject(error);
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
if (isCctp) {
|
||||
return await cctpWithdraw();
|
||||
}
|
||||
|
||||
if (!subaccountClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
return await sendSquidWithdrawFromSubaccount({ subaccountClient, amount, payload });
|
||||
const tx = await sendSquidWithdrawFromSubaccount({ subaccountClient, amount, payload });
|
||||
return hashFromTx(tx?.hash);
|
||||
},
|
||||
[subaccountClient, sendSquidWithdrawFromSubaccount]
|
||||
);
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
import { createContext, useContext, useEffect, useState } from 'react';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import queryString from 'query-string';
|
||||
|
||||
class TestFlags {
|
||||
public queryParams: queryString.ParsedQuery<string>;
|
||||
|
||||
constructor() {
|
||||
this.queryParams = {};
|
||||
}
|
||||
|
||||
setQueryParams(flags: queryString.ParsedQuery<string>) {
|
||||
this.queryParams = flags;
|
||||
}
|
||||
|
||||
get displayInitializingMarkets() {
|
||||
return !!this.queryParams.displayInitializingMarkets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description We are temporarily displaying a subset of ACTIVE markets, this flag will allow you to see all ACTIVE markets
|
||||
*/
|
||||
get displayAllMarkets() {
|
||||
return !!this.queryParams.displayAllMarkets;
|
||||
}
|
||||
}
|
||||
|
||||
export const testFlags = new TestFlags();
|
||||
|
||||
const useTestFlagsContext = () => {
|
||||
const [queryParams, setQueryParams] = useState<queryString.ParsedQuery<string>>({});
|
||||
const location = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
const parsedQueryParams = queryString.parse(location.search.substring(-1));
|
||||
testFlags.setQueryParams(parsedQueryParams);
|
||||
setQueryParams(parsedQueryParams);
|
||||
}, []);
|
||||
|
||||
return {
|
||||
...queryParams,
|
||||
};
|
||||
};
|
||||
|
||||
type TestFlagsContextType = ReturnType<typeof useTestFlagsContext>;
|
||||
const TestFlagsContext = createContext<TestFlagsContextType>({} as TestFlagsContextType);
|
||||
TestFlagsContext.displayName = 'TestFlags';
|
||||
|
||||
export const TestFlagsProvider = ({ ...props }) => (
|
||||
<TestFlagsContext.Provider value={useTestFlagsContext()} {...props} />
|
||||
);
|
||||
|
||||
export const useTestFlags = () => useContext(TestFlagsContext);
|
||||
@@ -11,22 +11,19 @@ export const useTradeFormInputs = () => {
|
||||
const { limitPriceInput, triggerPriceInput, trailingPercentInput } = tradeFormInputValues;
|
||||
|
||||
useEffect(() => {
|
||||
const floatValue = parseFloat(triggerPriceInput);
|
||||
abacusStateManager.setTradeValue({
|
||||
value: floatValue,
|
||||
value: triggerPriceInput,
|
||||
field: TradeInputField.triggerPrice,
|
||||
});
|
||||
}, [triggerPriceInput]);
|
||||
|
||||
useEffect(() => {
|
||||
const floatValue = parseFloat(limitPriceInput);
|
||||
abacusStateManager.setTradeValue({ value: floatValue, field: TradeInputField.limitPrice });
|
||||
abacusStateManager.setTradeValue({ value: limitPriceInput, field: TradeInputField.limitPrice });
|
||||
}, [limitPriceInput]);
|
||||
|
||||
useEffect(() => {
|
||||
const floatValue = parseFloat(trailingPercentInput);
|
||||
abacusStateManager.setTradeValue({
|
||||
value: floatValue,
|
||||
value: trailingPercentInput,
|
||||
field: TradeInputField.trailingPercent,
|
||||
});
|
||||
}, [trailingPercentInput]);
|
||||
|
||||
@@ -32,6 +32,7 @@ export { default as GiftboxIcon } from './giftbox.svg';
|
||||
export { default as HelpCircleIcon } from './help-circle.svg';
|
||||
export { default as HideIcon } from './hide.svg';
|
||||
export { default as HistoryIcon } from './history.svg';
|
||||
export { default as LeaderboardIcon } from './leaderboard.svg';
|
||||
export { default as LinkOutIcon } from './link-out.svg';
|
||||
export { default as LockIcon } from './lock.svg';
|
||||
export { default as LogoShortIcon } from './logo-short';
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<svg width="13" height="14" viewBox="0 0 13 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M0.0996094 2.60156C0.0996094 2.07113 0.310323 1.56242 0.685396 1.18735C1.06047 0.812276 1.56918 0.601563 2.09961 0.601562H10.8996C11.43 0.601563 11.9387 0.812276 12.3138 1.18735C12.6889 1.56242 12.8996 2.07113 12.8996 2.60156C12.8996 3.132 12.6889 3.6407 12.3138 4.01578C11.9387 4.39085 11.43 4.60156 10.8996 4.60156H2.09961C1.56918 4.60156 1.06047 4.39085 0.685396 4.01578C0.310323 3.6407 0.0996094 3.132 0.0996094 2.60156ZM0.699609 6.26796C0.540479 6.26796 0.387867 6.33118 0.275345 6.4437C0.162823 6.55622 0.0996094 6.70883 0.0996094 6.86796C0.0996094 7.02709 0.162823 7.1797 0.275345 7.29223C0.387867 7.40475 0.540479 7.46796 0.699609 7.46796H12.2996C12.4587 7.46796 12.6114 7.40475 12.7239 7.29223C12.8364 7.1797 12.8996 7.02709 12.8996 6.86796C12.8996 6.70883 12.8364 6.55622 12.7239 6.4437C12.6114 6.33118 12.4587 6.26796 12.2996 6.26796H0.699609ZM0.699609 9.13196C0.540479 9.13196 0.387867 9.19518 0.275345 9.3077C0.162823 9.42022 0.0996094 9.57283 0.0996094 9.73196C0.0996094 9.89109 0.162823 10.0437 0.275345 10.1562C0.387867 10.2687 0.540479 10.332 0.699609 10.332H12.2996C12.4587 10.332 12.6114 10.2687 12.7239 10.1562C12.8364 10.0437 12.8996 9.89109 12.8996 9.73196C12.8996 9.57283 12.8364 9.42022 12.7239 9.3077C12.6114 9.19518 12.4587 9.13196 12.2996 9.13196H0.699609ZM0.699609 12.0016C0.540479 12.0016 0.387867 12.0648 0.275345 12.1773C0.162823 12.2898 0.0996094 12.4424 0.0996094 12.6016C0.0996094 12.7607 0.162823 12.9133 0.275345 13.0258C0.387867 13.1383 0.540479 13.2016 0.699609 13.2016H12.2996C12.4587 13.2016 12.6114 13.1383 12.7239 13.0258C12.8364 12.9133 12.8996 12.7607 12.8996 12.6016C12.8996 12.4424 12.8364 12.2898 12.7239 12.1773C12.6114 12.0648 12.4587 12.0016 12.2996 12.0016H0.699609Z" fill="currentColor"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
@@ -11,6 +11,7 @@ import { DepositDialog } from '@/views/dialogs/DepositDialog';
|
||||
import { DisconnectDialog } from '@/views/dialogs/DisconnectDialog';
|
||||
import { ExchangeOfflineDialog } from '@/views/dialogs/ExchangeOfflineDialog';
|
||||
import { HelpDialog } from '@/views/dialogs/HelpDialog';
|
||||
import { ExternalLinkDialog } from '@/views/dialogs/ExternalLinkDialog';
|
||||
import { ExternalNavKeplrDialog } from '@/views/dialogs/ExternalNavKeplrDialog';
|
||||
import { MnemonicExportDialog } from '@/views/dialogs/MnemonicExportDialog';
|
||||
import { MobileSignInDialog } from '@/views/dialogs/MobileSignInDialog';
|
||||
@@ -53,6 +54,7 @@ export const DialogManager = () => {
|
||||
[DialogTypes.FillDetails]: <FillDetailsDialog {...modalProps} />,
|
||||
[DialogTypes.Help]: <HelpDialog {...modalProps} />,
|
||||
[DialogTypes.ExternalNavKeplr]: <ExternalNavKeplrDialog {...modalProps} />,
|
||||
[DialogTypes.ExternalLink]: <ExternalLinkDialog {...modalProps} />,
|
||||
[DialogTypes.MnemonicExport]: <MnemonicExportDialog {...modalProps} />,
|
||||
[DialogTypes.MobileSignIn]: <MobileSignInDialog {...modalProps} />,
|
||||
[DialogTypes.Onboarding]: <OnboardingDialog {...modalProps} />,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import styled, { type AnyStyledComponent } from 'styled-components';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
|
||||
import { ButtonShape } from '@/constants/buttons';
|
||||
import { DialogTypes } from '@/constants/dialogs';
|
||||
@@ -8,6 +8,10 @@ import { STRING_KEYS } from '@/constants/localization';
|
||||
import { AppRoute } from '@/constants/routes';
|
||||
import { LogoShortIcon, BellStrokeIcon } from '@/icons';
|
||||
|
||||
import { headerMixins } from '@/styles/headerMixins';
|
||||
import { layoutMixins } from '@/styles/layoutMixins';
|
||||
import breakpoints from '@/styles/breakpoints';
|
||||
|
||||
import { useTokenConfigs, useStringGetter, useURLConfigs } from '@/hooks';
|
||||
|
||||
import { Icon, IconName } from '@/components/Icon';
|
||||
@@ -21,10 +25,7 @@ import { NotificationsMenu } from '@/views/menus/NotificationsMenu';
|
||||
import { LanguageSelector } from '@/views/menus/LanguageSelector';
|
||||
|
||||
import { openDialog } from '@/state/dialogs';
|
||||
|
||||
import { headerMixins } from '@/styles/headerMixins';
|
||||
import { layoutMixins } from '@/styles/layoutMixins';
|
||||
import breakpoints from '@/styles/breakpoints';
|
||||
import { getHasSeenLaunchIncentives } from '@/state/configsSelectors';
|
||||
|
||||
export const HeaderDesktop = () => {
|
||||
const stringGetter = useStringGetter();
|
||||
@@ -32,6 +33,8 @@ export const HeaderDesktop = () => {
|
||||
const dispatch = useDispatch();
|
||||
const { chainTokenLabel } = useTokenConfigs();
|
||||
|
||||
const hasSeenLaunchIncentives = useSelector(getHasSeenLaunchIncentives);
|
||||
|
||||
const navItems = [
|
||||
{
|
||||
group: 'navigation',
|
||||
@@ -55,6 +58,7 @@ export const HeaderDesktop = () => {
|
||||
value: chainTokenLabel,
|
||||
label: chainTokenLabel,
|
||||
href: `/${chainTokenLabel}`,
|
||||
slotAfter: !hasSeenLaunchIncentives && <Styled.UnreadIndicator />,
|
||||
},
|
||||
{
|
||||
value: 'MORE',
|
||||
@@ -238,3 +242,10 @@ Styled.IconButton = styled(IconButton)<{ size?: string }>`
|
||||
--button-icon-size: 1rem;
|
||||
--button-padding: 0 0.5em;
|
||||
`;
|
||||
|
||||
Styled.UnreadIndicator = styled.div`
|
||||
width: 0.4375rem;
|
||||
height: 0.4375rem;
|
||||
border-radius: 50%;
|
||||
background-color: var(--color-accent);
|
||||
`;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import Abacus, { type Nullable } from '@dydxprotocol/v4-abacus';
|
||||
import Long from 'long';
|
||||
import type { IndexedTx } from '@cosmjs/stargate';
|
||||
import { encodeJson } from '@dydxprotocol/v4-client-js';
|
||||
import { GAS_MULTIPLIER, encodeJson } from '@dydxprotocol/v4-client-js';
|
||||
import { EncodeObject } from '@cosmjs/proto-signing';
|
||||
|
||||
import {
|
||||
CompositeClient,
|
||||
@@ -9,6 +10,7 @@ import {
|
||||
type LocalWallet,
|
||||
Network,
|
||||
NetworkOptimizer,
|
||||
NobleClient,
|
||||
SubaccountClient,
|
||||
ValidatorConfig,
|
||||
OrderType,
|
||||
@@ -40,11 +42,14 @@ import { openDialog } from '@/state/dialogs';
|
||||
import { StatefulOrderError } from '../errors';
|
||||
import { bytesToBigInt } from '../numbers';
|
||||
import { log } from '../telemetry';
|
||||
import { hashFromTx } from '../hashfromTx';
|
||||
|
||||
class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
|
||||
private compositeClient: CompositeClient | undefined;
|
||||
private nobleClient: NobleClient | undefined;
|
||||
private store: RootStore | undefined;
|
||||
private localWallet: LocalWallet | undefined;
|
||||
private nobleWallet: LocalWallet | undefined;
|
||||
|
||||
constructor() {
|
||||
this.compositeClient = undefined;
|
||||
@@ -59,6 +64,13 @@ class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
|
||||
this.localWallet = localWallet;
|
||||
}
|
||||
|
||||
setNobleWallet(nobleWallet: LocalWallet) {
|
||||
this.nobleWallet = nobleWallet;
|
||||
if (this.nobleClient) {
|
||||
this.nobleClient.connect(nobleWallet);
|
||||
}
|
||||
}
|
||||
|
||||
async connectNetwork(
|
||||
paramsInJson: Nullable<string>,
|
||||
callback: (p0: Nullable<string>) => void
|
||||
@@ -70,6 +82,7 @@ class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
|
||||
websocketUrl,
|
||||
validatorUrl,
|
||||
chainId,
|
||||
nobleValidatorUrl,
|
||||
USDC_DENOM,
|
||||
USDC_DECIMALS,
|
||||
USDC_GAS_DENOM,
|
||||
@@ -101,6 +114,10 @@ class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
|
||||
|
||||
this.compositeClient = compositeClient;
|
||||
|
||||
if (nobleValidatorUrl) {
|
||||
this.nobleClient = new NobleClient(nobleValidatorUrl);
|
||||
if (this.nobleWallet) await this.nobleClient.connect(this.nobleWallet);
|
||||
}
|
||||
// Dispatch custom event to notify other parts of the app that the network has been connected
|
||||
const customEvent = new CustomEvent('abacus:connectNetwork', {
|
||||
detail: parsedParams,
|
||||
@@ -325,6 +342,130 @@ class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
async sendNobleIBC(
|
||||
params: {
|
||||
msgTypeUrl: string,
|
||||
msg: any,
|
||||
}
|
||||
): Promise<string> {
|
||||
if (!this.nobleClient?.isConnected) {
|
||||
throw new Error('Missing nobleClient or localWallet');
|
||||
}
|
||||
|
||||
try {
|
||||
const ibcMsg = {
|
||||
typeUrl: params.msgTypeUrl, // '/ibc.applications.transfer.v1.MsgTransfer',
|
||||
value: params.msg,
|
||||
};
|
||||
const fee = await this.nobleClient.simulateTransaction([ibcMsg]);
|
||||
|
||||
// take out fee from amount before sweeping
|
||||
const amount = parseInt(ibcMsg.value.token.amount, 10) -
|
||||
Math.floor(parseInt(fee.amount[0].amount, 10) * GAS_MULTIPLIER);
|
||||
|
||||
if (amount <= 0) {
|
||||
throw new Error('noble balance does not cover fees');
|
||||
}
|
||||
|
||||
ibcMsg.value.token.amount = amount.toString();
|
||||
const tx = await this.nobleClient.send([ibcMsg]);
|
||||
|
||||
const parsedTx = this.parseToPrimitives(tx);
|
||||
|
||||
return JSON.stringify(parsedTx);
|
||||
} catch (error) {
|
||||
log('DydxChainTransactions/sendNobleIBC', error);
|
||||
|
||||
return JSON.stringify({
|
||||
error,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async withdrawToNobleIBC(
|
||||
params: {
|
||||
subaccountNumber: number,
|
||||
amount: string,
|
||||
ibcPayload: string,
|
||||
}
|
||||
): Promise<string> {
|
||||
if (!this.compositeClient || !this.localWallet) {
|
||||
throw new Error('Missing compositeClient or localWallet');
|
||||
}
|
||||
|
||||
const { subaccountNumber, amount, ibcPayload } = params ?? {};
|
||||
const parsedIbcPayload: {
|
||||
msgTypeUrl: string,
|
||||
msg: any,
|
||||
} = ibcPayload ? JSON.parse(ibcPayload) : undefined;
|
||||
|
||||
try {
|
||||
const msg = this.compositeClient.withdrawFromSubaccountMessage(
|
||||
new SubaccountClient(this.localWallet, subaccountNumber),
|
||||
parseFloat(amount).toFixed(this.compositeClient.validatorClient.config.denoms.USDC_DECIMALS)
|
||||
);
|
||||
const ibcMsg: EncodeObject = {
|
||||
typeUrl: parsedIbcPayload.msgTypeUrl,
|
||||
value: parsedIbcPayload.msg,
|
||||
};
|
||||
|
||||
const tx = await this.compositeClient.send(
|
||||
this.localWallet,
|
||||
() => Promise.resolve([msg, ibcMsg]),
|
||||
false
|
||||
);
|
||||
|
||||
return JSON.stringify({
|
||||
txHash: hashFromTx(tx?.hash)
|
||||
});
|
||||
} catch (error) {
|
||||
log('DydxChainTransactions/withdrawToNobleIBC', error);
|
||||
|
||||
return JSON.stringify({
|
||||
error,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async cctpWithdraw(params: {
|
||||
typeUrl: string,
|
||||
value: any,
|
||||
}): Promise<string> {
|
||||
if (!this.nobleClient?.isConnected) {
|
||||
throw new Error('Missing nobleClient or localWallet');
|
||||
}
|
||||
|
||||
try {
|
||||
const ibcMsg = {
|
||||
typeUrl: params.typeUrl, // '/circle.cctp.v1.MsgDepositForBurn',
|
||||
value: params.value,
|
||||
};
|
||||
const fee = await this.nobleClient.simulateTransaction([ibcMsg]);
|
||||
|
||||
// take out fee from amount before sweeping
|
||||
const amount = parseInt(ibcMsg.value.amount, 10) -
|
||||
Math.floor(parseInt(fee.amount[0].amount, 10) * GAS_MULTIPLIER);
|
||||
|
||||
if (amount <= 0) {
|
||||
throw new Error('noble balance does not cover fees');
|
||||
}
|
||||
|
||||
ibcMsg.value.amount = amount.toString();
|
||||
|
||||
const tx = await this.nobleClient.send([ibcMsg]);
|
||||
|
||||
const parsedTx = this.parseToPrimitives(tx);
|
||||
|
||||
return JSON.stringify(parsedTx);
|
||||
} catch (error) {
|
||||
log('DydxChainTransactions/cctpWithdraw', error);
|
||||
|
||||
return JSON.stringify({
|
||||
error,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async transaction(
|
||||
type: TransactionTypes,
|
||||
paramsInJson: Abacus.Nullable<string>,
|
||||
@@ -354,6 +495,22 @@ class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
|
||||
callback(result);
|
||||
break;
|
||||
}
|
||||
case TransactionType.SendNobleIBC: {
|
||||
const result = await this.sendNobleIBC(params);
|
||||
callback(result);
|
||||
break;
|
||||
}
|
||||
case TransactionType.WithdrawToNobleIBC: {
|
||||
const result = await this.withdrawToNobleIBC(params);
|
||||
callback(result);
|
||||
break;
|
||||
}
|
||||
case TransactionType.CctpWithdraw: {
|
||||
const result = await this.cctpWithdraw(params);
|
||||
callback(result);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
@@ -441,6 +598,13 @@ class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
|
||||
const parseDelegations = this.parseToPrimitives(delegations);
|
||||
callback(JSON.stringify(parseDelegations));
|
||||
break;
|
||||
case QueryType.GetNobleBalance:
|
||||
if (this.nobleClient?.isConnected) {
|
||||
const nobleBalance = await this.nobleClient.getAccountBalance('uusdc');
|
||||
const parsedNobleBalance = this.parseToPrimitives(nobleBalance);
|
||||
callback(JSON.stringify(parsedNobleBalance));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
+22
-14
@@ -26,13 +26,15 @@ import {
|
||||
} from '@/constants/abacus';
|
||||
|
||||
import { DEFAULT_MARKETID } from '@/constants/markets';
|
||||
import { CURRENT_ABACUS_DEPLOYMENT, type DydxNetwork } from '@/constants/networks';
|
||||
import { CURRENT_ABACUS_DEPLOYMENT, type DydxNetwork, isMainnet } from '@/constants/networks';
|
||||
import { CLEARED_SIZE_INPUTS, CLEARED_TRADE_INPUTS } from '@/constants/trade';
|
||||
|
||||
import type { RootStore } from '@/state/_store';
|
||||
import { setTradeFormInputs } from '@/state/inputs';
|
||||
import { getInputTradeOptions, getTransferInputs } from '@/state/inputsSelectors';
|
||||
|
||||
import { testFlags } from '@/lib/testFlags';
|
||||
|
||||
import AbacusRest from './rest';
|
||||
import AbacusAnalytics from './analytics';
|
||||
import AbacusWebsocket from './websocket';
|
||||
@@ -81,10 +83,14 @@ class AbacusStateManager {
|
||||
this.abacusFormatter
|
||||
);
|
||||
|
||||
const appConfigs = AbacusAppConfig.Companion.forWeb;
|
||||
if (!isMainnet || testFlags.withCCTP)
|
||||
appConfigs.squidVersion = AbacusAppConfig.SquidVersion.V2;
|
||||
|
||||
this.stateManager = new AsyncAbacusStateManager(
|
||||
'',
|
||||
CURRENT_ABACUS_DEPLOYMENT,
|
||||
AbacusAppConfig.Companion.forWeb,
|
||||
appConfigs,
|
||||
ioImplementations,
|
||||
uiImplementations,
|
||||
// @ts-ignore
|
||||
@@ -180,6 +186,12 @@ class AbacusStateManager {
|
||||
}
|
||||
};
|
||||
|
||||
setNobleWallet = (nobleWallet?: LocalWallet) => {
|
||||
if (nobleWallet) {
|
||||
this.chainTransactions.setNobleWallet(nobleWallet);
|
||||
}
|
||||
};
|
||||
|
||||
setTransfersSourceAddress = (evmAddress: string) => {
|
||||
this.stateManager.sourceAddress = evmAddress;
|
||||
};
|
||||
@@ -223,18 +235,6 @@ class AbacusStateManager {
|
||||
this.abacusFormatter.setLocaleSeparators({ group, decimal });
|
||||
};
|
||||
|
||||
setTransferStatus = ({
|
||||
hash,
|
||||
fromChainId,
|
||||
toChainId,
|
||||
}: {
|
||||
hash: string;
|
||||
fromChainId?: string;
|
||||
toChainId?: string;
|
||||
}) => {
|
||||
this.stateManager.transferStatus(hash, fromChainId, toChainId);
|
||||
};
|
||||
|
||||
// ------ Transactions ------ //
|
||||
|
||||
placeOrder = (
|
||||
@@ -262,6 +262,14 @@ class AbacusStateManager {
|
||||
) => void
|
||||
) => this.stateManager.cancelOrder(orderId, callback);
|
||||
|
||||
cctpWithdraw = (
|
||||
callback: (
|
||||
success: boolean,
|
||||
parsingError: Nullable<ParsingError>,
|
||||
data: string,
|
||||
) => void
|
||||
): void => this.stateManager.commitCCTPWithdraw(callback);
|
||||
|
||||
// ------ Utils ------ //
|
||||
getHistoricalPnlPeriod = (): Nullable<HistoricalPnlPeriods> =>
|
||||
this.stateManager.historicalPnlPeriod;
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from '@/constants/websocket';
|
||||
|
||||
import { lastSuccessfulWebsocketRequestByOrigin } from '@/hooks/useAnalytics';
|
||||
import { testFlags } from '@/hooks/useTestFlags';
|
||||
import { testFlags } from '@/lib/testFlags';
|
||||
|
||||
import { subscriptionsByChannelId } from '@/lib/tradingView/dydxfeed/cache';
|
||||
import { mapCandle } from '@/lib/tradingView/utils';
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export const hashFromTx = (
|
||||
txHash: string | Uint8Array
|
||||
): string => `0x${Buffer.from(txHash).toString('hex')}`;
|
||||
@@ -0,0 +1,48 @@
|
||||
import { isMainnet } from '@/constants/networks';
|
||||
import { GetStatus, StatusResponse } from '@0xsquid/sdk';
|
||||
|
||||
export const NATIVE_TOKEN_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
||||
|
||||
export const STATUS_ERROR_GRACE_PERIOD = 300_000;
|
||||
|
||||
const getSquidStatusUrl = (isV2: boolean) => {
|
||||
if (isV2) {
|
||||
return isMainnet
|
||||
? 'https://v2.api.squidrouter.com/v2/status'
|
||||
: 'https://testnet.v2.api.squidrouter.com/v2/status';
|
||||
}
|
||||
return isMainnet
|
||||
? 'https://api.squidrouter.com/v1/status'
|
||||
: 'https://testnet.api.squidrouter.com/v1/status';
|
||||
};
|
||||
|
||||
export const fetchSquidStatus = async (
|
||||
params: GetStatus,
|
||||
isV2?: boolean,
|
||||
integratorId?: string
|
||||
): Promise<StatusResponse> => {
|
||||
const parsedParams: { [key: string]: string } = {
|
||||
transactionId: params.transactionId,
|
||||
fromChainId: String(params.fromChainId),
|
||||
toChainId: String(params.toChainId),
|
||||
};
|
||||
if (isV2) parsedParams.bridgeType = 'cctp';
|
||||
const url = `${getSquidStatusUrl(!!isV2)}?${new URLSearchParams(parsedParams).toString()}`;
|
||||
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
"x-integrator-id": integratorId || 'dYdX-api'
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
throw new Error(error);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const getNobleChainId = () => {
|
||||
return isMainnet ? 'noble-1' : 'grand-1';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
class TestFlags {
|
||||
public queryParams: { [key: string]: string };
|
||||
|
||||
constructor() {
|
||||
this.queryParams = {};
|
||||
const hash = window.location.hash;
|
||||
const queryIndex = hash.indexOf('?');
|
||||
if (queryIndex === -1) return
|
||||
|
||||
const queryParamsString = hash.substring(queryIndex + 1);
|
||||
const params = new URLSearchParams(queryParamsString);
|
||||
|
||||
for (const [key, value] of params) {
|
||||
this.queryParams[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
get displayInitializingMarkets() {
|
||||
return !!this.queryParams.displayInitializingMarkets;
|
||||
}
|
||||
|
||||
get displayAllMarkets() {
|
||||
return !!this.queryParams.displayAllMarkets;
|
||||
}
|
||||
|
||||
get withCCTP() {
|
||||
return !!this.queryParams.withCCTP;
|
||||
}
|
||||
}
|
||||
|
||||
export const testFlags = new TestFlags();
|
||||
@@ -2,6 +2,7 @@ import type { ElementType } from 'react';
|
||||
import styled, { AnyStyledComponent } from 'styled-components';
|
||||
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
|
||||
|
||||
import breakpoints from '@/styles/breakpoints';
|
||||
import { layoutMixins } from '@/styles/layoutMixins';
|
||||
import { useAccountBalance, useAccounts, useTokenConfigs, useStringGetter } from '@/hooks';
|
||||
|
||||
@@ -116,12 +117,17 @@ const Styled: Record<string, AnyStyledComponent> = {};
|
||||
|
||||
Styled.Panel = styled(Panel)`
|
||||
--panel-paddingX: 1.5rem;
|
||||
|
||||
@media ${breakpoints.tablet} {
|
||||
--panel-paddingY: 1.5rem;
|
||||
--panel-content-paddingY: 1rem;
|
||||
}
|
||||
`;
|
||||
|
||||
Styled.Header = styled.div`
|
||||
${layoutMixins.spacedRow}
|
||||
gap: 1rem;
|
||||
padding: 1rem 1.5rem 0;
|
||||
padding: var(--panel-paddingY) var(--panel-paddingX) 0;
|
||||
`;
|
||||
|
||||
Styled.Title = styled.h3`
|
||||
|
||||
@@ -0,0 +1,296 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { useQuery } from 'react-query';
|
||||
import styled, { AnyStyledComponent } from 'styled-components';
|
||||
|
||||
import { STRING_KEYS } from '@/constants/localization';
|
||||
import { ButtonAction } from '@/constants/buttons';
|
||||
import { DialogTypes } from '@/constants/dialogs';
|
||||
|
||||
import breakpoints from '@/styles/breakpoints';
|
||||
import { useAccounts, useBreakpoints, useStringGetter } from '@/hooks';
|
||||
|
||||
import { layoutMixins } from '@/styles/layoutMixins';
|
||||
|
||||
import { Panel } from '@/components/Panel';
|
||||
import { Button } from '@/components/Button';
|
||||
|
||||
import { Output, OutputType } from '@/components/Output';
|
||||
import { Icon, IconName } from '@/components/Icon';
|
||||
import { Tag, TagSize } from '@/components/Tag';
|
||||
|
||||
import { markLaunchIncentivesSeen } from '@/state/configs';
|
||||
import { openDialog } from '@/state/dialogs';
|
||||
|
||||
import { log } from '@/lib/telemetry';
|
||||
|
||||
export const LaunchIncentivesPanel = () => {
|
||||
const { isNotTablet } = useBreakpoints();
|
||||
const dispatch = useDispatch();
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(markLaunchIncentivesSeen());
|
||||
}, []);
|
||||
|
||||
return isNotTablet ? (
|
||||
<Styled.Panel slotHeader={<LaunchIncentivesTitle />} slotRight={<EstimatedRewards />}>
|
||||
<LaunchIncentivesContent />
|
||||
</Styled.Panel>
|
||||
) : (
|
||||
<Styled.Panel>
|
||||
<Styled.Column>
|
||||
<EstimatedRewards />
|
||||
<LaunchIncentivesTitle />
|
||||
<LaunchIncentivesContent />
|
||||
</Styled.Column>
|
||||
</Styled.Panel>
|
||||
);
|
||||
};
|
||||
|
||||
const LaunchIncentivesTitle = () => {
|
||||
const stringGetter = useStringGetter();
|
||||
return (
|
||||
<Styled.Title>
|
||||
{stringGetter({
|
||||
key: STRING_KEYS.LAUNCH_INCENTIVES_TITLE,
|
||||
params: {
|
||||
FOR_V4: <Styled.ForV4>{stringGetter({ key: STRING_KEYS.FOR_V4 })}</Styled.ForV4>,
|
||||
},
|
||||
})}
|
||||
<Styled.NewTag size={TagSize.Medium}>{stringGetter({ key: STRING_KEYS.NEW })}</Styled.NewTag>
|
||||
</Styled.Title>
|
||||
);
|
||||
};
|
||||
|
||||
const EstimatedRewards = () => {
|
||||
const stringGetter = useStringGetter();
|
||||
const { dydxAddress } = useAccounts();
|
||||
|
||||
const { data, isLoading } = useQuery({
|
||||
enabled: !!dydxAddress,
|
||||
queryKey: `launch_incentives_rewards_${dydxAddress ?? ''}`,
|
||||
queryFn: async () => {
|
||||
if (!dydxAddress) return undefined;
|
||||
const resp = await fetch(`https://cloud.chaoslabs.co/query/api/dydx/points/${dydxAddress}`);
|
||||
return (await resp.json())?.incentivePoints;
|
||||
},
|
||||
onError: (error: Error) => log('LaunchIncentives/fetchPoints', error),
|
||||
});
|
||||
|
||||
return (
|
||||
<Styled.EstimatedRewardsCard>
|
||||
<Styled.EstimatedRewardsCardContent>
|
||||
<div>
|
||||
<span>{stringGetter({ key: STRING_KEYS.ESTIMATED_REWARDS })}</span>
|
||||
<Styled.Season>
|
||||
{stringGetter({
|
||||
key: STRING_KEYS.LAUNCH_INCENTIVES_SEASON_NUM,
|
||||
params: {
|
||||
SEASON_NUMBER: 1,
|
||||
},
|
||||
})}
|
||||
</Styled.Season>
|
||||
</div>
|
||||
|
||||
<Styled.Points>
|
||||
<Output type={OutputType.Number} value={data} isLoading={isLoading} fractionDigits={2} />
|
||||
{data !== undefined && stringGetter({ key: STRING_KEYS.POINTS })}
|
||||
</Styled.Points>
|
||||
</Styled.EstimatedRewardsCardContent>
|
||||
|
||||
<Styled.Image src="/rewards-stars.svg" />
|
||||
</Styled.EstimatedRewardsCard>
|
||||
);
|
||||
};
|
||||
|
||||
const LaunchIncentivesContent = () => {
|
||||
const stringGetter = useStringGetter();
|
||||
const dispatch = useDispatch();
|
||||
|
||||
return (
|
||||
<Styled.Column>
|
||||
<Styled.Description>
|
||||
{stringGetter({ key: STRING_KEYS.LAUNCH_INCENTIVES_DESCRIPTION })}{' '}
|
||||
</Styled.Description>
|
||||
<Styled.ChaosLabsLogo src="/logos/chaos-labs.svg" />
|
||||
<Styled.ButtonRow>
|
||||
<Styled.AboutButton
|
||||
action={ButtonAction.Base}
|
||||
onClick={() => {
|
||||
dispatch(
|
||||
openDialog({
|
||||
type: DialogTypes.ExternalLink,
|
||||
dialogProps: { link: 'https://dydx.exchange/blog/v4-full-trading' },
|
||||
})
|
||||
);
|
||||
}}
|
||||
slotRight={<Styled.LinkOutIcon iconName={IconName.LinkOut} />}
|
||||
>
|
||||
{stringGetter({ key: STRING_KEYS.ABOUT })}
|
||||
</Styled.AboutButton>
|
||||
<Styled.Button
|
||||
action={ButtonAction.Primary}
|
||||
onClick={() => {
|
||||
dispatch(
|
||||
openDialog({
|
||||
type: DialogTypes.ExternalLink,
|
||||
dialogProps: { link: 'https://community.chaoslabs.xyz/dydx-v4/risk/leaderboard' },
|
||||
})
|
||||
);
|
||||
}}
|
||||
slotRight={<Styled.LinkOutIcon iconName={IconName.LinkOut} />}
|
||||
slotLeft={<Icon iconName={IconName.Leaderboard} />}
|
||||
>
|
||||
{stringGetter({ key: STRING_KEYS.LEADERBOARD })}
|
||||
</Styled.Button>
|
||||
</Styled.ButtonRow>
|
||||
</Styled.Column>
|
||||
);
|
||||
};
|
||||
|
||||
const Styled: Record<string, AnyStyledComponent> = {};
|
||||
|
||||
Styled.Panel = styled(Panel)`
|
||||
--panel-paddingY: 1rem;
|
||||
--panel-paddingX: 1.5rem;
|
||||
|
||||
background-color: var(--color-layer-4);
|
||||
width: 100%;
|
||||
|
||||
@media ${breakpoints.tablet} {
|
||||
--panel-paddingY: 1.5rem;
|
||||
}
|
||||
`;
|
||||
|
||||
Styled.ForV4 = styled.span`
|
||||
color: var(--color-text-0);
|
||||
`;
|
||||
|
||||
Styled.Title = styled.h3`
|
||||
${layoutMixins.inlineRow}
|
||||
font: var(--font-medium-book);
|
||||
color: var(--color-text-2);
|
||||
|
||||
@media ${breakpoints.notTablet} {
|
||||
padding: var(--panel-paddingY) var(--panel-paddingX) 0;
|
||||
}
|
||||
`;
|
||||
|
||||
Styled.Description = styled.div`
|
||||
color: var(--color-text-0);
|
||||
--link-color: var(--color-text-1);
|
||||
|
||||
a {
|
||||
display: inline;
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 0.25rem;
|
||||
|
||||
::before {
|
||||
content: ' ';
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
Styled.ButtonRow = styled.div`
|
||||
${layoutMixins.inlineRow}
|
||||
gap: 0.75rem;
|
||||
margin-top: 0.5rem;
|
||||
|
||||
a:last-child {
|
||||
--button-width: 100%;
|
||||
}
|
||||
`;
|
||||
|
||||
Styled.Button = styled(Button)`
|
||||
--button-padding: 0 1rem;
|
||||
`;
|
||||
|
||||
Styled.LinkOutIcon = styled(Icon)`
|
||||
color: var(--color-text-1);
|
||||
`;
|
||||
|
||||
Styled.AboutButton = styled(Styled.Button)`
|
||||
--button-textColor: var(--color-text-2);
|
||||
--button-backgroundColor: var(--color-layer-6);
|
||||
--button-border: solid var(--border-width) var(--color-layer-7);
|
||||
`;
|
||||
|
||||
Styled.Column = styled.div`
|
||||
${layoutMixins.flexColumn}
|
||||
gap: 0.5rem;
|
||||
`;
|
||||
|
||||
Styled.EstimatedRewardsCard = styled.div`
|
||||
${layoutMixins.spacedRow}
|
||||
padding: 1rem 1.25rem;
|
||||
min-width: 21.25rem;
|
||||
height: calc(100% - calc(1.5rem * 2));
|
||||
margin: 1.5rem;
|
||||
|
||||
background-color: var(--color-layer-5);
|
||||
background-image: url('/dots-background.svg');
|
||||
background-size: cover;
|
||||
|
||||
border-radius: 0.75rem;
|
||||
border: solid var(--border-width) var(--color-layer-6);
|
||||
color: var(--color-text-1);
|
||||
|
||||
@media ${breakpoints.tablet} {
|
||||
margin: 0 0 0.5rem;
|
||||
}
|
||||
`;
|
||||
|
||||
Styled.EstimatedRewardsCardContent = styled.div`
|
||||
${layoutMixins.flexColumn}
|
||||
gap: 1rem;
|
||||
height: 100%;
|
||||
justify-content: space-between;
|
||||
|
||||
div {
|
||||
${layoutMixins.flexColumn}
|
||||
gap: 0.15rem;
|
||||
font: var(--font-medium-book);
|
||||
|
||||
:first-child {
|
||||
color: var(--color-text-2);
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
Styled.BackgroundDots = styled.img`
|
||||
position: absolute;
|
||||
`;
|
||||
|
||||
Styled.Season = styled.span`
|
||||
font: var(--font-small-book);
|
||||
color: var(--color-text-1);
|
||||
`;
|
||||
|
||||
Styled.Points = styled.span`
|
||||
${layoutMixins.inlineRow}
|
||||
gap: 0.25rem;
|
||||
font: var(--font-large-book);
|
||||
color: var(--color-text-0);
|
||||
|
||||
output {
|
||||
color: var(--color-text-2);
|
||||
}
|
||||
`;
|
||||
|
||||
Styled.Image = styled.img`
|
||||
position: relative;
|
||||
float: right;
|
||||
|
||||
width: 5.25rem;
|
||||
height: auto;
|
||||
`;
|
||||
|
||||
Styled.ChaosLabsLogo = styled.img`
|
||||
height: 1.25rem;
|
||||
align-self: start;
|
||||
`;
|
||||
|
||||
Styled.NewTag = styled(Tag)`
|
||||
color: var(--color-accent);
|
||||
background-color: var(--color-accent-faded);
|
||||
`;
|
||||
@@ -7,6 +7,8 @@ import { ButtonAction, ButtonSize, ButtonType } from '@/constants/buttons';
|
||||
|
||||
import { useAccountBalance, useBreakpoints, useStringGetter } from '@/hooks';
|
||||
|
||||
import { breakpoints } from '@/styles';
|
||||
|
||||
import { layoutMixins } from '@/styles/layoutMixins';
|
||||
|
||||
import { Details } from '@/components/Details';
|
||||
@@ -134,13 +136,22 @@ const Styled: Record<string, AnyStyledComponent> = {};
|
||||
Styled.MigratePanel = styled(Panel)`
|
||||
--panel-paddingX: 1.5rem;
|
||||
width: 100%;
|
||||
|
||||
background-image: url('/dots-background.svg');
|
||||
background-position: right;
|
||||
background-repeat: no-repeat;
|
||||
|
||||
@media ${breakpoints.tablet} {
|
||||
--panel-paddingY: 1.5rem;
|
||||
--panel-content-paddingY: 1rem;
|
||||
}
|
||||
`;
|
||||
|
||||
Styled.Title = styled.h3`
|
||||
font: var(--font-medium-book);
|
||||
color: var(--color-text-2);
|
||||
|
||||
padding: 1rem 1.5rem 0;
|
||||
padding: var(--panel-paddingY) var(--panel-paddingX) 0;
|
||||
`;
|
||||
|
||||
Styled.MigrateAction = styled.div`
|
||||
@@ -164,6 +175,13 @@ Styled.Token = styled(Output)`
|
||||
Styled.Description = styled.div`
|
||||
color: var(--color-text-0);
|
||||
--link-color: var(--color-text-1);
|
||||
|
||||
a {
|
||||
display: inline;
|
||||
::before {
|
||||
content: ' ';
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
Styled.Column = styled.div`
|
||||
|
||||
@@ -19,6 +19,7 @@ import { openDialog } from '@/state/dialogs';
|
||||
|
||||
import { DYDXBalancePanel } from './DYDXBalancePanel';
|
||||
import { MigratePanel } from './MigratePanel';
|
||||
import { LaunchIncentivesPanel } from './LaunchIncentivesPanel';
|
||||
|
||||
export const RewardsPage = () => {
|
||||
const dispatch = useDispatch();
|
||||
@@ -39,9 +40,20 @@ export const RewardsPage = () => {
|
||||
return (
|
||||
<Styled.Page>
|
||||
{import.meta.env.VITE_V3_TOKEN_ADDRESS && <MigratePanel />}
|
||||
<Styled.PanelRow>
|
||||
{isTablet && <DYDXBalancePanel />}
|
||||
|
||||
{isTablet ? (
|
||||
<>
|
||||
<LaunchIncentivesPanel />
|
||||
<DYDXBalancePanel />
|
||||
</>
|
||||
) : (
|
||||
<Styled.PanelRowIncentivesAndBalance>
|
||||
<LaunchIncentivesPanel />
|
||||
<DYDXBalancePanel />
|
||||
</Styled.PanelRowIncentivesAndBalance>
|
||||
)}
|
||||
|
||||
<Styled.PanelRow>
|
||||
<Styled.Panel
|
||||
slotHeader={<Styled.Title>{stringGetter({ key: STRING_KEYS.GOVERNANCE })}</Styled.Title>}
|
||||
slotRight={panelArrow}
|
||||
@@ -67,8 +79,6 @@ export const RewardsPage = () => {
|
||||
</Link>
|
||||
</Styled.Description>
|
||||
</Styled.Panel>
|
||||
|
||||
{isNotTablet && <DYDXBalancePanel />}
|
||||
</Styled.PanelRow>
|
||||
</Styled.Page>
|
||||
);
|
||||
@@ -99,6 +109,11 @@ Styled.Page = styled.div`
|
||||
|
||||
Styled.Panel = styled(Panel)`
|
||||
--panel-paddingX: 1.5rem;
|
||||
|
||||
@media ${breakpoints.tablet} {
|
||||
--panel-paddingY: 1.5rem;
|
||||
--panel-content-paddingY: 1rem;
|
||||
}
|
||||
`;
|
||||
|
||||
Styled.Title = styled.h3`
|
||||
@@ -110,20 +125,29 @@ Styled.Title = styled.h3`
|
||||
Styled.Description = styled.div`
|
||||
color: var(--color-text-0);
|
||||
--link-color: var(--color-text-1);
|
||||
|
||||
a {
|
||||
display: inline;
|
||||
::before {
|
||||
content: ' ';
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
Styled.PanelRow = styled.div`
|
||||
${layoutMixins.gridEqualColumns}
|
||||
gap: 1.5rem;
|
||||
|
||||
align-items: flex-start;
|
||||
|
||||
@media ${breakpoints.tablet} {
|
||||
grid-auto-flow: row;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
`;
|
||||
|
||||
Styled.PanelRowIncentivesAndBalance = styled(Styled.PanelRow)`
|
||||
grid-template-columns: 2fr 1fr;
|
||||
`;
|
||||
|
||||
Styled.IconButton = styled(IconButton)`
|
||||
color: var(--color-text-0);
|
||||
--color-border: var(--color-layer-6);
|
||||
|
||||
+10
-1
@@ -17,6 +17,7 @@ export interface ConfigsState {
|
||||
feeTiers?: kollections.List<FeeTier>;
|
||||
feeDiscounts?: FeeDiscount[];
|
||||
network?: NetworkConfigs;
|
||||
hasSeenLaunchIncentives: boolean;
|
||||
}
|
||||
|
||||
const DOCUMENT_THEME_MAP = {
|
||||
@@ -43,6 +44,10 @@ const initialState: ConfigsState = {
|
||||
feeDiscounts: undefined,
|
||||
feeTiers: undefined,
|
||||
network: undefined,
|
||||
hasSeenLaunchIncentives: getLocalStorage({
|
||||
key: LocalStorageKey.HasSeenLaunchIncentives,
|
||||
defaultValue: false,
|
||||
}),
|
||||
};
|
||||
|
||||
changeTheme(initialState.appTheme);
|
||||
@@ -60,7 +65,11 @@ export const configsSlice = createSlice({
|
||||
...state,
|
||||
...action.payload,
|
||||
}),
|
||||
markLaunchIncentivesSeen: (state: ConfigsState) => {
|
||||
setLocalStorage({ key: LocalStorageKey.HasSeenLaunchIncentives, value: true });
|
||||
state.hasSeenLaunchIncentives = true;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setAppTheme, setConfigs } = configsSlice.actions;
|
||||
export const { setAppTheme, setConfigs, markLaunchIncentivesSeen } = configsSlice.actions;
|
||||
|
||||
@@ -5,3 +5,6 @@ export const getAppTheme = (state: RootState) => state.configs.appTheme;
|
||||
export const getFeeTiers = (state: RootState) => state.configs.feeTiers?.toArray();
|
||||
|
||||
export const getFeeDiscounts = (state: RootState) => state.configs.feeDiscounts;
|
||||
|
||||
export const getHasSeenLaunchIncentives = (state: RootState) =>
|
||||
state.configs.hasSeenLaunchIncentives;
|
||||
|
||||
+4
-1
@@ -47,7 +47,10 @@ export const inputsSlice = createSlice({
|
||||
inputErrors: errors?.toArray(),
|
||||
tradeInputs: trade,
|
||||
closePositionInputs: closePosition,
|
||||
transferInputs: transfer,
|
||||
transferInputs: {
|
||||
...transfer,
|
||||
isCctp: !!transfer?.isCctp,
|
||||
} as Nullable<TransferInputs>,
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@@ -116,6 +116,7 @@
|
||||
|
||||
--color-gradient-positive: hsla(158, 49%, 48%, 0.16);
|
||||
--color-gradient-negative: hsla(0, 100%, 66%, 0.16);
|
||||
--color-accent-faded: hsla(var(--theme-classic-hue-purple), 100%, 70%, 0.16);
|
||||
|
||||
--color-risk-low: var(--theme-classic-color-green);
|
||||
--color-risk-medium: var(--theme-classic-color-yellow);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { shallowEqual, useSelector } from 'react-redux';
|
||||
import { STRING_KEYS } from '@/constants/localization';
|
||||
import { MARKETS_TO_DISPLAY } from '@/constants/markets';
|
||||
import { useBreakpoints, useStringGetter } from '@/hooks';
|
||||
import { testFlags } from '@/hooks/useTestFlags';
|
||||
import { testFlags } from '@/lib/testFlags';
|
||||
import { breakpoints } from '@/styles';
|
||||
import { layoutMixins } from '@/styles/layoutMixins';
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import styled, { type AnyStyledComponent } from 'styled-components';
|
||||
|
||||
import { ButtonAction, ButtonType } from '@/constants/buttons';
|
||||
import { STRING_KEYS } from '@/constants/localization';
|
||||
import { useStringGetter } from '@/hooks';
|
||||
|
||||
import { Button } from '@/components/Button';
|
||||
import { Dialog } from '@/components/Dialog';
|
||||
|
||||
import { layoutMixins } from '@/styles/layoutMixins';
|
||||
|
||||
type ElementProps = {
|
||||
link: string;
|
||||
linkDescription?: string;
|
||||
setIsOpen: (open: boolean) => void;
|
||||
};
|
||||
|
||||
export const ExternalLinkDialog = ({ setIsOpen, link, linkDescription }: ElementProps) => {
|
||||
const stringGetter = useStringGetter();
|
||||
return (
|
||||
<Dialog
|
||||
isOpen
|
||||
setIsOpen={setIsOpen}
|
||||
title={stringGetter({ key: STRING_KEYS.LEAVING_WEBSITE })}
|
||||
description={
|
||||
linkDescription ?? stringGetter({ key: STRING_KEYS.LEAVING_WEBSITE_DESCRIPTION })
|
||||
}
|
||||
>
|
||||
<Styled.Content>
|
||||
<p>{stringGetter({ key: STRING_KEYS.LEAVING_WEBSITE_DISCLAIMER })}.</p>
|
||||
<Button type={ButtonType.Link} action={ButtonAction.Primary} href={link}>
|
||||
{stringGetter({ key: STRING_KEYS.CONTINUE })}
|
||||
</Button>
|
||||
</Styled.Content>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
const Styled: Record<string, AnyStyledComponent> = {};
|
||||
|
||||
Styled.Content = styled.div`
|
||||
${layoutMixins.flexColumn}
|
||||
gap: 1rem;
|
||||
|
||||
font: var(--font-base-book);
|
||||
`;
|
||||
@@ -18,7 +18,6 @@ import type { EvmAddress } from '@/constants/wallets';
|
||||
import { useAccounts, useDebounce, useStringGetter, useSelectedNetwork } from '@/hooks';
|
||||
import { useAccountBalance, CHAIN_DEFAULT_TOKEN_ADDRESS } from '@/hooks/useAccountBalance';
|
||||
import { useLocalNotifications } from '@/hooks/useLocalNotifications';
|
||||
import { NATIVE_TOKEN_ADDRESS, useSquid } from '@/hooks/useSquid';
|
||||
|
||||
import { layoutMixins } from '@/styles/layoutMixins';
|
||||
import { formMixins } from '@/styles/formMixins';
|
||||
@@ -38,6 +37,7 @@ import { getTransferInputs } from '@/state/inputsSelectors';
|
||||
|
||||
import abacusStateManager from '@/lib/abacus';
|
||||
import { MustBigNumber } from '@/lib/numbers';
|
||||
import { getNobleChainId, NATIVE_TOKEN_ADDRESS } from '@/lib/squid';
|
||||
import { log } from '@/lib/telemetry';
|
||||
import { parseWalletError } from '@/lib/wallet';
|
||||
|
||||
@@ -69,6 +69,7 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
||||
summary,
|
||||
errors: routeErrors,
|
||||
errorMessage: routeErrorMessage,
|
||||
isCctp,
|
||||
} = useSelector(getTransferInputs, shallowEqual) || {};
|
||||
const chainId = chainIdStr ? parseInt(chainIdStr) : undefined;
|
||||
|
||||
@@ -84,7 +85,7 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
||||
);
|
||||
|
||||
const [fromAmount, setFromAmount] = useState('');
|
||||
const [slippage, setSlippage] = useState(0.01); // 1% slippage
|
||||
const [slippage, setSlippage] = useState(isCctp ? 0 : 0.01); // 1% slippage
|
||||
const debouncedAmount = useDebounce<string>(fromAmount, 500);
|
||||
|
||||
// Async Data
|
||||
@@ -99,6 +100,8 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
||||
const debouncedAmountBN = MustBigNumber(debouncedAmount);
|
||||
const balanceBN = MustBigNumber(balance);
|
||||
|
||||
useEffect(() => setSlippage(isCctp ? 0 : 0.01), [isCctp]);
|
||||
|
||||
useEffect(() => {
|
||||
const hasInvalidInput =
|
||||
debouncedAmountBN.isNaN() || debouncedAmountBN.lte(0) || debouncedAmountBN.gt(balanceBN);
|
||||
@@ -250,11 +253,11 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
||||
if (txHash) {
|
||||
addTransferNotification({
|
||||
txHash: txHash,
|
||||
toChainId: ENVIRONMENT_CONFIG_MAP[selectedNetwork].dydxChainId,
|
||||
toChainId: !isCctp ? ENVIRONMENT_CONFIG_MAP[selectedNetwork].dydxChainId : getNobleChainId(),
|
||||
fromChainId: chainIdStr || undefined,
|
||||
toAmount: summary?.usdcSize || undefined,
|
||||
triggeredAt: Date.now(),
|
||||
notificationStatus: NotificationStatus.Triggered,
|
||||
isCctp,
|
||||
});
|
||||
abacusStateManager.clearTransferInputValues();
|
||||
setFromAmount('');
|
||||
|
||||
@@ -109,6 +109,8 @@ export const DepositButtonAndReceipt = ({
|
||||
? stringGetter({ key: STRING_KEYS.HIDE_ALL_DETAILS })
|
||||
: stringGetter({ key: STRING_KEYS.SHOW_ALL_DETAILS });
|
||||
|
||||
const totalFees = (summary?.bridgeFee || 0) + (summary?.gasFee || 0);
|
||||
|
||||
const submitButtonReceipt = [
|
||||
{
|
||||
key: 'equity',
|
||||
@@ -158,9 +160,7 @@ export const DepositButtonAndReceipt = ({
|
||||
{
|
||||
key: 'total-fees',
|
||||
label: <span>{stringGetter({ key: STRING_KEYS.TOTAL_FEES })}</span>,
|
||||
value: typeof summary?.bridgeFee === 'number' && typeof summary?.gasFee === 'number' && (
|
||||
<Output type={OutputType.Fiat} value={summary?.bridgeFee + summary?.gasFee} />
|
||||
),
|
||||
value: <Output type={OutputType.Fiat} value={totalFees} />,
|
||||
subitems: feeSubitems,
|
||||
},
|
||||
{
|
||||
@@ -183,7 +183,12 @@ export const DepositButtonAndReceipt = ({
|
||||
type={OutputType.Text}
|
||||
value={stringGetter({
|
||||
key: STRING_KEYS.X_MINUTES_LOWERCASED,
|
||||
params: { X: Math.round(summary?.estimatedRouteDuration / 60) },
|
||||
params: {
|
||||
X:
|
||||
summary?.estimatedRouteDuration < 60
|
||||
? '< 1'
|
||||
: Math.round(summary?.estimatedRouteDuration / 60),
|
||||
},
|
||||
})}
|
||||
/>
|
||||
),
|
||||
|
||||
@@ -10,7 +10,7 @@ import { AlertType } from '@/constants/alerts';
|
||||
import { ButtonSize } from '@/constants/buttons';
|
||||
import { STRING_KEYS } from '@/constants/localization';
|
||||
import { ENVIRONMENT_CONFIG_MAP } from '@/constants/networks';
|
||||
import { NotificationStatus } from '@/constants/notifications';
|
||||
import { NotificationStatus, TransferNotificationTypes } from '@/constants/notifications';
|
||||
import { NumberSign } from '@/constants/numbers';
|
||||
|
||||
import {
|
||||
@@ -45,6 +45,7 @@ import { getTransferInputs } from '@/state/inputsSelectors';
|
||||
|
||||
import abacusStateManager from '@/lib/abacus';
|
||||
import { MustBigNumber } from '@/lib/numbers';
|
||||
import { getNobleChainId } from '@/lib/squid';
|
||||
|
||||
import { TokenSelectMenu } from './TokenSelectMenu';
|
||||
import { WithdrawButtonAndReceipt } from './WithdrawForm/WithdrawButtonAndReceipt';
|
||||
@@ -58,11 +59,6 @@ export const WithdrawForm = () => {
|
||||
const { sendSquidWithdraw } = useSubaccount();
|
||||
const { freeCollateral } = useSelector(getSubaccount, shallowEqual) || {};
|
||||
|
||||
// User input
|
||||
const [withdrawAmount, setWithdrawAmount] = useState('');
|
||||
const [slippage, setSlippage] = useState(0.01); // 0.1% slippage
|
||||
const debouncedAmount = useDebounce<string>(withdrawAmount, 500);
|
||||
|
||||
const {
|
||||
requestPayload,
|
||||
token,
|
||||
@@ -71,8 +67,15 @@ export const WithdrawForm = () => {
|
||||
resources,
|
||||
errors: routeErrors,
|
||||
errorMessage: routeErrorMessage,
|
||||
isCctp
|
||||
} = useSelector(getTransferInputs, shallowEqual) || {};
|
||||
|
||||
// User input
|
||||
const [withdrawAmount, setWithdrawAmount] = useState('');
|
||||
const [slippage, setSlippage] = useState(isCctp ? 0 : 0.01); // 0.1% slippage
|
||||
const debouncedAmount = useDebounce<string>(withdrawAmount, 500);
|
||||
|
||||
|
||||
const isValidAddress = toAddress && isAddress(toAddress);
|
||||
|
||||
const toToken = useMemo(
|
||||
@@ -89,6 +92,8 @@ export const WithdrawForm = () => {
|
||||
[freeCollateral?.current]
|
||||
);
|
||||
|
||||
useEffect(() => setSlippage(isCctp ? 0 : 0.01), [isCctp]);
|
||||
|
||||
useEffect(() => {
|
||||
abacusStateManager.setTransferValue({
|
||||
field: TransferInputField.type,
|
||||
@@ -163,16 +168,16 @@ export const WithdrawForm = () => {
|
||||
})
|
||||
);
|
||||
} else {
|
||||
const txHash = await sendSquidWithdraw(debouncedAmountBN.toNumber(), requestPayload.data);
|
||||
if (txHash?.hash) {
|
||||
const hash = `0x${Buffer.from(txHash.hash).toString('hex')}`;
|
||||
const txHash = await sendSquidWithdraw(debouncedAmountBN.toNumber(), requestPayload.data, isCctp);
|
||||
if (txHash) {
|
||||
addTransferNotification({
|
||||
txHash: hash,
|
||||
fromChainId: ENVIRONMENT_CONFIG_MAP[selectedNetwork].dydxChainId,
|
||||
txHash: txHash,
|
||||
type: TransferNotificationTypes.Withdrawal,
|
||||
fromChainId: !isCctp ? ENVIRONMENT_CONFIG_MAP[selectedNetwork].dydxChainId : getNobleChainId(),
|
||||
toChainId: chainIdStr || undefined,
|
||||
toAmount: debouncedAmountBN.toNumber(),
|
||||
triggeredAt: Date.now(),
|
||||
notificationStatus: NotificationStatus.Triggered,
|
||||
isCctp,
|
||||
});
|
||||
abacusStateManager.clearTransferInputValues();
|
||||
setWithdrawAmount('');
|
||||
|
||||
@@ -89,14 +89,14 @@ export const WithdrawButtonAndReceipt = ({
|
||||
const showSubitemsToggle = showFeeBreakdown
|
||||
? stringGetter({ key: STRING_KEYS.HIDE_ALL_DETAILS })
|
||||
: stringGetter({ key: STRING_KEYS.SHOW_ALL_DETAILS });
|
||||
|
||||
const totalFees = (summary?.bridgeFee || 0) + (summary?.gasFee || 0);
|
||||
|
||||
const submitButtonReceipt = [
|
||||
{
|
||||
key: 'total-fees',
|
||||
label: <span>{stringGetter({ key: STRING_KEYS.TOTAL_FEES })}</span>,
|
||||
value: typeof summary?.bridgeFee === 'number' && typeof summary?.gasFee === 'number' && (
|
||||
<Output type={OutputType.Fiat} value={summary?.bridgeFee + summary?.gasFee} />
|
||||
),
|
||||
value: <Output type={OutputType.Fiat} value={totalFees} />,
|
||||
subitems: feeSubitems,
|
||||
},
|
||||
{
|
||||
@@ -165,7 +165,12 @@ export const WithdrawButtonAndReceipt = ({
|
||||
type={OutputType.Text}
|
||||
value={stringGetter({
|
||||
key: STRING_KEYS.X_MINUTES_LOWERCASED,
|
||||
params: { X: Math.round(summary?.estimatedRouteDuration / 60) },
|
||||
params: {
|
||||
X:
|
||||
summary?.estimatedRouteDuration < 60
|
||||
? '< 1'
|
||||
: Math.round(summary?.estimatedRouteDuration / 60),
|
||||
},
|
||||
})}
|
||||
/>
|
||||
),
|
||||
|
||||
@@ -206,7 +206,7 @@ export const TradeForm = ({
|
||||
dispatch(setTradeFormInputs({ triggerPriceInput: value }));
|
||||
},
|
||||
value: triggerPriceInput ?? '',
|
||||
decimals: tickSizeDecimals || USD_DECIMALS,
|
||||
decimals: tickSizeDecimals ?? USD_DECIMALS,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ export const TradeForm = ({
|
||||
dispatch(setTradeFormInputs({ limitPriceInput: value }));
|
||||
},
|
||||
value: limitPriceInput,
|
||||
decimals: tickSizeDecimals || USD_DECIMALS,
|
||||
decimals: tickSizeDecimals ?? USD_DECIMALS,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { type Dispatch, type SetStateAction, useCallback, useMemo } from 'react';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import styled, { AnyStyledComponent, css } from 'styled-components';
|
||||
import { Root, Thumb, Track } from '@radix-ui/react-slider';
|
||||
import _ from 'lodash';
|
||||
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||
|
||||
import { type Nullable, TradeInputField } from '@/constants/abacus';
|
||||
import { TradeInputField } from '@/constants/abacus';
|
||||
import { PositionSide } from '@/constants/trade';
|
||||
|
||||
import { MustBigNumber, type BigNumberish } from '@/lib/numbers';
|
||||
@@ -12,11 +12,11 @@ import abacusStateManager from '@/lib/abacus';
|
||||
|
||||
type ElementProps = {
|
||||
leverage?: BigNumberish | null;
|
||||
leverageInputValue: Nullable<number>;
|
||||
leverageInputValue: string;
|
||||
maxLeverage: BigNumberish | null;
|
||||
orderSide: OrderSide;
|
||||
positionSide: PositionSide;
|
||||
setLeverageInputValue: Dispatch<SetStateAction<Nullable<number>>>;
|
||||
setLeverageInputValue: (value: string) => void;
|
||||
};
|
||||
|
||||
type StyleProps = { className?: string };
|
||||
@@ -33,6 +33,7 @@ export const LeverageSlider = ({
|
||||
const leverageBN = MustBigNumber(leverage);
|
||||
const maxLeverageBN = MustBigNumber(maxLeverage);
|
||||
const leverageInputBN = MustBigNumber(leverageInputValue || leverage);
|
||||
const leverageInputNumber = isNaN(leverageInputBN.toNumber()) ? 0 : leverageInputBN.toNumber();
|
||||
|
||||
const sliderConfig = useMemo(
|
||||
() => ({
|
||||
@@ -79,12 +80,12 @@ export const LeverageSlider = ({
|
||||
);
|
||||
|
||||
const onSliderDrag = ([newLeverage]: number[]) => {
|
||||
setLeverageInputValue(newLeverage);
|
||||
setLeverageInputValue(`${newLeverage}`);
|
||||
debouncedSetAbacusLeverage(newLeverage);
|
||||
};
|
||||
|
||||
const onValueCommit = ([newLeverage]: number[]) => {
|
||||
setLeverageInputValue(newLeverage);
|
||||
setLeverageInputValue(`${newLeverage}`);
|
||||
|
||||
// Ensure Abacus is updated with the latest, committed value
|
||||
debouncedSetAbacusLeverage.cancel();
|
||||
@@ -102,7 +103,7 @@ export const LeverageSlider = ({
|
||||
min={min}
|
||||
max={max}
|
||||
step={0.1}
|
||||
value={[Math.min(Math.max(leverageInputBN.toNumber(), min), max)]}
|
||||
value={[Math.min(Math.max(leverageInputNumber, min), max)]}
|
||||
onValueChange={onSliderDrag}
|
||||
onValueCommit={onValueCommit}
|
||||
>
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import type { Dispatch, SetStateAction } from 'react';
|
||||
import { shallowEqual, useSelector } from 'react-redux';
|
||||
import styled, { AnyStyledComponent } from 'styled-components';
|
||||
import { OrderSide } from '@dydxprotocol/v4-client-js';
|
||||
|
||||
import { TradeInputField, Nullable } from '@/constants/abacus';
|
||||
import { TradeInputField } from '@/constants/abacus';
|
||||
import { ButtonShape } from '@/constants/buttons';
|
||||
import { STRING_KEYS } from '@/constants/localization';
|
||||
import { LEVERAGE_DECIMALS } from '@/constants/numbers';
|
||||
@@ -62,21 +61,7 @@ export const MarketLeverageInput = ({
|
||||
|
||||
const leveragePosition = postOrderLeverage ? newPositionSide : currentPositionSide;
|
||||
|
||||
const onLeverageInput = ({ value, floatValue }: { value: string; floatValue?: number }) => {
|
||||
const newLeverage = MustBigNumber(floatValue).toFixed();
|
||||
|
||||
if (value === '' || newLeverage === 'NaN' || !floatValue) {
|
||||
setLeverageInputValue('');
|
||||
abacusStateManager.setTradeValue({
|
||||
value: null,
|
||||
field: TradeInputField.leverage,
|
||||
});
|
||||
} else {
|
||||
updateLeverage(floatValue);
|
||||
}
|
||||
};
|
||||
|
||||
const updateLeverage = (newLeverage: string | number) => {
|
||||
const getSignedLeverage = (newLeverage: string | number) => {
|
||||
const newLeverageBN = MustBigNumber(newLeverage);
|
||||
const newLeverageSignedBN =
|
||||
leveragePosition === PositionSide.Short ||
|
||||
@@ -84,10 +69,33 @@ export const MarketLeverageInput = ({
|
||||
? newLeverageBN.abs().negated()
|
||||
: newLeverageBN.abs();
|
||||
|
||||
setLeverageInputValue(newLeverageSignedBN.toString());
|
||||
return newLeverageSignedBN.toFixed(LEVERAGE_DECIMALS);
|
||||
};
|
||||
|
||||
const onLeverageInput = ({
|
||||
floatValue,
|
||||
formattedValue,
|
||||
}: {
|
||||
floatValue?: number;
|
||||
formattedValue: string;
|
||||
}) => {
|
||||
setLeverageInputValue(formattedValue);
|
||||
const newLeverage = MustBigNumber(floatValue).toFixed();
|
||||
|
||||
abacusStateManager.setTradeValue({
|
||||
value: newLeverageSignedBN.toFixed(LEVERAGE_DECIMALS),
|
||||
value:
|
||||
formattedValue === '' || newLeverage === 'NaN' ? null : getSignedLeverage(formattedValue),
|
||||
field: TradeInputField.leverage,
|
||||
});
|
||||
};
|
||||
|
||||
const updateLeverage = (newLeverage: string | number) => {
|
||||
const newLeverageSigned = getSignedLeverage(newLeverage);
|
||||
|
||||
setLeverageInputValue(newLeverageSigned);
|
||||
|
||||
abacusStateManager.setTradeValue({
|
||||
value: newLeverageSigned,
|
||||
field: TradeInputField.leverage,
|
||||
});
|
||||
};
|
||||
@@ -130,7 +138,7 @@ export const MarketLeverageInput = ({
|
||||
>
|
||||
<Styled.LeverageSlider
|
||||
leverage={currentLeverage}
|
||||
leverageInputValue={leverageInputValue}
|
||||
leverageInputValue={getSignedLeverage(leverageInputValue)}
|
||||
maxLeverage={maxLeverage}
|
||||
orderSide={orderSide}
|
||||
positionSide={currentPositionSide}
|
||||
|
||||
@@ -49,7 +49,7 @@ export const TradeSizeInputs = () => {
|
||||
useSelector(getCurrentMarketConfig, shallowEqual) || {};
|
||||
const { size, usdcSize, leverage, input: lastEditedInput } = inputTradeSizeData || {};
|
||||
const { needsLeverage } = currentTradeInputOptions || {};
|
||||
const decimals = stepSizeDecimals || TOKEN_DECIMALS;
|
||||
const decimals = stepSizeDecimals ?? TOKEN_DECIMALS;
|
||||
|
||||
const { amountInput, usdAmountInput, leverageInput } = useSelector(
|
||||
getTradeFormInputs,
|
||||
@@ -70,22 +70,34 @@ export const TradeSizeInputs = () => {
|
||||
}
|
||||
}, [size, usdcSize, leverage, lastEditedInput]);
|
||||
|
||||
const onSizeInput = ({ value, floatValue }: { value: string; floatValue?: number }) => {
|
||||
dispatch(setTradeFormInputs({ amountInput: value }));
|
||||
const onSizeInput = ({
|
||||
floatValue,
|
||||
formattedValue,
|
||||
}: {
|
||||
floatValue?: number;
|
||||
formattedValue: string;
|
||||
}) => {
|
||||
dispatch(setTradeFormInputs({ amountInput: formattedValue }));
|
||||
const newAmount = MustBigNumber(floatValue).toFixed(decimals);
|
||||
|
||||
abacusStateManager.setTradeValue({
|
||||
value: value === '' || newAmount === 'NaN' ? null : newAmount,
|
||||
value: formattedValue === '' || newAmount === 'NaN' ? null : newAmount,
|
||||
field: TradeInputField.size,
|
||||
});
|
||||
};
|
||||
|
||||
const onUSDCInput = ({ value, floatValue }: { value: string; floatValue?: number }) => {
|
||||
dispatch(setTradeFormInputs({ usdAmountInput: value }));
|
||||
const newUsdcAmount = MustBigNumber(floatValue).toFixed();
|
||||
const onUSDCInput = ({
|
||||
floatValue,
|
||||
formattedValue,
|
||||
}: {
|
||||
floatValue?: number;
|
||||
formattedValue: string;
|
||||
}) => {
|
||||
dispatch(setTradeFormInputs({ usdAmountInput: formattedValue }));
|
||||
const newUsdcAmount = MustBigNumber(floatValue).toFixed(tickSizeDecimals || USD_DECIMALS);
|
||||
|
||||
abacusStateManager.setTradeValue({
|
||||
value: value === '' || newUsdcAmount === 'NaN' ? null : newUsdcAmount,
|
||||
value: formattedValue === '' || newUsdcAmount === 'NaN' ? null : newUsdcAmount,
|
||||
field: TradeInputField.usdcSize,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -12,10 +12,11 @@ import { LoadingSpinner } from '@/components/Loading/LoadingSpinner';
|
||||
import { layoutMixins } from '@/styles/layoutMixins';
|
||||
import { STRING_KEYS } from '@/constants/localization';
|
||||
import { ENVIRONMENT_CONFIG_MAP } from '@/constants/networks';
|
||||
import { TransferNotificationTypes } from '@/constants/notifications';
|
||||
|
||||
type ElementProps = {
|
||||
status?: StatusResponse;
|
||||
type: 'withdrawal' | 'deposit';
|
||||
type: TransferNotificationTypes;
|
||||
};
|
||||
|
||||
type StyleProps = {
|
||||
@@ -46,11 +47,13 @@ export const TransferStatusSteps = ({ className, status, type }: ElementProps &
|
||||
{
|
||||
label: stringGetter({
|
||||
key:
|
||||
type === 'deposit' ? STRING_KEYS.INITIATED_DEPOSIT : STRING_KEYS.INITIATED_WITHDRAWAL,
|
||||
type === TransferNotificationTypes.Deposit
|
||||
? STRING_KEYS.INITIATED_DEPOSIT
|
||||
: STRING_KEYS.INITIATED_WITHDRAWAL,
|
||||
}),
|
||||
step: TransferStatusStep.FromChain,
|
||||
link:
|
||||
type === 'deposit'
|
||||
link:
|
||||
type === TransferNotificationTypes.Deposit
|
||||
? status?.fromChain?.transactionUrl
|
||||
: routeStatus?.[0]?.chainId === dydxChainId && routeStatus[0].txHash
|
||||
? `${mintscanTxUrl?.replace('{tx_hash}', routeStatus[0].txHash.replace('0x', ''))}`
|
||||
@@ -63,14 +66,20 @@ export const TransferStatusSteps = ({ className, status, type }: ElementProps &
|
||||
},
|
||||
{
|
||||
label: stringGetter({
|
||||
key: type === 'deposit' ? STRING_KEYS.DEPOSIT_TO_CHAIN : STRING_KEYS.WITHDRAW_TO_CHAIN,
|
||||
key:
|
||||
type === TransferNotificationTypes.Deposit
|
||||
? STRING_KEYS.DEPOSIT_TO_CHAIN
|
||||
: STRING_KEYS.WITHDRAW_TO_CHAIN,
|
||||
params: {
|
||||
CHAIN: type === 'deposit' ? 'dYdX' : status?.toChain?.chainData?.chainName,
|
||||
CHAIN:
|
||||
type === TransferNotificationTypes.Deposit
|
||||
? 'dYdX'
|
||||
: status?.toChain?.chainData?.chainName,
|
||||
},
|
||||
}),
|
||||
step: TransferStatusStep.ToChain,
|
||||
link:
|
||||
type === 'withdrawal'
|
||||
type === TransferNotificationTypes.Withdrawal
|
||||
? status?.toChain?.transactionUrl
|
||||
: currentStatus?.chainId === dydxChainId && currentStatus?.txHash
|
||||
? `${mintscanTxUrl?.replace('{tx_hash}', currentStatus.txHash.replace('0x', ''))}`
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useInterval, useStringGetter } from '@/hooks';
|
||||
|
||||
import { AlertType } from '@/constants/alerts';
|
||||
import { STRING_KEYS } from '@/constants/localization';
|
||||
import { TransferNotifcation } from '@/constants/notifications';
|
||||
import { TransferNotifcation, TransferNotificationTypes } from '@/constants/notifications';
|
||||
|
||||
import { formatSeconds } from '@/lib/timeUtils';
|
||||
|
||||
@@ -22,7 +22,7 @@ import { layoutMixins } from '@/styles/layoutMixins';
|
||||
import { TransferStatusSteps } from './TransferStatusSteps';
|
||||
|
||||
type ElementProps = {
|
||||
type: 'withdrawal' | 'deposit';
|
||||
type: TransferNotificationTypes;
|
||||
transfer: TransferNotifcation;
|
||||
triggeredAt?: number;
|
||||
};
|
||||
@@ -44,6 +44,7 @@ export const TransferStatusNotification = ({
|
||||
|
||||
// @ts-ignore status.errors is not in the type definition but can be returned
|
||||
const error = status?.errors?.length ? status?.errors[0] : status?.error;
|
||||
const hasError = error && Object.keys(error).length !== 0;
|
||||
|
||||
const updateSecondsLeft = useCallback(() => {
|
||||
const fromChainEta = (status?.fromChain?.chainData?.estimatedRouteDuration || 0) * 1000;
|
||||
@@ -54,7 +55,7 @@ export const TransferStatusNotification = ({
|
||||
useInterval({ callback: updateSecondsLeft });
|
||||
|
||||
const inProgressStatusString =
|
||||
type === 'deposit'
|
||||
type === TransferNotificationTypes.Deposit
|
||||
? secondsLeft > 0
|
||||
? STRING_KEYS.DEPOSIT_STATUS
|
||||
: STRING_KEYS.DEPOSIT_STATUS_SHORTLY
|
||||
@@ -63,7 +64,7 @@ export const TransferStatusNotification = ({
|
||||
: STRING_KEYS.WITHDRAW_STATUS_SHORTLY;
|
||||
|
||||
const statusString =
|
||||
type === 'deposit'
|
||||
type === TransferNotificationTypes.Deposit
|
||||
? status?.squidTransactionStatus === 'success'
|
||||
? STRING_KEYS.DEPOSIT_COMPLETE
|
||||
: inProgressStatusString
|
||||
@@ -87,7 +88,7 @@ export const TransferStatusNotification = ({
|
||||
},
|
||||
})}
|
||||
</Styled.Status>
|
||||
{error && (
|
||||
{hasError && (
|
||||
<AlertMessage type={AlertType.Error}>
|
||||
{stringGetter({
|
||||
key: STRING_KEYS.SOMETHING_WENT_WRONG_WITH_MESSAGE,
|
||||
@@ -112,7 +113,7 @@ export const TransferStatusNotification = ({
|
||||
) : (
|
||||
<Styled.BridgingStatus>
|
||||
{content}
|
||||
{!isToast && status?.squidTransactionStatus !== 'success' && (
|
||||
{!isToast && status?.squidTransactionStatus !== 'success' && !hasError && (
|
||||
<Styled.TransferStatusSteps status={status} type={type} />
|
||||
)}
|
||||
</Styled.BridgingStatus>
|
||||
@@ -120,8 +121,7 @@ export const TransferStatusNotification = ({
|
||||
}
|
||||
slotAction={
|
||||
isToast &&
|
||||
status &&
|
||||
!error && (
|
||||
status && (
|
||||
<Styled.Trigger
|
||||
isOpen={open}
|
||||
onClick={(e: MouseEvent) => {
|
||||
|
||||
@@ -42,7 +42,11 @@ type StyleProps = {
|
||||
className?: string;
|
||||
};
|
||||
|
||||
type RowData = OrderbookLine & { side: 'bid' | 'ask'; mine?: number };
|
||||
type RowData = Pick<OrderbookLine, 'depth' | 'offset' | 'price' | 'size'> & {
|
||||
side: 'bid' | 'ask';
|
||||
mine?: number;
|
||||
key: string;
|
||||
};
|
||||
|
||||
const useCalculateOrderbookData = ({ maxRowsPerSide }: { maxRowsPerSide: number }) => {
|
||||
const orderbook = useSelector(getCurrentMarketOrderbook, shallowEqual);
|
||||
@@ -53,8 +57,9 @@ const useCalculateOrderbookData = ({ maxRowsPerSide }: { maxRowsPerSide: number
|
||||
return useMemo(() => {
|
||||
const asks = (orderbook?.asks?.toArray() ?? [])
|
||||
.map(
|
||||
(row: OrderbookLine) =>
|
||||
(row: OrderbookLine, idx: number) =>
|
||||
({
|
||||
key: `ask-${idx}`,
|
||||
side: 'ask',
|
||||
mine: openOrdersBySideAndPrice[OrderSide.SELL]?.[row.price]?.size,
|
||||
...row,
|
||||
@@ -64,8 +69,9 @@ const useCalculateOrderbookData = ({ maxRowsPerSide }: { maxRowsPerSide: number
|
||||
|
||||
const bids = (orderbook?.bids?.toArray() ?? [])
|
||||
.map(
|
||||
(row: OrderbookLine) =>
|
||||
(row: OrderbookLine, idx: number) =>
|
||||
({
|
||||
key: `bid-${idx}`,
|
||||
side: 'bid',
|
||||
mine: openOrdersBySideAndPrice[OrderSide.BUY]?.[row.price]?.size,
|
||||
...row,
|
||||
@@ -97,15 +103,44 @@ const useCalculateOrderbookData = ({ maxRowsPerSide }: { maxRowsPerSide: number
|
||||
}
|
||||
|
||||
const spread =
|
||||
asks[0] && bids[0] ? MustBigNumber(asks[0]?.price ?? 0).minus(bids[0]?.price ?? 0) : null;
|
||||
asks[0]?.price && bids[0]?.price ? MustBigNumber(asks[0].price).minus(bids[0].price) : null;
|
||||
|
||||
const spreadPercent = orderbook?.spreadPercent;
|
||||
|
||||
const histogramRange = Math.max(
|
||||
Number(bids[bids.length - 1]?.depth),
|
||||
Number(asks[asks.length - 1]?.depth)
|
||||
isNaN(Number(bids[bids.length - 1]?.depth)) ? 0 : Number(bids[bids.length - 1]?.depth),
|
||||
isNaN(Number(asks[asks.length - 1]?.depth)) ? 0 : Number(asks[asks.length - 1]?.depth)
|
||||
);
|
||||
|
||||
// Ensure asks and bids are of length maxRowsPerSide by adding empty rows.
|
||||
let idx = asks.length - 1;
|
||||
while (asks.length < maxRowsPerSide) {
|
||||
idx += 1;
|
||||
|
||||
asks.push({
|
||||
key: `ask-${idx}`,
|
||||
side: 'ask',
|
||||
size: 0,
|
||||
price: 0,
|
||||
offset: 0,
|
||||
depth: 0,
|
||||
});
|
||||
}
|
||||
|
||||
idx = bids.length - 1;
|
||||
while (bids.length < maxRowsPerSide) {
|
||||
idx += 1;
|
||||
|
||||
bids.push({
|
||||
key: `bid-${idx}`,
|
||||
side: 'bid',
|
||||
size: 0,
|
||||
price: 0,
|
||||
offset: 0,
|
||||
depth: 0,
|
||||
});
|
||||
}
|
||||
|
||||
return { asks, bids, spread, spreadPercent, histogramRange, hasOrderbook: !!orderbook };
|
||||
}, [orderbook, openOrdersBySideAndPrice]);
|
||||
};
|
||||
@@ -142,31 +177,33 @@ const OrderbookTable = ({
|
||||
getCellValue: (row: RowData) => row.size,
|
||||
label: stringGetter({ key: STRING_KEYS.ORDERBOOK_ORDER_SIZE }),
|
||||
tag: symbol,
|
||||
renderCell: (row: RowData) => (
|
||||
<Styled.HistogramOutput
|
||||
highlightText
|
||||
type={OutputType.Asset}
|
||||
value={row.size}
|
||||
fractionDigits={stepSizeDecimals}
|
||||
histogramSide={histogramSide === 'left' && 'left'}
|
||||
useGrouping={false}
|
||||
/>
|
||||
),
|
||||
renderCell: (row: RowData) =>
|
||||
row.size > 0 && (
|
||||
<Styled.HistogramOutput
|
||||
highlightText
|
||||
type={OutputType.Asset}
|
||||
value={row.size}
|
||||
fractionDigits={stepSizeDecimals}
|
||||
histogramSide={histogramSide === 'left' && 'left'}
|
||||
useGrouping={false}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
columnKey: 'price',
|
||||
getCellValue: (row: RowData) => row.price,
|
||||
label: stringGetter({ key: STRING_KEYS.PRICE }),
|
||||
tag: 'USD',
|
||||
renderCell: (row: RowData) => (
|
||||
<OrderbookTradesOutput
|
||||
highlightText
|
||||
type={OutputType.Number}
|
||||
value={row.price}
|
||||
fractionDigits={tickSizeDecimals}
|
||||
useGrouping={false}
|
||||
/>
|
||||
),
|
||||
renderCell: (row: RowData) =>
|
||||
row.price > 0 && (
|
||||
<OrderbookTradesOutput
|
||||
highlightText
|
||||
type={OutputType.Number}
|
||||
value={row.price}
|
||||
fractionDigits={tickSizeDecimals}
|
||||
useGrouping={false}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
columnKey: 'subaccount-orders',
|
||||
@@ -194,12 +231,13 @@ const OrderbookTable = ({
|
||||
label="Orderbook"
|
||||
data={data}
|
||||
columns={columns}
|
||||
getRowKey={(row: RowData) => `${row.side}-${row.price}`}
|
||||
getRowKey={(row: RowData) => row.key}
|
||||
getRowAttributes={(row: RowData) => ({
|
||||
'data-side': row.side,
|
||||
style: {
|
||||
'--histogram-bucket-size': row.size,
|
||||
'--histogram-bucket-depth': row.depth,
|
||||
'--tr-pointerEvents': row.price ? 'auto' : 'none',
|
||||
},
|
||||
})}
|
||||
onRowAction={onRowAction}
|
||||
@@ -238,19 +276,10 @@ export const Orderbook = ({
|
||||
maxRowsPerSide,
|
||||
});
|
||||
|
||||
const [showRowsPerSide, setShowRowsPerSide] = useState(0);
|
||||
|
||||
// Make rows visible one by one so avoid jumps in initial scroll position
|
||||
useEffect(() => {
|
||||
if (showRowsPerSide < maxRowsPerSide) {
|
||||
setShowRowsPerSide((showRows) => showRows + 1);
|
||||
}
|
||||
}, [showRowsPerSide]);
|
||||
|
||||
const data = useMemo(
|
||||
() =>
|
||||
[
|
||||
...bids.slice(0, showRowsPerSide).reverse(),
|
||||
...bids.reverse(),
|
||||
{
|
||||
key: 'spread',
|
||||
slotCustomRow: (props) => (
|
||||
@@ -267,9 +296,9 @@ export const Orderbook = ({
|
||||
</Styled.SpreadTableRow>
|
||||
),
|
||||
} as CustomRowConfig,
|
||||
...asks.slice(0, showRowsPerSide),
|
||||
...asks,
|
||||
].reverse(),
|
||||
[asks, bids, spread, spreadPercent, showRowsPerSide, isTablet]
|
||||
[asks, bids, spread, spreadPercent, isTablet]
|
||||
);
|
||||
|
||||
const onRowAction = useCallback(
|
||||
@@ -325,7 +354,7 @@ export const Orderbook = ({
|
||||
</Styled.Header>
|
||||
<Styled.SplitOrderbook>
|
||||
<OrderbookTable data={asks} histogramSide="right" {...orderbookTableProps} />
|
||||
<OrderbookTable data={bids} histogramSide="left" {...orderbookTableProps} />
|
||||
<OrderbookTable data={bids.reverse()} histogramSide="left" {...orderbookTableProps} />
|
||||
</Styled.SplitOrderbook>
|
||||
</Styled.HorizontalLayout>
|
||||
);
|
||||
@@ -495,6 +524,7 @@ Styled.OrderbookTable = styled(OrderbookTradesTable)<StyleProps>`
|
||||
|
||||
tr {
|
||||
--histogram-bucket-depth: 0;
|
||||
pointer-events: var(--tr-pointerEvents);
|
||||
|
||||
&[data-side='bid'] {
|
||||
--accent-color: var(--color-positive);
|
||||
|
||||
Reference in New Issue
Block a user