Skip to content

Commit

Permalink
feat: closure repay amount fix
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-98 committed Mar 6, 2024
1 parent 30a582b commit 12fe4f1
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions scripts/closure_repay_amount/index.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main

import (
"math/big"

"github.com/Gearbox-protocol/sdk-go/core"
"github.com/Gearbox-protocol/sdk-go/log"
"github.com/Gearbox-protocol/third-eye/config"
"github.com/Gearbox-protocol/third-eye/repository"
)

type data struct {
Transfers core.Hstore `gorm:"column:transfers"`
AmountBi *core.BigInt `gorm:"column:amount_bi"`
LogId int64 `gorm:"column:log_id"`
BlockNum int64 `gorm:"column:block_num"`
}

func main() {
cfg := config.NewConfig()
db := repository.NewDBClient(cfg)
query := `select a.log_id , a.block_num, a.tx_hash, a.transfers, b.amount_bi from (select * from account_operations where action like 'Decrease%' and args->>'amount' = '115792089237316195423570985008687907853269984665640564039457584007913129639935' ) a join (select * from pool_ledger where event='Repay' ) b on b.tx_hash = a.tx_hash;`
d := []data{}
err := db.Raw(query).Find(&d).Error
log.CheckFatal(err)
for _, entry := range d {
m := entry.Transfers.GetMap()
for key := range m {
m[key] = new(big.Int).Neg(entry.AmountBi.Convert()).String()
}
log.Info(m)
err = db.Exec(`update account_operations set transfers =? where log_id =? and block_num = ?`, entry.Transfers, entry.LogId, entry.BlockNum).Error
log.CheckFatal(err)
}
}

0 comments on commit 12fe4f1

Please sign in to comment.