Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Register
Sign in
Toggle navigation
Menu
Open sidebar
Tiger Ton
Osmosis_Sync
Commits
034b5a82
Commit
034b5a82
authored
3 years ago
by
ValarDragon
Browse files
Options
Download
Email Patches
Plain Diff
scrapped changes
parent
089f69ae
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
x/epochs/abci.go
+1
-0
x/epochs/abci.go
x/incentives/keeper/hooks.go
+7
-0
x/incentives/keeper/hooks.go
x/incentives/types/genesis.go
+1
-1
x/incentives/types/genesis.go
x/superfluid/keeper/epoch.go
+32
-5
x/superfluid/keeper/epoch.go
x/superfluid/keeper/hooks_test.go
+8
-3
x/superfluid/keeper/hooks_test.go
x/superfluid/keeper/intermediary_account.go
+3
-0
x/superfluid/keeper/intermediary_account.go
x/superfluid/keeper/keeper_test.go
+23
-2
x/superfluid/keeper/keeper_test.go
x/superfluid/keeper/stake_test.go
+5
-154
x/superfluid/keeper/stake_test.go
x/superfluid/types/expected_keepers.go
+4
-0
x/superfluid/types/expected_keepers.go
with
84 additions
and
165 deletions
+84
-165
x/epochs/abci.go
+
1
-
0
View file @
034b5a82
...
...
@@ -12,6 +12,7 @@ import (
// BeginBlocker of epochs module
func
BeginBlocker
(
ctx
sdk
.
Context
,
k
keeper
.
Keeper
)
{
panic
(
"hiiiiiiii"
)
defer
telemetry
.
ModuleMeasureSince
(
types
.
ModuleName
,
time
.
Now
(),
telemetry
.
MetricKeyBeginBlocker
)
k
.
IterateEpochInfo
(
ctx
,
func
(
index
int64
,
epochInfo
types
.
EpochInfo
)
(
stop
bool
)
{
logger
:=
k
.
Logger
(
ctx
)
...
...
This diff is collapsed.
Click to expand it.
x/incentives/keeper/hooks.go
+
7
-
0
View file @
034b5a82
package
keeper
import
(
"fmt"
sdk
"github.com/cosmos/cosmos-sdk/types"
epochstypes
"github.com/osmosis-labs/osmosis/v7/x/epochs/types"
"github.com/osmosis-labs/osmosis/v7/x/incentives/types"
...
...
@@ -13,9 +15,14 @@ func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochN
func
(
k
Keeper
)
AfterEpochEnd
(
ctx
sdk
.
Context
,
epochIdentifier
string
,
epochNumber
int64
)
{
params
:=
k
.
GetParams
(
ctx
)
if
epochIdentifier
==
params
.
DistrEpochIdentifier
{
fmt
.
Println
(
"start incentives epoch"
)
// begin distribution if it's start time
gauges
:=
k
.
GetUpcomingGauges
(
ctx
)
for
_
,
gauge
:=
range
gauges
{
fmt
.
Println
(
"gauge debug"
,
ctx
.
BlockTime
())
fmt
.
Println
(
"gauge debug"
,
gauge
.
StartTime
)
fmt
.
Println
(
"gauge debug"
,
!
ctx
.
BlockTime
()
.
Before
(
gauge
.
StartTime
))
if
!
ctx
.
BlockTime
()
.
Before
(
gauge
.
StartTime
)
{
if
err
:=
k
.
BeginDistribution
(
ctx
,
gauge
);
err
!=
nil
{
panic
(
err
)
...
...
This diff is collapsed.
Click to expand it.
x/incentives/types/genesis.go
+
1
-
1
View file @
034b5a82
...
...
@@ -15,7 +15,7 @@ const DefaultIndex uint64 = 1
func
DefaultGenesis
()
*
GenesisState
{
return
&
GenesisState
{
Params
:
Params
{
DistrEpochIdentifier
:
"
week
"
,
DistrEpochIdentifier
:
"
day
"
,
},
Gauges
:
[]
Gauge
{},
LockableDurations
:
[]
time
.
Duration
{
...
...
This diff is collapsed.
Click to expand it.
x/superfluid/keeper/epoch.go
+
32
-
5
View file @
034b5a82
...
...
@@ -2,6 +2,7 @@ package keeper
import
(
"errors"
"fmt"
sdk
"github.com/cosmos/cosmos-sdk/types"
"github.com/osmosis-labs/osmosis/v7/osmoutils"
...
...
@@ -13,9 +14,11 @@ import (
)
func
(
k
Keeper
)
AfterEpochEnd
(
ctx
sdk
.
Context
,
epochIdentifier
string
,
_
int64
)
{
panic
(
"plz i beg"
)
}
func
(
k
Keeper
)
AfterEpochStartBeginBlock
(
ctx
sdk
.
Context
)
{
fmt
.
Println
(
"AfterEpochStartBeginBlock"
)
params
:=
k
.
GetParams
(
ctx
)
// cref [#830](https://github.com/osmosis-labs/osmosis/issues/830),
// the supplied epoch number is wrong at time of commit. hence we get from the info.
...
...
@@ -61,7 +64,11 @@ func (k Keeper) MoveSuperfluidDelegationRewardToGauges(ctx sdk.Context) {
// To avoid unexpected issues on WithdrawDelegationRewards and AddToGaugeRewards
// we use cacheCtx and apply the changes later
_
=
osmoutils
.
ApplyFuncIfNoError
(
ctx
,
func
(
cacheCtx
sdk
.
Context
)
error
{
_
,
err
:=
k
.
dk
.
WithdrawDelegationRewards
(
cacheCtx
,
addr
,
valAddr
)
// bondDenom := k.sk.BondDenom(cacheCtx)
// balance := k.bk.GetBalance(cacheCtx, addr, bondDenom)
// fmt.Println("addr balance", balance)
coins
,
err
:=
k
.
dk
.
WithdrawDelegationRewards
(
cacheCtx
,
addr
,
valAddr
)
fmt
.
Println
(
"withdraw delegation rewards"
,
coins
,
err
)
return
err
})
...
...
@@ -71,18 +78,40 @@ func (k Keeper) MoveSuperfluidDelegationRewardToGauges(ctx sdk.Context) {
// send many different denoms to the intermediary account, and make a resource exhaustion attack on end block.
bondDenom
:=
k
.
sk
.
BondDenom
(
cacheCtx
)
balance
:=
k
.
bk
.
GetBalance
(
cacheCtx
,
addr
,
bondDenom
)
return
k
.
ik
.
AddToGaugeRewards
(
cacheCtx
,
addr
,
sdk
.
Coins
{
balance
},
acc
.
GaugeId
)
if
balance
.
IsZero
()
{
return
nil
}
err
:=
k
.
ik
.
AddToGaugeRewards
(
cacheCtx
,
addr
,
sdk
.
Coins
{
balance
},
acc
.
GaugeId
)
// gauge, err := k.ik.GetGaugeByID(cacheCtx, acc.GaugeId)
// fmt.Println("gauge balance", gauge.Coins, gauge, err)
return
err
})
}
}
func
(
k
Keeper
)
distributeSuperfluidGauges
(
ctx
sdk
.
Context
)
{
gauges
:=
k
.
ik
.
GetActiveGauges
(
ctx
)
// TODO: NONE OF THIS SHOULD BE NEEDED. IT SHOULD ALL BE DONE IN EPOCH,
// WHY IS EPOCH NOT GETTING CALLED
gauges
:=
k
.
ik
.
GetUpcomingGauges
(
ctx
)
for
_
,
gauge
:=
range
gauges
{
fmt
.
Println
(
"gauge debug"
,
ctx
.
BlockTime
())
fmt
.
Println
(
"gauge debug"
,
gauge
.
StartTime
)
fmt
.
Println
(
"gauge debug"
,
!
ctx
.
BlockTime
()
.
Before
(
gauge
.
StartTime
))
if
!
ctx
.
BlockTime
()
.
Before
(
gauge
.
StartTime
)
{
if
err
:=
k
.
ik
.
BeginDistribution
(
ctx
,
gauge
);
err
!=
nil
{
panic
(
err
)
}
}
}
gauges
=
k
.
ik
.
GetActiveGauges
(
ctx
)
// only distribute to active gauges that are for perpetual synthetic denoms
distrGauges
:=
[]
incentivestypes
.
Gauge
{}
for
_
,
gauge
:=
range
gauges
{
isSynthetic
:=
lockuptypes
.
IsSyntheticDenom
(
gauge
.
DistributeTo
.
Denom
)
fmt
.
Println
(
"plz"
,
gauge
.
DistributeTo
.
Denom
,
isSynthetic
,
gauge
.
IsPerpetual
)
if
isSynthetic
&&
gauge
.
IsPerpetual
{
distrGauges
=
append
(
distrGauges
,
gauge
)
}
...
...
@@ -116,8 +145,6 @@ func (k Keeper) UpdateOsmoEquivalentMultipliers(ctx sdk.Context, asset types.Sup
}
twap
:=
k
.
calculateOsmoBackingPerShare
(
pool
,
osmoPoolAsset
)
// TODO: "newEpochNumber" is wrong in the edge-case where the chain is down for over a day.
// However, since we don't use this epoch number right now, we don't deal with it.
k
.
SetOsmoEquivalentMultiplier
(
ctx
,
newEpochNumber
,
asset
.
Denom
,
twap
)
}
else
if
asset
.
AssetType
==
types
.
SuperfluidAssetTypeNative
{
// TODO: Consider deleting superfluid asset type native
...
...
This diff is collapsed.
Click to expand it.
x/superfluid/keeper/hooks_test.go
+
8
-
3
View file @
034b5a82
package
keeper_test
import
(
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/simapp"
sdk
"github.com/cosmos/cosmos-sdk/types"
stakingtypes
"github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/tendermint/tendermint/crypto/ed25519"
)
func
(
suite
*
KeeperTestSuite
)
TestSuperfluidAfterEpochEnd
()
{
...
...
@@ -18,7 +18,7 @@ func (suite *KeeperTestSuite) TestSuperfluidAfterEpochEnd() {
"happy path with single validator and delegator"
,
[]
stakingtypes
.
BondStatus
{
stakingtypes
.
Bonded
},
[]
superfluidDelegation
{{
0
,
0
,
"gamm/pool/1"
,
1000000
}},
sdk
.
Coins
{},
sdk
.
Coins
{
sdk
.
NewCoin
(
"uion"
,
sdk
.
OneInt
())
},
},
}
...
...
@@ -35,7 +35,7 @@ func (suite *KeeperTestSuite) TestSuperfluidAfterEpochEnd() {
// gamm swap operation before refresh
suite
.
app
.
SuperfluidKeeper
.
SetOsmoEquivalentMultiplier
(
suite
.
ctx
,
2
,
"gamm/pool/1"
,
sdk
.
NewDec
(
10
))
acc1
:=
sdk
.
AccAddress
(
ed25519
.
GenPrivKey
()
.
PubKey
()
.
Address
()
.
Bytes
())
acc1
:=
sdk
.
AccAddress
(
secp256k1
.
GenPrivKey
()
.
PubKey
()
.
Address
()
.
Bytes
())
coins
:=
sdk
.
Coins
{
sdk
.
NewInt64Coin
(
"foo"
,
100000000000000
)}
err
:=
simapp
.
FundAccount
(
suite
.
app
.
BankKeeper
,
suite
.
ctx
,
acc1
,
coins
)
...
...
@@ -58,6 +58,11 @@ func (suite *KeeperTestSuite) TestSuperfluidAfterEpochEnd() {
suite
.
Require
()
.
True
(
found
)
suite
.
Require
()
.
Equal
(
delegation
.
Shares
,
sdk
.
NewDec
(
9500
))
// TODO: Check reward distribution
gauge
,
err
:=
suite
.
app
.
IncentivesKeeper
.
GetGaugeByID
(
suite
.
ctx
,
acc
.
GaugeId
)
suite
.
Require
()
.
NoError
(
err
)
suite
.
Require
()
.
Equal
(
tc
.
expRewards
,
gauge
.
Coins
)
suite
.
Require
()
.
Equal
(
tc
.
expRewards
,
suite
.
app
.
BankKeeper
.
GetAllBalances
(
suite
.
ctx
,
delAddrs
[
0
]))
suite
.
Require
()
.
Equal
(
tc
.
expRewards
,
suite
.
app
.
BankKeeper
.
GetAllBalances
(
suite
.
ctx
,
acc
.
GetAccAddress
()))
}
})
}
...
...
This diff is collapsed.
Click to expand it.
x/superfluid/keeper/intermediary_account.go
+
3
-
0
View file @
034b5a82
package
keeper
import
(
"fmt"
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk
"github.com/cosmos/cosmos-sdk/types"
authtypes
"github.com/cosmos/cosmos-sdk/x/auth/types"
...
...
@@ -82,6 +84,7 @@ func (k Keeper) GetOrCreateIntermediaryAccount(ctx sdk.Context, denom, valAddr s
k
.
Logger
(
ctx
)
.
Error
(
err
.
Error
())
return
types
.
SuperfluidIntermediaryAccount
{},
err
}
fmt
.
Println
(
"gauge created"
,
gaugeID
)
intermediaryAcct
:=
types
.
NewSuperfluidIntermediaryAccount
(
denom
,
valAddr
,
gaugeID
)
k
.
SetIntermediaryAccount
(
ctx
,
intermediaryAcct
)
...
...
This diff is collapsed.
Click to expand it.
x/superfluid/keeper/keeper_test.go
+
23
-
2
View file @
034b5a82
...
...
@@ -15,8 +15,10 @@ import (
abci
"github.com/tendermint/tendermint/abci/types"
tmproto
"github.com/tendermint/tendermint/proto/tendermint/types"
epochtypes
"github.com/osmosis-labs/osmosis/v7/x/epochs/types"
"github.com/osmosis-labs/osmosis/v7/x/gamm/pool-models/balancer"
gammtypes
"github.com/osmosis-labs/osmosis/v7/x/gamm/types"
"github.com/tendermint/tendermint/crypto/ed25519"
lockupkeeper
"github.com/osmosis-labs/osmosis/v7/x/lockup/keeper"
...
...
@@ -35,15 +37,31 @@ type KeeperTestSuite struct {
func
(
suite
*
KeeperTestSuite
)
SetupTest
()
{
suite
.
app
=
app
.
Setup
(
false
)
suite
.
ctx
=
suite
.
app
.
BaseApp
.
NewContext
(
false
,
tmproto
.
Header
{
Height
:
1
,
ChainID
:
"osmosis-1"
,
Time
:
time
.
Now
()
.
UTC
()})
startTime
:=
time
.
Unix
(
1645580000
,
0
)
suite
.
ctx
=
suite
.
app
.
BaseApp
.
NewContext
(
false
,
tmproto
.
Header
{
Height
:
1
,
ChainID
:
"osmosis-1"
,
Time
:
startTime
.
UTC
()})
queryHelper
:=
baseapp
.
NewQueryServerTestHelper
(
suite
.
ctx
,
suite
.
app
.
InterfaceRegistry
())
types
.
RegisterQueryServer
(
queryHelper
,
suite
.
app
.
SuperfluidKeeper
)
suite
.
queryClient
=
types
.
NewQueryClient
(
queryHelper
)
suite
.
SetupDefaultPool
()
unbondingDuration
:=
suite
.
app
.
StakingKeeper
.
GetParams
(
suite
.
ctx
)
.
UnbondingTime
// require distribution identifier = superfluid identifier, and identifier exists on chain.
distrIdentifier
:=
suite
.
app
.
IncentivesKeeper
.
GetParams
(
suite
.
ctx
)
.
DistrEpochIdentifier
suite
.
Require
()
.
Equal
(
distrIdentifier
,
suite
.
app
.
SuperfluidKeeper
.
GetParams
(
suite
.
ctx
)
.
RefreshEpochIdentifier
)
epochInfo
:=
epochtypes
.
EpochInfo
{
Identifier
:
distrIdentifier
,
StartTime
:
startTime
,
Duration
:
time
.
Hour
,
CurrentEpoch
:
0
,
CurrentEpochStartTime
:
startTime
,
CurrentEpochStartHeight
:
1
,
}
suite
.
app
.
EpochsKeeper
.
SetEpochInfo
(
suite
.
ctx
,
epochInfo
)
unbondingDuration
:=
suite
.
app
.
StakingKeeper
.
GetParams
(
suite
.
ctx
)
.
UnbondingTime
suite
.
app
.
IncentivesKeeper
.
SetLockableDurations
(
suite
.
ctx
,
[]
time
.
Duration
{
time
.
Hour
*
24
*
14
,
time
.
Hour
,
...
...
@@ -51,6 +69,8 @@ func (suite *KeeperTestSuite) SetupTest() {
time
.
Hour
*
7
,
unbondingDuration
,
})
suite
.
BeginNewBlock
(
true
)
}
func
(
suite
*
KeeperTestSuite
)
SetupDefaultPool
()
{
...
...
@@ -69,6 +89,7 @@ func (suite *KeeperTestSuite) BeginNewBlock(executeNextEpoch bool) {
}
header
:=
tmproto
.
Header
{
Height
:
suite
.
ctx
.
BlockHeight
()
+
1
,
Time
:
newBlockTime
}
reqBeginBlock
:=
abci
.
RequestBeginBlock
{
Header
:
header
}
suite
.
ctx
=
suite
.
ctx
.
WithBlockHeader
(
header
)
.
WithBlockHeight
(
header
.
Height
)
.
WithBlockTime
(
header
.
Time
)
suite
.
app
.
BeginBlocker
(
suite
.
ctx
,
reqBeginBlock
)
}
...
...
This diff is collapsed.
Click to expand it.
x/superfluid/keeper/stake_test.go
+
5
-
154
View file @
034b5a82
...
...
@@ -48,12 +48,13 @@ func (suite *KeeperTestSuite) SetupSuperfluidDelegations(delAddrs []sdk.AccAddre
delAddr
:=
delAddrs
[
del
.
delIndex
]
valAddr
:=
valAddrs
[
del
.
valIndex
]
lock
:=
suite
.
SetupSuperfluidDelegate
(
delAddr
,
valAddr
,
del
.
lpDenom
,
del
.
lpAmount
)
expAcc
:=
types
.
NewSuperfluidIntermediaryAccount
(
lock
.
Coins
[
0
]
.
Denom
,
valAddr
.
String
(),
0
)
intAccAddr
:=
suite
.
app
.
SuperfluidKeeper
.
GetLockIdIntermediaryAccountConnection
(
suite
.
ctx
,
lock
.
ID
)
intAcc
:=
suite
.
app
.
SuperfluidKeeper
.
GetIntermediaryAccount
(
suite
.
ctx
,
intAccAddr
)
// save accounts for future use
if
flagIntermediaryAcc
[
expAcc
.
String
()]
==
false
{
flagIntermediaryAcc
[
expAcc
.
String
()]
=
true
intermediaryAccs
=
append
(
intermediaryAccs
,
exp
Acc
)
if
flagIntermediaryAcc
[
intAccAddr
.
String
()]
==
false
{
flagIntermediaryAcc
[
intAccAddr
.
String
()]
=
true
intermediaryAccs
=
append
(
intermediaryAccs
,
int
Acc
)
}
// save locks for future use
locks
=
append
(
locks
,
lock
)
...
...
@@ -509,156 +510,6 @@ func (suite *KeeperTestSuite) TestSuperfluidUnbondLock() {
}
}
// func (suite *KeeperTestSuite) TestSuperfluidRedelegate() {
// testCases := []struct {
// name string
// validatorStats []stakingtypes.BondStatus
// superDelegations []superfluidDelegation
// superRedelegations []superfluidRedelegation
// expSuperRedelegationErr []bool
// }{
// {
// "with single validator and single superfluid delegation with single redelegation",
// []stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Bonded},
// []superfluidDelegation{{0, "gamm/pool/1", 1000000}},
// []superfluidRedelegation{{1, 0, 1}}, // lock1 => val0 -> val1
// []bool{false},
// },
// {
// "with multiple superfluid delegations with single redelegation",
// []stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Bonded},
// []superfluidDelegation{{0, "gamm/pool/1", 1000000}, {0, "gamm/pool/1", 1000000}},
// []superfluidRedelegation{{1, 0, 1}}, // lock1 => val0 -> val1
// []bool{false},
// },
// {
// "with multiple superfluid delegations with multiple redelegations",
// []stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Bonded},
// []superfluidDelegation{{0, "gamm/pool/1", 1000000}, {0, "gamm/pool/1", 1000000}},
// []superfluidRedelegation{{1, 0, 1}, {2, 0, 1}}, // lock1 => val0 -> val1, lock2 => val0 -> val1
// []bool{false, false},
// },
// {
// "try redelegating back from new validator to original validator",
// []stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Bonded},
// []superfluidDelegation{{0, "gamm/pool/1", 1000000}, {0, "gamm/pool/1", 1000000}},
// []superfluidRedelegation{{1, 0, 1}, {1, 1, 0}}, // lock1 => val0 -> val1, lock1 => val1 -> val0
// []bool{false, true},
// },
// {
// "not available lock id redelegation",
// []stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Bonded},
// []superfluidDelegation{{0, "gamm/pool/1", 1000000}},
// []superfluidRedelegation{{2, 0, 1}}, // lock1 => val0 -> val1
// []bool{true},
// },
// {
// "redelegation for same validator",
// []stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Bonded},
// []superfluidDelegation{{0, "gamm/pool/1", 1000000}},
// []superfluidRedelegation{{1, 0, 0}}, // lock1 => val0 -> val0
// []bool{true},
// },
// }
// for _, tc := range testCases {
// tc := tc
// suite.Run(tc.name, func() {
// suite.SetupTest()
// poolId := suite.createGammPool([]string{appparams.BaseCoinUnit, "foo"})
// suite.Require().Equal(poolId, uint64(1))
// // setup validators
// valAddrs := suite.SetupValidators(tc.validatorStats)
// // setup superfluid delegations
// intermediaryAccs, _ := suite.SetupSuperfluidDelegations(valAddrs, tc.superDelegations)
// suite.checkIntermediaryAccountDelegations(intermediaryAccs)
// // execute redelegation and check changes on store
// for index, srd := range tc.superRedelegations {
// lock, err := suite.app.LockupKeeper.GetLockByID(suite.ctx, srd.lockId)
// if err != nil {
// lock = &lockuptypes.PeriodLock{}
// }
// // superfluid redelegate
// err = suite.app.SuperfluidKeeper.SuperfluidRedelegate(suite.ctx, lock.Owner, srd.lockId, valAddrs[srd.newValIndex].String())
// if tc.expSuperRedelegationErr[index] {
// suite.Require().Error(err)
// continue
// }
// suite.Require().NoError(err)
// // check previous validator bonding synthetic lockup deletion
// _, err = suite.app.LockupKeeper.GetSyntheticLockup(suite.ctx, srd.lockId, keeper.StakingSuffix(valAddrs[srd.oldValIndex].String()))
// suite.Require().Error(err)
// // check unbonding synthetic lockup creation
// params := suite.app.SuperfluidKeeper.GetParams(suite.ctx)
// synthLock, err := suite.app.LockupKeeper.GetSyntheticLockup(suite.ctx, srd.lockId, keeper.UnstakingSuffix(valAddrs[srd.oldValIndex].String()))
// suite.Require().NoError(err)
// suite.Require().Equal(synthLock.UnderlyingLockId, srd.lockId)
// suite.Require().Equal(synthLock.Suffix, keeper.UnstakingSuffix(valAddrs[srd.oldValIndex].String()))
// suite.Require().Equal(synthLock.EndTime, suite.ctx.BlockTime().Add(params.UnbondingDuration))
// // check synthetic lockup creation
// synthLock2, err := suite.app.LockupKeeper.GetSyntheticLockup(suite.ctx, srd.lockId, keeper.StakingSuffix(valAddrs[srd.newValIndex].String()))
// suite.Require().NoError(err)
// suite.Require().Equal(synthLock2.UnderlyingLockId, srd.lockId)
// suite.Require().Equal(synthLock2.Suffix, keeper.StakingSuffix(valAddrs[srd.newValIndex].String()))
// suite.Require().Equal(synthLock2.EndTime, time.Time{})
// // check intermediary account creation
// lock, err = suite.app.LockupKeeper.GetLockByID(suite.ctx, srd.lockId)
// suite.Require().NoError(err)
// expAcc := types.NewSuperfluidIntermediaryAccount(lock.Coins[0].Denom, valAddrs[srd.newValIndex].String(), 1)
// gotAcc := suite.app.SuperfluidKeeper.GetIntermediaryAccount(suite.ctx, expAcc.GetAccAddress())
// suite.Require().Equal(gotAcc.Denom, expAcc.Denom)
// suite.Require().Equal(gotAcc.ValAddr, expAcc.ValAddr)
// // check gauge creation
// gauge, err := suite.app.IncentivesKeeper.GetGaugeByID(suite.ctx, gotAcc.GaugeId)
// suite.Require().NoError(err)
// suite.Require().Equal(gauge.Id, gotAcc.GaugeId)
// suite.Require().Equal(gauge.IsPerpetual, true)
// suite.Require().Equal(gauge.DistributeTo, lockuptypes.QueryCondition{
// LockQueryType: lockuptypes.ByDuration,
// Denom: expAcc.Denom + keeper.StakingSuffix(valAddrs[srd.newValIndex].String()),
// Duration: params.UnbondingDuration,
// })
// suite.Require().Equal(gauge.Coins, sdk.Coins(nil))
// suite.Require().Equal(gauge.StartTime, suite.ctx.BlockTime())
// suite.Require().Equal(gauge.NumEpochsPaidOver, uint64(1))
// suite.Require().Equal(gauge.FilledEpochs, uint64(0))
// suite.Require().Equal(gauge.DistributedCoins, sdk.Coins(nil))
// // Check lockID connection with intermediary account
// intAcc := suite.app.SuperfluidKeeper.GetLockIdIntermediaryAccountConnection(suite.ctx, srd.lockId)
// suite.Require().Equal(intAcc.String(), expAcc.GetAccAddress().String())
// // check delegation from intermediary account to validator
// _, found := suite.app.StakingKeeper.GetDelegation(suite.ctx, expAcc.GetAccAddress(), valAddrs[srd.newValIndex])
// suite.Require().True(found)
// }
// // try redelegating twice
// for index, srd := range tc.superRedelegations {
// if tc.expSuperRedelegationErr[index] {
// continue
// }
// cacheCtx, _ := suite.ctx.CacheContext()
// lock, err := suite.app.LockupKeeper.GetLockByID(suite.ctx, srd.lockId)
// suite.Require().NoError(err)
// err = suite.app.SuperfluidKeeper.SuperfluidRedelegate(cacheCtx, lock.Owner, srd.lockId, valAddrs[srd.newValIndex].String())
// suite.Require().Error(err)
// }
// })
// }
// }
// func (suite *KeeperTestSuite) TestRefreshIntermediaryDelegationAmounts1() {
// testCases := []struct {
// name string
...
...
This diff is collapsed.
Click to expand it.
x/superfluid/types/expected_keepers.go
+
4
-
0
View file @
034b5a82
...
...
@@ -78,10 +78,14 @@ type DistrKeeper interface {
// IncentivesKeeper expected incentives keeper
type
IncentivesKeeper
interface
{
GetGaugeByID
(
ctx
sdk
.
Context
,
gaugeID
uint64
)
(
*
incentivestypes
.
Gauge
,
error
)
CreateGauge
(
ctx
sdk
.
Context
,
isPerpetual
bool
,
owner
sdk
.
AccAddress
,
coins
sdk
.
Coins
,
distrTo
lockuptypes
.
QueryCondition
,
startTime
time
.
Time
,
numEpochsPaidOver
uint64
)
(
uint64
,
error
)
AddToGaugeRewards
(
ctx
sdk
.
Context
,
owner
sdk
.
AccAddress
,
coins
sdk
.
Coins
,
gaugeID
uint64
)
error
GetUpcomingGauges
(
ctx
sdk
.
Context
)
[]
incentivestypes
.
Gauge
GetActiveGauges
(
ctx
sdk
.
Context
)
[]
incentivestypes
.
Gauge
BeginDistribution
(
ctx
sdk
.
Context
,
gauge
incentivestypes
.
Gauge
)
error
Distribute
(
ctx
sdk
.
Context
,
gauges
[]
incentivestypes
.
Gauge
)
(
sdk
.
Coins
,
error
)
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment