Skip to content

Commit

Permalink
submodule: crescent (#491)
Browse files Browse the repository at this point in the history
* initial approach

* shortened

* validation

* callback tests

* adding validation

* params test

* claim tests

* minor fixes

* gofumpt

* lint

* removing unused interface

* resolving comments

* resolving comments

* resolving comments

* additional test cases

* prooftypeposition and denom validation

* validation

* validation

* gofumpt

* resolving comments

* lint

* validation tests

* separate directory for claims logic

* updating comment

* lint

* lint

* lint

* lint

* fixing imports

* fixing imports

* lint

* fix conflict with externalised multierror mod

---------

Co-authored-by: Alex Johnson <[email protected]>
Co-authored-by: Ajaz Ahmed Ansari <[email protected]>
Co-authored-by: Joe Bowman <[email protected]>
  • Loading branch information
4 people authored Jul 21, 2023
1 parent 2a6fb85 commit 9baf8c3
Show file tree
Hide file tree
Showing 117 changed files with 12,921 additions and 349 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,7 @@ enum ProtocolDataType {
ProtocolDataTypeUmeeTotalBorrows = 10;
ProtocolDataTypeUmeeUTokenSupply = 11;
ProtocolDataTypeUmeeLeverageModuleBalance = 12;
ProtocolDataTypeCrescentParams = 13;
ProtocolDataTypeCrescentReserveAddressBalance = 14;
ProtocolDataTypeCrescentPoolCoinSupply = 15;
}
20 changes: 20 additions & 0 deletions third-party-chains/crescent-types/liquidity/types/keys.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package types

import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

const (
// ModuleName defines the module name.
ModuleName = "liquidity"

// StoreKey defines the primary module store key.
StoreKey = ModuleName
)

var PoolKeyPrefix = []byte{0xab}

// GetPoolKey returns the store key to retrieve pool object from the pool id.
func GetPoolKey(poolID uint64) []byte {
return append(PoolKeyPrefix, sdk.Uint64ToBigEndian(poolID)...)
}
3,722 changes: 3,722 additions & 0 deletions third-party-chains/crescent-types/liquidity/types/liquidity.pb.go

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions third-party-chains/crescent-types/liquidity/types/pool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package types

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
)

func (pool Pool) GetReserveAddress() sdk.AccAddress {
addr, err := sdk.AccAddressFromBech32(pool.ReserveAddress)
if err != nil {
panic(err)
}
return addr
}

// Validate validates Pool for genesis.
func (pool Pool) Validate() error {
if pool.Id == 0 {
return fmt.Errorf("pool id must not be 0")
}
if pool.PairId == 0 {
return fmt.Errorf("pair id must not be 0")
}
if _, err := sdk.AccAddressFromBech32(pool.ReserveAddress); err != nil {
return fmt.Errorf("invalid reserve address %s: %w", pool.ReserveAddress, err)
}
if err := sdk.ValidateDenom(pool.PoolCoinDenom); err != nil {
return fmt.Errorf("invalid pool coin denom: %w", err)
}
return nil
}
20 changes: 20 additions & 0 deletions third-party-chains/crescent-types/lpfarm/keys.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package types

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
)

const (
// ModuleName defines the module name.
ModuleName = "lpfarm"

// StoreKey defines the primary module store key.
StoreKey = ModuleName
)

var PositionKeyPrefix = []byte{0xd5}

func GetPositionKey(farmerAddr sdk.AccAddress, denom string) []byte {
return append(append(PositionKeyPrefix, address.MustLengthPrefix(farmerAddr)...), denom...)
}
Loading

0 comments on commit 9baf8c3

Please sign in to comment.