All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
The transaction mentioned in the question is Riba (usurious interest). A debt is to be repaid in kind; if what was borrowed was gold, then the debt is repaid in gold; and if it was cash, then it is repaid in cash.
If someone wants to get what he loaned out according to the value of gold, then he should loan out gold itself, as in this case the debtor pays back the debt with an equal amount of gold.
Allaah Knows best.