One way to implement pyramid accounts is using SQL triggers, so that it reacts to transfers.

Trigger triggers when rows are inserted into Banking.Transfer:

if the destination account type is PyramidAccount: PyramidRate=1.5 FeeRate=0.01 Currency=BTC RecursionRate is looked up in account settings as 60% (0.6) Fee = FeeRate * Amount transfer Fee to GetSpecialAccount('Pyramid' + Currency + 'Fee') transfer Amount-Fee to GetSpecialAccount('Pyramid' + Currency + 'Pool') insert row into table Queue: (Remaining, Currency, SourceAccountId, DestAccountId) values (Amount * PyramidRate, Currency, 1234)

Runs every X seconds or on trigger: for each Currency: PoolBalance = GetBalance(GetSpecialAccount('Pyramid' + Currency + 'Pool')) if PoolBalance = 0, don't do anything find oldest row in Queue with Remaining > 0 and Currency=Currency AmountToMove=biggest number of Remaining and PoolBalance

look up RecursionRate for the user's account SourceAccount RecurseAmount=RecursionRate*AmountToMove CollectAmount=AmountToMove-RecurseAmount

if RecurseAmount > 0:

 move RecurseAmount from GetSpecialAccount(PyramidCurrencyPool) to SourceAccountId

if CollectAmount > 0:

 move CollectAmount from GetSpecialAccount(PyramidCurrencyPool) to DestinationAccountId

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.