1
This commit is contained in:
parent
cec26567d4
commit
a2eb258d18
@ -25,6 +25,7 @@ class StakingController extends BaseAuthedController {
|
|||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
$info = array(
|
$info = array(
|
||||||
|
'pool_size' => 8000 * 10000 - Staking::getAllStakingValue(),
|
||||||
'total_staking_value' => '0',
|
'total_staking_value' => '0',
|
||||||
'daily_staking_value' => '0',
|
'daily_staking_value' => '0',
|
||||||
'planet' => array(
|
'planet' => array(
|
||||||
|
@ -17,6 +17,27 @@ class Staking extends BaseModel {
|
|||||||
|
|
||||||
const NFT721 = 1;
|
const NFT721 = 1;
|
||||||
|
|
||||||
|
public static function getAllStakingValue()
|
||||||
|
{
|
||||||
|
$value = 0;
|
||||||
|
$rows = SqlHelper::ormSelect(
|
||||||
|
myself()->_getMysql(''),
|
||||||
|
't_staking',
|
||||||
|
array(
|
||||||
|
'status' => self::STAKING_STATUS
|
||||||
|
)
|
||||||
|
);
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
if ($row['nft_type'] == self::NFT721) {
|
||||||
|
if ($row['item_id']) {
|
||||||
|
$stakingDto = self::toDto($row);
|
||||||
|
$value += $stakingDto['cec_value'] * (1 + self::getTotalInterest($row['stake_time']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
public static function all($address)
|
public static function all($address)
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
@ -307,4 +328,26 @@ class Staking extends BaseModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function getTotalInterest($stakeTime)
|
||||||
|
{
|
||||||
|
$months = intval($stakeTime / 3600 / 24 / 30);
|
||||||
|
if ($months <= 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//1 3 6 12 24
|
||||||
|
if ($months <= 1) {
|
||||||
|
return 0.01;
|
||||||
|
} else if ($months <= 3) {
|
||||||
|
return 0.05;
|
||||||
|
} else if ($months <= 6) {
|
||||||
|
return 0.15;
|
||||||
|
} else if ($months <= 12) {
|
||||||
|
return 0.4;
|
||||||
|
} else if ($months <= 24) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user