Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion trivex_contract/src/trivexaction.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ mod TrivexAction {
quantity: quantity,
average_price: average_price,
leverage: leverage,
total_value: total_value,
total_value: average_price*quantity,
action: action,
datetime: get_block_timestamp()
};
Expand Down Expand Up @@ -298,6 +298,9 @@ mod TrivexAction {

if success {
self.staked.write((token_address, caller), current_staked - amount);

let current_total_staked = self.total_staked.read();
self.total_staked.write(current_total_staked - amount);
}
}

Expand Down
13 changes: 2 additions & 11 deletions trivex_web/src/assets/data.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
[
{
"label": "Create New Strategy",
"value": "newStrategy",
"tags": "Custom",
"cost": 0,
"creator": "0x0000000000000000000000000000000000000000000000000000000000000000",
"rating": 0,
"description": "Create your own custom strategy by providing parameters and implementation details."
},
{
"label": "Average Rebalance",
"value": "averageRebalance",
"tags": "Low Frequency",
"tags": "Mid Frequency",
"cost": 1,
"creator": "0x012B099F50C3CbCc82ccF7Ee557c9d60255c35C359eA6615435B761Ec3336EC8",
"rating": 4.5,
Expand All @@ -20,7 +11,7 @@
{
"label": "Momentum",
"value": "momentum",
"tags": "Low Frequency",
"tags": "Mid Frequency",
"cost": 2,
"creator": "0x012B099F50C3CbCc82ccF7Ee557c9d60255c35C359eA6615435B761Ec3336EC8",
"rating": 4,
Expand Down
6 changes: 3 additions & 3 deletions trivex_web/src/components/AppContract.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const hash_provider = new RpcProvider({
nodeUrl: 'https://starknet-sepolia.public.blastapi.io/rpc/v0_7',
});

const classHash = '0x04074c9358508a35eb68e9a785fecffededed939e27705539df6ee5e7efb01f8';
const contractAddress = '0x074b86ea6740d99816f83b83e30895c88b8e628ff8cbf216cc3310022781228d';
const classHash = '0x007fe76700f3cf1cbe20df4447ef69b7d3c74fcf35df60e5c6134cb43f202567';
const contractAddress = '0x066ec78f1ec3aafd617a49890d7007d0d7961139bea637beb2413b6a606efbbd';
const usdcTokenAddress = '0x53b40a647cedfca6ca84f542a0fe36736031905a9639a7f19a3c1e66bfd5080';
const strkTokenAddress = '0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d';

Expand Down Expand Up @@ -176,7 +176,7 @@ export class AppContract {
quantity: Number(item.quantity)/1000000,
average_price: Number(item.average_price)/1000000,
leverage: Number(item.leverage),
total_value: Number(item.total_value)/1000000,
total_value: Number((Number(item.total_value)/1000000/1000000).toFixed(7)),
action: shortString.decodeShortString(item.action),
datetime: new Date(Number(item.datetime) * 1000)
}));
Expand Down
14 changes: 12 additions & 2 deletions trivex_web/src/components/Selection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,19 @@ const StyledButton = styled(Button)(({ theme }) => ({
}
}));

const newStrategyItem = {
"label": "Create New Strategy",
"value": "newStrategy",
"tags": "Custom",
"cost": 0,
"creator": "0x0000000000000000000000000000000000000000000000000000000000000000",
"rating": 0,
"description": "Create your own custom strategy by providing parameters and implementation details."
}

const getTagColor = (tag) => {
switch (tag) {
case 'Low Frequency':
case 'Mid Frequency':
return { bg: '#9C27B0', color: '#FFFFFF' };
case 'Calculator':
return { bg: '#673AB7', color: '#FFFFFF' };
Expand All @@ -44,7 +54,7 @@ const Selection = ({ selections, onSelect }) => {
<Box sx={{ display: 'flex', justifyContent: 'flex-end', marginBottom: '10px' }}>
<StyledButton
startIcon={<AddIcon />}
onClick={() => onSelect({ value: 'newStrategy' })}
onClick={() => onSelect(newStrategyItem)}
>
Create Strategy
</StyledButton>
Expand Down
6 changes: 5 additions & 1 deletion trivex_web/src/pages/StrategyPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ const StrategyPage = () => {
const handleSelect = (item) => {
setStrategy(item.value);
const index = data.findIndex(strategy => strategy.value === item.value);
setSelectedInfo(data[index]);
if(index == -1){
setSelectedInfo(item);
}else {
setSelectedInfo(data[index]);
}
console.log(`You selected the strategy: ${item.value} at index: ${index}`);
};

Expand Down