@@ -18,15 +18,15 @@ pub mod express_relay {
18
18
use super :: * ;
19
19
20
20
pub fn initialize ( ctx : Context < Initialize > , data : InitializeArgs ) -> Result < ( ) > {
21
- validate_fee_split ( data. split_protocol_default ) ?;
21
+ validate_fee_split ( data. split_router_default ) ?;
22
22
validate_fee_split ( data. split_relayer ) ?;
23
23
24
24
let express_relay_metadata_data = & mut ctx. accounts . express_relay_metadata ;
25
25
26
26
express_relay_metadata_data. admin = * ctx. accounts . admin . key ;
27
27
express_relay_metadata_data. relayer_signer = * ctx. accounts . relayer_signer . key ;
28
28
express_relay_metadata_data. fee_receiver_relayer = * ctx. accounts . fee_receiver_relayer . key ;
29
- express_relay_metadata_data. split_protocol_default = data. split_protocol_default ;
29
+ express_relay_metadata_data. split_router_default = data. split_router_default ;
30
30
express_relay_metadata_data. split_relayer = data. split_relayer ;
31
31
32
32
Ok ( ( ) )
@@ -50,27 +50,27 @@ pub mod express_relay {
50
50
}
51
51
52
52
pub fn set_splits ( ctx : Context < SetSplits > , data : SetSplitsArgs ) -> Result < ( ) > {
53
- validate_fee_split ( data. split_protocol_default ) ?;
53
+ validate_fee_split ( data. split_router_default ) ?;
54
54
validate_fee_split ( data. split_relayer ) ?;
55
55
56
56
let express_relay_metadata_data = & mut ctx. accounts . express_relay_metadata ;
57
57
58
- express_relay_metadata_data. split_protocol_default = data. split_protocol_default ;
58
+ express_relay_metadata_data. split_router_default = data. split_router_default ;
59
59
express_relay_metadata_data. split_relayer = data. split_relayer ;
60
60
61
61
Ok ( ( ) )
62
62
}
63
63
64
- pub fn set_protocol_split ( ctx : Context < SetProtocolSplit > , data : SetProtocolSplitArgs ) -> Result < ( ) > {
65
- validate_fee_split ( data. split_protocol ) ?;
64
+ pub fn set_router_split ( ctx : Context < SetRouterSplit > , data : SetRouterSplitArgs ) -> Result < ( ) > {
65
+ validate_fee_split ( data. split_router ) ?;
66
66
67
- ctx. accounts . protocol_config . protocol = * ctx. accounts . protocol . key ;
68
- ctx. accounts . protocol_config . split = data. split_protocol ;
67
+ ctx. accounts . router_config . router = * ctx. accounts . router . key ;
68
+ ctx. accounts . router_config . split = data. split_router ;
69
69
70
70
Ok ( ( ) )
71
71
}
72
72
73
- // Submits a bid for a particular (protocol, permission ) pair and distributes bids according to splits
73
+ // Submits a bid for a particular (permission, router ) pair and distributes bids according to splits
74
74
pub fn submit_bid ( ctx : Context < SubmitBid > , data : SubmitBidArgs ) -> Result < ( ) > {
75
75
if data. deadline < Clock :: get ( ) ?. unix_timestamp {
76
76
return err ! ( ErrorCode :: DeadlinePassed ) ;
@@ -84,18 +84,18 @@ pub mod express_relay {
84
84
// check "no reentrancy"--submit_bid instruction only used once in transaction
85
85
// this is done to prevent an exploit where a searcher submits a transaction with multiple submit_bid instructions with different permission keys
86
86
// that would allow the searcher to win the right to perform the transaction if they won just one of the auctions
87
- let permission_count = num_permissions_in_tx ( ctx. accounts . sysvar_instructions . clone ( ) , None , None ) ?;
87
+ let permission_count = num_permissions_in_tx ( ctx. accounts . sysvar_instructions . clone ( ) , None ) ?;
88
88
if permission_count > 1 {
89
89
return err ! ( ErrorCode :: MultiplePermissions ) ;
90
90
}
91
91
92
92
handle_bid_payment ( ctx, data. bid_amount )
93
93
}
94
94
95
- // Checks if permissioning exists for a particular (protocol, permission ) pair within the same transaction
96
- // Permissioning takes the form of a submit_bid instruction with matching protocol and permission accounts
95
+ // Checks if permissioning exists for a particular (permission, router ) pair within the same transaction
96
+ // Permissioning takes the form of a submit_bid instruction with matching permission and router accounts
97
97
pub fn check_permission ( ctx : Context < CheckPermission > ) -> Result < ( ) > {
98
- let num_permissions = num_permissions_in_tx ( ctx. accounts . sysvar_instructions . clone ( ) , Some ( * ctx. accounts . permission . key ) , Some ( * ctx. accounts . protocol . key ) ) ?;
98
+ let num_permissions = num_permissions_in_tx ( ctx. accounts . sysvar_instructions . clone ( ) , Some ( PermissionInfo { permission : * ctx. accounts . permission . key , router : * ctx. accounts . router . key } ) ) ?;
99
99
100
100
if num_permissions == 0 {
101
101
return err ! ( ErrorCode :: MissingPermission ) ;
@@ -121,7 +121,7 @@ pub mod express_relay {
121
121
122
122
#[ derive( AnchorSerialize , AnchorDeserialize , Eq , PartialEq , Clone , Copy , Debug ) ]
123
123
pub struct InitializeArgs {
124
- pub split_protocol_default : u64 ,
124
+ pub split_router_default : u64 ,
125
125
pub split_relayer : u64
126
126
}
127
127
@@ -174,7 +174,7 @@ pub struct SetRelayer<'info> {
174
174
175
175
#[ derive( AnchorSerialize , AnchorDeserialize , Eq , PartialEq , Clone , Copy , Debug ) ]
176
176
pub struct SetSplitsArgs {
177
- pub split_protocol_default : u64 ,
177
+ pub split_router_default : u64 ,
178
178
pub split_relayer : u64 ,
179
179
}
180
180
@@ -188,23 +188,23 @@ pub struct SetSplits<'info> {
188
188
}
189
189
190
190
#[ derive( AnchorSerialize , AnchorDeserialize , Eq , PartialEq , Clone , Copy , Debug ) ]
191
- pub struct SetProtocolSplitArgs {
192
- pub split_protocol : u64 ,
191
+ pub struct SetRouterSplitArgs {
192
+ pub split_router : u64 ,
193
193
}
194
194
195
195
#[ derive( Accounts ) ]
196
- pub struct SetProtocolSplit < ' info > {
196
+ pub struct SetRouterSplit < ' info > {
197
197
#[ account( mut ) ]
198
198
pub admin : Signer < ' info > ,
199
199
200
- #[ account( init_if_needed, payer = admin, space = RESERVE_EXPRESS_RELAY_CONFIG_PROTOCOL , seeds = [ SEED_CONFIG_PROTOCOL , protocol . key( ) . as_ref( ) ] , bump) ]
201
- pub protocol_config : Account < ' info , ConfigProtocol > ,
200
+ #[ account( init_if_needed, payer = admin, space = RESERVE_EXPRESS_RELAY_CONFIG_ROUTER , seeds = [ SEED_CONFIG_ROUTER , router . key( ) . as_ref( ) ] , bump) ]
201
+ pub router_config : Account < ' info , ConfigRouter > ,
202
202
203
203
#[ account( seeds = [ SEED_METADATA ] , bump, has_one = admin) ]
204
204
pub express_relay_metadata : Account < ' info , ExpressRelayMetadata > ,
205
205
206
- /// CHECK: this is just the protocol fee receiver PK
207
- pub protocol : UncheckedAccount < ' info > ,
206
+ /// CHECK: this is just the router fee receiver PK
207
+ pub router : UncheckedAccount < ' info > ,
208
208
209
209
pub system_program : Program < ' info , System > ,
210
210
}
@@ -225,21 +225,18 @@ pub struct SubmitBid<'info> {
225
225
/// CHECK: this is the permission_key
226
226
pub permission : UncheckedAccount < ' info > ,
227
227
228
- /// CHECK: this is the protocol/router address
229
- pub protocol : UncheckedAccount < ' info > ,
228
+ /// CHECK: don't care what this looks like
229
+ #[ account( mut ) ]
230
+ pub router : UncheckedAccount < ' info > ,
230
231
231
- /// CHECK: this cannot be checked against ConfigProtocol bc it may not be initialized bc anchor. we need to check this config even when unused to make sure unique fee splits don't exist
232
- #[ account( seeds = [ SEED_CONFIG_PROTOCOL , protocol . key( ) . as_ref( ) ] , bump) ]
233
- pub protocol_config : UncheckedAccount < ' info > ,
232
+ /// CHECK: this cannot be checked against ConfigRouter bc it may not be initialized bc anchor. we need to check this config even when unused to make sure unique fee splits don't exist
233
+ #[ account( seeds = [ SEED_CONFIG_ROUTER , router . key( ) . as_ref( ) ] , bump) ]
234
+ pub router_config : UncheckedAccount < ' info > ,
234
235
235
236
/// CHECK: this is just a PK for the relayer to receive fees at
236
237
#[ account( mut ) ]
237
238
pub fee_receiver_relayer : UncheckedAccount < ' info > ,
238
239
239
- /// CHECK: don't care what this looks like; if PDA, validate within program logic
240
- #[ account( mut ) ]
241
- pub fee_receiver_protocol : UncheckedAccount < ' info > ,
242
-
243
240
#[ account( mut , seeds = [ SEED_METADATA ] , bump, has_one = relayer_signer, has_one = fee_receiver_relayer) ]
244
241
pub express_relay_metadata : Account < ' info , ExpressRelayMetadata > ,
245
242
@@ -259,8 +256,8 @@ pub struct CheckPermission<'info> {
259
256
/// CHECK: this is the permission_key
260
257
pub permission : UncheckedAccount < ' info > ,
261
258
262
- /// CHECK: this is the protocol/ router address
263
- pub protocol : UncheckedAccount < ' info > ,
259
+ /// CHECK: this is the router address
260
+ pub router : UncheckedAccount < ' info > ,
264
261
}
265
262
266
263
#[ derive( Accounts ) ]
0 commit comments