fix: export synced deposits/borrows (#811)

* fix: export synced deposits/borrows

* fix: epxort synced cdps
This commit is contained in:
Kevin Davis 2021-02-10 07:56:38 -07:00 committed by GitHub
parent b620275165
commit 04b65e1d4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -94,7 +94,8 @@ func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState {
cdps := CDPs{}
deposits := Deposits{}
k.IterateAllCdps(ctx, func(cdp CDP) (stop bool) {
cdps = append(cdps, cdp)
syncedCdp := k.SynchronizeInterest(ctx, cdp)
cdps = append(cdps, syncedCdp)
k.IterateDeposits(ctx, cdp.ID, func(deposit Deposit) (stop bool) {
deposits = append(deposits, deposit)
return false

View File

@ -54,12 +54,20 @@ func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState {
borrows := types.Borrows{}
k.IterateDeposits(ctx, func(d types.Deposit) bool {
deposits = append(deposits, d)
syncedDeposit, found := k.GetSyncedDeposit(ctx, d.Depositor)
if !found {
panic(fmt.Sprintf("syncable deposit not found for %s", d.Depositor))
}
deposits = append(deposits, syncedDeposit)
return false
})
k.IterateBorrows(ctx, func(b types.Borrow) bool {
borrows = append(borrows, b)
syncedBorrow, found := k.GetSyncedBorrow(ctx, b.Borrower)
if !found {
panic(fmt.Sprintf("syncable borrow not found for %s", b.Borrower))
}
borrows = append(borrows, syncedBorrow)
return false
})