Skip to content
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

Add partner fee to OneInchKit #310

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TransactionSigner(
private val chainId: Int
) {

fun signatureLegacy(rawTransaction: RawTransaction): Signature {
fun signature(rawTransaction: RawTransaction): Signature {
return when (val gasPrice = rawTransaction.gasPrice) {
is GasPrice.Eip1559 -> {
val signatureData = signEip1559(rawTransaction, gasPrice.maxFeePerGas, gasPrice.maxPriorityFeePerGas)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Signer(
) {

fun signature(rawTransaction: RawTransaction): Signature {
return transactionSigner.signatureLegacy(rawTransaction)
return transactionSigner.signature(rawTransaction)
}

fun signedTransaction(
Expand All @@ -40,7 +40,7 @@ class Signer(
nonce,
transactionInput
)
val signature = transactionSigner.signatureLegacy(rawTransaction)
val signature = transactionSigner.signature(rawTransaction)
return transactionBuilder.encode(rawTransaction, signature)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class OneInchKit(
fromToken: Address,
toToken: Address,
amount: BigInteger,
fee: Float? = null,
protocols: List<String>? = null,
gasPrice: GasPrice? = null,
complexityLevel: Int? = null,
Expand All @@ -36,6 +37,7 @@ class OneInchKit(
fromToken,
toToken,
amount,
fee,
protocols,
gasPrice,
complexityLevel,
Expand All @@ -52,6 +54,8 @@ class OneInchKit(
toToken: Address,
amount: BigInteger,
slippagePercentage: Float,
referrer: String? = null,
fee: Float? = null,
protocols: List<String>? = null,
recipient: Address? = null,
gasPrice: GasPrice? = null,
Expand All @@ -69,6 +73,8 @@ class OneInchKit(
amount,
receiveAddress,
slippagePercentage,
referrer,
fee,
protocols,
recipient,
gasPrice,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class OneInchService(
fromToken: Address,
toToken: Address,
amount: BigInteger,
fee: Float? = null,
protocols: List<String>? = null,
gasPrice: GasPrice? = null,
complexityLevel: Int? = null,
Expand All @@ -81,6 +82,7 @@ class OneInchService(
fromTokenAddress = fromToken.hex,
toTokenAddress = toToken.hex,
amount = amount,
fee = fee,
protocols = protocols?.joinToString(","),
maxFeePerGas = gasPrice.maxFeePerGas,
maxPriorityFeePerGas = gasPrice.maxPriorityFeePerGas,
Expand All @@ -96,6 +98,7 @@ class OneInchService(
fromTokenAddress = fromToken.hex,
toTokenAddress = toToken.hex,
amount = amount,
fee = fee,
protocols = protocols?.joinToString(","),
gasPrice = gasPrice?.max,
complexityLevel = complexityLevel,
Expand All @@ -113,6 +116,8 @@ class OneInchService(
amount: BigInteger,
fromAddress: Address,
slippagePercentage: Float,
referrer: String? = null,
fee: Float? = null,
protocols: List<String>? = null,
recipient: Address? = null,
gasPrice: GasPrice? = null,
Expand All @@ -131,6 +136,8 @@ class OneInchService(
amount = amount,
fromAddress = fromAddress.hex,
slippagePercentage = slippagePercentage,
referrer = referrer,
fee = fee,
protocols = protocols?.joinToString(","),
recipient = recipient?.hex,
maxFeePerGas = gasPrice.maxFeePerGas,
Expand All @@ -151,6 +158,8 @@ class OneInchService(
amount = amount,
fromAddress = fromAddress.hex,
slippagePercentage = slippagePercentage,
referrer = referrer,
fee = fee,
protocols = protocols?.joinToString(","),
recipient = recipient?.hex,
gasPrice = gasPrice?.max,
Expand Down Expand Up @@ -179,6 +188,7 @@ class OneInchService(
@Query("src") fromTokenAddress: String,
@Query("dst") toTokenAddress: String,
@Query("amount") amount: BigInteger,
@Query("fee") fee: Float? = null,
@Query("protocols") protocols: String? = null,
@Query("maxFeePerGas") maxFeePerGas: Long? = null,
@Query("maxPriorityFeePerGas") maxPriorityFeePerGas: Long? = null,
Expand All @@ -202,6 +212,7 @@ class OneInchService(
@Query("from") fromAddress: String,
@Query("slippage") slippagePercentage: Float,
@Query("referrer") referrer: String? = null,
@Query("fee") fee: Float? = null,
@Query("protocols") protocols: String? = null,
@Query("receiver") recipient: String? = null,
@Query("maxFeePerGas") maxFeePerGas: Long? = null,
Expand Down
Loading