Skip to content

Commit

Permalink
Merge pull request #165 from renproject/feat/pull-fees-from-state
Browse files Browse the repository at this point in the history
Pull cross-chain fees from RenVM state
  • Loading branch information
jazg committed May 22, 2021
2 parents a967ea0 + de9c0a1 commit be11de4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.4.1
- Update Multichain to v0.3.8
- Update Multichain to v0.3.10
- Add support for watching Solana burns
- Pull cross-chain fees from RenVM state

## 0.3.2

Expand Down
23 changes: 12 additions & 11 deletions compat/v0/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ func QueryFeesResponseFromState(state map[string]engine.XState) (ResponseQueryFe
}
bitcoinCap := bitcoinS.GasCap
bitcoinLimit := bitcoinS.GasLimit

bitcoinUnderlying := U64{Int: big.NewInt(int64(bitcoinCap.Int().Uint64() * bitcoinLimit.Int().Uint64()))}
bitcoinMintFee := U64{Int: big.NewInt(int64(bitcoinS.MintFee))}
bitcoinBurnFee := U64{Int: big.NewInt(int64(bitcoinS.BurnFee))}

zcashS, ok := state[string(multichain.Zcash.NativeAsset())]
if !ok {
Expand All @@ -83,6 +84,8 @@ func QueryFeesResponseFromState(state map[string]engine.XState) (ResponseQueryFe
zcashCap := zcashS.GasCap
zcashLimit := zcashS.GasLimit
zcashUnderlying := U64{Int: big.NewInt(int64(zcashCap.Int().Uint64() * zcashLimit.Int().Uint64()))}
zcashMintFee := U64{Int: big.NewInt(int64(zcashS.MintFee))}
zcashBurnFee := U64{Int: big.NewInt(int64(zcashS.BurnFee))}

bitcoinCashS, ok := state[string(multichain.BitcoinCash.NativeAsset())]
if !ok {
Expand All @@ -91,35 +94,33 @@ func QueryFeesResponseFromState(state map[string]engine.XState) (ResponseQueryFe
}
bitcoinCashCap := bitcoinCashS.GasCap
bitcoinCashLimit := bitcoinCashS.GasLimit

bitcoinCashUnderlying := U64{Int: big.NewInt(int64(bitcoinCashCap.Int().Uint64() * bitcoinCashLimit.Int().Uint64()))}

mintFee := U64{Int: big.NewInt(25)}
burnFee := U64{Int: big.NewInt(10)}
bitcoinCashMintFee := U64{Int: big.NewInt(int64(bitcoinCashS.MintFee))}
bitcoinCashBurnFee := U64{Int: big.NewInt(int64(bitcoinCashS.BurnFee))}

resp := ResponseQueryFees{
Btc: Fees{
Lock: bitcoinUnderlying,
Release: bitcoinUnderlying,
Ethereum: MintAndBurnFees{
Mint: mintFee,
Burn: burnFee,
Mint: bitcoinMintFee,
Burn: bitcoinBurnFee,
},
},
Zec: Fees{
Lock: zcashUnderlying,
Release: zcashUnderlying,
Ethereum: MintAndBurnFees{
Mint: mintFee,
Burn: burnFee,
Mint: zcashMintFee,
Burn: zcashBurnFee,
},
},
Bch: Fees{
Lock: bitcoinCashUnderlying,
Release: bitcoinCashUnderlying,
Ethereum: MintAndBurnFees{
Mint: mintFee,
Burn: burnFee,
Mint: bitcoinCashMintFee,
Burn: bitcoinCashBurnFee,
},
},
}
Expand Down

0 comments on commit be11de4

Please sign in to comment.