Skip to content

Commit

Permalink
update mango settings lib (solana-labs#1923)
Browse files Browse the repository at this point in the history
  • Loading branch information
abrzezinski94 authored Nov 15, 2023
1 parent a6bb595 commit 9447152
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 37 deletions.
14 changes: 7 additions & 7 deletions components/instructions/programs/mangoV4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ const instructions = () => ({
<DisplayListingPropertyWrapped
label="Flash Loan Deposit Fee Rate"
suggestedUntrusted={suggestedUntrusted}
valKey="flashLoanDepositFeeRate"
valKey="flashLoanSwapFeeRate"
/>
</div>
<AdvancedOptionsDropdown className="mt-4" title="Raw values">
Expand Down Expand Up @@ -841,7 +841,7 @@ const instructions = () => ({
args.tokenConditionalSwapMakerFeeRateOpt,
tokenConditionalSwapTakerFeeRate:
args.tokenConditionalSwapTakerFeeRateOpt,
flashLoanDepositFeeRate: args.flashLoanDepositFeeRateOpt,
flashLoanSwapFeeRate: args.flashLoanSwapFeeRateOpt,
reduceOnly:
args.reduceOnlyOpt !== undefined
? REDUCE_ONLY_OPTIONS[args.reduceOnlyOpt].name
Expand Down Expand Up @@ -1259,10 +1259,10 @@ const instructions = () => ({
suggestedVal={invalidFields.tokenConditionalSwapTakerFeeRate}
/>
<DisplayNullishProperty
label="Flash Loan Deposit Fee Rate"
value={parsedArgs.flashLoanDepositFeeRate}
currentValue={bankFormattedValues?.flashLoanDepositFeeRate}
suggestedVal={invalidFields.flashLoanDepositFeeRate}
label="Flash Loan Swap Fee Rate"
value={parsedArgs.flashLoanSwapFeeRate}
currentValue={bankFormattedValues?.flashLoanSwapFeeRate}
suggestedVal={invalidFields.flashLoanSwapFeeRate}
/>
<DisplayNullishProperty
label="Reduce only"
Expand Down Expand Up @@ -1662,7 +1662,7 @@ const getFormattedListingValues = (args: FlatListingArgs) => {
stablePriceGrowthLimit: (args.stablePriceGrowthLimit * 100).toFixed(2),
tokenConditionalSwapMakerFeeRate: args.tokenConditionalSwapMakerFeeRate,
tokenConditionalSwapTakerFeeRate: args.tokenConditionalSwapTakerFeeRate,
flashLoanDepositFeeRate: args.flashLoanDepositFeeRate,
flashLoanSwapFeeRate: args.flashLoanSwapFeeRate,
reduceOnly: REDUCE_ONLY_OPTIONS[args.reduceOnly].name,
}
return formattedArgs
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
},
"dependencies": {
"@blockworks-foundation/mango-mints-redemption": "0.0.10",
"@blockworks-foundation/mango-v4": "0.19.34",
"@blockworks-foundation/mango-v4-settings": "0.2.16",
"@blockworks-foundation/mango-v4": "0.20.2",
"@blockworks-foundation/mango-v4-settings": "0.2.18",
"@blockworks-foundation/mangolana": "0.0.1-beta.15",
"@bonfida/spl-name-service": "0.1.47",
"@bundlr-network/client": "0.7.15",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const keyToLabel = {
forceClose: 'Force Close',
tokenConditionalSwapTakerFeeRate: 'Token Conditional Swap Taker Fee Rate',
tokenConditionalSwapMakerFeeRate: 'Token Conditional Swap Maker Fee Rate',
flashLoanDepositFeeRate: 'Flash Loan Deposit Fee Rate',
flashLoanSwapFeeRate: 'Flash Loan Deposit Fee Rate',
}

type NamePkVal = {
Expand Down Expand Up @@ -104,7 +104,7 @@ interface EditTokenForm {
forceClose: boolean
tokenConditionalSwapTakerFeeRate: number
tokenConditionalSwapMakerFeeRate: number
flashLoanDepositFeeRate: number
flashLoanSwapFeeRate: number
}

const defaultFormValues: EditTokenForm = {
Expand Down Expand Up @@ -144,7 +144,7 @@ const defaultFormValues: EditTokenForm = {
holdupTime: 0,
tokenConditionalSwapTakerFeeRate: 0,
tokenConditionalSwapMakerFeeRate: 0,
flashLoanDepositFeeRate: 0,
flashLoanSwapFeeRate: 0,
}

const EditToken = ({
Expand Down Expand Up @@ -290,7 +290,7 @@ const EditToken = ({
null,
Number
),
getNullOrTransform(values.flashLoanDepositFeeRate, null, Number)
getNullOrTransform(values.flashLoanSwapFeeRate, null, Number)
)
.accounts({
group: mangoGroup!.publicKey,
Expand Down Expand Up @@ -387,7 +387,7 @@ const EditToken = ({
currentToken.tokenConditionalSwapTakerFeeRate,
tokenConditionalSwapMakerFeeRate:
currentToken.tokenConditionalSwapMakerFeeRate,
flashLoanDepositFeeRate: currentToken.flashLoanDepositFeeRate,
flashLoanSwapFeeRate: currentToken.flashLoanSwapFeeRate,
}
setForm((prevForm) => ({
...prevForm,
Expand Down Expand Up @@ -696,12 +696,12 @@ const EditToken = ({
name: 'tokenConditionalSwapTakerFeeRate',
},
{
label: keyToLabel['flashLoanDepositFeeRate'],
subtitle: getAdditionalLabelInfo('flashLoanDepositFeeRate'),
initialValue: form.flashLoanDepositFeeRate,
label: keyToLabel['flashLoanSwapFeeRate'],
subtitle: getAdditionalLabelInfo('flashLoanSwapFeeRate'),
initialValue: form.flashLoanSwapFeeRate,
type: InstructionInputType.INPUT,
inputType: 'number',
name: 'flashLoanDepositFeeRate',
name: 'flashLoanSwapFeeRate',
},
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type GroupEditForm = {
feesMngoTokenIndex: number | null
feesExpiryInterval: number | null
holdupTime: number
allowedFastListingsPerInterval: number | null
}

const defaultFormValues: GroupEditForm = {
Expand All @@ -62,6 +63,7 @@ const defaultFormValues: GroupEditForm = {
feesMngoTokenIndex: 0,
feesExpiryInterval: 0,
holdupTime: 0,
allowedFastListingsPerInterval: 0,
}

const GroupEdit = ({
Expand Down Expand Up @@ -122,7 +124,12 @@ const GroupEdit = ({
getNullOrTransform(values.feesMngoBonusRate, null, Number),
getNullOrTransform(values.feesSwapMangoAccount, PublicKey),
getNullOrTransform(values.feesMngoTokenIndex, null, Number),
getNullOrTransform(values.feesExpiryInterval, BN)
getNullOrTransform(values.feesExpiryInterval, BN),
getNullOrTransform(
values.allowedFastListingsPerInterval,
null,
Number
)
)
.accounts({
group: mangoGroup!.publicKey,
Expand Down Expand Up @@ -195,6 +202,8 @@ const GroupEdit = ({
feesSwapMangoAccount: mangoGroup!.buybackFeesSwapMangoAccount?.toBase58(),
feesMngoTokenIndex: mangoGroup!.mngoTokenIndex,
feesExpiryInterval: mangoGroup!.buybackFeesExpiryInterval?.toNumber(),
allowedFastListingsPerInterval: mangoGroup!
.allowedFastListingsPerInterval,
}
setForm((prevForm) => ({
...prevForm,
Expand Down Expand Up @@ -307,6 +316,14 @@ const GroupEdit = ({
inputType: 'number',
name: 'feesExpiryInterval',
},
{
label: keyToLabel['allowedFastListingsPerInterval'],
subtitle: getAdditionalLabelInfo('allowedFastListingsPerInterval'),
initialValue: form.allowedFastListingsPerInterval,
type: InstructionInputType.INPUT,
inputType: 'number',
name: 'allowedFastListingsPerInterval',
},
]

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ const IxGateSet = ({
OpenbookV2SettleFunds: true,
AdminTokenWithdrawFees: true,
AdminPerpWithdrawFees: true,
AccountSizeMigration: true,
TokenConditionalSwapStart: true,
TokenConditionalSwapCreatePremiumAuction: true,
TokenConditionalSwapCreateLinearAuction: true,
})
const [formErrors, setFormErrors] = useState({})
const { handleSetInstructions } = useContext(NewProposalContext)
Expand Down Expand Up @@ -599,6 +603,30 @@ const IxGateSet = ({
type: InstructionInputType.SWITCH,
name: 'AdminPerpWithdrawFees',
},
{
label: 'Account Size Migration',
initialValue: form.AccountSizeMigration,
type: InstructionInputType.SWITCH,
name: 'AccountSizeMigration',
},
{
label: 'Token Conditional Swap Start',
initialValue: form.TokenConditionalSwapStart,
type: InstructionInputType.SWITCH,
name: 'TokenConditionalSwapStart',
},
{
label: 'Token Conditional Swap Create Premium Auction',
initialValue: form.TokenConditionalSwapCreatePremiumAuction,
type: InstructionInputType.SWITCH,
name: 'TokenConditionalSwapCreatePremiumAuction',
},
{
label: 'Token Conditional Swap Create Linear Auction',
initialValue: form.TokenConditionalSwapCreateLinearAuction,
type: InstructionInputType.SWITCH,
name: 'TokenConditionalSwapCreateLinearAuction',
},
]

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ interface TokenRegisterForm {
stablePriceDelayGrowthLimit: number
tokenConditionalSwapTakerFeeRate: number
tokenConditionalSwapMakerFeeRate: number
flashLoanDepositFeeRate: number
flashLoanSwapFeeRate: number
reduceOnly: { name: string; value: number }
borrowWeightScaleStartQuote: number
depositWeightScaleStartQuote: number
Expand Down Expand Up @@ -105,7 +105,7 @@ const TokenRegister = ({
stablePriceDelayGrowthLimit: 0.06,
tokenConditionalSwapTakerFeeRate: 0,
tokenConditionalSwapMakerFeeRate: 0,
flashLoanDepositFeeRate: 0,
flashLoanSwapFeeRate: 0,
reduceOnly: REDUCE_ONLY_OPTIONS[0],
borrowWeightScaleStartQuote: toNative(10000, 6).toNumber(),
depositWeightScaleStartQuote: toNative(10000, 6).toNumber(),
Expand Down Expand Up @@ -163,7 +163,7 @@ const TokenRegister = ({
Number(form.reduceOnly),
Number(form.tokenConditionalSwapTakerFeeRate),
Number(form.tokenConditionalSwapMakerFeeRate),
Number(form.flashLoanDepositFeeRate)
Number(form.flashLoanSwapFeeRate)
)
.accounts({
group: mangoGroup!.publicKey,
Expand Down Expand Up @@ -461,11 +461,11 @@ const TokenRegister = ({
},
{
label: `Flash Loan Deposit Fee Rate`,
subtitle: getAdditionalLabelInfo('flashLoanDepositFeeRate'),
initialValue: form.flashLoanDepositFeeRate,
subtitle: getAdditionalLabelInfo('flashLoanSwapFeeRate'),
initialValue: form.flashLoanSwapFeeRate,
type: InstructionInputType.INPUT,
inputType: 'number',
name: 'flashLoanDepositFeeRate',
name: 'flashLoanSwapFeeRate',
},
{
label: `Borrow Weight Scale Start Quote`,
Expand Down
6 changes: 3 additions & 3 deletions utils/Mango/listingTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export type FlatListingArgs = {
stablePriceGrowthLimit: number
tokenConditionalSwapMakerFeeRate: number
tokenConditionalSwapTakerFeeRate: number
flashLoanDepositFeeRate: number
flashLoanSwapFeeRate: number
reduceOnly: number
groupInsuranceFund: boolean
oracle: PublicKey
Expand Down Expand Up @@ -97,7 +97,7 @@ export type FlatEditArgs = {
stablePriceGrowthLimitOpt: number
tokenConditionalSwapMakerFeeRateOpt: number
tokenConditionalSwapTakerFeeRateOpt: number
flashLoanDepositFeeRateOpt: number
flashLoanSwapFeeRateOpt: number
reduceOnlyOpt: number
groupInsuranceFundOpt: boolean
oracleOpt: PublicKey
Expand Down Expand Up @@ -131,7 +131,7 @@ export type ListingArgsFormatted = {
stablePriceGrowthLimit: string
tokenConditionalSwapMakerFeeRate: number
tokenConditionalSwapTakerFeeRate: number
flashLoanDepositFeeRate: number
flashLoanSwapFeeRate: number
reduceOnly: string
oracle: string
}
Expand Down
26 changes: 17 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -337,20 +337,28 @@
keccak256 "^1.0.6"
merkletreejs "^0.3.11"

"@blockworks-foundation/[email protected].16", "@blockworks-foundation/mango-v4-settings@^0.2.15":
version "0.2.16"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4-settings/-/mango-v4-settings-0.2.16.tgz#63f03c13d1677461ea42d3b1e9171042830c6cdc"
integrity sha512-9GCRZkVqTQsEUkqx/488pmSWM8I74Ght5AEzMPsuS5XlRGWIDjytWoBE0Y9wFVPrnRw2THTj0ZQft+vDwCYDCA==
"@blockworks-foundation/[email protected].18":
version "0.2.18"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4-settings/-/mango-v4-settings-0.2.18.tgz#d984617fd44d7ba0d56b7f4a751f8b3b4d95cc35"
integrity sha512-hdU75eED5YzUWg4EJcUIJZsEvfeLVwUj3yfEykyj/OMVR/H83cbX5KuTnfh6ri0Iwd+K8cqNNFdParLKigoUxQ==
dependencies:
bn.js "^5.2.1"
eslint-config-prettier "^9.0.0"

"@blockworks-foundation/mango-v4@0.19.34":
version "0.19.34"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4/-/mango-v4-0.19.34.tgz#ddeec24f4caa9343de08354790eab6ba50a0d613"
integrity sha512-QMM3e4pyfwh13S0dn7nYZp8fs4pRI00CtUiN/9Q/DvLqEF97JuBFllGDuxRM5Y3SZSiBOwsFaWOJwYnDyNJOAA==
"@blockworks-foundation/mango-v4-settings@^0.2.16":
version "0.2.17"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4-settings/-/mango-v4-settings-0.2.17.tgz#ebc64eb037137bdd16df93cdb63badc7f178542b"
integrity sha512-k4Hi0Rjq3XbWnN4Hvdd2aDrm24Ob+8+WDCz7hzR+XKCQ0HcYQXVrZn2Yz7e9IA4M3zQEP9n5HHnQopLQb8UgMw==
dependencies:
"@blockworks-foundation/mango-v4-settings" "^0.2.15"
bn.js "^5.2.1"
eslint-config-prettier "^9.0.0"

"@blockworks-foundation/[email protected]":
version "0.20.2"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4/-/mango-v4-0.20.2.tgz#1e8d041155288cd3ca56cb19c935ca12da306c39"
integrity sha512-PrTFd1ZraRF3mjtCuJvqDqepwlo5xKIMxgJmrRRuC2Am8VqcIiXglrbPoYDKNVrEZ5OEraJFhccgRDHamkq2Vg==
dependencies:
"@blockworks-foundation/mango-v4-settings" "^0.2.16"
"@coral-xyz/anchor" "^0.28.1-beta.2"
"@project-serum/serum" "0.13.65"
"@pythnetwork/client" "~2.14.0"
Expand Down

0 comments on commit 9447152

Please sign in to comment.