Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
crons/DailyCron.php
crons/DailyCron.php
inc/config.json
22 changes: 20 additions & 2 deletions inc/Accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ function doAddAccount(){

if($newUser['id']!=0){
// Set default settings for the account //
$sql = "INSERT into `".$config['db']['prefix']."Vars` (`id`,`minlendrate`,`spreadlend`,`USDgapBottom`,`USDgapTop`,`thirtyDayMin`,`highholdlimit`,`highholdamt` )
$sql = "INSERT into `".$config['db']['prefix']."Vars` (`id`,`minlendrate`,`spreadlend`,`USDgapBottom`,`USDgapTop`,`thirtyDayMin`,`hundredDayMin`,`highholdlimit`,`highholdamt` )
VALUES
( '".$newUser['id']."', '0.0650', '3', '25000', '100000', '0.1500', '0.3500', '0' )";
( '".$newUser['id']."', '0.0650', '3', '25000', '100000', '0.1500', '0.2500', '0.3500', '0' )";
$newActSettings = $this->db->iquery($sql);
$ret['page']=2;
$ret['newaccount']=$newUser['id'];
Expand Down Expand Up @@ -276,6 +276,12 @@ function displayDetailsTableRow(){
</div>
Minimum<br>for 30 Day
</th>
<th class="mid" style="width: 110px;">
<div style="height:25px;padding-top:8px;" aria-label="Help" class="pull-right" data-toggle="popover" data-placement="right" title="Minimum for 120 Day Loans" data-content="Lowest Daily Interest Rate at which your loans will be offered for 120 days instead of 30. Set this to insure your loans earn you a higher interest rate for longer periods durring flash lending runs. If you want all loans to stay on a 2 day cycle, set this to 0.">
<span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span>
</div>
Minimum<br>for 120 Day
</th>
<th class="mid" style="width: 100px;">
<div style="height:25px;padding-top:8px;" aria-label="Help" class="pull-right" data-toggle="popover" data-placement="right" title="High Hold Amount" data-content="Amount of money you want to keep offered at the High Hold Rate. High Hold is used to keep a portion of your Deposit Wallet offered on Loan at a much higher rate than Marginbot would be likely to set in a given day. This allows you to catch Flash Margin runs and lend at least some money at a higher than normal rate. Set this to 0 if you don\'t want to keep money set aside for Flash Runs.">
<span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span>
Expand Down Expand Up @@ -304,6 +310,12 @@ function displayDetailsTableRow(){
<span class="input-group-addon">%</span>
</div>
</td>
<td>
<div class="input-group">
<input type="text" name="hundredDayMin" value="'.number_format($this->bfx->actSettings['hundredDayMin'][$thisCurrency], 5).'" class="form-control autoPercent">
<span class="input-group-addon">%</span>
</div>
</td>
<td>
<div class="input-group">
<span class="input-group-addon">'.$thisCurrency.'</span>
Expand Down Expand Up @@ -331,6 +343,7 @@ function displayDetailsTableRow(){
Gap Top
</th>
<th></th>
<th></th>
</tr>
<tr>
<td colspan="2">
Expand All @@ -346,6 +359,7 @@ function displayDetailsTableRow(){
</div>
</td>
<td></td>
<td></td>
</tr>
</table>
</div>
Expand Down Expand Up @@ -526,6 +540,7 @@ function updateSettings(){
$USDgapBottom = preg_replace('/[^0-9.]/', '', $_REQUEST['USDgapBottom']);
$USDgapTop = preg_replace('/[^0-9.]/', '', $_REQUEST['USDgapTop']);
$thirtyDayMin = preg_replace('/[^0-9.]/', '', $_REQUEST['thirtyDayMin']);
$hundredDayMin = preg_replace('/[^0-9.]/', '', $_REQUEST['hundredDayMin']);
$highholdlimit = preg_replace('/[^0-9.]/', '', $_REQUEST['highholdlimit']);
$highholdamt = preg_replace('/[^0-9.]/', '', $_REQUEST['highholdamt']);

Expand All @@ -535,6 +550,7 @@ function updateSettings(){
$sql = "UPDATE `".$config['db']['prefix']."Vars` SET minlendrate = '".$this->db->escapeStr($minlendrate)."', spreadlend = '".$this->db->escapeStr($spreadlend)."',
USDgapBottom = '".$this->db->escapeStr($USDgapBottom)."', USDgapTop = '".$this->db->escapeStr($USDgapTop)."',
thirtyDayMin = '".$this->db->escapeStr($thirtyDayMin)."',
hundredDayMin = '".$this->db->escapeStr($hundredDayMin)."',
highholdlimit = '".$this->db->escapeStr($highholdlimit)."',
highholdamt = '".$this->db->escapeStr($highholdamt)."'
WHERE userid = '".$this->db->escapeStr($this->userid)."' AND curType = '".$this->db->escapeStr($_REQUEST['curType'])."' LIMIT 1";
Expand All @@ -546,6 +562,7 @@ function updateSettings(){
`USDgapBottom`,
`USDgapTop`,
`thirtyDayMin`,
`hundredDayMin`,
`highholdlimit`,
`highholdamt`,
`userid`,
Expand All @@ -558,6 +575,7 @@ function updateSettings(){
'".$this->db->escapeStr($USDgapBottom)."',
'".$this->db->escapeStr($USDgapTop)."',
'".$this->db->escapeStr($thirtyDayMin)."',
'".$this->db->escapeStr($hundredDayMin)."',
'".$this->db->escapeStr($highholdlimit)."',
'".$this->db->escapeStr($highholdamt)."',
'".$this->db->escapeStr($this->userid)."',
Expand Down
15 changes: 12 additions & 3 deletions inc/ExchangeAPIs/bitfinex.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ function bitfinex_getMyLendRates($cur='USD', $minForLend = 50){
//checking to make sure the highhold isn't more than total available too...
$loans[$cur][0]['amt'] = ($this->actSettings['highholdamt'][$cur] > $ca ? $ca : $this->actSettings['highholdamt'][$cur]);
$loans[$cur][0]['rate'] = ($this->actSettings['highholdlimit'][$cur]*365);
// always loan out highholds for 30 days... bascially we're pretty sure this is a high rate loan
$loans[$cur][0]['time'] = 30;
// always loan out highholds for 120 days... bascially we're pretty sure this is a high rate loan
$loans[$cur][0]['time'] = 120;
}
// is there anything left after the highhold? if so, lets split it up //
if( $splitAvailable >= $minForLend ){
Expand Down Expand Up @@ -405,7 +405,15 @@ function bitfinex_getMyLendRates($cur='USD', $minForLend = 50){
// unless its above the threshold $this->actSettings['thirtyDayMin'], in which case we should lend it for the max 30 days
// (basically, the rate is higher than normal, lets keep this loan out as long as possible)
// if $this->actSettings['thirtyDayMin'] = 0, always loan for 2 days, no matter what
$loans[$cur][$a]['time'] = (($this->actSettings['thirtyDayMin'][$cur]>0)&&($lrate >= ($this->actSettings['thirtyDayMin'][$cur] * 365)) ? 30 : 2);
if ($this->actSettings['hundredDayMin'][$cur] > 0 && $lrate >= $this->actSettings['hundredDayMin'][$cur] * 365){
$loans[$cur][$a]['time'] = 120;
}
else if ($this->actSettings['thirtyDayMin'][$cur] > 0 && $lrate >= $this->actSettings['thirtyDayMin'][$cur] * 365){
$loans[$cur][$a]['time'] = 30;
}
else {
$loans[$cur][$a]['time'] = 2;
}
$nextlend += $gapClimb;
$a++;
}
Expand Down Expand Up @@ -511,6 +519,7 @@ function bitfinex_getAccountSettings(){
$this->actSettings['USDgapBottom'][strtoupper($u['curType'])] = $u['USDgapBottom'];
$this->actSettings['USDgapTop'][strtoupper($u['curType'])] = $u['USDgapTop'];
$this->actSettings['thirtyDayMin'][strtoupper($u['curType'])] = $u['thirtyDayMin'];
$this->actSettings['hundredDayMin'][strtoupper($u['curType'])] = $u['hundredDayMin'];
$this->actSettings['highholdlimit'][strtoupper($u['curType'])] = $u['highholdlimit'];
$this->actSettings['highholdamt'][strtoupper($u['curType'])] = $u['highholdamt'];
$this->actSettings['extractAmt'][strtoupper($u['curType'])] = $u['extractAmt'];
Expand Down
21 changes: 9 additions & 12 deletions inc/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@
require_once('version_info.php');

// Local Database Connection Info //
$config['db']['host'] = '';
$config['db']['dbname'] = '';
$config['db']['dbuser'] = '';
$config['db']['dbpass'] = '';
$fileContent = file_exists('inc/config.json') ? file_get_contents('inc/config.json') : file_get_contents('../inc/config.json');
$privateInfo = json_decode($fileContent , true);
$config['db']['host'] = $privateInfo['database']['host'];
$config['db']['dbname'] = $privateInfo['database']['dbname'];
$config['db']['dbuser'] = $privateInfo['database']['dbuser'];
$config['db']['dbpass'] = $privateInfo['database']['dbpass'];

// this is included in front of each database table name
$config['db']['prefix'] = '';
$config['db']['prefix'] = $privateInfo['database']['prefix'];

//Local Admin Email //
$config['admin_email'] = 'marginbot@therovegroup.com';
$config['admin_email'] = $privateInfo['email'];

// Current Fees Charged by BFX for Margin Swaps (15% as of Nov. 2014)
$config['curFeesBFX'] = 15;





$config['curFeesBFX'] = $privateInfo['fee'];
?>
48 changes: 20 additions & 28 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
$warning = array();

$configFile = getcwd().'/inc/config.php';
$configJsonPath = getcwd().'/inc/config.json';
// This is a submit, lets do some stuff //
if($_REQUEST['doInstall']==1){
//Install Step 1
Expand Down Expand Up @@ -62,6 +63,7 @@
`USDgapBottom` varchar(12) DEFAULT NULL,
`USDgapTop` varchar(12) DEFAULT NULL,
`thirtyDayMin` varchar(12) DEFAULT NULL,
`hundredDayMin` varchar(12) DEFAULT NULL,
`highholdlimit` varchar(12) DEFAULT NULL,
`highholdamt` varchar(12) DEFAULT NULL,
`extractAmt` varchar(12) DEFAULT NULL,
Expand Down Expand Up @@ -114,37 +116,27 @@

if(count($warning)==0){
// tables seemed to create ok, lets write the config file //

$configData = '<?php
date_default_timezone_set(\'America/Los_Angeles\');
setlocale(LC_MONETARY, \'en_US\');
session_start();
require_once(\'version_info.php\');

// Local Database Connection Info //
$config[\'db\'][\'host\'] = \''.$_REQUEST['installDBHost'].'\';
$config[\'db\'][\'dbname\'] = \''.$_REQUEST['installDBName'].'\';
$config[\'db\'][\'dbuser\'] = \''.$_REQUEST['installDBUser'].'\';
$config[\'db\'][\'dbpass\'] = \''.$_REQUEST['installDBPassword'].'\';

// this is included in front of each database table name
$config[\'db\'][\'prefix\'] = \''.$_REQUEST['installDBPrefix'].'\';

//Local Admin Email //
$config[\'admin_email\'] = \''.$_REQUEST['installEmail'].'\';

// Current Fees Charged by BFX for Margin Swaps (15% as of Nov. 2014)
$config[\'curFeesBFX\'] = '.$_REQUEST['installBFXFees'].';
?>';

$configJsonData = array(
"database" => array(
"host" => $_REQUEST['installDBHost'],
"dbname" => $_REQUEST['installDBName'],
"dbuser" => $_REQUEST['installDBUser'],
"dbpass" => $_REQUEST['installDBPassword'],
"prefix" => $_REQUEST['installDBPrefix']
),
"email" => $_REQUEST['installEmail'],
"fee" => $_REQUEST['installBFXFees']
);

if (!$handle = fopen($configFile, 'w')) {
$warning[] = "Could Not open file ($configFile)";
//exit;
}
// Write to the config file //
if (fwrite($handle, $configData) === FALSE) {
$warning[] = "Cannot write to file ($configFile)";

if (file_put_contents($configJsonPath, json_encode($configJsonData)) === FALSE) {
$warning[] = "Cannot write to file ($configJsonPath)";
//exit;
}
else{
Expand Down Expand Up @@ -223,13 +215,13 @@

if($newUser['id']!=0){
// Set default settings for the account //
$sql = "INSERT into `".$config['db']['prefix']."Vars` (`userid`,`curType`,`minlendrate`,`spreadlend`,`USDgapBottom`,`USDgapTop`,`thirtyDayMin`,`highholdlimit`,`highholdamt` )
$sql = "INSERT into `".$config['db']['prefix']."Vars` (`userid`,`curType`,`minlendrate`,`spreadlend`,`USDgapBottom`,`USDgapTop`,`thirtyDayMin`,`hundredDayMin`,`highholdlimit`,`highholdamt` )
VALUES
( '".$newUser['id']."', 'USD', '0.0650', '3', '25000', '100000', '0.1500', '0.3500', '0' )";
( '".$newUser['id']."', 'USD', '0.0650', '3', '25000', '100000', '0.1500', '0.2500', '0.3500', '0' )";
$newActSettings = $db->iquery($sql);
$sql = "INSERT into `".$config['db']['prefix']."Vars` (`userid`,`curType`,`minlendrate`,`spreadlend`,`USDgapBottom`,`USDgapTop`,`thirtyDayMin`,`highholdlimit`,`highholdamt` )
$sql = "INSERT into `".$config['db']['prefix']."Vars` (`userid`,`curType`,`minlendrate`,`spreadlend`,`USDgapBottom`,`USDgapTop`,`thirtyDayMin`,`hundredDayMin`,`highholdlimit`,`highholdamt` )
VALUES
( '".$newUser['id']."', 'BTC', '0.0150', '2', '2', '10', '0.1500', '0.3500', '0' )";
( '".$newUser['id']."', 'BTC', '0.0150', '2', '2', '10', '0.1500', '0.2500', '0.3500', '0' )";
$newActSettings = $db->iquery($sql);

// Success, tell them they need to login now //
Expand Down