Skip to content

Commit 9de910c

Browse files
authored
Update rewards (#812)
1 parent 5e1d33b commit 9de910c

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ allprojects {
4040
"ktlint_standard_backing-property-naming" to "disabled",
4141
"ktlint_standard_filename" to "disabled",
4242
"ktlint_standard_function-naming" to "disabled",
43+
"ktlint_standard_property-naming" to "disabled",
4344
)
4445
)
4546

@@ -52,7 +53,7 @@ allprojects {
5253
}
5354

5455
group = "exchange.dydx.abacus"
55-
version = "1.14.2"
56+
version = "1.14.3"
5657

5758
repositories {
5859
google()

src/commonMain/kotlin/exchange.dydx.abacus/calculator/TradeInput/TradeInputSummaryCalculator.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@ internal class TradeInputSummaryCalculator {
342342
return if (trade.side == OrderSide.Sell) Numeric.double.POSITIVE else Numeric.double.NEGATIVE
343343
}
344344

345+
// megavault and ops
346+
@Suppress("LocalVariableName", "PropertyName", "VariableNaming")
347+
private val RATE_LOST_TO_REV_SHARES = 0.4
348+
349+
// affiliates
350+
@Suppress("LocalVariableName", "PropertyName", "VariableNaming")
351+
private val MAX_POSSIBLE_TAKER_REV_SHARE = 0.5
352+
345353
private fun calculateTakerReward(
346354
usdcSize: Double?,
347355
fee: Double?,
@@ -363,9 +371,14 @@ internal class TradeInputSummaryCalculator {
363371
tokenPrice > 0.0
364372
) {
365373
val feeMultiplier = feeMultiplierPpm / QUANTUM_MULTIPLIER
366-
return feeMultiplier * (fee - maxMakerRebate * notional) / (
374+
val reward = feeMultiplier * (fee - maxMakerRebate * notional - fee * MAX_POSSIBLE_TAKER_REV_SHARE) * RATE_LOST_TO_REV_SHARES / (
367375
tokenPrice * 10.0.pow(tokenPriceExponent)
368376
)
377+
return if (reward > 0.0) {
378+
reward
379+
} else {
380+
0.0
381+
}
369382
}
370383
return null
371384
}
@@ -386,7 +399,7 @@ internal class TradeInputSummaryCalculator {
386399
tokenPrice > 0.0
387400
) {
388401
val feeMultiplier = feeMultiplierPpm / QUANTUM_MULTIPLIER
389-
return fee * feeMultiplier / (tokenPrice * 10.0.pow(tokenPriceExponent))
402+
return fee * feeMultiplier * MAX_POSSIBLE_TAKER_REV_SHARE / (tokenPrice * 10.0.pow(tokenPriceExponent))
390403
}
391404
return null
392405
}

v4_abacus.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'v4_abacus'
3-
spec.version = '1.14.2'
3+
spec.version = '1.14.3'
44
spec.homepage = 'https://github.com/dydxprotocol/v4-abacus'
55
spec.source = { :http=> ''}
66
spec.authors = ''

0 commit comments

Comments
 (0)