Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

chore: dynamic weights strategy table #47

Merged
merged 12 commits into from
Jan 31, 2024

Conversation

cbrzn
Copy link
Contributor

@cbrzn cbrzn commented Jan 29, 2024

No description provided.

Copy link

vercel bot commented Jan 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fund-public-goods-ai ❌ Failed (Inspect) Jan 30, 2024 3:42pm

@cbrzn cbrzn requested review from dOrgJelli and nerfZael and removed request for dOrgJelli January 29, 2024 12:25
};
});

const amount = run.data.funding_entries.reduce((previous, current) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Super nit: run.data.funding_entries.reduce((acc, x) => acc + Number(x.amount), 0);
acc is for accumulator, relatively standard
You could also do (s, x) or even (a, b) instead of (acc, x), I think most people reading it would know what it does

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yah agreed - i added it cause its easier for me to read hehe will update it accordingly

const networkIndex = Object.values(SUPPORTED_NETWORKS).indexOf(11155111)
const networkName = Object.keys(SUPPORTED_NETWORKS)[networkIndex] as NetworkName
const token = getTokensForNetwork(networkName).find(t => t.name == "WETH")
const networkIndex = Object.values(SUPPORTED_NETWORKS).indexOf(11155111);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the user's current address? We can just make sure that we switch to Sepolia when testing.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup yup

const networkName = Object.keys(SUPPORTED_NETWORKS)[
networkIndex
] as NetworkName;
const token = getTokensForNetwork(networkName).find(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use the first token in the list as the default one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yasss

strategy: StrategyWithProjects,
amount: string
) => {
const selectedStrategies = strategy.filter(({ selected }) => selected);
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: strategy.filter(x => x.selected);

const weights = selectedStrategies.map((s) => s.weight) as number[];
const amounts = distributeWeights(weights, +amount, 2);
let amountIndex = 0;
return strategy.map(s => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be simpler to do

return strategy.map(s => ({
  ...s,
  amount: s.selected ? amounts[amountIndex++].toFixed(2) : undefined
}));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

smart

@dOrgJelli
Copy link
Contributor

I was able to make it show incorrect % values by:

  • removing each entry 1-by-1
  • then, adding each entry back 1-by-1
  • the % values are different from what was originally shown

If you select the "toggle all" button in the top right to turn the off/on again it will reset back to the original correct values.

@cbrzn
Copy link
Contributor Author

cbrzn commented Jan 30, 2024

I was able to make it show incorrect % values by:

  • removing each entry 1-by-1
  • then, adding each entry back 1-by-1
  • the % values are different from what was originally shown

If you select the "toggle all" button in the top right to turn the off/on again it will reset back to the original correct values.

@dOrgJelli nice catch, I didn't handle that case - added a commit to fix that

@dOrgJelli
Copy link
Contributor

Found one more, otherwise it's working great!
https://youtu.be/NivM5XTOYWQ?si=g9qcA2WwO6ViaS25

@cbrzn
Copy link
Contributor Author

cbrzn commented Jan 30, 2024

Found one more, otherwise it's working great! https://youtu.be/NivM5XTOYWQ?si=g9qcA2WwO6ViaS25

@dOrgJelli what is the expected behavior here? my thought was that if a strategy is unselected, and then you select it again; it will have the default weight (which is the one given by the agent). if the user would like to set any weight in particular he could just edit the weight input manually

@dOrgJelli dOrgJelli merged commit f483625 into dev Jan 31, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants