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

fea: add psm #104

Merged
merged 67 commits into from
Nov 25, 2024
Merged

fea: add psm #104

merged 67 commits into from
Nov 25, 2024

Conversation

ricklista
Copy link
Contributor

No description provided.

@ricklista ricklista force-pushed the psm branch 8 times, most recently from ff78a68 to 96a5dc8 Compare October 30, 2024 07:19
contracts/psm/LisUSDPool.sol Outdated Show resolved Hide resolved
contracts/psm/LisUSDPool.sol Outdated Show resolved Hide resolved
@ricklista ricklista force-pushed the psm branch 2 times, most recently from ef38c13 to e6a0b1d Compare October 30, 2024 11:15
contracts/psm/LisUSDPool.sol Outdated Show resolved Hide resolved
@ricklista ricklista force-pushed the psm branch 3 times, most recently from 519ab06 to fbc04ed Compare October 31, 2024 03:03
@oliver-lista
Copy link

_ No description provided. _

Every PR should have some description

contracts/psm/LisUSDPool.sol Outdated Show resolved Hide resolved
contracts/psm/LisUSDPool.sol Outdated Show resolved Hide resolved
test/psm/LisUSDPool.t.sol Outdated Show resolved Hide resolved
contracts/psm/PSM.sol Outdated Show resolved Hide resolved
contracts/hMath.sol Outdated Show resolved Hide resolved
contracts/interfaces/IEarnPool.sol Outdated Show resolved Hide resolved
contracts/interfaces/IVBep20Delegate.sol Show resolved Hide resolved
contracts/psm/LisUSDPool.sol Outdated Show resolved Hide resolved
require(
(amount > totalWeights && costWeight == totalWeights) ||
(amount <= totalWeights && costWeight == amount),
"pool weight should be used first"

Choose a reason for hiding this comment

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

what does this error mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When withdrawing lisUSD, users should use the stablecoin amout first.

Choose a reason for hiding this comment

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

in which case, amount > totalWeights could be true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when interest accrues

contracts/psm/LisUSDPool.sol Outdated Show resolved Hide resolved
if (lastUpdate == block.timestamp) {
return rate;
}
return hMath.rmul(hMath.rpow(duty, block.timestamp - lastUpdate, hMath.ONE), rate);

Choose a reason for hiding this comment

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

how much gas fee does this calculation cost?

Copy link
Contributor Author

@ricklista ricklista Nov 4, 2024

Choose a reason for hiding this comment

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

20K / 1 days

22k / 365 days

contracts/psm/PSM.sol Outdated Show resolved Hide resolved
contracts/psm/PSM.sol Outdated Show resolved Hide resolved
contracts/psm/PSM.sol Outdated Show resolved Hide resolved
contracts/psm/VenusAdapter.sol Outdated Show resolved Hide resolved
contracts/psm/VenusAdapter.sol Outdated Show resolved Hide resolved
}

// withdraw token from adapters
for (uint256 i = 0; i < adapters.length; i++) {

Choose a reason for hiding this comment

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

is it better to withdraw multiple source to the VaultMgr first, and then send to user as one shot?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will reduce the gas of a transfer

contracts/psm/VaultManager.sol Outdated Show resolved Hide resolved
@ricklista ricklista force-pushed the psm branch 2 times, most recently from 87ee9fc to 7d636c7 Compare November 1, 2024 07:17
contracts/psm/PSM.sol Outdated Show resolved Hide resolved
contracts/psm/VaultManager.sol Outdated Show resolved Hide resolved
contracts/psm/VenusAdapter.sol Outdated Show resolved Hide resolved
contracts/psm/VenusAdapter.sol Outdated Show resolved Hide resolved
// token => psm
mapping(address => address) public psm;

address public lisUSDPool; // lisUSD pool address

Choose a reason for hiding this comment

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

If these are not to be updated, then you can make them immutable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

may be updated

contracts/psm/LisUSDPoolSet.sol Show resolved Hide resolved

name = "lisUSD Single Staking Pool";
symbol = "sLisUSD";
maxDuty = _maxDuty;

Choose a reason for hiding this comment

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

Probably set a upper limit and lowe limit for "maxDuty", so setting should be in range. @ricklista

contracts/psm/LisUSDPoolSet.sol Show resolved Hide resolved
contracts/psm/LisUSDPoolSet.sol Outdated Show resolved Hide resolved

contract VaultManager is ReentrancyGuardUpgradeable, AccessControlUpgradeable, UUPSUpgradeable {
using SafeERC20 for IERC20;
address public psm; // PSM address

Choose a reason for hiding this comment

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

Is this token address and token under PSM contract, both will be same? @ricklista

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

contracts/psm/VaultManager.sol Show resolved Hide resolved
contracts/psm/VaultManager.sol Show resolved Hide resolved
for (uint256 i = 0; i < adapters.length; i++) {
IAdapter(adapters[i].adapter).withdrawAll();
}
uint256 amount = IERC20(token).balanceOf(address(this));

Choose a reason for hiding this comment

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

You can do a amount difference here, to avoid any accidental tokens already being on contract.

Check before balance, then withdraw all, then check after balance and finally distribute.

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

VaultManager may have some tokens.

contracts/psm/VenusAdapter.sol Show resolved Hide resolved
Copy link
Contributor

@qingyang-lista qingyang-lista left a comment

Choose a reason for hiding this comment

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

LGTM

@qingyang-lista qingyang-lista merged commit 9e99fa9 into master Nov 25, 2024
1 check passed
@qingyang-lista qingyang-lista deleted the psm branch November 25, 2024 08:31
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.

7 participants