Skip to content

Commit

Permalink
Merge pull request #29 from pnetwork-association/feat/merkl-preset
Browse files Browse the repository at this point in the history
Feat/merkl preset
  • Loading branch information
envin3 authored Jan 26, 2024
2 parents 9ee4f3f + 7508cc4 commit 402aa41
Show file tree
Hide file tree
Showing 11 changed files with 5,017 additions and 43 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dao-v2-ui",
"version": "0.3.1",
"version": "0.4.0",
"private": true,
"homepage": ".",
"dependencies": {
Expand Down
7 changes: 7 additions & 0 deletions src/components/complex/CreateProposalModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Select from '../../base/Select'
import AssetSelection from '../AssetSelection'
import ChainSelection from '../ChainSelection'
import { FaEye, FaEyeSlash } from 'react-icons/fa'
import MerklDistributionFormula from '../MerklDistributionFormula'

const UseScriptText = styled(Text)`
font-size: 13px;
Expand Down Expand Up @@ -101,6 +102,12 @@ const CreateProposalModal = ({ show, onClose }) => {
<ChainSelection {...props} />
</div>
)
case 'MerklDistributionFormula':
return (
<div key={id}>
<MerklDistributionFormula {...props} />
</div>
)
case 'AssetSelection':
return <AssetSelection key={id} {...props} />
case 'Input':
Expand Down
27 changes: 27 additions & 0 deletions src/components/complex/MerklDistributionFormula/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Text from '../../base/Text'
import Input from '../../base/Input'
import { Col, Row } from 'react-bootstrap'

const MerklDistributionFormula = (props) => {
return (
<div>
<Text size="sm">Distribution Formula:</Text>
<Row xs={1} md={3}>
<Col>
<Text size="sm">% PNT</Text>
<Input {...props[0]} />
</Col>
<Col>
<Text size="sm">% wETH</Text>
<Input {...props[1]} />
</Col>
<Col>
<Text size="sm">% Fees</Text>
<Input {...props[2]} />
</Col>
</Row>
</div>
)
}

export default MerklDistributionFormula
4 changes: 3 additions & 1 deletion src/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const settings = {
registrationManager: '0x906B067e392e2c5f9E4f101f36C0b8CdA4885EBf',
feesManager: '0xDf951d2061b12922BFbF22cb17B17f3b39183570',
pNetworkAssociationGnosisSafeAddress: '0xf1f6568a76559d85cF68E6597fA587544184dD46',
pNetworkV2EthereumVaultAddess: '0xe396757ec7e6ac7c8e5abe7285dde47b98f22db8'
pNetworkV2EthereumVaultAddess: '0xe396757ec7e6ac7c8e5abe7285dde47b98f22db8',
merklDistributionCreatorAddress: '0x8BB4C975Ff3c250e0ceEA271728547f3802B36Fd'
},
stakingManager: {
minStakeDays: 7,
Expand All @@ -35,6 +36,7 @@ const settings = {
estimatedSentinelRunningCost: 150
},
explorer: 'https://etherscan.io',
zeroAddress: '0x0000000000000000000000000000000000000000',
assets: [
{
address: '0xf4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2',
Expand Down
47 changes: 47 additions & 0 deletions src/utils/__tests__/createMerklInflation.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 0 additions & 39 deletions src/utils/__tests__/withdrawInflation.test.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,7 @@
import { ethers } from 'ethers'

import { getVotePresets } from '../vote-presets'
import { encodeCallScript } from '../voting-scripts'
import { ethPNTContract, pNetworkV2Vault, vaultContract } from '../presets/utils'
import BigNumber from 'bignumber.js'

const DAO_V1_VOTING_ADDRESS = '0x2211bFD97b1c02aE8Ac305d206e9780ba7D8BfF4'
const DAO_V1_TREASURY_ADDRESS = '0xDd92eb1478D3189707aB7F4a5aCE3a615cdD0476'
const ETHPNT_ADDRESS = '0xf4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2'
const PNETWORKV2_VAULT_ADDRESS = '0xe396757ec7e6ac7c8e5abe7285dde47b98f22db8'

describe('withdrawInflationAndPegin', () => {
const getLiquidityPoolsPresetActions = (_destinationAddress, _amount, _userData, _destinationChainId) => {
const withdrawInflationCalldata = ethPNTContract.encodeFunctionData('withdrawInflation', [
DAO_V1_TREASURY_ADDRESS,
_amount
])

const transferCalldata = vaultContract.encodeFunctionData('transfer', [
ETHPNT_ADDRESS,
DAO_V1_VOTING_ADDRESS,
_amount
])

const approveCalldata = ethPNTContract.encodeFunctionData('approve', [PNETWORKV2_VAULT_ADDRESS, _amount])

const pegInCalldata = pNetworkV2Vault.encodeFunctionData('pegIn(uint256, address, string, bytes, bytes4)', [
_amount,
ETHPNT_ADDRESS,
_destinationAddress,
_userData,
_destinationChainId
])

return [
{ to: ETHPNT_ADDRESS, calldata: withdrawInflationCalldata },
{ to: DAO_V1_TREASURY_ADDRESS, calldata: transferCalldata },
{ to: ETHPNT_ADDRESS, calldata: approveCalldata },
{ to: PNETWORKV2_VAULT_ADDRESS, calldata: pegInCalldata }
]
}

test('Should match the generated script', async () => {
const presets = getVotePresets({
presetParams: { 0: '1', 2: '0xa41657bf225F8Ec7E2010C89c3F084172948264D' },
Expand Down
Loading

0 comments on commit 402aa41

Please sign in to comment.