Skip to content

Conversation

@Exef
Copy link

@Exef Exef commented Aug 1, 2025

This PR adds a new asset whitelisting mechanism to SingleTokenConverter that allows specific tokens to be directly transferred to the destination address without going through the conversion process. This enhancement provides a more efficient path for certain assets while maintaining all existing functionality.

Changes to SingleTokenConverter contract

  1. New State Variable
/// @notice The mapping contains the assets which are sent to destination directly
/// @dev Asset -> bool(should transfer directly on true)
mapping(address => bool) public assetsDirectTransfer;
  1. New Event
/// @notice Emitted after the assetsDirectTransfer mapping is updated
event AssetsDirectTransferUpdated(address indexed receiver, address indexed asset, bool value);
  1. New function in Public Interface
/// @notice Update the assetsDirectTransfer mapping
/// @param assets Addresses of the assets need to be added for direct transfer
/// @param values Boolean value to indicate whether direct transfer is allowed for each asset
/// @custom:access Restricted by ACM
function setAssetsDirectTransfer(address[] calldata assets, bool[] calldata values) external virtual;

Asset Processing Flow after changes

  • Base Asset: Always transferred directly (existing behavior)
  • Whitelisted Assets: Transferred directly via assetsDirectTransfer[asset] == true
  • Other Assets: Follow normal conversion process (existing behavior)

…em to destination.

Moved poolsAssetsDirectTransfer mapping to AbstractTokenConverter.

Used inherited poolsAssetsDirectTransfer mapping in RiskFundConverter.

Modified SingleTokenConverter so whitelisted assets would be directly transfered to the destination address.
@Exef Exef requested a review from Debugger022 August 1, 2025 12:42
@Exef Exef self-assigned this Aug 1, 2025
@Exef Exef requested a review from chechu August 1, 2025 12:44
expect(await whitelistedTokenIn.balanceOf(xvsVaultTreasury.address)).to.equal(whitelistedTokenAmount);
});

it("Revert on when trying to set to a differnet address than xvsVaultTreasury", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
it("Revert on when trying to set to a differnet address than xvsVaultTreasury", async () => {
it("Revert on when trying to set to a different address than xvsVaultTreasury", async () => {

unchecked {
balanceDifference = currentBalance - assetReserve;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

Comment on lines 183 to 187
it("Should revert on zero address", async () => {
await expect(converter.setBaseAsset(ethers.constants.AddressZero)).to.be.revertedWithCustomError(
converter,
"ZeroAddressNotAllowed",
);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a duplicate, there’s already a test written for it here.

Comment on lines 190 to 207
it("Should succeed on updating existing base asset", async () => {
await converter.setBaseAsset(tokenIn.address);
expect(await converter.baseAsset()).to.equal(tokenIn.address);

const tx = await converter.setBaseAsset(tokenOut.address);
expect(tx).to.emit(converter, "BaseAssetUpdated").withArgs(tokenIn.address, tokenOut.address);

expect(await converter.baseAsset()).to.equal(tokenOut.address);
});

it("Should succeed on setting same base asset multiple times", async () => {
await converter.setBaseAsset(tokenIn.address);
expect(await converter.baseAsset()).to.equal(tokenIn.address);

const tx = await converter.setBaseAsset(tokenIn.address);
expect(tx).to.emit(converter, "BaseAssetUpdated").withArgs(tokenIn.address, tokenIn.address);

expect(await converter.baseAsset()).to.equal(tokenIn.address);
Copy link
Contributor

Choose a reason for hiding this comment

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

it should revert if we update same base asset again. Please encorporate change here

@Exef Exef requested review from Debugger022 and chechu August 4, 2025 09:45
@chechu
Copy link
Contributor

chechu commented Aug 4, 2025

LGTM

@chechu chechu force-pushed the VEN-3338-whitelist branch from 2c52398 to 868c4dc Compare August 4, 2025 15:49
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.

5 participants