This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# STDLIB_VERSION 6 #-} | |
{-# CONTENT_TYPE DAPP #-} | |
{-# SCRIPT_TYPE ACCOUNT #-} | |
### System functions | |
let Scale8 = 100000000 | |
let Scale16 = 10000000000000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prettify_apr(n): | |
return prettify_number(n * 100) + "%" | |
def get_pretty_apy(apr): | |
apy = (1 + apr / 365) ** 365 - 1 | |
return prettify_apr(apy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// calc interest | |
const supplyInterest = interests[index].times(UR).times(0.8); | |
// calc supply APY (i = interest) | |
const calcApy = (i: BN) => { | |
if (!i || i.isNaN()) return BN.ZERO; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# given code shows how you can invoke Puzzle Aggregator on-chain | |
# aggregator allows to exchange any token to any supported by PuzzleSwap.org | |
# you can modify any of these 4 parameters | |
let asset0Bytes = unit # asset you pay | |
let asset1Str = "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p" # asset you want to receive | |
let amountToExchange = 1000000 | |
let recipientStr = this.toString() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# permissionless issue NFT on Waves using puzzlemarket.org SDK | |
# run this with your Ride code | |
let nftCreationAddress = Address(base58'3PFQjjDMiZKQZdu5JqTHD7HwgSXyp9Rw9By') | |
let nftName = "Test NFT" # up to 16 symbols | |
let nftDescription = "A very rare NFT" | |
let nftImageLink = "https://ipfs.io/ipfs/bafybeidwsupz24ozr244breub5obhl5dxh22xr3wu7xumm4mlf7tgmocvi/display.png" | |
let collectionName = "artefacts" # set "" to use default collection name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// calculate amountOut for puzzle swap | |
// coef = 0.98 (excludes fee) | |
calculateAmountOut(coef: number) { | |
const tokenOut = this.state.tokenOut | |
const tokenIn = this.getTokenIn(); | |
const BalanceIn = this.state.data.get("global_"+[this.poolData.tokenIds[tokenIn]]+"_balance") | |
const BalanceOut = this.state.data.get("global_"+[this.poolData.tokenIds[tokenOut]]+"_balance") | |
const amountOut = BalanceOut / this.poolData.tokenDecimals[tokenOut] * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// to invoke puzzle swap you will need to broadcast this transaction | |
// TODO: replace poolAddress (for example "3PPRHHF9JKvDLkAc3aHD3Kd5tRZp1CoqAJa") | |
// TODO: replace assetInId and assetOutId (for example "4kwKSf4Bx2Wq8YxKnVZBhcEHyXzEtJ2pw7ixfJgirwf2" and "54UszKAj3MtYmkdRCqSXAcaQLaVALBy7CCrVkfmfzhxR") | |
// TODO: set minToReceive if you want to avoid slippage risk | |
.invoke({ | |
dApp: "poolAddress", | |
fee: 500000, | |
payment: { | |
assetId: "assetInId", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# use this JSON to swap EGGs with ledger | |
# replace "amount": 100, with your amount of EGGlets (1 EGG = 100, 1.01 EGG = 101) | |
{ | |
"type": 16, | |
"version": 2, | |
"dApp": "3PJQUUiJdvz9etUKED9ju7o7VrcNMtnkXBU", | |
"call": { | |
"args": [], | |
"function": "swapEgg" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func foo() = { | |
... | |
strict balanceBefore = wavesBalance(this).regular | |
strict z = invoke(dapp2,bar,args,[AttachedPayment(unit,100000000)]) | |
strict balanceAfter = wavesBalance(this).regular | |
if(balanceAfter < balanceBefore) then ... else... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
strict z = invoke(dapp, func, args,[AttachedPayment(unit,100000000)]) | |
// invoke(dApp: Address|Alias, function: String, arguments: List[Any], payments: List[AttachedPayments]): Any |
NewerOlder