Skip to content

Commit

Permalink
feat(fusion-order): add isExclusiveResolver method (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
vbrvk authored Mar 27, 2024
1 parent 6fe5d6d commit ff6b6d5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/api/quoter/quote/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {Preset} from '../preset'
import {AuctionWhitelistItem, FusionOrder} from '../../../fusion-order'
import {QuoterRequest} from '../quoter.request'
import {bpsToRatioFormat} from '../../../sdk'
import {now} from '../../../utils/time'

export class Quote {
/**
Expand Down Expand Up @@ -132,7 +131,7 @@ export class Quote {

return {
address: resolver,
allowFrom: isExclusive ? now() : auctionStartTime
allowFrom: isExclusive ? 0n : auctionStartTime
}
})
}
Expand Down
9 changes: 9 additions & 0 deletions src/fusion-order/fusion-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,4 +411,13 @@ export class FusionOrder {
this.makingAmount
)
}

/**
* Check if `wallet` can fill order before other
*/
public isExclusiveResolver(wallet: Address): boolean {
return this.fusionExtension.postInteractionData.isExclusiveResolver(
wallet
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,22 @@ export class SettlementPostInteractionData {

return false
}

public isExclusiveResolver(wallet: Address): boolean {
const addressHalf = wallet.toString().slice(-20)

// only one resolver, so check if it is the passed address
if (this.whitelist.length === 1) {
return addressHalf === this.whitelist[0].addressHalf
}

// more than 1 address can fill at the same time, no exclusivity
if (this.whitelist[0].delay === this.whitelist[1].delay) {
return false
}

return addressHalf === this.whitelist[0].addressHalf
}
}

type WhitelistItem = {
Expand Down

0 comments on commit ff6b6d5

Please sign in to comment.