Beispiel #1
0
        }
        $total_amount += floatval($item['amount']);
        // Possible the closest rate to what we want to lend
        if ($total_amount <= $config['max_total_swaps']) {
            $rate = $item['rate'];
            $check_next = TRUE;
        }
    }
    // Current rate is too low, move closer to the next rate
    if ($next_amount <= $config['max_total_swaps']) {
        $rate = $next_rate - 0.01;
    }
    $daily_rate = daily_rate($rate);
    $log->lwrite("OK, daily rate is {$daily_rate}");
    $log->lwrite("About to make Lend offer of " . $config['currency'] . " {$available_balance} @ {$rate} % apr (=" . round($rate / 365, 5) . " daily) for " . $config['period'] . " days");
    // make API offer request
    $result = $bfx->new_offer($config['currency'], (string) $available_balance, (string) $rate, $config['period'], 'lend');
    // Successfully lent
    if (array_key_exists('id', $result)) {
        $log->lwrite("{$available_balance} {$config['currency']} lent for {$config['period']} days at daily rate of {$daily_rate}%. Offer id {$result['id']}.");
    } else {
        // Something went wrong
        $log->lwrite("Something went wrong");
        var_dump($result);
    }
} else {
    $log->lwrite("Available Balance of {$available_balance} {$config['currency']} is below minimum of {$config['minimum_balance']} - not enough to lend.");
}
// close log file
$log->lwrite("exit");
$log->lclose();