Skip to content

Commit

Permalink
[Contract] Remove KRW exchange rate
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKim20 committed Apr 26, 2024
1 parent af660e4 commit 6f37548
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/contracts-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dms-osx-lib",
"version": "2.11.0",
"version": "2.12.0",
"description": "",
"main": "dist/bundle-cjs.js",
"module": "dist/bundle-esm.js",
Expand Down
9 changes: 3 additions & 6 deletions packages/contracts/contracts/currency/CurrencyRate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ contract CurrencyRate is CurrencyStorage, Initializable, OwnableUpgradeable, UUP
validator = IValidator(_validator);
tokenSymbol = _tokenSymbol;

rates["krw"] = MULTIPLE;
rates["point"] = MULTIPLE;

prevHeight = 0;
Expand Down Expand Up @@ -89,8 +88,6 @@ contract CurrencyRate is CurrencyStorage, Initializable, OwnableUpgradeable, UUP
rates[_data[idx].symbol] = _data[idx].rate;
emit SetRate(_data[idx].symbol, _data[idx].rate);
}
rates["krw"] = MULTIPLE;
rates["KRW"] = MULTIPLE;
rates["point"] = MULTIPLE;
rates["POINT"] = MULTIPLE;
}
Expand Down Expand Up @@ -132,7 +129,7 @@ contract CurrencyRate is CurrencyStorage, Initializable, OwnableUpgradeable, UUP
/// @param _symbol 통화명
function convertCurrencyToPoint(uint256 _amount, string calldata _symbol) external view override returns (uint256) {
bytes32 byteCurrency = keccak256(abi.encodePacked(_symbol));
if ((byteCurrency == BASE_CURRENCY) || (byteCurrency == NULL_CURRENCY)) {
if (byteCurrency == NULL_CURRENCY) {
return _amount;
} else {
return DMS.zeroGWEI((_amount * _get(_symbol)) / MULTIPLE);
Expand Down Expand Up @@ -166,8 +163,8 @@ contract CurrencyRate is CurrencyStorage, Initializable, OwnableUpgradeable, UUP
bytes32 bSymbol1 = keccak256(abi.encodePacked(_symbol1));
bytes32 bSymbol2 = keccak256(abi.encodePacked(_symbol2));
if (bSymbol1 == bSymbol2) return _amount;
uint256 rate1 = ((bSymbol1 == BASE_CURRENCY) || (bSymbol1 == NULL_CURRENCY)) ? MULTIPLE : _get(_symbol1);
uint256 rate2 = ((bSymbol2 == BASE_CURRENCY) || (bSymbol2 == NULL_CURRENCY)) ? MULTIPLE : _get(_symbol2);
uint256 rate1 = ((bSymbol1 == NULL_CURRENCY)) ? MULTIPLE : _get(_symbol1);
uint256 rate2 = ((bSymbol2 == NULL_CURRENCY)) ? MULTIPLE : _get(_symbol2);
return DMS.zeroGWEI((_amount * rate1) / rate2);
}

Expand Down
1 change: 0 additions & 1 deletion packages/contracts/contracts/currency/CurrencyStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import "../interfaces/IValidator.sol";

/// @notice 토큰 가격을 제공하는 스마트컨트랙트
contract CurrencyStorage {
bytes32 public constant BASE_CURRENCY = keccak256(abi.encodePacked("krw"));
bytes32 public constant NULL_CURRENCY = keccak256(abi.encodePacked(""));
uint256 public constant MULTIPLE = 1000000000;
mapping(string => uint256) internal rates;
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dms-osx-artifacts",
"version": "2.11.0",
"version": "2.12.0",
"description": "Smart contracts that decentralized point systems",
"files": [
"**/*.sol"
Expand Down Expand Up @@ -67,7 +67,7 @@
},
"dependencies": {
"del-osx-artifacts": "^2.3.0",
"dms-bridge-contracts": "^1.2.3",
"dms-bridge-contracts": "^1.3.0",
"multisig-wallet-contracts": "^1.1.0",
"loyalty-tokens": "^1.1.0"
}
Expand Down
4 changes: 4 additions & 0 deletions packages/contracts/test/helper/Deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,10 @@ async function deployCurrencyRate(accounts: IAccount, deployment: Deployments) {
symbol: "LYT",
rate: multiple.mul(150),
},
{
symbol: "krw",
rate: multiple,
},
{
symbol: "usd",
rate: multiple.mul(1000),
Expand Down
4 changes: 2 additions & 2 deletions packages/faker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"axios": "^1.6.7",
"chai": "^4.3.7",
"del-osx-artifacts": "^2.3.0",
"dms-bridge-contracts": "^1.2.3",
"dms-osx-artifacts": "^2.11.0",
"dms-bridge-contracts": "^1.3.0",
"dms-osx-artifacts": "^2.12.0",
"dotenv": "^10.0.0",
"ethereum-waffle": "^4.0.10",
"ethers": "5.7.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/relay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
"chai-http": "^4.3.7",
"cors": "^2.8.5",
"del-osx-artifacts": "^2.3.0",
"dms-bridge-contracts": "^1.2.3",
"dms-osx-artifacts": "^2.11.0",
"dms-bridge-contracts": "^1.3.0",
"dms-osx-artifacts": "^2.12.0",
"dotenv": "^10.0.0",
"ethereum-waffle": "^4.0.10",
"ethereumjs-util": "^7.1.5",
Expand Down
4 changes: 4 additions & 0 deletions packages/relay/test/helper/Deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,10 @@ async function deployCurrencyRate(accounts: IAccount, deployment: Deployments) {
symbol: "LYT",
rate: multiple.mul(150),
},
{
symbol: "krw",
rate: multiple,
},
{
symbol: "usd",
rate: multiple.mul(1000),
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3350,10 +3350,10 @@ [email protected]:
resolved "https://registry.yarnpkg.com/discontinuous-range/-/discontinuous-range-1.0.0.tgz#e38331f0844bba49b9a9cb71c771585aab1bc65a"
integrity sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ==

dms-bridge-contracts@^1.2.3:
version "1.2.3"
resolved "https://registry.yarnpkg.com/dms-bridge-contracts/-/dms-bridge-contracts-1.2.3.tgz#e46b4aec8691ffe2b8aaff5f76247d306f8b8eae"
integrity sha512-PNFR8tQ/C6rjPR3WNJZwJjdg9AXyxusdCEvXL2izzqGSYPMIqJu+kdwNeyAHebhlq30Wrr+AxFv+iQO/HT7+/Q==
dms-bridge-contracts@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/dms-bridge-contracts/-/dms-bridge-contracts-1.3.0.tgz#ba37c2171c49571aef9184cc917e5f1570162d96"
integrity sha512-o/s8iJwRJl+tNGYN0BddojF3LbAXZG6aKnsl+qUmpo/QO3QWwx4N4LJsxgiSwDLCrcbdEBHS5kP7GwqfwO2mOA==

dns-over-http-resolver@^1.2.3:
version "1.2.3"
Expand Down

0 comments on commit 6f37548

Please sign in to comment.