Skip to content

Commit

Permalink
fix: last fixs and working build
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasmatt committed Apr 10, 2024
1 parent 8e67500 commit f06b3ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ temp
.env

cmd/*
compounder
10 changes: 7 additions & 3 deletions compounder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/csv"
"encoding/json"
"errors"
"fmt"
"log/slog"
"math"
"os"
Expand Down Expand Up @@ -35,7 +36,7 @@ type Compounder struct {
}

type StakeMsg struct {
Share uint64 `json:"share"`
Share string `json:"share"`
Validator string `json:"validator"`
}

Expand Down Expand Up @@ -86,7 +87,7 @@ func (compounder *Compounder) ClaimRewards() {

func (compounder *Compounder) Compound() {
// read current nibi balance
balance := compounder.ChainClient.QueryAccountBalance(compounder.Account.GetAddressStr())
balance := compounder.ChainClient.QueryAccountBalance(config.CompounderContractAddress)

// we will stake the whole balance minus 1 nibi for fees
stakeAmount := balance.AmountOf("unibi").Sub(sdk.NewInt(1))
Expand All @@ -95,6 +96,8 @@ func (compounder *Compounder) Compound() {
return
}

compounder.LogInfo("Staking ", stakeAmount, " unibi")

file, err := os.Open(config.CsvPath)
if err != nil {
compounder.LogError("Error opening CSV file", "err", err)
Expand All @@ -121,7 +124,7 @@ func (compounder *Compounder) Compound() {
}

stakeMsg := StakeMsg{
Share: share,
Share: fmt.Sprintf("%d", share),
Validator: validatorAddress,
}
stakeMsgs = append(stakeMsgs, stakeMsg)
Expand All @@ -130,6 +133,7 @@ func (compounder *Compounder) Compound() {
msgData := map[string]interface{}{
"stake": map[string]interface{}{
"stake_msgs": stakeMsgs,
"amount": stakeAmount,
},
}

Expand Down

0 comments on commit f06b3ec

Please sign in to comment.