Skip to content

Commit b2b0402

Browse files
committed
fix: update firstlog of plasma address
1 parent 918a250 commit b2b0402

File tree

4 files changed

+35
-11
lines changed

4 files changed

+35
-11
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.23
55
// toolchain go1.23.2
66

77
require (
8-
github.com/Gearbox-protocol/sdk-go v0.0.0-20251003023307-36e24214f260
8+
github.com/Gearbox-protocol/sdk-go v0.0.0-20251009023106-5db15e47fe3a
99
github.com/ethereum/go-ethereum v1.13.14
1010
github.com/go-playground/validator/v10 v10.4.1
1111
github.com/google/go-cmp v0.6.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
66
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
77
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
88
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
9-
github.com/Gearbox-protocol/sdk-go v0.0.0-20251003023307-36e24214f260 h1:kUM2YOxHE5ybdGQ7OoPvKJ4La0QRWALkTWfYQoNLIW0=
10-
github.com/Gearbox-protocol/sdk-go v0.0.0-20251003023307-36e24214f260/go.mod h1:MZsiiSAwDdnHY6GEILYtHEqhb9wmbUUE34UBQgNlUyM=
9+
github.com/Gearbox-protocol/sdk-go v0.0.0-20251009023106-5db15e47fe3a h1:ULopGZmGRbN2kCR/mULt0+CcLTLVCikSBkPM888zZXY=
10+
github.com/Gearbox-protocol/sdk-go v0.0.0-20251009023106-5db15e47fe3a/go.mod h1:MZsiiSAwDdnHY6GEILYtHEqhb9wmbUUE34UBQgNlUyM=
1111
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
1212
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
1313
github.com/OffchainLabs/go-ethereum v1.13.4-0.20240313010929-e5d8587e7227 h1:+/3TrD+q+BP36jGj2Bycdmrc/joKLNbc5ImePQzKRLM=

models/configurators/configurator_v3/on_log.go

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package configurator_v3
22

33
import (
44
"math/big"
5+
"reflect"
56

67
"github.com/Gearbox-protocol/sdk-go/core"
78
"github.com/Gearbox-protocol/sdk-go/core/schemas"
@@ -85,14 +86,19 @@ func (mdl *Configuratorv3) OnLog(txLog types.Log) {
8586
log.CheckFatal(err)
8687
values, err := cmabi.Unpack("fees", data)
8788
log.CheckFatal(err)
88-
type feesDS struct {
89-
FeeInterest uint16
90-
FeeLiquidation uint16
91-
LiquidationDiscount uint16
92-
FeeLiquidationExpired uint16
93-
LiquidationDiscountExpired uint16
89+
90+
var feesEvent *feesDS
91+
log.Info(reflect.TypeOf(values[0]))
92+
_feesEvent := getF(values)
93+
if _feesEvent == nil {
94+
feesEvent = &feesDS{
95+
FeeInterest: uint16(values[0].(uint16)),
96+
FeeLiquidation: uint16(values[1].(uint16)),
97+
LiquidationDiscount: uint16(values[2].(uint16)),
98+
FeeLiquidationExpired: uint16(values[3].(uint16)),
99+
LiquidationDiscountExpired: uint16(values[4].(uint16)),
100+
}
94101
}
95-
feesEvent := abi.ConvertType(values, new(feesDS)).(*feesDS)
96102
params := &schemas.Parameters{
97103
BlockNum: blockNum,
98104
CreditManager: creditManager,
@@ -271,3 +277,21 @@ func (mdl *Configuratorv3) OnLog(txLog types.Log) {
271277
}
272278

273279
// select block_num, token , credit_manager , count(*) from (select * from (select block_num , credit_manager, token from allowed_tokens ) a union all (select block_num, credit_manager, token from token_ltramp)) b group by b.block_num, b.token, b.credit_manager having count(*)>1;
280+
281+
type feesDS struct {
282+
FeeInterest uint16
283+
FeeLiquidation uint16
284+
LiquidationDiscount uint16
285+
FeeLiquidationExpired uint16
286+
LiquidationDiscountExpired uint16
287+
}
288+
289+
func getF(values []interface{}) *feesDS {
290+
defer func() {
291+
if err := recover(); err != nil {
292+
log.Info(err)
293+
// return nil
294+
}
295+
}()
296+
return abi.ConvertType(values, new(feesDS)).(*feesDS)
297+
}

models/credit_manager/cm_common/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (mdl *CommonCMAdapter) CalculateCMStat(blockNum int64, state dc.CMCallData)
3131
))
3232
mdl.State.TotalRepaid = utils.GetFloat64Decimal(mdl.State.TotalRepaidBI.Convert(), mdl.GetUnderlyingDecimal())
3333
// repaying here, so subtract
34-
mdl.State.TotalBorrowedBI = core.SubCoreAndInt(mdl.State.TotalBorrowedBI, pnl.BorrowedAmount)
34+
mdl.State.TotalBorrowedBI = core.SubCoreAndInt(mdl.State.TotalBorrowedBI, pnl.BorrowedAmount) // which is negative
3535
mdl.State.TotalBorrowed = utils.GetFloat64Decimal(mdl.State.TotalBorrowedBI.Convert(), mdl.GetUnderlyingDecimal())
3636
mdl.State.TotalLossesBI = core.AddCoreAndInt(mdl.State.TotalLossesBI, pnl.Loss)
3737
mdl.State.TotalLosses = utils.GetFloat64Decimal(mdl.State.TotalLossesBI.Convert(), mdl.GetUnderlyingDecimal())

0 commit comments

Comments
 (0)