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

Contract: Make miner fee a context var #25

Merged
merged 1 commit into from
Jul 22, 2023
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 @@ -14,7 +14,7 @@ Tokens
- None

Registers
- R4: Long MinerFee
- None

### Relevant Transactions
1. GuapDrop Tx
Expand All @@ -30,4 +30,4 @@ Registers

### Context Variables (@)
- @receiverData: Coll[(SigmaProp, (Long, Long))]

- @minerFee: Long
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// Tokens
// None
// Registers
// R4: Long MinerFee
// None

// ===== Relevant Transactions ===== //
// 1. GuapDrop Tx
Expand All @@ -27,6 +27,7 @@

// ===== Context Variables (@) ===== //
// @receiverData: Coll[(SigmaProp, (Long, Long))]
// @minerFee: Long

// ===== Receiver Data ===== //
// Coll(
Expand All @@ -42,9 +43,9 @@
// ===== Global Variables ===== //
val minerFeeErgoTreeBytesHash: Coll[Byte] =fromBase16("e540cceffd3b8dd0f401193576cc413467039695969427df94454193dddfb375")
val @receiverData: Coll[(SigmaProp, (Long, Long))] = getVar[Coll[(SigmaProp, (Long, Long))]](0).get
val minerFee: Long = SELF.R4[Long].get
val @minerFee: Long = getVar[Long](1).get
val guapdropServiceFeeAmount: Long = (SELF.value * $guapdropServiceFee._1) / $guapdropServiceFee._2
val serviceAllocation: Long = SELF.value - guapdropFeeAmount - minerFee
val serviceAllocation: Long = SELF.value - guapdropFeeAmount - @minerFee

// ===== GuapDrop Tx ===== //
val validGuapDropTx: Boolean = {
Expand Down Expand Up @@ -105,7 +106,7 @@
val validMinerFee: Boolean = {

allOf(Coll(
(minerFeeBoxOUT.value == minerFee),
(minerFeeBoxOUT.value == @minerFee),
(minerFeeBoxOUT.propositionBytes == minerFeeAddress.propBytes)
))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Tokens
- None

Registers
- R4: Long MinerFee
- None

### Relevant Transactions
1. GuapSwap Service Tx
Expand All @@ -30,5 +30,5 @@ Registers
- $guapswapServiceFeeAddress: SigmaProp

### Context Variables (@)
- @guapswapServiceData: Coll[(Int, Coll[Long])]

- @guapswapServiceData: Coll[(Int, (Long, Long))]
- @minerFee: Long
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// Tokens
// None
// Registers
// R4: Long MinerFee
// None

// ===== Relevant Transactions ===== //
// 1. GuapSwap Service Tx
Expand All @@ -26,16 +26,16 @@
// $guapswapServiceFeeAddress: SigmaProp

// ===== Context Variables (@) ===== //
// @guapswapServiceData: Coll[(Int, Coll[Long])]
// @guapswapServiceData: Coll[(Int, (Long, Long))]
// @minerFee: Long

// ===== GuapSwap Service Data ===== //
// Coll(
// (
// serviceIndex,
// Coll(
// dexServiceMinerFee,
// percentageOfServiceAllocationNum,
// percentageOfServiceAllocationDenom
// (
// percentageOfServiceAllocationNum,
// percentageOfServiceAllocationDenom
// )
// )
// )
Expand All @@ -46,10 +46,10 @@

// ===== Global Variables ===== //
val minerFeeErgoTreeBytesHash: Coll[Byte] = fromBase16("e540cceffd3b8dd0f401193576cc413467039695969427df94454193dddfb375")
val minerFee: Long = SELF.R4[Long].get
val @guapswapServiceData: Coll[(Int, Coll[Long])] = getVar[Coll[(Int, Coll[Long])]](0).get
val @minerFee: Long = getVar[Long](1).get
val guapswapServiceFeeAmount: Long = (SELF.value * $guapswapServiceFee._1) / $guapswapServiceFee._2
val serviceAllocation: Long = SELF.value - guapswapServiceFee - minerFee
val serviceAllocation: Long = SELF.value - guapswapServiceFee - @minerFee

// ===== GuapSwap Service Tx ===== //
val validGuapSwapServiceTx: Boolean = {
Expand All @@ -67,9 +67,8 @@
val serviceIndex: Int = guapswapDatum._1
val dexServiceContractBytesHash: Coll[Byte] = $dexServiceContractsBytesHash(serviceIndex)

val dexServiceMinerFee: Long = guapswapDatum._2(0)
val percentageOfServiceAllocationNum: Long = guapswapDatum._2(1)
val percentageOfServiceAllocationDenom: Long = guapswapDatum._2(2)
val percentageOfServiceAllocationNum: Long = guapswapDatum._2._1
val percentageOfServiceAllocationDenom: Long = guapswapDatum._2._2

val validDexServiceBox: Boolean = {

Expand All @@ -86,17 +85,10 @@
(blake2b256(dexServiceBoxOUT.propositionBytes) == dexServiceContractBytesHash)

}

val validDexServiceMinerFee: Boolean = {

(dexServiceBoxOUT.R4[Long].get == serviceMinerFee)

}


allOf(Coll(
validAllocation,
validDexServiceContract,
validDexServiceMinerFee
validDexServiceContract
))

}
Expand All @@ -119,7 +111,7 @@
val validMinerFee: Boolean = {

allOf(Coll(
(minerFeeBoxOUT.value == minerFee),
(minerFeeBoxOUT.value == @minerFee),
(blake2b256(minerFeeBoxOUT.propositionBytes) == minerFeeErgoTreeBytesHash)
))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Tokens
- None

Registers
- R4: Long MinerFee
- None

### Relevant Transactions
1. GuapSwap Spectrum Dex Service Tx
Expand All @@ -29,4 +29,5 @@ Registers

### Context Variables (@)
- @spectrumData: Coll[(Coll[Long], (Coll[Long], (Coll[Int], (Coll[ProveDlog], (Coll[Boolean], Coll[Coll[Byte]])))))]
- @minerFee: Long

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// Tokens
// None
// Registers
// R4: Long MinerFee
// None

// ===== Relevant Transactions ===== //
// 1. GuapSwap Spectrum Dex Service Tx
Expand All @@ -25,6 +25,7 @@

// ===== Context Variables (@) ===== //
// @spectrumData: Coll[(Coll[Long], (Coll[Long], (Coll[Int], (Coll[ProveDlog], (Coll[Boolean], Coll[Coll[Byte]])))))]
// @minerFee: Long

// ===== Spectrum Data ===== //
// Coll(
Expand Down Expand Up @@ -65,9 +66,9 @@

// ===== Global Variables ===== //
val minerFeeErgoTreeBytesHash: Coll[Byte] = fromBase16("e540cceffd3b8dd0f401193576cc413467039695969427df94454193dddfb375")
val minerFee: Long = SELF.R4[Long].get
val serviceAllocation: Long = SELF.value - minerFee
val @spectrumData: Coll[(Coll[Long], (Coll[Long], (Coll[Int], (Coll[ProveDlog], (Coll[Boolean], Coll[Coll[Byte]])))))] = getVar[Coll[(Coll[Long], (Coll[Long], (Coll[Int], (Coll[ProveDlog], (Coll[Boolean], Coll[Coll[Byte]])))))]](0).get
val @minerFee: Long = getVar[Long](1).get
val serviceAllocation: Long = SELF.value - @minerFee
val spectrumConstantsPositions_Long: Coll[Int] = Coll(1, 2, 3, 11, 16, 31)
val spectrumConstantsPositions_Int: Coll[Int] = Coll(4, 27)
val spectrumConstantsPositions_ProveDlog: Coll[Int] = Coll(5)
Expand Down Expand Up @@ -136,7 +137,7 @@
val validMinerFee: Boolean = {

allOf(Coll(
(minerFeeBoxOUT.value == minerFee),
(minerFeeBoxOUT.value == @minerFee),
(blake2b256(minerFeeBoxOUT.propositionBytes) == minerFeeErgoTreeBytesHash)
))

Expand Down
2 changes: 1 addition & 1 deletion guapswap/src/main/scala/contracts/proxy/v3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ Registers
- $serviceContractsBytesHash: Coll[Coll[Byte]]

### Context Variables (@)
- @serviceData: Coll[(Int, Coll[Long])]
- @serviceData: Coll[(Int, (Long, Long))]
- @minerFee: Long

Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@
// Coll[
// (
// serviceIndex,
// Coll(
// serviceMinerFee,
// percentageOfServiceAllocationNum,
// percentageOfServiceAllocationDenom
// (
// percentageOfServiceAllocationNum,
// percentageOfServiceAllocationDenom
// )
// )
// ]
Expand Down Expand Up @@ -65,9 +64,8 @@
val serviceIndex: Int = serviceDatum._1
val serviceContractBytesHash: Coll[Byte] = $serviceContractsBytesHash(serviceIndex)

val serviceMinerFee: Long = serviceDatum._2(0)
val percentageOfServiceAllocationNum: Long = serviceDatum._2(1)
val percentageOfServiceAllocationDenom: Long = serviceDatum._2(2)
val percentageOfServiceAllocationNum: Long = serviceDatum._2._1
val percentageOfServiceAllocationDenom: Long = serviceDatum._2._2

val validServiceContractBox: Boolean = {

Expand All @@ -84,17 +82,10 @@
(blake2b256(serviceContractBoxOUT.propositionBytes) == serviceContractBytesHash)

}

val validServiceMinerFee: Boolean = {

(serviceContractBoxOUT.R4[Long].get == serviceMinerFee)

}

allOf(Coll(
validAllocation,
validServiceContract,
validServiceMinerFee
validServiceContract
))

}
Expand Down