Skip to content

decouple campaign price from asset state - #47

Merged
evmbro merged 3 commits into
sd-552-test-the-new-architecture-detachedfrom
sd-601-remove-tokenpriceprecision-from-assets
Mar 2, 2022
Merged

evmbro merged 3 commits into
sd-552-test-the-new-architecture-detachedfrom
sd-601-remove-tokenpriceprecision-from-assets

Conversation

@evmbro

@evmbro evmbro commented Mar 1, 2022

Copy link
Copy Markdown
Member

removed the tokenPricePrecision property from assets

use priceDecimals rather than price precision (use 4, not 10**4)

provide priceDecimals as a parameter while creating campaign

provide priceDecimals as a parameter while updateing price on ApxRegistry (important for liquidations)

track priceDecimals when storing the highestSellPrice on asset state (important for liquidations)

make all the _token_value() methods look the same (operations ordering)

fix tests

add priceDecimalsPrecision to the campaign common state

fix deployer service scripts to take into account new priceDecimals parameter when creating campaigns

removed the tokenPricePrecision property from assets

use priceDecimals rather than price precision (use 4, not 10**4)

provide priceDecimals as a parameter while creating campaign

provide priceDecimals as a parameter while updateing price on ApxRegistry (important for liquidations)

track priceDecimals when storing the highestSellPrice on asset state (important for liquidations)

make all the _token_value() methods look the same (operations ordering)

fix tests

add priceDecimalsPrecision to the campaign common state

fix deployer service scripts to take into account new priceDecimals parameter when creating campaigns
@evmbro
evmbro requested review from githinho and mightymatth March 1, 2022 14:19
@linear

linear Bot commented Mar 1, 2022

Copy link
Copy Markdown
SD-601 Remove tokenPricePrecision from Assets!

tokenPricePrecision is used when calculating the value of tokens when reserving the investment on campaign contracts.

Requirement:

  • token price precision shouldn't be placed/tied to asset contracts
  • token price precision must be moved from asset contracts to the actual campaign contracts since it's the only place where we use it

Comment thread contracts/services/QueryService.sol Outdated
IToken stablecoin,
uint256 price
uint256 price,
uint256 priceDecimals

@githinho githinho Mar 1, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why use uint256 for decimals?!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's a read-only service so any optimization is pointless but I'll fix it in the new commit with other changes

Comment thread contracts/managers/ACfManager.sol Outdated
function _token_amount_for_investment(
uint256 investment,
uint256 tokenPrice,
uint256 tokenPriceDecimals,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why use uint256 for decimals?!

Comment on lines +143 to +144
_safeFinalizeSale();
_safeDistributeFunds(msg.sender, fundsRaised, sc);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is a safe transfer needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If for any reason FeeManager interaction fails we still want to allow the campaign manager to finalize the campaign , or else he's locked out of his funds. In other words, we want the fee calculation to silently fail

Comment thread contracts/shared/Structs.sol Outdated
@@ -70,7 +70,7 @@ contract Structs {
address issuer;
address paymentMethod;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we rename it to something like paymentToken or paymentTokenAddress or something else?
as word method tells "how" something is paid (e.g. cash, card, "u naturi").

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

Comment thread contracts/shared/Structs.sol Outdated
@@ -52,7 +52,7 @@ contract Structs {
address issuerAddress;
address paymentMethod;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same here

@evmbro

evmbro commented Mar 1, 2022 via email

Copy link
Copy Markdown
Member Author

@mightymatth mightymatth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Alles gut, but check whether it works in frontend branch. demo is here.

Check all screens related to assets and campaigns. Try to create a new asset and campaign to see how it works. Keep the console opened to see possible errors. gl hf

@evmbro
evmbro merged commit 4615b2b into sd-552-test-the-new-architecture-detached Mar 2, 2022
@evmbro
evmbro deleted the sd-601-remove-tokenpriceprecision-from-assets branch October 25, 2023 10:52
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