Skip to content

Commit

Permalink
error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cipig committed Nov 11, 2024
1 parent ca6bbd0 commit 6cb3fb4
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions mpm/mpm
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,10 @@ sub vrscbridge_latest_price {
$command = '{"jsonrpc":"1.0","id":"curltest","method":"getcurrencystate","params":["Bridge.vETH"]}';
$req->content($command);
my $resp = $ua->request($req);
if ($resp->is_success) {
if (length from_json($resp->content)->{"error"}{"code"}) {
print "ERROR: ", from_json($resp->content)->{"error"}{"message"}, "\n";
return 1;
} elsif ($resp->is_success) {
return $resp->content;
} else {
print "HTTP GET url: ", $url, "\n";
Expand All @@ -448,7 +451,10 @@ sub varrrbridge_latest_price {
$command = '{"jsonrpc":"1.0","id":"curltest","method":"getcurrencystate","params":["Bridge.vARRR"]}';
$req->content($command);
my $resp = $ua->request($req);
if ($resp->is_success) {
if (length from_json($resp->content)->{"error"}{"code"}) {
print "ERROR: ", from_json($resp->content)->{"error"}{"message"}, "\n";
return 1;
} elsif ($resp->is_success) {
return $resp->content;
} else {
print "HTTP GET url: ", $url, "\n";
Expand All @@ -470,7 +476,10 @@ sub vdexbridge_latest_price {
$command = '{"jsonrpc":"1.0","id":"curltest","method":"getcurrencystate","params":["Bridge.vDEX"]}';
$req->content($command);
my $resp = $ua->request($req);
if ($resp->is_success) {
if (length from_json($resp->content)->{"error"}{"code"}) {
print "ERROR: ", from_json($resp->content)->{"error"}{"message"}, "\n";
return 1;
} elsif ($resp->is_success) {
return $resp->content;
} else {
print "HTTP GET url: ", $url, "\n";
Expand Down Expand Up @@ -2611,9 +2620,9 @@ if ( $api eq "dex_gecko" ) {
if ( (($base eq "KMD") && ($coin eq "KMD-BEP20")) || (($base eq "FIRO") && ($coin eq "FIRO-BEP20")) || (($base eq "DOGE") && ($coin eq "DOGE-BEP20")) || (($base eq "FLUX") && ($coin eq "FLUX-BEP20")) ) {
$price = 1;
} elsif ( (defined $binance_usd_symbol) || (defined $binance_btc_symbol) || (defined $usd_stablecoin) || (defined $chainlink_usd_bep) || (defined $chainlink_usd_eth) || (defined $usdrate_symbol) || (defined $kucoin_usd_symbol) ) {
$marginadd = max($change,$base_4h_change)/100/4;
$marginadd = max($change,$base_4h_change)/100/4.5;
} else {
$marginadd = max($change,$base_4h_change)/100/3;
$marginadd = max($change,$base_4h_change)/100/3.5;
}
#print "====== $coin change: $change, $base base_4h_change: $base_4h_change, marginadd: $marginadd\n";

Expand Down

0 comments on commit 6cb3fb4

Please sign in to comment.