Updated ZEPH
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cryptoforknote-util",
|
"name": "cryptoforknote-util",
|
||||||
"version": "15.7.0",
|
"version": "15.7.1",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "LucasJones",
|
"name": "LucasJones",
|
||||||
"email": "lucasjonesdev@hotmail.co.uk"
|
"email": "lucasjonesdev@hotmail.co.uk"
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
// Copyright (c) 2019, Haven Protocol
|
// Copyright (c) 2019, Haven Protocol
|
||||||
//
|
//
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
//
|
//
|
||||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
// conditions and the following disclaimer.
|
// conditions and the following disclaimer.
|
||||||
//
|
//
|
||||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
// of conditions and the following disclaimer in the documentation and/or other
|
// of conditions and the following disclaimer in the documentation and/or other
|
||||||
// materials provided with the distribution.
|
// materials provided with the distribution.
|
||||||
//
|
//
|
||||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||||
// used to endorse or promote products derived from this software without specific
|
// used to endorse or promote products derived from this software without specific
|
||||||
// prior written permission.
|
// prior written permission.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
//
|
||||||
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -40,6 +40,7 @@
|
|||||||
template <template <bool> class Archive>
|
template <template <bool> class Archive>
|
||||||
bool do_serialize(Archive<false> &ar, zephyr_oracle::pricing_record &pr, uint8_t version)
|
bool do_serialize(Archive<false> &ar, zephyr_oracle::pricing_record &pr, uint8_t version)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (version >= 6)
|
if (version >= 6)
|
||||||
{
|
{
|
||||||
// very basic sanity check
|
// very basic sanity check
|
||||||
|
|||||||
@@ -32,23 +32,37 @@
|
|||||||
namespace zephyr_oracle {
|
namespace zephyr_oracle {
|
||||||
|
|
||||||
const std::vector<std::string> ASSET_TYPES = {"ZEPH", "ZEPHUSD", "ZEPHRSV", "ZYIELD"};
|
const std::vector<std::string> ASSET_TYPES = {"ZEPH", "ZEPHUSD", "ZEPHRSV", "ZYIELD"};
|
||||||
|
const std::vector<std::string> RESERVE_TYPES = {"ZEPH", "ZEPHUSD", "ZEPHRSV", "ZYIELD", "ZYIELDRSV"};
|
||||||
|
|
||||||
|
const std::vector<std::string> ASSET_TYPES_V2 = {"ZPH", "ZSD", "ZRS", "ZYS"};
|
||||||
|
const std::vector<std::string> RESERVE_TYPES_V2 = {"DJED", "YIELD"};
|
||||||
|
|
||||||
class asset_type_counts
|
class asset_type_counts
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Fields
|
// Fields
|
||||||
uint64_t ZEPH;
|
uint64_t ZEPH;
|
||||||
uint64_t ZEPHUSD;
|
uint64_t ZEPHUSD;
|
||||||
uint64_t ZEPHRSV;
|
uint64_t ZEPHRSV;
|
||||||
uint64_t ZYIELD;
|
uint64_t ZYIELD;
|
||||||
|
|
||||||
|
// v2 fields
|
||||||
|
uint64_t ZPH;
|
||||||
|
uint64_t ZSD;
|
||||||
|
uint64_t ZRS;
|
||||||
|
uint64_t ZYS;
|
||||||
|
|
||||||
asset_type_counts() noexcept
|
asset_type_counts() noexcept
|
||||||
: ZEPH(0)
|
: ZEPH(0)
|
||||||
, ZEPHUSD(0)
|
, ZEPHUSD(0)
|
||||||
, ZEPHRSV(0)
|
, ZEPHRSV(0)
|
||||||
, ZYIELD(0)
|
, ZYIELD(0)
|
||||||
|
, ZPH(0)
|
||||||
|
, ZSD(0)
|
||||||
|
, ZRS(0)
|
||||||
|
, ZYS(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,6 +76,14 @@ namespace zephyr_oracle {
|
|||||||
return ZEPHRSV;
|
return ZEPHRSV;
|
||||||
} else if (asset_type == "ZYIELD") {
|
} else if (asset_type == "ZYIELD") {
|
||||||
return ZYIELD;
|
return ZYIELD;
|
||||||
|
} else if (asset_type == "ZPH") {
|
||||||
|
return ZPH;
|
||||||
|
} else if (asset_type == "ZSD") {
|
||||||
|
return ZSD;
|
||||||
|
} else if (asset_type == "ZRS") {
|
||||||
|
return ZRS;
|
||||||
|
} else if (asset_type == "ZYS") {
|
||||||
|
return ZYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -77,6 +99,14 @@ namespace zephyr_oracle {
|
|||||||
ZEPHRSV += val;
|
ZEPHRSV += val;
|
||||||
} else if (asset_type == "ZYIELD") {
|
} else if (asset_type == "ZYIELD") {
|
||||||
ZYIELD += val;
|
ZYIELD += val;
|
||||||
|
} else if (asset_type == "ZPH") {
|
||||||
|
ZPH += val;
|
||||||
|
} else if (asset_type == "ZSD") {
|
||||||
|
ZSD += val;
|
||||||
|
} else if (asset_type == "ZRS") {
|
||||||
|
ZRS += val;
|
||||||
|
} else if (asset_type == "ZYS") {
|
||||||
|
ZYS += val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace zephyr_oracle
|
|||||||
END_KV_SERIALIZE_MAP()
|
END_KV_SERIALIZE_MAP()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pricing_record::pricing_record() noexcept
|
pricing_record::pricing_record() noexcept
|
||||||
: spot(0)
|
: spot(0)
|
||||||
, moving_average(0)
|
, moving_average(0)
|
||||||
@@ -152,7 +152,7 @@ namespace zephyr_oracle
|
|||||||
::memcpy(signature, orig.signature, sizeof(signature));
|
::memcpy(signature, orig.signature, sizeof(signature));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pricing_record::equal(const pricing_record& other) const noexcept
|
bool pricing_record::equal(const pricing_record& other) const noexcept
|
||||||
{
|
{
|
||||||
return ((spot == other.spot) &&
|
return ((spot == other.spot) &&
|
||||||
@@ -256,7 +256,7 @@ namespace zephyr_oracle
|
|||||||
}
|
}
|
||||||
|
|
||||||
// overload for pr validation for block
|
// overload for pr validation for block
|
||||||
bool pricing_record::valid(uint32_t hf_version, uint64_t bl_timestamp, uint64_t last_bl_timestamp) const
|
bool pricing_record::valid(uint32_t hf_version, uint64_t bl_timestamp, uint64_t last_bl_timestamp) const
|
||||||
{
|
{
|
||||||
if (hf_version < 3) {
|
if (hf_version < 3) {
|
||||||
if (!this->empty())
|
if (!this->empty())
|
||||||
@@ -298,4 +298,3 @@ namespace zephyr_oracle
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ namespace zephyr_oracle
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Fields
|
// Fields
|
||||||
uint64_t spot;
|
uint64_t spot;
|
||||||
uint64_t moving_average;
|
uint64_t moving_average;
|
||||||
uint64_t stable;
|
uint64_t stable;
|
||||||
@@ -127,7 +127,7 @@ namespace zephyr_oracle
|
|||||||
{
|
{
|
||||||
return a.equal(b);
|
return a.equal(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator!=(const pricing_record& a, const pricing_record& b) noexcept
|
inline bool operator!=(const pricing_record& a, const pricing_record& b) noexcept
|
||||||
{
|
{
|
||||||
return !a.equal(b);
|
return !a.equal(b);
|
||||||
@@ -252,4 +252,4 @@ namespace zephyr_oracle
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // oracle
|
} // zephyr_oracle
|
||||||
|
|||||||
Reference in New Issue
Block a user