@rainlanguage/ui-components 0.0.1-alpha.237 → 0.0.1-alpha.239
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -6
- package/dist/__fixtures__/settings.yaml +18 -20
- package/dist/__mocks__/MockCodeMirrorEditor.svelte +17 -0
- package/dist/__mocks__/MockCodeMirrorEditor.svelte.d.ts +21 -0
- package/dist/__mocks__/MockComponent.js +1 -1
- package/dist/__mocks__/MockComponent.svelte +7 -3
- package/dist/__mocks__/MockComponent.svelte.d.ts +1 -0
- package/dist/__mocks__/mockWeb3Config.d.ts +1 -1
- package/dist/__mocks__/mockWeb3Config.js +10 -7
- package/dist/__mocks__/queries.js +9 -9
- package/dist/__mocks__/stores.d.ts +4 -4
- package/dist/__mocks__/stores.js +40 -40
- package/dist/app.css +3 -3
- package/dist/components/ButtonDarkMode.svelte +7 -1
- package/dist/components/ButtonScrub.svelte +22 -0
- package/dist/components/ButtonScrub.svelte.d.ts +25 -0
- package/dist/components/ButtonVaultLink.svelte +3 -2
- package/dist/components/ButtonVaultLink.svelte.d.ts +2 -2
- package/dist/components/CodeMirrorRainlang.svelte +19 -2
- package/dist/components/CodeMirrorRainlang.svelte.d.ts +2 -1
- package/dist/components/Hash.svelte +3 -2
- package/dist/components/{ListViewOrderbookFilters.svelte → ListViewRaindexFilters.svelte} +7 -7
- package/dist/components/{ListViewOrderbookFilters.svelte.d.ts → ListViewRaindexFilters.svelte.d.ts} +7 -7
- package/dist/components/LocalDbStatusBadge.svelte.d.ts +1 -1
- package/dist/components/LocalDbStatusCard.svelte +7 -4
- package/dist/components/LocalDbStatusCard.svelte.d.ts +2 -2
- package/dist/components/LocalDbStatusModal.svelte +16 -14
- package/dist/components/LocalDbStatusModal.svelte.d.ts +2 -2
- package/dist/components/OrderOrVaultHash.svelte +2 -2
- package/dist/components/OrderOrVaultHash.svelte.d.ts +2 -2
- package/dist/components/Sensitive.svelte +16 -0
- package/dist/components/Sensitive.svelte.d.ts +28 -0
- package/dist/components/TanstackAppTable.svelte +146 -87
- package/dist/components/TanstackAppTable.svelte.d.ts +1 -1
- package/dist/components/VaultBalanceChangeTypeFilter.svelte +1 -1
- package/dist/components/VaultBalanceChangeTypeFilter.svelte.d.ts +1 -1
- package/dist/components/VaultCard.svelte +1 -1
- package/dist/components/VaultCard.svelte.d.ts +1 -1
- package/dist/components/charts/OrderTradesChart.svelte +116 -97
- package/dist/components/charts/OrderTradesChart.svelte.d.ts +2 -2
- package/dist/components/charts/transformAndSortData.d.ts +1 -1
- package/dist/components/charts/transformAndSortData.js +19 -19
- package/dist/components/deployment/DeploymentSteps.svelte +5 -2
- package/dist/components/deployment/DeploymentSteps.svelte.d.ts +1 -1
- package/dist/components/deployment/DeploymentsSection.svelte.d.ts +1 -1
- package/dist/components/deployment/DepositInput.svelte +1 -1
- package/dist/components/deployment/DepositInput.svelte.d.ts +1 -1
- package/dist/components/deployment/FieldDefinitionInput.svelte +1 -1
- package/dist/components/deployment/FieldDefinitionInput.svelte.d.ts +1 -1
- package/dist/components/deployment/OrderPage.svelte.d.ts +1 -1
- package/dist/components/deployment/SelectToken.svelte.d.ts +1 -1
- package/dist/components/deployment/TokenIOInput.svelte +1 -1
- package/dist/components/deployment/TokenIOInput.svelte.d.ts +1 -1
- package/dist/components/deployment/TokenSelectionModal.svelte.d.ts +1 -1
- package/dist/components/detail/OrderDetail.svelte +12 -6
- package/dist/components/detail/OrderDetail.svelte.d.ts +2 -2
- package/dist/components/detail/TanstackOrderQuote.svelte +22 -0
- package/dist/components/detail/TanstackOrderQuote.svelte.d.ts +1 -1
- package/dist/components/detail/VaultDetail.svelte +12 -10
- package/dist/components/detail/VaultDetail.svelte.d.ts +2 -2
- package/dist/components/dropdown/{DropdownOrderbooksFilter.svelte → DropdownRaindexesFilter.svelte} +54 -54
- package/dist/components/dropdown/DropdownRaindexesFilter.svelte.d.ts +25 -0
- package/dist/components/dropdown/DropdownTokensFilter.svelte.d.ts +1 -1
- package/dist/components/icon/Refresh.svelte +2 -1
- package/dist/components/icon/Refresh.svelte.d.ts +1 -0
- package/dist/components/input/InputTokenAmount.svelte +16 -1
- package/dist/components/input/InputTokenAmount.svelte.d.ts +1 -1
- package/dist/components/tables/OrderTradesListTable.svelte +113 -98
- package/dist/components/tables/OrderTradesListTable.svelte.d.ts +1 -1
- package/dist/components/tables/OrderVaultsVolTable.svelte +1 -1
- package/dist/components/tables/OrderVaultsVolTable.svelte.d.ts +1 -1
- package/dist/components/tables/OrdersListTable.svelte +19 -17
- package/dist/components/tables/OrdersListTable.svelte.d.ts +1 -1
- package/dist/components/tables/VaultBalanceChangesTable.svelte +1 -1
- package/dist/components/tables/VaultBalanceChangesTable.svelte.d.ts +1 -1
- package/dist/components/tables/VaultsListTable.svelte +24 -21
- package/dist/components/tables/VaultsListTable.svelte.d.ts +2 -2
- package/dist/components/transactions/FixedBottomTransaction.svelte +1 -0
- package/dist/components/transactions/getStatusEmoji.d.ts +1 -1
- package/dist/components/transactions/getStatusEmoji.js +13 -13
- package/dist/consts.js +1 -1
- package/dist/errors/DeploymentStepsError.js +3 -3
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/hooks/useLocalDb.d.ts +1 -1
- package/dist/hooks/useLocalDb.js +3 -3
- package/dist/hooks/useRaindexClient.d.ts +1 -1
- package/dist/hooks/useRaindexClient.js +4 -4
- package/dist/hooks/useRaindexOrderBuilder.d.ts +1 -1
- package/dist/hooks/useRaindexOrderBuilder.js +4 -4
- package/dist/index.d.ts +122 -114
- package/dist/index.js +115 -109
- package/dist/models/Transaction.d.ts +4 -4
- package/dist/models/Transaction.js +9 -9
- package/dist/providers/RaindexClientProvider.svelte +1 -1
- package/dist/providers/RaindexClientProvider.svelte.d.ts +1 -1
- package/dist/providers/RaindexOrderBuilderProvider.svelte +1 -1
- package/dist/providers/RaindexOrderBuilderProvider.svelte.d.ts +1 -1
- package/dist/providers/dotrainRegistry/DotrainRegistryProvider.svelte.d.ts +1 -1
- package/dist/providers/dotrainRegistry/context.d.ts +2 -2
- package/dist/providers/dotrainRegistry/context.js +13 -10
- package/dist/providers/dotrainRegistry/useDotrainRegistry.d.ts +1 -1
- package/dist/providers/dotrainRegistry/useDotrainRegistry.js +8 -8
- package/dist/providers/registry/RegistryManager.js +8 -7
- package/dist/providers/registry/context.d.ts +1 -1
- package/dist/providers/registry/context.js +9 -9
- package/dist/providers/registry/useRegistry.d.ts +1 -1
- package/dist/providers/registry/useRegistry.js +5 -5
- package/dist/providers/toasts/context.d.ts +2 -2
- package/dist/providers/toasts/context.js +4 -4
- package/dist/providers/toasts/useToasts.d.ts +1 -1
- package/dist/providers/toasts/useToasts.js +4 -4
- package/dist/providers/transactions/TransactionManager.d.ts +14 -15
- package/dist/providers/transactions/TransactionManager.js +107 -107
- package/dist/providers/transactions/context.d.ts +1 -1
- package/dist/providers/transactions/context.js +4 -4
- package/dist/providers/transactions/useTransactions.js +2 -2
- package/dist/providers/wallet/context.d.ts +1 -1
- package/dist/providers/wallet/context.js +11 -11
- package/dist/providers/wallet/useAccount.js +27 -27
- package/dist/queries/keys.js +10 -10
- package/dist/queries/queryClient.d.ts +1 -1
- package/dist/queries/queryClient.js +8 -8
- package/dist/services/awaitTransactionIndexing.d.ts +8 -8
- package/dist/services/awaitTransactionIndexing.js +10 -8
- package/dist/services/getExplorerLink.js +2 -2
- package/dist/services/handleShareChoices.d.ts +1 -1
- package/dist/services/handleShareChoices.js +4 -4
- package/dist/services/historicalOrderCharts.d.ts +2 -2
- package/dist/services/historicalOrderCharts.js +260 -201
- package/dist/services/index.d.ts +5 -3
- package/dist/services/index.js +3 -2
- package/dist/services/loadRegistryUrl.d.ts +1 -1
- package/dist/services/loadRegistryUrl.js +5 -5
- package/dist/services/pairTradesChartData.d.ts +2 -2
- package/dist/services/pairTradesChartData.js +28 -24
- package/dist/services/registry.d.ts +1 -1
- package/dist/services/registry.js +10 -10
- package/dist/services/time.d.ts +1 -1
- package/dist/services/time.js +35 -35
- package/dist/services/validateAmount.d.ts +30 -0
- package/dist/services/validateAmount.js +53 -0
- package/dist/storesGeneric/cachedWritableStore.d.ts +2 -2
- package/dist/storesGeneric/cachedWritableStore.js +3 -3
- package/dist/storesGeneric/scrub.d.ts +14 -0
- package/dist/storesGeneric/scrub.js +22 -0
- package/dist/test/matchers.d.ts +2 -2
- package/dist/test/matchers.js +2 -2
- package/dist/types/account.d.ts +2 -2
- package/dist/types/appStores.d.ts +3 -3
- package/dist/types/modal.d.ts +3 -3
- package/dist/types/order.d.ts +1 -1
- package/dist/types/toast.d.ts +2 -2
- package/dist/types/tokenBalance.d.ts +1 -1
- package/dist/types/transaction.d.ts +4 -4
- package/dist/utils/breadcrumbs.js +2 -2
- package/dist/utils/codeMirrorThemes.js +80 -74
- package/dist/utils/configHelpers.d.ts +1 -1
- package/dist/utils/configHelpers.js +6 -6
- package/dist/utils/constructHashLink.d.ts +3 -3
- package/dist/utils/constructHashLink.js +39 -37
- package/dist/utils/getNetworkName.js +5 -5
- package/dist/utils/hex.js +1 -1
- package/dist/utils/lightweightChartsThemes.d.ts +1 -1
- package/dist/utils/lightweightChartsThemes.js +11 -11
- package/dist/utils/localDbStatus.d.ts +26 -0
- package/dist/utils/localDbStatus.js +22 -0
- package/dist/utils/number.js +5 -3
- package/dist/utils/stripTrailingWhitespace.d.ts +16 -0
- package/dist/utils/stripTrailingWhitespace.js +22 -0
- package/dist/utils/tokens.d.ts +1 -1
- package/dist/utils/tokens.js +1 -1
- package/dist/utils/vaultBalanceChangeLabels.d.ts +1 -1
- package/dist/utils/vaultBalanceChangeLabels.js +11 -11
- package/package.json +89 -89
- package/dist/components/dropdown/DropdownOrderbooksFilter.svelte.d.ts +0 -25
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { timestampSecondsToUTCTimestamp } from
|
|
2
|
-
import { sortBy } from
|
|
1
|
+
import { timestampSecondsToUTCTimestamp } from "../services/time";
|
|
2
|
+
import { sortBy } from "lodash";
|
|
3
3
|
export function prepareHistoricalOrderChartData(takeOrderEntities, colorTheme) {
|
|
4
4
|
const transformedData = takeOrderEntities.map((d) => ({
|
|
5
5
|
value: Math.abs(Number(d.inputVaultBalanceChange.formattedAmount) /
|
|
6
6
|
Number(d.outputVaultBalanceChange.formattedAmount)),
|
|
7
7
|
time: timestampSecondsToUTCTimestamp(BigInt(d.timestamp)),
|
|
8
|
-
color: colorTheme ==
|
|
9
|
-
outputAmount: Number(d.outputVaultBalanceChange.amount)
|
|
8
|
+
color: colorTheme == "dark" ? "#5178FF" : "#4E4AF6",
|
|
9
|
+
outputAmount: Number(d.outputVaultBalanceChange.amount),
|
|
10
10
|
}));
|
|
11
11
|
// if we have multiple object in the array with the same timestamp, we need to merge them
|
|
12
12
|
// we do this by taking the weighted average of the ioratio values for objects that share the same timestamp.
|
|
@@ -22,7 +22,7 @@ export function prepareHistoricalOrderChartData(takeOrderEntities, colorTheme) {
|
|
|
22
22
|
finalData.push({
|
|
23
23
|
value: ioratioAverage,
|
|
24
24
|
time: timestamp,
|
|
25
|
-
color: objectsWithSameTimestamp[0].color
|
|
25
|
+
color: objectsWithSameTimestamp[0].color,
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
@@ -33,196 +33,196 @@ export function prepareHistoricalOrderChartData(takeOrderEntities, colorTheme) {
|
|
|
33
33
|
}
|
|
34
34
|
if (import.meta.vitest) {
|
|
35
35
|
const { it, expect } = import.meta.vitest;
|
|
36
|
-
it(
|
|
36
|
+
it("transforms and sorts data as expected", () => {
|
|
37
37
|
const takeOrderEntities = [
|
|
38
38
|
{
|
|
39
|
-
id:
|
|
39
|
+
id: "1",
|
|
40
40
|
timestamp: BigInt(1632000000),
|
|
41
41
|
transaction: {
|
|
42
|
-
id:
|
|
43
|
-
from:
|
|
42
|
+
id: "transaction_id",
|
|
43
|
+
from: "0xsender_address",
|
|
44
44
|
timestamp: BigInt(1632000000),
|
|
45
|
-
blockNumber: BigInt(0)
|
|
45
|
+
blockNumber: BigInt(0),
|
|
46
46
|
},
|
|
47
47
|
outputVaultBalanceChange: {
|
|
48
48
|
amount: BigInt(100),
|
|
49
|
-
formattedAmount:
|
|
49
|
+
formattedAmount: "100",
|
|
50
50
|
vaultId: BigInt(1),
|
|
51
|
-
__typename:
|
|
51
|
+
__typename: "Withdraw",
|
|
52
52
|
token: {
|
|
53
|
-
id:
|
|
54
|
-
address:
|
|
55
|
-
name:
|
|
56
|
-
symbol:
|
|
57
|
-
decimals: BigInt(1)
|
|
53
|
+
id: "output_token",
|
|
54
|
+
address: "0xoutput_token",
|
|
55
|
+
name: "output_token",
|
|
56
|
+
symbol: "output_token",
|
|
57
|
+
decimals: BigInt(1),
|
|
58
58
|
},
|
|
59
59
|
newBalance: BigInt(0),
|
|
60
|
-
formattedNewBalance:
|
|
60
|
+
formattedNewBalance: "0",
|
|
61
61
|
oldBalance: BigInt(0),
|
|
62
|
-
formattedOldBalance:
|
|
62
|
+
formattedOldBalance: "0",
|
|
63
63
|
timestamp: BigInt(0),
|
|
64
64
|
transaction: {
|
|
65
|
-
id:
|
|
66
|
-
from:
|
|
65
|
+
id: "transaction_id",
|
|
66
|
+
from: "sender_address",
|
|
67
67
|
timestamp: BigInt(1632000000),
|
|
68
|
-
blockNumber: BigInt(0)
|
|
68
|
+
blockNumber: BigInt(0),
|
|
69
69
|
},
|
|
70
|
-
|
|
70
|
+
raindex: "0x1",
|
|
71
71
|
},
|
|
72
|
-
orderHash:
|
|
72
|
+
orderHash: "orderHash",
|
|
73
73
|
inputVaultBalanceChange: {
|
|
74
74
|
vaultId: BigInt(1),
|
|
75
75
|
token: {
|
|
76
|
-
id:
|
|
77
|
-
address:
|
|
78
|
-
name:
|
|
79
|
-
symbol:
|
|
80
|
-
decimals: BigInt(1)
|
|
76
|
+
id: "output_token",
|
|
77
|
+
address: "0xoutput_token",
|
|
78
|
+
name: "output_token",
|
|
79
|
+
symbol: "output_token",
|
|
80
|
+
decimals: BigInt(1),
|
|
81
81
|
},
|
|
82
82
|
amount: BigInt(50),
|
|
83
|
-
formattedAmount:
|
|
84
|
-
__typename:
|
|
83
|
+
formattedAmount: "50",
|
|
84
|
+
__typename: "Withdraw",
|
|
85
85
|
newBalance: BigInt(0),
|
|
86
|
-
formattedNewBalance:
|
|
86
|
+
formattedNewBalance: "0",
|
|
87
87
|
oldBalance: BigInt(0),
|
|
88
|
-
formattedOldBalance:
|
|
88
|
+
formattedOldBalance: "0",
|
|
89
89
|
timestamp: BigInt(0),
|
|
90
90
|
transaction: {
|
|
91
|
-
id:
|
|
92
|
-
from:
|
|
91
|
+
id: "transaction_id",
|
|
92
|
+
from: "0xsender_address",
|
|
93
93
|
timestamp: BigInt(1632000000),
|
|
94
|
-
blockNumber: BigInt(0)
|
|
94
|
+
blockNumber: BigInt(0),
|
|
95
95
|
},
|
|
96
|
-
|
|
96
|
+
raindex: "0x1",
|
|
97
97
|
},
|
|
98
|
-
|
|
98
|
+
raindex: "0x00",
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
|
-
id:
|
|
101
|
+
id: "2",
|
|
102
102
|
timestamp: BigInt(1631000000),
|
|
103
103
|
transaction: {
|
|
104
|
-
id:
|
|
105
|
-
from:
|
|
104
|
+
id: "transaction_id",
|
|
105
|
+
from: "0xsender_address",
|
|
106
106
|
timestamp: BigInt(1631000000),
|
|
107
|
-
blockNumber: BigInt(0)
|
|
107
|
+
blockNumber: BigInt(0),
|
|
108
108
|
},
|
|
109
109
|
outputVaultBalanceChange: {
|
|
110
110
|
amount: BigInt(100),
|
|
111
|
-
formattedAmount:
|
|
111
|
+
formattedAmount: "100",
|
|
112
112
|
vaultId: BigInt(1),
|
|
113
113
|
token: {
|
|
114
|
-
id:
|
|
115
|
-
address:
|
|
116
|
-
name:
|
|
117
|
-
symbol:
|
|
118
|
-
decimals: BigInt(1)
|
|
114
|
+
id: "output_token",
|
|
115
|
+
address: "0xoutput_token",
|
|
116
|
+
name: "output_token",
|
|
117
|
+
symbol: "output_token",
|
|
118
|
+
decimals: BigInt(1),
|
|
119
119
|
},
|
|
120
120
|
newBalance: BigInt(0),
|
|
121
|
-
formattedNewBalance:
|
|
121
|
+
formattedNewBalance: "0",
|
|
122
122
|
oldBalance: BigInt(0),
|
|
123
|
-
formattedOldBalance:
|
|
124
|
-
__typename:
|
|
123
|
+
formattedOldBalance: "0",
|
|
124
|
+
__typename: "Withdraw",
|
|
125
125
|
timestamp: BigInt(0),
|
|
126
126
|
transaction: {
|
|
127
|
-
id:
|
|
128
|
-
from:
|
|
127
|
+
id: "transaction_id",
|
|
128
|
+
from: "0xsender_address",
|
|
129
129
|
timestamp: BigInt(1632000000),
|
|
130
|
-
blockNumber: BigInt(0)
|
|
130
|
+
blockNumber: BigInt(0),
|
|
131
131
|
},
|
|
132
|
-
|
|
132
|
+
raindex: "0x1",
|
|
133
133
|
},
|
|
134
|
-
orderHash:
|
|
134
|
+
orderHash: "orderHash",
|
|
135
135
|
inputVaultBalanceChange: {
|
|
136
136
|
vaultId: BigInt(1),
|
|
137
137
|
token: {
|
|
138
|
-
id:
|
|
139
|
-
address:
|
|
140
|
-
name:
|
|
141
|
-
symbol:
|
|
142
|
-
decimals: BigInt(1)
|
|
138
|
+
id: "output_token",
|
|
139
|
+
address: "0xoutput_token",
|
|
140
|
+
name: "output_token",
|
|
141
|
+
symbol: "output_token",
|
|
142
|
+
decimals: BigInt(1),
|
|
143
143
|
},
|
|
144
144
|
amount: BigInt(50),
|
|
145
|
-
formattedAmount:
|
|
146
|
-
__typename:
|
|
145
|
+
formattedAmount: "50",
|
|
146
|
+
__typename: "Withdraw",
|
|
147
147
|
newBalance: BigInt(0),
|
|
148
|
-
formattedNewBalance:
|
|
148
|
+
formattedNewBalance: "0",
|
|
149
149
|
oldBalance: BigInt(0),
|
|
150
|
-
formattedOldBalance:
|
|
150
|
+
formattedOldBalance: "0",
|
|
151
151
|
timestamp: BigInt(0),
|
|
152
152
|
transaction: {
|
|
153
|
-
id:
|
|
154
|
-
from:
|
|
153
|
+
id: "transaction_id",
|
|
154
|
+
from: "0xsender_address",
|
|
155
155
|
timestamp: BigInt(1632000000),
|
|
156
|
-
blockNumber: BigInt(0)
|
|
156
|
+
blockNumber: BigInt(0),
|
|
157
157
|
},
|
|
158
|
-
|
|
158
|
+
raindex: "0x1",
|
|
159
159
|
},
|
|
160
|
-
|
|
160
|
+
raindex: "0x00",
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
|
-
id:
|
|
163
|
+
id: "3",
|
|
164
164
|
timestamp: BigInt(1630000000),
|
|
165
165
|
transaction: {
|
|
166
|
-
id:
|
|
167
|
-
from:
|
|
166
|
+
id: "transaction_id",
|
|
167
|
+
from: "0xsender_address",
|
|
168
168
|
timestamp: BigInt(1630000000),
|
|
169
|
-
blockNumber: BigInt(0)
|
|
169
|
+
blockNumber: BigInt(0),
|
|
170
170
|
},
|
|
171
171
|
outputVaultBalanceChange: {
|
|
172
172
|
amount: BigInt(100),
|
|
173
|
-
formattedAmount:
|
|
173
|
+
formattedAmount: "100",
|
|
174
174
|
vaultId: BigInt(1),
|
|
175
175
|
token: {
|
|
176
|
-
id:
|
|
177
|
-
address:
|
|
178
|
-
name:
|
|
179
|
-
symbol:
|
|
180
|
-
decimals: BigInt(1)
|
|
176
|
+
id: "output_token",
|
|
177
|
+
address: "0xoutput_token",
|
|
178
|
+
name: "output_token",
|
|
179
|
+
symbol: "output_token",
|
|
180
|
+
decimals: BigInt(1),
|
|
181
181
|
},
|
|
182
182
|
newBalance: BigInt(0),
|
|
183
|
-
formattedNewBalance:
|
|
183
|
+
formattedNewBalance: "0",
|
|
184
184
|
oldBalance: BigInt(0),
|
|
185
|
-
formattedOldBalance:
|
|
186
|
-
__typename:
|
|
185
|
+
formattedOldBalance: "0",
|
|
186
|
+
__typename: "Withdraw",
|
|
187
187
|
timestamp: BigInt(0),
|
|
188
188
|
transaction: {
|
|
189
|
-
id:
|
|
190
|
-
from:
|
|
189
|
+
id: "transaction_id",
|
|
190
|
+
from: "sender_address",
|
|
191
191
|
timestamp: BigInt(1632000000),
|
|
192
|
-
blockNumber: BigInt(0)
|
|
192
|
+
blockNumber: BigInt(0),
|
|
193
193
|
},
|
|
194
|
-
|
|
194
|
+
raindex: "0x1",
|
|
195
195
|
},
|
|
196
|
-
orderHash:
|
|
196
|
+
orderHash: "orderHash",
|
|
197
197
|
inputVaultBalanceChange: {
|
|
198
198
|
vaultId: BigInt(1),
|
|
199
199
|
token: {
|
|
200
|
-
id:
|
|
201
|
-
address:
|
|
202
|
-
name:
|
|
203
|
-
symbol:
|
|
204
|
-
decimals: BigInt(1)
|
|
200
|
+
id: "output_token",
|
|
201
|
+
address: "0xoutput_token",
|
|
202
|
+
name: "output_token",
|
|
203
|
+
symbol: "output_token",
|
|
204
|
+
decimals: BigInt(1),
|
|
205
205
|
},
|
|
206
206
|
newBalance: BigInt(0),
|
|
207
|
-
formattedNewBalance:
|
|
207
|
+
formattedNewBalance: "0",
|
|
208
208
|
oldBalance: BigInt(0),
|
|
209
|
-
formattedOldBalance:
|
|
209
|
+
formattedOldBalance: "0",
|
|
210
210
|
amount: BigInt(50),
|
|
211
|
-
formattedAmount:
|
|
212
|
-
__typename:
|
|
211
|
+
formattedAmount: "50",
|
|
212
|
+
__typename: "Withdraw",
|
|
213
213
|
timestamp: BigInt(0),
|
|
214
214
|
transaction: {
|
|
215
|
-
id:
|
|
216
|
-
from:
|
|
215
|
+
id: "transaction_id",
|
|
216
|
+
from: "sender_address",
|
|
217
217
|
timestamp: BigInt(1632000000),
|
|
218
|
-
blockNumber: BigInt(0)
|
|
218
|
+
blockNumber: BigInt(0),
|
|
219
219
|
},
|
|
220
|
-
|
|
220
|
+
raindex: "0x1",
|
|
221
221
|
},
|
|
222
|
-
|
|
223
|
-
}
|
|
222
|
+
raindex: "0x00",
|
|
223
|
+
},
|
|
224
224
|
];
|
|
225
|
-
const result = prepareHistoricalOrderChartData(takeOrderEntities,
|
|
225
|
+
const result = prepareHistoricalOrderChartData(takeOrderEntities, "dark");
|
|
226
226
|
expect(result.length).toEqual(3);
|
|
227
227
|
expect(result[0].value).toEqual(0.5);
|
|
228
228
|
expect(result[0].time).toEqual(1630000000);
|
|
@@ -231,195 +231,195 @@ if (import.meta.vitest) {
|
|
|
231
231
|
expect(result[2].value).toEqual(0.5);
|
|
232
232
|
expect(result[2].time).toEqual(1632000000);
|
|
233
233
|
// check the color
|
|
234
|
-
expect(result[0].color).toEqual(
|
|
235
|
-
expect(result[1].color).toEqual(
|
|
236
|
-
expect(result[2].color).toEqual(
|
|
234
|
+
expect(result[0].color).toEqual("#5178FF");
|
|
235
|
+
expect(result[1].color).toEqual("#5178FF");
|
|
236
|
+
expect(result[2].color).toEqual("#5178FF");
|
|
237
237
|
});
|
|
238
|
-
it(
|
|
238
|
+
it("handles the case where multiple trades have the same timestamp", () => {
|
|
239
239
|
const takeOrderEntities = [
|
|
240
240
|
{
|
|
241
|
-
id:
|
|
241
|
+
id: "1",
|
|
242
242
|
timestamp: BigInt(1632000000),
|
|
243
243
|
transaction: {
|
|
244
|
-
id:
|
|
245
|
-
from:
|
|
244
|
+
id: "transaction_id",
|
|
245
|
+
from: "0xsender_address",
|
|
246
246
|
timestamp: BigInt(1632000000),
|
|
247
|
-
blockNumber: BigInt(0)
|
|
247
|
+
blockNumber: BigInt(0),
|
|
248
248
|
},
|
|
249
249
|
outputVaultBalanceChange: {
|
|
250
250
|
amount: BigInt(100),
|
|
251
|
-
formattedAmount:
|
|
251
|
+
formattedAmount: "100",
|
|
252
252
|
vaultId: BigInt(1),
|
|
253
253
|
token: {
|
|
254
|
-
id:
|
|
255
|
-
address:
|
|
256
|
-
name:
|
|
257
|
-
symbol:
|
|
258
|
-
decimals: BigInt(1)
|
|
254
|
+
id: "output_token",
|
|
255
|
+
address: "0xoutput_token",
|
|
256
|
+
name: "output_token",
|
|
257
|
+
symbol: "output_token",
|
|
258
|
+
decimals: BigInt(1),
|
|
259
259
|
},
|
|
260
260
|
newBalance: BigInt(0),
|
|
261
|
-
formattedNewBalance:
|
|
261
|
+
formattedNewBalance: "0",
|
|
262
262
|
oldBalance: BigInt(0),
|
|
263
|
-
formattedOldBalance:
|
|
263
|
+
formattedOldBalance: "0",
|
|
264
264
|
timestamp: BigInt(0),
|
|
265
265
|
transaction: {
|
|
266
|
-
id:
|
|
267
|
-
from:
|
|
266
|
+
id: "transaction_id",
|
|
267
|
+
from: "0xsender_address",
|
|
268
268
|
timestamp: BigInt(1632000000),
|
|
269
|
-
blockNumber: BigInt(0)
|
|
269
|
+
blockNumber: BigInt(0),
|
|
270
270
|
},
|
|
271
|
-
__typename:
|
|
272
|
-
|
|
271
|
+
__typename: "Withdraw",
|
|
272
|
+
raindex: "0x1",
|
|
273
273
|
},
|
|
274
|
-
orderHash:
|
|
274
|
+
orderHash: "orderHash",
|
|
275
275
|
inputVaultBalanceChange: {
|
|
276
276
|
vaultId: BigInt(1),
|
|
277
277
|
token: {
|
|
278
|
-
id:
|
|
279
|
-
address:
|
|
280
|
-
name:
|
|
281
|
-
symbol:
|
|
282
|
-
decimals: BigInt(1)
|
|
278
|
+
id: "output_token",
|
|
279
|
+
address: "0xoutput_token",
|
|
280
|
+
name: "output_token",
|
|
281
|
+
symbol: "output_token",
|
|
282
|
+
decimals: BigInt(1),
|
|
283
283
|
},
|
|
284
284
|
amount: BigInt(50),
|
|
285
|
-
formattedAmount:
|
|
285
|
+
formattedAmount: "50",
|
|
286
286
|
newBalance: BigInt(0),
|
|
287
|
-
formattedNewBalance:
|
|
287
|
+
formattedNewBalance: "0",
|
|
288
288
|
oldBalance: BigInt(0),
|
|
289
|
-
formattedOldBalance:
|
|
289
|
+
formattedOldBalance: "0",
|
|
290
290
|
timestamp: BigInt(0),
|
|
291
291
|
transaction: {
|
|
292
|
-
id:
|
|
293
|
-
from:
|
|
292
|
+
id: "transaction_id",
|
|
293
|
+
from: "0xsender_address",
|
|
294
294
|
timestamp: BigInt(1632000000),
|
|
295
|
-
blockNumber: BigInt(0)
|
|
295
|
+
blockNumber: BigInt(0),
|
|
296
296
|
},
|
|
297
|
-
|
|
297
|
+
raindex: "0x1",
|
|
298
298
|
},
|
|
299
|
-
|
|
299
|
+
raindex: "0x00",
|
|
300
300
|
},
|
|
301
301
|
{
|
|
302
|
-
id:
|
|
302
|
+
id: "2",
|
|
303
303
|
timestamp: BigInt(1632000000),
|
|
304
304
|
transaction: {
|
|
305
|
-
id:
|
|
306
|
-
from:
|
|
305
|
+
id: "transaction_id",
|
|
306
|
+
from: "0xsender_address",
|
|
307
307
|
timestamp: BigInt(1632000000),
|
|
308
|
-
blockNumber: BigInt(0)
|
|
308
|
+
blockNumber: BigInt(0),
|
|
309
309
|
},
|
|
310
310
|
outputVaultBalanceChange: {
|
|
311
311
|
amount: BigInt(200),
|
|
312
|
-
formattedAmount:
|
|
312
|
+
formattedAmount: "200",
|
|
313
313
|
vaultId: BigInt(1),
|
|
314
314
|
token: {
|
|
315
|
-
id:
|
|
316
|
-
address:
|
|
317
|
-
name:
|
|
318
|
-
symbol:
|
|
319
|
-
decimals: BigInt(1)
|
|
315
|
+
id: "output_token",
|
|
316
|
+
address: "0xoutput_token",
|
|
317
|
+
name: "output_token",
|
|
318
|
+
symbol: "output_token",
|
|
319
|
+
decimals: BigInt(1),
|
|
320
320
|
},
|
|
321
321
|
newBalance: BigInt(0),
|
|
322
|
-
formattedNewBalance:
|
|
322
|
+
formattedNewBalance: "0",
|
|
323
323
|
oldBalance: BigInt(0),
|
|
324
|
-
formattedOldBalance:
|
|
324
|
+
formattedOldBalance: "0",
|
|
325
325
|
timestamp: BigInt(0),
|
|
326
326
|
transaction: {
|
|
327
|
-
id:
|
|
328
|
-
from:
|
|
327
|
+
id: "transaction_id",
|
|
328
|
+
from: "0xsender_address",
|
|
329
329
|
timestamp: BigInt(1632000000),
|
|
330
|
-
blockNumber: BigInt(0)
|
|
330
|
+
blockNumber: BigInt(0),
|
|
331
331
|
},
|
|
332
|
-
|
|
332
|
+
raindex: "0x1",
|
|
333
333
|
},
|
|
334
|
-
orderHash:
|
|
334
|
+
orderHash: "orderHash",
|
|
335
335
|
inputVaultBalanceChange: {
|
|
336
336
|
vaultId: BigInt(1),
|
|
337
337
|
token: {
|
|
338
|
-
id:
|
|
339
|
-
address:
|
|
340
|
-
name:
|
|
341
|
-
symbol:
|
|
342
|
-
decimals: BigInt(1)
|
|
338
|
+
id: "output_token",
|
|
339
|
+
address: "0xoutput_token",
|
|
340
|
+
name: "output_token",
|
|
341
|
+
symbol: "output_token",
|
|
342
|
+
decimals: BigInt(1),
|
|
343
343
|
},
|
|
344
344
|
amount: BigInt(50),
|
|
345
|
-
formattedAmount:
|
|
345
|
+
formattedAmount: "50",
|
|
346
346
|
newBalance: BigInt(0),
|
|
347
|
-
formattedNewBalance:
|
|
347
|
+
formattedNewBalance: "0",
|
|
348
348
|
oldBalance: BigInt(0),
|
|
349
|
-
formattedOldBalance:
|
|
349
|
+
formattedOldBalance: "0",
|
|
350
350
|
timestamp: BigInt(0),
|
|
351
351
|
transaction: {
|
|
352
|
-
id:
|
|
353
|
-
from:
|
|
352
|
+
id: "transaction_id",
|
|
353
|
+
from: "0xsender_address",
|
|
354
354
|
timestamp: BigInt(1632000000),
|
|
355
|
-
blockNumber: BigInt(0)
|
|
355
|
+
blockNumber: BigInt(0),
|
|
356
356
|
},
|
|
357
|
-
|
|
357
|
+
raindex: "0x1",
|
|
358
358
|
},
|
|
359
|
-
|
|
359
|
+
raindex: "0x00",
|
|
360
360
|
},
|
|
361
361
|
{
|
|
362
|
-
id:
|
|
362
|
+
id: "3",
|
|
363
363
|
timestamp: BigInt(1632000000),
|
|
364
364
|
transaction: {
|
|
365
|
-
id:
|
|
366
|
-
from:
|
|
365
|
+
id: "transaction_id",
|
|
366
|
+
from: "0xsender_address",
|
|
367
367
|
timestamp: BigInt(1632000000),
|
|
368
|
-
blockNumber: BigInt(0)
|
|
368
|
+
blockNumber: BigInt(0),
|
|
369
369
|
},
|
|
370
370
|
outputVaultBalanceChange: {
|
|
371
371
|
amount: BigInt(400),
|
|
372
|
-
formattedAmount:
|
|
372
|
+
formattedAmount: "400",
|
|
373
373
|
vaultId: BigInt(1),
|
|
374
374
|
token: {
|
|
375
|
-
id:
|
|
376
|
-
address:
|
|
377
|
-
name:
|
|
378
|
-
symbol:
|
|
379
|
-
decimals: BigInt(1)
|
|
375
|
+
id: "output_token",
|
|
376
|
+
address: "0xoutput_token",
|
|
377
|
+
name: "output_token",
|
|
378
|
+
symbol: "output_token",
|
|
379
|
+
decimals: BigInt(1),
|
|
380
380
|
},
|
|
381
381
|
newBalance: BigInt(0),
|
|
382
|
-
formattedNewBalance:
|
|
382
|
+
formattedNewBalance: "0",
|
|
383
383
|
oldBalance: BigInt(0),
|
|
384
|
-
formattedOldBalance:
|
|
384
|
+
formattedOldBalance: "0",
|
|
385
385
|
timestamp: BigInt(0),
|
|
386
386
|
transaction: {
|
|
387
|
-
id:
|
|
388
|
-
from:
|
|
387
|
+
id: "transaction_id",
|
|
388
|
+
from: "0xsender_address",
|
|
389
389
|
timestamp: BigInt(1632000000),
|
|
390
|
-
blockNumber: BigInt(0)
|
|
390
|
+
blockNumber: BigInt(0),
|
|
391
391
|
},
|
|
392
|
-
|
|
392
|
+
raindex: "0x1",
|
|
393
393
|
},
|
|
394
|
-
orderHash:
|
|
394
|
+
orderHash: "orderHash",
|
|
395
395
|
inputVaultBalanceChange: {
|
|
396
396
|
vaultId: BigInt(1),
|
|
397
397
|
token: {
|
|
398
|
-
id:
|
|
399
|
-
address:
|
|
400
|
-
name:
|
|
401
|
-
symbol:
|
|
402
|
-
decimals: BigInt(1)
|
|
398
|
+
id: "output_token_id",
|
|
399
|
+
address: "0xoutput_token",
|
|
400
|
+
name: "output_token",
|
|
401
|
+
symbol: "output_token",
|
|
402
|
+
decimals: BigInt(1),
|
|
403
403
|
},
|
|
404
404
|
amount: BigInt(50),
|
|
405
|
-
formattedAmount:
|
|
405
|
+
formattedAmount: "50",
|
|
406
406
|
newBalance: BigInt(0),
|
|
407
|
-
formattedNewBalance:
|
|
407
|
+
formattedNewBalance: "0",
|
|
408
408
|
oldBalance: BigInt(0),
|
|
409
|
-
formattedOldBalance:
|
|
409
|
+
formattedOldBalance: "0",
|
|
410
410
|
timestamp: BigInt(0),
|
|
411
411
|
transaction: {
|
|
412
|
-
id:
|
|
413
|
-
from:
|
|
412
|
+
id: "transaction_id",
|
|
413
|
+
from: "0xsender_address",
|
|
414
414
|
timestamp: BigInt(1632000000),
|
|
415
|
-
blockNumber: BigInt(0)
|
|
415
|
+
blockNumber: BigInt(0),
|
|
416
416
|
},
|
|
417
|
-
|
|
417
|
+
raindex: "0x1",
|
|
418
418
|
},
|
|
419
|
-
|
|
420
|
-
}
|
|
419
|
+
raindex: "0x00",
|
|
420
|
+
},
|
|
421
421
|
];
|
|
422
|
-
const result = prepareHistoricalOrderChartData(takeOrderEntities,
|
|
422
|
+
const result = prepareHistoricalOrderChartData(takeOrderEntities, "dark");
|
|
423
423
|
// calculate the weighted average of the ioratio values
|
|
424
424
|
const ioratioSum = 0.5 * 100 + 0.25 * 200 + 0.125 * 400;
|
|
425
425
|
const outputAmountSum = 100 + 200 + 400;
|
|
@@ -427,4 +427,63 @@ if (import.meta.vitest) {
|
|
|
427
427
|
expect(result.length).toEqual(1);
|
|
428
428
|
expect(result[0].value).toEqual(ioratioAverage);
|
|
429
429
|
});
|
|
430
|
+
// Minimal trade builder: prepareHistoricalOrderChartData only reads
|
|
431
|
+
// timestamp, the two formattedAmount values and the output amount.
|
|
432
|
+
const makeTrade = (args) => ({
|
|
433
|
+
timestamp: BigInt(args.timestamp),
|
|
434
|
+
inputVaultBalanceChange: {
|
|
435
|
+
formattedAmount: args.inputFormatted,
|
|
436
|
+
},
|
|
437
|
+
outputVaultBalanceChange: {
|
|
438
|
+
formattedAmount: args.outputFormatted,
|
|
439
|
+
amount: args.outputAmount,
|
|
440
|
+
},
|
|
441
|
+
});
|
|
442
|
+
it("uses the light theme colour when colorTheme is not 'dark'", () => {
|
|
443
|
+
const trades = [
|
|
444
|
+
makeTrade({
|
|
445
|
+
timestamp: 1632000000,
|
|
446
|
+
inputFormatted: "50",
|
|
447
|
+
outputFormatted: "100",
|
|
448
|
+
outputAmount: BigInt(100),
|
|
449
|
+
}),
|
|
450
|
+
];
|
|
451
|
+
const result = prepareHistoricalOrderChartData(trades, "light");
|
|
452
|
+
expect(result.length).toEqual(1);
|
|
453
|
+
expect(result[0].color).toEqual("#4E4AF6");
|
|
454
|
+
});
|
|
455
|
+
it("returns the absolute value of the io ratio (the output vault balance change is negative)", () => {
|
|
456
|
+
// The output vault balance change is debited, so its formattedAmount is negative;
|
|
457
|
+
// the raw input/output ratio is negative (50 / -100 = -0.5) and Math.abs yields
|
|
458
|
+
// the positive charted value.
|
|
459
|
+
const trades = [
|
|
460
|
+
makeTrade({
|
|
461
|
+
timestamp: 1632000000,
|
|
462
|
+
inputFormatted: "50",
|
|
463
|
+
outputFormatted: "-100",
|
|
464
|
+
outputAmount: BigInt(100),
|
|
465
|
+
}),
|
|
466
|
+
];
|
|
467
|
+
const result = prepareHistoricalOrderChartData(trades, "dark");
|
|
468
|
+
expect(result.length).toEqual(1);
|
|
469
|
+
expect(result[0].value).toEqual(0.5);
|
|
470
|
+
});
|
|
471
|
+
it("keeps a single trade's value as-is even when its output amount is zero", () => {
|
|
472
|
+
// A lone trade at a timestamp must go through the single-trade branch and
|
|
473
|
+
// be preserved verbatim. The merge (weighted-average) branch would divide
|
|
474
|
+
// by the zero output amount and produce NaN, so a zero output amount
|
|
475
|
+
// distinguishes the two branches.
|
|
476
|
+
const trades = [
|
|
477
|
+
makeTrade({
|
|
478
|
+
timestamp: 1632000000,
|
|
479
|
+
inputFormatted: "50",
|
|
480
|
+
outputFormatted: "100",
|
|
481
|
+
outputAmount: BigInt(0),
|
|
482
|
+
}),
|
|
483
|
+
];
|
|
484
|
+
const result = prepareHistoricalOrderChartData(trades, "dark");
|
|
485
|
+
expect(result.length).toEqual(1);
|
|
486
|
+
expect(result[0].value).toEqual(0.5);
|
|
487
|
+
expect(Number.isNaN(result[0].value)).toBe(false);
|
|
488
|
+
});
|
|
430
489
|
}
|