Skip to content

Commit

Permalink
feat add idr and jpy currency
Browse files Browse the repository at this point in the history
  • Loading branch information
wirapratamaz committed May 28, 2024
1 parent 3939301 commit 9cc97ad
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
14 changes: 8 additions & 6 deletions src/Types.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module Types {
#cad;
#gbp;
#chf;
#idr;
#jpy
};

//add new chain here and update TokenFactory
Expand Down Expand Up @@ -47,12 +49,12 @@ module Types {

//add new service here and update PriceFactory with your implementation
public type PriceService = {
#icpservice; //onchain
#coingecko; //offchain
#chainlink; //onchain
#coinmarketcap; //offchain
#kraken; //offchain
#testnet; //offchain
#icpservice;
#coingecko;
#chainlink;
#coinmarketcap;
#kraken;
#testnet;
};

public type CurrencyQuote = {
Expand Down
24 changes: 23 additions & 1 deletion src/currency/FXFactory.mo
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ module {
case (#usd) { return "USD"; };
case (#gbp) { return "GBP"; };
case (#chf) { return "CHF"; };
case (#idr) { return "IDR"; };
case (#jpy) { return "JPY"; };
};
};

Expand Down Expand Up @@ -162,8 +164,28 @@ module {
currency_type = #chf;
description = ?"Swiss Franc";
};
let idr : Types.CurrencyQuote = {
name = "IDR";
symbol = "Rp";
value = 0.00006329; // 1 USD = 15,800 IDR
value_str = "0.00006329";
source = ?"cache";
created_at = Utils.now_seconds();
currency_type = #idr;
description = ?"Indonesian Rupiah";
};
let jpy : Types.CurrencyQuote = {
name = "JPY";
symbol = "¥";
value = 0.00909091; // 1 USD = 110 JPY
value_str = "0.00909091";
source = ?"cache";
created_at = Utils.now_seconds();
currency_type = #jpy;
description = ?"Japanese Yen";
};

return [usd, cad, eur, gbp, chf];
return [usd, cad, eur, gbp, chf, idr, jpy];
};

public type ForexResult = {
Expand Down

0 comments on commit 9cc97ad

Please sign in to comment.