A lien document containing a written provision securing the repayment of future advances, whether or not the lien creditor is obligated to make such future advances, has priority over all subsequent encumbrancers to the extent of all sums advanced, with interest thereon, with the same effect as if the entire sum had been advanced at the time of the creation of the lien.
SDCL 44-1-13