How much are delegators earning on their investment in bid-bots? The Steem blockchain has most of the data needed to make the calculations so let’s follow the numbers!
But not so fast. First, we need some definitions and some code. Any Steem account can delegate its Steem Power to another one and undelegate anytime with no previous notice. The account that delegates is the delegator and the account that receives the delegated funds is the delegatee. There is no credit risk for the delegator as she does not depend on the delegatee’s actions to get her money (Steem Power) back. It takes 7 days to get the undelegated funds back in the delegator’s account so delegators have some incentive to not undelegate so often.
In this short-term credit market, the delegated funds are the bid-bot’s debt. It is common for bid-bots to pay interest on their debt every day. This reduces how much a delegator would not receive if a bid-bot were to default on its interest payments.
The query to get all delegations ever made to one bid-bot account (see previous posts to learn about getting and processing the Steem blockchain info) is:
bidbot <- 'your_favorite_bid_bot'
sqltxt <- paste("SELECT * FROM TxDelegateVestingShares WHERE delegatee IN ('",bidbot,"')",sep="")
delegations_to_bot <- data.table(dbGetQuery(conn, sqltxt))
delegators <- unique(delegations_to_bot[,list(to=delegator)])
delegators[,isdelegator := 'yes']
sqltxt <- paste("SELECT [from],[to],amount,amount_symbol,memo,timestamp,type FROM TxTransfers (NOLOCK) WHERE [from] IN ('",bot,"')",sep="")
transfers_out <- data.table(dbGetQuery(conn, sqltxt))
setkey(transfers_out,to)
setkey(delegators,to)
transfers_out <- delegators[transfers_out]
transfers_out[,isdelegator := ifelse(is.na(isdelegator),'no',isdelegator)]
interest_payments <- transfers_out[isdelegator=='yes',list(int_usd=sum(usd)),by=list(delegator=to,year,month)]
setkey(delegation_balances,delegator,year,month)
setkey(interest_payments,delegator,year,month)
cash_flow <- merge(interest_payments,delegation_balances)
cash_flow_monthly <- cash_flow[delegation_usd > 0,list(interest_usd=round(sum(interest_usd)),delegation_usd=round(sum(delegation_usd))),keyby=list(year,month)]
cash_flow_monthly[,mrr := round(100*interest_usd/delegation_usd,4)]
cash_flow_monthly[,arr := round(100*(((1+(mrr/100))^12)-1),4)]