Skip to content

Commit

Permalink
feat: prepare v9.0.0 (#500)
Browse files Browse the repository at this point in the history
Co-authored-by: Luca Graziotti <[email protected]>
Co-authored-by: Dan Kanefsky <[email protected]>
  • Loading branch information
3 people authored Feb 28, 2025
1 parent b714a14 commit d6f8461
Show file tree
Hide file tree
Showing 26 changed files with 222 additions and 21 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions .changelog/v9.0.0/features/470-enable-swagger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Enable Swagger documentation in API endpoint. ([#470](https://github.com/noble-assets/noble/pull/470))
8 changes: 8 additions & 0 deletions .changelog/v9.0.0/summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*Feb 28, 2025*

This is the Argentum major release of Noble. It introduces various new modules
that enable the issuance and use-cases of the Noble Dollar (USDN), Noble's
yield bearing stablecoin. USDN is fully collateralized by U.S. Treasury bills
via the M^0 protocol.

This and other notable changes are documented below.
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
# CHANGELOG

## v9.0.0

*Feb 28, 2025*

This is the Argentum major release of Noble. It introduces various new modules
that enable the issuance and use-cases of the Noble Dollar (USDN), Noble's
yield bearing stablecoin. USDN is fully collateralized by U.S. Treasury bills
via the M^0 protocol.

This and other notable changes are documented below.

### BUG FIXES

- Update the capabilities of previously created ICA channels from the ICA Controller module back to the ICA Host module. ([#432](https://github.com/noble-assets/noble/pull/432))

### DEPENDENCIES

- Bump FiatTokenFactory to remove the limit check when decoding addresses. ([#455](https://github.com/noble-assets/noble/pull/455))
- Bump `cosmossdk.io/client/v2` to support returning maps inside AutoCLI queries. ([#464](https://github.com/noble-assets/noble/pull/464))
- Bump Authority to [`v1.0.2`](https://github.com/noble-assets/authority/releases/tag/v1.0.2) to include a new helper CLI command. ([#480](https://github.com/noble-assets/noble/pull/480))
- Bump Forwarding to [`v2.0.1`](https://github.com/noble-assets/forwarding/releases/tag/v2.0.1) to check recipient length and harden validation when registering accounts. ([#481](https://github.com/noble-assets/noble/pull/481))
- Bump Packet Forward Middleware to [`v8.2.0`](https://github.com/cosmos/ibc-apps/releases/tag/middleware%2Fpacket-forward-middleware%2Fv8.2.0) to resolve [GHSA-6fgm-x6ff-w78f](https://github.com/cosmos/ibc-apps/security/advisories/GHSA-6fgm-x6ff-w78f) security advisory. ([#488](https://github.com/noble-assets/noble/pull/488), [#506](https://github.com/noble-assets/noble/pull/506))
- Bump Cosmos SDK to [`v0.50.12`](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.12) ([#495](https://github.com/noble-assets/noble/pull/495))
- Bump IBC to [`v8.6.1`](https://github.com/cosmos/ibc-go/releases/v8.6.1) to resolve [ASA-2025-004](https://github.com/cosmos/ibc-go/security/advisories/GHSA-jg6f-48ff-5xrw) security advisory. ([#506](https://github.com/noble-assets/noble/pull/506))

### FEATURES

- Integrate our custom Wormhole module, that enables Wormhole messaging on Noble via IBC. ([#444](https://github.com/noble-assets/noble/pull/444))
- Integrate our custom Dollar module, that enables the issuance of Noble's stablecoin $USDN. ([#448](https://github.com/noble-assets/noble/pull/448))
- Integrate our custom Swap module, that enables the exchange of tokens issued on Noble. ([#449](https://github.com/noble-assets/noble/pull/449))
- Integrate our custom Jester sidecar, that enables the automatic relaying of $USDN transfers to Noble. ([#463](https://github.com/noble-assets/noble/pull/463))
- Enable Swagger documentation in API endpoint. ([#470](https://github.com/noble-assets/noble/pull/470))
- Enable functionality for in-place forking a synced testnet or mainnet node. ([#487](https://github.com/noble-assets/noble/pull/487))

### IMPROVEMENTS

- Update module path for v9 release line. ([#443](https://github.com/noble-assets/noble/pull/443))

## v8.0.5

*Feb 3, 2025*
Expand Down
6 changes: 3 additions & 3 deletions api/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ buf export buf.build/cosmos/ibc:e69c8f372b127401762cb251bb7b60371b4cef29 --outpu
buf export buf.build/noble-assets/aura:v2.0.0 --output api/proto
buf export buf.build/noble-assets/authority:v1.0.2 --output api/proto
buf export buf.build/noble-assets/cctp:4285c94ec19438ad1e05ba3e5106a5e7980cfffd --output api/proto
buf export buf.build/noble-assets/dollar:v1.0.0-beta.1 --output api/proto
buf export buf.build/noble-assets/dollar:v1.0.0 --output api/proto
buf export buf.build/noble-assets/fiattokenfactory:5f9bd9dd2c5b5336b94bae4a47195bdf035f04af --output api/proto
buf export buf.build/noble-assets/florin:v2.0.0 --output api/proto
buf export buf.build/noble-assets/forwarding:v2.0.1 --output api/proto
buf export buf.build/noble-assets/globalfee:v1.0.0 --output api/proto
buf export buf.build/noble-assets/halo:v2.0.1 --output api/proto
buf export buf.build/noble-assets/swap:v1.0.0-beta.1 --output api/proto
buf export buf.build/noble-assets/wormhole:v1.0.0-beta.0 --output api/proto
buf export buf.build/noble-assets/swap:v1.0.0 --output api/proto
buf export buf.build/noble-assets/wormhole:v1.0.0 --output api/proto

buf generate
swagger-combine ./api/config.json -o ./api/gen/swagger.yaml -f yaml --includeDefinitions true
4 changes: 4 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,12 @@ func (app *App) RegisterUpgradeHandler() error {
app.ModuleManager,
app.Configurator(),
app.Logger(),
app.AccountKeeper,
app.BankKeeper,
app.CapabilityKeeper,
app.DollarKeeper,
app.GlobalFeeKeeper,
app.SwapKeeper,
app.WormholeKeeper,
),
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func NewRootCmd() *cobra.Command {

// overwrite the minimum gas price from the app configuration
srvCfg := serverconfig.DefaultConfig()
srvCfg.MinGasPrices = "0uusdc,0ausdy,0ueure"
srvCfg.MinGasPrices = "0ausdy,0ueure,0uusdc,0uusdn"
srvCfg.API.Enable = true
srvCfg.API.Swagger = true
// overwrite default commit timeout from the cometbft configuration
Expand Down
2 changes: 1 addition & 1 deletion e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/monerium/module-noble/v2 v2.0.0
github.com/noble-assets/authority v1.0.2
github.com/noble-assets/halo/v2 v2.0.1
github.com/noble-assets/wormhole v1.0.0-beta.0
github.com/noble-assets/wormhole v1.0.0
github.com/ondoprotocol/usdy-noble/v2 v2.0.0
github.com/strangelove-ventures/interchaintest/v8 v8.8.0
github.com/stretchr/testify v1.10.0
Expand Down
4 changes: 2 additions & 2 deletions e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -959,8 +959,8 @@ github.com/noble-assets/authority v1.0.2 h1:aqcQJDyFF6n5Etm4qOAtB2yBJ1AskizevJby
github.com/noble-assets/authority v1.0.2/go.mod h1:NeduRYMyYEZ2sep+wFenvj/LWJTB9UUYw0GPldF+Bkk=
github.com/noble-assets/halo/v2 v2.0.1 h1:nHAhTnq5dPJGelcLnKzMviXtk9x0DfMnRPv+CPoEvyA=
github.com/noble-assets/halo/v2 v2.0.1/go.mod h1:DY4GCfZ/7S3IEjoJBCCh7HRTxirPBOLMVwkT0N6n3bA=
github.com/noble-assets/wormhole v1.0.0-beta.0 h1:AiOkdQw0X9FmuIPOT+SRc+o10uDoozcKz0wPh7vEQrQ=
github.com/noble-assets/wormhole v1.0.0-beta.0/go.mod h1:s7T9FC+bxHwlLED8pmXumdqwhr56CGJqTdhhcIj4A/Q=
github.com/noble-assets/wormhole v1.0.0 h1:c3otKgRv6Am4IoB/Vob2ziom02Ptpzv8R1/OtM2gxxI=
github.com/noble-assets/wormhole v1.0.0/go.mod h1:s7T9FC+bxHwlLED8pmXumdqwhr56CGJqTdhhcIj4A/Q=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
cosmossdk.io/x/evidence v0.1.1
cosmossdk.io/x/feegrant v0.1.1
cosmossdk.io/x/upgrade v0.1.4
dollar.noble.xyz v1.0.0-beta.1
dollar.noble.xyz v1.0.0
github.com/circlefin/noble-cctp v0.0.0-20241031192117-4285c94ec194
github.com/circlefin/noble-fiattokenfactory v0.0.0-20250123235012-5f9bd9dd2c5b
github.com/cometbft/cometbft v0.38.17
Expand All @@ -33,7 +33,7 @@ require (
github.com/noble-assets/forwarding/v2 v2.0.1
github.com/noble-assets/globalfee v1.0.0
github.com/noble-assets/halo/v2 v2.0.1
github.com/noble-assets/wormhole v1.0.0-beta.0
github.com/noble-assets/wormhole v1.0.0
github.com/ondoprotocol/usdy-noble/v2 v2.0.0
github.com/spf13/cast v1.7.1
github.com/spf13/cobra v1.8.1
Expand All @@ -42,7 +42,7 @@ require (
github.com/wormhole-foundation/wormhole/sdk v0.0.0-20241218143724-3797ed082150
jester.noble.xyz/api v0.2.0
mvdan.cc/gofumpt v0.7.0
swap.noble.xyz v1.0.0-beta.1
swap.noble.xyz v1.0.0
)

require (
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ cosmossdk.io/x/tx v0.13.8/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
cosmossdk.io/x/upgrade v0.1.4 h1:/BWJim24QHoXde8Bc64/2BSEB6W4eTydq0X/2f8+g38=
cosmossdk.io/x/upgrade v0.1.4/go.mod h1:9v0Aj+fs97O+Ztw+tG3/tp5JSlrmT7IcFhAebQHmOPo=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
dollar.noble.xyz v1.0.0-beta.1 h1:hjFyeH9SqTZSRPs7ztit7vOIIIGWzpSHp/mYsnNHDqQ=
dollar.noble.xyz v1.0.0-beta.1/go.mod h1:PYo0MOT3B0nxvXUNinWGAsH2ArJgMI8DisqP9fqZtjo=
dollar.noble.xyz v1.0.0 h1:jn+YV6A3n1xOckn6eW8ZxEbIVsHYFjdZAKihhYGW4AI=
dollar.noble.xyz v1.0.0/go.mod h1:PYo0MOT3B0nxvXUNinWGAsH2ArJgMI8DisqP9fqZtjo=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/4meepo/tagalign v1.3.4 h1:P51VcvBnf04YkHzjfclN6BbsopfJR5rxs1n+5zHt+w8=
Expand Down Expand Up @@ -1096,8 +1096,8 @@ github.com/noble-assets/halo/v2 v2.0.1 h1:nHAhTnq5dPJGelcLnKzMviXtk9x0DfMnRPv+CP
github.com/noble-assets/halo/v2 v2.0.1/go.mod h1:DY4GCfZ/7S3IEjoJBCCh7HRTxirPBOLMVwkT0N6n3bA=
github.com/noble-assets/ibc-apps/middleware/packet-forward-middleware/v8 v8.2.0-noble h1:nxz3n15ChWqK/PvRYg0sGpfsrsIM1uqK4z/I/6CvSbc=
github.com/noble-assets/ibc-apps/middleware/packet-forward-middleware/v8 v8.2.0-noble/go.mod h1:O5H9Ic3Pe6cmJn1eqlj5N48sLb8WQ1VWmDP4/11g/4E=
github.com/noble-assets/wormhole v1.0.0-beta.0 h1:AiOkdQw0X9FmuIPOT+SRc+o10uDoozcKz0wPh7vEQrQ=
github.com/noble-assets/wormhole v1.0.0-beta.0/go.mod h1:s7T9FC+bxHwlLED8pmXumdqwhr56CGJqTdhhcIj4A/Q=
github.com/noble-assets/wormhole v1.0.0 h1:c3otKgRv6Am4IoB/Vob2ziom02Ptpzv8R1/OtM2gxxI=
github.com/noble-assets/wormhole v1.0.0/go.mod h1:s7T9FC+bxHwlLED8pmXumdqwhr56CGJqTdhhcIj4A/Q=
github.com/nunnatsa/ginkgolinter v0.16.2 h1:8iLqHIZvN4fTLDC0Ke9tbSZVcyVHoBs0HIbnVSxfHJk=
github.com/nunnatsa/ginkgolinter v0.16.2/go.mod h1:4tWRinDN1FeJgU+iJANW/kz7xKN5nYRAOfJDQUS9dOQ=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
Expand Down Expand Up @@ -2141,5 +2141,5 @@ sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
swap.noble.xyz v1.0.0-beta.1 h1:MvzYWOm7bUxFp296q5LPE5+k1TsTuUFritpqQg7mEDQ=
swap.noble.xyz v1.0.0-beta.1/go.mod h1:QQzrClLCg0Fr+XIlc/ZcAXr5qqB2m5klg+rbtoE9rxo=
swap.noble.xyz v1.0.0 h1:XGt5uXfiHZsAIuGmcmIXJyLjh5RvJI7JlbpWvSDRkYo=
swap.noble.xyz v1.0.0/go.mod h1:QQzrClLCg0Fr+XIlc/ZcAXr5qqB2m5klg+rbtoE9rxo=
1 change: 1 addition & 0 deletions local_net/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ update_genesis() {
touch $TEMP && jq '.app_state.bank.denom_metadata += [{ "description": "Ondo US Dollar Yield", "denom_units": [{ "denom": "ausdy", "exponent": 0, "aliases": ["attousdy"] }, { "denom": "usdy", "exponent": 18 }], "base": "ausdy", "display": "usdy", "name": "Ondo US Dollar Yield", "symbol": "USDY" }]' $HOME1/config/genesis.json > $TEMP && mv $TEMP $HOME1/config/genesis.json
touch $TEMP && jq '.app_state.bank.denom_metadata += [{ "description": "Hashnote US Yield Coin", "denom_units": [{ "denom": "uusyc", "exponent": 0, "aliases": ["microusyc"] }, { "denom": "usyc", "exponent": 6 }], "base": "uusyc", "display": "usyc", "name": "Hashnote US Yield Coin", "symbol": "USYC" }]' $HOME1/config/genesis.json > $TEMP && mv $TEMP $HOME1/config/genesis.json
touch $TEMP && jq '.app_state.bank.denom_metadata += [{ "description": "Monerium EUR emoney", "denom_units": [{ "denom": "ueure", "exponent": 0, "aliases": ["microeure"] }, { "denom": "eure", "exponent": 6 }], "base": "ueure", "display": "eure", "name": "Monerium EUR emoney", "symbol": "EURe" }]' $HOME1/config/genesis.json > $TEMP && mv $TEMP $HOME1/config/genesis.json
touch $TEMP && jq '.app_state.bank.denom_metadata += [{ "description": "Noble Dollar", "denom_units": [{ "denom": "uusdn", "exponent": 0, "aliases": ["microusdn"] }, { "denom": "usdn", "exponent": 6 }], "base": "uusdn", "display": "usdn", "name": "Noble Dollar", "symbol": "USDN" }]' $HOME1/config/genesis.json > $TEMP && mv $TEMP $HOME1/config/genesis.json
touch $TEMP && jq '.app_state."fiat-tokenfactory".mintingDenom = { "denom": "uusdc" }' $HOME1/config/genesis.json > $TEMP && mv $TEMP $HOME1/config/genesis.json
touch $TEMP && jq '.app_state."fiat-tokenfactory".paused.paused = false' $HOME1/config/genesis.json > $TEMP && mv $TEMP $HOME1/config/genesis.json
touch $TEMP && jq '.app_state.staking.params.bond_denom = "ustake"' $HOME1/config/genesis.json > $TEMP && mv $TEMP $HOME1/config/genesis.json
Expand Down
159 changes: 154 additions & 5 deletions upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,24 @@ import (
"cosmossdk.io/collections"
"cosmossdk.io/errors"
"cosmossdk.io/log"
"cosmossdk.io/math"
upgradetypes "cosmossdk.io/x/upgrade/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/ethereum/go-ethereum/common"

authoritytypes "github.com/noble-assets/authority/types"

bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

dollarkeeper "dollar.noble.xyz/keeper"
portaltypes "dollar.noble.xyz/types/portal"

globalfeekeeper "github.com/noble-assets/globalfee/keeper"

capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
Expand All @@ -37,16 +50,21 @@ import (
wormholetypes "github.com/noble-assets/wormhole/types"
vaautils "github.com/wormhole-foundation/wormhole/sdk/vaa"

dollarkeeper "dollar.noble.xyz/keeper"
portaltypes "dollar.noble.xyz/types/portal"
swapkeeper "swap.noble.xyz/keeper"
swaptypes "swap.noble.xyz/types"
stableswaptypes "swap.noble.xyz/types/stableswap"
)

func CreateUpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
logger log.Logger,
accountKeeper authkeeper.AccountKeeper,
bankKeeper bankkeeper.Keeper,
capabilityKeeper *capabilitykeeper.Keeper,
dollarKeeper *dollarkeeper.Keeper,
globalFeeKeeper *globalfeekeeper.Keeper,
swapKeeper *swapkeeper.Keeper,
wormholeKeeper *wormholekeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
Expand All @@ -67,6 +85,16 @@ func CreateUpgradeHandler(
return vm, err
}

if err := ConfigureSwapModule(sdkCtx, accountKeeper, swapKeeper); err != nil {
return vm, err
}

ConfigureBankModule(ctx, bankKeeper)

if err := ConfigureGlobalFeeModule(ctx, dollarKeeper, globalFeeKeeper); err != nil {
return vm, err
}

logger.Info("Welcome to a new generation of Noble!" + UpgradeASCII)

return vm, nil
Expand Down Expand Up @@ -189,14 +217,20 @@ func ConfigureDollarModule(ctx sdk.Context, dollarKeeper *dollarkeeper.Keeper) (
case MainnetChainID:
chainID := uint16(vaautils.ChainIDEthereum)

// TODO: Add portal owner configuration!
err = dollarKeeper.PortalOwner.Set(ctx, authoritytypes.ModuleAddress.String())
if err != nil {
return errors.Wrap(err, "unable to set dollar portal owner in state")
}

err = dollarKeeper.PortalPeers.Set(ctx, chainID, portaltypes.Peer{
// TODO: Confirm Noble's mainnnet transceiver address with M^0

// https://etherscan.io/address/0xc7Dd372c39E38BF11451ab4A8427B4Ae38ceF644
Transceiver: common.FromHex("0x000000000000000000000000c7dd372c39e38bf11451ab4a8427b4ae38cef644"),
// https://etherscan.io/address/0x83Ae82Bd4054e815fB7B189C39D9CE670369ea16
Manager: common.FromHex("0x00000000000000000000000083ae82bd4054e815fb7b189c39d9ce670369ea16"),
})
if err != nil {
return errors.Wrap(err, "unable to set dollar portal peer in state")
}

// $USDN -> $M
err = dollarKeeper.PortalBridgingPaths.Set(ctx, collections.Join(chainID, m), true)
Expand All @@ -214,3 +248,118 @@ func ConfigureDollarModule(ctx sdk.Context, dollarKeeper *dollarkeeper.Keeper) (
return fmt.Errorf("cannot configure the dollar portal on %s chain", ctx.ChainID())
}
}

// ConfigureSwapModule creates an initial USDN<>USDC swap pool.
func ConfigureSwapModule(ctx sdk.Context, accountKeeper authkeeper.AccountKeeper, swapKeeper *swapkeeper.Keeper) (err error) {
switch ctx.ChainID() {
case MainnetChainID:
// Create the initial uusdn<>uusdc pool, following the same logic of the StableSwap `CreatePool` function:
// https://github.com/noble-assets/swap/blob/f94f41da984bdfbdebb013f70ed8ce05d2993726/keeper/msg_stableswap_server.go#L46-L169

// Increase and get the next Pool ID.
poolId, err := swapKeeper.IncreaseNextPoolID(ctx)
if err != nil {
return errors.Wrapf(err, "unable to set next pool id")
}

// Create the Pool address.
prefix := fmt.Sprintf("%s/pool/%d", swaptypes.ModuleName, poolId)
account := authtypes.NewEmptyModuleAccount(prefix)
account = accountKeeper.NewAccount(ctx, account).(*authtypes.ModuleAccount)
accountKeeper.SetModuleAccount(ctx, account)

// Create the Protocol Fees Pool address.
protocolFeesAccount := authtypes.NewEmptyModuleAccount(fmt.Sprintf("%s/protocol_fees", prefix))
protocolFees := accountKeeper.NewAccount(ctx, protocolFeesAccount).(*authtypes.ModuleAccount)
accountKeeper.SetModuleAccount(ctx, protocolFees)

// Create the Rewards Fees Pool address.
rewardFeesAccount := authtypes.NewEmptyModuleAccount(fmt.Sprintf("%s/reward_fees", prefix))
rewardFees := accountKeeper.NewAccount(ctx, rewardFeesAccount).(*authtypes.ModuleAccount)
accountKeeper.SetModuleAccount(ctx, rewardFees)

// Set the new Pool on state.
err = swapKeeper.SetPool(ctx, 0, swaptypes.Pool{
Id: poolId,
Address: account.GetAddress().String(),
Algorithm: swaptypes.STABLESWAP,
Pair: "uusdc",
})
if err != nil {
return errors.Wrap(err, "unable to set initial swap pool in state")
}

// Add the new Pool ID to the `Paused` state.
if err = swapKeeper.SetPaused(ctx, poolId, false); err != nil {
return errors.Wrapf(err, "unable to create paused pool initial entry")
}

// Set the `StableSwap` data on state.
err = swapKeeper.Stableswap.SetPool(ctx, 0, stableswaptypes.Pool{
ProtocolFeePercentage: 100,
RewardsFee: 10000000,
InitialA: 800,
FutureA: 800,
InitialATime: ctx.HeaderInfo().Time.Unix(),
FutureATime: 0,
RateMultipliers: sdk.NewCoins(
sdk.NewCoin("uusdn", math.NewInt(1e18)),
sdk.NewCoin("uusdc", math.NewInt(1e18)),
),
TotalShares: math.LegacyZeroDec(),
})
if err != nil {
return errors.Wrap(err, "unable to set initial swap pool in state")
}

return nil
default:
return fmt.Errorf("cannot create initial swap pool on %s chain", ctx.ChainID())
}
}

// ConfigureBankModule sets the bank metadata for the Noble Dollar.
func ConfigureBankModule(ctx context.Context, bankKeeper bankkeeper.Keeper) {
bankKeeper.SetDenomMetaData(ctx, banktypes.Metadata{
Description: "Noble Dollar",
DenomUnits: []*banktypes.DenomUnit{
{
Denom: "uusdn",
Exponent: 0,
Aliases: []string{"microusdn"},
},
{
Denom: "usdn",
Exponent: 6,
},
},
Base: "uusdn",
Display: "usdn",
Name: "Noble Dollar",
Symbol: "USDN",
})
}

// ConfigureGlobalFeeModule updates the minimum gas prices to include the Noble Dollar.
func ConfigureGlobalFeeModule(ctx context.Context, dollarKeeper *dollarkeeper.Keeper, globalFeeKeeper *globalfeekeeper.Keeper) (err error) {
gasPrices, err := globalFeeKeeper.GasPrices.Get(ctx)
if err != nil {
return errors.Wrap(err, "unable to get gas prices from state")
}

if !gasPrices.Value.IsZero() {
gasPrices.Value = gasPrices.Value.Add(
sdk.NewDecCoinFromDec(
dollarKeeper.GetDenom(),
math.LegacyMustNewDecFromStr("0.1"),
),
).Sort()
}

err = globalFeeKeeper.GasPrices.Set(ctx, gasPrices)
if err != nil {
return errors.Wrap(err, "unable to set gas prices in state")
}

return nil
}

0 comments on commit d6f8461

Please sign in to comment.