Optimizing GAS usage in rkDAI via Community Pool Tokens

Moresh Kokane
2 min readJun 7, 2020

As the title suggests this is going to be a technical article and is meant for the consideration of the internal teams at Konkrete and GrowUSD.

rkDAI is a fork of the rdai effort and it points to kDAI which in turn is a fork of Compound.

When a user buys or redeems rkDAI they are triggering the rkDAI wrapper and the OTL interaction (Compound fork). This effectively means that every interaction triggers atleast 2 interactions at a high level. rkDAI gas fees will always be its own fees plus Compound fees. This coupled with the high gas costs on Ethereum observed in recent days makes it expensive to interact with.

There is another problem. rkDAI is expected to develop in to an affiliate style program. rkDAI sends part of the interest to the affiliates address, however the holder of the rkDAI tokens can redirect the interest to any address they want. This effectively means that the affiliate can be shafted. And while we do not intend to build interfaces to that effect, the nature of smart contracts is such that any one else can build interfaces assuming they know what they are doing and achieve the same outcomes.

It is possible to deprecate the function that allows transfer of beneficiary address and effectively hardcode it at the contract level of rkDAI. But that would mean that new beneficiaries cannot be added.

A solution would be to hardcode the beneficiary address and direct it to a pool which is tokenized. This would mean all interest flows into a pool and pool tokens can be distributed to affiliates. So instead of a different link for every affiliate, each affiliate simply gets a number of tokens which are their claim to the interest pool.

This would also allow such pool tokens to be given away via an airdrop to the community for doing various activities such as sharing or liking the posts. The value of such pool tokens would be linked to the amount of interest locked into the pool.

Pool token holders can redeem their share of interest by burning their tokens.

Instead of minting new rkDAI each time we can mint a few million rkADR and put it in a selling smart contract which would allow people to buy rkADR against USDT/USDC/DAI. There would be a price module to update rkADR price daily against the US Dollar.

This would mean the OTL contract as well as rkADR will only be initiated once. The selling contract would be lighweight.

Redeeming will be gas intensive but that will serve as a disincentive against people redeeming as well, which works well for us.

Redeeming can be done as before, where rkADR would first convert to kADR and kADR to ADR and ADR can also be automatically converted to DAI/USDC/USDT etc via a Uniswap integration. Those who provide ADR to USDT etc liquidity get additional pool tokens as a reward.

Affiliates instead of getting their own link would get pool tokens as well reflecting their share.

--

--