diff --git a/Cargo.lock b/Cargo.lock index c5e2c8b9..b06e4b04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2673,6 +2673,7 @@ version = "2.0.0" dependencies = [ "anyhow", "astroport 2.9.0", + "astroport 5.0.0-rc.1-tokenfactory", "cosmwasm-schema", "cosmwasm-std", "cw-it", diff --git a/Cargo.toml b/Cargo.toml index afaed10e..3248994e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,6 +59,8 @@ anyhow = "1.0.80" apollo-cw-asset = { version = "0.1.2", features = ["astroport"] } apollo-utils = "0.1.2" astroport = "2.8.0" +# TODO: update with official release once ready +astroport-v5 = { package = "astroport", version = "=5.0.0-rc.1-tokenfactory" } bech32 = "0.9.1" cosmwasm-schema = "1.5.3" cosmwasm-std = "1.5.4" diff --git a/contracts/incentives/Cargo.toml b/contracts/incentives/Cargo.toml index 9c7305b2..a3d19ce7 100644 --- a/contracts/incentives/Cargo.toml +++ b/contracts/incentives/Cargo.toml @@ -15,13 +15,12 @@ crate-type = ["cdylib", "rlib"] doctest = false [features] -astroport = ["cw-it/astroport"] # for more explicit tests, cargo test --features=backtraces backtraces = ["cosmwasm-std/backtraces", "mars-testing/backtraces", "mars-utils/backtraces", "mars-red-bank/backtraces"] library = [] [dependencies] -astroport = "=5.0.0-rc.1-tokenfactory" +astroport-v5 = { workspace = true } cosmwasm-schema = { workspace = true } cosmwasm-std = { workspace = true } cw2 = { workspace = true } diff --git a/contracts/incentives/src/astroport_incentives.rs b/contracts/incentives/src/astroport_incentives.rs index 8b33b226..b96154df 100644 --- a/contracts/incentives/src/astroport_incentives.rs +++ b/contracts/incentives/src/astroport_incentives.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use astroport::incentives::ExecuteMsg; +use astroport_v5::incentives::ExecuteMsg; use cosmwasm_std::{ ensure_eq, to_json_binary, BankMsg, Coin, CosmosMsg, Decimal, DepsMut, Env, Event, MessageInfo, Order::Ascending, Response, StdResult, Storage, Uint128, WasmMsg, diff --git a/contracts/incentives/src/helpers.rs b/contracts/incentives/src/helpers.rs index 59922717..db82e33a 100644 --- a/contracts/incentives/src/helpers.rs +++ b/contracts/incentives/src/helpers.rs @@ -3,7 +3,7 @@ use std::{ collections::HashMap, }; -use astroport::incentives::ExecuteMsg; +use astroport_v5::incentives::ExecuteMsg; use cosmwasm_std::{ coin, to_json_binary, Addr, BlockInfo, Coin, CosmosMsg, Decimal, Deps, MessageInfo, Order, OverflowError, OverflowOperation, QuerierWrapper, StdError, StdResult, Storage, Uint128, diff --git a/contracts/incentives/src/query.rs b/contracts/incentives/src/query.rs index 82cd284d..9e2aa979 100644 --- a/contracts/incentives/src/query.rs +++ b/contracts/incentives/src/query.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use astroport::asset::Asset; +use astroport_v5::asset::Asset; use cosmwasm_std::{ Addr, Coin, Coins, Decimal, Deps, Env, Order, Order::Ascending, StdResult, Uint128, }; @@ -102,7 +102,7 @@ pub fn query_unclaimed_astroport_rewards( ) -> Result, ContractError> { let result: Vec = deps.querier.query_wasm_smart( astroport_incentives_addr, - &astroport::incentives::QueryMsg::PendingRewards { + &astroport_v5::incentives::QueryMsg::PendingRewards { lp_token: lp_denom.to_string(), user: mars_incentives_addr.to_string(), }, diff --git a/contracts/incentives/tests/tests/test_claim_astro_lp_rewards.rs b/contracts/incentives/tests/tests/test_claim_astro_lp_rewards.rs index 8212971b..8afd36d0 100644 --- a/contracts/incentives/tests/tests/test_claim_astro_lp_rewards.rs +++ b/contracts/incentives/tests/tests/test_claim_astro_lp_rewards.rs @@ -1,8 +1,8 @@ +use astroport_v5::asset::Asset; use cosmwasm_std::{ testing::{mock_env, mock_info, MockApi}, Addr, Coin, Deps, DepsMut, Env, MemoryStorage, OwnedDeps, Response, Uint128, }; -use cw_it::astroport::astroport_v3::asset::Asset; use mars_incentives::{contract::execute, query, state::ASTRO_TOTAL_LP_DEPOSITS, ContractError}; use mars_testing::{assert_eq_vec, MarsMockQuerier}; use mars_types::{ diff --git a/contracts/v2-zapper/astroport/Cargo.toml b/contracts/v2-zapper/astroport/Cargo.toml index 32751c03..f52785ef 100644 --- a/contracts/v2-zapper/astroport/Cargo.toml +++ b/contracts/v2-zapper/astroport/Cargo.toml @@ -21,8 +21,7 @@ library = [] [dependencies] apollo-cw-asset = { workspace = true } apollo-utils = { workspace = true } -# TODO: update with official release once ready -astroport = "=5.0.0-rc.1-tokenfactory" +astroport-v5 = { workspace = true } cosmwasm-std = { workspace = true } cw2 = { workspace = true } cw-dex = { workspace = true } diff --git a/contracts/v2-zapper/astroport/src/lp_pool.rs b/contracts/v2-zapper/astroport/src/lp_pool.rs index 4d240dc1..65d725e6 100644 --- a/contracts/v2-zapper/astroport/src/lp_pool.rs +++ b/contracts/v2-zapper/astroport/src/lp_pool.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use apollo_cw_asset::{Asset, AssetInfo, AssetInfoBase, AssetList}; use apollo_utils::assets::assert_only_native_coins; -use astroport::{ +use astroport_v5::{ asset::{Asset as AstroAsset, AssetInfo as AstroAssetInfo, PairInfo}, factory::PairType, pair::{PoolResponse, QueryMsg as PairQueryMsg, MAX_ALLOWED_SLIPPAGE}, @@ -133,7 +133,7 @@ impl Pool for AstroportLpPool { // Create the provide liquidity message let provide_liquidity_msg = CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: self.pair_addr.to_string(), - msg: to_json_binary(&astroport::pair::ExecuteMsg::ProvideLiquidity { + msg: to_json_binary(&astroport_v5::pair::ExecuteMsg::ProvideLiquidity { assets: astro_assets, slippage_tolerance: Some(Decimal::from_str(MAX_ALLOWED_SLIPPAGE)?), auto_stake: Some(false), @@ -163,7 +163,7 @@ impl Pool for AstroportLpPool { let withdraw_liquidity = CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: self.pair_addr.to_string(), - msg: to_json_binary(&astroport::pair::ExecuteMsg::WithdrawLiquidity { + msg: to_json_binary(&astroport_v5::pair::ExecuteMsg::WithdrawLiquidity { // This field is currently not used... assets: vec![], min_assets_to_receive: Some(astro_assets), @@ -211,7 +211,7 @@ impl Pool for AstroportLpPool { let amount: Uint128 = deps.querier.query_wasm_smart( self.pair_addr.to_string(), - &astroport::pair::QueryMsg::SimulateProvide { + &astroport_v5::pair::QueryMsg::SimulateProvide { assets: astro_assets, slippage_tolerance: Some(Decimal::from_str(MAX_ALLOWED_SLIPPAGE)?), }, @@ -232,7 +232,7 @@ impl Pool for AstroportLpPool { ) -> Result { let assets: Vec = deps.querier.query_wasm_smart( self.pair_addr.to_string(), - &astroport::pair::QueryMsg::SimulateWithdraw { + &astroport_v5::pair::QueryMsg::SimulateWithdraw { lp_amount: lp_token.amount, }, )?; diff --git a/packages/testing/Cargo.toml b/packages/testing/Cargo.toml index 8138cd67..eb6c9646 100644 --- a/packages/testing/Cargo.toml +++ b/packages/testing/Cargo.toml @@ -22,6 +22,7 @@ osmosis-test-tube = ["cw-it/osmosis-test-tube"] [dependencies] anyhow = { workspace = true } astroport = { workspace = true, optional = true } +astroport-v5 = { workspace = true } cosmwasm-std = { workspace = true } cosmwasm-schema = { workspace = true } cw721 = { workspace = true } diff --git a/packages/testing/src/astroport_incentives_querier.rs b/packages/testing/src/astroport_incentives_querier.rs index 89f992c8..d55297cc 100644 --- a/packages/testing/src/astroport_incentives_querier.rs +++ b/packages/testing/src/astroport_incentives_querier.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; +use astroport_v5::{asset::Asset, incentives::QueryMsg}; use cosmwasm_std::{to_json_binary, Addr, Binary, ContractResult, QuerierResult, Uint128}; -use cw_it::astroport::astroport_v3::{asset::Asset, incentives::QueryMsg}; pub struct AstroportIncentivesQuerier { /// Holds mock rewards, key is (user, lp_token_denom) diff --git a/packages/testing/src/lib.rs b/packages/testing/src/lib.rs index 95b5e813..1996c8f5 100644 --- a/packages/testing/src/lib.rs +++ b/packages/testing/src/lib.rs @@ -2,8 +2,8 @@ extern crate core; -#[cfg(feature = "astroport")] pub mod astroport_incentives_querier; +#[cfg(feature = "astroport")] pub mod astroport_swapper; mod cosmwasm_pool_querier; /// cosmwasm_std::testing overrides and custom test helpers diff --git a/packages/testing/src/mars_mock_querier.rs b/packages/testing/src/mars_mock_querier.rs index 975bc349..ae56cadf 100644 --- a/packages/testing/src/mars_mock_querier.rs +++ b/packages/testing/src/mars_mock_querier.rs @@ -1,10 +1,10 @@ +use astroport_v5::asset::Asset; use cosmwasm_std::{ from_json, testing::{MockQuerier, MOCK_CONTRACT_ADDR}, Addr, Coin, Decimal, Empty, Querier, QuerierResult, QueryRequest, StdResult, SystemError, SystemResult, Uint128, WasmQuery, }; -use cw_it::astroport::{astroport_v3, astroport_v3::asset::Asset}; use ica_oracle::msg::RedemptionRateResponse; use mars_oracle_osmosis::DowntimeDetector; use mars_types::{address_provider, incentives, oracle, params::AssetParams, red_bank}; @@ -259,7 +259,7 @@ impl MarsMockQuerier { // Astroport Incentive Queries if let Ok(astroport_incentives_query) = - from_json::(msg) + from_json::(msg) { return self .astroport_incentives_querier diff --git a/schemas/mars-address-provider/mars-address-provider.json b/schemas/mars-address-provider/mars-address-provider.json index a8ce16fd..9cf4cd37 100644 --- a/schemas/mars-address-provider/mars-address-provider.json +++ b/schemas/mars-address-provider/mars-address-provider.json @@ -108,6 +108,13 @@ "enum": [ "swapper" ] + }, + { + "description": "Astroport incentives contract", + "type": "string", + "enum": [ + "astroport_incentives" + ] } ] }, @@ -312,6 +319,13 @@ "enum": [ "swapper" ] + }, + { + "description": "Astroport incentives contract", + "type": "string", + "enum": [ + "astroport_incentives" + ] } ] } @@ -384,6 +398,13 @@ "enum": [ "swapper" ] + }, + { + "description": "Astroport incentives contract", + "type": "string", + "enum": [ + "astroport_incentives" + ] } ] } @@ -459,6 +480,13 @@ "enum": [ "swapper" ] + }, + { + "description": "Astroport incentives contract", + "type": "string", + "enum": [ + "astroport_incentives" + ] } ] } @@ -534,6 +562,13 @@ "enum": [ "swapper" ] + }, + { + "description": "Astroport incentives contract", + "type": "string", + "enum": [ + "astroport_incentives" + ] } ] } diff --git a/schemas/mars-incentives/mars-incentives.json b/schemas/mars-incentives/mars-incentives.json index a07776b8..29972c1e 100644 --- a/schemas/mars-incentives/mars-incentives.json +++ b/schemas/mars-incentives/mars-incentives.json @@ -228,6 +228,95 @@ }, "additionalProperties": false }, + { + "type": "object", + "required": [ + "claim_astro_lp_rewards" + ], + "properties": { + "claim_astro_lp_rewards": { + "type": "object", + "required": [ + "account_id", + "lp_denom" + ], + "properties": { + "account_id": { + "type": "string" + }, + "lp_denom": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Stake Astroport LP tokens in astroport incentives contract to receive rewards.", + "type": "object", + "required": [ + "stake_astro_lp" + ], + "properties": { + "stake_astro_lp": { + "type": "object", + "required": [ + "account_id", + "lp_coin" + ], + "properties": { + "account_id": { + "description": "User credit account Id", + "type": "string" + }, + "lp_coin": { + "description": "AstroLp token to stake.", + "allOf": [ + { + "$ref": "#/definitions/Coin" + } + ] + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Unstake Astroport LP tokens from astroport incentives contract. Sends tokens back to the users credit account", + "type": "object", + "required": [ + "unstake_astro_lp" + ], + "properties": { + "unstake_astro_lp": { + "type": "object", + "required": [ + "account_id", + "lp_coin" + ], + "properties": { + "account_id": { + "description": "User credit account Id", + "type": "string" + }, + "lp_coin": { + "description": "AstroLp token to unstake.", + "allOf": [ + { + "$ref": "#/definitions/ActionCoin" + } + ] + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, { "description": "Update contract config (only callable by owner)", "type": "object", @@ -287,10 +376,63 @@ } ], "definitions": { + "ActionAmount": { + "oneOf": [ + { + "type": "string", + "enum": [ + "account_balance" + ] + }, + { + "type": "object", + "required": [ + "exact" + ], + "properties": { + "exact": { + "$ref": "#/definitions/Uint128" + } + }, + "additionalProperties": false + } + ] + }, + "ActionCoin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/ActionAmount" + }, + "denom": { + "type": "string" + } + }, + "additionalProperties": false + }, "Addr": { "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", "type": "string" }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, "MigrateV1ToV2": { "description": "Migrate from V1 to V2, only owner can call", "oneOf": [ @@ -546,6 +688,73 @@ }, "additionalProperties": false }, + { + "description": "Enumerate a users LP positions with pagination", + "type": "object", + "required": [ + "staked_lp_positions" + ], + "properties": { + "staked_lp_positions": { + "type": "object", + "required": [ + "account_id" + ], + "properties": { + "account_id": { + "description": "The id of the account who owns the LP", + "type": "string" + }, + "limit": { + "description": "The maximum number of results to return. If not set, 5 is used. If larger than 10, 10 is used.", + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "description": "Start pagination after this lp denom, if used.", + "type": [ + "string", + "null" + ] + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Get specific details on a users LP Position", + "type": "object", + "required": [ + "staked_lp_position" + ], + "properties": { + "staked_lp_position": { + "type": "object", + "required": [ + "account_id", + "lp_denom" + ], + "properties": { + "account_id": { + "description": "The id of the account who owns the LP", + "type": "string" + }, + "lp_denom": { + "description": "The denom of the LP position", + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, { "description": "Queries the planned emission rate for a given collateral and incentive denom tuple at the specified unix timestamp. The emission rate returned is the amount of incentive tokens that will be emitted per second for each unit of collateral supplied during the epoch. NB: that the returned value can change if someone adds incentives to the contract.", "type": "object", @@ -932,6 +1141,121 @@ } } }, + "staked_lp_position": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "StakedLpPositionResponse", + "type": "object", + "required": [ + "lp_coin", + "rewards" + ], + "properties": { + "lp_coin": { + "$ref": "#/definitions/Coin" + }, + "rewards": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + }, + "additionalProperties": false, + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "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); ```", + "type": "string" + } + } + }, + "staked_lp_positions": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PaginationResponse_for_StakedLpPositionResponse", + "type": "object", + "required": [ + "data", + "metadata" + ], + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/StakedLpPositionResponse" + } + }, + "metadata": { + "$ref": "#/definitions/Metadata" + } + }, + "additionalProperties": false, + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "Metadata": { + "type": "object", + "required": [ + "has_more" + ], + "properties": { + "has_more": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "StakedLpPositionResponse": { + "type": "object", + "required": [ + "lp_coin", + "rewards" + ], + "properties": { + "lp_coin": { + "$ref": "#/definitions/Coin" + }, + "rewards": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + }, + "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); ```", + "type": "string" + } + } + }, "user_unclaimed_rewards": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Array_of_Coin", diff --git a/scripts/types/generated/mars-address-provider/MarsAddressProvider.types.ts b/scripts/types/generated/mars-address-provider/MarsAddressProvider.types.ts index 572f4035..87688b41 100644 --- a/scripts/types/generated/mars-address-provider/MarsAddressProvider.types.ts +++ b/scripts/types/generated/mars-address-provider/MarsAddressProvider.types.ts @@ -25,6 +25,7 @@ export type MarsAddressType = | 'fee_collector' | 'safety_fund' | 'swapper' + | 'astroport_incentives' export type OwnerUpdate = | { propose_new_owner: { diff --git a/scripts/types/generated/mars-incentives/MarsIncentives.client.ts b/scripts/types/generated/mars-incentives/MarsIncentives.client.ts index cf9a37c8..45c8c554 100644 --- a/scripts/types/generated/mars-incentives/MarsIncentives.client.ts +++ b/scripts/types/generated/mars-incentives/MarsIncentives.client.ts @@ -12,9 +12,12 @@ import { ExecuteMsg, Uint128, Addr, + ActionAmount, OwnerUpdate, MigrateV1ToV2, WhitelistEntry, + Coin, + ActionCoin, QueryMsg, ArrayOfActiveEmission, ActiveEmission, @@ -24,8 +27,10 @@ import { Decimal, IncentiveStateResponse, ArrayOfIncentiveStateResponse, + StakedLpPositionResponse, + PaginationResponseForStakedLpPositionResponse, + Metadata, ArrayOfCoin, - Coin, ArrayOfWhitelistEntry, } from './MarsIncentives.types' export interface MarsIncentivesReadOnlyInterface { @@ -52,6 +57,22 @@ export interface MarsIncentivesReadOnlyInterface { startAfterCollateralDenom?: string startAfterIncentiveDenom?: string }) => Promise + stakedLpPositions: ({ + accountId, + limit, + startAfter, + }: { + accountId: string + limit?: number + startAfter?: string + }) => Promise + stakedLpPosition: ({ + accountId, + lpDenom, + }: { + accountId: string + lpDenom: string + }) => Promise emission: ({ collateralDenom, incentiveDenom, @@ -98,6 +119,8 @@ export class MarsIncentivesQueryClient implements MarsIncentivesReadOnlyInterfac this.config = this.config.bind(this) this.incentiveState = this.incentiveState.bind(this) this.incentiveStates = this.incentiveStates.bind(this) + this.stakedLpPositions = this.stakedLpPositions.bind(this) + this.stakedLpPosition = this.stakedLpPosition.bind(this) this.emission = this.emission.bind(this) this.emissions = this.emissions.bind(this) this.userUnclaimedRewards = this.userUnclaimedRewards.bind(this) @@ -151,6 +174,37 @@ export class MarsIncentivesQueryClient implements MarsIncentivesReadOnlyInterfac }, }) } + stakedLpPositions = async ({ + accountId, + limit, + startAfter, + }: { + accountId: string + limit?: number + startAfter?: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + staked_lp_positions: { + account_id: accountId, + limit, + start_after: startAfter, + }, + }) + } + stakedLpPosition = async ({ + accountId, + lpDenom, + }: { + accountId: string + lpDenom: string + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + staked_lp_position: { + account_id: accountId, + lp_denom: lpDenom, + }, + }) + } emission = async ({ collateralDenom, incentiveDenom, @@ -284,6 +338,42 @@ export interface MarsIncentivesInterface extends MarsIncentivesReadOnlyInterface memo?: string, _funds?: Coin[], ) => Promise + claimAstroLpRewards: ( + { + accountId, + lpDenom, + }: { + accountId: string + lpDenom: string + }, + fee?: number | StdFee | 'auto', + memo?: string, + _funds?: Coin[], + ) => Promise + stakeAstroLp: ( + { + accountId, + lpCoin, + }: { + accountId: string + lpCoin: Coin + }, + fee?: number | StdFee | 'auto', + memo?: string, + _funds?: Coin[], + ) => Promise + unstakeAstroLp: ( + { + accountId, + lpCoin, + }: { + accountId: string + lpCoin: ActionCoin + }, + fee?: number | StdFee | 'auto', + memo?: string, + _funds?: Coin[], + ) => Promise updateConfig: ( { addressProvider, @@ -326,6 +416,9 @@ export class MarsIncentivesClient this.setAssetIncentive = this.setAssetIncentive.bind(this) this.balanceChange = this.balanceChange.bind(this) this.claimRewards = this.claimRewards.bind(this) + this.claimAstroLpRewards = this.claimAstroLpRewards.bind(this) + this.stakeAstroLp = this.stakeAstroLp.bind(this) + this.unstakeAstroLp = this.unstakeAstroLp.bind(this) this.updateConfig = this.updateConfig.bind(this) this.updateOwner = this.updateOwner.bind(this) this.migrate = this.migrate.bind(this) @@ -459,6 +552,84 @@ export class MarsIncentivesClient _funds, ) } + claimAstroLpRewards = async ( + { + accountId, + lpDenom, + }: { + accountId: string + lpDenom: string + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + _funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + claim_astro_lp_rewards: { + account_id: accountId, + lp_denom: lpDenom, + }, + }, + fee, + memo, + _funds, + ) + } + stakeAstroLp = async ( + { + accountId, + lpCoin, + }: { + accountId: string + lpCoin: Coin + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + _funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + stake_astro_lp: { + account_id: accountId, + lp_coin: lpCoin, + }, + }, + fee, + memo, + _funds, + ) + } + unstakeAstroLp = async ( + { + accountId, + lpCoin, + }: { + accountId: string + lpCoin: ActionCoin + }, + fee: number | StdFee | 'auto' = 'auto', + memo?: string, + _funds?: Coin[], + ): Promise => { + return await this.client.execute( + this.sender, + this.contractAddress, + { + unstake_astro_lp: { + account_id: accountId, + lp_coin: lpCoin, + }, + }, + fee, + memo, + _funds, + ) + } updateConfig = async ( { addressProvider, diff --git a/scripts/types/generated/mars-incentives/MarsIncentives.react-query.ts b/scripts/types/generated/mars-incentives/MarsIncentives.react-query.ts index 109af6c7..a512c6ea 100644 --- a/scripts/types/generated/mars-incentives/MarsIncentives.react-query.ts +++ b/scripts/types/generated/mars-incentives/MarsIncentives.react-query.ts @@ -13,9 +13,12 @@ import { ExecuteMsg, Uint128, Addr, + ActionAmount, OwnerUpdate, MigrateV1ToV2, WhitelistEntry, + Coin, + ActionCoin, QueryMsg, ArrayOfActiveEmission, ActiveEmission, @@ -25,8 +28,10 @@ import { Decimal, IncentiveStateResponse, ArrayOfIncentiveStateResponse, + StakedLpPositionResponse, + PaginationResponseForStakedLpPositionResponse, + Metadata, ArrayOfCoin, - Coin, ArrayOfWhitelistEntry, } from './MarsIncentives.types' import { MarsIncentivesQueryClient, MarsIncentivesClient } from './MarsIncentives.client' @@ -52,6 +57,22 @@ export const marsIncentivesQueryKeys = { [ { ...marsIncentivesQueryKeys.address(contractAddress)[0], method: 'incentive_states', args }, ] as const, + stakedLpPositions: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsIncentivesQueryKeys.address(contractAddress)[0], + method: 'staked_lp_positions', + args, + }, + ] as const, + stakedLpPosition: (contractAddress: string | undefined, args?: Record) => + [ + { + ...marsIncentivesQueryKeys.address(contractAddress)[0], + method: 'staked_lp_position', + args, + }, + ] as const, emission: (contractAddress: string | undefined, args?: Record) => [{ ...marsIncentivesQueryKeys.address(contractAddress)[0], method: 'emission', args }] as const, emissions: (contractAddress: string | undefined, args?: Record) => @@ -176,6 +197,54 @@ export function useMarsIncentivesEmissionQuery({ { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, ) } +export interface MarsIncentivesStakedLpPositionQuery + extends MarsIncentivesReactQuery { + args: { + accountId: string + lpDenom: string + } +} +export function useMarsIncentivesStakedLpPositionQuery({ + client, + args, + options, +}: MarsIncentivesStakedLpPositionQuery) { + return useQuery( + marsIncentivesQueryKeys.stakedLpPosition(client?.contractAddress, args), + () => + client + ? client.stakedLpPosition({ + accountId: args.accountId, + lpDenom: args.lpDenom, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} +export interface MarsIncentivesStakedLpPositionsQuery + extends MarsIncentivesReactQuery { + args: { + accountId: string + limit?: number + startAfter?: string + } +} +export function useMarsIncentivesStakedLpPositionsQuery< + TData = PaginationResponseForStakedLpPositionResponse, +>({ client, args, options }: MarsIncentivesStakedLpPositionsQuery) { + return useQuery( + marsIncentivesQueryKeys.stakedLpPositions(client?.contractAddress, args), + () => + client + ? client.stakedLpPositions({ + accountId: args.accountId, + limit: args.limit, + startAfter: args.startAfter, + }) + : Promise.reject(new Error('Invalid client')), + { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, + ) +} export interface MarsIncentivesIncentiveStatesQuery extends MarsIncentivesReactQuery { args: { @@ -324,6 +393,78 @@ export function useMarsIncentivesUpdateConfigMutation( options, ) } +export interface MarsIncentivesUnstakeAstroLpMutation { + client: MarsIncentivesClient + msg: { + accountId: string + lpCoin: ActionCoin + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsIncentivesUnstakeAstroLpMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.unstakeAstroLp(msg, fee, memo, funds), + options, + ) +} +export interface MarsIncentivesStakeAstroLpMutation { + client: MarsIncentivesClient + msg: { + accountId: string + lpCoin: Coin + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsIncentivesStakeAstroLpMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.stakeAstroLp(msg, fee, memo, funds), + options, + ) +} +export interface MarsIncentivesClaimAstroLpRewardsMutation { + client: MarsIncentivesClient + msg: { + accountId: string + lpDenom: string + } + args?: { + fee?: number | StdFee | 'auto' + memo?: string + funds?: Coin[] + } +} +export function useMarsIncentivesClaimAstroLpRewardsMutation( + options?: Omit< + UseMutationOptions, + 'mutationFn' + >, +) { + return useMutation( + ({ client, msg, args: { fee, memo, funds } = {} }) => + client.claimAstroLpRewards(msg, fee, memo, funds), + options, + ) +} export interface MarsIncentivesClaimRewardsMutation { client: MarsIncentivesClient msg: { diff --git a/scripts/types/generated/mars-incentives/MarsIncentives.types.ts b/scripts/types/generated/mars-incentives/MarsIncentives.types.ts index 257a7c05..5069a172 100644 --- a/scripts/types/generated/mars-incentives/MarsIncentives.types.ts +++ b/scripts/types/generated/mars-incentives/MarsIncentives.types.ts @@ -44,6 +44,24 @@ export type ExecuteMsg = start_after_incentive_denom?: string | null } } + | { + claim_astro_lp_rewards: { + account_id: string + lp_denom: string + } + } + | { + stake_astro_lp: { + account_id: string + lp_coin: Coin + } + } + | { + unstake_astro_lp: { + account_id: string + lp_coin: ActionCoin + } + } | { update_config: { address_provider?: string | null @@ -58,6 +76,11 @@ export type ExecuteMsg = } export type Uint128 = string export type Addr = string +export type ActionAmount = + | 'account_balance' + | { + exact: Uint128 + } export type OwnerUpdate = | { propose_new_owner: { @@ -86,6 +109,15 @@ export interface WhitelistEntry { denom: string min_emission_rate: Uint128 } +export interface Coin { + amount: Uint128 + denom: string + [k: string]: unknown +} +export interface ActionCoin { + amount: ActionAmount + denom: string +} export type QueryMsg = | { active_emissions: { @@ -108,6 +140,19 @@ export type QueryMsg = start_after_incentive_denom?: string | null } } + | { + staked_lp_positions: { + account_id: string + limit?: number | null + start_after?: string | null + } + } + | { + staked_lp_position: { + account_id: string + lp_denom: string + } + } | { emission: { collateral_denom: string @@ -161,10 +206,16 @@ export interface IncentiveStateResponse { last_updated: number } export type ArrayOfIncentiveStateResponse = IncentiveStateResponse[] -export type ArrayOfCoin = Coin[] -export interface Coin { - amount: Uint128 - denom: string - [k: string]: unknown +export interface StakedLpPositionResponse { + lp_coin: Coin + rewards: Coin[] +} +export interface PaginationResponseForStakedLpPositionResponse { + data: StakedLpPositionResponse[] + metadata: Metadata } +export interface Metadata { + has_more: boolean +} +export type ArrayOfCoin = Coin[] export type ArrayOfWhitelistEntry = WhitelistEntry[]