diff --git a/contracts/swapper/osmosis/src/route.rs b/contracts/swapper/osmosis/src/route.rs index 698eba5b5..85a12f706 100644 --- a/contracts/swapper/osmosis/src/route.rs +++ b/contracts/swapper/osmosis/src/route.rs @@ -6,7 +6,7 @@ use mars_osmosis::helpers::{query_arithmetic_twap_price, query_pool, CommonPoolD use mars_red_bank_types::swapper::EstimateExactInSwapResponse; use mars_swapper_base::{ContractError, ContractResult, Route}; use osmosis_std::types::osmosis::gamm::v1beta1::MsgSwapExactAmountIn; -pub use osmosis_std::types::osmosis::poolmanager::v1beta1::SwapAmountInRoute; +pub use osmosis_std::types::osmosis::poolmanager::v1beta1::SwapAmountInRoute as OsmosisSwapAmountInRoute; use crate::helpers::hashset; @@ -16,6 +16,17 @@ const TWAP_WINDOW_SIZE_SECONDS: u64 = 600u64; #[cw_serde] pub struct OsmosisRoute(pub Vec); +/// SwapAmountInRoute instead of using `osmosis_std::types::osmosis::poolmanager::v1beta1::SwapAmountInRoute` +/// to keep consistency for pool_id representation as u64. +/// +/// SwapAmountInRoute from osmosis package uses as_str serializer/deserializer, so it expects pool_id +/// as a String, but JSON schema doesn't correctly represent it. +#[cw_serde] +pub struct SwapAmountInRoute { + pub pool_id: u64, + pub token_out_denom: String, +} + impl fmt::Display for OsmosisRoute { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let s = self @@ -118,9 +129,17 @@ impl Route for OsmosisRoute { let out_amount = query_out_amount(querier, &env.block, coin_in, steps)?; let min_out_amount = (Decimal::one() - slippage) * out_amount; + let routes: Vec<_> = steps + .iter() + .map(|step| OsmosisSwapAmountInRoute { + pool_id: step.pool_id, + token_out_denom: step.token_out_denom.clone(), + }) + .collect(); + let swap_msg: CosmosMsg = MsgSwapExactAmountIn { sender: env.contract.address.to_string(), - routes: steps.to_vec(), + routes, token_in: Some(osmosis_std::types::cosmos::base::v1beta1::Coin { denom: coin_in.denom.clone(), amount: coin_in.amount.to_string(), diff --git a/contracts/swapper/osmosis/tests/test_enumerate_routes.rs b/contracts/swapper/osmosis/tests/test_enumerate_routes.rs index 9a6358bc1..c9a679a99 100644 --- a/contracts/swapper/osmosis/tests/test_enumerate_routes.rs +++ b/contracts/swapper/osmosis/tests/test_enumerate_routes.rs @@ -5,8 +5,7 @@ use std::collections::HashMap; use cosmwasm_std::coin; use cw_it::osmosis_test_tube::{Gamm, Module, OsmosisTestApp, SigningAccount, Wasm}; use mars_red_bank_types::swapper::{ExecuteMsg, QueryMsg, RouteResponse}; -use mars_swapper_osmosis::route::OsmosisRoute; -use osmosis_std::types::osmosis::poolmanager::v1beta1::SwapAmountInRoute; +use mars_swapper_osmosis::route::{OsmosisRoute, SwapAmountInRoute}; use crate::helpers::instantiate_contract; diff --git a/schemas/mars-swapper-osmosis/mars-swapper-osmosis.json b/schemas/mars-swapper-osmosis/mars-swapper-osmosis.json index 5fd1ac9ee..512d773a2 100644 --- a/schemas/mars-swapper-osmosis/mars-swapper-osmosis.json +++ b/schemas/mars-swapper-osmosis/mars-swapper-osmosis.json @@ -232,6 +232,7 @@ ] }, "SwapAmountInRoute": { + "description": "SwapAmountInRoute instead of using `osmosis_std::types::osmosis::poolmanager::v1beta1::SwapAmountInRoute` to keep consistency for pool_id representation as u64.\n\nSwapAmountInRoute from osmosis package uses as_str serializer/deserializer, so it expects pool_id as a String, but JSON schema doesn't correctly represent it.", "type": "object", "required": [ "pool_id", @@ -246,7 +247,8 @@ "token_out_denom": { "type": "string" } - } + }, + "additionalProperties": false }, "Uint128": { "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", diff --git a/scripts/deploy/addresses/osmo-test-5.json b/scripts/deploy/addresses/osmo-test-5.json index cf6020bfa..561d4776c 100644 --- a/scripts/deploy/addresses/osmo-test-5.json +++ b/scripts/deploy/addresses/osmo-test-5.json @@ -1,9 +1,9 @@ { - "address-provider": "osmo1xlf93me2979mvgj0gmluzuw22zxwd9rt2jaafzymw7d8kghkhwsqlwgh2r", - "red-bank": "osmo1r9ks824qewvpa9sqgzs3w2ylxx582c6d0hrnzqf3csufchqneydq60hgrv", - "incentives": "osmo1uq2y7h5sw8xtzhluhh7m9l3h9jdv5zjz7jhvavc3sgq0ps8ggq9s39qgcf", - "oracle": "osmo1vae2gsgeqw8q2x5ycvcrspsuqrnydveqgca03v8k9p4uvl2fgdlqp5r8fc", - "rewards-collector": "osmo1uw8g8mxlfk4at27xq26vqzttddtae7fgup4sd59ndrh0ymk99prsezh896", - "swapper": "osmo1q97xatqr3c0zrlgck60yd6f6nqvvtcg5772pngthzrkmdxkc6kqqdj56v2", - "params": "osmo1et0qv7acfv0wv3wlqmjtyflw5dectct24nuwjeqdkfzm9fznfunste0hnc" + "address-provider": "osmo1sm42690a2836cy0ufzaffvsc5e29xagm267ef7jm7acn82f7f4nsh320uv", + "red-bank": "osmo1hs4sm0fah9rk4mz8e56v4n76g0q9fffdkkjm3f8tjagkdx78pqcq75pk0a", + "incentives": "osmo1nu0k6g294jela67vyth6nwr3l42gutq2m07pg9927f7v7tuv0d4sre9fr7", + "oracle": "osmo1dxu93scjdnx42txdp9d4hm3snffvnzmkp4jpc9sml8xlu3ncgamsl2lx58", + "rewards-collector": "osmo1q8gsh9ugl68yx03as3se8w7yegzcpdggy56zxt0mxsjxjvsggyqqedj03f", + "swapper": "osmo1ee9cq8dcknmw43znznx6vuupx5ku0tt505agccgaz5gn48mhe45s3kwwfm", + "params": "osmo1h334tvddn82m4apm08rm9k6kt32ws7vy0c4n30ngrvu6h6yxh8eq9l9jfh" } diff --git a/scripts/deploy/base/deployer.ts b/scripts/deploy/base/deployer.ts index a5c7ea102..75cb7294b 100644 --- a/scripts/deploy/base/deployer.ts +++ b/scripts/deploy/base/deployer.ts @@ -21,9 +21,13 @@ import { InstantiateMsg as ParamsInstantiateMsg } from '../../types/generated/ma import { ExecuteMsg as ParamsExecuteMsg } from '../../types/generated/mars-params/MarsParams.types' import { InstantiateMsg as RedBankInstantiateMsg, + ExecuteMsg as RedBankExecuteMsg, QueryMsg as RedBankQueryMsg, } from '../../types/generated/mars-red-bank/MarsRedBank.types' -import { InstantiateMsg as AddressProviderInstantiateMsg } from '../../types/generated/mars-address-provider/MarsAddressProvider.types' +import { + AddressResponseItem, + InstantiateMsg as AddressProviderInstantiateMsg, +} from '../../types/generated/mars-address-provider/MarsAddressProvider.types' import { InstantiateMsg as IncentivesInstantiateMsg } from '../../types/generated/mars-incentives/MarsIncentives.types' import { InstantiateMsg as RewardsInstantiateMsg } from '../../types/generated/mars-rewards-collector-base/MarsRewardsCollectorBase.types' import { @@ -217,6 +221,40 @@ export class Deployer { printYellow(`${assetConfig.symbol} updated.`) } + async initializeMarket(assetConfig: AssetConfig) { + if (this.storage.execute.marketsUpdated.includes(assetConfig.denom)) { + printBlue(`${assetConfig.symbol} already initialized in red-bank contract`) + return + } + printBlue(`Initializing ${assetConfig.symbol}...`) + + const msg: RedBankExecuteMsg = { + init_asset: { + denom: assetConfig.denom, + params: { + reserve_factor: assetConfig.reserve_factor, + interest_rate_model: { + optimal_utilization_rate: assetConfig.interest_rate_model.optimal_utilization_rate, + base: assetConfig.interest_rate_model.base, + slope_1: assetConfig.interest_rate_model.slope_1, + slope_2: assetConfig.interest_rate_model.slope_2, + }, + }, + }, + } + + await this.client.execute( + this.deployerAddress, + this.storage.addresses['red-bank']!, + msg, + 'auto', + ) + + printYellow(`${assetConfig.symbol} initialized`) + + this.storage.execute.marketsUpdated.push(assetConfig.denom) + } + async updateVaultConfig(vaultConfig: VaultConfig) { if (this.storage.execute.vaultsUpdated.includes(vaultConfig.addr)) { printBlue(`${vaultConfig.symbol} already updated in Params contract`) @@ -273,38 +311,42 @@ export class Deployer { async updateAddressProvider() { printBlue('Updating addresses in Address Provider...') - const addressesToSet = [ + const addressesToSet: AddressResponseItem[] = [ { + address: this.storage.addresses['rewards-collector']!, address_type: 'rewards_collector', - address: this.storage.addresses['rewards-collector'], }, { + address: this.storage.addresses.incentives!, address_type: 'incentives', - address: this.storage.addresses.incentives, }, { + address: this.storage.addresses.oracle!, address_type: 'oracle', - address: this.storage.addresses.oracle, }, { + address: this.storage.addresses['red-bank']!, address_type: 'red_bank', - address: this.storage.addresses['red-bank'], }, { - address_type: 'fee_collector', address: this.config.feeCollectorAddr, + address_type: 'fee_collector', }, { - address_type: 'safety_fund', address: this.config.safetyFundAddr, + address_type: 'safety_fund', }, { - address_type: 'protocol_admin', address: this.config.protocolAdminAddr, + address_type: 'protocol_admin', }, { + address: this.storage.addresses.swapper!, address_type: 'swapper', - address: this.storage.addresses.swapper, + }, + { + address: this.storage.addresses.params!, + address_type: 'params', }, ] @@ -635,6 +677,23 @@ export class Deployer { assert.equal(swapperConfig.proposed, this.config.multisigAddr) } + async updateParamsContractOwner() { + const msg = { + update_owner: { + propose_new_owner: { + proposed: this.storage.owner, + }, + }, + } + await this.client.execute(this.deployerAddress, this.storage.addresses.params!, msg, 'auto') + printYellow('Owner updated to Mutlisig for Params') + const paramsConfig = (await this.client.queryContractSmart(this.storage.addresses.params!, { + owner: {}, + })) as { proposed: string } + + assert.equal(paramsConfig.proposed, this.config.multisigAddr) + } + async updateAddressProviderContractOwner() { const msg = { update_owner: { diff --git a/scripts/deploy/base/index.ts b/scripts/deploy/base/index.ts index fc3fa13ba..5dedb8547 100644 --- a/scripts/deploy/base/index.ts +++ b/scripts/deploy/base/index.ts @@ -19,6 +19,7 @@ export const taskRunner = async (config: DeploymentConfig) => { `mars_rewards_collector_${config.rewardsCollectorName}.wasm`, ) await deployer.upload('swapper', `mars_swapper_${config.swapperDexName}.wasm`) + await deployer.upload('params', `mars_params.wasm`) // Instantiate contracts deployer.setOwnerAddr() @@ -32,9 +33,10 @@ export const taskRunner = async (config: DeploymentConfig) => { await deployer.saveDeploymentAddrsToFile() // setup - await deployer.updateAddressProvider() + await deployer.updateAddressProvider() // CreditManager address in address-provider should be set once known for (const asset of config.assets) { await deployer.updateAssetParams(asset) + await deployer.initializeMarket(asset) } for (const vault of config.vaults) { await deployer.updateVaultConfig(vault) @@ -59,6 +61,7 @@ export const taskRunner = async (config: DeploymentConfig) => { await deployer.updateOracleContractOwner() await deployer.updateRewardsContractOwner() await deployer.updateSwapperContractOwner() + await deployer.updateParamsContractOwner() await deployer.updateAddressProviderContractOwner() printGreen('It is confirmed that all contracts have transferred ownership to the Multisig') } else { diff --git a/scripts/deploy/base/storage.ts b/scripts/deploy/base/storage.ts index 6f429224e..768ae3ee0 100644 --- a/scripts/deploy/base/storage.ts +++ b/scripts/deploy/base/storage.ts @@ -28,7 +28,12 @@ export class Storage implements StorageItems { return new this(chainId, { addresses: {}, codeIds: {}, - execute: { assetsUpdated: [], vaultsUpdated: [], addressProviderUpdated: {} }, + execute: { + assetsUpdated: [], + marketsUpdated: [], + vaultsUpdated: [], + addressProviderUpdated: {}, + }, }) } } diff --git a/scripts/deploy/neutron/config_mainnet.ts b/scripts/deploy/neutron/config_mainnet.ts index 2189aaf6b..f7ba6a1e3 100644 --- a/scripts/deploy/neutron/config_mainnet.ts +++ b/scripts/deploy/neutron/config_mainnet.ts @@ -277,13 +277,6 @@ export const ntrnAsset: AssetConfig = { }, protocol_liquidation_fee: '0.5', // liquidation_bonus: '0.15', - // reserve_factor: '0.1', - // interest_rate_model: { - // optimal_utilization_rate: '0.6', - // base: '0', - // slope_1: '0.15', - // slope_2: '3', - // }, symbol: 'NTRN', credit_manager: { whitelisted: false, @@ -293,6 +286,13 @@ export const ntrnAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '5000000000000', + reserve_factor: '0.1', + interest_rate_model: { + optimal_utilization_rate: '0.6', + base: '0', + slope_1: '0.15', + slope_2: '3', + }, } export const atomAsset: AssetConfig = { @@ -307,13 +307,6 @@ export const atomAsset: AssetConfig = { }, protocol_liquidation_fee: '0.5', // liquidation_bonus: '0.1', - // reserve_factor: '0.1', - // interest_rate_model: { - // optimal_utilization_rate: '0.7', - // base: '0', - // slope_1: '0.2', - // slope_2: '3', - // }, symbol: 'ATOM', credit_manager: { whitelisted: false, @@ -323,6 +316,13 @@ export const atomAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '150000000000', + reserve_factor: '0.1', + interest_rate_model: { + optimal_utilization_rate: '0.7', + base: '0', + slope_1: '0.2', + slope_2: '3', + }, } export const axlUSDCAsset: AssetConfig = { @@ -337,13 +337,6 @@ export const axlUSDCAsset: AssetConfig = { }, protocol_liquidation_fee: '0.5', // liquidation_bonus: '0.1', - // reserve_factor: '0.1', - // interest_rate_model: { - // optimal_utilization_rate: '0.8', - // base: '0', - // slope_1: '0.125', - // slope_2: '2', - // }, symbol: 'axlUSDC', credit_manager: { whitelisted: false, @@ -353,6 +346,13 @@ export const axlUSDCAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '500000000000', + reserve_factor: '0.1', + interest_rate_model: { + optimal_utilization_rate: '0.8', + base: '0', + slope_1: '0.125', + slope_2: '2', + }, } export const neutronMainnetConfig: DeploymentConfig = { diff --git a/scripts/deploy/neutron/config_testnet.ts b/scripts/deploy/neutron/config_testnet.ts index e15dcd429..612b31caa 100644 --- a/scripts/deploy/neutron/config_testnet.ts +++ b/scripts/deploy/neutron/config_testnet.ts @@ -236,13 +236,6 @@ export const ntrnAsset: AssetConfig = { }, protocol_liquidation_fee: '0.5', // liquidation_bonus: '0.15', - // reserve_factor: '0.1', - // interest_rate_model: { - // optimal_utilization_rate: '0.6', - // base: '0', - // slope_1: '0.15', - // slope_2: '3', - // }, symbol: 'NTRN', credit_manager: { whitelisted: false, @@ -252,6 +245,13 @@ export const ntrnAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '5000000000000', + reserve_factor: '0.1', + interest_rate_model: { + optimal_utilization_rate: '0.6', + base: '0', + slope_1: '0.15', + slope_2: '3', + }, } export const atomAsset: AssetConfig = { @@ -266,13 +266,6 @@ export const atomAsset: AssetConfig = { }, protocol_liquidation_fee: '0.5', // liquidation_bonus: '0.1', - // reserve_factor: '0.1', - // interest_rate_model: { - // optimal_utilization_rate: '0.7', - // base: '0', - // slope_1: '0.2', - // slope_2: '3', - // }, symbol: 'ATOM', credit_manager: { whitelisted: false, @@ -282,6 +275,13 @@ export const atomAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '150000000000', + reserve_factor: '0.1', + interest_rate_model: { + optimal_utilization_rate: '0.7', + base: '0', + slope_1: '0.2', + slope_2: '3', + }, } export const axlUSDCAsset: AssetConfig = { @@ -296,13 +296,6 @@ export const axlUSDCAsset: AssetConfig = { }, protocol_liquidation_fee: '0.5', // liquidation_bonus: '0.1', - // reserve_factor: '0.1', - // interest_rate_model: { - // optimal_utilization_rate: '0.8', - // base: '0', - // slope_1: '0.125', - // slope_2: '2', - // }, symbol: 'axlUSDC', credit_manager: { whitelisted: false, @@ -312,6 +305,13 @@ export const axlUSDCAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '500000000000', + reserve_factor: '0.1', + interest_rate_model: { + optimal_utilization_rate: '0.8', + base: '0', + slope_1: '0.125', + slope_2: '2', + }, } export const neutronTestnetConfig: DeploymentConfig = { diff --git a/scripts/deploy/neutron/config_testnet_multisig.ts b/scripts/deploy/neutron/config_testnet_multisig.ts index 15a0a2964..552e75eb0 100644 --- a/scripts/deploy/neutron/config_testnet_multisig.ts +++ b/scripts/deploy/neutron/config_testnet_multisig.ts @@ -273,13 +273,6 @@ export const ntrnAsset: AssetConfig = { }, protocol_liquidation_fee: '0.5', // liquidation_bonus: '0.15', - // reserve_factor: '0.1', - // interest_rate_model: { - // optimal_utilization_rate: '0.6', - // base: '0', - // slope_1: '0.15', - // slope_2: '3', - // }, symbol: 'NTRN', credit_manager: { whitelisted: false, @@ -289,6 +282,13 @@ export const ntrnAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '5000000000000', + reserve_factor: '0.1', + interest_rate_model: { + optimal_utilization_rate: '0.6', + base: '0', + slope_1: '0.15', + slope_2: '3', + }, } export const atomAsset: AssetConfig = { @@ -303,13 +303,6 @@ export const atomAsset: AssetConfig = { }, protocol_liquidation_fee: '0.5', // liquidation_bonus: '0.1', - // reserve_factor: '0.1', - // interest_rate_model: { - // optimal_utilization_rate: '0.7', - // base: '0', - // slope_1: '0.2', - // slope_2: '3', - // }, symbol: 'ATOM', credit_manager: { whitelisted: false, @@ -319,6 +312,13 @@ export const atomAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '150000000000', + reserve_factor: '0.1', + interest_rate_model: { + optimal_utilization_rate: '0.7', + base: '0', + slope_1: '0.2', + slope_2: '3', + }, } export const axlUSDCAsset: AssetConfig = { @@ -333,13 +333,6 @@ export const axlUSDCAsset: AssetConfig = { }, protocol_liquidation_fee: '0.5', // liquidation_bonus: '0.1', - // reserve_factor: '0.1', - // interest_rate_model: { - // optimal_utilization_rate: '0.8', - // base: '0', - // slope_1: '0.125', - // slope_2: '2', - // }, symbol: 'axlUSDC', credit_manager: { whitelisted: false, @@ -349,6 +342,13 @@ export const axlUSDCAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '500000000000', + reserve_factor: '0.1', + interest_rate_model: { + optimal_utilization_rate: '0.8', + base: '0', + slope_1: '0.125', + slope_2: '2', + }, } export const neutronTetstnetMultisigConfig: DeploymentConfig = { diff --git a/scripts/deploy/osmosis/config.ts b/scripts/deploy/osmosis/config.ts index 9dc457a75..3a59e3047 100644 --- a/scripts/deploy/osmosis/config.ts +++ b/scripts/deploy/osmosis/config.ts @@ -34,13 +34,6 @@ export const osmoAsset: AssetConfig = { starting_lb: '0', }, protocol_liquidation_fee: '0.5', - // reserve_factor: '0.2', - // interest_rate_model: { - // optimal_utilization_rate: '0.6', - // base: '0', - // slope_1: '0.15', - // slope_2: '3', - // }, symbol: 'OSMO', credit_manager: { whitelisted: true, @@ -50,6 +43,13 @@ export const osmoAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '2500000000000', + reserve_factor: '0.2', + interest_rate_model: { + optimal_utilization_rate: '0.6', + base: '0', + slope_1: '0.15', + slope_2: '3', + }, } export const atomAsset: AssetConfig = { @@ -63,13 +63,6 @@ export const atomAsset: AssetConfig = { starting_lb: '0', }, protocol_liquidation_fee: '0.5', - // reserve_factor: '0.2', - // interest_rate_model: { - // optimal_utilization_rate: '0.6', - // base: '0', - // slope_1: '0.15', - // slope_2: '3', - // }, symbol: 'ATOM', credit_manager: { whitelisted: true, @@ -79,6 +72,13 @@ export const atomAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '100000000000', + reserve_factor: '0.2', + interest_rate_model: { + optimal_utilization_rate: '0.6', + base: '0', + slope_1: '0.15', + slope_2: '3', + }, } export const atomAssetTest: AssetConfig = { @@ -92,13 +92,6 @@ export const atomAssetTest: AssetConfig = { starting_lb: '0', }, protocol_liquidation_fee: '0.5', - // reserve_factor: '0.2', - // interest_rate_model: { - // optimal_utilization_rate: '0.6', - // base: '0', - // slope_1: '0.15', - // slope_2: '3', - // }, symbol: 'ATOM', credit_manager: { whitelisted: true, @@ -108,6 +101,13 @@ export const atomAssetTest: AssetConfig = { deposit_enabled: true, }, deposit_cap: '100000000000', + reserve_factor: '0.2', + interest_rate_model: { + optimal_utilization_rate: '0.6', + base: '0', + slope_1: '0.15', + slope_2: '3', + }, } export const axlUSDCAsset: AssetConfig = { @@ -121,13 +121,6 @@ export const axlUSDCAsset: AssetConfig = { starting_lb: '0', }, protocol_liquidation_fee: '0.5', - // reserve_factor: '0.2', - // interest_rate_model: { - // optimal_utilization_rate: '0.8', - // base: '0', - // slope_1: '0.2', - // slope_2: '2', - // }, symbol: 'axlUSDC', credit_manager: { whitelisted: true, @@ -137,6 +130,13 @@ export const axlUSDCAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '500000000000', + reserve_factor: '0.2', + interest_rate_model: { + optimal_utilization_rate: '0.8', + base: '0', + slope_1: '0.2', + slope_2: '2', + }, } export const axlUSDCAssetTest: AssetConfig = { @@ -150,13 +150,6 @@ export const axlUSDCAssetTest: AssetConfig = { starting_lb: '0', }, protocol_liquidation_fee: '0.5', - // reserve_factor: '0.2', - // interest_rate_model: { - // optimal_utilization_rate: '0.8', - // base: '0', - // slope_1: '0.2', - // slope_2: '2', - // }, symbol: 'axlUSDC', credit_manager: { whitelisted: true, @@ -166,6 +159,13 @@ export const axlUSDCAssetTest: AssetConfig = { deposit_enabled: true, }, deposit_cap: '500000000000', + reserve_factor: '0.2', + interest_rate_model: { + optimal_utilization_rate: '0.8', + base: '0', + slope_1: '0.2', + slope_2: '2', + }, } export const marsAssetTest: AssetConfig = { @@ -179,13 +179,6 @@ export const marsAssetTest: AssetConfig = { starting_lb: '0', }, protocol_liquidation_fee: '0.5', - // reserve_factor: '0.2', - // interest_rate_model: { - // optimal_utilization_rate: '0.8', - // base: '0', - // slope_1: '0.2', - // slope_2: '2', - // }, symbol: 'mars', credit_manager: { whitelisted: true, @@ -195,6 +188,13 @@ export const marsAssetTest: AssetConfig = { deposit_enabled: true, }, deposit_cap: '500000000000', + reserve_factor: '0.2', + interest_rate_model: { + optimal_utilization_rate: '0.8', + base: '0', + slope_1: '0.2', + slope_2: '2', + }, } // export const osmoOracle: OracleConfig = { @@ -428,7 +428,7 @@ export const osmosisLocalConfig: DeploymentConfig = { assets: [osmoAsset, atomAsset, axlUSDCAsset], vaults: [], oracleConfigs: [atomOracle, axlUSDCOracle], - incentiveEpochDuration: 86400, + incentiveEpochDuration: 604800, // 1 week maxWhitelistedIncentiveDenoms: 10, targetHealthFactor: '1.2', } diff --git a/scripts/deploy/osmosis/mainnetConfig.ts b/scripts/deploy/osmosis/mainnetConfig.ts index fecc8d4c2..8085df2cd 100644 --- a/scripts/deploy/osmosis/mainnetConfig.ts +++ b/scripts/deploy/osmosis/mainnetConfig.ts @@ -33,6 +33,13 @@ export const osmoAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '2500000000000', + reserve_factor: '0.2', + interest_rate_model: { + optimal_utilization_rate: '0.8', + base: '0', + slope_1: '0.2', + slope_2: '2', + }, } export const atomAsset: AssetConfig = { @@ -55,6 +62,13 @@ export const atomAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '100000000000', + reserve_factor: '0.2', + interest_rate_model: { + optimal_utilization_rate: '0.8', + base: '0', + slope_1: '0.2', + slope_2: '2', + }, } export const axlUSDCAsset: AssetConfig = { @@ -77,6 +91,13 @@ export const axlUSDCAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '500000000000', + reserve_factor: '0.2', + interest_rate_model: { + optimal_utilization_rate: '0.8', + base: '0', + slope_1: '0.2', + slope_2: '2', + }, } export const atomOracle: OracleConfig = { @@ -165,6 +186,6 @@ export const osmosisMainnet: DeploymentConfig = { vaults: [], oracleConfigs: [atomOracle, axlUSDCOracle], targetHealthFactor: '1.2', - incentiveEpochDuration: 86400, + incentiveEpochDuration: 604800, // 1 week maxWhitelistedIncentiveDenoms: 10, } diff --git a/scripts/deploy/osmosis/testnetConfig.ts b/scripts/deploy/osmosis/testnetConfig.ts index 947a1fb11..35e554703 100644 --- a/scripts/deploy/osmosis/testnetConfig.ts +++ b/scripts/deploy/osmosis/testnetConfig.ts @@ -1,12 +1,13 @@ import { DeploymentConfig, AssetConfig, OracleConfig, VaultConfig } from '../../types/config' // assets based off of OSMO-TEST-5: https://docs.osmosis.zone/osmosis-core/asset-info/ -const osmo = 'uosmo' +const uosmo = 'uosmo' +const aUSDC = 'ibc/6F34E1BD664C36CE49ACC28E60D62559A5F96C4F9A6CCE4FC5A67B2852E24CFE' // axelar USDC const atom = 'ibc/A8C2D23A1E6F95DA4E48BA349667E322BD7A6C996D8A4AAE8BA72E190F3D1477' -const nUSDC = 'ibc/40F1B2458AEDA66431F9D44F48413240B8D28C072463E2BF53655728683583E3' // noble const mars = 'ibc/2E7368A14AC9AB7870F32CFEA687551C5064FA861868EDF7437BC877358A81F9' +const usdcOsmo = 'gamm/pool/5' +const atomOsmo = 'gamm/pool/12' -const pythContractAddr = 'UPDATE' const protocolAdminAddr = 'osmo14w4x949nwcrqgfe53pxs3k7x53p0gvlrq34l5n' // note the following addresses are all 'mars' bech32 prefix @@ -18,7 +19,7 @@ export const osmoAsset: AssetConfig = { whitelisted: true, }, symbol: 'OSMO', - denom: osmo, + denom: uosmo, liquidation_bonus: { max_lb: '0.05', min_lb: '0', @@ -33,6 +34,13 @@ export const osmoAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '2500000000000', + reserve_factor: '0.2', + interest_rate_model: { + optimal_utilization_rate: '0.8', + base: '0', + slope_1: '0.2', + slope_2: '2', + }, } export const atomAsset: AssetConfig = { @@ -55,14 +63,21 @@ export const atomAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '100000000000', + reserve_factor: '0.2', + interest_rate_model: { + optimal_utilization_rate: '0.8', + base: '0', + slope_1: '0.2', + slope_2: '2', + }, } export const USDCAsset: AssetConfig = { credit_manager: { whitelisted: true, }, - symbol: 'nUSDC', - denom: nUSDC, + symbol: 'aUSDC', + denom: aUSDC, liquidation_bonus: { max_lb: '0.05', min_lb: '0', @@ -77,13 +92,20 @@ export const USDCAsset: AssetConfig = { deposit_enabled: true, }, deposit_cap: '500000000000', + reserve_factor: '0.2', + interest_rate_model: { + optimal_utilization_rate: '0.8', + base: '0', + slope_1: '0.2', + slope_2: '2', + }, } export const usdcOsmoVault: VaultConfig = { - addr: 'osmo1fmq9hw224fgz8lk48wyd0gfg028kvvzggt6c3zvnaqkw23x68cws5nd5em', + addr: 'osmo1l3q4mrhkzjyernjhg8lz2t52ddw589y5qc0z7y8y28h6y5wcl46sg9n28j', symbol: 'usdcOsmoVault', deposit_cap: { - denom: nUSDC, + denom: aUSDC, amount: '1000000000', }, liquidation_threshold: '0.65', @@ -91,38 +113,73 @@ export const usdcOsmoVault: VaultConfig = { whitelisted: true, } +export const atomOsmoVault: VaultConfig = { + addr: 'osmo1m45ap4rq4m2mfjkcqu9ks9mxmyx2hvx0cdca9sjmrg46q7lghzqqhxxup5', + symbol: 'atomOsmoVault', + deposit_cap: { + denom: aUSDC, + amount: '1000000000', + }, + liquidation_threshold: '0.65', + max_loan_to_value: '0.63', + whitelisted: true, +} + +export const osmoOracle: OracleConfig = { + denom: uosmo, + price_source: { + fixed: { + price: '1', + }, + }, +} + export const atomOracle: OracleConfig = { denom: atom, price_source: { - pyth: { - contract_addr: pythContractAddr, - price_feed_id: 'UPDATE', - max_staleness: 60, - denom_decimals: 6, - max_confidence: '5', - max_deviation: '4', + geometric_twap: { + downtime_detector: { downtime: 'duration30m', recovery: 7200 }, + window_size: 1800, + pool_id: 12, }, }, } - export const USDCOracle: OracleConfig = { - denom: nUSDC, + denom: aUSDC, price_source: { staked_geometric_twap: { - transitive_denom: osmo, - pool_id: 6, + transitive_denom: uosmo, + pool_id: 5, window_size: 1800, downtime_detector: { downtime: 'duration30m', recovery: 7200 }, }, }, } +export const usdcOsmoOracle: OracleConfig = { + denom: usdcOsmo, + price_source: { + xyk_liquidity_token: { + pool_id: 5, + }, + }, +} + +export const atomOsmoOracle: OracleConfig = { + denom: atomOsmo, + price_source: { + xyk_liquidity_token: { + pool_id: 12, + }, + }, +} + export const osmosisTestnetConfig: DeploymentConfig = { oracleName: 'osmosis', - oracleBaseDenom: 'uusd', + oracleBaseDenom: 'uosmo', rewardsCollectorName: 'osmosis', atomDenom: atom, - baseAssetDenom: osmo, + baseAssetDenom: uosmo, gasPrice: '0.1uosmo', chainId: 'osmo-test-5', chainPrefix: 'osmo', @@ -138,19 +195,19 @@ export const osmosisTestnetConfig: DeploymentConfig = { runTests: false, mainnet: false, feeCollectorDenom: mars, - safetyFundDenom: nUSDC, + safetyFundDenom: aUSDC, swapRoutes: [ - { denom_in: atom, denom_out: osmo, route: [{ pool_id: 12, token_out_denom: osmo }] }, + { denom_in: atom, denom_out: uosmo, route: [{ pool_id: 12, token_out_denom: uosmo }] }, ], safetyFundAddr: safetyFundAddr, protocolAdminAddr: protocolAdminAddr, feeCollectorAddr: feeCollectorAddr, swapperDexName: 'osmosis', assets: [osmoAsset, atomAsset, USDCAsset], - vaults: [usdcOsmoVault], - oracleConfigs: [atomOracle, USDCOracle], + vaults: [usdcOsmoVault, atomOsmoVault], + oracleConfigs: [osmoOracle, atomOracle, USDCOracle, atomOsmoOracle, usdcOsmoOracle], targetHealthFactor: '1.2', - incentiveEpochDuration: 86400, + incentiveEpochDuration: 604800, // 1 week maxWhitelistedIncentiveDenoms: 10, } @@ -176,18 +233,18 @@ export const osmosisTestMultisig: DeploymentConfig = { runTests: false, mainnet: false, feeCollectorDenom: mars, - safetyFundDenom: nUSDC, + safetyFundDenom: aUSDC, swapRoutes: [ - { denom_in: atom, denom_out: 'uosmo', route: [{ pool_id: 1, token_out_denom: 'uosmo' }] }, + { denom_in: atom, denom_out: 'uosmo', route: [{ pool_id: 12, token_out_denom: 'uosmo' }] }, ], safetyFundAddr: safetyFundAddr, protocolAdminAddr: protocolAdminAddr, feeCollectorAddr: feeCollectorAddr, swapperDexName: 'osmosis', assets: [osmoAsset, atomAsset, USDCAsset], - vaults: [usdcOsmoVault], - oracleConfigs: [atomOracle, USDCOracle], + vaults: [usdcOsmoVault, atomOsmoVault], + oracleConfigs: [osmoOracle, atomOracle, USDCOracle, atomOsmoOracle, usdcOsmoOracle], targetHealthFactor: '1.2', - incentiveEpochDuration: 86400, + incentiveEpochDuration: 604800, // 1 week maxWhitelistedIncentiveDenoms: 10, } diff --git a/scripts/types/config.ts b/scripts/types/config.ts index 5243ab649..413242d33 100644 --- a/scripts/types/config.ts +++ b/scripts/types/config.ts @@ -81,6 +81,13 @@ export interface AssetConfig { protocol_liquidation_fee: Decimal red_bank: RedBankSettings deposit_cap: Uint128 + reserve_factor: string + interest_rate_model: { + optimal_utilization_rate: string + base: string + slope_1: string + slope_2: string + } } export interface VaultConfig { addr: string diff --git a/scripts/types/generated/mars-swapper-osmosis/MarsSwapperOsmosis.types.ts b/scripts/types/generated/mars-swapper-osmosis/MarsSwapperOsmosis.types.ts index 0046c3fb7..0df6ac650 100644 --- a/scripts/types/generated/mars-swapper-osmosis/MarsSwapperOsmosis.types.ts +++ b/scripts/types/generated/mars-swapper-osmosis/MarsSwapperOsmosis.types.ts @@ -55,7 +55,6 @@ export type Addr = string export interface SwapAmountInRoute { pool_id: number token_out_denom: string - [k: string]: unknown } export interface Coin { amount: Uint128 diff --git a/scripts/types/storageItems.ts b/scripts/types/storageItems.ts index f5a134753..2ec983b9d 100644 --- a/scripts/types/storageItems.ts +++ b/scripts/types/storageItems.ts @@ -21,6 +21,7 @@ export interface StorageItems { execute: { addressProviderUpdated: Record assetsUpdated: string[] + marketsUpdated: string[] vaultsUpdated: string[] oraclePriceSet?: boolean smokeTest?: boolean