-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: add market (auction paradigm 2) to server #298
base: main
Are you sure you want to change the base?
Changes from 7 commits
4fb3234
2e1fcad
eebc145
72bf7af
c3704ae
af57751
9f8d6d6
57acf6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,9 +58,8 @@ pub struct OpportunityBidResult { | |
} | ||
|
||
#[derive(Serialize, Deserialize, ToSchema, Clone, PartialEq, Debug)] | ||
#[serde(rename_all = "lowercase")] | ||
pub enum ProgramSvm { | ||
Phantom, | ||
Swap, | ||
Limo, | ||
} | ||
|
||
|
@@ -206,18 +205,18 @@ pub enum OpportunityCreateProgramParamsV1Svm { | |
#[serde_as(as = "DisplayFromStr")] | ||
order_address: Pubkey, | ||
}, | ||
/// Phantom program specific parameters for the opportunity. | ||
#[serde(rename = "phantom")] | ||
#[schema(title = "phantom")] | ||
Phantom { | ||
/// Swap program specific parameters for the opportunity. | ||
#[serde(rename = "swap")] | ||
#[schema(title = "swap")] | ||
Swap { | ||
/// The user wallet address which requested the quote from the wallet. | ||
#[schema(example = "DUcTi3rDyS5QEmZ4BNRBejtArmDCWaPYGfN44vBJXKL5", value_type = String)] | ||
#[serde_as(as = "DisplayFromStr")] | ||
user_wallet_address: Pubkey, | ||
|
||
/// The maximum slippage percentage that the user is willing to accept. | ||
#[schema(example = 0.5, value_type = f64)] | ||
maximum_slippage_percentage: f64, | ||
/// The maximum slippage in basis points that the user is willing to accept. | ||
#[schema(example = 50, value_type = u16)] | ||
maximum_slippage_bps: u16, | ||
}, | ||
} | ||
|
||
|
@@ -311,18 +310,18 @@ pub enum OpportunityParamsV1ProgramSvm { | |
#[serde_as(as = "DisplayFromStr")] | ||
order_address: Pubkey, | ||
}, | ||
/// Phantom program specific parameters for the opportunity. | ||
#[serde(rename = "phantom")] | ||
#[schema(title = "phantom")] | ||
Phantom { | ||
/// Swap program specific parameters for the opportunity. | ||
#[serde(rename = "swap")] | ||
#[schema(title = "swap")] | ||
Swap { | ||
/// The user wallet address which requested the quote from the wallet. | ||
#[schema(example = "DUcTi3rDyS5QEmZ4BNRBejtArmDCWaPYGfN44vBJXKL5", value_type = String)] | ||
#[serde_as(as = "DisplayFromStr")] | ||
user_wallet_address: Pubkey, | ||
|
||
/// The maximum slippage percentage that the user is willing to accept. | ||
#[schema(example = 0.5, value_type = f64)] | ||
maximum_slippage_percentage: f64, | ||
/// The maximum slippage in basis points that the user is willing to accept. | ||
#[schema(example = 50, value_type = u16)] | ||
maximum_slippage_bps: u16, | ||
|
||
/// The permission account to be permitted by the ER contract for the opportunity execution of the protocol. | ||
#[schema(example = "DUcTi3rDyS5QEmZ4BNRBejtArmDCWaPYGfN44vBJXKL5", value_type = String)] | ||
|
@@ -334,11 +333,21 @@ pub enum OpportunityParamsV1ProgramSvm { | |
#[serde_as(as = "DisplayFromStr")] | ||
router_account: Pubkey, | ||
|
||
/// The token searcher will send. | ||
sell_token: TokenAmountSvm, | ||
/// Details about the tokens to be swapped. Either the input token amount or the output token amount must be specified. | ||
#[schema(inline)] | ||
tokens: QuoteTokens, | ||
}, | ||
} | ||
|
||
/// The token searcher will receive. | ||
buy_token: TokenAmountSvm, | ||
#[derive(Serialize, Deserialize, ToSchema, Clone, PartialEq, Debug, ToResponse)] | ||
pub enum QuoteTokens { | ||
InputTokenSpecified { | ||
input_token: TokenAmountSvm, | ||
output_token: Pubkey, | ||
}, | ||
OutputTokenSpecified { | ||
input_token: Pubkey, | ||
output_token: TokenAmountSvm, | ||
}, | ||
} | ||
|
||
|
@@ -466,48 +475,49 @@ pub struct OpportunityBidEvm { | |
pub signature: Signature, | ||
} | ||
|
||
/// Parameters needed to create a new opportunity from the Phantom wallet. | ||
/// Parameters needed to create a new opportunity from the swap request. | ||
/// Auction server will extract the output token price for the auction. | ||
#[serde_as] | ||
#[derive(Serialize, Deserialize, ToSchema, Clone, PartialEq, Debug)] | ||
pub struct QuoteCreatePhantomV1Svm { | ||
pub struct QuoteCreateV1SvmParams { | ||
/// The user wallet address which requested the quote from the wallet. | ||
#[schema(example = "DUcTi3rDyS5QEmZ4BNRBejtArmDCWaPYGfN44vBJXKL5", value_type = String)] | ||
#[serde_as(as = "DisplayFromStr")] | ||
pub user_wallet_address: Pubkey, | ||
pub user_wallet_address: Pubkey, | ||
/// The token mint address of the input token. | ||
#[schema(example = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", value_type = String)] | ||
#[serde_as(as = "DisplayFromStr")] | ||
pub input_token_mint: Pubkey, | ||
pub input_token_mint: Pubkey, | ||
/// The token mint address of the output token. | ||
#[schema(example = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", value_type = String)] | ||
#[serde_as(as = "DisplayFromStr")] | ||
pub output_token_mint: Pubkey, | ||
/// The input token amount that the user wants to swap. | ||
#[schema(example = 100)] | ||
pub input_token_amount: u64, | ||
/// The maximum slippage percentage that the user is willing to accept. | ||
#[schema(example = 0.5)] | ||
pub maximum_slippage_percentage: f64, | ||
pub output_token_mint: Pubkey, | ||
/// The token amount that the user wants to swap out of/into. | ||
pub token_amount: QuoteTokenAmount, | ||
/// The maximum slippage in basis points that the user is willing to accept. | ||
#[schema(example = 50)] | ||
pub maximum_slippage_bps: u16, | ||
/// The router account to send referral fees to. | ||
#[schema(example = "DUcTi3rDyS5QEmZ4BNRBejtArmDCWaPYGfN44vBJXKL5", value_type = String)] | ||
#[serde_as(as = "DisplayFromStr")] | ||
pub router: Pubkey, | ||
/// The chain id for creating the quote. | ||
#[schema(example = "solana", value_type = String)] | ||
pub chain_id: ChainId, | ||
pub chain_id: ChainId, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, ToSchema, Clone, PartialEq, Debug)] | ||
#[serde(tag = "program")] | ||
pub enum QuoteCreateV1Svm { | ||
#[serde(rename = "phantom")] | ||
#[schema(title = "phantom")] | ||
Phantom(QuoteCreatePhantomV1Svm), | ||
pub enum QuoteTokenAmount { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use serde to rename the internal fields here (for better api). Maybe take a look at docs to see how to api structure is looking like? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can talk on this part together There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can also rename this to sth else :-? Maybe like QouteType? |
||
InputToken { amount: u64 }, | ||
OutputToken { amount: u64 }, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, ToSchema, Clone, PartialEq, Debug)] | ||
#[serde(tag = "version")] | ||
pub enum QuoteCreateSvm { | ||
#[serde(rename = "v1")] | ||
#[schema(title = "v1")] | ||
V1(QuoteCreateV1Svm), | ||
V1(QuoteCreateV1SvmParams), | ||
} | ||
|
||
#[derive(Serialize, Deserialize, ToSchema, Clone, PartialEq, Debug)] | ||
|
@@ -522,20 +532,20 @@ pub struct QuoteV1Svm { | |
/// The signed transaction for the quote to be executed on chain which is valid until the expiration time. | ||
#[schema(example = "SGVsbG8sIFdvcmxkIQ==", value_type = String)] | ||
#[serde(with = "crate::serde::transaction_svm")] | ||
pub transaction: VersionedTransaction, | ||
pub transaction: VersionedTransaction, | ||
/// The expiration time of the quote (in seconds since the Unix epoch). | ||
#[schema(example = 1_700_000_000_000_000i64, value_type = i64)] | ||
pub expiration_time: i64, | ||
pub expiration_time: i64, | ||
/// The input token amount that the user wants to swap. | ||
pub input_token: TokenAmountSvm, | ||
pub input_token: TokenAmountSvm, | ||
/// The output token amount that the user will receive. | ||
pub output_token: TokenAmountSvm, | ||
/// The maximum slippage percentage that the user is willing to accept. | ||
#[schema(example = 0.5)] | ||
pub maximum_slippage_percentage: f64, | ||
pub output_token: TokenAmountSvm, | ||
/// The maximum slippage in basis points that the user is willing to accept. | ||
#[schema(example = 50)] | ||
pub maximum_slippage_bps: u16, | ||
/// The chain id for the quote. | ||
#[schema(example = "solana", value_type = String)] | ||
pub chain_id: ChainId, | ||
pub chain_id: ChainId, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, ToSchema, Clone, PartialEq, Debug)] | ||
|
@@ -558,7 +568,7 @@ impl OpportunityCreateSvm { | |
match self { | ||
OpportunityCreateSvm::V1(params) => match ¶ms.program_params { | ||
OpportunityCreateProgramParamsV1Svm::Limo { .. } => ProgramSvm::Limo, | ||
OpportunityCreateProgramParamsV1Svm::Phantom { .. } => ProgramSvm::Phantom, | ||
OpportunityCreateProgramParamsV1Svm::Swap { .. } => ProgramSvm::Swap, | ||
}, | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think slippage doesn't make sense anymore in this context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i agree, i kept it in here for legacy reasons, since wallets will always pass this number in their requests. we don't have to consume it, but we could also get rid of it.