Skip to content

Commit

Permalink
Added amp keys to delete function
Browse files Browse the repository at this point in the history
Updated tests
  • Loading branch information
bra1nsurfer committed Sep 19, 2023
1 parent 426f1fd commit e18a50f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
13 changes: 8 additions & 5 deletions ride/factory_v2.ride
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func keyMinBalanceDefault(assetId: String)
= makeString(["%s%s", "minBalanceDefault", assetId], SEP)

# keyAmplification
func amp(poolAddress: String)
func keyAmp(poolAddress: String)
= makeString(["%s%s", "amp", poolAddress], SEP)
func keyAmpHistory(poolAddress: String, heightBlocks: Int)
= makeString(["%s%s%d", "amp", poolAddress, heightBlocks.toString()], SEP)
Expand Down Expand Up @@ -671,7 +671,7 @@ func activateNewPool(poolAddress: String, amountAssetStr: String, priceAssetStr:
StringEntry(keyMappingPoolContractToLPAsset(poolAddress), lpAssetIdStr),
IntegerEntry(keyPoolToWeight(poolAddress),poolWeight),
IntegerEntry(keyPoolSpread(poolAddress),defaultSpread),
StringEntry(amp(poolAddress), ampInitial.toString()),
StringEntry(keyAmp(poolAddress), ampInitial.toString()),
StringEntry(keyAmpHistory(poolAddress, height), ampInitial.toString())
]
, lpAssetIdStr
Expand Down Expand Up @@ -879,7 +879,7 @@ func changeAmp(poolAddress: String) = {
let delta = keyChangeAmpDelta(poolAddress).getIntegerValue()
let target = keyChangeAmpTarget(poolAddress).getIntegerValue()

let curAmp = amp(poolAddress).getStringValue().parseIntValue()
let curAmp = keyAmp(poolAddress).getStringValue().parseIntValue()
let newAmpRaw = curAmp + delta
# to not increment/decrement too much
let newAmp = if (delta < 0) then {
Expand All @@ -898,7 +898,7 @@ func changeAmp(poolAddress: String) = {

[
IntegerEntry(keyChangeAmpLastCall(poolAddress), height),
StringEntry(amp(poolAddress), newAmp.toString()),
StringEntry(keyAmp(poolAddress), newAmp.toString()),
StringEntry(keyAmpHistory(poolAddress, height), newAmp.toString())
]
}
Expand Down Expand Up @@ -1067,7 +1067,10 @@ func deletePool(poolContractAddress: String) = {

DeleteEntry(keyChangeAmpDelay(poolContractAddress)),
DeleteEntry(keyChangeAmpDelta(poolContractAddress)),
DeleteEntry(keyChangeAmpTarget(poolContractAddress))
DeleteEntry(keyChangeAmpTarget(poolContractAddress)),

DeleteEntry(keyAmp(poolContractAddress)),
DeleteEntry(keyChangeAmpLastCall(poolContractAddress))
]
}

Expand Down
7 changes: 4 additions & 3 deletions test/components/lp_stable/_hooks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export const mochaHooks = {
type: 'integer',
value: '100000',
}, {
key: '$s__outFeeDefault',
key: '%s__outFeeDefault',
type: 'integer',
value: '100000',
}],
Expand Down Expand Up @@ -277,12 +277,13 @@ export const mochaHooks = {
const setAmpTx = data({
additionalFee: 4e5,
data: [{
key: '%s__amp',
key: `%s%s__amp__${address(this.accounts.lpStable, chainId)}`,
type: 'string',
value: '250',
}],
chainId,
}, this.accounts.lpStable);
senderPublicKey: publicKey(this.accounts.factoryV2),
}, this.accounts.manager);
await api.transactions.broadcast(setAmpTx, {});
await waitForTx(setAmpTx.id, { apiBase });

Expand Down

0 comments on commit e18a50f

Please sign in to comment.