Skip to content

Commit

Permalink
added matcher verified tokens support
Browse files Browse the repository at this point in the history
  • Loading branch information
deemru committed Dec 28, 2023
1 parent 0b5b5d9 commit 07bcce8
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/WavesKit.php
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,9 @@ private function setDefaultMatcher()
public $matcherDiscountRate;
public $matcherPairMinFees;
public $matcherPairMinFeesInWaves;
public $matcherVerified;
public $matcherVerifiedMinFee;
public $matcherVerifiedMinFeeInWaves;

/**
* Sets matcher settings
Expand Down Expand Up @@ -873,6 +876,17 @@ public function setMatcherSettings( $settings = null )
$this->matcherPairMinFeesInWaves[$pair][0] = $minFeeInWavesBA;
}

$this->matcherVerified = [];
if( isset( $settings['orderFee']['composite']['verified']['assets'] ) &&
isset( $settings['orderFee']['composite']['verified']['settings']['percent']['minFee'] ) &&
isset( $settings['orderFee']['composite']['verified']['settings']['percent']['minFeeInWaves'] ) )
{
foreach( $settings['orderFee']['composite']['verified']['assets'] as $asset )
$this->matcherVerified[$asset] = true;
$this->matcherVerifiedMinFee = $settings['orderFee']['composite']['verified']['settings']['percent']['minFee'] / 100;
$this->matcherVerifiedMinFeeInWaves = $settings['orderFee']['composite']['verified']['settings']['percent']['minFeeInWaves'];
}

return true;
}

Expand Down Expand Up @@ -954,6 +968,32 @@ public function setMatcherFee( $order, $discount = true )
}
}
else
if( isset( $this->matcherVerified[$priceAsset] ) || isset( $this->matcherVerified[$amountAsset] ) )
{
$isPrice = isset( $this->matcherVerified[$priceAsset] );
$mainAsset = $isPrice ? $priceAsset : $amountAsset;

$rate = $this->matcherRates[$mainAsset];
$amount = $isPrice ? ( $order['amount'] * $order['price'] / 100000000 ) : $order['amount'];

$matcherBaseFee = $this->matcherVerifiedMinFeeInWaves;
$fee = $amount * $this->matcherVerifiedMinFee;
$fee /= $rate;
if( $fee < $matcherBaseFee )
$fee = $matcherBaseFee;

if( $discount )
{
$asset = $this->matcherDiscountAsset;
$rate = $this->matcherDiscountRate;
}
else
{
$asset = null; // fixedAsset WAVES only
$rate = 1;
}
}
else
{
$fee = $this->matcherBaseFee;

Expand Down

0 comments on commit 07bcce8

Please sign in to comment.