Skip to content

Commit

Permalink
fix: pair details, color generation
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlak committed Sep 5, 2023
1 parent 68a7ac6 commit a9c574d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions contracts/PositionRenderer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "solmate/tokens/ERC20.sol";

import "./libraries/StringsLib.sol";
import "./libraries/AssemblyLib.sol";
import { PoolIdLib } from "./libraries/PoolLib.sol";
import "./interfaces/IPortfolio.sol";
import "./strategies/NormalStrategy.sol";

Expand Down Expand Up @@ -106,15 +107,17 @@ contract PositionRenderer {

/**
* @dev Returns the data associated with the asset / quote pair.
* @param id Id of the required pool.
* @param id Id of the pair associated with the required pool.
*/
function _getPair(uint256 id) internal view returns (Pair memory) {
(
address tokenAsset,
uint8 decimalsAsset,
address tokenQuote,
uint8 decimalsQuote
) = IPortfolio(msg.sender).pairs(uint24(id));
) = IPortfolio(msg.sender).pairs(
uint24(PoolIdLib.pairId(PoolId.wrap(uint64(id))))
);

return Pair({
asset: tokenAsset,
Expand Down Expand Up @@ -318,11 +321,17 @@ contract PositionRenderer {
{
string memory color0 = StringsLib.toHexColor(
bytes3(
keccak256(abi.encode((properties.pool.poolId >> 232) << 232))
keccak256(
abi.encode(properties.pool.poolId, properties.pair.asset)
)
)
);
string memory color1 = StringsLib.toHexColor(
bytes3(keccak256(abi.encode(properties.pool.poolId << 232)))
bytes3(
keccak256(
abi.encode(properties.pool.poolId, properties.pair.quote)
)
)
);

string memory title = string.concat(
Expand Down

0 comments on commit a9c574d

Please sign in to comment.