Skip to content

Commit

Permalink
Added WXDAO price coefficient
Browse files Browse the repository at this point in the history
  • Loading branch information
bra1nsurfer committed Apr 2, 2024
1 parent 3589397 commit 5691274
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/wxdao_funding/wxdao_funding.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
| `%s__USDTassetId` | `String` | `'G5WWWzzVsWRyzGf32xojbnfp7gXbWrgqJT8RcVWEfLmC'` |
| `%s__minClaimAmount` | `Integer` | `30000000000` |
| `%s__processFeeAmount` | `Integer` | `500000` |
| `%s__WXDAOpriceCoeff` | `Integer` | `110000000` (SCALE8) |
| `%s%s%s__history__<action>__<txId>` | `String` | `'%d%d%d__<wavesAmount>__<WXDAOamount>__<processFeeAmount>'` |


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
"key": "%s__processFeeAmount",
"type": "integer",
"value": 500000
},
{
"key": "%s__WXDAOpriceCoeff",
"type": "integer",
"value": 110000000
}
]
}
4 changes: 3 additions & 1 deletion ride/wxdao_funding.ride
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func keyWXDAOassetId() = ["%s", "WXDAOassetId"].makeString(SEP)
func keyUSDTassetId() = ["%s", "USDTassetId"].makeString(SEP)
func keyProcessFeeAmount() = ["%s", "processFeeAmount"].makeString(SEP)
func keyMinClaimAmount() = ["%s", "minClaimAmount"].makeString(SEP)
func keyWXDAOpriceCoeff() = ["%s", "WXDAOpriceCoeff"].makeString(SEP)

func keyHistory(action: String, txId: String) = ["%s%s%s", "history", action, txId].makeString(SEP)

Expand Down Expand Up @@ -63,6 +64,7 @@ func getBalance(address: Address, assetIdString: String) = {

let processFeeAmount = this.getInteger(keyProcessFeeAmount()).valueOrElse(500000)
let minClaimAmount = this.getInteger(keyMinClaimAmount()).valueOrElse(0)
let wxdaoPriceCoeff = this.getInteger(keyWXDAOpriceCoeff()).valueOrElse(SCALE8)
let usdtAssetIdString = this.getStringValue(keyUSDTassetId())
let wxdaoAssetIdString = this.getStringValue(keyWXDAOassetId())
let wxdaoAssetId = stringToAsset(wxdaoAssetIdString)
Expand Down Expand Up @@ -190,7 +192,7 @@ func getWXDAOUsdtPrice() = {
let invokeResult = match (priceInvoke) {
case r:List[Any] => {
match(r[0]) {
case i:Int => i
case i:Int => fraction(i, wxdaoPriceCoeff, SCALE8)
case _ => unit
}
}
Expand Down
5 changes: 5 additions & 0 deletions test/components/wxdao_funding/_hooks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ export const mochaHooks = {
type: 'string',
value: 'MOCKED_USDT_ASSET_ID',
},
{
key: '%s__WXDAOpriceCoeff',
type: 'integer',
value: 1_1000_0000, // 110%
},
],
chainId,
}, this.accounts.wxdaoFunding.seed));
Expand Down
2 changes: 1 addition & 1 deletion test/components/wxdao_funding/processClaim.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('wxdao_funding: process', /** @this {MochaSuiteModified} */() => {
// Prices set in mocks
const claimAmount = 1.5 * 1e8;
const wavesUsdtPrice = 5.5 * 1e6;
const wxdaoUsdtPrice = 11.0 * 1e6;
const wxdaoUsdtPrice = 11.0 * 1e6 * 1.1;
const processFee = 0.005 * 1e8;

const swapAmount = claimAmount - processFee;
Expand Down

0 comments on commit 5691274

Please sign in to comment.