@indigo-labs/indigo-sdk 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +7 -0
- package/dist/index.d.mts +892 -867
- package/dist/index.d.ts +892 -867
- package/dist/index.js +1805 -1712
- package/dist/index.mjs +1592 -1499
- package/package.json +12 -20
- package/scripts/bench.sh +0 -0
- package/src/contracts/gov/transactions.ts +3 -1
- package/{tests/queries/stability-pool-queries.ts → src/contracts/stability-pool/queries.ts} +22 -14
- package/src/index.ts +4 -3
- package/tests/cdp/cdp-queries.ts +7 -2
- package/tests/pyth/pyth-feeds.test.ts +943 -0
- package/tests/stability-pool/actions.ts +27 -14
- package/tests/stability-pool.test.ts +62 -64
package/dist/index.mjs
CHANGED
|
@@ -6029,7 +6029,9 @@ async function vote(voteOption, pollShardOref, stakingPositionOref, sysParams, l
|
|
|
6029
6029
|
BigInt(validityFrom),
|
|
6030
6030
|
indyStakedAmt
|
|
6031
6031
|
);
|
|
6032
|
-
return lucid.newTx().validFrom(validityFrom).validTo(
|
|
6032
|
+
return lucid.newTx().validFrom(validityFrom).validTo(
|
|
6033
|
+
validityFrom + Number(sysParams.pollManagerParams.pBiasTime) - ONE_SECOND
|
|
6034
|
+
).readFrom([stakingRefScriptUtxo, pollShardRefScriptUtxo]).collectFrom([stakingPosUtxo], serialiseStakingRedeemer("Lock")).collectFrom(
|
|
6033
6035
|
[pollShardUtxo],
|
|
6034
6036
|
serialisePollShardRedeemer({ Vote: voteOption })
|
|
6035
6037
|
).pay.ToContract(
|
|
@@ -6990,1567 +6992,1655 @@ var mkGovValidatorFromSP = (params) => {
|
|
|
6990
6992
|
};
|
|
6991
6993
|
};
|
|
6992
6994
|
|
|
6993
|
-
// src/contracts/
|
|
6995
|
+
// src/contracts/staking/transactions.ts
|
|
6994
6996
|
import {
|
|
6995
|
-
|
|
6997
|
+
addAssets as addAssets9,
|
|
6996
6998
|
Data as Data32,
|
|
6997
6999
|
fromHex as fromHex9,
|
|
6998
|
-
|
|
6999
|
-
addAssets as addAssets9,
|
|
7000
|
+
fromText as fromText5,
|
|
7000
7001
|
slotToUnixTime as slotToUnixTime7,
|
|
7001
|
-
|
|
7002
|
+
toHex as toHex9
|
|
7002
7003
|
} from "@lucid-evolution/lucid";
|
|
7003
7004
|
import {
|
|
7004
|
-
adaAssetClass as adaAssetClass4,
|
|
7005
|
-
addressFromBech32 as addressFromBech322,
|
|
7006
|
-
addressToBech32 as addressToBech322,
|
|
7007
7005
|
assetClassValueOf as assetClassValueOf5,
|
|
7008
|
-
|
|
7009
|
-
lovelacesAmt as lovelacesAmt2,
|
|
7010
|
-
matchSingle as matchSingle3,
|
|
7006
|
+
getInlineDatumOrThrow as getInlineDatumOrThrow5,
|
|
7011
7007
|
mkAssetsOf as mkAssetsOf7,
|
|
7012
|
-
mkLovelacesOf as mkLovelacesOf4
|
|
7013
|
-
negateAssets as negateAssets4
|
|
7008
|
+
mkLovelacesOf as mkLovelacesOf4
|
|
7014
7009
|
} from "@3rd-eye-labs/cardano-offchain-common";
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
const
|
|
7018
|
-
const
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
)
|
|
7023
|
-
|
|
7010
|
+
async function openStakingPosition(amount, params, lucid, stakingManagerRef) {
|
|
7011
|
+
const [pkh, _] = await addrDetails(lucid);
|
|
7012
|
+
const stakingManagerOut = stakingManagerRef ? await findStakingManagerByOutRef(stakingManagerRef, lucid) : await findStakingManager(params, lucid);
|
|
7013
|
+
const stakingRefScriptUtxo = matchSingle(
|
|
7014
|
+
await lucid.utxosByOutRef([
|
|
7015
|
+
fromSystemParamsScriptRef(params.scriptReferences.stakingValidatorRef)
|
|
7016
|
+
]),
|
|
7017
|
+
(_2) => new Error("Expected a single staking Ref Script UTXO")
|
|
7018
|
+
);
|
|
7019
|
+
const stakingTokenPolicyRefScriptUtxo = matchSingle(
|
|
7020
|
+
await lucid.utxosByOutRef([
|
|
7021
|
+
fromSystemParamsScriptRef(
|
|
7022
|
+
params.scriptReferences.authTokenPolicies.stakingTokenRef
|
|
7023
|
+
)
|
|
7024
|
+
]),
|
|
7025
|
+
(_2) => new Error("Expected a single staking token policy Ref Script UTXO")
|
|
7026
|
+
);
|
|
7027
|
+
const newStakingManagerDatum = {
|
|
7028
|
+
totalStake: stakingManagerOut.datum.totalStake + amount,
|
|
7029
|
+
managerSnapshot: {
|
|
7030
|
+
snapshotAda: stakingManagerOut.datum.managerSnapshot.snapshotAda
|
|
7031
|
+
}
|
|
7024
7032
|
};
|
|
7025
|
-
const
|
|
7033
|
+
const stakingPositionDatum = {
|
|
7026
7034
|
owner: fromHex9(pkh.hash),
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
lastRequestProcessingTime: 0n
|
|
7035
|
+
lockedAmount: [],
|
|
7036
|
+
positionSnapshot: {
|
|
7037
|
+
snapshotAda: stakingManagerOut.datum.managerSnapshot.snapshotAda
|
|
7038
|
+
}
|
|
7032
7039
|
};
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
) : void 0
|
|
7043
|
-
),
|
|
7040
|
+
const stakingToken = params.stakingParams.stakingToken[0].unCurrencySymbol + fromText5(params.stakingParams.stakingToken[1].unTokenName);
|
|
7041
|
+
const indyToken = params.stakingParams.indyToken[0].unCurrencySymbol + fromText5(params.stakingParams.indyToken[1].unTokenName);
|
|
7042
|
+
return lucid.newTx().collectFrom(
|
|
7043
|
+
[stakingManagerOut.utxo],
|
|
7044
|
+
serialiseStakingRedeemer({
|
|
7045
|
+
CreateStakingPosition: { creatorPkh: fromHex9(pkh.hash) }
|
|
7046
|
+
})
|
|
7047
|
+
).readFrom([stakingRefScriptUtxo]).pay.ToContract(
|
|
7048
|
+
stakingManagerOut.utxo.address,
|
|
7044
7049
|
{
|
|
7045
7050
|
kind: "inline",
|
|
7046
|
-
value:
|
|
7051
|
+
value: serialiseStakingDatum(newStakingManagerDatum)
|
|
7047
7052
|
},
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7053
|
+
stakingManagerOut.utxo.assets
|
|
7054
|
+
).readFrom([stakingTokenPolicyRefScriptUtxo]).mintAssets(
|
|
7055
|
+
{
|
|
7056
|
+
[stakingToken]: 1n
|
|
7057
|
+
},
|
|
7058
|
+
Data32.void()
|
|
7059
|
+
).pay.ToContract(
|
|
7060
|
+
stakingManagerOut.utxo.address,
|
|
7061
|
+
{
|
|
7062
|
+
kind: "inline",
|
|
7063
|
+
value: serialiseStakingDatum(stakingPositionDatum)
|
|
7064
|
+
},
|
|
7065
|
+
{
|
|
7066
|
+
[stakingToken]: 1n,
|
|
7067
|
+
[indyToken]: amount
|
|
7068
|
+
}
|
|
7057
7069
|
).addSignerKey(pkh.hash);
|
|
7058
7070
|
}
|
|
7059
|
-
async function
|
|
7060
|
-
const
|
|
7061
|
-
const
|
|
7071
|
+
async function adjustStakingPosition(stakingPositionRef, amount, params, lucid, currentSlot, stakingManagerRef) {
|
|
7072
|
+
const network = lucid.config().network;
|
|
7073
|
+
const now = BigInt(slotToUnixTime7(network, currentSlot));
|
|
7074
|
+
const stakingPositionOut = await findStakingPositionByOutRef(
|
|
7075
|
+
stakingPositionRef,
|
|
7076
|
+
lucid
|
|
7077
|
+
);
|
|
7078
|
+
const stakingManagerOut = stakingManagerRef ? await findStakingManagerByOutRef(stakingManagerRef, lucid) : await findStakingManager(params, lucid);
|
|
7079
|
+
const stakingRefScriptUtxo = matchSingle(
|
|
7062
7080
|
await lucid.utxosByOutRef([
|
|
7063
|
-
fromSystemParamsScriptRef(
|
|
7064
|
-
sysParams.scriptReferences.stabilityPoolValidatorRef
|
|
7065
|
-
)
|
|
7081
|
+
fromSystemParamsScriptRef(params.scriptReferences.stakingValidatorRef)
|
|
7066
7082
|
]),
|
|
7067
|
-
(_) => new Error("Expected a single
|
|
7083
|
+
(_) => new Error("Expected a single staking Ref Script UTXO")
|
|
7068
7084
|
);
|
|
7069
|
-
const
|
|
7070
|
-
|
|
7085
|
+
const indyToken = fromSystemParamsAsset(params.stakingParams.indyToken);
|
|
7086
|
+
const adaReward = calculateAdaReward(
|
|
7087
|
+
stakingManagerOut.datum.managerSnapshot.snapshotAda,
|
|
7088
|
+
stakingPositionOut.datum.positionSnapshot.snapshotAda,
|
|
7089
|
+
assetClassValueOf5(stakingPositionOut.utxo.assets, indyToken)
|
|
7071
7090
|
);
|
|
7072
|
-
const
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
};
|
|
7081
|
-
return lucid.newTx().readFrom([stabilityPoolScriptRef]).collectFrom(
|
|
7082
|
-
[accountUtxo],
|
|
7083
|
-
serialiseStabilityPoolRedeemer({
|
|
7084
|
-
RequestAction: {
|
|
7085
|
-
Adjust: {
|
|
7086
|
-
amount,
|
|
7087
|
-
outputAddress: addressFromBech322(myAddress)
|
|
7088
|
-
}
|
|
7089
|
-
}
|
|
7091
|
+
const newLockedAmount = updateStakingLockedAmount(
|
|
7092
|
+
stakingPositionOut.datum.lockedAmount,
|
|
7093
|
+
BigInt(now)
|
|
7094
|
+
);
|
|
7095
|
+
return lucid.newTx().validFrom(Number(now)).readFrom([stakingRefScriptUtxo]).collectFrom(
|
|
7096
|
+
[stakingPositionOut.utxo],
|
|
7097
|
+
serialiseStakingRedeemer({
|
|
7098
|
+
AdjustStakedAmount: { adjustAmount: amount }
|
|
7090
7099
|
})
|
|
7100
|
+
).collectFrom(
|
|
7101
|
+
[stakingManagerOut.utxo],
|
|
7102
|
+
serialiseStakingRedeemer("UpdateTotalStake")
|
|
7091
7103
|
).pay.ToContract(
|
|
7092
|
-
|
|
7104
|
+
stakingManagerOut.utxo.address,
|
|
7093
7105
|
{
|
|
7094
7106
|
kind: "inline",
|
|
7095
|
-
value:
|
|
7096
|
-
|
|
7107
|
+
value: serialiseStakingDatum({
|
|
7108
|
+
...stakingManagerOut.datum,
|
|
7109
|
+
totalStake: stakingManagerOut.datum.totalStake + amount
|
|
7097
7110
|
})
|
|
7098
7111
|
},
|
|
7099
|
-
addAssets9(
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
1n
|
|
7109
|
-
),
|
|
7110
|
-
amount > 0n ? mkAssetsOf7(
|
|
7111
|
-
{
|
|
7112
|
-
currencySymbol: fromHex9(
|
|
7113
|
-
sysParams.stabilityPoolParams.assetSymbol.unCurrencySymbol
|
|
7114
|
-
),
|
|
7115
|
-
tokenName: oldAccountDatum.iasset
|
|
7112
|
+
addAssets9(stakingManagerOut.utxo.assets, mkLovelacesOf4(-adaReward))
|
|
7113
|
+
).pay.ToContract(
|
|
7114
|
+
stakingPositionOut.utxo.address,
|
|
7115
|
+
{
|
|
7116
|
+
kind: "inline",
|
|
7117
|
+
value: serialiseStakingDatum({
|
|
7118
|
+
...stakingPositionOut.datum,
|
|
7119
|
+
positionSnapshot: {
|
|
7120
|
+
snapshotAda: stakingManagerOut.datum.managerSnapshot.snapshotAda
|
|
7116
7121
|
},
|
|
7117
|
-
|
|
7118
|
-
)
|
|
7119
|
-
|
|
7120
|
-
|
|
7122
|
+
lockedAmount: newLockedAmount
|
|
7123
|
+
})
|
|
7124
|
+
},
|
|
7125
|
+
addAssets9(stakingPositionOut.utxo.assets, mkAssetsOf7(indyToken, amount))
|
|
7126
|
+
).addSignerKey(toHex9(stakingPositionOut.datum.owner));
|
|
7121
7127
|
}
|
|
7122
|
-
async function
|
|
7123
|
-
const
|
|
7124
|
-
const
|
|
7128
|
+
async function closeStakingPosition(stakingPositionRef, params, lucid, currentSlot, stakingManagerRef) {
|
|
7129
|
+
const network = lucid.config().network;
|
|
7130
|
+
const now = BigInt(slotToUnixTime7(network, currentSlot));
|
|
7131
|
+
const stakingPositionOut = await findStakingPositionByOutRef(
|
|
7132
|
+
stakingPositionRef,
|
|
7133
|
+
lucid
|
|
7134
|
+
);
|
|
7135
|
+
const stakingManagerOut = stakingManagerRef ? await findStakingManagerByOutRef(stakingManagerRef, lucid) : await findStakingManager(params, lucid);
|
|
7136
|
+
const stakingRefScriptUtxo = matchSingle(
|
|
7137
|
+
await lucid.utxosByOutRef([
|
|
7138
|
+
fromSystemParamsScriptRef(params.scriptReferences.stakingValidatorRef)
|
|
7139
|
+
]),
|
|
7140
|
+
(_) => new Error("Expected a single staking Ref Script UTXO")
|
|
7141
|
+
);
|
|
7142
|
+
const stakingTokenPolicyRefScriptUtxo = matchSingle(
|
|
7125
7143
|
await lucid.utxosByOutRef([
|
|
7126
7144
|
fromSystemParamsScriptRef(
|
|
7127
|
-
|
|
7145
|
+
params.scriptReferences.authTokenPolicies.stakingTokenRef
|
|
7128
7146
|
)
|
|
7129
7147
|
]),
|
|
7130
|
-
(_) => new Error("Expected a single
|
|
7148
|
+
(_) => new Error("Expected a single staking token policy Ref Script UTXO")
|
|
7131
7149
|
);
|
|
7132
|
-
const
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
}
|
|
7137
|
-
};
|
|
7138
|
-
const oldAccountDatum = parseAccountDatumOrThrow(
|
|
7139
|
-
getInlineDatumOrThrow(accountUtxo)
|
|
7150
|
+
const indyToken = fromSystemParamsAsset(params.stakingParams.indyToken);
|
|
7151
|
+
const existingIndyAmount = assetClassValueOf5(
|
|
7152
|
+
stakingPositionOut.utxo.assets,
|
|
7153
|
+
indyToken
|
|
7140
7154
|
);
|
|
7141
|
-
const
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7155
|
+
const adaReward = calculateAdaReward(
|
|
7156
|
+
stakingManagerOut.datum.managerSnapshot.snapshotAda,
|
|
7157
|
+
stakingPositionOut.datum.positionSnapshot.snapshotAda,
|
|
7158
|
+
assetClassValueOf5(stakingPositionOut.utxo.assets, indyToken)
|
|
7159
|
+
);
|
|
7160
|
+
return lucid.newTx().validFrom(Number(now)).readFrom([stakingRefScriptUtxo, stakingTokenPolicyRefScriptUtxo]).collectFrom([stakingPositionOut.utxo], serialiseStakingRedeemer("Unstake")).collectFrom(
|
|
7161
|
+
[stakingManagerOut.utxo],
|
|
7162
|
+
serialiseStakingRedeemer("UpdateTotalStake")
|
|
7148
7163
|
).pay.ToContract(
|
|
7149
|
-
|
|
7164
|
+
stakingManagerOut.utxo.address,
|
|
7150
7165
|
{
|
|
7151
7166
|
kind: "inline",
|
|
7152
|
-
value:
|
|
7167
|
+
value: serialiseStakingDatum({
|
|
7168
|
+
...stakingManagerOut.datum,
|
|
7169
|
+
totalStake: stakingManagerOut.datum.totalStake - existingIndyAmount
|
|
7170
|
+
})
|
|
7153
7171
|
},
|
|
7154
|
-
addAssets9(
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
),
|
|
7160
|
-
mkAssetsOf7(
|
|
7161
|
-
fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
|
|
7162
|
-
1n
|
|
7163
|
-
)
|
|
7164
|
-
)
|
|
7165
|
-
).addSignerKey(toHex9(oldAccountDatum.owner));
|
|
7172
|
+
addAssets9(stakingManagerOut.utxo.assets, mkLovelacesOf4(-adaReward))
|
|
7173
|
+
).mintAssets(
|
|
7174
|
+
mkAssetsOf7(fromSystemParamsAsset(params.stakingParams.stakingToken), -1n),
|
|
7175
|
+
Data32.void()
|
|
7176
|
+
).addSignerKey(toHex9(stakingPositionOut.datum.owner));
|
|
7166
7177
|
}
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
const
|
|
7170
|
-
const
|
|
7171
|
-
|
|
7172
|
-
fromSystemParamsScriptRef(
|
|
7173
|
-
sysParams.scriptReferences.stabilityPoolValidatorRef
|
|
7174
|
-
)
|
|
7175
|
-
]),
|
|
7176
|
-
(_) => new Error("Expected a single stability pool Ref Script UTXO")
|
|
7178
|
+
var MIN_UTXO_AMOUNT = 2000000n;
|
|
7179
|
+
async function distributeAda(stakingManagerRef, collectorRefs, params, lucid) {
|
|
7180
|
+
const [stakingManagerUtxo] = await lucid.utxosByOutRef([stakingManagerRef]);
|
|
7181
|
+
const stakingManagerDatum = parseStakingManagerDatum(
|
|
7182
|
+
getInlineDatumOrThrow5(stakingManagerUtxo)
|
|
7177
7183
|
);
|
|
7178
|
-
const
|
|
7179
|
-
|
|
7184
|
+
const collectorUtxos = (await lucid.utxosByOutRef(collectorRefs)).filter((utxo) => utxo.datum && utxo.datum === Data32.void()).filter((utxo) => utxo.assets["lovelace"] > MIN_UTXO_AMOUNT);
|
|
7185
|
+
if (collectorUtxos.length === 0) {
|
|
7186
|
+
throw new Error("No available collectors found");
|
|
7187
|
+
}
|
|
7188
|
+
const adaRewardCollected = collectorUtxos.reduce(
|
|
7189
|
+
(acc, utxo) => acc + utxo.assets["lovelace"] - MIN_UTXO_AMOUNT,
|
|
7190
|
+
0n
|
|
7180
7191
|
);
|
|
7181
|
-
const
|
|
7182
|
-
|
|
7192
|
+
const newSnapshot = distributeReward(
|
|
7193
|
+
stakingManagerDatum.managerSnapshot.snapshotAda,
|
|
7194
|
+
adaRewardCollected,
|
|
7195
|
+
stakingManagerDatum.totalStake
|
|
7183
7196
|
);
|
|
7184
|
-
const
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7197
|
+
const stakingRefScriptUtxo = matchSingle(
|
|
7198
|
+
await lucid.utxosByOutRef([
|
|
7199
|
+
fromSystemParamsScriptRef(params.scriptReferences.stakingValidatorRef)
|
|
7200
|
+
]),
|
|
7201
|
+
(_) => new Error("Expected a single staking Ref Script UTXO")
|
|
7202
|
+
);
|
|
7203
|
+
const collectorRefScriptUtxo = matchSingle(
|
|
7204
|
+
await lucid.utxosByOutRef([
|
|
7205
|
+
fromSystemParamsScriptRef(params.scriptReferences.collectorValidatorRef)
|
|
7206
|
+
]),
|
|
7207
|
+
(_) => new Error("Expected a single staking Ref Script UTXO")
|
|
7208
|
+
);
|
|
7209
|
+
const tx = lucid.newTx().readFrom([stakingRefScriptUtxo, collectorRefScriptUtxo]).collectFrom([stakingManagerUtxo], serialiseStakingRedeemer("Distribute")).collectFrom(
|
|
7210
|
+
collectorUtxos,
|
|
7211
|
+
serialiseCollectorRedeemer("DistributeToStakers")
|
|
7212
|
+
).pay.ToContract(
|
|
7213
|
+
stakingManagerUtxo.address,
|
|
7214
|
+
{
|
|
7215
|
+
kind: "inline",
|
|
7216
|
+
value: serialiseStakingDatum({
|
|
7217
|
+
...stakingManagerDatum,
|
|
7218
|
+
managerSnapshot: { snapshotAda: newSnapshot }
|
|
7219
|
+
})
|
|
7220
|
+
},
|
|
7221
|
+
addAssets9(stakingManagerUtxo.assets, mkLovelacesOf4(adaRewardCollected))
|
|
7222
|
+
);
|
|
7223
|
+
for (const collectorUtxo of collectorUtxos) {
|
|
7224
|
+
tx.pay.ToContract(
|
|
7225
|
+
collectorUtxo.address,
|
|
7226
|
+
{ kind: "inline", value: Data32.void() },
|
|
7227
|
+
mkLovelacesOf4(MIN_UTXO_AMOUNT)
|
|
7228
|
+
);
|
|
7229
|
+
}
|
|
7230
|
+
return tx;
|
|
7231
|
+
}
|
|
7232
|
+
|
|
7233
|
+
// src/contracts/staking/types.ts
|
|
7234
|
+
import { Data as Data33 } from "@lucid-evolution/lucid";
|
|
7235
|
+
var StakingParamsSchema = Data33.Object({
|
|
7236
|
+
stakingManagerNft: AssetClassSchema2,
|
|
7237
|
+
stakingToken: AssetClassSchema2,
|
|
7238
|
+
indyToken: AssetClassSchema2,
|
|
7239
|
+
pollToken: AssetClassSchema2,
|
|
7240
|
+
versionRecordToken: AssetClassSchema2,
|
|
7241
|
+
collectorValHash: Data33.Bytes()
|
|
7242
|
+
});
|
|
7243
|
+
var StakingParams = StakingParamsSchema;
|
|
7244
|
+
function castStakingParams(params) {
|
|
7245
|
+
return Data33.castTo(params, StakingParams);
|
|
7246
|
+
}
|
|
7247
|
+
|
|
7248
|
+
// src/contracts/interest-oracle/transactions.ts
|
|
7249
|
+
import {
|
|
7250
|
+
fromHex as fromHex10,
|
|
7251
|
+
fromText as fromText6,
|
|
7252
|
+
slotToUnixTime as slotToUnixTime8,
|
|
7253
|
+
toUnit as toUnit2,
|
|
7254
|
+
validatorToAddress
|
|
7255
|
+
} from "@lucid-evolution/lucid";
|
|
7256
|
+
|
|
7257
|
+
// src/contracts/one-shot/transactions.ts
|
|
7258
|
+
import {
|
|
7259
|
+
addAssets as addAssets10,
|
|
7260
|
+
Data as Data35,
|
|
7261
|
+
mintingPolicyToId,
|
|
7262
|
+
toUnit
|
|
7263
|
+
} from "@lucid-evolution/lucid";
|
|
7264
|
+
|
|
7265
|
+
// src/contracts/one-shot/scripts.ts
|
|
7266
|
+
import { applyParamsToScript as applyParamsToScript7 } from "@lucid-evolution/lucid";
|
|
7267
|
+
|
|
7268
|
+
// src/contracts/one-shot/types.ts
|
|
7269
|
+
import { Data as Data34 } from "@lucid-evolution/lucid";
|
|
7270
|
+
var OneShotParamsSchema = Data34.Object({
|
|
7271
|
+
referenceOutRef: Data34.Object({
|
|
7272
|
+
txHash: Data34.Bytes(),
|
|
7273
|
+
outputIdx: Data34.Integer()
|
|
7274
|
+
}),
|
|
7275
|
+
mintAmounts: Data34.Array(
|
|
7276
|
+
Data34.Object({
|
|
7277
|
+
/// Use hex encoded string
|
|
7278
|
+
tokenName: Data34.Bytes(),
|
|
7279
|
+
amount: Data34.Integer()
|
|
7194
7280
|
})
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7281
|
+
)
|
|
7282
|
+
});
|
|
7283
|
+
var OneShotParams = OneShotParamsSchema;
|
|
7284
|
+
function castOneShotParams(params) {
|
|
7285
|
+
return Data34.castTo(params, OneShotParams);
|
|
7286
|
+
}
|
|
7287
|
+
|
|
7288
|
+
// src/validators/one-shot-policy.ts
|
|
7289
|
+
var _oneShotPolicy = {
|
|
7290
|
+
type: "PlutusScriptV3",
|
|
7291
|
+
description: "Generated by Aiken",
|
|
7292
|
+
cborHex: "590379590376010100229800aba4aba2aba1aba0aab9faab9eaab9dab9a4888888896600264653001300800198041804800cdc3a400130080024888966002600460106ea800e26644b30013004300a37546466446600400400244b30010018a60103d87a80008992cc004cdd7980918079baa001004899ba548000cc0440052f5c11330030033013002403460220028078dd6180798061baa004300e300b375402515980099912cc004006294226530013259800980418071baa00189bad300f301237566024601e6ea800629000201a30110019baf301130120019bab0024889660020031598009801002c4c02800e294100f44c96600266ebd300101400030110018acc004cdc38021bad301230153756602400313003374c602c00514a080822b3001300b0048980180345282020404060280028090653001001801c88cc048008cc048dd3000a5eb810011112cc00400a26600298103d87a80004bd6f7b63044c8cc896600266e452201000028acc004cdc7a4410000289980219ba548000cc054c04c00d2f5c00031330044c103d87a80000054045198008034006446600c0046602e00a00280310111bae301000130150033013002404514a114a114a08090dd59807180798079807980798059baa003374c646530010019bac3002300d37540294bd6f7b630200222259800801440063300100398098014c8cc8966002601600310048991919800800803112cc00400626602e66ec0dd48061ba60034bd6f7b63044c8cc896600266e4403c00a2b30013371e01e0051325980099baf4c101a000374c003100289980d99bb037520206e9800400901719198008009bab30190042259800800c4cc070cdd81ba900a375001297adef6c6089919912cc004cdc8806801456600266e3c03400a264b30013370e00266e05200000d880144cc080cdd81ba900e375066e0000403400901c1bad301d00389980f99bb0375201a6ea003001101b44cc07c00ccc01401400501b1bae301a001301f002301d001406d13301a337606ea403cdd3003002202c89980d00199802802800a02c375c602a0026034004603000280b0cc050cdd81ba9002375000297adef6c6040406eb8c04cc040dd50009bad30053010375400260240048019010118079808000c528c590094590091bae300c30093754006b300130023008375400915980098049baa0048a4d16402916401d16401c300800130033754013149a26cac8009"
|
|
7293
|
+
};
|
|
7294
|
+
|
|
7295
|
+
// src/contracts/one-shot/scripts.ts
|
|
7296
|
+
function mkOneShotPolicy(params) {
|
|
7297
|
+
return {
|
|
7298
|
+
type: "PlutusV3",
|
|
7299
|
+
script: applyParamsToScript7(_oneShotPolicy.cborHex, [
|
|
7300
|
+
castOneShotParams(params)
|
|
7301
|
+
])
|
|
7202
7302
|
};
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
const requestDepositAmt = assetClassValueOf5(
|
|
7213
|
-
accountUtxo.assets,
|
|
7214
|
-
iassetAssetClass
|
|
7215
|
-
);
|
|
7216
|
-
const poolAddr = credentialToAddress3(
|
|
7217
|
-
lucid.config().network,
|
|
7303
|
+
}
|
|
7304
|
+
|
|
7305
|
+
// src/contracts/one-shot/transactions.ts
|
|
7306
|
+
import { reduce } from "fp-ts/lib/Array";
|
|
7307
|
+
async function oneShotMintTx(lucid, params) {
|
|
7308
|
+
const oneShotPolicy = mkOneShotPolicy(params);
|
|
7309
|
+
const policyId = mintingPolicyToId(oneShotPolicy);
|
|
7310
|
+
const refUtxo = matchSingle(
|
|
7311
|
+
await lucid.utxosByOutRef([
|
|
7218
7312
|
{
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
},
|
|
7222
|
-
sysParams.stabilityPoolParams.stakeCredential != null ? fromSysParamsCredential(
|
|
7223
|
-
sysParams.stabilityPoolParams.stakeCredential
|
|
7224
|
-
) : void 0
|
|
7225
|
-
);
|
|
7226
|
-
const accountOutputAdaAmt = lovelacesAmt2(accountUtxo.assets) - BigInt(sysParams.stabilityPoolParams.accountCreateFeeLovelaces) - txFee;
|
|
7227
|
-
const accountTokenVal = mkAssetsOf7(
|
|
7228
|
-
fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
|
|
7229
|
-
1n
|
|
7230
|
-
);
|
|
7231
|
-
const accountOutputDatum = serialiseStabilityPoolDatum({
|
|
7232
|
-
Account: {
|
|
7233
|
-
owner: accountDatum.owner,
|
|
7234
|
-
iasset: stabilityPoolDatum.iasset,
|
|
7235
|
-
state: {
|
|
7236
|
-
...stabilityPoolDatum.state,
|
|
7237
|
-
depositVal: mkSPInteger(requestDepositAmt)
|
|
7238
|
-
},
|
|
7239
|
-
assetSums: stabilityPoolDatum.assetStates.map(([key, val]) => [
|
|
7240
|
-
key,
|
|
7241
|
-
val.currentSumVal
|
|
7242
|
-
]),
|
|
7243
|
-
request: null,
|
|
7244
|
-
lastRequestProcessingTime: currentTime
|
|
7313
|
+
txHash: params.referenceOutRef.txHash,
|
|
7314
|
+
outputIndex: Number(params.referenceOutRef.outputIdx)
|
|
7245
7315
|
}
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
poolAddr,
|
|
7250
|
-
accountTokenVal,
|
|
7251
|
-
{ InlineDatum: { datum: accountOutputDatum } }
|
|
7252
|
-
);
|
|
7253
|
-
if (accountOutputAdaAmt < accountOutMinUtxoLovelace) {
|
|
7254
|
-
throw new Error("Request doesn't have enough ADA to be processed.");
|
|
7316
|
+
]),
|
|
7317
|
+
(_) => {
|
|
7318
|
+
throw new Error("Cannot find the reference UTXO for one-shot.");
|
|
7255
7319
|
}
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
e2s2sIdxs: [],
|
|
7264
|
-
currentTime
|
|
7265
|
-
}
|
|
7266
|
-
})
|
|
7267
|
-
}).mintAssets(accountTokenVal, Data32.void()).pay.ToContract(
|
|
7268
|
-
poolAddr,
|
|
7269
|
-
{
|
|
7270
|
-
kind: "inline",
|
|
7271
|
-
value: serialiseStabilityPoolDatum({
|
|
7272
|
-
StabilityPool: liquidationHelper(
|
|
7273
|
-
{
|
|
7274
|
-
...stabilityPoolDatum,
|
|
7275
|
-
state: {
|
|
7276
|
-
...stabilityPoolDatum.state,
|
|
7277
|
-
depositVal: spAdd(
|
|
7278
|
-
stabilityPoolDatum.state.depositVal,
|
|
7279
|
-
mkSPInteger(requestDepositAmt)
|
|
7280
|
-
)
|
|
7281
|
-
}
|
|
7282
|
-
},
|
|
7283
|
-
adaAssetClass4,
|
|
7284
|
-
0n,
|
|
7285
|
-
BigInt(sysParams.stabilityPoolParams.accountCreateFeeLovelaces)
|
|
7286
|
-
)
|
|
7320
|
+
);
|
|
7321
|
+
return [
|
|
7322
|
+
lucid.newTx().collectFrom([refUtxo]).mintAssets(
|
|
7323
|
+
reduce(
|
|
7324
|
+
{},
|
|
7325
|
+
(acc, entry) => addAssets10(acc, {
|
|
7326
|
+
[toUnit(policyId, entry.tokenName)]: entry.amount
|
|
7287
7327
|
})
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
makeRedeemer: (indices) => {
|
|
7355
|
-
return serialiseStabilityPoolRedeemer({
|
|
7356
|
-
ProcessRequestAccount: mkProcessRequestAccountRedeemerContent(
|
|
7357
|
-
indices[0],
|
|
7358
|
-
indices[1]
|
|
7359
|
-
)
|
|
7360
|
-
});
|
|
7361
|
-
}
|
|
7362
|
-
}).pay.ToContract(
|
|
7363
|
-
stabilityPoolUtxo.address,
|
|
7328
|
+
)(params.mintAmounts),
|
|
7329
|
+
Data35.void()
|
|
7330
|
+
).attach.MintingPolicy(oneShotPolicy),
|
|
7331
|
+
policyId
|
|
7332
|
+
];
|
|
7333
|
+
}
|
|
7334
|
+
async function runOneShotMintTx(lucid, params) {
|
|
7335
|
+
const [tx, policyId] = await oneShotMintTx(lucid, params);
|
|
7336
|
+
const txHash = await tx.complete().then((tx2) => tx2.sign.withWallet().complete()).then((tx2) => tx2.submit());
|
|
7337
|
+
await lucid.awaitTx(txHash);
|
|
7338
|
+
return policyId;
|
|
7339
|
+
}
|
|
7340
|
+
|
|
7341
|
+
// src/contracts/interest-oracle/scripts.ts
|
|
7342
|
+
import { applyParamsToScript as applyParamsToScript8 } from "@lucid-evolution/lucid";
|
|
7343
|
+
|
|
7344
|
+
// src/contracts/interest-oracle/types.ts
|
|
7345
|
+
import { Data as Data36 } from "@lucid-evolution/lucid";
|
|
7346
|
+
var InterestOracleParamsSchema = Data36.Object({
|
|
7347
|
+
/** Milliseconds */
|
|
7348
|
+
biasTime: Data36.Integer(),
|
|
7349
|
+
owner: Data36.Bytes()
|
|
7350
|
+
});
|
|
7351
|
+
var InterestOracleParams = InterestOracleParamsSchema;
|
|
7352
|
+
function castInterestOracleParams(params) {
|
|
7353
|
+
return Data36.castTo(params, InterestOracleParams);
|
|
7354
|
+
}
|
|
7355
|
+
|
|
7356
|
+
// src/validators/interest-oracle-validator.ts
|
|
7357
|
+
var _interestOracleValidator = {
|
|
7358
|
+
type: "PlutusScriptV3",
|
|
7359
|
+
description: "Generated by Aiken",
|
|
7360
|
+
cborHex: "5907e05907dd010100229800aba2aba1aba0aab9faab9eaab9dab9cab9a4888888896600264653001300900198049805000cdc3a400530090024888966002600460126ea800e2653001300e00198071807800cdc3a40009112cc004c004c034dd500444c8c8c966002602a00513259800980298089baa001899192cc004c06000a2b300130073013375401119800980b980a1baa008980a1baa00b9180c180c800c896600200310018a9980a0010800a02648888c966002660049201205458206973206e6f74207369676e6564206279206f7261636c65206f776e6572003232330010013758603c603e603e603e603e603e603e603e603e60366ea8048896600200314a115980099b8f375c603e00200714a31330020023020001406480e8dd71801980c9baa01f899912cc004cc011240115496e636f72726563742074782076616c6964697479003322980091192cc004c04c0062b30013013301f375400514c103d87a80008a6103d879800040751598009802000c5660026008603e6ea800a2980103d87a80008a6103d87b800040751332259800980d000c4c96600266e2000c0062980103d87980008acc004cdc4000801c530103d87b80008a6103d87a800040808100dd6981298111baa0048acc004c054006298103d87b80008a6103d8798000407c80f8dd6981198101baa003301f375400480e901d180f1baa002980118101810981098109810981098109810980e9baa014980118019980f98019980f98021980f9ba8337026eb4c01cc074dd500b9bad3020301d375404697ae03301f9800a51a60103d87a8000a60103d8798000406897ae03301f30033301f30043301f375066e00dd69803980e9baa017375a6040603a6ea808d2f5c06603f30014a34c103d87a8000a60103d8798000406897ae04bd702444b300132598009802800c528c566002603200314a314a080f101e180f9baa33003302330203754004604660406ea8006264b300130140018a518acc004c0640062946294101e203c301f375466006601460406ea8008c028c080dd5000c528203a118011980f192cc004c054c070dd5000c4c966002602c603a6ea8c020c078dd51810980f1baa00389802998101ba80014bd7044c014cc080dd419b80001480092f5c080d8dd69810180e9baa0018800a034301f301c3754603e60386ea8004cc078c966002602a60386ea8006264b30013016301d37546010603c6ea8c020c078dd5001c4c014cc080dd4000a5eb822600a660406ea0cdc0000a400297ae0406c6eb4c080c074dd5000c400501a180f980e1baa3006301c375400297ae0370e900244c9660026600a92012643757272656e742074696d652068617320746f206265203e3d206c6173745f736574746c656400337126eb4c004c070dd50041bad3006301c375402d15980099802a492b496e74657265737420726174652068617320746f20626520696e2072616e6765205b30252c20313030255d005980099b8948000dd6980f980e1baa301f301c375402d1337126eb4c07cc070dd5180f980e1baa0164820225ea294101944cc015240120496e746572657374206f7261636c65206f757470757420696e636f72726563740098009bac301f3020302000798019980f18011980f180f980e1baa301f301c37540086603c98103d87a80004bd7025eb8266e9520043301e30023301e375066e00dd6980f980e1baa008325980099b88375a6004603a6ea8024006266e0ccdc199b823370466e04004dd69801180e9baa009375a6040603a6ea8c01cc074dd5004a41010141ede959b7c03690405844fdf500a410112f5153301b4901015a001640686eb4c018c070dd500b1980f180f980e1baa0163301e3006301c375402c97ae04bd704dd59803180e1baa00448888c8c8cc004004018896600200314a1159800992cc004c0100062b30013375e601260486ea800401a2b300133229800992cc004c068c098dd5000c4dd6981398151bab302a302737540031480010241814800cdd58014dd798149815000c89660026040604e6ea930103d87a8000899b890010028acc004cdc480080144cdc480119b80001482026fb80a2941025204a4888966002007159800980100344cc00401120008a50409d1325980099baf4c1014000302a0018acc004cc008014dd6981598171bab302b001898019ba6302f0048a5040a115980099801002a4001130030078a5040a08140c0b400d02b0dd3002994c0040066eacc03cc094dd5001488cc0a4008cc0a4dd3000a5eb810011112cc00400a26600298103d87a80004bd6f7b63044c8cc896600266e452201000028acc004cdc7a441000028998021808198161815001a5eb80006266008980103d87a8000005409d198008034006446600c0046605c00a00280310271bae3027001302c003302a00240a113375e604e60506050605060486ea800530103d87a80008a50408514a0810a29410211813000c528c4cc008008c09c0050202048598009809980f9baa003891919baf302530223754604a60446ea8008004c090c084dd5002448c8cdd7981298111baa00200130243021375400880e914a080ca29410191180f98101810000c5282030374a90011ba548002294101619198008009bac301c0042259800800c5a264b30013375e603c60366ea80040422600a60366ea8006266006006603e00480c0c07400501b22c808a2c80a8dd6980b00098091baa0018b201e30140038b2024375a60260026026002601c6ea80222c805860146ea800e2c8038601200260086ea802629344d95900101"
|
|
7361
|
+
};
|
|
7362
|
+
|
|
7363
|
+
// src/contracts/interest-oracle/scripts.ts
|
|
7364
|
+
function mkInterestOracleValidator(params) {
|
|
7365
|
+
return {
|
|
7366
|
+
type: "PlutusV3",
|
|
7367
|
+
script: applyParamsToScript8(_interestOracleValidator.cborHex, [
|
|
7368
|
+
castInterestOracleParams(params)
|
|
7369
|
+
])
|
|
7370
|
+
};
|
|
7371
|
+
}
|
|
7372
|
+
|
|
7373
|
+
// tests/queries/interest-oracle-queries.ts
|
|
7374
|
+
import {
|
|
7375
|
+
assetClassToUnit as assetClassToUnit2
|
|
7376
|
+
} from "@3rd-eye-labs/cardano-offchain-common";
|
|
7377
|
+
async function findInterestOracle(lucid, interestNft) {
|
|
7378
|
+
return lucid.utxoByUnit(assetClassToUnit2(interestNft));
|
|
7379
|
+
}
|
|
7380
|
+
|
|
7381
|
+
// src/contracts/interest-oracle/transactions.ts
|
|
7382
|
+
async function startInterestOracle(initialUnitaryInterest, initialInterestRate, initialLastInterestUpdate, oracleParams, lucid, interestTokenName, withScriptRef = false, refOutRef) {
|
|
7383
|
+
const network = lucid.config().network;
|
|
7384
|
+
const tokenName = interestTokenName ?? "INTEREST_ORACLE";
|
|
7385
|
+
if (!refOutRef) {
|
|
7386
|
+
refOutRef = (await lucid.wallet().getUtxos())[0];
|
|
7387
|
+
}
|
|
7388
|
+
const [tx, policyId] = await oneShotMintTx(lucid, {
|
|
7389
|
+
referenceOutRef: {
|
|
7390
|
+
txHash: refOutRef.txHash,
|
|
7391
|
+
outputIdx: BigInt(refOutRef.outputIndex)
|
|
7392
|
+
},
|
|
7393
|
+
mintAmounts: [
|
|
7364
7394
|
{
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
StabilityPool: {
|
|
7368
|
-
...stabilityPoolDatum,
|
|
7369
|
-
state: newPoolState
|
|
7370
|
-
}
|
|
7371
|
-
})
|
|
7372
|
-
},
|
|
7373
|
-
addAssets9(
|
|
7374
|
-
stabilityPoolUtxo.assets,
|
|
7375
|
-
negateAssets4(reward),
|
|
7376
|
-
mkAssetsOf7(iassetAssetClass, accountBalanceChange + withdrawalFeeAmt)
|
|
7377
|
-
)
|
|
7378
|
-
);
|
|
7379
|
-
const theoreticalOwnerOutputVal = addAssets9(
|
|
7380
|
-
reward,
|
|
7381
|
-
isDepositOrRewardWithdrawal ? {} : mkAssetsOf7(
|
|
7382
|
-
iassetAssetClass,
|
|
7383
|
-
-accountBalanceChange - withdrawalFeeAmt
|
|
7384
|
-
)
|
|
7385
|
-
);
|
|
7386
|
-
const ownerOutputDat = serialiseActionReturnDatum({
|
|
7387
|
-
IndigoStabilityPoolAccountAdjustment: {
|
|
7388
|
-
txHash: fromHex9(accountUtxo.txHash),
|
|
7389
|
-
outputIndex: BigInt(accountUtxo.outputIndex)
|
|
7395
|
+
tokenName: fromText6(tokenName),
|
|
7396
|
+
amount: 1n
|
|
7390
7397
|
}
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
);
|
|
7403
|
-
const accountOutputDat = serialiseStabilityPoolDatum({
|
|
7404
|
-
Account: {
|
|
7405
|
-
...updatedAccountContent,
|
|
7406
|
-
state: {
|
|
7407
|
-
...updatedAccountContent.state,
|
|
7408
|
-
depositVal: spAdd(
|
|
7409
|
-
updatedAccountContent.state.depositVal,
|
|
7410
|
-
mkSPInteger(accountBalanceChange)
|
|
7411
|
-
)
|
|
7398
|
+
]
|
|
7399
|
+
});
|
|
7400
|
+
const validator = mkInterestOracleValidator(oracleParams);
|
|
7401
|
+
tx.pay.ToContract(
|
|
7402
|
+
validatorToAddress(network, validator),
|
|
7403
|
+
{
|
|
7404
|
+
kind: "inline",
|
|
7405
|
+
value: serialiseInterestOracleDatum({
|
|
7406
|
+
unitaryInterest: initialUnitaryInterest,
|
|
7407
|
+
interestRate: {
|
|
7408
|
+
getOnChainInt: initialInterestRate
|
|
7412
7409
|
},
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
1n
|
|
7420
|
-
);
|
|
7421
|
-
const accountOutMinUtxoLovelace = estimateUtxoMinLovelace3(
|
|
7422
|
-
lucid.config().protocolParameters,
|
|
7423
|
-
stabilityPoolUtxo.address,
|
|
7424
|
-
accountOutputValWithoutAda,
|
|
7425
|
-
{ InlineDatum: { datum: accountOutputDat } }
|
|
7426
|
-
);
|
|
7427
|
-
const accountOutputAdaAmt = lovelacesAmt2(accountUtxo.assets) - extraOwnerOutputLovelacesAmt - txFee;
|
|
7428
|
-
if (accountOutputAdaAmt < accountOutMinUtxoLovelace) {
|
|
7429
|
-
throw new Error("Account doesn't have enough ADA to be processed.");
|
|
7430
|
-
}
|
|
7431
|
-
tx.pay.ToContract(
|
|
7432
|
-
stabilityPoolUtxo.address,
|
|
7433
|
-
{
|
|
7434
|
-
kind: "inline",
|
|
7435
|
-
value: accountOutputDat
|
|
7436
|
-
},
|
|
7437
|
-
addAssets9(
|
|
7438
|
-
accountOutputValWithoutAda,
|
|
7439
|
-
mkLovelacesOf4(accountOutputAdaAmt)
|
|
7440
|
-
)
|
|
7441
|
-
).pay.ToAddressWithData(
|
|
7442
|
-
outputAddress,
|
|
7443
|
-
{
|
|
7444
|
-
kind: "inline",
|
|
7445
|
-
value: ownerOutputDat
|
|
7446
|
-
},
|
|
7447
|
-
actualOwnerOutputVal
|
|
7448
|
-
).setMinFee(txFee);
|
|
7449
|
-
}).with({ Close: P17.select() }, async (closeContent) => {
|
|
7450
|
-
if (txFee > closeContent.maxTxFee) {
|
|
7451
|
-
throw new Error("Account doesn't allow current transaction fee.");
|
|
7410
|
+
lastUpdated: initialLastInterestUpdate
|
|
7411
|
+
})
|
|
7412
|
+
},
|
|
7413
|
+
{
|
|
7414
|
+
lovelace: 2500000n,
|
|
7415
|
+
[toUnit2(policyId, fromText6(tokenName))]: 1n
|
|
7452
7416
|
}
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
);
|
|
7461
|
-
const iassetDatum = parseIAssetDatumOrThrow(
|
|
7462
|
-
getInlineDatumOrThrow(iAssetUtxo)
|
|
7463
|
-
);
|
|
7464
|
-
const outputAddress = addressToBech322(
|
|
7465
|
-
closeContent.outputAddress,
|
|
7466
|
-
lucid.config().network
|
|
7467
|
-
);
|
|
7468
|
-
const e2s2sIdxs = await findRelevantE2s2sIdxs(
|
|
7469
|
-
lucid,
|
|
7470
|
-
stabilityPoolDatum,
|
|
7471
|
-
accountDatum.state,
|
|
7472
|
-
allE2s2sSnapshotOrefs
|
|
7473
|
-
);
|
|
7474
|
-
const { updatedAccountContent, reward } = updateAccount(
|
|
7475
|
-
stabilityPoolDatum,
|
|
7476
|
-
accountDatum,
|
|
7477
|
-
e2s2sIdxs
|
|
7478
|
-
);
|
|
7479
|
-
const newPoolDepositExcludingFee = spZeroNegatives(
|
|
7480
|
-
spSub(
|
|
7481
|
-
stabilityPoolDatum.state.depositVal,
|
|
7482
|
-
updatedAccountContent.state.depositVal
|
|
7483
|
-
)
|
|
7484
|
-
);
|
|
7485
|
-
const withdrawnAmt = zeroNegatives(
|
|
7486
|
-
fromSPInteger(updatedAccountContent.state.depositVal)
|
|
7487
|
-
);
|
|
7488
|
-
const withdrawalFeeAmt = newPoolDepositExcludingFee.value === 0n ? 0n : calculateFeeFromRatio(
|
|
7489
|
-
iassetDatum.stabilityPoolWithdrawalFeeRatio,
|
|
7490
|
-
withdrawnAmt
|
|
7491
|
-
);
|
|
7492
|
-
const newPoolState = updatePoolStateWhenWithdrawalFee(withdrawalFeeAmt, {
|
|
7493
|
-
...stabilityPoolDatum.state,
|
|
7494
|
-
depositVal: newPoolDepositExcludingFee
|
|
7495
|
-
});
|
|
7496
|
-
const { e2s2sRefInputs, mkProcessRequestAccountRedeemerContent } = createProcessRequestAccountRedeemer(
|
|
7497
|
-
e2s2sIdxs,
|
|
7498
|
-
[...baseRefInputs, accountTokenScriptRef],
|
|
7499
|
-
currentTime
|
|
7417
|
+
);
|
|
7418
|
+
if (withScriptRef) {
|
|
7419
|
+
tx.pay.ToAddressWithData(
|
|
7420
|
+
validatorToAddress(network, validator),
|
|
7421
|
+
void 0,
|
|
7422
|
+
void 0,
|
|
7423
|
+
validator
|
|
7500
7424
|
);
|
|
7501
|
-
|
|
7502
|
-
|
|
7425
|
+
}
|
|
7426
|
+
return [
|
|
7427
|
+
tx,
|
|
7428
|
+
{
|
|
7429
|
+
currencySymbol: fromHex10(policyId),
|
|
7430
|
+
tokenName: fromHex10(fromText6(tokenName))
|
|
7503
7431
|
}
|
|
7504
|
-
|
|
7505
|
-
kind: "selected",
|
|
7506
|
-
inputs: [stabilityPoolUtxo, accountUtxo],
|
|
7507
|
-
makeRedeemer: (indices) => {
|
|
7508
|
-
return serialiseStabilityPoolRedeemer({
|
|
7509
|
-
ProcessRequestAccount: mkProcessRequestAccountRedeemerContent(
|
|
7510
|
-
indices[0],
|
|
7511
|
-
indices[1]
|
|
7512
|
-
)
|
|
7513
|
-
});
|
|
7514
|
-
}
|
|
7515
|
-
}).mintAssets(
|
|
7516
|
-
mkAssetsOf7(
|
|
7517
|
-
fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
|
|
7518
|
-
-1n
|
|
7519
|
-
),
|
|
7520
|
-
Data32.void()
|
|
7521
|
-
).pay.ToContract(
|
|
7522
|
-
stabilityPoolUtxo.address,
|
|
7523
|
-
{
|
|
7524
|
-
kind: "inline",
|
|
7525
|
-
value: serialiseStabilityPoolDatum({
|
|
7526
|
-
StabilityPool: {
|
|
7527
|
-
...stabilityPoolDatum,
|
|
7528
|
-
state: newPoolState
|
|
7529
|
-
}
|
|
7530
|
-
})
|
|
7531
|
-
},
|
|
7532
|
-
addAssets9(
|
|
7533
|
-
stabilityPoolUtxo.assets,
|
|
7534
|
-
negateAssets4(reward),
|
|
7535
|
-
mkAssetsOf7(iassetAssetClass, -withdrawnAmt + withdrawalFeeAmt)
|
|
7536
|
-
)
|
|
7537
|
-
).pay.ToAddressWithData(
|
|
7538
|
-
outputAddress,
|
|
7539
|
-
{
|
|
7540
|
-
kind: "inline",
|
|
7541
|
-
value: serialiseActionReturnDatum({
|
|
7542
|
-
IndigoStabilityPoolAccountClosure: {
|
|
7543
|
-
txHash: fromHex9(accountUtxo.txHash),
|
|
7544
|
-
outputIndex: BigInt(accountUtxo.outputIndex)
|
|
7545
|
-
}
|
|
7546
|
-
})
|
|
7547
|
-
},
|
|
7548
|
-
addAssets9(
|
|
7549
|
-
mkLovelacesOf4(lovelacesAmt2(accountUtxo.assets) - txFee),
|
|
7550
|
-
reward,
|
|
7551
|
-
mkAssetsOf7(iassetAssetClass, withdrawnAmt - withdrawalFeeAmt)
|
|
7552
|
-
)
|
|
7553
|
-
).setMinFee(txFee);
|
|
7554
|
-
}).exhaustive();
|
|
7555
|
-
return tx;
|
|
7556
|
-
}
|
|
7557
|
-
async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid, currentSlot) {
|
|
7558
|
-
const draftTx = processSpRequestAuxiliary(
|
|
7559
|
-
stabilityPoolUtxo,
|
|
7560
|
-
accountUtxo,
|
|
7561
|
-
iAssetUtxo,
|
|
7562
|
-
allE2s2sSnapshotOrefs,
|
|
7563
|
-
sysParams,
|
|
7564
|
-
lucid,
|
|
7565
|
-
currentSlot,
|
|
7566
|
-
// Placeholder transation fee
|
|
7567
|
-
1n
|
|
7568
|
-
);
|
|
7569
|
-
const fee = (await (await draftTx).complete()).toTransaction().body().fee();
|
|
7570
|
-
return processSpRequestAuxiliary(
|
|
7571
|
-
stabilityPoolUtxo,
|
|
7572
|
-
accountUtxo,
|
|
7573
|
-
iAssetUtxo,
|
|
7574
|
-
allE2s2sSnapshotOrefs,
|
|
7575
|
-
sysParams,
|
|
7576
|
-
lucid,
|
|
7577
|
-
currentSlot,
|
|
7578
|
-
fee
|
|
7579
|
-
);
|
|
7432
|
+
];
|
|
7580
7433
|
}
|
|
7581
|
-
async function
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
)
|
|
7587
|
-
]),
|
|
7588
|
-
(_) => new Error("Expected a single stability pool Ref Script UTXO")
|
|
7589
|
-
);
|
|
7590
|
-
const snapshotE2s2sPolicyRefScriptUtxo = matchSingle3(
|
|
7591
|
-
await lucid.utxosByOutRef([
|
|
7592
|
-
fromSystemParamsScriptRef(
|
|
7593
|
-
sysParams.scriptReferences.authTokenPolicies.snapshotEpochToScaleToSumTokenRef
|
|
7594
|
-
)
|
|
7595
|
-
]),
|
|
7596
|
-
(_) => new Error("Expected a single snapshot e2s2s policy Ref Script UTXO")
|
|
7597
|
-
);
|
|
7598
|
-
const spUtxo = matchSingle3(
|
|
7599
|
-
await lucid.utxosByOutRef([stabilityPoolOref]),
|
|
7600
|
-
(_) => new Error("Expected a single stability pool UTXO")
|
|
7601
|
-
);
|
|
7602
|
-
const spDatum = parseStabilityPoolDatumOrThrow(getInlineDatumOrThrow(spUtxo));
|
|
7603
|
-
const [newSnapshotDatums, newAssetStates] = partitionEpochToScaleToSums(spDatum);
|
|
7604
|
-
if (newSnapshotDatums.length === 0) {
|
|
7605
|
-
throw new Error("There has to be a snapshot being created.");
|
|
7434
|
+
async function feedInterestOracle(params, newInterestRate, lucid, currentSlot, assetClass, utxo, scriptRef2) {
|
|
7435
|
+
if (!assetClass && !utxo)
|
|
7436
|
+
throw new Error("Either interest oracle nft or utxo must be provided");
|
|
7437
|
+
if (assetClass && !utxo) {
|
|
7438
|
+
utxo = await findInterestOracle(lucid, assetClass);
|
|
7606
7439
|
}
|
|
7607
|
-
const
|
|
7608
|
-
|
|
7440
|
+
const network = lucid.config().network;
|
|
7441
|
+
const now = BigInt(slotToUnixTime8(network, currentSlot));
|
|
7442
|
+
const tx = lucid.newTx();
|
|
7443
|
+
const datum = parseInterestOracleDatum(getInlineDatumOrThrow(utxo));
|
|
7444
|
+
if (scriptRef2) {
|
|
7445
|
+
tx.readFrom([scriptRef2]);
|
|
7446
|
+
} else {
|
|
7447
|
+
tx.attach.Script(mkInterestOracleValidator(params));
|
|
7448
|
+
}
|
|
7449
|
+
tx.collectFrom(
|
|
7450
|
+
[utxo],
|
|
7451
|
+
serialiseFeedInterestOracleRedeemer({
|
|
7452
|
+
newInterestRate: {
|
|
7453
|
+
getOnChainInt: newInterestRate
|
|
7454
|
+
},
|
|
7455
|
+
currentTime: now
|
|
7456
|
+
})
|
|
7609
7457
|
);
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
serialiseStabilityPoolRedeemer("RecordEpochToScaleToSum")
|
|
7613
|
-
).mintAssets(
|
|
7614
|
-
mkAssetsOf7(snapshotAc, BigInt(newSnapshotDatums.length)),
|
|
7615
|
-
Data32.void()
|
|
7616
|
-
).pay.ToContract(
|
|
7617
|
-
spUtxo.address,
|
|
7458
|
+
tx.pay.ToContract(
|
|
7459
|
+
utxo.address,
|
|
7618
7460
|
{
|
|
7619
7461
|
kind: "inline",
|
|
7620
|
-
value:
|
|
7621
|
-
|
|
7462
|
+
value: serialiseInterestOracleDatum({
|
|
7463
|
+
unitaryInterest: datum.unitaryInterest + calculateUnitaryInterestSinceOracleLastUpdated(now, datum),
|
|
7464
|
+
interestRate: {
|
|
7465
|
+
getOnChainInt: newInterestRate
|
|
7466
|
+
},
|
|
7467
|
+
lastUpdated: now
|
|
7622
7468
|
})
|
|
7623
7469
|
},
|
|
7624
|
-
|
|
7470
|
+
utxo.assets
|
|
7625
7471
|
);
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
{
|
|
7630
|
-
kind: "inline",
|
|
7631
|
-
value: serialiseStabilityPoolDatum({
|
|
7632
|
-
SnapshotEpochToScaleToSum: newDatum
|
|
7633
|
-
})
|
|
7634
|
-
},
|
|
7635
|
-
mkAssetsOf7(snapshotAc, 1n)
|
|
7636
|
-
);
|
|
7637
|
-
}
|
|
7472
|
+
tx.validFrom(Number(now) - ONE_SECOND);
|
|
7473
|
+
tx.validTo(Number(now + params.biasTime) - ONE_SECOND);
|
|
7474
|
+
tx.addSignerKey(params.owner);
|
|
7638
7475
|
return tx;
|
|
7639
7476
|
}
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
(
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
|
|
7654
|
-
tx.pay.ToContract(
|
|
7655
|
-
accountUtxo.address,
|
|
7656
|
-
{
|
|
7657
|
-
kind: "inline",
|
|
7658
|
-
value: serialiseStabilityPoolDatum({
|
|
7659
|
-
Account: {
|
|
7660
|
-
...oldAccountDatum,
|
|
7661
|
-
request: null
|
|
7662
|
-
}
|
|
7663
|
-
})
|
|
7664
|
-
},
|
|
7665
|
-
mkAssetsOf7(
|
|
7666
|
-
fromSystemParamsAsset(params.stabilityPoolParams.accountToken),
|
|
7667
|
-
1n
|
|
7668
|
-
)
|
|
7669
|
-
);
|
|
7477
|
+
|
|
7478
|
+
// src/contracts/interest-collection/helpers.ts
|
|
7479
|
+
import { toHex as toHex10 } from "@lucid-evolution/lucid";
|
|
7480
|
+
function signersAllOf(multisig) {
|
|
7481
|
+
if ("Signature" in multisig) {
|
|
7482
|
+
return [toHex10(multisig.Signature.keyHash)];
|
|
7483
|
+
} else {
|
|
7484
|
+
return multisig.AtLeast.authSignatories.map((signatory) => {
|
|
7485
|
+
try {
|
|
7486
|
+
return signersAllOf(fromDataMultisig(signatory));
|
|
7487
|
+
} catch {
|
|
7488
|
+
return [];
|
|
7489
|
+
}
|
|
7490
|
+
}).flat();
|
|
7670
7491
|
}
|
|
7671
|
-
return tx;
|
|
7672
7492
|
}
|
|
7673
7493
|
|
|
7674
|
-
// src/contracts/
|
|
7675
|
-
import {
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7494
|
+
// src/contracts/interest-collection/types.ts
|
|
7495
|
+
import { Data as Data37 } from "@lucid-evolution/lucid";
|
|
7496
|
+
var InterestCollectionParamsSchema = Data37.Object({
|
|
7497
|
+
versionRecordNft: AssetClassSchema2,
|
|
7498
|
+
multisigUtxoNft: AssetClassSchema2,
|
|
7499
|
+
cdpAuthTk: AssetClassSchema2,
|
|
7500
|
+
collateralAssetAuthTk: AssetClassSchema2,
|
|
7501
|
+
govAuthTk: AssetClassSchema2,
|
|
7502
|
+
cdpAssetSymbol: Data37.Bytes(),
|
|
7503
|
+
cdpBiasTime: Data37.Integer(),
|
|
7504
|
+
interestSettlementCooldown: Data37.Integer()
|
|
7505
|
+
});
|
|
7506
|
+
var InterestCollectionParams = InterestCollectionParamsSchema;
|
|
7507
|
+
function castInterestCollectionParams(params) {
|
|
7508
|
+
return Data37.castTo(params, InterestCollectionParams);
|
|
7509
|
+
}
|
|
7510
|
+
|
|
7511
|
+
// src/contracts/interest-collection/scripts.ts
|
|
7512
|
+
import { applyParamsToScript as applyParamsToScript9 } from "@lucid-evolution/lucid";
|
|
7513
|
+
|
|
7514
|
+
// src/validators/interest-collection-validator.ts
|
|
7515
|
+
var _interestCollectionValidator = {
|
|
7516
|
+
type: "PlutusScriptV3",
|
|
7517
|
+
description: "Generated by Aiken",
|
|
7518
|
+
cborHex: "59202059201d010100229800aba2aba1aba0aab9faab9eaab9dab9cab9a488888888cc896600264653001300b00198059806000cdc3a4005300b0024888966002600460166ea800e33001300c3754007370e90034dc3a4001370e90024c02cdd5002244444646644b300130060048acc004c050dd5006400a2c80aa2b3001300a0048991919194c004dd6980d800cdd6980d8024dd6980d801cdd6980d80124444b3001302000580545901d0c06c004c068004c064004c050dd50064566002600a009159800980a1baa00c8014590154566002600e009159800980a1baa00c801459015456600266e1d20080048acc004c050dd5006400a2c80aa2c8089011202240448088660024602c602e003259800980218091baa0018980b18099baa0018b20209180b180b980b980b980b800c888c8cc88cc0080080048966002003003899192cc004cdc8803000c56600266e3c01800626eb4c06800a00a80ba266008008603c00680b8dd7180c000980d800a0323232330010010062259800800c00e26464b30013372201000315980099b8f00800189bab301b002802a030899802002180f801a030375c6032002603800280d052f5bded8c029000488c8cc00400400c896600200314bd7044cc8966002600a00513301a00233004004001899802002000a02a3019001301a001405d3710900048c058c05cc05c00644646600200200644660060026004005301137540152259800800c40062a660240042002808a4602c602e602e602e602e602e602e602e602e602e003374a90012444444444444653001222323300d00423002301230243754002b300130143021375400312330053756602260466ea800400e24601930013756602260466ea80066eb8c098c08cdd5001cdd7180898119baa003403880fa4466016004466ebcc094c088dd5181298111baa3010302237540020052232330010010032259800800c5a264b30013375e604e60486ea80040122602460486ea800626600600660500048108c0980050242444b300130140088cc00488c966002602e0031323259800981580140122c8140dd6981480098129baa0038acc004c06c00626464b3001302b0028024590281bad302900130253754007159800980b000c566002604a6ea800e005164099164088811102218119baa002980518111baa028980818111baa028998009bac30253022375402e0229111192cc0040060451598009815800c4c9660020030248992cc004c0b400a2646644b3001301e00189919194c004dd69819000cc0cc0066eb4c0c800e6eb4c0c8009222259800981b801c4cc044c0d800c0262c81a06064002606200260586ea800e2b30013022001899192cc004c0c800a0091640bc6eb4c0c0004c0b0dd5001c566002603a00315980098161baa00380145902d4566002603e0031323322598009819800c4cc034c0c80040162c8180dd69818000981880098161baa0038acc004cdc3a401000315980098161baa00380145902d456600266e1d200a0018992cc004c0c4006264b30013020302d375400313232332259800981b001c0222c8198dd698198009bae30330023033001302e37540031640ac60600031640b860586ea800e2b30013370e9006000c56600260586ea800e0051640b515980099b874803800626464b3001303200280245902f1bad3030001302c375400715980099b874804000626464b3001303200280245902f1bad3030001302c375400715980099b87480480062b3001302c37540070028b205a8b205240a48149029205240a48149029205240a42b30013300f4901205370656e74205554784f2063616e6e6f7420686176652061646d696e204e4654009800998061bab3018302a375400a00d4a14a2813a26601e9212b43445020696e70757420646f6573206e6f74206861766520616e20616c6c6f7765642072656465656d6572003259800980e800c528c566002604200314a3159800980e000c528c56600266e1d200c0018a518a5040a0814102820503029375400314a08138c0a4dd50009919198008009bab300f302b37540404464b30013375e00860580031302d00189980180198188012054302f001300c3302b302c3029375400297ae0812a054302b00140a5300137586054604e6ea80720094c103d87a8000402102240a08140cc018dd6181498131baa01b3029302637546052604c6ea80051980092cc004c054c088dd5000c48c8cdd7981418129baa302830253754004002604e60486ea800a246466ebcc0a0c094dd5001000981398121baa0024081374a900048c098c09cc09cc09c0064464b30013017001899192cc004c0ac00a0091640a06eb8c0a4004c094dd5001c566002603600315980098129baa0038014590264590222044302337540053700900124444464b3001301e00e8cc004c0a0dd501048966002603860526ea800a264646644b30013032003802c5902f1bae302f001375c605e004605e00260546ea800a2c813a44b3001301c30293754005132323322598009819001c0162c8178dd698178009bad302f002302f001302a375400516409d223259800980e800c566002603a60546ea800a2980103d87a80008a6103d879800040a1159800980e000c566002603860546ea800a2980103d87a80008a6103d87b800040a113322598009811800c4c96600266e2000c0062980103d87980008acc004cdc4000801c530103d87b80008a6103d87a800040ac8158dd6981818169baa0048acc004c07c006298103d87b80008a6103d879800040a88150dd6981718159baa003302a3754004814102818149baa0029180319815992cc004c080c0a4dd5000c4c966002604260546ea8c064c0acdd5181718159baa00389807198169ba80014bd7044c038cc0b4dd41802800a5eb810281bad302d302a37540031001409c605860526ea8c0b0c0a4dd500099815992cc004c080c0a4dd5000c4c966002604260546ea8c064c0acdd5180c98159baa00389807198169ba80014bd7044c038cc0b4dd419b80001480052f5c08140dd6981698151baa0018800a04e302c30293754602e60526ea80052f5c1223302c337606ea4008dd4000a5eb7bdb182444b3001337129002000c66002007302f302f00299b800014800d003456600266e2520020018cc00400e605e005337000029000a0068acc004c0740062605c0051533029491146578706563745f61743a206e6f7420666f756e64001640a0814102848c0b0c0b4c0b4c0b4c0b4c0b4c0b4c0b400644444b30013300b0040058acc004cdd7980a98169baa0050038acc00660026eacc06cc0b4dd5002c00a0028032266ebcc024c0b4dd5002a60103d87a80008a5040a914a08152294102a48c0b0c0b4c0b4c0b4c0b4c0b4c0b400646058605a605a605a605a605a00291111111111194c004c0e00066eb4c0dc006600c00c9114c004dd6981d001cdd6981d181d801ccc004dd6181d181b9baa02c0029bad303a00f488896600266ebcc0f8c0ecdd5001015466002607c60766ea8c0f8c0ecdd51814981d9baa002981f1bac3023303b3754061330053758605260766ea80c001122259800998101bab302c303e37546058607c6ea8004c068c0f8dd502244c966002606a607c6ea8006264b30013044001899192cc004c0d0c104dd500144c8c8c8c8c8c8c8c8c8c8ca600260a0003375c60a0017375a60a001330500089828003cc14001a60a000b30500049bad3050003992cc004c1380062b30013371290021826800c5a26088609a002825a2c8278dd5182800124444444444b3001305b00b899817182d00a099912cc004c12c006264b3001305e001899818182e800801c5905b182c9baa0098acc004c13c006264b3001305e001899818982e800801c5905b182c9baa0098acc004c12800626464b3001305f00280245905c1bae305d0013059375401316415882b10560998170030998168028998168020998168018992cc004c128006264b3001305d001899818182e00080c45905a182c1baa00b8acc004c1380062b3001305837540170178b20b28b20aa415460ac6ea8028c158dd5003c590580c140004c13c004c138004c134004c130004c12c004c128004c124004c120004c11c004c108dd500145903f0992cc004cc090dd5981818211baa303030423754002605c60846ea800a264b300130353042375400313232323322598009826001c4c966002607660906ea800626464b3001304f00289919192cc004cc0cd2410f4261642074782076616c696469747900332259800992cc004c10800629462b300130470018a518a5041388270c13cdd519812982998281baa002305330503754003132598009821800c528c566002608e00314a314a0827104e18279baa33025303e30503754004607c60a06ea8006294104d1811180f98271baa0433022302b33050302b33050303133050375060066eb4c074c138dd502a25eb80cc142600294698103d87a8000a60103d8798000412c97ae033050302b33050303133050375066e00050dd6980e98271baa0544bd70198284c00528d300103d87a8000a60103d8798000412c97ae04bd704566002660669201274d757374206f6e6c79206d696e742074686520616363756d756c6174656420696e746572657374003375e6074609c6ea810cdd32cc004c100006297adef6c6089982819bb0301c304e37540a86e98cc084dd7182898271baa00e0014bd6f7b63020968acc004cc0cd241205370656e74205554784f2063616e6e6f7420686176652061646d696e204e4654009800998181bab303c304e37546078609c6ea8054c0f0c138dd502a528528a096899819a48146436f6e74696e75696e67206f7574707574206d7573742068617665206e6f20646174756d20616e6420686f6c642074686520616363756d756c6174656420696e7465726573740098008094c0c4cc140c0accc14004ccc141300103d87a80004bd7025eb8298107d87b9fd87980ff00cc004dd5981e18271baa303c304e375402b375c6038609c6ea81526eb8c144c138dd50072444b300130430048801c4c8c8cc0040040148966002003133056337606ea4014dd3001a5eb7bdb1822646644b30013372201000515980099b8f0080028992cc004cdd7a6101a000374c003100289982d19bb037520126e9800400905519198008009bab30580042259800800c4cc16ccdd81ba9009375001897adef6c6089919912cc004cdc8806001456600266e3c03000a264b30013370e00266e052000010880144cc17ccdd81ba900d375066e0000404000905a1bad305c00389982f19bb037520186ea003c01105944cc17800ccc0140140050591bae3059001305e002305c0014169133059337606ea4020dd300300220a889982c80199802802800a0a8375c60a800260b200460ae00282a8cc09000401104e2980103d87a8000407914a0825a294104b45282096375a60a06530010019bac3051304e375408737566064609c6ea810e660a098101000033050374e60a46eb0c0d8c138dd5021998284c005285300103d87a8000a60103d8798000412c97ae040044444b30010038800c4cc8966002609260a46ea8c158c14cdd5182b18299baa3041305337540051329800803c00a6eacc15cc160006653001375860b0003304b3054375460b060b2003375a60b000b30580024888966002660766eacc11cc164dd51823982c9baa0083041305937540bf15980099b8748038c160dd5000c4c96600260bc00313322598009827182d9baa0018992cc004c184006264b30013050305d37540031323232323298009833000cdd718330024c19800e6eb4c1980092222598009835802c4c8cc10c0044cc0fc00c4cc896600260b8003132323322598009839001c01a2c8378dd698378009bad306f002306f001306a375400f1598009830000c4c8c8cc896600260e40070068b20de375a60de0026eb4c1bc008c1bc004c1a8dd5003c5906720ce159800982d18339baa005899192cc0056600266e3c018dd7183698351baa02a899baf0053058306a375405514a0833a2b30013371066e00004dd6981d98351baa0700308992cc004c1500062b30019800983700b4c138cc1b4c1b8c1acdd5182c98359baa01a4bd704cdd2a4008660da6090660da6090660da008660da6ea401ccc1b4018cc1b4dd419b800050013306d30483306d3750062660da6ea007d2f5c097ae04bd7025eb826eacc164c1acdd5182c98359baa01aa60103d879800040ed13306d375066e00050004cc1b4dd3983780b19836cc00405698103d87a8000a60103d879800041a097ae08a99834a481333c65787065637465643e20457870656374206120636f727265637479207570646174656420636f6e74696e75696e6720434450001641a115330694912a3c65787065637465643e20546865726520697320736f6d65206163637275656420696e7465726573742e001641a064b3001337120026eb4c1b8c1acdd5014c56600266e20dd6982998359baa029031899b803370666e08cdc09bad306e306b375405200200a904040507b7a566df00d99b833370666e08cdc118101bad3053306b37540526eb4c1b8c1acdd5182c98359baa02900548202c227efa8052080897a8a99834a4810155001641a115980099b88002031899b833370666e08cdc118100011bad306e306b375460b260d66ea80a40152080b089fbea014820225ea2a660d292010156001641a08340dd698369837001454cc1a124012d3c65787065637465643e20497420697320746f6f20736f6f6e20746f20736574746c6520696e7465726573742e0016419d1533068491413c65787065637465643e20416c6c20434450732061726520666f72207468652073616d652069417373657420616e6420636f6c6c61746572616c2061737365742e0016419c6eb4c1b0004c1a0dd5002c5906518339baa005306a0098b20d01833000983280098320009831800982f1baa0018b20b630600018b20bc305c37540031641646eb4c174004c11cc108c168dd51824182d1baa0098b20b63059375400316415915980099baf305c3059375460b860b26ea8c11cc164dd500400f45660033001003a50a51415913305b3750004660b66e9c010cc16e600294698103d87a8000a60103d8798000415897ae08a9982ba4812845787065637420612073696e676c6520696e74657265737420636f6c6c6563746f7220696e7075740016415913305b3750004660b66e9c010cc16e60020074c103d87a8000a60103d8798000415897ae0415882b060b00088038c8cc0040040148966002003168994c004c15400660ac003305a00248896600266ebc00cc0f0cc16cc170c164dd500425eb822660b6004660b66e980052f5c113300600600141583058001415919800803400600900340188280c15000cc15400d05219b80375a609e60986ea80296600266e20dd6981a18261baa00a012899b833370666e08cdc118009bad3034304c37540146eb4c13cc130dd5181d18261baa00a482020283dbd2b36f806d2080b089fbea014820225ea2a66094921015a001641246e040462c8260dd6982680098249baa0018b208c304b0048b2092375a60920026eb4c12400cc124004c120004c10cdd5000c590401817981518211baa30303042375400315330404914c3c65787065637465643e205468652070726f7669646564207265662e20696e70757420696e64657820636f72726573706f6e647320746f2074686520696e746572657374206f7261636c652e001640fc660166eb0c0bcc104dd501b0049821800c59041181f9baa0018b2078302b3026303e37546058607c6ea80062a6607892014d3c65787065637465643e205468652070726f7669646564207265662e20696e70757420696e64657820636f72726573706f6e647320746f2074686520636f6c6c61746572616c2061737365742e001640ec8a9981ca49413c65787065637465643e205468652070726f766964656420696e70757420696e64657820636f72726573706f6e647320746f20746865206f776e20696e7075742e001640e0181b805a2646530012259800980f18159baa0028992cc004c0c400626600860600020051640b860586ea800a2c814a4605c605e605e605e605e605e605e605e605e0032232330010010032259800981018169baa0018991919800800802912cc00400629422b30013371e6eb8c0d000400e2946266004004606a00281710321bae3031302e3754003132337126eb4c0c8004c8cc004004dd61819981a001112cc0040062900044cc89660026600e00e0051300d0018800a060303400133002002303500140c8605c6ea800502b2444b3001301e013899912cc004c0cc006264646600e0022b3001330164901235265666572656e636564205554784f206d75737420686176652061646d696e204e465400330133756603e60626ea8c07cc0c4dd500100244cc0592412041646d696e206d756c7469736967206d7573742062652073617469736669656400330053034303137540026eb0c018c0c4dd50134528205c301d301830303754603c60606ea8004c0c80062c8180c06cc0b4dd5019998069bac301b302d37540446060605a6ea8c0c0c0b4dd5198061bac3030302d37540440391598009810009c6600244b30010018a40011300933002002303300140c1301b302d37540673019302d37540673300c37586060605a6ea80880712222323233223300b00113259800981d000c4c966002605a606c6ea8c04cc0dcdd5000c4cc88cc03c0044c9660026603e9211e5370656e74205554784f206d75737420686176652061646d696e204e4654003301c3756605060746ea80280322b30013301f490125466f756e646174696f6e206d756c7469736967206d75737420626520736174697366696564003300e303d303e303e303e303e303e303e303e303e303e303e303e303a3754605060746ea800cdd61807981d1baa02f8acc004cc07d2401234e65772061646d696e67206d756c74697369672063616e6e6f7420626520656d7074790030070018acc004cc07d241244e65772061646d696e206d756c7469736967206d75737420626520736174697366696564003300e0013758601e60746ea80be2b30013301f490121436f6e74696e75696e672076616c7565206d757374206265207468652073616d650098009bab3028303a37540093756605060746ea802a980103d87a8000404d13301f4901244f6c6420616e64206e657720646174756d73206d75737420626520646966666572656e7400980099baf006002a50a5140dd14a081ba29410374528206e8a5040dd14a081b8c0f0c0e4dd5000992cc004c0f0006264b3001302b303837540031323232323298009bad30410019bad30410059bad30410039bad30410024888966002608c00b13259800981a98211baa00189919191919191919191919194c004c1480066eb4c1480326eb4c14802e6eb4c14802a6eb4c1480266eb4c1480226eb4c14801e6eb4c14801a6eb4c1480166eb4c1480126eb4c1480092222222222259800982f00644cc0d4c1740384cc0c402c408a2c82d860a400260a200260a0002609e002609c002609a0026098002609600260940026092002609000260866ea80062c8200c1140222c821860820026080002607e002607c00260726ea80062c81b0c094c080c0e0dd51813181c1baa303b0018b207298009bac302530373754059008a60103d879800040606048603e606e6ea80062c81a0c0e40062c81b8cc07cdd6180e981a9baa02a301330183303730383035375400a97ae030010013020301b3033375400644b300130263033375400314a31323322598009810001456600266e24008c0180062646600200200444b30010018a518acc004cc01c01cc0f0006266004004607a00314a081b103a452820688a5040d06eb4c0e0004dd6181c181c800981a1baa00140c4600800889919912cc004c098c0bcdd5000c4cc8966002606c00313259800981298191baa00189919912cc004c0e800626603a6eb0c0e40048966002005132598009815981c1baa0018991925159800991980080098069bab3027303b375406044b30013371e6eb8c0fc00400e2946266004004608000281ca2934590371bae303c303937540031640d864660020026eb0c09cc0e4dd5003912cc004006298103d87a80008992cc006600266ebc00530103d87a8000a50a5140e11001899801801981f8012070325980099b8f375c607c002017130183303d303e303f0014bd7045300103d87a800040e06eb0c0f400503b44c8c8cc896600260800071300530400068b207a375c607a0026eb8c0f4008c0f4004dd6181d80120728b206e375a606e002607000260666ea80062c8180c07cc068c0c8dd5181018191baa30350018b2066375c606660606ea800660026eb0c078c0c0dd5012cc0ccc0c0dd501b530103d879800040451640b460020026062605c6ea8c0c4c0b8dd5198069bac3031302e375404603a44b30010018a5eb82266062605c6064002660040046066002818102a20541800800911192cc004c07800626464b3001303200280245902f1bae3030001302c37540071598009811000c4c8cc896600260660031330163758606400244b3001002803c66002013303400289800981a801201240c91640c06eb4c0c0004c0c4004c0b0dd5001c590292052302a37540048128888cc8a600264b3001301f302c37540031375a605a60606eacc0c0c0b4dd5000c5200040a8605e0033756005375e605e60600032259800981218169baa005899b890010028acc004cdc480080144cdc480119b80001482026fb80a294102b20564888966002007159800980100344cc00401120008a5040b51325980099baf4c0101400030300018acc004cc008014dd69818981a1bab3031001898019ba630350048a5040b915980099801002a4001130030078a5040b88170c0cc00d0310dd3001194c004006009223302f0023302f374c00297ae04004444b3001002899800a6103d87a80004bd6f7b63044c8cc896600266e452201000028acc004cdc7a441000028998021806998191818001a5eb80006266008980103d87a800000540b5198008034006446600c0046606800a002803102d1bae302d0013032003303000240b8407c22301698008014dd7181198101baa0019bae300e302037540028058602a602c00c602800a8b2012180580098031baa00b8a4d13656400c2a660049212f3c65787065637465643e2053696e676c652043445020696e70757420696e20746865207472616e73616374696f6e2e001615330024913f3c65787065637465643e2053696e676c6520696e74657265737420636f6c6c656374696f6e20696e70757420696e20746865207472616e73616374696f6e2e001601"
|
|
7519
|
+
};
|
|
7520
|
+
|
|
7521
|
+
// src/contracts/interest-collection/scripts.ts
|
|
7522
|
+
function mkInterestCollectionValidator(params) {
|
|
7523
|
+
return {
|
|
7524
|
+
type: "PlutusV3",
|
|
7525
|
+
script: applyParamsToScript9(_interestCollectionValidator.cborHex, [
|
|
7526
|
+
castInterestCollectionParams(params)
|
|
7527
|
+
])
|
|
7528
|
+
};
|
|
7529
|
+
}
|
|
7530
|
+
var mkInterestCollectionValidatorFromSP = (params) => {
|
|
7531
|
+
return {
|
|
7532
|
+
type: "PlutusV3",
|
|
7533
|
+
script: applyParamsToScript9(_interestCollectionValidator.cborHex, [
|
|
7534
|
+
castInterestCollectionParams({
|
|
7535
|
+
versionRecordNft: fromSystemParamsAssetLucid(params.versionRecordNft),
|
|
7536
|
+
multisigUtxoNft: fromSystemParamsAssetLucid(params.multisigUtxoNft),
|
|
7537
|
+
cdpAuthTk: fromSystemParamsAssetLucid(params.cdpAuthTk),
|
|
7538
|
+
collateralAssetAuthTk: fromSystemParamsAssetLucid(
|
|
7539
|
+
params.collateralAssetAuthTk
|
|
7540
|
+
),
|
|
7541
|
+
govAuthTk: fromSystemParamsAssetLucid(params.govAuthTk),
|
|
7542
|
+
cdpAssetSymbol: params.cdpAssetSymbol.unCurrencySymbol,
|
|
7543
|
+
cdpBiasTime: BigInt(params.cdpBiasTime),
|
|
7544
|
+
interestSettlementCooldown: BigInt(params.interestSettlementCooldown)
|
|
7545
|
+
})
|
|
7546
|
+
])
|
|
7547
|
+
};
|
|
7548
|
+
};
|
|
7549
|
+
|
|
7550
|
+
// src/contracts/interest-collection/queries.ts
|
|
7551
|
+
import { option as O14, function as F17 } from "fp-ts";
|
|
7683
7552
|
import {
|
|
7553
|
+
assetClassToUnit as assetClassToUnit3,
|
|
7684
7554
|
assetClassValueOf as assetClassValueOf6,
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
mkLovelacesOf as mkLovelacesOf5
|
|
7555
|
+
getRandomElement as getRandomElement2,
|
|
7556
|
+
matchSingle as matchSingle3
|
|
7688
7557
|
} from "@3rd-eye-labs/cardano-offchain-common";
|
|
7689
|
-
async function
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
]),
|
|
7696
|
-
(_2) => new Error("Expected a single staking Ref Script UTXO")
|
|
7697
|
-
);
|
|
7698
|
-
const stakingTokenPolicyRefScriptUtxo = matchSingle(
|
|
7699
|
-
await lucid.utxosByOutRef([
|
|
7700
|
-
fromSystemParamsScriptRef(
|
|
7701
|
-
params.scriptReferences.authTokenPolicies.stakingTokenRef
|
|
7702
|
-
)
|
|
7703
|
-
]),
|
|
7704
|
-
(_2) => new Error("Expected a single staking token policy Ref Script UTXO")
|
|
7558
|
+
async function findAllInterestCollectors(lucid, sysParams) {
|
|
7559
|
+
return lucid.utxosAt(
|
|
7560
|
+
createScriptAddress(
|
|
7561
|
+
lucid.config().network,
|
|
7562
|
+
sysParams.validatorHashes.interestCollectionHash
|
|
7563
|
+
)
|
|
7705
7564
|
);
|
|
7706
|
-
const newStakingManagerDatum = {
|
|
7707
|
-
totalStake: stakingManagerOut.datum.totalStake + amount,
|
|
7708
|
-
managerSnapshot: {
|
|
7709
|
-
snapshotAda: stakingManagerOut.datum.managerSnapshot.snapshotAda
|
|
7710
|
-
}
|
|
7711
|
-
};
|
|
7712
|
-
const stakingPositionDatum = {
|
|
7713
|
-
owner: fromHex10(pkh.hash),
|
|
7714
|
-
lockedAmount: [],
|
|
7715
|
-
positionSnapshot: {
|
|
7716
|
-
snapshotAda: stakingManagerOut.datum.managerSnapshot.snapshotAda
|
|
7717
|
-
}
|
|
7718
|
-
};
|
|
7719
|
-
const stakingToken = params.stakingParams.stakingToken[0].unCurrencySymbol + fromText6(params.stakingParams.stakingToken[1].unTokenName);
|
|
7720
|
-
const indyToken = params.stakingParams.indyToken[0].unCurrencySymbol + fromText6(params.stakingParams.indyToken[1].unTokenName);
|
|
7721
|
-
return lucid.newTx().collectFrom(
|
|
7722
|
-
[stakingManagerOut.utxo],
|
|
7723
|
-
serialiseStakingRedeemer({
|
|
7724
|
-
CreateStakingPosition: { creatorPkh: fromHex10(pkh.hash) }
|
|
7725
|
-
})
|
|
7726
|
-
).readFrom([stakingRefScriptUtxo]).pay.ToContract(
|
|
7727
|
-
stakingManagerOut.utxo.address,
|
|
7728
|
-
{
|
|
7729
|
-
kind: "inline",
|
|
7730
|
-
value: serialiseStakingDatum(newStakingManagerDatum)
|
|
7731
|
-
},
|
|
7732
|
-
stakingManagerOut.utxo.assets
|
|
7733
|
-
).readFrom([stakingTokenPolicyRefScriptUtxo]).mintAssets(
|
|
7734
|
-
{
|
|
7735
|
-
[stakingToken]: 1n
|
|
7736
|
-
},
|
|
7737
|
-
Data33.void()
|
|
7738
|
-
).pay.ToContract(
|
|
7739
|
-
stakingManagerOut.utxo.address,
|
|
7740
|
-
{
|
|
7741
|
-
kind: "inline",
|
|
7742
|
-
value: serialiseStakingDatum(stakingPositionDatum)
|
|
7743
|
-
},
|
|
7744
|
-
{
|
|
7745
|
-
[stakingToken]: 1n,
|
|
7746
|
-
[indyToken]: amount
|
|
7747
|
-
}
|
|
7748
|
-
).addSignerKey(pkh.hash);
|
|
7749
|
-
}
|
|
7750
|
-
async function adjustStakingPosition(stakingPositionRef, amount, params, lucid, currentSlot, stakingManagerRef) {
|
|
7751
|
-
const network = lucid.config().network;
|
|
7752
|
-
const now = BigInt(slotToUnixTime8(network, currentSlot));
|
|
7753
|
-
const stakingPositionOut = await findStakingPositionByOutRef(
|
|
7754
|
-
stakingPositionRef,
|
|
7755
|
-
lucid
|
|
7756
|
-
);
|
|
7757
|
-
const stakingManagerOut = stakingManagerRef ? await findStakingManagerByOutRef(stakingManagerRef, lucid) : await findStakingManager(params, lucid);
|
|
7758
|
-
const stakingRefScriptUtxo = matchSingle(
|
|
7759
|
-
await lucid.utxosByOutRef([
|
|
7760
|
-
fromSystemParamsScriptRef(params.scriptReferences.stakingValidatorRef)
|
|
7761
|
-
]),
|
|
7762
|
-
(_) => new Error("Expected a single staking Ref Script UTXO")
|
|
7763
|
-
);
|
|
7764
|
-
const indyToken = fromSystemParamsAsset(params.stakingParams.indyToken);
|
|
7765
|
-
const adaReward = calculateAdaReward(
|
|
7766
|
-
stakingManagerOut.datum.managerSnapshot.snapshotAda,
|
|
7767
|
-
stakingPositionOut.datum.positionSnapshot.snapshotAda,
|
|
7768
|
-
assetClassValueOf6(stakingPositionOut.utxo.assets, indyToken)
|
|
7769
|
-
);
|
|
7770
|
-
const newLockedAmount = updateStakingLockedAmount(
|
|
7771
|
-
stakingPositionOut.datum.lockedAmount,
|
|
7772
|
-
BigInt(now)
|
|
7773
|
-
);
|
|
7774
|
-
return lucid.newTx().validFrom(Number(now)).readFrom([stakingRefScriptUtxo]).collectFrom(
|
|
7775
|
-
[stakingPositionOut.utxo],
|
|
7776
|
-
serialiseStakingRedeemer({
|
|
7777
|
-
AdjustStakedAmount: { adjustAmount: amount }
|
|
7778
|
-
})
|
|
7779
|
-
).collectFrom(
|
|
7780
|
-
[stakingManagerOut.utxo],
|
|
7781
|
-
serialiseStakingRedeemer("UpdateTotalStake")
|
|
7782
|
-
).pay.ToContract(
|
|
7783
|
-
stakingManagerOut.utxo.address,
|
|
7784
|
-
{
|
|
7785
|
-
kind: "inline",
|
|
7786
|
-
value: serialiseStakingDatum({
|
|
7787
|
-
...stakingManagerOut.datum,
|
|
7788
|
-
totalStake: stakingManagerOut.datum.totalStake + amount
|
|
7789
|
-
})
|
|
7790
|
-
},
|
|
7791
|
-
addAssets10(stakingManagerOut.utxo.assets, mkLovelacesOf5(-adaReward))
|
|
7792
|
-
).pay.ToContract(
|
|
7793
|
-
stakingPositionOut.utxo.address,
|
|
7794
|
-
{
|
|
7795
|
-
kind: "inline",
|
|
7796
|
-
value: serialiseStakingDatum({
|
|
7797
|
-
...stakingPositionOut.datum,
|
|
7798
|
-
positionSnapshot: {
|
|
7799
|
-
snapshotAda: stakingManagerOut.datum.managerSnapshot.snapshotAda
|
|
7800
|
-
},
|
|
7801
|
-
lockedAmount: newLockedAmount
|
|
7802
|
-
})
|
|
7803
|
-
},
|
|
7804
|
-
addAssets10(stakingPositionOut.utxo.assets, mkAssetsOf8(indyToken, amount))
|
|
7805
|
-
).addSignerKey(toHex10(stakingPositionOut.datum.owner));
|
|
7806
7565
|
}
|
|
7807
|
-
async function
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
]),
|
|
7819
|
-
(_) => new Error("Expected a single staking Ref Script UTXO")
|
|
7820
|
-
);
|
|
7821
|
-
const stakingTokenPolicyRefScriptUtxo = matchSingle(
|
|
7822
|
-
await lucid.utxosByOutRef([
|
|
7823
|
-
fromSystemParamsScriptRef(
|
|
7824
|
-
params.scriptReferences.authTokenPolicies.stakingTokenRef
|
|
7566
|
+
async function findAdminInterestCollectors(lucid, sysParams) {
|
|
7567
|
+
return matchSingle3(
|
|
7568
|
+
await lucid.utxosAtWithUnit(
|
|
7569
|
+
createScriptAddress(
|
|
7570
|
+
lucid.config().network,
|
|
7571
|
+
sysParams.validatorHashes.interestCollectionHash
|
|
7572
|
+
),
|
|
7573
|
+
assetClassToUnit3(
|
|
7574
|
+
fromSystemParamsAsset(
|
|
7575
|
+
sysParams.interestCollectionParams.multisigUtxoNft
|
|
7576
|
+
)
|
|
7825
7577
|
)
|
|
7826
|
-
|
|
7827
|
-
(_) => new Error("Expected a single
|
|
7828
|
-
);
|
|
7829
|
-
const indyToken = fromSystemParamsAsset(params.stakingParams.indyToken);
|
|
7830
|
-
const existingIndyAmount = assetClassValueOf6(
|
|
7831
|
-
stakingPositionOut.utxo.assets,
|
|
7832
|
-
indyToken
|
|
7833
|
-
);
|
|
7834
|
-
const adaReward = calculateAdaReward(
|
|
7835
|
-
stakingManagerOut.datum.managerSnapshot.snapshotAda,
|
|
7836
|
-
stakingPositionOut.datum.positionSnapshot.snapshotAda,
|
|
7837
|
-
assetClassValueOf6(stakingPositionOut.utxo.assets, indyToken)
|
|
7578
|
+
),
|
|
7579
|
+
(_) => new Error("Expected a single admin interest collector UTXO")
|
|
7838
7580
|
);
|
|
7839
|
-
return lucid.newTx().validFrom(Number(now)).readFrom([stakingRefScriptUtxo, stakingTokenPolicyRefScriptUtxo]).collectFrom([stakingPositionOut.utxo], serialiseStakingRedeemer("Unstake")).collectFrom(
|
|
7840
|
-
[stakingManagerOut.utxo],
|
|
7841
|
-
serialiseStakingRedeemer("UpdateTotalStake")
|
|
7842
|
-
).pay.ToContract(
|
|
7843
|
-
stakingManagerOut.utxo.address,
|
|
7844
|
-
{
|
|
7845
|
-
kind: "inline",
|
|
7846
|
-
value: serialiseStakingDatum({
|
|
7847
|
-
...stakingManagerOut.datum,
|
|
7848
|
-
totalStake: stakingManagerOut.datum.totalStake - existingIndyAmount
|
|
7849
|
-
})
|
|
7850
|
-
},
|
|
7851
|
-
addAssets10(stakingManagerOut.utxo.assets, mkLovelacesOf5(-adaReward))
|
|
7852
|
-
).mintAssets(
|
|
7853
|
-
mkAssetsOf8(fromSystemParamsAsset(params.stakingParams.stakingToken), -1n),
|
|
7854
|
-
Data33.void()
|
|
7855
|
-
).addSignerKey(toHex10(stakingPositionOut.datum.owner));
|
|
7856
7581
|
}
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
throw new Error("No available collectors found");
|
|
7866
|
-
}
|
|
7867
|
-
const adaRewardCollected = collectorUtxos.reduce(
|
|
7868
|
-
(acc, utxo) => acc + utxo.assets["lovelace"] - MIN_UTXO_AMOUNT,
|
|
7869
|
-
0n
|
|
7870
|
-
);
|
|
7871
|
-
const newSnapshot = distributeReward(
|
|
7872
|
-
stakingManagerDatum.managerSnapshot.snapshotAda,
|
|
7873
|
-
adaRewardCollected,
|
|
7874
|
-
stakingManagerDatum.totalStake
|
|
7875
|
-
);
|
|
7876
|
-
const stakingRefScriptUtxo = matchSingle(
|
|
7877
|
-
await lucid.utxosByOutRef([
|
|
7878
|
-
fromSystemParamsScriptRef(params.scriptReferences.stakingValidatorRef)
|
|
7879
|
-
]),
|
|
7880
|
-
(_) => new Error("Expected a single staking Ref Script UTXO")
|
|
7881
|
-
);
|
|
7882
|
-
const collectorRefScriptUtxo = matchSingle(
|
|
7883
|
-
await lucid.utxosByOutRef([
|
|
7884
|
-
fromSystemParamsScriptRef(params.scriptReferences.collectorValidatorRef)
|
|
7885
|
-
]),
|
|
7886
|
-
(_) => new Error("Expected a single staking Ref Script UTXO")
|
|
7582
|
+
async function findRandomNonAdminInterestCollector(lucid, sysParams) {
|
|
7583
|
+
const allCollectors = (await findAllInterestCollectors(lucid, sysParams)).filter(
|
|
7584
|
+
(utxo) => !assetClassValueOf6(
|
|
7585
|
+
utxo.assets,
|
|
7586
|
+
fromSystemParamsAsset(
|
|
7587
|
+
sysParams.interestCollectionParams.multisigUtxoNft
|
|
7588
|
+
)
|
|
7589
|
+
)
|
|
7887
7590
|
);
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
{
|
|
7894
|
-
kind: "inline",
|
|
7895
|
-
value: serialiseStakingDatum({
|
|
7896
|
-
...stakingManagerDatum,
|
|
7897
|
-
managerSnapshot: { snapshotAda: newSnapshot }
|
|
7898
|
-
})
|
|
7899
|
-
},
|
|
7900
|
-
addAssets10(stakingManagerUtxo.assets, mkLovelacesOf5(adaRewardCollected))
|
|
7591
|
+
return F17.pipe(
|
|
7592
|
+
O14.fromNullable(getRandomElement2(allCollectors)),
|
|
7593
|
+
O14.match(() => {
|
|
7594
|
+
throw new Error("Expected some non-admin interest collector UTXOs.");
|
|
7595
|
+
}, F17.identity)
|
|
7901
7596
|
);
|
|
7902
|
-
for (const collectorUtxo of collectorUtxos) {
|
|
7903
|
-
tx.pay.ToContract(
|
|
7904
|
-
collectorUtxo.address,
|
|
7905
|
-
{ kind: "inline", value: Data33.void() },
|
|
7906
|
-
mkLovelacesOf5(MIN_UTXO_AMOUNT)
|
|
7907
|
-
);
|
|
7908
|
-
}
|
|
7909
|
-
return tx;
|
|
7910
7597
|
}
|
|
7911
7598
|
|
|
7912
|
-
// src/contracts/
|
|
7913
|
-
import { Data as
|
|
7914
|
-
var
|
|
7915
|
-
|
|
7916
|
-
stakingToken: AssetClassSchema2,
|
|
7917
|
-
indyToken: AssetClassSchema2,
|
|
7918
|
-
pollToken: AssetClassSchema2,
|
|
7919
|
-
versionRecordToken: AssetClassSchema2,
|
|
7920
|
-
collectorValHash: Data34.Bytes()
|
|
7599
|
+
// src/contracts/version-registry/types.ts
|
|
7600
|
+
import { Data as Data38 } from "@lucid-evolution/lucid";
|
|
7601
|
+
var VersionRecordTokenParamsSchema = Data38.Object({
|
|
7602
|
+
upgradeToken: AssetClassSchema2
|
|
7921
7603
|
});
|
|
7922
|
-
var
|
|
7923
|
-
function
|
|
7924
|
-
return
|
|
7604
|
+
var VersionRecordTokenParams = VersionRecordTokenParamsSchema;
|
|
7605
|
+
function castVersionRecordTokenParams(params) {
|
|
7606
|
+
return Data38.castTo(params, VersionRecordTokenParams);
|
|
7925
7607
|
}
|
|
7926
7608
|
|
|
7927
|
-
// src/contracts/
|
|
7928
|
-
import {
|
|
7929
|
-
fromHex as fromHex11,
|
|
7930
|
-
fromText as fromText7,
|
|
7931
|
-
slotToUnixTime as slotToUnixTime9,
|
|
7932
|
-
toUnit as toUnit2,
|
|
7933
|
-
validatorToAddress
|
|
7934
|
-
} from "@lucid-evolution/lucid";
|
|
7935
|
-
|
|
7936
|
-
// src/contracts/one-shot/transactions.ts
|
|
7609
|
+
// src/contracts/version-registry/scripts.ts
|
|
7937
7610
|
import {
|
|
7938
|
-
|
|
7939
|
-
Data as Data36,
|
|
7940
|
-
mintingPolicyToId,
|
|
7941
|
-
toUnit
|
|
7611
|
+
applyParamsToScript as applyParamsToScript10
|
|
7942
7612
|
} from "@lucid-evolution/lucid";
|
|
7943
7613
|
|
|
7944
|
-
// src/
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
referenceOutRef: Data35.Object({
|
|
7951
|
-
txHash: Data35.Bytes(),
|
|
7952
|
-
outputIdx: Data35.Integer()
|
|
7953
|
-
}),
|
|
7954
|
-
mintAmounts: Data35.Array(
|
|
7955
|
-
Data35.Object({
|
|
7956
|
-
/// Use hex encoded string
|
|
7957
|
-
tokenName: Data35.Bytes(),
|
|
7958
|
-
amount: Data35.Integer()
|
|
7959
|
-
})
|
|
7960
|
-
)
|
|
7961
|
-
});
|
|
7962
|
-
var OneShotParams = OneShotParamsSchema;
|
|
7963
|
-
function castOneShotParams(params) {
|
|
7964
|
-
return Data35.castTo(params, OneShotParams);
|
|
7965
|
-
}
|
|
7614
|
+
// src/validators/version-record-policy.ts
|
|
7615
|
+
var _versionRecordTokenPolicy = {
|
|
7616
|
+
type: "PlutusScriptV3",
|
|
7617
|
+
description: "Generated by Aiken",
|
|
7618
|
+
cborHex: "5901a159019e010100229800aba2aba1aba0aab9faab9eaab9dab9a488888896600264646644b30013370e900018031baa0018992cc004c032600246018601a003222323322330020020012259800800c00e26464b30013372200c00315980099b8f00600189bad3010002802a01c899802002180a001a01c375c601c00260220028078c8c8cc0040040188966002003003899192cc004cdc8804000c56600266e3c02000626eacc04400a00a807a266008008602a0068078dd718078009809000a02014bd6f7b6300a40013758601660106ea8c02c016601660106ea803922223232330010010042259800800c52f5c113322598009802980498089baa00289980980119802002000c4cc01001000500f18090009809800a0205980099b8748000c02cdd5260103d87980008919b8798009bab3005300d3754003375c6020601a6ea800a6eb8c014c034dd500120084800a2466e21200098009bab3005300d3754003375c6020601a6ea800a6eb8c014c034dd5001200840288a518b2012375c6014600e6ea80062c8028c020004c020c024004c020004c00cdd5004452689b2b200201"
|
|
7619
|
+
};
|
|
7966
7620
|
|
|
7967
|
-
// src/validators/
|
|
7968
|
-
var
|
|
7621
|
+
// src/validators/version-registry-validator.ts
|
|
7622
|
+
var _versionRegistryValidator = {
|
|
7969
7623
|
type: "PlutusScriptV3",
|
|
7970
7624
|
description: "Generated by Aiken",
|
|
7971
|
-
cborHex: "
|
|
7625
|
+
cborHex: "585e585c01010029800aba2aba1aab9eaab9dab9a4888896600264653001300600198031803800cc0180092225980099b8748008c01cdd500144c8cc892818050009805180580098041baa0028b200c180300098019baa0068a4d13656400401"
|
|
7972
7626
|
};
|
|
7973
7627
|
|
|
7974
|
-
// src/contracts/
|
|
7975
|
-
function
|
|
7628
|
+
// src/contracts/version-registry/scripts.ts
|
|
7629
|
+
function mkVersionRecordTokenPolicy(params) {
|
|
7976
7630
|
return {
|
|
7977
7631
|
type: "PlutusV3",
|
|
7978
|
-
script:
|
|
7979
|
-
|
|
7632
|
+
script: applyParamsToScript10(_versionRecordTokenPolicy.cborHex, [
|
|
7633
|
+
castVersionRecordTokenParams(params)
|
|
7980
7634
|
])
|
|
7981
7635
|
};
|
|
7982
7636
|
}
|
|
7637
|
+
var mkVersionRegistryValidator = () => {
|
|
7638
|
+
return {
|
|
7639
|
+
type: "PlutusV3",
|
|
7640
|
+
script: _versionRegistryValidator.cborHex
|
|
7641
|
+
};
|
|
7642
|
+
};
|
|
7983
7643
|
|
|
7984
|
-
// src/contracts/
|
|
7985
|
-
import {
|
|
7986
|
-
async function oneShotMintTx(lucid, params) {
|
|
7987
|
-
const oneShotPolicy = mkOneShotPolicy(params);
|
|
7988
|
-
const policyId = mintingPolicyToId(oneShotPolicy);
|
|
7989
|
-
const refUtxo = matchSingle(
|
|
7990
|
-
await lucid.utxosByOutRef([
|
|
7991
|
-
{
|
|
7992
|
-
txHash: params.referenceOutRef.txHash,
|
|
7993
|
-
outputIndex: Number(params.referenceOutRef.outputIdx)
|
|
7994
|
-
}
|
|
7995
|
-
]),
|
|
7996
|
-
(_) => {
|
|
7997
|
-
throw new Error("Cannot find the reference UTXO for one-shot.");
|
|
7998
|
-
}
|
|
7999
|
-
);
|
|
8000
|
-
return [
|
|
8001
|
-
lucid.newTx().collectFrom([refUtxo]).mintAssets(
|
|
8002
|
-
reduce(
|
|
8003
|
-
{},
|
|
8004
|
-
(acc, entry) => addAssets11(acc, {
|
|
8005
|
-
[toUnit(policyId, entry.tokenName)]: entry.amount
|
|
8006
|
-
})
|
|
8007
|
-
)(params.mintAmounts),
|
|
8008
|
-
Data36.void()
|
|
8009
|
-
).attach.MintingPolicy(oneShotPolicy),
|
|
8010
|
-
policyId
|
|
8011
|
-
];
|
|
8012
|
-
}
|
|
8013
|
-
async function runOneShotMintTx(lucid, params) {
|
|
8014
|
-
const [tx, policyId] = await oneShotMintTx(lucid, params);
|
|
8015
|
-
const txHash = await tx.complete().then((tx2) => tx2.sign.withWallet().complete()).then((tx2) => tx2.submit());
|
|
8016
|
-
await lucid.awaitTx(txHash);
|
|
8017
|
-
return policyId;
|
|
8018
|
-
}
|
|
8019
|
-
|
|
8020
|
-
// src/contracts/interest-oracle/scripts.ts
|
|
8021
|
-
import { applyParamsToScript as applyParamsToScript8 } from "@lucid-evolution/lucid";
|
|
8022
|
-
|
|
8023
|
-
// src/contracts/interest-oracle/types.ts
|
|
8024
|
-
import { Data as Data37 } from "@lucid-evolution/lucid";
|
|
8025
|
-
var InterestOracleParamsSchema = Data37.Object({
|
|
8026
|
-
/** Milliseconds */
|
|
8027
|
-
biasTime: Data37.Integer(),
|
|
8028
|
-
owner: Data37.Bytes()
|
|
8029
|
-
});
|
|
8030
|
-
var InterestOracleParams = InterestOracleParamsSchema;
|
|
8031
|
-
function castInterestOracleParams(params) {
|
|
8032
|
-
return Data37.castTo(params, InterestOracleParams);
|
|
8033
|
-
}
|
|
7644
|
+
// src/contracts/treasury/scripts.ts
|
|
7645
|
+
import { applyParamsToScript as applyParamsToScript11 } from "@lucid-evolution/lucid";
|
|
8034
7646
|
|
|
8035
|
-
// src/validators/
|
|
8036
|
-
var
|
|
7647
|
+
// src/validators/treasury-validator.ts
|
|
7648
|
+
var _treasuryValidator = {
|
|
8037
7649
|
type: "PlutusScriptV3",
|
|
8038
7650
|
description: "Generated by Aiken",
|
|
8039
|
-
cborHex: "5907e05907dd010100229800aba2aba1aba0aab9faab9eaab9dab9cab9a4888888896600264653001300900198049805000cdc3a400530090024888966002600460126ea800e2653001300e00198071807800cdc3a40009112cc004c004c034dd500444c8c8c966002602a00513259800980298089baa001899192cc004c06000a2b300130073013375401119800980b980a1baa008980a1baa00b9180c180c800c896600200310018a9980a0010800a02648888c966002660049201205458206973206e6f74207369676e6564206279206f7261636c65206f776e6572003232330010013758603c603e603e603e603e603e603e603e603e60366ea8048896600200314a115980099b8f375c603e00200714a31330020023020001406480e8dd71801980c9baa01f899912cc004cc011240115496e636f72726563742074782076616c6964697479003322980091192cc004c04c0062b30013013301f375400514c103d87a80008a6103d879800040751598009802000c5660026008603e6ea800a2980103d87a80008a6103d87b800040751332259800980d000c4c96600266e2000c0062980103d87980008acc004cdc4000801c530103d87b80008a6103d87a800040808100dd6981298111baa0048acc004c054006298103d87b80008a6103d8798000407c80f8dd6981198101baa003301f375400480e901d180f1baa002980118101810981098109810981098109810980e9baa014980118019980f98019980f98021980f9ba8337026eb4c01cc074dd500b9bad3020301d375404697ae03301f9800a51a60103d87a8000a60103d8798000406897ae03301f30033301f30043301f375066e00dd69803980e9baa017375a6040603a6ea808d2f5c06603f30014a34c103d87a8000a60103d8798000406897ae04bd702444b300132598009802800c528c566002603200314a314a080f101e180f9baa33003302330203754004604660406ea8006264b300130140018a518acc004c0640062946294101e203c301f375466006601460406ea8008c028c080dd5000c528203a118011980f192cc004c054c070dd5000c4c966002602c603a6ea8c020c078dd51810980f1baa00389802998101ba80014bd7044c014cc080dd419b80001480092f5c080d8dd69810180e9baa0018800a034301f301c3754603e60386ea8004cc078c966002602a60386ea8006264b30013016301d37546010603c6ea8c020c078dd5001c4c014cc080dd4000a5eb822600a660406ea0cdc0000a400297ae0406c6eb4c080c074dd5000c400501a180f980e1baa3006301c375400297ae0370e900244c9660026600a92012643757272656e742074696d652068617320746f206265203e3d206c6173745f736574746c656400337126eb4c004c070dd50041bad3006301c375402d15980099802a492b496e74657265737420726174652068617320746f20626520696e2072616e6765205b30252c20313030255d005980099b8948000dd6980f980e1baa301f301c375402d1337126eb4c07cc070dd5180f980e1baa0164820225ea294101944cc015240120496e746572657374206f7261636c65206f757470757420696e636f72726563740098009bac301f3020302000798019980f18011980f180f980e1baa301f301c37540086603c98103d87a80004bd7025eb8266e9520043301e30023301e375066e00dd6980f980e1baa008325980099b88375a6004603a6ea8024006266e0ccdc199b823370466e04004dd69801180e9baa009375a6040603a6ea8c01cc074dd5004a41010141ede959b7c03690405844fdf500a410112f5153301b4901015a001640686eb4c018c070dd500b1980f180f980e1baa0163301e3006301c375402c97ae04bd704dd59803180e1baa00448888c8c8cc004004018896600200314a1159800992cc004c0100062b30013375e601260486ea800401a2b300133229800992cc004c068c098dd5000c4dd6981398151bab302a302737540031480010241814800cdd58014dd798149815000c89660026040604e6ea930103d87a8000899b890010028acc004cdc480080144cdc480119b80001482026fb80a2941025204a4888966002007159800980100344cc00401120008a50409d1325980099baf4c1014000302a0018acc004cc008014dd6981598171bab302b001898019ba6302f0048a5040a115980099801002a4001130030078a5040a08140c0b400d02b0dd3002994c0040066eacc03cc094dd5001488cc0a4008cc0a4dd3000a5eb810011112cc00400a26600298103d87a80004bd6f7b63044c8cc896600266e452201000028acc004cdc7a441000028998021808198161815001a5eb80006266008980103d87a8000005409d198008034006446600c0046605c00a00280310271bae3027001302c003302a00240a113375e604e60506050605060486ea800530103d87a80008a50408514a0810a29410211813000c528c4cc008008c09c0050202048598009809980f9baa003891919baf302530223754604a60446ea8008004c090c084dd5002448c8cdd7981298111baa00200130243021375400880e914a080ca29410191180f98101810000c5282030374a90011ba548002294101619198008009bac301c0042259800800c5a264b30013375e603c60366ea80040422600a60366ea8006266006006603e00480c0c07400501b22c808a2c80a8dd6980b00098091baa0018b201e30140038b2024375a60260026026002601c6ea80222c805860146ea800e2c8038601200260086ea802629344d95900101"
|
|
7651
|
+
cborHex: "59225f59225c010100229800aba4aba2aba1aba0aab9faab9eaab9dab9cab9a488888888a60022a660049201293c65787065637465643e2045787065637473206f6e6c792073696e676c65206f776e206f757470757400168a998012493b3c65787065637465643e20416c6c20747265617375727920696e70757473206d75737420757365207468652072696768742072656465656d65722e00168a99801249303c65787065637465643e2048617320746f207265666572656e63652073696e676c65206578656375746520696e70757400168a99801249333c65787065637465643e20457870656374732073696e676c65206f757470757420746f207769746864726177616c206164647200168a998012492d3c65787065637465643e20457870656374732073696e676c6520696e7075742066726f6d20747265617375727900164888896600264653001300e00198071807800cdc3a4005300e00248889660026004601c6ea800e33001300f3754007370e90004dc3a4009370e90034dc3a401091111194c00488c9660026010003159800980c1baa00380145901945660026016003159800980c1baa0038014590194566002600e003159800980c1baa0038014590194566002600c003159800980c1baa0038014590194566002600a0031323232329800980f800cdd6980f801cdd6980f8012444b3001302300489980598110038acc004c03cc078dd5001c4c8c8cc8966002604e00700d8b2048375a60480026eb8c090008c090004c07cdd5001c5901c4590200c07c004c078004c074004c060dd5001c56600266e1d200a0018acc004c060dd5001c00a2c80ca2c80a9015202a405480a9015180b1baa002980c180c8034c0600192223300300d198009180e180e800c888c8cc88cc0080080048966002003003899192cc004cdc8803000c56600266e3c01800626eb4c08000a00a80ea266008008604800680e8dd7180f0009810800a03e3232330010010062259800800c00e26464b30013372201000315980099b8f00800189bab3021002802a03c8998020021812801a03c375c603e0026044002810052f5bded8c029000488c8cc00400400c896600200314bd7044cc8966002600a00513302000233004004001899802002000a036301f00130200014075371090004966002601060306ea80062603860326ea80062c80b246038603a603a00322323300100100322330030013002002980b9baa00d912cc004006200315330180021001405d2598009804980c1baa001891919baf301e301b3754603c60366ea8008004c074c068dd5001448c8cdd7980f180d9baa002001301d301a375400480b26e9520009180e180e980e980e800cdd7a6103d87a800091111919800800802912cc00400626604066ec0dd48029ba60044bd6f7b63044c8cc896600266e4402000a2b30013371e010005198008044dd59810801c01e46604866ec0dd48049ba60010028800a00c89981199bb037520106e9801c01101e44cc08c00ccc01401400501e1bae301e00130230023021001407d222232330010010052259800800c4cc080cdd81ba9005375000897adef6c6089919912cc004cdc8804001456600266e3c02000a330010089bad3021003803c8cc090cdd81ba9009375000200510014019133023337606ea4020dd4003802203c89981180199802802800a03c375c603c0026046004604200280fa244444b30013370e00866e052000003800c4c008cdc0002001a0349baf4c0101a0009111919800800802112cc004006200913298009bae301d0019bab301e00199801801981100120083020001407922232330010010042259800800c40122653001375c603a003375a603c0033300300330220024010604000280f244b3001300a30193754005132323322598009811001c0162c80f8dd6980f8009bad301f002301f001301a375400516405d2232598009805800c4c8c96600260420050048b203c375c603e00260366ea800e2b3001300e0018acc004c06cdd5001c00a2c80e22c80c1018180c9baa00291192cc004c02c00626464b3001302100280245901e1bae301f001301b37540071598009807000c4c8c96600260420050048b203c375c603e00260366ea800e2c80c1018180c9baa002911980e19bb037520046ea00052f5bded8c122232330010010042259800800c4012266006604000266004004604200280f26e9520024888888888888888888888888a600244646600200200644b30010018b44c96600266ebcc0e4c0d8dd500080244c078c0d8dd5000c4cc00c00cc0e8009033181c000a06c911191980d80211801180f181b1baa00159800981218199baa0018918144c004dd5980e981a9baa0019bae303830353754007375c603a606a6ea800d01c448c06a60026eacc074c0d4dd5000cdd7181c181a9baa0039bae301d3035375400680e10314888cc8a600264b30013027303637540031375a606e60746eacc0e8c0dcdd5000c5200040d060720033756005375e6072607400322598009815981b9baa005899b890010028acc004cdc480080144cdc480119b80001482026fb80a2941035206a4888966002007159800980100344cc00401120008a5040dd1325980099baf4c01014000303a0018acc004cc008014dd6981d981f1bab303b001898019ba6303f0048a5040e115980099801002a4001130030078a5040e081c0c0f400d03b0dd3001194c004006009223303900233039374c00297ae04004444b3001002899800a6103d87a80004bd6f7b63044c8cc896600266e452201000028acc004cdc7a44100002899802180c1981e181d001a5eb80006266008980103d87a800000540dd198008034006446600c0046607c00a00280310371bae3037001303c003303a00240e1223301900223375e606e60686ea8c0dcc0d0dd5180e181a1baa00100291194c0040060070024004444b30010028800c4ca6002009303b003cc00400a6eb8c0d80066eacc0dc0064444464b30013015374c00300289801800a07432329800800c01a00a80088896600200510018994c004012608a00798008014dd71820000cdd69820800c01501b200830430024104a02a8091004181c801206e911980c8011809000ca60020034bd70488a60020050019111981d1ba73303a375200c660746ea400ccc0e8dd400125eb8000500b201291192cc004c090006264b30013039001899805181c000801c59036181a1baa0038acc004c09c006264b30013039001899810981c000801c59036181a1baa0038acc004c08c00626464b3001303a0028024590371bae3038001303437540071640c4818903118191baa002911192cc004c09400626464b3001303b0028024590381bae3039001303537540071598009814000c4c8cc8966002607800313301a3758607600244b3001002803c66002013303d00289800981f001201240ed1640e46eb4c0e4004c0e8004c0d4dd5001c590322064303337540052232598009812000c4c9660026072003132598009813181a9baa00189919192cc004c0f400a26644b3001302b303a3754005132323259800982100144cc044c10400c4c966002605e003132598009822000c4c8c9660026064003132598009823800c4cc058c1180040262c8220c108dd50014566002606a003132323298009bad30480019bad30480039bad3048002488966002609800900e8b20921824000982380098211baa0028b207e40fc60806ea8004c10c0062c8208c0fcdd500145660026064003159800981f9baa002802c5904045903c2078303d37540031640fc6080002608000260766ea800a2c81c0c0f000c4cc06c00489660020050098992cc004c0b0c0ecdd5000c4c8c8ca60026eb4c1080066eb8c10800e6eb8c10800922259800982300244c020c1180262c82186084002608200260786ea80062c81c8c0f800903c45903a1bac303b001303b001303637540031640cc60700031640d860686ea800e2b300130270018acc004c0d0dd5001c00a2c81aa2c818903118191baa00291112cc004c094006200919800802400e6600e00400322222325980098099ba600180144c00c0050384c00401200f006a809a0284040819122222222222980091111191919800800803912cc00400629422b300132598009802000c56600266ebcc0a0c114dd5000803c56600330013756605a608a6ea800600d00540491302130223045375400314a0821229410424528208430470018a518998010011824000a08241146040009222225980099810002002c56600266ebcc090c104dd5002801c56600330013756605260826ea801600500140391301d301e3041375400b14a081f2294103e4528207c9801801ca60020034bd6f7b630488c8ca6002007375c6088005375c6088003375a6088608a0028030c110004c0fcdd5001201c48888c9660026062045132323259800800c0f22b300130480018992cc004c12400626464b3001303730463754003132323232323298009828000cdd698280024dd69828001cdd6982800124444b3001305500589919809182a80509980c0028acc004c108c144dd5002c4c8cc896600200304e8992cc004c16800a2b300133036491205769746864726177616c2076616c75652063616e6e6f7420626520656d70747900980098171ba6003a50a51414d1598009981b2481245472656173757279207769746864726177616c206f757470757420696e636f7272656374009800800cc098cc160c164c158dd500225eb8266e95200433058374e660b098011a5818496e6469676f54726561737572795769746864726177616c003305830593056375402297ae04bd70400e980103d87a800040651325980098179ba60018a518acc004c8cc004004c084008896600200314a115980099b88375a60b860ba60ba6eb0c17000520008a51899801001182e800a0ac416915330554901224e6f7420656e6f7567682066756e647320696e20747265617375727920696e707574001689981ba4811c5472656173757279206f757470757420697320696e636f72726563740098009bac303a3057375409330273305930353305901533059303a305737540bc97ae04bd70530107d87b9fd87980ff00800d300103d87a8000406c82a1054198109bab303e3056375402a646600200200844b30010018a5eb7bdb182264660b666ec0c160004dd319198008009bab305a0022259800800c52f5bded8c11323305e3376060b60026ea0cdc0a40006eb4c170004cc00c00cc180008c17800505c19801801982e801182d800a0b28a50414d14a0829a09e82b8c160005056180a1bac303b305337540026603a6eb0c0d8c14cdd502298119982a982b18299baa0014bd70182a98291baa0058b209e375a60a80151641483050001304f001304e001304d001304c0013047375400316411060546052608c6ea8c0b8c118dd50009824000c590464c004dd6182398221baa036982398221baa04ba60103d8798000404903c41148228cc03cdd6182318219baa035001304530423754608a60846ea8004cc040dd6182218209baa03302a8cc004dc0240052304530463046304630463046304630463046304600194c00400691100a4410040a5371090012444464b3001303902789919912cc00400608713259800982700144c966002607660946ea80062646464646465300130540019bad30540049bad30540039bad3054002488896600260b200b13233016305900a13301c005132598009823982b1baa006899192cc004ca6002003375860ba60b46ea81326eacc060c168dd5026528a002222259800801c400626644b30013052305e375460c460be6ea8c188c17cdd51823982f9baa0028994c00401e005375660c660c8003325980099baf30643061375460c860c26ea8c124c184dd500200dc566002003159800982a18301baa0018acc004c184dd5000c40160b883120b882f20b905c82e41710664401505e1831800a00e32330010010052259800800c5a265300130610019831000cc1980092225980099baf00330353306730683065375401097ae0899833801198339ba60014bd7044cc0180180050620c19000506246600200d001802400d00620b83060003306100341791598009981ca493d43616e6e6f742062652075736564207768656e207769746864726177616c2076616c7565206861732073696e676c65206173736574206f72206e6f6e650030150018acc004cc0e52412e43616e6e6f742062652075736564207769746820617373657473206e6f7420746f2062652077697468647261776e003370e6028006b3001303e30160028800c4c0600050564566002660729201374f6e65206f75747075742068617320746f2068617665207468652076616c7565206f662074726561737572795f7769746864726177616c0098009bac303c3059375409730293305b0124bd70530107d87b9fd87980ff008015300103d87a80004075133039490123416c6c207370656e742076616c75652068617320746f2062652070616964206261636b009800cc004dd6181e182c9baa04ba5eb7bdb18244b30013375e60bc60b66ea8c178c16cdd500100ac56600266ebcc0f8c16cdd500126107d87b9fd87980ff008998130009bab3043305b375400515330594912f3c65787065637465643e20416c6c206f776e206f757470757473206d757374206861766520766f696420646174756d001641611001416081520074c103d87a8000409914a082b22941056452820ac8a504158602600260306eb0c0fcc15cdd5182d182b9baa0068b20a898009bac3059305637540914bd6f7b6304896600266ebcc16cc160dd5182d982c1baa3040305837540040251330230013756608060b06ea8c100c160dd500144005055204e375a60b001516415830540013053001305200130510013050001304b3754003164120605c605a60946ea8c0c8c128dd5000c11104b1826000a09430253304900133049302a3047375409c97ae098009bac302f30473754073304a3047375409d4c0103d879800040546092608c6ea8c124c118dd51980a9bac30493046375407005f1323259800981b814c4c8ca600260506609800266098605a60946ea81452f5c1232330010010022259800800c52f5bded8c113233225980099b91489000028acc004cdc7a441000028800c401104d44cc14800ccc01401400504d1bae304d0013052002305000141393756606460946ea80092225980098289980c9bac3050304d375407e009132325980099817a495d416c6c20696e70757473206d7573742068617665206d6f7265207468616e2031206e6f6e2d414441206173736574206f722031206e6f6e2d41444120617373657420616e64206d6f7265207468616e20327820414441206275666665720032598009806000c528c566002608600313371090405b6e0298068024528209a41346014600800715980099817a492f416c6c207468652076616c7565206e6565647320746f2062652073656e74206261636b20746f207472656173757279009800800c00e98103d87a8000407113302f49012354686572652063616e2062652031206f75747075742077697468206f6e6c7920414441003371266e04c020008dd698294c004c010006660a2981010000330513032304f375408297ae09114c00400a0032223259800cc004c164006604c660b001897ae0a60107d87b9fd87980ff00acc004c11800e297adef6c6089982c19bb0375200e6e98cc0a001000d2f5bded8c0829a98103d879800040651330583750602a6eb4c164008cc160dd3982d000a5eb822a660a8921593c65787065637465643e2045616368206e6f6e204144412061737365742069732073657061726174656420696e746f20697473206f776e20636f6e74696e75696e67206f7574707574207769746820766f696420646174756d0016414c6eb0c160c164005028204c4800a294104c452820989800800d2f5bded8c1223301b0013756607060a06ea800901f1980b9bac3030304d375407e603a6609e00697ae08b209c182618249baa304c304937540026602e6eb0c12cc120dd501d018c566002606c05313233229800cc00400697adef6c60911980c0009bab3035304d3754606a609a6ea800901c4cc054dd6181718259baa03d301b3304d0024bd70488c8cc00400400c896600200314a315980098019829000c4cc008008c14c006294104c20a048896600200504a8992cc004c14c00e2b30013302f4912d416c6c206f776e20696e70757473206861766520746f20757365207468652072696768742072656465656d657200330020052323303c00113375e002980103d87c80003232330010013756602060a46ea811088c96600266ebc010c14c006260a80031330030033058002414460ac0026040660a460a660a06ea80052f5c115980099817a4812554686572652068617320746f206265206174206c656173742032206f776e20696e7075747300300b30080058acc004cc0bd2411c5472656173757279206f757470757420697320696e636f7272656374009800800cc07ccc1440192f5c14c107d87b9fd87980ff008025300103d87a8000404913302f490132416c6c20696e70757473206861766520746f20636f6e7461696e207468652073616d65206d657267696e6720617373657473003233003006232330010010032259800800c528c56600264607330013756607860a86ea8c0f0c150dd50024dd7182b800cdd7182b982c000a076375860ac00313300200230570018a50414082a0c060012294104c452820988a50413104b414060a20048278604e6609600266096605860926ea81412f5c06602a6eb0c130c124dd501d800982598241baa304b304837546602e6eb0c12cc120dd501d018c566002606a053132323298009bad304e00198271827800ccc068dd6182718259baa03d0349827001cdd698270012444446644b30013303249116546f6f206d616e7920617373657420636c61737365730033712601a004900245660026606492011c436f6c6c656374656420616d6f756e7420697320706f7369746976650059800981b801c4cdc4a400000f14a0827a26606492011c5472656173757279206f757470757420697320696e636f72726563740098009bac30353052375408930223305430303305430553052375460aa60a46ea8014cc150c0d4c148dd502ca5eb812f5c13374a90021982a18181982a18181982a01da5eb80cc1500192f5c097ae0801530103d87a8000405914a0827a294104f4c00660026eacc0e0c140dd5001cdd7182998281baa0029bae303830503754005001405548900a44100802a02a3233001001375860a860a26ea810c896600266ebcc154c148dd5182a8008034526899801001182b000a09e1827000982680098241baa03d89919912cc004c0f8c128dd5000c4cc896600260a200313259800981f18269baa00189919912cc004c1540062660666eb0c150004896600200513259800982218299baa0018991925159800991980080098069bab3059305a305a305a305a3056375409044b30013371e6eb8c16800400e294626600400460b600282a22934590521bae30573054375400316414464660020026eb0c0f0c150dd5003912cc0040062980103d87a80008992cc006600260640034a14a2829a2003133003003305a002414c64b30013371e6eb8c16400402e26068660b060b260b400297ae08a6103d87a8000414c6eb0c16000505644c8c8cc896600260b600713005305b0068b20b0375c60b00026eb8c160008c160004dd6182b00120a88b20a4375a60a400260a6002609c6ea80062c8258c0c4c0c0c134dd5181a98269baa30500018b209c375c609c60966ea800660026eb0c0ccc12cdd501ecc0ccc12cdd5029530103d879800040651641206002002609860926ea8c130c124dd51980c1bac304c3049375407606444b30010018a5eb822660986092609a00266004004609c0028259045208a4114600200244b30010018a40011300733002002304c001412482188c8cc0040040088966002003148002266453001375c6092005375660940052259800800c400e2646644601c6600a00a60a60086eb8c130004dd698268009827800a09a4888cc0040040086096002660040046098002824881f088c9660026066003132598009824000c4c966002606a60886ea800626464646464653001304e0019bae304e00698270024c13800e609c004911112cc004c15001a26604a60a601426604a00626604a00426604a00226604a00a01f164144304e001304d001304c001304b001304a00130453754003164108608e00316411460866ea800e2b300130360018992cc004c120006264b3001303530443754003132323232323298009827000cdd718270034c138012609c007304e0024888896600260a800d133025305300a13302500313302500213302500113302500500f8b20a21827000982680098260009825800982500098229baa0018b208430470018b208a304337540071598009819000c4c966002609000313259800981a98221baa00189919191919191919194c004dd69828800cdd71828804cdd69828803cc14401a60a200b30510049828801cc1440092222222259800982d004c4cc108c1640404cc0780144cc1080104cc0ac00c4cc0ac0084cc0ac0040562c82b860a200260a0002609e002609c002609a002609800260960026094002608a6ea80062c8210c11c0062c8228c10cdd5001c5660026062003132598009824000c4c966002606a60886ea800626464646464646464653001375a60a2003375c60a2013375a60a200f30510069828802cc14401260a200730510024888888896600260b4013133042305901013301e00513304200413302b00313302b00213302b0010158b20ae1828800982800098278009827000982680098260009825800982500098229baa0018b208430470018b208a304337540071598009818000c4c966002609000313259800981a98221baa00189919191919191919194c004dd71828800cdd71828804cc14401e60a200d305100598288024dd69828801cdd69828801244444444b3001305a009899821182c80809981580309981580289981580209981500180ac590570c144004c140004c13c004c138004c134004c130004c12c004c128004c114dd5000c590421823800c5904518219baa0038acc004cdc3a4014003132598009824000c4c966002606a60886ea8006264646464646464646464653001375c60a6003375c60a6017305300998298044c14c01e64b300130510018acc004cdc4a400860a000316898221828000a09c8b20a4375460a600d32598009828800c56600266e25200430500018b44c110c14000504e4590521baa305300598298024dd69829801cdd6982980124444444444b3001305e00b899823182e80a09981780409981780389981780309981700180cc5905b0c14c004c148004c144004c140004c13c004c138004c134004c130004c12c004c128004c114dd5000c590421823800c5904518219baa0038acc004cdc3a4018003132598009824000c4c966002606a60886ea80062646464646464646464646465300130540019bad305400c9bad305400b9bad305400a9bad30540099bad30540089bad30540079bad30540069bad30540059bad30540049bad30540024888888888896600260c0019133030305f00e13301e00b01b8b20ba182a000982980098290009828800982800098278009827000982680098260009825800982500098229baa0018b208430470018b208a3043375400715980099b8748038006264b300130480018992cc004c0d4c110dd5000c4c8cc8966002609800313302a3758609600244b3001002804c4c8cc896600260a200313259800981f18269baa001899192cc004c15000a2600e60a80111641446eb8c148004c138dd5000c5904b1828000c5904e1bae304e001304f0013758609a004825a2c8248dd69824800982500098229baa0018b208430470018b208a3043375400715980099b874804000626464b300130490028024590461bae30470013043375400716410082010402080410082010402080410060826ea800808966002600c602a6ea800a264646644b3001301e003802c5901b1bae301b001375c60360046036002602c6ea800a2c8099164030300e0013009375401f149a26cac80301"
|
|
8040
7652
|
};
|
|
8041
7653
|
|
|
8042
|
-
// src/contracts/
|
|
8043
|
-
|
|
7654
|
+
// src/contracts/treasury/types.ts
|
|
7655
|
+
import { Data as Data39 } from "@lucid-evolution/lucid";
|
|
7656
|
+
var TreasuryParamsSchema = Data39.Object({
|
|
7657
|
+
upgradeToken: AssetClassSchema2,
|
|
7658
|
+
versionRecordToken: AssetClassSchema2,
|
|
7659
|
+
treasuryUtxosStakeCredential: Data39.Nullable(StakeCredentialSchema)
|
|
7660
|
+
});
|
|
7661
|
+
var TreasuryParams = TreasuryParamsSchema;
|
|
7662
|
+
function castTreasuryParams(params) {
|
|
7663
|
+
return Data39.castTo(params, TreasuryParams);
|
|
7664
|
+
}
|
|
7665
|
+
|
|
7666
|
+
// src/contracts/treasury/scripts.ts
|
|
7667
|
+
var mkTreasuryValidatorFromSP = (params) => {
|
|
8044
7668
|
return {
|
|
8045
7669
|
type: "PlutusV3",
|
|
8046
|
-
script:
|
|
8047
|
-
|
|
7670
|
+
script: applyParamsToScript11(_treasuryValidator.cborHex, [
|
|
7671
|
+
castTreasuryParams({
|
|
7672
|
+
upgradeToken: fromSystemParamsAssetLucid(params.upgradeToken),
|
|
7673
|
+
versionRecordToken: fromSystemParamsAssetLucid(
|
|
7674
|
+
params.versionRecordToken
|
|
7675
|
+
),
|
|
7676
|
+
treasuryUtxosStakeCredential: params.treasuryUtxosStakeCredential ? fromSysParamsStakeCredential(params.treasuryUtxosStakeCredential) : null
|
|
7677
|
+
})
|
|
8048
7678
|
])
|
|
8049
7679
|
};
|
|
8050
|
-
}
|
|
7680
|
+
};
|
|
8051
7681
|
|
|
8052
|
-
//
|
|
7682
|
+
// src/contracts/treasury/queries.ts
|
|
7683
|
+
import { option as O15, function as F18 } from "fp-ts";
|
|
8053
7684
|
import {
|
|
8054
|
-
assetClassToUnit as
|
|
7685
|
+
assetClassToUnit as assetClassToUnit4,
|
|
7686
|
+
assetClassValueOf as assetClassValueOf7,
|
|
7687
|
+
getRandomElement as getRandomElement3
|
|
8055
7688
|
} from "@3rd-eye-labs/cardano-offchain-common";
|
|
8056
|
-
async function
|
|
8057
|
-
return lucid.
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
// src/contracts/interest-oracle/transactions.ts
|
|
8061
|
-
async function startInterestOracle(initialUnitaryInterest, initialInterestRate, initialLastInterestUpdate, oracleParams, lucid, interestTokenName, withScriptRef = false, refOutRef) {
|
|
8062
|
-
const network = lucid.config().network;
|
|
8063
|
-
const tokenName = interestTokenName ?? "INTEREST_ORACLE";
|
|
8064
|
-
if (!refOutRef) {
|
|
8065
|
-
refOutRef = (await lucid.wallet().getUtxos())[0];
|
|
8066
|
-
}
|
|
8067
|
-
const [tx, policyId] = await oneShotMintTx(lucid, {
|
|
8068
|
-
referenceOutRef: {
|
|
8069
|
-
txHash: refOutRef.txHash,
|
|
8070
|
-
outputIdx: BigInt(refOutRef.outputIndex)
|
|
8071
|
-
},
|
|
8072
|
-
mintAmounts: [
|
|
8073
|
-
{
|
|
8074
|
-
tokenName: fromText7(tokenName),
|
|
8075
|
-
amount: 1n
|
|
8076
|
-
}
|
|
8077
|
-
]
|
|
7689
|
+
async function findAllTreasuryUtxos(lucid, sysParams) {
|
|
7690
|
+
return lucid.utxosAt({
|
|
7691
|
+
type: "Script",
|
|
7692
|
+
hash: sysParams.validatorHashes.treasuryHash
|
|
8078
7693
|
});
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
getOnChainInt: initialInterestRate
|
|
8088
|
-
},
|
|
8089
|
-
lastUpdated: initialLastInterestUpdate
|
|
8090
|
-
})
|
|
8091
|
-
},
|
|
8092
|
-
{
|
|
8093
|
-
lovelace: 2500000n,
|
|
8094
|
-
[toUnit2(policyId, fromText7(tokenName))]: 1n
|
|
8095
|
-
}
|
|
7694
|
+
}
|
|
7695
|
+
async function findRandomTreasuryUtxo(lucid, sysParams) {
|
|
7696
|
+
const treasuryUtxos = await findAllTreasuryUtxos(lucid, sysParams);
|
|
7697
|
+
return F18.pipe(
|
|
7698
|
+
O15.fromNullable(getRandomElement3(treasuryUtxos)),
|
|
7699
|
+
O15.match(() => {
|
|
7700
|
+
throw new Error("Expected some treasury UTXOs.");
|
|
7701
|
+
}, F18.identity)
|
|
8096
7702
|
);
|
|
8097
|
-
if (withScriptRef) {
|
|
8098
|
-
tx.pay.ToAddressWithData(
|
|
8099
|
-
validatorToAddress(network, validator),
|
|
8100
|
-
void 0,
|
|
8101
|
-
void 0,
|
|
8102
|
-
validator
|
|
8103
|
-
);
|
|
8104
|
-
}
|
|
8105
|
-
return [
|
|
8106
|
-
tx,
|
|
8107
|
-
{
|
|
8108
|
-
currencySymbol: fromHex11(policyId),
|
|
8109
|
-
tokenName: fromHex11(fromText7(tokenName))
|
|
8110
|
-
}
|
|
8111
|
-
];
|
|
8112
7703
|
}
|
|
8113
|
-
async function
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
utxo = await findInterestOracle(lucid, assetClass);
|
|
8118
|
-
}
|
|
8119
|
-
const network = lucid.config().network;
|
|
8120
|
-
const now = BigInt(slotToUnixTime9(network, currentSlot));
|
|
8121
|
-
const tx = lucid.newTx();
|
|
8122
|
-
const datum = parseInterestOracleDatum(getInlineDatumOrThrow(utxo));
|
|
8123
|
-
if (scriptRef2) {
|
|
8124
|
-
tx.readFrom([scriptRef2]);
|
|
8125
|
-
} else {
|
|
8126
|
-
tx.attach.Script(mkInterestOracleValidator(params));
|
|
8127
|
-
}
|
|
8128
|
-
tx.collectFrom(
|
|
8129
|
-
[utxo],
|
|
8130
|
-
serialiseFeedInterestOracleRedeemer({
|
|
8131
|
-
newInterestRate: {
|
|
8132
|
-
getOnChainInt: newInterestRate
|
|
8133
|
-
},
|
|
8134
|
-
currentTime: now
|
|
8135
|
-
})
|
|
7704
|
+
async function findRandomTreasuryUtxoWithOnlyAda(lucid, sysParams) {
|
|
7705
|
+
const treasuryUtxos = await findAllTreasuryUtxos(lucid, sysParams);
|
|
7706
|
+
const adaOnlyTreasuryUtxos = treasuryUtxos.filter(
|
|
7707
|
+
(utxo) => Object.keys(utxo.assets).length == 1
|
|
8136
7708
|
);
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
{
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
unitaryInterest: datum.unitaryInterest + calculateUnitaryInterestSinceOracleLastUpdated(now, datum),
|
|
8143
|
-
interestRate: {
|
|
8144
|
-
getOnChainInt: newInterestRate
|
|
8145
|
-
},
|
|
8146
|
-
lastUpdated: now
|
|
8147
|
-
})
|
|
8148
|
-
},
|
|
8149
|
-
utxo.assets
|
|
7709
|
+
return F18.pipe(
|
|
7710
|
+
O15.fromNullable(getRandomElement3(adaOnlyTreasuryUtxos)),
|
|
7711
|
+
O15.match(() => {
|
|
7712
|
+
throw new Error("Expected some treasury UTXOs.");
|
|
7713
|
+
}, F18.identity)
|
|
8150
7714
|
);
|
|
8151
|
-
tx.validFrom(Number(now) - ONE_SECOND);
|
|
8152
|
-
tx.validTo(Number(now + params.biasTime) - ONE_SECOND);
|
|
8153
|
-
tx.addSignerKey(params.owner);
|
|
8154
|
-
return tx;
|
|
8155
7715
|
}
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
}
|
|
7716
|
+
async function findRandomTreasuryUtxoWithAsset(lucid, sysParams, asset, max_number_of_assets = 2n) {
|
|
7717
|
+
const treasuryUtxos = await lucid.utxosAtWithUnit(
|
|
7718
|
+
{ hash: sysParams.validatorHashes.treasuryHash, type: "Script" },
|
|
7719
|
+
assetClassToUnit4(asset)
|
|
7720
|
+
);
|
|
7721
|
+
const validTreasuryUtxos = treasuryUtxos.filter(
|
|
7722
|
+
(utxo) => Object.keys(utxo.assets).length <= max_number_of_assets
|
|
7723
|
+
);
|
|
7724
|
+
return F18.pipe(
|
|
7725
|
+
O15.fromNullable(getRandomElement3(validTreasuryUtxos)),
|
|
7726
|
+
O15.match(() => {
|
|
7727
|
+
throw new Error("Expected some treasury UTXOs.");
|
|
7728
|
+
}, F18.identity)
|
|
7729
|
+
);
|
|
8171
7730
|
}
|
|
8172
|
-
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
cdpAssetSymbol: Data38.Bytes(),
|
|
8182
|
-
cdpBiasTime: Data38.Integer(),
|
|
8183
|
-
interestSettlementCooldown: Data38.Integer()
|
|
8184
|
-
});
|
|
8185
|
-
var InterestCollectionParams = InterestCollectionParamsSchema;
|
|
8186
|
-
function castInterestCollectionParams(params) {
|
|
8187
|
-
return Data38.castTo(params, InterestCollectionParams);
|
|
7731
|
+
async function findAllTreasuryUtxosWithNonAdaAsset(lucid, sysParams, includeDaoToken = true) {
|
|
7732
|
+
const treasuryUtxos = await findAllTreasuryUtxos(lucid, sysParams);
|
|
7733
|
+
const treasuryUtxosWithNonAdaAsset = treasuryUtxos.filter(
|
|
7734
|
+
(utxo) => Object.keys(utxo.assets).length !== 1 && (includeDaoToken ? true : assetClassValueOf7(
|
|
7735
|
+
utxo.assets,
|
|
7736
|
+
fromSystemParamsAsset(sysParams.govParams.daoIdentityToken)
|
|
7737
|
+
) === 0n)
|
|
7738
|
+
);
|
|
7739
|
+
return treasuryUtxosWithNonAdaAsset;
|
|
8188
7740
|
}
|
|
8189
7741
|
|
|
8190
|
-
// src/contracts/
|
|
8191
|
-
import {
|
|
7742
|
+
// src/contracts/collector/scripts.ts
|
|
7743
|
+
import {
|
|
7744
|
+
applyParamsToScript as applyParamsToScript12,
|
|
7745
|
+
Constr as Constr2,
|
|
7746
|
+
fromText as fromText7
|
|
7747
|
+
} from "@lucid-evolution/lucid";
|
|
8192
7748
|
|
|
8193
|
-
// src/validators/
|
|
8194
|
-
var
|
|
7749
|
+
// src/validators/collector-validator.ts
|
|
7750
|
+
var _collectorValidator = {
|
|
8195
7751
|
type: "PlutusScriptV3",
|
|
8196
7752
|
description: "Generated by Aiken",
|
|
8197
|
-
cborHex: "59202059201d010100229800aba2aba1aba0aab9faab9eaab9dab9cab9a488888888cc896600264653001300b00198059806000cdc3a4005300b0024888966002600460166ea800e33001300c3754007370e90034dc3a4001370e90024c02cdd5002244444646644b300130060048acc004c050dd5006400a2c80aa2b3001300a0048991919194c004dd6980d800cdd6980d8024dd6980d801cdd6980d80124444b3001302000580545901d0c06c004c068004c064004c050dd50064566002600a009159800980a1baa00c8014590154566002600e009159800980a1baa00c801459015456600266e1d20080048acc004c050dd5006400a2c80aa2c8089011202240448088660024602c602e003259800980218091baa0018980b18099baa0018b20209180b180b980b980b980b800c888c8cc88cc0080080048966002003003899192cc004cdc8803000c56600266e3c01800626eb4c06800a00a80ba266008008603c00680b8dd7180c000980d800a0323232330010010062259800800c00e26464b30013372201000315980099b8f00800189bab301b002802a030899802002180f801a030375c6032002603800280d052f5bded8c029000488c8cc00400400c896600200314bd7044cc8966002600a00513301a00233004004001899802002000a02a3019001301a001405d3710900048c058c05cc05c00644646600200200644660060026004005301137540152259800800c40062a660240042002808a4602c602e602e602e602e602e602e602e602e602e003374a90012444444444444653001222323300d00423002301230243754002b300130143021375400312330053756602260466ea800400e24601930013756602260466ea80066eb8c098c08cdd5001cdd7180898119baa003403880fa4466016004466ebcc094c088dd5181298111baa3010302237540020052232330010010032259800800c5a264b30013375e604e60486ea80040122602460486ea800626600600660500048108c0980050242444b300130140088cc00488c966002602e0031323259800981580140122c8140dd6981480098129baa0038acc004c06c00626464b3001302b0028024590281bad302900130253754007159800980b000c566002604a6ea800e005164099164088811102218119baa002980518111baa028980818111baa028998009bac30253022375402e0229111192cc0040060451598009815800c4c9660020030248992cc004c0b400a2646644b3001301e00189919194c004dd69819000cc0cc0066eb4c0c800e6eb4c0c8009222259800981b801c4cc044c0d800c0262c81a06064002606200260586ea800e2b30013022001899192cc004c0c800a0091640bc6eb4c0c0004c0b0dd5001c566002603a00315980098161baa00380145902d4566002603e0031323322598009819800c4cc034c0c80040162c8180dd69818000981880098161baa0038acc004cdc3a401000315980098161baa00380145902d456600266e1d200a0018992cc004c0c4006264b30013020302d375400313232332259800981b001c0222c8198dd698198009bae30330023033001302e37540031640ac60600031640b860586ea800e2b30013370e9006000c56600260586ea800e0051640b515980099b874803800626464b3001303200280245902f1bad3030001302c375400715980099b874804000626464b3001303200280245902f1bad3030001302c375400715980099b87480480062b3001302c37540070028b205a8b205240a48149029205240a48149029205240a42b30013300f4901205370656e74205554784f2063616e6e6f7420686176652061646d696e204e4654009800998061bab3018302a375400a00d4a14a2813a26601e9212b43445020696e70757420646f6573206e6f74206861766520616e20616c6c6f7765642072656465656d6572003259800980e800c528c566002604200314a3159800980e000c528c56600266e1d200c0018a518a5040a0814102820503029375400314a08138c0a4dd50009919198008009bab300f302b37540404464b30013375e00860580031302d00189980180198188012054302f001300c3302b302c3029375400297ae0812a054302b00140a5300137586054604e6ea80720094c103d87a8000402102240a08140cc018dd6181498131baa01b3029302637546052604c6ea80051980092cc004c054c088dd5000c48c8cdd7981418129baa302830253754004002604e60486ea800a246466ebcc0a0c094dd5001000981398121baa0024081374a900048c098c09cc09cc09c0064464b30013017001899192cc004c0ac00a0091640a06eb8c0a4004c094dd5001c566002603600315980098129baa0038014590264590222044302337540053700900124444464b3001301e00e8cc004c0a0dd501048966002603860526ea800a264646644b30013032003802c5902f1bae302f001375c605e004605e00260546ea800a2c813a44b3001301c30293754005132323322598009819001c0162c8178dd698178009bad302f002302f001302a375400516409d223259800980e800c566002603a60546ea800a2980103d87a80008a6103d879800040a1159800980e000c566002603860546ea800a2980103d87a80008a6103d87b800040a113322598009811800c4c96600266e2000c0062980103d87980008acc004cdc4000801c530103d87b80008a6103d87a800040ac8158dd6981818169baa0048acc004c07c006298103d87b80008a6103d879800040a88150dd6981718159baa003302a3754004814102818149baa0029180319815992cc004c080c0a4dd5000c4c966002604260546ea8c064c0acdd5181718159baa00389807198169ba80014bd7044c038cc0b4dd41802800a5eb810281bad302d302a37540031001409c605860526ea8c0b0c0a4dd500099815992cc004c080c0a4dd5000c4c966002604260546ea8c064c0acdd5180c98159baa00389807198169ba80014bd7044c038cc0b4dd419b80001480052f5c08140dd6981698151baa0018800a04e302c30293754602e60526ea80052f5c1223302c337606ea4008dd4000a5eb7bdb182444b3001337129002000c66002007302f302f00299b800014800d003456600266e2520020018cc00400e605e005337000029000a0068acc004c0740062605c0051533029491146578706563745f61743a206e6f7420666f756e64001640a0814102848c0b0c0b4c0b4c0b4c0b4c0b4c0b4c0b400644444b30013300b0040058acc004cdd7980a98169baa0050038acc00660026eacc06cc0b4dd5002c00a0028032266ebcc024c0b4dd5002a60103d87a80008a5040a914a08152294102a48c0b0c0b4c0b4c0b4c0b4c0b4c0b400646058605a605a605a605a605a00291111111111194c004c0e00066eb4c0dc006600c00c9114c004dd6981d001cdd6981d181d801ccc004dd6181d181b9baa02c0029bad303a00f488896600266ebcc0f8c0ecdd5001015466002607c60766ea8c0f8c0ecdd51814981d9baa002981f1bac3023303b3754061330053758605260766ea80c001122259800998101bab302c303e37546058607c6ea8004c068c0f8dd502244c966002606a607c6ea8006264b30013044001899192cc004c0d0c104dd500144c8c8c8c8c8c8c8c8c8c8ca600260a0003375c60a0017375a60a001330500089828003cc14001a60a000b30500049bad3050003992cc004c1380062b30013371290021826800c5a26088609a002825a2c8278dd5182800124444444444b3001305b00b899817182d00a099912cc004c12c006264b3001305e001899818182e800801c5905b182c9baa0098acc004c13c006264b3001305e001899818982e800801c5905b182c9baa0098acc004c12800626464b3001305f00280245905c1bae305d0013059375401316415882b10560998170030998168028998168020998168018992cc004c128006264b3001305d001899818182e00080c45905a182c1baa00b8acc004c1380062b3001305837540170178b20b28b20aa415460ac6ea8028c158dd5003c590580c140004c13c004c138004c134004c130004c12c004c128004c124004c120004c11c004c108dd500145903f0992cc004cc090dd5981818211baa303030423754002605c60846ea800a264b300130353042375400313232323322598009826001c4c966002607660906ea800626464b3001304f00289919192cc004cc0cd2410f4261642074782076616c696469747900332259800992cc004c10800629462b300130470018a518a5041388270c13cdd519812982998281baa002305330503754003132598009821800c528c566002608e00314a314a0827104e18279baa33025303e30503754004607c60a06ea8006294104d1811180f98271baa0433022302b33050302b33050303133050375060066eb4c074c138dd502a25eb80cc142600294698103d87a8000a60103d8798000412c97ae033050302b33050303133050375066e00050dd6980e98271baa0544bd70198284c00528d300103d87a8000a60103d8798000412c97ae04bd704566002660669201274d757374206f6e6c79206d696e742074686520616363756d756c6174656420696e746572657374003375e6074609c6ea810cdd32cc004c100006297adef6c6089982819bb0301c304e37540a86e98cc084dd7182898271baa00e0014bd6f7b63020968acc004cc0cd241205370656e74205554784f2063616e6e6f7420686176652061646d696e204e4654009800998181bab303c304e37546078609c6ea8054c0f0c138dd502a528528a096899819a48146436f6e74696e75696e67206f7574707574206d7573742068617665206e6f20646174756d20616e6420686f6c642074686520616363756d756c6174656420696e7465726573740098008094c0c4cc140c0accc14004ccc141300103d87a80004bd7025eb8298107d87b9fd87980ff00cc004dd5981e18271baa303c304e375402b375c6038609c6ea81526eb8c144c138dd50072444b300130430048801c4c8c8cc0040040148966002003133056337606ea4014dd3001a5eb7bdb1822646644b30013372201000515980099b8f0080028992cc004cdd7a6101a000374c003100289982d19bb037520126e9800400905519198008009bab30580042259800800c4cc16ccdd81ba9009375001897adef6c6089919912cc004cdc8806001456600266e3c03000a264b30013370e00266e052000010880144cc17ccdd81ba900d375066e0000404000905a1bad305c00389982f19bb037520186ea003c01105944cc17800ccc0140140050591bae3059001305e002305c0014169133059337606ea4020dd300300220a889982c80199802802800a0a8375c60a800260b200460ae00282a8cc09000401104e2980103d87a8000407914a0825a294104b45282096375a60a06530010019bac3051304e375408737566064609c6ea810e660a098101000033050374e60a46eb0c0d8c138dd5021998284c005285300103d87a8000a60103d8798000412c97ae040044444b30010038800c4cc8966002609260a46ea8c158c14cdd5182b18299baa3041305337540051329800803c00a6eacc15cc160006653001375860b0003304b3054375460b060b2003375a60b000b30580024888966002660766eacc11cc164dd51823982c9baa0083041305937540bf15980099b8748038c160dd5000c4c96600260bc00313322598009827182d9baa0018992cc004c184006264b30013050305d37540031323232323298009833000cdd718330024c19800e6eb4c1980092222598009835802c4c8cc10c0044cc0fc00c4cc896600260b8003132323322598009839001c01a2c8378dd698378009bad306f002306f001306a375400f1598009830000c4c8c8cc896600260e40070068b20de375a60de0026eb4c1bc008c1bc004c1a8dd5003c5906720ce159800982d18339baa005899192cc0056600266e3c018dd7183698351baa02a899baf0053058306a375405514a0833a2b30013371066e00004dd6981d98351baa0700308992cc004c1500062b30019800983700b4c138cc1b4c1b8c1acdd5182c98359baa01a4bd704cdd2a4008660da6090660da6090660da008660da6ea401ccc1b4018cc1b4dd419b800050013306d30483306d3750062660da6ea007d2f5c097ae04bd7025eb826eacc164c1acdd5182c98359baa01aa60103d879800040ed13306d375066e00050004cc1b4dd3983780b19836cc00405698103d87a8000a60103d879800041a097ae08a99834a481333c65787065637465643e20457870656374206120636f727265637479207570646174656420636f6e74696e75696e6720434450001641a115330694912a3c65787065637465643e20546865726520697320736f6d65206163637275656420696e7465726573742e001641a064b3001337120026eb4c1b8c1acdd5014c56600266e20dd6982998359baa029031899b803370666e08cdc09bad306e306b375405200200a904040507b7a566df00d99b833370666e08cdc118101bad3053306b37540526eb4c1b8c1acdd5182c98359baa02900548202c227efa8052080897a8a99834a4810155001641a115980099b88002031899b833370666e08cdc118100011bad306e306b375460b260d66ea80a40152080b089fbea014820225ea2a660d292010156001641a08340dd698369837001454cc1a124012d3c65787065637465643e20497420697320746f6f20736f6f6e20746f20736574746c6520696e7465726573742e0016419d1533068491413c65787065637465643e20416c6c20434450732061726520666f72207468652073616d652069417373657420616e6420636f6c6c61746572616c2061737365742e0016419c6eb4c1b0004c1a0dd5002c5906518339baa005306a0098b20d01833000983280098320009831800982f1baa0018b20b630600018b20bc305c37540031641646eb4c174004c11cc108c168dd51824182d1baa0098b20b63059375400316415915980099baf305c3059375460b860b26ea8c11cc164dd500400f45660033001003a50a51415913305b3750004660b66e9c010cc16e600294698103d87a8000a60103d8798000415897ae08a9982ba4812845787065637420612073696e676c6520696e74657265737420636f6c6c6563746f7220696e7075740016415913305b3750004660b66e9c010cc16e60020074c103d87a8000a60103d8798000415897ae0415882b060b00088038c8cc0040040148966002003168994c004c15400660ac003305a00248896600266ebc00cc0f0cc16cc170c164dd500425eb822660b6004660b66e980052f5c113300600600141583058001415919800803400600900340188280c15000cc15400d05219b80375a609e60986ea80296600266e20dd6981a18261baa00a012899b833370666e08cdc118009bad3034304c37540146eb4c13cc130dd5181d18261baa00a482020283dbd2b36f806d2080b089fbea014820225ea2a66094921015a001641246e040462c8260dd6982680098249baa0018b208c304b0048b2092375a60920026eb4c12400cc124004c120004c10cdd5000c590401817981518211baa30303042375400315330404914c3c65787065637465643e205468652070726f7669646564207265662e20696e70757420696e64657820636f72726573706f6e647320746f2074686520696e746572657374206f7261636c652e001640fc660166eb0c0bcc104dd501b0049821800c59041181f9baa0018b2078302b3026303e37546058607c6ea80062a6607892014d3c65787065637465643e205468652070726f7669646564207265662e20696e70757420696e64657820636f72726573706f6e647320746f2074686520636f6c6c61746572616c2061737365742e001640ec8a9981ca49413c65787065637465643e205468652070726f766964656420696e70757420696e64657820636f72726573706f6e647320746f20746865206f776e20696e7075742e001640e0181b805a2646530012259800980f18159baa0028992cc004c0c400626600860600020051640b860586ea800a2c814a4605c605e605e605e605e605e605e605e605e0032232330010010032259800981018169baa0018991919800800802912cc00400629422b30013371e6eb8c0d000400e2946266004004606a00281710321bae3031302e3754003132337126eb4c0c8004c8cc004004dd61819981a001112cc0040062900044cc89660026600e00e0051300d0018800a060303400133002002303500140c8605c6ea800502b2444b3001301e013899912cc004c0cc006264646600e0022b3001330164901235265666572656e636564205554784f206d75737420686176652061646d696e204e465400330133756603e60626ea8c07cc0c4dd500100244cc0592412041646d696e206d756c7469736967206d7573742062652073617469736669656400330053034303137540026eb0c018c0c4dd50134528205c301d301830303754603c60606ea8004c0c80062c8180c06cc0b4dd5019998069bac301b302d37540446060605a6ea8c0c0c0b4dd5198061bac3030302d37540440391598009810009c6600244b30010018a40011300933002002303300140c1301b302d37540673019302d37540673300c37586060605a6ea80880712222323233223300b00113259800981d000c4c966002605a606c6ea8c04cc0dcdd5000c4cc88cc03c0044c9660026603e9211e5370656e74205554784f206d75737420686176652061646d696e204e4654003301c3756605060746ea80280322b30013301f490125466f756e646174696f6e206d756c7469736967206d75737420626520736174697366696564003300e303d303e303e303e303e303e303e303e303e303e303e303e303a3754605060746ea800cdd61807981d1baa02f8acc004cc07d2401234e65772061646d696e67206d756c74697369672063616e6e6f7420626520656d7074790030070018acc004cc07d241244e65772061646d696e206d756c7469736967206d75737420626520736174697366696564003300e0013758601e60746ea80be2b30013301f490121436f6e74696e75696e672076616c7565206d757374206265207468652073616d650098009bab3028303a37540093756605060746ea802a980103d87a8000404d13301f4901244f6c6420616e64206e657720646174756d73206d75737420626520646966666572656e7400980099baf006002a50a5140dd14a081ba29410374528206e8a5040dd14a081b8c0f0c0e4dd5000992cc004c0f0006264b3001302b303837540031323232323298009bad30410019bad30410059bad30410039bad30410024888966002608c00b13259800981a98211baa00189919191919191919191919194c004c1480066eb4c1480326eb4c14802e6eb4c14802a6eb4c1480266eb4c1480226eb4c14801e6eb4c14801a6eb4c1480166eb4c1480126eb4c1480092222222222259800982f00644cc0d4c1740384cc0c402c408a2c82d860a400260a200260a0002609e002609c002609a0026098002609600260940026092002609000260866ea80062c8200c1140222c821860820026080002607e002607c00260726ea80062c81b0c094c080c0e0dd51813181c1baa303b0018b207298009bac302530373754059008a60103d879800040606048603e606e6ea80062c81a0c0e40062c81b8cc07cdd6180e981a9baa02a301330183303730383035375400a97ae030010013020301b3033375400644b300130263033375400314a31323322598009810001456600266e24008c0180062646600200200444b30010018a518acc004cc01c01cc0f0006266004004607a00314a081b103a452820688a5040d06eb4c0e0004dd6181c181c800981a1baa00140c4600800889919912cc004c098c0bcdd5000c4cc8966002606c00313259800981298191baa00189919912cc004c0e800626603a6eb0c0e40048966002005132598009815981c1baa0018991925159800991980080098069bab3027303b375406044b30013371e6eb8c0fc00400e2946266004004608000281ca2934590371bae303c303937540031640d864660020026eb0c09cc0e4dd5003912cc004006298103d87a80008992cc006600266ebc00530103d87a8000a50a5140e11001899801801981f8012070325980099b8f375c607c002017130183303d303e303f0014bd7045300103d87a800040e06eb0c0f400503b44c8c8cc896600260800071300530400068b207a375c607a0026eb8c0f4008c0f4004dd6181d80120728b206e375a606e002607000260666ea80062c8180c07cc068c0c8dd5181018191baa30350018b2066375c606660606ea800660026eb0c078c0c0dd5012cc0ccc0c0dd501b530103d879800040451640b460020026062605c6ea8c0c4c0b8dd5198069bac3031302e375404603a44b30010018a5eb82266062605c6064002660040046066002818102a20541800800911192cc004c07800626464b3001303200280245902f1bae3030001302c37540071598009811000c4c8cc896600260660031330163758606400244b3001002803c66002013303400289800981a801201240c91640c06eb4c0c0004c0c4004c0b0dd5001c590292052302a37540048128888cc8a600264b3001301f302c37540031375a605a60606eacc0c0c0b4dd5000c5200040a8605e0033756005375e605e60600032259800981218169baa005899b890010028acc004cdc480080144cdc480119b80001482026fb80a294102b20564888966002007159800980100344cc00401120008a5040b51325980099baf4c0101400030300018acc004cc008014dd69818981a1bab3031001898019ba630350048a5040b915980099801002a4001130030078a5040b88170c0cc00d0310dd3001194c004006009223302f0023302f374c00297ae04004444b3001002899800a6103d87a80004bd6f7b63044c8cc896600266e452201000028acc004cdc7a441000028998021806998191818001a5eb80006266008980103d87a800000540b5198008034006446600c0046606800a002803102d1bae302d0013032003303000240b8407c22301698008014dd7181198101baa0019bae300e302037540028058602a602c00c602800a8b2012180580098031baa00b8a4d13656400c2a660049212f3c65787065637465643e2053696e676c652043445020696e70757420696e20746865207472616e73616374696f6e2e001615330024913f3c65787065637465643e2053696e676c6520696e74657265737420636f6c6c656374696f6e20696e70757420696e20746865207472616e73616374696f6e2e001601"
|
|
7753
|
+
cborHex: "590a2a590a27010100229800aba2aba1aba0aab9faab9eaab9dab9cab9a488888888cc896600264653001300b00198059806000cdc3a4005300b0024888966002600460166ea800e33001300c3754007370e90024dc3a4001300b375400891111919912cc004c0140122b3001301337540170028b20288acc004c0240122b3001301337540170028b20288acc004c0180122b3001301337540170028b20288b202040408080660024602a602c0032259800800c52f5c11330153012301600133002002301700140512301530163016001911919800800801912cc004006297ae0899912cc004c01400a2660320046600800800313300400400140506030002603200280b24446466446600400400244b3001001801c4c8c96600266e440180062b30013371e00c0031375a60320050054059133004004301d00340586eb8c05c004c068005018191919800800803112cc004006007132325980099b910080018acc004cdc7804000c4dd5980d001401501744cc010010c07800d0171bae3018001301b0014064297adef6c6014800260206ea802644b30010018800c54cc04400840050104dd2a400091111111194c0048c00800644602530010029bae301f301c3754003375c601660386ea8005007488c8cc00400400c8966002003168992cc004cdd79811180f9baa00100489807180f9baa001899801801981180120383021001407c9112cc004c03c01e2646464b300100180dc4c966002604a00513259800800c07a2b30013026001899805a49364d7573742070726f6475636520636f6c6c6563746f72206f7574707574207769746820696e63726561736564204144412076616c75650098009b914881009b8f4881009bac300f3022375402f3374a90011981218051981200219812260103d87a80004bd7025eb812222332232330010010052259800800c528456600264b300130040018acc004cdd7980c18159baa0014c107d87b9fd87980ff008acc004cc8a600264b30013020302d37540031375a605c60626eacc0c4c0b8dd5000c5200040ac60600033756005375e606060620032259800981298171baa4c0103d87a8000899b890010028acc004cdc480080144cdc480119b80001482026fb80a294102c20584888966002007159800980100344cc00401120008a5040b91325980099baf4c101400030310018acc004cc008014dd69819181a9bab3032001898019ba630360048a5040bd15980099801002a4001130030078a5040bc8178c0d000d0320dd3002994c0040066eacc06cc0b0dd5001488cc0c0008cc0c0dd3000a5eb810011112cc00400a26600298103d87a80004bd6f7b63044c8cc8966002601e005159800980700144cc010c064cc0ccc0c400d2f5c00031330044c0103d87a800000540b9198008034006446600c0046606a00a002803102e1bae302e0013033003303100240bd13375e605c605e605e605e60566ea800530103d87a80008a5040a114a0814229410281816800c528c4cc008008c0b800502720563259800a508800c4c8c8cc00400400c896600200313302c337609801014000374c00697adef6c6089919912cc004c02c00a2b3001300a0028992cc004cdd7a6101a000374c003100289981819bb04c01014000374c0020048158c8cc004004dd59817002112cc00400626606266ec130010140004c010101004bd6f7b63044c8cc89660026020005159800980780144c96600266e1c0052001880144cc0d4cdd8261014000375066e00005200200240c06eb4c0c800e26606866ec13010140004c0101010000440bd1330340033300500500140bc6eb8c0bc004c0d0008c0c800503044cc0bccdd82601014000374c00c008815226605e0066600a00a0028150dd7181500098178011816800a056330293376098010140004c010101004bd6f7b63020483756602a604c6ea8025660026030604a6ea8006246466ebcc0acc0a0dd5181598141baa002001302a3027375400512323375e605660506ea8008004c0a8c09cdd500120464079023204630073756602060426ea8c040c084dd5000c0710221811800a0423300b37586044603e6ea80508cdd7981198101baa302330203754601e60406ea8004008c084c078dd51810980f1baa0013300137586040603a6ea80480362b3001301300789919803a49334d757374207370656e64207374616b696e67206d616e61676572207769746820446973747269627574652072656465656d657200332259800800c00a2b3001302400189919912cc004c05400626464b300130290028024590261bae302700130233754007159800980c800c56600260466ea800e005164091159800980b000c56600260466ea800e00516409115980099b874801800626464b300130290028024590261bad30270013023375400715980099b87480200062b3001302337540070028b20488acc004cdc3a401400315980098119baa003801459024456600266e1d200c0018acc004c08cdd5001c00a2c81222c8101020204040808101020204013375e00298103d87b8000302037540026464660020026eacc094c098c098c098c098c098c098c098c098c098c088dd500b91192cc004cdd78021811800c4c09000626600600660500048108c098004cdd2a400466044604660406ea8c08c0052f5c100240848108528198051bac3021301e37540264660086eacc038c07cdd51807180f9baa0010023020301d37540471332259800980a980f1baa001899912cc004c094006264b30013014302137540031323322598009814800c4c8cc004004dd61814801112cc004006264b3001301a30273754003132324a2b3001323300100130103756605a605c605c605c605c60546ea807c896600266e3cdd71817000801c528c4cc008008c0bc00502845268b204c375c605660506ea80062c8128c8cc004004dd6180b98141baa0072259800800c5300103d87a80008992cc006600266ebc00530103d87a8000a50a51409d10018998018019817001204e325980099b8f375c605a002017130123302c302d302e0014bd7045300103d87a8000409c6eb0c0b000502a44c8c8cc8966002605e007133006006302f0058b2058375c60580026eb8c0b0008c0b0004dd61815000a0508b204c375a604c002604e00260446ea80062c80f8c966002602a60426ea80062604a60446ea80062c80f8c038c084dd5180818109baa30240018b2044375c6044603e6ea8004c8cc030dd6180798101baa01523002301030213754002b30013011301e375498103d879800089198029bab300f30203754002007123371090004c004dd5980798101baa0019bae302330203754007375c601e60406ea800d00b20388b2038300a301d37540466040603a6ea8c080c074dd5198009bac3020301d375402401a80d101a0c01c01c6028602a00a60260088b2012180580098031baa00b8a4d13656400c2a660049201353c65787065637465643e20436f6c6c6563746f7220696e7075742063616e6e6f742068617665206e6f6e2d41444120617373657473001615330024912c3c65787065637465643e204d757374207370656e642073696e676c6520636f6c6c6563746f7220696e707574001601"
|
|
8198
7754
|
};
|
|
8199
7755
|
|
|
8200
|
-
// src/contracts/
|
|
8201
|
-
|
|
7756
|
+
// src/contracts/collector/scripts.ts
|
|
7757
|
+
var mkCollectorValidatorFromSP = (params) => {
|
|
8202
7758
|
return {
|
|
8203
7759
|
type: "PlutusV3",
|
|
8204
|
-
script:
|
|
8205
|
-
|
|
7760
|
+
script: applyParamsToScript12(_collectorValidator.cborHex, [
|
|
7761
|
+
new Constr2(0, [
|
|
7762
|
+
new Constr2(0, [
|
|
7763
|
+
params.stakingManagerNFT[0].unCurrencySymbol,
|
|
7764
|
+
fromText7(params.stakingManagerNFT[1].unTokenName)
|
|
7765
|
+
]),
|
|
7766
|
+
new Constr2(0, [
|
|
7767
|
+
params.stakingToken[0].unCurrencySymbol,
|
|
7768
|
+
fromText7(params.stakingToken[1].unTokenName)
|
|
7769
|
+
]),
|
|
7770
|
+
new Constr2(0, [
|
|
7771
|
+
params.versionRecordToken[0].unCurrencySymbol,
|
|
7772
|
+
fromText7(params.versionRecordToken[1].unTokenName)
|
|
7773
|
+
])
|
|
7774
|
+
])
|
|
8206
7775
|
])
|
|
8207
7776
|
};
|
|
7777
|
+
};
|
|
7778
|
+
|
|
7779
|
+
// src/contracts/execute/types.ts
|
|
7780
|
+
import { Data as Data40 } from "@lucid-evolution/lucid";
|
|
7781
|
+
var ExecuteParamsSchema = Data40.Object({
|
|
7782
|
+
govNFT: AssetClassSchema2,
|
|
7783
|
+
upgradeToken: AssetClassSchema2,
|
|
7784
|
+
iAssetToken: AssetClassSchema2,
|
|
7785
|
+
collateralAssetToken: AssetClassSchema2,
|
|
7786
|
+
stabilityPoolToken: AssetClassSchema2,
|
|
7787
|
+
cdpCreatorToken: AssetClassSchema2,
|
|
7788
|
+
cdpToken: AssetClassSchema2,
|
|
7789
|
+
versionRecordToken: AssetClassSchema2,
|
|
7790
|
+
iassetValHash: Data40.Bytes(),
|
|
7791
|
+
cdpValHash: Data40.Bytes(),
|
|
7792
|
+
sPoolValHash: Data40.Bytes(),
|
|
7793
|
+
versionRegistryValHash: Data40.Bytes(),
|
|
7794
|
+
treasuryValHash: Data40.Bytes()
|
|
7795
|
+
});
|
|
7796
|
+
var ExecuteParams = ExecuteParamsSchema;
|
|
7797
|
+
function castExecuteParams(params) {
|
|
7798
|
+
return Data40.castTo(params, ExecuteParams);
|
|
8208
7799
|
}
|
|
8209
|
-
|
|
7800
|
+
|
|
7801
|
+
// src/contracts/execute/scripts.ts
|
|
7802
|
+
import {
|
|
7803
|
+
applyParamsToScript as applyParamsToScript13,
|
|
7804
|
+
applySingleCborEncoding
|
|
7805
|
+
} from "@lucid-evolution/lucid";
|
|
7806
|
+
|
|
7807
|
+
// src/validators/execute-validator.ts
|
|
7808
|
+
var _executeValidator = {
|
|
7809
|
+
type: "PlutusScriptV3",
|
|
7810
|
+
description: "Generated by Aiken",
|
|
7811
|
+
cborHex: "5931ec5931e9010100229800aba2aba1aba0aab9faab9eaab9dab9cab9a48888888a60022a66004921203c65787065637465643e20694173736574206e6f74207265666572656e63656400168a99801249283c65787065637465643e2053696e676c6520636f6c6c61746572616c20617373657420696e70757400168a998012491e3c65787065637465643e2053696e676c652069617373657420696e70757400168a99801249193c65787065637465643e204d697865642076657273696f6e7300168a99801249523c65787065637465643e205768656e2066756e64732066726f6d207472656173757279207265717565737465642069742068617320746f207370656e642061207574786f2066726f6d20747265617375727900168a99801249243c65787065637465643e204f6e6c792073696e676c65206578656375746520696e707574001648888896600264653001300f00198079808000cdc3a4005300f00248889660026004601e6ea800e2664530013015002980a980b001566002600260226ea801a2b30013012375400d149a2c809a2c8079222598009802180a1baa0028cc004c060c054dd50014c054dd500348c064c06800644646600200200644b30010018a5eb8226644b3001300500289980e80119802002000c4cc010010005018180e000980e800a03448888c8cc88cc89660020050158acc004c08800a26464b3001330013756601260406ea8018c024c080dd5013466002444646601800846004601c604a6ea800566002602460446ea8006246600a6eacc034c090dd5000801c48cdc42400130013756601a60486ea80066eb8c09cc090dd5001cdd7180698121baa003401881026e1d20049181218129812800c88c8cc00400400c88cc00c004c00800a4464b30013012001899192cc004c0a400a0091640986eb8c09c004c08cdd5001c566002602a00315980098119baa0038014590244590202040302137540049111119914c004c0a800a6002003259800980398139baa0018981598141baa0018b204a488a60026002601060546ea8c04cc0a8dd5001c8966002603660566ea800a26464646464646464646464653001303b0019bad303b00c9bad303b00b9bad303b00a9bad303b0099bad303b0089bad303b0079bad303b0069bad303b0059bad303b0049bad303b00248888888888966002608e01913301f304600e13301b00b0188b2088181d800981d000981c800981c000981b800981b000981a800981a00098198009819000981880098161baa0028b2052980e18149baa302d302e005488966002603860586ea800e264646464653001375a606a003375a606a00b375a606a007375a606a00491112cc004c0e80162660166072010330012303a303b303b303b303b303b303b303b0019181d181d981d981d800cdd2a40052259800800c40062a6606c004200281aa44b3001302730373754005132323322598009820001c0162c81e8dd6981e8009bad303d002303d001303837540051640d522598009813981b9baa0028991919912cc004c10000e00b1640f46eb8c0f4004dd7181e801181e800981c1baa0028b206a9b874801a6e1d20089b874802a6e1d200e9b87480326e2520044888888888888cc89660026601692125476f7620696e707574206d75737420757365207468652072696768742072656465656d6572005980080c44ca6002266ebc00530103d87b800098221baa00191192cc004c0dc00626464b3001304e00280245904b1bae304c00130483754007159800981d000c4c8c966002609c0050048b2096375c609800260906ea800e2c822904518231baa002488966002606e00513232323298009827800cdd698278024dd71827801a444b3001305300489919912cc004c10400a264b300130570018992cc004c10cc14cdd5000c4c8c8c8c8c8ca600260ba003375c60ba00d305d004982e801cc1740092222259800983180344cc094c1880284cc09400c4cc0940084cc0940044cc09401403a2c830060ba00260b800260b600260b400260b200260a86ea80062c8288c1580062c82a0c148dd5001c566002608800513259800982b800c4c966002608660a66ea800626464646464653001305d0019bae305d006982e8024c17400e60ba004911112cc004c18c01a26604a60c401426604a00626604a00426604a00226604a00a01d164180305d001305c001305b001305a00130590013054375400316414460ac00316415060a46ea800e2b300130310028992cc004c15c006264b3001304330533754003132323232323232323298009bad30600019bae30600099bad306000798300034c18001660c000930600039830001244444444b30013069009899815183400809981100289981500209981580189981580109981580080a4590660c180004c17c004c178004c174004c170004c16c004c168004c164004c150dd5000c59051182b000c5905418291baa0038acc004c05800a264b300130570018992cc004c10cc14cdd5000c4c8c8c8c8c8c8c8c8ca60026eb4c1800066eb8c1800266eb4c18001e60c000d306000598300024c18000e60c0004911111112cc004c1a402626605460d002026604400a2660540082660560062660560042660560020291641983060001305f001305e001305d001305c001305b001305a00130590013054375400316414460ac00316415060a46ea800e2b300130150028992cc004c15c006264b3001304330533754003132323232323232323298009bae30600019bae30600099830003cc18001a60c000b30600049bad30600039bad30600024888888896600260d201313302a306801013302b00613302b00513302b0041330410030148b20cc1830000982f800982f000982e800982e000982d800982d000982c800982a1baa0018b20a230560018b20a830523754007159800980a00144c96600260ae00313259800982198299baa001899191919191919191919194c004dd71831000cdd71831005cc18802660c40113062007992cc004c1800062b3001301f305f0018b44c148c17c00505d4590611baa3062006992cc004c1800062b3001301f305f0018b44c148c17c00505d4590611baa306200598310024dd69831001cdd6983100124444444444b3001306d00b899817183600a09981780409981780389981780309982280180c45906a0c188004c184004c180004c17c004c178004c174004c170004c16c004c168004c164004c150dd5000c59051182b000c5905418291baa0038acc004c04800a264b30013057001899814182b00080145905418291baa0038acc004c04c00a264b300130570018992cc004c10cc14cdd5000c4c8cc896600260b6003133034375860b400244b300100280444c8cc896600260c0003132598009826182e1baa001899192cc004c18c00a2600e60c60111641806eb8c184004c174dd5000c5905a182f800c5905d1bae305d001305e001375860b800482d22c82c0dd6982c000982c800982a1baa0018b20a230560018b20a83052375400715980099b874804000a26464b30013058002801c590551bae30560013052375400716413c827904f209e413c827904f209e413c609e6ea80044c966002608000313259800982b000c4c966002608460a46ea80062646464b3001305a002899912cc004c11cc15cdd500144c8c8c96600260be005133014305e003132598009825800c4c96600260c200313232598009827000c4c96600260c800313301930630010098b20c2305f37540051598009828800c4c8c8ca60026eb4c1940066eb4c19400e6eb4c194009222598009834802403a2c833060ca00260c800260be6ea800a2c82e105c182e9baa00130600018b20bc305c37540051598009827000c56600260b86ea800a00b16417516416482c8c168dd5000c5905c182e800982e800982c1baa0028b20aa30590031330330012259800801404e264b3001304830583754003132323298009bad305f0019bae305f0039bae305f00248896600260c60091300830630098b20c0182f800982f000982c9baa0018b20ac305b002416516415c6eb0c160004c160004c14cdd5000c59050182a800c5905318289baa0058acc004c10c0062b30013051375400b00c8b20a48b209c4138609e6ea8010c1480162c8280609e002609c002609a00260906ea80122b3001303a002899192cc004c13800a00b16412c6eb4c130004c120dd50024566002604e00515980098241baa004801c590494566002601800515980098241baa004801c59049459045208a4114822866004608e60886ea807409e294504144c96600266018921174d697865642070726f746f636f6c2076657273696f6e73003370e6eb4c08cc114dd500d9bad30013045375406115980099806249224d7573742065786563757465206166746572206566666563746976652064656c6179003259800981c18229baa001899b88337006eb4c090c118dd50189bad302430463754605e608c6ea8070dd6982498231baa0018a50410c6090608a6ea8c120c114dd5180798229baa0368acc004cc03124011143616e6e6f742062652065787069726564003259800981c18229baa001899b89375a6092608c6ea8004cdc01bad300f304637540626eb4c03cc118dd5181798231baa01c8a50410c6090608a6ea8c0b8c114dd5180798229baa0368cc0048c124c128c128c128c128c12800646092609460946094609460946094609460946094003375e980103d879800048896600264b3001303830483754600860926ea80d22b3001001820c4c966002609c005132332259800981e000c566002609a6ea800e005164139159800981f800c566002609a6ea800e0051641391598009816000c566002609a6ea800e0051641391598009808800c566002609a6ea800e0051641391598009808000c4c8c8c8ca600260a8003375a60a8007375a60a80049112cc004c16001226603260ae00e2b300130433053375400713232332259800982e001c0362c82c8dd6982c8009bae3059002305900130543754007164145164154305400130530013052001304d37540071598009807800c566002609a6ea800e005164139164128825104a2094412882504c010004c128dd500099804182698251baa0013756600860946ea80ee0848258c13000504a44cc0412414b5768656e206e6f207472656173757279207769746864726177616c207265717565737465642069742063616e2774207370656e6420616e79207574786f2066726f6d207472656173757279003375e6e9c005300101800041186605a6eb0c12cc120dd501c980819825182598261826182618261826182618261826182618261826182618241baa04e4bd704660026e952000911982619bb037520046ea00052f5bded8c1370090014dd2a4008911119912cc004cc88cc05d24012c54686520646174756d206f6620676f7665726e616e6365206d757374207570646174652070726f7065726c79003232598009820800c6600200900398039982a19191918069982b982c0019982b982c0011982b982c0009982b9ba8300b375a603c60aa6ea80acc164c164004c160004c15c004c148dd501425eb82600a60aa60a46ea816298103d87a800040191598009809000c6600200900398039982a1918059982a982b0009982a982b18299baa003305730570013052375405097ae09802982a98291baa058a60103d87a800040191598009809800c6600200900398039982a191918061982b182b8011982b182b8009982b1ba8300a375a606460a86ea80a8c160c160004c15c004c148dd501425eb82600a60aa60a46ea816298103d87a8000401919800813528528a09e413c827904f18281baa0013039305037540766eb0c144c148c148c138dd501f980b19828180319828182898271baa3051304e3754606e609c6ea809ccc14130103d87a80004bd7025eb82264b300133016490122546865207472616e73616374696f6e206d757374206d696e742070726f7065726c79003375e6016609e6ea8100dd34c0048c8cc004004008896600200314bd6f7b63044c8cc154cdd818290009ba63233001001375660a800444b30010018a5eb7bdb182264660b066ec0c154004dd419b8148000dd6982b00099801801982d001182c000a0ac3300300330570023055001414d304e37546070609e6ea80ea4446644b300130430038802c4c8c8cc00400401c8966002003133059337606ea4014dd3001a5eb7bdb1822646644b30013372201000515980099b8f0080028992cc004cdd7a60101a000374c003100289982e99bb037520126e9800400905819198008009bab305b0042259800800c4cc178cdd81ba9009375001697adef6c6089919912cc004cdc8806001456600266e3c03000a264b30013370e00266e05200000f880144cc188cdd81ba900d375066e0000403c00905d1bad305f00389983099bb037520186ea003801105c44cc18400ccc01401400505c1bae305c0013061002305f001417513305c337606ea4020dd300300220ae89982e00199802802800a0ae375c60ae00260b800460b400282c0cc02c00400d0511bae3055305237540046eb8c0ecc148dd50012444b300130410028cc00660026006600a607660a46ea8162601c60a46ea816290012002981818291baa058a4004800a2b300130310028cc004c00cc014c0ecc148dd502c4c06cc148dd502c520024005159800980a8014660026006600a607660a46ea8162600860a46ea8162900120028acc004c04c00a3300130033005303b305237540b1301c305237540b14800900144c00cc014c0ecc148dd502c209e413c827904f226602c921104661696c656420657865637574696f6e009800981c18279baa03a91829982a182a182a182a182a182a182a182a000c8c14cc150c150c150c150c150c150c150c150c150c15000644b300130403050375400513232323232323232329800982e800cdd7182e804cdd6982e8044c17401a60ba00b305d004982e801cc96600260b6003159800980d182d000c5a2609a60b400282c22c82e0dd5182e801244444444b30013066009899814183280789981400289981400209981400189981400109981f0040094590630c174004c170004c16c004c168004c164004c160004c15c004c158004c144dd500145904e4896600266e40008006298103d87980008acc004cdc7801000c530103d87a80008a6103d87b8000413882712222232598009822000c4ca6002601c660b0002660b0980103d87a80004bd704dd6182c982d182d182b1baa047982c982b1baa0074888c966002660429212153746162696c697479506f6f6c206f757470757420697320696e636f7272656374009800801cc088cc170c048cc170c088cc170c024c168dd503025eb80cc171300103d87a80004bd7025eb82601e660b86024660b86024660b860ba60b46ea8008cc171300118d8799fd8799f1b0de0b6b3a7640000ffd8799f00ff0000ff003305c4c10180004bd7025eb812f5c1300d3016305a37540c14c103d87a8000403915980098249bad3023305a37540611330214912370726f706f73656420694173736574206f757470757420697320696e636f727265637400330014a2980103d87a8000899810a48125496e636f72726563746c7920636f6e73756d6564207265666572656e636520696173736574003259800982f800c4c96600266ebc01cc17cc170dd5182f982e1baa3045305c3754003132598009826182e1baa0018992cc004c1880062646601a002264b3001304f0018acc004c148c17cdd5181518301baa0028acc004cc09d2412370726f706f73656420694173736574206f757470757420697320696e636f727265637400330074a26030660c460c660c06ea80092f5c113302749123636f6e73756d656420694173736574206f757470757420697320696e636f7272656374009800804cc0a0cc1880292f5c130153306230183306232323232323232301f33069306a00733069306a00633069306a00533069306a00433069306a00333069306a00233069306a001330699800a50a6103d87a8000a60103d8798000419060d660d600260d400260d200260d000260ce00260cc00260ca00260c06ea80092f5c097ae09809981f18301baa066a6103d87a8000405114a082ea294105d4566002607e003159800992cc004c140c180dd5000c4c068cc038dd7183218309baa009375c60c860c26ea8006294505e180818301baa0028acc004cc09d2412370726f706f73656420694173736574206f757470757420697320696e636f727265637400330074a0602060c06ea800a26604e92123636f6e73756d656420694173736574206f757470757420697320696e636f7272656374009800804cc0a0cc1880292f5c130153306230183306232323232323232301f33069306a00733069306a00633069306a00533069306a00433069306a00333069306a00233069306a00133069306a306b00133069301f33069306a3067375401e97ae04bd7018350009834800983400098338009833000983280098301baa0024bd7025eb826026607c60c06ea819a98103d87a8000405114a082ea294105d454cc1792411a537563682069617373657420616c7265616479206578697374730016417482e8c178dd5198061bae3062305f375400e6eb8c188c17cdd50009830800c5905f182e9baa0018b20b43033303a305c3754608a60b86ea80060aa82c8c1780062c82e260026eb0c174c168dd5025cc0e0c168dd50305300103d879800040e882ba2941057114c0040126046660ba00a97ae098081982e98099982e98099982e982f182d9baa0033305d4c10100003305d3044305b3754006660ba607260b66ea800ccc174c090c16cdd50019982e980b982d9baa0033305d3016305b3754006660bb3001002a6103d87a8000a60103d87980004160660ba00297ae04bd7025eb82601c607260b66ea818698103d87a8000403c301d330573005305537540b697ae08acc004c11c0062653001375860b260b460b400398009bac3059001981a182b1baa05ca6103d879800040d9301e330583006305637540b897ae0982c982b1baa007488896600260bc0071325980099baf003305e305b375460bc60b66ea8c110c16cdd5000c4c966002609660b66ea8006264b30013061001899198060008acc004cdc79bae3061305e37540026eb8c184c178dd5002c5660033001008981319830180b198300031983026103d87a80004bd7025eb826026660c0602c660c064646030660c460c6004660c460c6002660c4609260c06ea801ccc188c0f8c180dd500399831181498301baa00733062301c3060375400e660c4603660c06ea801cc190c190c190c190c190c190004c18c004c178dd5000a5eb812f5c13011303c305e37540c94c0103d87a8000404914a3153305c491253c65787065637465643e20694173736574206f757470757420697320696e636f72726563740016416d153305c4911e3c65787065637465643e204e6f742072656c6576616e74206961737365740016416c60c000316417860b86ea80062c82c8c0c8c0e4c16cdd51822182d9baa0018a9982ca49283c65787065637465643e204d6f64696679696e67206e6f6e2d7570677261646564204941737365740016416060ba00716416c3055375408d13259800981a80146600260b260ac6ea801e4464b3001304b30583754003133006375c608460b26ea800cdd71821182c9baa0028800a0ac33005375c60b660b06ea8008dd7182d982c1baa001980f1982c1803182b1baa05c4bd704c158dd5023a4445300130123305c0023305c4c103d87a80004bd704dd6182e982f182f000e60026eb0c174006607060b46ea818298103d879800040e89112cc0040060af132598009831001456600266ebc018c184c178dd51830982f1baa3047305e3754003132598009827182f1baa0018992cc004c1900062646601e0022b30013371e6eb8c190c184dd50009bae306430613754017159800cc00401a6052660c600e97ae0980b19831980c9983199180d198321832800998321ba83018375a609660c46ea8008c198c198004c184dd5000a5eb812f5c13014303f306137540cf4c103d87a80004055132324a2b30013051375a609660c46ea800a2b300198009bac3065306237540a7302b306237540d14c0103d8798000410915980099800a514c0103d87a80008a4d1533060491223c65787065637465643e2057726f6e6720636f6c6c61746572616c206f75747075740016417d1533060491243c65787065637465643e204e6f20636f6c6c61746572616c20617373657420696e7075740016418d13259800800c17a264b300130680028acc004cdd7806183398321baa306730643754609a60c86ea8006264b3001305730643754003132598009835000c4c8cc04800456600266e3cdd7183518339baa001375c60d460ce6ea80462b3001337106eb4c140c19cdd5003acc0056600266ebd6600260b260cc6ea8c084c19cdd5000c4c140c19cdd5000c4c96600260d800313259800982d98341baa0018992cc004c1b80062646602c0022b3001305d306a3754604a60d66ea8006260a860d66ea80062a660d2921253c65787065637465643e204e6f742074686520666972737420696e2074686520636861696e001641a060da0031641ac60d26ea80062c8330c0fcc118c1a0dd5182898341baa306b0018b20d298009bac3050306737540b13030306737540db4c0103d8798000411c8321300106d8799f4040ff008a51899baf30503067375402298106d8799f4040ff00419114804a2900820c88acc004c96600260ae003159800982d18339baa30223068375400515980099817a4812a70726f706f73656420636f6c6c61746572616c206173736574206f757470757420696e636f727265637400330074a26040660d460a260d06ea80092f5c113302f4912a636f6e73756d656420636f6c6c61746572616c206173736574206f757470757420696e636f7272656374009800806cc0c0cc1a80392f5c1301d3306a30303306a3232323232323232323029330733074009330733074008330733074007330733074006330733074005330733074004330733074003330733074002330733074001330739800a50a6103d87a8000a60103d879800041b860ea60ea00260e800260e600260e400260e200260e000260de00260dc00260da00260d06ea80092f5c097ae0980d981898341baa06ea6103d87a8000407114a0832a29410654566002608e003159800992cc004c160c1a0dd5000c4c088cc048c148c1a4dd5009983618349baa0018a514198602e60d06ea800a2b30013302f4912a70726f706f73656420636f6c6c61746572616c206173736574206f757470757420696e636f727265637400330074a0602e60d06ea800a26605e9212a636f6e73756d656420636f6c6c61746572616c206173736574206f757470757420696e636f7272656374009800806cc0c0cc1a80392f5c1301d3306a30303306a3232323232323232323029330733074009330733074008330733074007330733074006330733074005330733074004330733074003330733074002330733074001330733074307500133073302933073305a3071375403697ae04bd70183a000983980098390009838800983800098378009837000983680098341baa0024bd7025eb826036606260d06ea81ba98103d87a8000407114a0832a2941065454cc199241245375636820636f6c6c61746572616c20617373657420616c726561647920657869737473001641948328c198dd519808182818339baa011305030673754003149a2c83222a660ca921283c65787065637465643e204d617820636f6c6c61746572616c206173736574732072656163686564001641911533065491283c65787065637465643e204e6f742072656c6576616e7420636f6c6c61746572616c2061737365740016419060d200316419c60ca6ea80062c8310c0ecc108c190dd5182698321baa00182ea0c282fa0ca306600141913001375860ca60c46ea814e605660c46ea81a298103d8798000410882f88a6002011302b330650094bd704c060cc194c0accc194c06ccc194c198c18cdd500199832982618319baa00d3306530413063375401a660ca605860c66ea8034cc194c07cc18cdd500699832980f18319baa00d3306530153063375401a660ca605a60c66ea8034cc194c04cc18cdd500699832cc00400a98103d87a8000a60103d87980004180660ca00297ae04bd7025eb82602c605860c66ea81a698103d87a8000405d153305f4911e3c65787065637465643e2057726f6e6720696173736574206f757470757400164179153305f491173c65787065637465643e2057726f6e67206961737365740016417860c600316418460be6ea80062c82e0c0d4c0f0c178dd51823982f1baa00182ba0b682c20be3060001417845660026034005132980098079982c8009982ca6103d87a80004bd70660026eb0c168c15cdd50244c080c15cdd502ed300103d879800040dd305a305737540109112cc004c17800a264b30013375e00a60bc60b66ea8c178c16cdd51822182d9baa0018992cc004c138c16cdd5000c4c96600260c200313233009001159800acc004cdc79bae3061305e37540026eb8c184c178dd5002c4cdd79823982f1baa0013047305e375400b14a082da2b300198009bac303c305e375409f3026330600074bd704c04ccc180c098cc180c8c8c8c064cc18cc19000ccc18cc190008cc18cc190004cc18cc0a8c184dd500419831980e98309baa00833063301c30613754010660c6602660c26ea8020cc18cc0acc184dd500419831980898309baa008306530653065306530653065306500130640013063001305e375400297ae04bd704c044c09cc178dd5032530103d87a8000404914a3153305c4912c3c65787065637465643e20436f6c6c61746572616c206173736574206f757470757420696e636f72726563740016416d153305c491263c65787065637465643e20697272656c6576616e7420636f6c6c61746572616c2061737365740016416c60c000316417860b86ea80062c82c8c0c8c0e4c16cdd51822182d9baa00182a20b0305d0028b20b6180f1982c1803182b1baa05c4bd70456600260320051332259800982e000c4c966002609660b06ea80062b30013059375400313259800800c15a264b3001305f0028992cc004c12cc16cdd5000c4c96600260c20031323300c00115980099812a4810c57726f6e6720694173736574003371e6eb8c184c178dd50009bae3061305e3754011133025490117434450206f757470757420697320696e636f72726563740098009bac303c305e375409f3026330603016330603026330603018305e37540c897ae0330604c103d87a80004bd7025eb826026660c0604c660c0602c660c060c260bc6ea8020cc180c11cc178dd500419830181e182f1baa008330603027305e3754010660c0603460bc6ea8020cc1826002946980103d87a8000a60103d8798000416c660c130014a34c0103d87a8000a60103d8798000416c660c0603260bc6ea8020cc180c040c178dd5004198301814182f1baa00833060300e305e375401097ae04bd7025eb826022602060bc6ea8192980103d87a8000404914a082d8c1800062c82f0c170dd5000c590591819181c982d9baa3044305b3754003057417060ba00282da60026eb0c108c164dd50254c0dcc164dd502fd300103d879800040e51641691641586602c60b660b06ea8c16c004dd59809182c1baa0498b20b230593056375400f3001375860b260ac6ea811e602260ac6ea817298103d879800040d9159800980c00144cc896600260b80031325980099baf305c3059375460b860b26ea8c108c164dd500098109982d9809982c9baa05f4bd7044c96600266e1d20103059375400313259800982f800c4cc8966002609e60b86ea8006264b300130620018992cc004c138c178dd5000c4c8c8c8c8c8c8c8c8c8c8ca60026eb8c1b40066eb8c1b402e60da013306d0089836803cc96600260d600315980098151835000c5a260ba60d400283422c8360dd518368034c96600260d600315980098151835000c5a260ba60d400283422c8360dd51836802cc1b40126eb4c1b400e6eb4c1b4009222222222259800983c005c4cc0e4c1dc0504cc0e80204cc0e801c4cc0e80184cc14000c566002660769211643445020696e70757420697320696e636f7272656374005980099b8f375c60ee60e86ea8058dd7183b983a1baa01e899baf305d3074375402c60ba60e86ea807a294107144cc0ed24117434450206f757470757420697320696e636f72726563740098009bac3052307437540cb303c33076302c33076303c33076302e307437540f497ae0330764c103d87a80004bd7025eb826052660ec6078660ec64605a660ee60f0002660ee60f060f2002660ee60a660ea6ea807ccc1dcc0f8c1d4dd500f9983b9818983a9baa01f3307798009833983a1baa30303075375403f4c0103d87a8000a60103d879800041c8660ef3001306730743754604e60ea6ea807e980103d87a8000a60103d879800041c8660ee607e60ea6ea807ccc1dcc094c1d4dd500f9983b9817983a9baa01f3307730243075375403e97ae03074375402c97ae04bd704dd5982e983a1baa305d307437540394c0103d87a800040a114a0838a2c83a860da00260d800260d600260d400260d200260d000260ce00260cc00260ca00260c800260be6ea80062c82e0c1840062c82f8c174dd5000c5905a1bad305e00130323039305b3754608860b66ea800e2c82e0c168dd5000c590571980b982e182c9baa0013756602660b26ea812a2a660ae92011a3c65787065637465643e204d697865642076657273696f6e732e0016415860b600316416460b260ac6ea801e60026eb0c164c158dd5023cc020c158dd502e5300103d879800040d9159800980b80144c8cc07924012176657273696f6e5265636f7264206f757470757420697320696e636f72726563740098009bac303530573754091301f33059300f33059301f33059305a305b305b305b305b305b305b305b305b305b305b305b305737540ba97ae0330594c103d87a80004bd7025eb826018660b2601e660b260b460ae6ea8004cc164dd399198008009bac30413058375400444b30010018a5eb822660b66e9cc8cc170c174004cc170c174c168dd5182e982f000a5eb80dd6182e00099801001182e800a0b44bd7025eb826014604260ae6ea8176980103d87a8000402c60b260ac6ea801e2b300130160028a518a51414c829905320a6414c82988966002608c60ac6ea800a26464646464646464646465300130650019bae306500b9bad306500998328044c19401e60ca00d306500598328024dd69832801cc96600260c600315980098111831000c5a260aa60c400283022c8320dd5183280124444444444b3001307000b899818983780a0998148038998188030998190028998190020998190018992cc004c170006264b30013072001899819983880080c45906f18369baa00b8acc004c17c0062b3001306d37540170178b20dc8b20d441a860d66ea802a2c836860ca00260c800260c600260c400260c200260c000260be00260bc00260ba00260b800260ae6ea800a2c82a105220a43053375400a8a504130460a460a660a660a660a660a660a600314a0825888888c8c8cc00400401c896600200314a1159800992cc004c0100062b30013375e606660aa6ea800401e2b300133229800992cc004c11cc15cdd5000c4dd6982c182d9bab305b30583754003148001055182d000cdd58014dd7982d182d800c8966002609660b06ea8026266e2400400a2b30013371200200513371200466e0000520809bee028a50415882b1222259800801c566002600400d13300100448002294105844c96600266ebd3001014000305b0018acc004cc008014dd6982e182f9bab305c001898019ba630600048a50416515980099801002a4001130030078a50416482c8c17800d05c0dd3003194c0040066eacc0fcc158dd5001488cc168008cc168dd3000a5eb810011112cc00400a26600298103d87a80004bd6f7b63044c8cc896600266e452201000028acc004cdc7a4410000289980218099982e982d801a5eb80006266008980103d87a80000054161198008034006446600c004660be00a00280310581bae3058001305d003305b002416513375e603c60aa6ea800530103d87a80008a50414914a082922941052182b800c528c4cc008008c16000505120aa59800982018281baa004891919baf30563053375460ac60a66ea8008004c154c148dd5002c48c8cdd7982b18299baa00200130553052375400a8270966002942297adef6c6089982799bb03050304d37540026e98cc010dd7181b18269baa001480092f5bded8c0825114a0822914a082122941042452820842304830493049304930490018a504104446464660020020064464b30013375e008608e003130480018998018019826001208a304a001300c330460024bd7011192cc004c0d0006264b3001304a0018998061824800801c5904718229baa0038acc004c0dc006264b3001304a0018998059824800801c5904718229baa0038acc004c09000626464b3001304b0028024590481bae304900130453754007164108821104218219baa0024590370c0d4004c0d0004c0cc004c0c8004c0b4dd5001c5902a06644b300100180145660026056003133029302a001330299800a51a60103d87a8000a60103d8798000409097ae0801205040a026644b300100180145660026056003133029302a001330299800a50a6103d87a8000a60103d8798000409097ae0801205040a02a6604692130457870656374656420476f7620696e7075742065697468657220617320696e707574206f72207265662e20696e707574001698009bac300e3025375402d3028302537540574c0103d87980004015300100c981418129baa02ba60103d8798000401444464b30013018001899192cc004c0bc00a0091640b06eb8c0b4004c0a4dd5001c56600260360031323322598009818000c4cc024dd61817800912cc00400a00f19800804cc0c400a260026064004804902f45902d1bad302d001302e001302937540071640988130c09cdd500122a6603c921283c65787065637465643e20526571756972657320617574686564206578656375746520696e7075740016407444602730010029bae302430213754003375c601460426ea800500311119199119801001000912cc004006007132325980099b910060018acc004cdc7803000c4dd69813001401502344cc010010c0a800d0231bae30240013027001409464646600200200c44b3001001801c4c8c96600266e440200062b30013371e01000313756604e0050054091133004004302b00340906eb8c094004c0a00050260a5eb7bdb1805200080aa03e407c66002006603e60386ea8c07cc070dd50011bab301f30203020302030203020302030203020302000632330010010022259800800c5a264b30013375e6040603a6ea800402e2600c603a6ea8006266006006604200480d0c07c00501d1119802001119baf3020301d37546040603a6ea8c018c074dd50008011bac301c0034590120c040dd50019b87480022c8068601e00260146ea803e29344d95900701"
|
|
7812
|
+
};
|
|
7813
|
+
|
|
7814
|
+
// src/contracts/execute/scripts.ts
|
|
7815
|
+
var mkExecuteValidator = (params) => {
|
|
8210
7816
|
return {
|
|
8211
7817
|
type: "PlutusV3",
|
|
8212
|
-
script:
|
|
8213
|
-
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
|
|
7818
|
+
script: applySingleCborEncoding(
|
|
7819
|
+
applyParamsToScript13(_executeValidator.cborHex, [
|
|
7820
|
+
castExecuteParams(params)
|
|
7821
|
+
])
|
|
7822
|
+
)
|
|
7823
|
+
};
|
|
7824
|
+
};
|
|
7825
|
+
var mkExecuteValidatorFromSP = (params) => {
|
|
7826
|
+
return {
|
|
7827
|
+
type: "PlutusV3",
|
|
7828
|
+
script: applySingleCborEncoding(
|
|
7829
|
+
applyParamsToScript13(_executeValidator.cborHex, [
|
|
7830
|
+
castExecuteParams({
|
|
7831
|
+
govNFT: fromSystemParamsAssetLucid(params.govNFT),
|
|
7832
|
+
upgradeToken: fromSystemParamsAssetLucid(params.upgradeToken),
|
|
7833
|
+
iAssetToken: fromSystemParamsAssetLucid(params.iAssetToken),
|
|
7834
|
+
collateralAssetToken: fromSystemParamsAssetLucid(
|
|
7835
|
+
params.collateralAssetToken
|
|
7836
|
+
),
|
|
7837
|
+
stabilityPoolToken: fromSystemParamsAssetLucid(
|
|
7838
|
+
params.stabilityPoolToken
|
|
7839
|
+
),
|
|
7840
|
+
cdpCreatorToken: fromSystemParamsAssetLucid(params.cdpCreatorToken),
|
|
7841
|
+
cdpToken: fromSystemParamsAssetLucid(params.cdpToken),
|
|
7842
|
+
versionRecordToken: fromSystemParamsAssetLucid(
|
|
7843
|
+
params.versionRecordToken
|
|
7844
|
+
),
|
|
7845
|
+
iassetValHash: params.iassetValHash,
|
|
7846
|
+
cdpValHash: params.cdpValHash,
|
|
7847
|
+
sPoolValHash: params.sPoolValHash,
|
|
7848
|
+
versionRegistryValHash: params.versionRegistryValHash,
|
|
7849
|
+
treasuryValHash: params.treasuryValHash
|
|
7850
|
+
})
|
|
7851
|
+
])
|
|
7852
|
+
)
|
|
8226
7853
|
};
|
|
8227
7854
|
};
|
|
8228
7855
|
|
|
8229
|
-
// src/contracts/
|
|
8230
|
-
import {
|
|
7856
|
+
// src/contracts/price-oracle/types.ts
|
|
7857
|
+
import { Data as Data41 } from "@lucid-evolution/lucid";
|
|
7858
|
+
var PriceOracleParamsSchema = Data41.Object({
|
|
7859
|
+
owner: Data41.Bytes(),
|
|
7860
|
+
/** Milliseconds */
|
|
7861
|
+
biasTime: Data41.Integer(),
|
|
7862
|
+
/** Milliseconds */
|
|
7863
|
+
expirationPeriod: Data41.Integer()
|
|
7864
|
+
});
|
|
7865
|
+
var PriceOracleParams = PriceOracleParamsSchema;
|
|
7866
|
+
function castPriceOracleParams(params) {
|
|
7867
|
+
return Data41.castTo(params, PriceOracleParams);
|
|
7868
|
+
}
|
|
7869
|
+
|
|
7870
|
+
// src/contracts/stability-pool/queries.ts
|
|
7871
|
+
import { toHex as toHex11 } from "@lucid-evolution/lucid";
|
|
8231
7872
|
import {
|
|
8232
|
-
assetClassToUnit as
|
|
8233
|
-
assetClassValueOf as assetClassValueOf7,
|
|
8234
|
-
getRandomElement as getRandomElement2,
|
|
7873
|
+
assetClassToUnit as assetClassToUnit5,
|
|
8235
7874
|
matchSingle as matchSingle4
|
|
8236
7875
|
} from "@3rd-eye-labs/cardano-offchain-common";
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
7876
|
+
import { option as O16, array as A10, function as F19 } from "fp-ts";
|
|
7877
|
+
async function findStabilityPool(lucid, sysParams, iassetName) {
|
|
7878
|
+
const spUtxos = await lucid.utxosAtWithUnit(
|
|
7879
|
+
{ hash: sysParams.validatorHashes.stabilityPoolHash, type: "Script" },
|
|
7880
|
+
assetClassToUnit5(
|
|
7881
|
+
fromSystemParamsAsset(sysParams.stabilityPoolParams.stabilityPoolToken)
|
|
8242
7882
|
)
|
|
8243
7883
|
);
|
|
8244
|
-
}
|
|
8245
|
-
async function findAdminInterestCollectors(lucid, sysParams) {
|
|
8246
7884
|
return matchSingle4(
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
7885
|
+
F19.pipe(
|
|
7886
|
+
spUtxos.map(
|
|
7887
|
+
(utxo) => F19.pipe(
|
|
7888
|
+
O16.fromNullable(utxo.datum),
|
|
7889
|
+
O16.flatMap(parseStabilityPoolDatum),
|
|
7890
|
+
O16.flatMap((datum) => {
|
|
7891
|
+
if (toHex11(datum.iasset) == toHex11(iassetName)) {
|
|
7892
|
+
return O16.some({ utxo, datum });
|
|
7893
|
+
} else {
|
|
7894
|
+
return O16.none;
|
|
7895
|
+
}
|
|
7896
|
+
})
|
|
7897
|
+
)
|
|
8251
7898
|
),
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
7899
|
+
A10.compact
|
|
7900
|
+
),
|
|
7901
|
+
(res) => new Error(
|
|
7902
|
+
"Expected a single Stability Pool UTXO.: " + JSON.stringify(res)
|
|
7903
|
+
)
|
|
7904
|
+
);
|
|
7905
|
+
}
|
|
7906
|
+
async function findStabilityPoolAccount(lucid, sysParams, owner, iassetName) {
|
|
7907
|
+
const spUtxos = await lucid.utxosAt({
|
|
7908
|
+
hash: sysParams.validatorHashes.stabilityPoolHash,
|
|
7909
|
+
type: "Script"
|
|
7910
|
+
});
|
|
7911
|
+
return matchSingle4(
|
|
7912
|
+
F19.pipe(
|
|
7913
|
+
spUtxos.map(
|
|
7914
|
+
(utxo) => F19.pipe(
|
|
7915
|
+
O16.fromNullable(utxo.datum),
|
|
7916
|
+
O16.flatMap(parseAccountDatum),
|
|
7917
|
+
O16.flatMap((datum) => {
|
|
7918
|
+
if (toHex11(datum.iasset) == toHex11(iassetName) && toHex11(datum.owner) == owner) {
|
|
7919
|
+
return O16.some({ utxo, datum });
|
|
7920
|
+
} else {
|
|
7921
|
+
return O16.none;
|
|
7922
|
+
}
|
|
7923
|
+
})
|
|
8255
7924
|
)
|
|
8256
|
-
)
|
|
7925
|
+
),
|
|
7926
|
+
A10.compact
|
|
8257
7927
|
),
|
|
8258
|
-
(
|
|
7928
|
+
(res) => new Error("Expected a single Account UTXO.: " + JSON.stringify(res))
|
|
8259
7929
|
);
|
|
8260
7930
|
}
|
|
8261
|
-
async function
|
|
8262
|
-
const
|
|
8263
|
-
(
|
|
8264
|
-
|
|
7931
|
+
async function findE2s2sSnapshots(lucid, sysParams, iassetName) {
|
|
7932
|
+
const spUtxos = await lucid.utxosAtWithUnit(
|
|
7933
|
+
mkStabilityPoolAddr(lucid, sysParams),
|
|
7934
|
+
assetClassToUnit5(
|
|
8265
7935
|
fromSystemParamsAsset(
|
|
8266
|
-
sysParams.
|
|
7936
|
+
sysParams.stabilityPoolParams.snapshotEpochToScaleToSumToken
|
|
8267
7937
|
)
|
|
8268
7938
|
)
|
|
8269
7939
|
);
|
|
8270
|
-
return
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
7940
|
+
return F19.pipe(
|
|
7941
|
+
spUtxos.map(
|
|
7942
|
+
(utxo) => F19.pipe(
|
|
7943
|
+
O16.fromNullable(utxo.datum),
|
|
7944
|
+
O16.flatMap(parseSnapshotEpochToScaleToSumDatum),
|
|
7945
|
+
O16.flatMap((datum) => {
|
|
7946
|
+
if (toHex11(datum.iasset) == toHex11(iassetName)) {
|
|
7947
|
+
return O16.some({ utxo, datum });
|
|
7948
|
+
} else {
|
|
7949
|
+
return O16.none;
|
|
7950
|
+
}
|
|
7951
|
+
})
|
|
7952
|
+
)
|
|
7953
|
+
),
|
|
7954
|
+
A10.compact
|
|
8275
7955
|
);
|
|
8276
7956
|
}
|
|
8277
7957
|
|
|
8278
|
-
// src/contracts/
|
|
8279
|
-
import { Data as Data39 } from "@lucid-evolution/lucid";
|
|
8280
|
-
var VersionRecordTokenParamsSchema = Data39.Object({
|
|
8281
|
-
upgradeToken: AssetClassSchema2
|
|
8282
|
-
});
|
|
8283
|
-
var VersionRecordTokenParams = VersionRecordTokenParamsSchema;
|
|
8284
|
-
function castVersionRecordTokenParams(params) {
|
|
8285
|
-
return Data39.castTo(params, VersionRecordTokenParams);
|
|
8286
|
-
}
|
|
8287
|
-
|
|
8288
|
-
// src/contracts/version-registry/scripts.ts
|
|
7958
|
+
// src/contracts/stability-pool/transactions.ts
|
|
8289
7959
|
import {
|
|
8290
|
-
|
|
7960
|
+
fromText as fromText8,
|
|
7961
|
+
Data as Data42,
|
|
7962
|
+
fromHex as fromHex11,
|
|
7963
|
+
toHex as toHex12,
|
|
7964
|
+
addAssets as addAssets11,
|
|
7965
|
+
slotToUnixTime as slotToUnixTime9,
|
|
7966
|
+
credentialToAddress as credentialToAddress3
|
|
8291
7967
|
} from "@lucid-evolution/lucid";
|
|
8292
|
-
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8306
|
-
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
])
|
|
7968
|
+
import {
|
|
7969
|
+
adaAssetClass as adaAssetClass4,
|
|
7970
|
+
addressFromBech32 as addressFromBech322,
|
|
7971
|
+
addressToBech32 as addressToBech322,
|
|
7972
|
+
assetClassValueOf as assetClassValueOf8,
|
|
7973
|
+
estimateUtxoMinLovelace as estimateUtxoMinLovelace3,
|
|
7974
|
+
lovelacesAmt as lovelacesAmt2,
|
|
7975
|
+
matchSingle as matchSingle5,
|
|
7976
|
+
mkAssetsOf as mkAssetsOf8,
|
|
7977
|
+
mkLovelacesOf as mkLovelacesOf5,
|
|
7978
|
+
negateAssets as negateAssets4
|
|
7979
|
+
} from "@3rd-eye-labs/cardano-offchain-common";
|
|
7980
|
+
import { match as match17, P as P17 } from "ts-pattern";
|
|
7981
|
+
async function requestSpAccountCreation(assetAscii, amount, sysParams, lucid) {
|
|
7982
|
+
const [pkh, _skh] = await addrDetails(lucid);
|
|
7983
|
+
const iasset = fromHex11(fromText8(assetAscii));
|
|
7984
|
+
const iassetAssetClass = {
|
|
7985
|
+
currencySymbol: fromHex11(
|
|
7986
|
+
sysParams.stabilityPoolParams.assetSymbol.unCurrencySymbol
|
|
7987
|
+
),
|
|
7988
|
+
tokenName: iasset
|
|
8314
7989
|
};
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
7990
|
+
const datum = {
|
|
7991
|
+
owner: fromHex11(pkh.hash),
|
|
7992
|
+
iasset,
|
|
7993
|
+
state: { ...initSpState, depositVal: mkSPInteger(amount) },
|
|
7994
|
+
assetSums: [],
|
|
7995
|
+
request: "Create",
|
|
7996
|
+
lastRequestProcessingTime: 0n
|
|
8320
7997
|
};
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
|
|
8327
|
-
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
cborHex: "59225f59225c010100229800aba4aba2aba1aba0aab9faab9eaab9dab9cab9a488888888a60022a660049201293c65787065637465643e2045787065637473206f6e6c792073696e676c65206f776e206f757470757400168a998012493b3c65787065637465643e20416c6c20747265617375727920696e70757473206d75737420757365207468652072696768742072656465656d65722e00168a99801249303c65787065637465643e2048617320746f207265666572656e63652073696e676c65206578656375746520696e70757400168a99801249333c65787065637465643e20457870656374732073696e676c65206f757470757420746f207769746864726177616c206164647200168a998012492d3c65787065637465643e20457870656374732073696e676c6520696e7075742066726f6d20747265617375727900164888896600264653001300e00198071807800cdc3a4005300e00248889660026004601c6ea800e33001300f3754007370e90004dc3a4009370e90034dc3a401091111194c00488c9660026010003159800980c1baa00380145901945660026016003159800980c1baa0038014590194566002600e003159800980c1baa0038014590194566002600c003159800980c1baa0038014590194566002600a0031323232329800980f800cdd6980f801cdd6980f8012444b3001302300489980598110038acc004c03cc078dd5001c4c8c8cc8966002604e00700d8b2048375a60480026eb8c090008c090004c07cdd5001c5901c4590200c07c004c078004c074004c060dd5001c56600266e1d200a0018acc004c060dd5001c00a2c80ca2c80a9015202a405480a9015180b1baa002980c180c8034c0600192223300300d198009180e180e800c888c8cc88cc0080080048966002003003899192cc004cdc8803000c56600266e3c01800626eb4c08000a00a80ea266008008604800680e8dd7180f0009810800a03e3232330010010062259800800c00e26464b30013372201000315980099b8f00800189bab3021002802a03c8998020021812801a03c375c603e0026044002810052f5bded8c029000488c8cc00400400c896600200314bd7044cc8966002600a00513302000233004004001899802002000a036301f00130200014075371090004966002601060306ea80062603860326ea80062c80b246038603a603a00322323300100100322330030013002002980b9baa00d912cc004006200315330180021001405d2598009804980c1baa001891919baf301e301b3754603c60366ea8008004c074c068dd5001448c8cdd7980f180d9baa002001301d301a375400480b26e9520009180e180e980e980e800cdd7a6103d87a800091111919800800802912cc00400626604066ec0dd48029ba60044bd6f7b63044c8cc896600266e4402000a2b30013371e010005198008044dd59810801c01e46604866ec0dd48049ba60010028800a00c89981199bb037520106e9801c01101e44cc08c00ccc01401400501e1bae301e00130230023021001407d222232330010010052259800800c4cc080cdd81ba9005375000897adef6c6089919912cc004cdc8804001456600266e3c02000a330010089bad3021003803c8cc090cdd81ba9009375000200510014019133023337606ea4020dd4003802203c89981180199802802800a03c375c603c0026046004604200280fa244444b30013370e00866e052000003800c4c008cdc0002001a0349baf4c0101a0009111919800800802112cc004006200913298009bae301d0019bab301e00199801801981100120083020001407922232330010010042259800800c40122653001375c603a003375a603c0033300300330220024010604000280f244b3001300a30193754005132323322598009811001c0162c80f8dd6980f8009bad301f002301f001301a375400516405d2232598009805800c4c8c96600260420050048b203c375c603e00260366ea800e2b3001300e0018acc004c06cdd5001c00a2c80e22c80c1018180c9baa00291192cc004c02c00626464b3001302100280245901e1bae301f001301b37540071598009807000c4c8c96600260420050048b203c375c603e00260366ea800e2c80c1018180c9baa002911980e19bb037520046ea00052f5bded8c122232330010010042259800800c4012266006604000266004004604200280f26e9520024888888888888888888888888a600244646600200200644b30010018b44c96600266ebcc0e4c0d8dd500080244c078c0d8dd5000c4cc00c00cc0e8009033181c000a06c911191980d80211801180f181b1baa00159800981218199baa0018918144c004dd5980e981a9baa0019bae303830353754007375c603a606a6ea800d01c448c06a60026eacc074c0d4dd5000cdd7181c181a9baa0039bae301d3035375400680e10314888cc8a600264b30013027303637540031375a606e60746eacc0e8c0dcdd5000c5200040d060720033756005375e6072607400322598009815981b9baa005899b890010028acc004cdc480080144cdc480119b80001482026fb80a2941035206a4888966002007159800980100344cc00401120008a5040dd1325980099baf4c01014000303a0018acc004cc008014dd6981d981f1bab303b001898019ba6303f0048a5040e115980099801002a4001130030078a5040e081c0c0f400d03b0dd3001194c004006009223303900233039374c00297ae04004444b3001002899800a6103d87a80004bd6f7b63044c8cc896600266e452201000028acc004cdc7a44100002899802180c1981e181d001a5eb80006266008980103d87a800000540dd198008034006446600c0046607c00a00280310371bae3037001303c003303a00240e1223301900223375e606e60686ea8c0dcc0d0dd5180e181a1baa00100291194c0040060070024004444b30010028800c4ca6002009303b003cc00400a6eb8c0d80066eacc0dc0064444464b30013015374c00300289801800a07432329800800c01a00a80088896600200510018994c004012608a00798008014dd71820000cdd69820800c01501b200830430024104a02a8091004181c801206e911980c8011809000ca60020034bd70488a60020050019111981d1ba73303a375200c660746ea400ccc0e8dd400125eb8000500b201291192cc004c090006264b30013039001899805181c000801c59036181a1baa0038acc004c09c006264b30013039001899810981c000801c59036181a1baa0038acc004c08c00626464b3001303a0028024590371bae3038001303437540071640c4818903118191baa002911192cc004c09400626464b3001303b0028024590381bae3039001303537540071598009814000c4c8cc8966002607800313301a3758607600244b3001002803c66002013303d00289800981f001201240ed1640e46eb4c0e4004c0e8004c0d4dd5001c590322064303337540052232598009812000c4c9660026072003132598009813181a9baa00189919192cc004c0f400a26644b3001302b303a3754005132323259800982100144cc044c10400c4c966002605e003132598009822000c4c8c9660026064003132598009823800c4cc058c1180040262c8220c108dd50014566002606a003132323298009bad30480019bad30480039bad3048002488966002609800900e8b20921824000982380098211baa0028b207e40fc60806ea8004c10c0062c8208c0fcdd500145660026064003159800981f9baa002802c5904045903c2078303d37540031640fc6080002608000260766ea800a2c81c0c0f000c4cc06c00489660020050098992cc004c0b0c0ecdd5000c4c8c8ca60026eb4c1080066eb8c10800e6eb8c10800922259800982300244c020c1180262c82186084002608200260786ea80062c81c8c0f800903c45903a1bac303b001303b001303637540031640cc60700031640d860686ea800e2b300130270018acc004c0d0dd5001c00a2c81aa2c818903118191baa00291112cc004c094006200919800802400e6600e00400322222325980098099ba600180144c00c0050384c00401200f006a809a0284040819122222222222980091111191919800800803912cc00400629422b300132598009802000c56600266ebcc0a0c114dd5000803c56600330013756605a608a6ea800600d00540491302130223045375400314a0821229410424528208430470018a518998010011824000a08241146040009222225980099810002002c56600266ebcc090c104dd5002801c56600330013756605260826ea801600500140391301d301e3041375400b14a081f2294103e4528207c9801801ca60020034bd6f7b630488c8ca6002007375c6088005375c6088003375a6088608a0028030c110004c0fcdd5001201c48888c9660026062045132323259800800c0f22b300130480018992cc004c12400626464b3001303730463754003132323232323298009828000cdd698280024dd69828001cdd6982800124444b3001305500589919809182a80509980c0028acc004c108c144dd5002c4c8cc896600200304e8992cc004c16800a2b300133036491205769746864726177616c2076616c75652063616e6e6f7420626520656d70747900980098171ba6003a50a51414d1598009981b2481245472656173757279207769746864726177616c206f757470757420696e636f7272656374009800800cc098cc160c164c158dd500225eb8266e95200433058374e660b098011a5818496e6469676f54726561737572795769746864726177616c003305830593056375402297ae04bd70400e980103d87a800040651325980098179ba60018a518acc004c8cc004004c084008896600200314a115980099b88375a60b860ba60ba6eb0c17000520008a51899801001182e800a0ac416915330554901224e6f7420656e6f7567682066756e647320696e20747265617375727920696e707574001689981ba4811c5472656173757279206f757470757420697320696e636f72726563740098009bac303a3057375409330273305930353305901533059303a305737540bc97ae04bd70530107d87b9fd87980ff00800d300103d87a8000406c82a1054198109bab303e3056375402a646600200200844b30010018a5eb7bdb182264660b666ec0c160004dd319198008009bab305a0022259800800c52f5bded8c11323305e3376060b60026ea0cdc0a40006eb4c170004cc00c00cc180008c17800505c19801801982e801182d800a0b28a50414d14a0829a09e82b8c160005056180a1bac303b305337540026603a6eb0c0d8c14cdd502298119982a982b18299baa0014bd70182a98291baa0058b209e375a60a80151641483050001304f001304e001304d001304c0013047375400316411060546052608c6ea8c0b8c118dd50009824000c590464c004dd6182398221baa036982398221baa04ba60103d8798000404903c41148228cc03cdd6182318219baa035001304530423754608a60846ea8004cc040dd6182218209baa03302a8cc004dc0240052304530463046304630463046304630463046304600194c00400691100a4410040a5371090012444464b3001303902789919912cc00400608713259800982700144c966002607660946ea80062646464646465300130540019bad30540049bad30540039bad3054002488896600260b200b13233016305900a13301c005132598009823982b1baa006899192cc004ca6002003375860ba60b46ea81326eacc060c168dd5026528a002222259800801c400626644b30013052305e375460c460be6ea8c188c17cdd51823982f9baa0028994c00401e005375660c660c8003325980099baf30643061375460c860c26ea8c124c184dd500200dc566002003159800982a18301baa0018acc004c184dd5000c40160b883120b882f20b905c82e41710664401505e1831800a00e32330010010052259800800c5a265300130610019831000cc1980092225980099baf00330353306730683065375401097ae0899833801198339ba60014bd7044cc0180180050620c19000506246600200d001802400d00620b83060003306100341791598009981ca493d43616e6e6f742062652075736564207768656e207769746864726177616c2076616c7565206861732073696e676c65206173736574206f72206e6f6e650030150018acc004cc0e52412e43616e6e6f742062652075736564207769746820617373657473206e6f7420746f2062652077697468647261776e003370e6028006b3001303e30160028800c4c0600050564566002660729201374f6e65206f75747075742068617320746f2068617665207468652076616c7565206f662074726561737572795f7769746864726177616c0098009bac303c3059375409730293305b0124bd70530107d87b9fd87980ff008015300103d87a80004075133039490123416c6c207370656e742076616c75652068617320746f2062652070616964206261636b009800cc004dd6181e182c9baa04ba5eb7bdb18244b30013375e60bc60b66ea8c178c16cdd500100ac56600266ebcc0f8c16cdd500126107d87b9fd87980ff008998130009bab3043305b375400515330594912f3c65787065637465643e20416c6c206f776e206f757470757473206d757374206861766520766f696420646174756d001641611001416081520074c103d87a8000409914a082b22941056452820ac8a504158602600260306eb0c0fcc15cdd5182d182b9baa0068b20a898009bac3059305637540914bd6f7b6304896600266ebcc16cc160dd5182d982c1baa3040305837540040251330230013756608060b06ea8c100c160dd500144005055204e375a60b001516415830540013053001305200130510013050001304b3754003164120605c605a60946ea8c0c8c128dd5000c11104b1826000a09430253304900133049302a3047375409c97ae098009bac302f30473754073304a3047375409d4c0103d879800040546092608c6ea8c124c118dd51980a9bac30493046375407005f1323259800981b814c4c8ca600260506609800266098605a60946ea81452f5c1232330010010022259800800c52f5bded8c113233225980099b91489000028acc004cdc7a441000028800c401104d44cc14800ccc01401400504d1bae304d0013052002305000141393756606460946ea80092225980098289980c9bac3050304d375407e009132325980099817a495d416c6c20696e70757473206d7573742068617665206d6f7265207468616e2031206e6f6e2d414441206173736574206f722031206e6f6e2d41444120617373657420616e64206d6f7265207468616e20327820414441206275666665720032598009806000c528c566002608600313371090405b6e0298068024528209a41346014600800715980099817a492f416c6c207468652076616c7565206e6565647320746f2062652073656e74206261636b20746f207472656173757279009800800c00e98103d87a8000407113302f49012354686572652063616e2062652031206f75747075742077697468206f6e6c7920414441003371266e04c020008dd698294c004c010006660a2981010000330513032304f375408297ae09114c00400a0032223259800cc004c164006604c660b001897ae0a60107d87b9fd87980ff00acc004c11800e297adef6c6089982c19bb0375200e6e98cc0a001000d2f5bded8c0829a98103d879800040651330583750602a6eb4c164008cc160dd3982d000a5eb822a660a8921593c65787065637465643e2045616368206e6f6e204144412061737365742069732073657061726174656420696e746f20697473206f776e20636f6e74696e75696e67206f7574707574207769746820766f696420646174756d0016414c6eb0c160c164005028204c4800a294104c452820989800800d2f5bded8c1223301b0013756607060a06ea800901f1980b9bac3030304d375407e603a6609e00697ae08b209c182618249baa304c304937540026602e6eb0c12cc120dd501d018c566002606c05313233229800cc00400697adef6c60911980c0009bab3035304d3754606a609a6ea800901c4cc054dd6181718259baa03d301b3304d0024bd70488c8cc00400400c896600200314a315980098019829000c4cc008008c14c006294104c20a048896600200504a8992cc004c14c00e2b30013302f4912d416c6c206f776e20696e70757473206861766520746f20757365207468652072696768742072656465656d657200330020052323303c00113375e002980103d87c80003232330010013756602060a46ea811088c96600266ebc010c14c006260a80031330030033058002414460ac0026040660a460a660a06ea80052f5c115980099817a4812554686572652068617320746f206265206174206c656173742032206f776e20696e7075747300300b30080058acc004cc0bd2411c5472656173757279206f757470757420697320696e636f7272656374009800800cc07ccc1440192f5c14c107d87b9fd87980ff008025300103d87a8000404913302f490132416c6c20696e70757473206861766520746f20636f6e7461696e207468652073616d65206d657267696e6720617373657473003233003006232330010010032259800800c528c56600264607330013756607860a86ea8c0f0c150dd50024dd7182b800cdd7182b982c000a076375860ac00313300200230570018a50414082a0c060012294104c452820988a50413104b414060a20048278604e6609600266096605860926ea81412f5c06602a6eb0c130c124dd501d800982598241baa304b304837546602e6eb0c12cc120dd501d018c566002606a053132323298009bad304e00198271827800ccc068dd6182718259baa03d0349827001cdd698270012444446644b30013303249116546f6f206d616e7920617373657420636c61737365730033712601a004900245660026606492011c436f6c6c656374656420616d6f756e7420697320706f7369746976650059800981b801c4cdc4a400000f14a0827a26606492011c5472656173757279206f757470757420697320696e636f72726563740098009bac30353052375408930223305430303305430553052375460aa60a46ea8014cc150c0d4c148dd502ca5eb812f5c13374a90021982a18181982a18181982a01da5eb80cc1500192f5c097ae0801530103d87a8000405914a0827a294104f4c00660026eacc0e0c140dd5001cdd7182998281baa0029bae303830503754005001405548900a44100802a02a3233001001375860a860a26ea810c896600266ebcc154c148dd5182a8008034526899801001182b000a09e1827000982680098241baa03d89919912cc004c0f8c128dd5000c4cc896600260a200313259800981f18269baa00189919912cc004c1540062660666eb0c150004896600200513259800982218299baa0018991925159800991980080098069bab3059305a305a305a305a3056375409044b30013371e6eb8c16800400e294626600400460b600282a22934590521bae30573054375400316414464660020026eb0c0f0c150dd5003912cc0040062980103d87a80008992cc006600260640034a14a2829a2003133003003305a002414c64b30013371e6eb8c16400402e26068660b060b260b400297ae08a6103d87a8000414c6eb0c16000505644c8c8cc896600260b600713005305b0068b20b0375c60b00026eb8c160008c160004dd6182b00120a88b20a4375a60a400260a6002609c6ea80062c8258c0c4c0c0c134dd5181a98269baa30500018b209c375c609c60966ea800660026eb0c0ccc12cdd501ecc0ccc12cdd5029530103d879800040651641206002002609860926ea8c130c124dd51980c1bac304c3049375407606444b30010018a5eb822660986092609a00266004004609c0028259045208a4114600200244b30010018a40011300733002002304c001412482188c8cc0040040088966002003148002266453001375c6092005375660940052259800800c400e2646644601c6600a00a60a60086eb8c130004dd698268009827800a09a4888cc0040040086096002660040046098002824881f088c9660026066003132598009824000c4c966002606a60886ea800626464646464653001304e0019bae304e00698270024c13800e609c004911112cc004c15001a26604a60a601426604a00626604a00426604a00226604a00a01f164144304e001304d001304c001304b001304a00130453754003164108608e00316411460866ea800e2b300130360018992cc004c120006264b3001303530443754003132323232323298009827000cdd718270034c138012609c007304e0024888896600260a800d133025305300a13302500313302500213302500113302500500f8b20a21827000982680098260009825800982500098229baa0018b208430470018b208a304337540071598009819000c4c966002609000313259800981a98221baa00189919191919191919194c004dd69828800cdd71828804cdd69828803cc14401a60a200b30510049828801cc1440092222222259800982d004c4cc108c1640404cc0780144cc1080104cc0ac00c4cc0ac0084cc0ac0040562c82b860a200260a0002609e002609c002609a002609800260960026094002608a6ea80062c8210c11c0062c8228c10cdd5001c5660026062003132598009824000c4c966002606a60886ea800626464646464646464653001375a60a2003375c60a2013375a60a200f30510069828802cc14401260a200730510024888888896600260b4013133042305901013301e00513304200413302b00313302b00213302b0010158b20ae1828800982800098278009827000982680098260009825800982500098229baa0018b208430470018b208a304337540071598009818000c4c966002609000313259800981a98221baa00189919191919191919194c004dd71828800cdd71828804cc14401e60a200d305100598288024dd69828801cdd69828801244444444b3001305a009899821182c80809981580309981580289981580209981500180ac590570c144004c140004c13c004c138004c134004c130004c12c004c128004c114dd5000c590421823800c5904518219baa0038acc004cdc3a4014003132598009824000c4c966002606a60886ea8006264646464646464646464653001375c60a6003375c60a6017305300998298044c14c01e64b300130510018acc004cdc4a400860a000316898221828000a09c8b20a4375460a600d32598009828800c56600266e25200430500018b44c110c14000504e4590521baa305300598298024dd69829801cdd6982980124444444444b3001305e00b899823182e80a09981780409981780389981780309981700180cc5905b0c14c004c148004c144004c140004c13c004c138004c134004c130004c12c004c128004c114dd5000c590421823800c5904518219baa0038acc004cdc3a4018003132598009824000c4c966002606a60886ea80062646464646464646464646465300130540019bad305400c9bad305400b9bad305400a9bad30540099bad30540089bad30540079bad30540069bad30540059bad30540049bad30540024888888888896600260c0019133030305f00e13301e00b01b8b20ba182a000982980098290009828800982800098278009827000982680098260009825800982500098229baa0018b208430470018b208a3043375400715980099b8748038006264b300130480018992cc004c0d4c110dd5000c4c8cc8966002609800313302a3758609600244b3001002804c4c8cc896600260a200313259800981f18269baa001899192cc004c15000a2600e60a80111641446eb8c148004c138dd5000c5904b1828000c5904e1bae304e001304f0013758609a004825a2c8248dd69824800982500098229baa0018b208430470018b208a3043375400715980099b874804000626464b300130490028024590461bae30470013043375400716410082010402080410082010402080410060826ea800808966002600c602a6ea800a264646644b3001301e003802c5901b1bae301b001375c60360046036002602c6ea800a2c8099164030300e0013009375401f149a26cac80301"
|
|
8331
|
-
|
|
8332
|
-
|
|
8333
|
-
|
|
8334
|
-
|
|
8335
|
-
|
|
8336
|
-
|
|
8337
|
-
|
|
8338
|
-
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
7998
|
+
return lucid.newTx().pay.ToContract(
|
|
7999
|
+
credentialToAddress3(
|
|
8000
|
+
lucid.config().network,
|
|
8001
|
+
{
|
|
8002
|
+
hash: sysParams.validatorHashes.stabilityPoolHash,
|
|
8003
|
+
type: "Script"
|
|
8004
|
+
},
|
|
8005
|
+
sysParams.stabilityPoolParams.stakeCredential != null ? fromSysParamsCredential(
|
|
8006
|
+
sysParams.stabilityPoolParams.stakeCredential
|
|
8007
|
+
) : void 0
|
|
8008
|
+
),
|
|
8009
|
+
{
|
|
8010
|
+
kind: "inline",
|
|
8011
|
+
value: serialiseStabilityPoolDatum({ Account: datum })
|
|
8012
|
+
},
|
|
8013
|
+
addAssets11(
|
|
8014
|
+
mkAssetsOf8(iassetAssetClass, amount),
|
|
8015
|
+
mkLovelacesOf5(
|
|
8016
|
+
// TODO: Calculate a more accurate amount to just cover costs.
|
|
8017
|
+
// This should cover the account creation fee,
|
|
8018
|
+
// the minimum ADA for the account UTxO and the transaction fee.
|
|
8019
|
+
BigInt(sysParams.stabilityPoolParams.accountCreateFeeLovelaces) + 3000000n
|
|
8020
|
+
)
|
|
8021
|
+
)
|
|
8022
|
+
).addSignerKey(pkh.hash);
|
|
8023
|
+
}
|
|
8024
|
+
async function requestSpAccountAdjustment(amount, accountUtxo, sysParams, lucid) {
|
|
8025
|
+
const myAddress = await lucid.wallet().address();
|
|
8026
|
+
const stabilityPoolScriptRef = matchSingle5(
|
|
8027
|
+
await lucid.utxosByOutRef([
|
|
8028
|
+
fromSystemParamsScriptRef(
|
|
8029
|
+
sysParams.scriptReferences.stabilityPoolValidatorRef
|
|
8030
|
+
)
|
|
8031
|
+
]),
|
|
8032
|
+
(_) => new Error("Expected a single stability pool Ref Script UTXO")
|
|
8033
|
+
);
|
|
8034
|
+
const oldAccountDatum = parseAccountDatumOrThrow(
|
|
8035
|
+
getInlineDatumOrThrow(accountUtxo)
|
|
8036
|
+
);
|
|
8037
|
+
const newAccountDatum = {
|
|
8038
|
+
...oldAccountDatum,
|
|
8039
|
+
request: {
|
|
8040
|
+
Adjust: {
|
|
8041
|
+
amount,
|
|
8042
|
+
outputAddress: addressFromBech322(myAddress)
|
|
8043
|
+
}
|
|
8044
|
+
}
|
|
8045
|
+
};
|
|
8046
|
+
return lucid.newTx().readFrom([stabilityPoolScriptRef]).collectFrom(
|
|
8047
|
+
[accountUtxo],
|
|
8048
|
+
serialiseStabilityPoolRedeemer({
|
|
8049
|
+
RequestAction: {
|
|
8050
|
+
Adjust: {
|
|
8051
|
+
amount,
|
|
8052
|
+
outputAddress: addressFromBech322(myAddress)
|
|
8053
|
+
}
|
|
8054
|
+
}
|
|
8055
|
+
})
|
|
8056
|
+
).pay.ToContract(
|
|
8057
|
+
accountUtxo.address,
|
|
8058
|
+
{
|
|
8059
|
+
kind: "inline",
|
|
8060
|
+
value: serialiseStabilityPoolDatum({
|
|
8061
|
+
Account: newAccountDatum
|
|
8356
8062
|
})
|
|
8357
|
-
|
|
8063
|
+
},
|
|
8064
|
+
addAssets11(
|
|
8065
|
+
mkLovelacesOf5(
|
|
8066
|
+
// TODO: Calculate a more accurate amount to just cover costs.
|
|
8067
|
+
// This should cover the minimum ADA for 2 UTxOs (account and
|
|
8068
|
+
// rewards withdrawal) and the transaction fee.
|
|
8069
|
+
5000000n
|
|
8070
|
+
),
|
|
8071
|
+
mkAssetsOf8(
|
|
8072
|
+
fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
|
|
8073
|
+
1n
|
|
8074
|
+
),
|
|
8075
|
+
amount > 0n ? mkAssetsOf8(
|
|
8076
|
+
{
|
|
8077
|
+
currencySymbol: fromHex11(
|
|
8078
|
+
sysParams.stabilityPoolParams.assetSymbol.unCurrencySymbol
|
|
8079
|
+
),
|
|
8080
|
+
tokenName: oldAccountDatum.iasset
|
|
8081
|
+
},
|
|
8082
|
+
amount
|
|
8083
|
+
) : {}
|
|
8084
|
+
)
|
|
8085
|
+
).addSignerKey(toHex12(oldAccountDatum.owner));
|
|
8086
|
+
}
|
|
8087
|
+
async function requestSpAccountClosure(accountUtxo, sysParams, lucid, maxTxFee = BASE_MAX_TX_FEE) {
|
|
8088
|
+
const myAddress = await lucid.wallet().address();
|
|
8089
|
+
const stabilityPoolScriptRef = matchSingle5(
|
|
8090
|
+
await lucid.utxosByOutRef([
|
|
8091
|
+
fromSystemParamsScriptRef(
|
|
8092
|
+
sysParams.scriptReferences.stabilityPoolValidatorRef
|
|
8093
|
+
)
|
|
8094
|
+
]),
|
|
8095
|
+
(_) => new Error("Expected a single stability pool Ref Script UTXO")
|
|
8096
|
+
);
|
|
8097
|
+
const request = {
|
|
8098
|
+
Close: {
|
|
8099
|
+
outputAddress: addressFromBech322(myAddress),
|
|
8100
|
+
maxTxFee
|
|
8101
|
+
}
|
|
8358
8102
|
};
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8103
|
+
const oldAccountDatum = parseAccountDatumOrThrow(
|
|
8104
|
+
getInlineDatumOrThrow(accountUtxo)
|
|
8105
|
+
);
|
|
8106
|
+
const newAccountDatum = {
|
|
8107
|
+
...oldAccountDatum,
|
|
8108
|
+
request
|
|
8109
|
+
};
|
|
8110
|
+
return lucid.newTx().readFrom([stabilityPoolScriptRef]).collectFrom(
|
|
8111
|
+
[accountUtxo],
|
|
8112
|
+
serialiseStabilityPoolRedeemer({ RequestAction: request })
|
|
8113
|
+
).pay.ToContract(
|
|
8114
|
+
accountUtxo.address,
|
|
8115
|
+
{
|
|
8116
|
+
kind: "inline",
|
|
8117
|
+
value: serialiseStabilityPoolDatum({ Account: newAccountDatum })
|
|
8118
|
+
},
|
|
8119
|
+
addAssets11(
|
|
8120
|
+
mkLovelacesOf5(
|
|
8121
|
+
// TODO: Calculate a more accurate amount to just cover costs.
|
|
8122
|
+
// This should cover the minimum ADA for the rewards UTxO and the transaction fee.
|
|
8123
|
+
3000000n
|
|
8124
|
+
),
|
|
8125
|
+
mkAssetsOf8(
|
|
8126
|
+
fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
|
|
8127
|
+
1n
|
|
8128
|
+
)
|
|
8129
|
+
)
|
|
8130
|
+
).addSignerKey(toHex12(oldAccountDatum.owner));
|
|
8131
|
+
}
|
|
8132
|
+
async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid, currentSlot, txFee) {
|
|
8133
|
+
const network = lucid.config().network;
|
|
8134
|
+
const currentTime = BigInt(slotToUnixTime9(network, currentSlot));
|
|
8135
|
+
const stabilityPoolScriptRef = matchSingle5(
|
|
8136
|
+
await lucid.utxosByOutRef([
|
|
8137
|
+
fromSystemParamsScriptRef(
|
|
8138
|
+
sysParams.scriptReferences.stabilityPoolValidatorRef
|
|
8139
|
+
)
|
|
8140
|
+
]),
|
|
8141
|
+
(_) => new Error("Expected a single stability pool Ref Script UTXO")
|
|
8142
|
+
);
|
|
8143
|
+
const accountDatum = parseAccountDatumOrThrow(
|
|
8144
|
+
getInlineDatumOrThrow(accountUtxo)
|
|
8145
|
+
);
|
|
8146
|
+
const stabilityPoolDatum = parseStabilityPoolDatumOrThrow(
|
|
8147
|
+
getInlineDatumOrThrow(stabilityPoolUtxo)
|
|
8148
|
+
);
|
|
8149
|
+
const baseRefInputs = [iAssetUtxo, stabilityPoolScriptRef];
|
|
8150
|
+
const validFrom = slotToUnixTime9(network, currentSlot - 1);
|
|
8151
|
+
const tx = lucid.newTx().validFrom(validFrom).validTo(validFrom + sysParams.stabilityPoolParams.accountProcessingBiasMs).readFrom(baseRefInputs).collectFrom([stabilityPoolUtxo], {
|
|
8152
|
+
kind: "selected",
|
|
8153
|
+
inputs: [stabilityPoolUtxo, accountUtxo],
|
|
8154
|
+
makeRedeemer: (indices) => serialiseStabilityPoolRedeemer({
|
|
8155
|
+
ProcessRequestPool: {
|
|
8156
|
+
poolInputIdx: indices[0],
|
|
8157
|
+
accountInputIdx: indices[1]
|
|
8158
|
+
}
|
|
8159
|
+
})
|
|
8372
8160
|
});
|
|
8161
|
+
if (!accountDatum.request) throw new Error("Account Request is null");
|
|
8162
|
+
const iassetAssetClass = {
|
|
8163
|
+
currencySymbol: fromHex11(
|
|
8164
|
+
sysParams.stabilityPoolParams.assetSymbol.unCurrencySymbol
|
|
8165
|
+
),
|
|
8166
|
+
tokenName: stabilityPoolDatum.iasset
|
|
8167
|
+
};
|
|
8168
|
+
await match17(accountDatum.request).with("Create", async (_) => {
|
|
8169
|
+
const accountTokenScriptRef = matchSingle5(
|
|
8170
|
+
await lucid.utxosByOutRef([
|
|
8171
|
+
fromSystemParamsScriptRef(
|
|
8172
|
+
sysParams.scriptReferences.authTokenPolicies.accountTokenRef
|
|
8173
|
+
)
|
|
8174
|
+
]),
|
|
8175
|
+
(_2) => new Error("Expected a single cdp auth token policy Ref Script UTXO")
|
|
8176
|
+
);
|
|
8177
|
+
const requestDepositAmt = assetClassValueOf8(
|
|
8178
|
+
accountUtxo.assets,
|
|
8179
|
+
iassetAssetClass
|
|
8180
|
+
);
|
|
8181
|
+
const poolAddr = credentialToAddress3(
|
|
8182
|
+
lucid.config().network,
|
|
8183
|
+
{
|
|
8184
|
+
hash: sysParams.validatorHashes.stabilityPoolHash,
|
|
8185
|
+
type: "Script"
|
|
8186
|
+
},
|
|
8187
|
+
sysParams.stabilityPoolParams.stakeCredential != null ? fromSysParamsCredential(
|
|
8188
|
+
sysParams.stabilityPoolParams.stakeCredential
|
|
8189
|
+
) : void 0
|
|
8190
|
+
);
|
|
8191
|
+
const accountOutputAdaAmt = lovelacesAmt2(accountUtxo.assets) - BigInt(sysParams.stabilityPoolParams.accountCreateFeeLovelaces) - txFee;
|
|
8192
|
+
const accountTokenVal = mkAssetsOf8(
|
|
8193
|
+
fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
|
|
8194
|
+
1n
|
|
8195
|
+
);
|
|
8196
|
+
const accountOutputDatum = serialiseStabilityPoolDatum({
|
|
8197
|
+
Account: {
|
|
8198
|
+
owner: accountDatum.owner,
|
|
8199
|
+
iasset: stabilityPoolDatum.iasset,
|
|
8200
|
+
state: {
|
|
8201
|
+
...stabilityPoolDatum.state,
|
|
8202
|
+
depositVal: mkSPInteger(requestDepositAmt)
|
|
8203
|
+
},
|
|
8204
|
+
assetSums: stabilityPoolDatum.assetStates.map(([key, val]) => [
|
|
8205
|
+
key,
|
|
8206
|
+
val.currentSumVal
|
|
8207
|
+
]),
|
|
8208
|
+
request: null,
|
|
8209
|
+
lastRequestProcessingTime: currentTime
|
|
8210
|
+
}
|
|
8211
|
+
});
|
|
8212
|
+
const accountOutMinUtxoLovelace = estimateUtxoMinLovelace3(
|
|
8213
|
+
lucid.config().protocolParameters,
|
|
8214
|
+
poolAddr,
|
|
8215
|
+
accountTokenVal,
|
|
8216
|
+
{ InlineDatum: { datum: accountOutputDatum } }
|
|
8217
|
+
);
|
|
8218
|
+
if (accountOutputAdaAmt < accountOutMinUtxoLovelace) {
|
|
8219
|
+
throw new Error("Request doesn't have enough ADA to be processed.");
|
|
8220
|
+
}
|
|
8221
|
+
tx.readFrom([accountTokenScriptRef]).collectFrom([accountUtxo], {
|
|
8222
|
+
kind: "selected",
|
|
8223
|
+
inputs: [stabilityPoolUtxo, accountUtxo],
|
|
8224
|
+
makeRedeemer: (indices) => serialiseStabilityPoolRedeemer({
|
|
8225
|
+
ProcessRequestAccount: {
|
|
8226
|
+
poolInputIdx: indices[0],
|
|
8227
|
+
accountInputIdx: indices[1],
|
|
8228
|
+
e2s2sIdxs: [],
|
|
8229
|
+
currentTime
|
|
8230
|
+
}
|
|
8231
|
+
})
|
|
8232
|
+
}).mintAssets(accountTokenVal, Data42.void()).pay.ToContract(
|
|
8233
|
+
poolAddr,
|
|
8234
|
+
{
|
|
8235
|
+
kind: "inline",
|
|
8236
|
+
value: serialiseStabilityPoolDatum({
|
|
8237
|
+
StabilityPool: liquidationHelper(
|
|
8238
|
+
{
|
|
8239
|
+
...stabilityPoolDatum,
|
|
8240
|
+
state: {
|
|
8241
|
+
...stabilityPoolDatum.state,
|
|
8242
|
+
depositVal: spAdd(
|
|
8243
|
+
stabilityPoolDatum.state.depositVal,
|
|
8244
|
+
mkSPInteger(requestDepositAmt)
|
|
8245
|
+
)
|
|
8246
|
+
}
|
|
8247
|
+
},
|
|
8248
|
+
adaAssetClass4,
|
|
8249
|
+
0n,
|
|
8250
|
+
BigInt(sysParams.stabilityPoolParams.accountCreateFeeLovelaces)
|
|
8251
|
+
)
|
|
8252
|
+
})
|
|
8253
|
+
},
|
|
8254
|
+
addAssets11(
|
|
8255
|
+
stabilityPoolUtxo.assets,
|
|
8256
|
+
mkAssetsOf8(iassetAssetClass, requestDepositAmt),
|
|
8257
|
+
mkLovelacesOf5(
|
|
8258
|
+
BigInt(sysParams.stabilityPoolParams.accountCreateFeeLovelaces)
|
|
8259
|
+
)
|
|
8260
|
+
)
|
|
8261
|
+
).pay.ToContract(
|
|
8262
|
+
poolAddr,
|
|
8263
|
+
{
|
|
8264
|
+
kind: "inline",
|
|
8265
|
+
value: accountOutputDatum
|
|
8266
|
+
},
|
|
8267
|
+
addAssets11(accountTokenVal, mkLovelacesOf5(accountOutputAdaAmt))
|
|
8268
|
+
).setMinFee(txFee);
|
|
8269
|
+
}).with({ Adjust: P17.select() }, async (adjustContent) => {
|
|
8270
|
+
const iassetDatum = parseIAssetDatumOrThrow(
|
|
8271
|
+
getInlineDatumOrThrow(iAssetUtxo)
|
|
8272
|
+
);
|
|
8273
|
+
const accountDepositChange = adjustContent.amount;
|
|
8274
|
+
const outputAddress = addressToBech322(
|
|
8275
|
+
adjustContent.outputAddress,
|
|
8276
|
+
lucid.config().network
|
|
8277
|
+
);
|
|
8278
|
+
const e2s2sIdxs = await findRelevantE2s2sIdxs(
|
|
8279
|
+
lucid,
|
|
8280
|
+
stabilityPoolDatum,
|
|
8281
|
+
accountDatum.state,
|
|
8282
|
+
allE2s2sSnapshotOrefs
|
|
8283
|
+
);
|
|
8284
|
+
const { updatedAccountContent, reward } = updateAccount(
|
|
8285
|
+
stabilityPoolDatum,
|
|
8286
|
+
accountDatum,
|
|
8287
|
+
e2s2sIdxs
|
|
8288
|
+
);
|
|
8289
|
+
const isDepositOrRewardWithdrawal = accountDepositChange >= 0;
|
|
8290
|
+
const accountBalanceChange = isDepositOrRewardWithdrawal ? accountDepositChange : bigintMax(
|
|
8291
|
+
accountDepositChange,
|
|
8292
|
+
-fromSPInteger(updatedAccountContent.state.depositVal)
|
|
8293
|
+
);
|
|
8294
|
+
const newPoolDepositExcludingFee = spZeroNegatives(
|
|
8295
|
+
spAdd(
|
|
8296
|
+
stabilityPoolDatum.state.depositVal,
|
|
8297
|
+
mkSPInteger(accountBalanceChange)
|
|
8298
|
+
)
|
|
8299
|
+
);
|
|
8300
|
+
const withdrawalFeeAmt = isDepositOrRewardWithdrawal || newPoolDepositExcludingFee.value === 0n ? 0n : calculateFeeFromRatio(
|
|
8301
|
+
iassetDatum.stabilityPoolWithdrawalFeeRatio,
|
|
8302
|
+
-accountBalanceChange
|
|
8303
|
+
);
|
|
8304
|
+
const newPoolState = updatePoolStateWhenWithdrawalFee(withdrawalFeeAmt, {
|
|
8305
|
+
...stabilityPoolDatum.state,
|
|
8306
|
+
depositVal: newPoolDepositExcludingFee
|
|
8307
|
+
});
|
|
8308
|
+
const { e2s2sRefInputs, mkProcessRequestAccountRedeemerContent } = createProcessRequestAccountRedeemer(
|
|
8309
|
+
e2s2sIdxs,
|
|
8310
|
+
baseRefInputs,
|
|
8311
|
+
currentTime
|
|
8312
|
+
);
|
|
8313
|
+
if (e2s2sRefInputs.length > 0) {
|
|
8314
|
+
tx.readFrom(e2s2sRefInputs);
|
|
8315
|
+
}
|
|
8316
|
+
tx.collectFrom([accountUtxo], {
|
|
8317
|
+
kind: "selected",
|
|
8318
|
+
inputs: [stabilityPoolUtxo, accountUtxo],
|
|
8319
|
+
makeRedeemer: (indices) => {
|
|
8320
|
+
return serialiseStabilityPoolRedeemer({
|
|
8321
|
+
ProcessRequestAccount: mkProcessRequestAccountRedeemerContent(
|
|
8322
|
+
indices[0],
|
|
8323
|
+
indices[1]
|
|
8324
|
+
)
|
|
8325
|
+
});
|
|
8326
|
+
}
|
|
8327
|
+
}).pay.ToContract(
|
|
8328
|
+
stabilityPoolUtxo.address,
|
|
8329
|
+
{
|
|
8330
|
+
kind: "inline",
|
|
8331
|
+
value: serialiseStabilityPoolDatum({
|
|
8332
|
+
StabilityPool: {
|
|
8333
|
+
...stabilityPoolDatum,
|
|
8334
|
+
state: newPoolState
|
|
8335
|
+
}
|
|
8336
|
+
})
|
|
8337
|
+
},
|
|
8338
|
+
addAssets11(
|
|
8339
|
+
stabilityPoolUtxo.assets,
|
|
8340
|
+
negateAssets4(reward),
|
|
8341
|
+
mkAssetsOf8(iassetAssetClass, accountBalanceChange + withdrawalFeeAmt)
|
|
8342
|
+
)
|
|
8343
|
+
);
|
|
8344
|
+
const theoreticalOwnerOutputVal = addAssets11(
|
|
8345
|
+
reward,
|
|
8346
|
+
isDepositOrRewardWithdrawal ? {} : mkAssetsOf8(
|
|
8347
|
+
iassetAssetClass,
|
|
8348
|
+
-accountBalanceChange - withdrawalFeeAmt
|
|
8349
|
+
)
|
|
8350
|
+
);
|
|
8351
|
+
const ownerOutputDat = serialiseActionReturnDatum({
|
|
8352
|
+
IndigoStabilityPoolAccountAdjustment: {
|
|
8353
|
+
txHash: fromHex11(accountUtxo.txHash),
|
|
8354
|
+
outputIndex: BigInt(accountUtxo.outputIndex)
|
|
8355
|
+
}
|
|
8356
|
+
});
|
|
8357
|
+
const ownerOutputMinUtxoLovelace = estimateUtxoMinLovelace3(
|
|
8358
|
+
lucid.config().protocolParameters,
|
|
8359
|
+
outputAddress,
|
|
8360
|
+
theoreticalOwnerOutputVal,
|
|
8361
|
+
{ InlineDatum: { datum: ownerOutputDat } }
|
|
8362
|
+
);
|
|
8363
|
+
const extraOwnerOutputLovelacesAmt = lovelacesAmt2(theoreticalOwnerOutputVal) >= ownerOutputMinUtxoLovelace ? 0n : ownerOutputMinUtxoLovelace - lovelacesAmt2(theoreticalOwnerOutputVal);
|
|
8364
|
+
const actualOwnerOutputVal = addAssets11(
|
|
8365
|
+
theoreticalOwnerOutputVal,
|
|
8366
|
+
mkLovelacesOf5(extraOwnerOutputLovelacesAmt)
|
|
8367
|
+
);
|
|
8368
|
+
const accountOutputDat = serialiseStabilityPoolDatum({
|
|
8369
|
+
Account: {
|
|
8370
|
+
...updatedAccountContent,
|
|
8371
|
+
state: {
|
|
8372
|
+
...updatedAccountContent.state,
|
|
8373
|
+
depositVal: spAdd(
|
|
8374
|
+
updatedAccountContent.state.depositVal,
|
|
8375
|
+
mkSPInteger(accountBalanceChange)
|
|
8376
|
+
)
|
|
8377
|
+
},
|
|
8378
|
+
request: null,
|
|
8379
|
+
lastRequestProcessingTime: currentTime
|
|
8380
|
+
}
|
|
8381
|
+
});
|
|
8382
|
+
const accountOutputValWithoutAda = mkAssetsOf8(
|
|
8383
|
+
fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
|
|
8384
|
+
1n
|
|
8385
|
+
);
|
|
8386
|
+
const accountOutMinUtxoLovelace = estimateUtxoMinLovelace3(
|
|
8387
|
+
lucid.config().protocolParameters,
|
|
8388
|
+
stabilityPoolUtxo.address,
|
|
8389
|
+
accountOutputValWithoutAda,
|
|
8390
|
+
{ InlineDatum: { datum: accountOutputDat } }
|
|
8391
|
+
);
|
|
8392
|
+
const accountOutputAdaAmt = lovelacesAmt2(accountUtxo.assets) - extraOwnerOutputLovelacesAmt - txFee;
|
|
8393
|
+
if (accountOutputAdaAmt < accountOutMinUtxoLovelace) {
|
|
8394
|
+
throw new Error("Account doesn't have enough ADA to be processed.");
|
|
8395
|
+
}
|
|
8396
|
+
tx.pay.ToContract(
|
|
8397
|
+
stabilityPoolUtxo.address,
|
|
8398
|
+
{
|
|
8399
|
+
kind: "inline",
|
|
8400
|
+
value: accountOutputDat
|
|
8401
|
+
},
|
|
8402
|
+
addAssets11(
|
|
8403
|
+
accountOutputValWithoutAda,
|
|
8404
|
+
mkLovelacesOf5(accountOutputAdaAmt)
|
|
8405
|
+
)
|
|
8406
|
+
).pay.ToAddressWithData(
|
|
8407
|
+
outputAddress,
|
|
8408
|
+
{
|
|
8409
|
+
kind: "inline",
|
|
8410
|
+
value: ownerOutputDat
|
|
8411
|
+
},
|
|
8412
|
+
actualOwnerOutputVal
|
|
8413
|
+
).setMinFee(txFee);
|
|
8414
|
+
}).with({ Close: P17.select() }, async (closeContent) => {
|
|
8415
|
+
if (txFee > closeContent.maxTxFee) {
|
|
8416
|
+
throw new Error("Account doesn't allow current transaction fee.");
|
|
8417
|
+
}
|
|
8418
|
+
const accountTokenScriptRef = matchSingle5(
|
|
8419
|
+
await lucid.utxosByOutRef([
|
|
8420
|
+
fromSystemParamsScriptRef(
|
|
8421
|
+
sysParams.scriptReferences.authTokenPolicies.accountTokenRef
|
|
8422
|
+
)
|
|
8423
|
+
]),
|
|
8424
|
+
(_) => new Error("Expected a single cdp auth token policy Ref Script UTXO")
|
|
8425
|
+
);
|
|
8426
|
+
const iassetDatum = parseIAssetDatumOrThrow(
|
|
8427
|
+
getInlineDatumOrThrow(iAssetUtxo)
|
|
8428
|
+
);
|
|
8429
|
+
const outputAddress = addressToBech322(
|
|
8430
|
+
closeContent.outputAddress,
|
|
8431
|
+
lucid.config().network
|
|
8432
|
+
);
|
|
8433
|
+
const e2s2sIdxs = await findRelevantE2s2sIdxs(
|
|
8434
|
+
lucid,
|
|
8435
|
+
stabilityPoolDatum,
|
|
8436
|
+
accountDatum.state,
|
|
8437
|
+
allE2s2sSnapshotOrefs
|
|
8438
|
+
);
|
|
8439
|
+
const { updatedAccountContent, reward } = updateAccount(
|
|
8440
|
+
stabilityPoolDatum,
|
|
8441
|
+
accountDatum,
|
|
8442
|
+
e2s2sIdxs
|
|
8443
|
+
);
|
|
8444
|
+
const newPoolDepositExcludingFee = spZeroNegatives(
|
|
8445
|
+
spSub(
|
|
8446
|
+
stabilityPoolDatum.state.depositVal,
|
|
8447
|
+
updatedAccountContent.state.depositVal
|
|
8448
|
+
)
|
|
8449
|
+
);
|
|
8450
|
+
const withdrawnAmt = zeroNegatives(
|
|
8451
|
+
fromSPInteger(updatedAccountContent.state.depositVal)
|
|
8452
|
+
);
|
|
8453
|
+
const withdrawalFeeAmt = newPoolDepositExcludingFee.value === 0n ? 0n : calculateFeeFromRatio(
|
|
8454
|
+
iassetDatum.stabilityPoolWithdrawalFeeRatio,
|
|
8455
|
+
withdrawnAmt
|
|
8456
|
+
);
|
|
8457
|
+
const newPoolState = updatePoolStateWhenWithdrawalFee(withdrawalFeeAmt, {
|
|
8458
|
+
...stabilityPoolDatum.state,
|
|
8459
|
+
depositVal: newPoolDepositExcludingFee
|
|
8460
|
+
});
|
|
8461
|
+
const { e2s2sRefInputs, mkProcessRequestAccountRedeemerContent } = createProcessRequestAccountRedeemer(
|
|
8462
|
+
e2s2sIdxs,
|
|
8463
|
+
[...baseRefInputs, accountTokenScriptRef],
|
|
8464
|
+
currentTime
|
|
8465
|
+
);
|
|
8466
|
+
if (e2s2sRefInputs.length > 0) {
|
|
8467
|
+
tx.readFrom(e2s2sRefInputs);
|
|
8468
|
+
}
|
|
8469
|
+
tx.readFrom([accountTokenScriptRef]).collectFrom([accountUtxo], {
|
|
8470
|
+
kind: "selected",
|
|
8471
|
+
inputs: [stabilityPoolUtxo, accountUtxo],
|
|
8472
|
+
makeRedeemer: (indices) => {
|
|
8473
|
+
return serialiseStabilityPoolRedeemer({
|
|
8474
|
+
ProcessRequestAccount: mkProcessRequestAccountRedeemerContent(
|
|
8475
|
+
indices[0],
|
|
8476
|
+
indices[1]
|
|
8477
|
+
)
|
|
8478
|
+
});
|
|
8479
|
+
}
|
|
8480
|
+
}).mintAssets(
|
|
8481
|
+
mkAssetsOf8(
|
|
8482
|
+
fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
|
|
8483
|
+
-1n
|
|
8484
|
+
),
|
|
8485
|
+
Data42.void()
|
|
8486
|
+
).pay.ToContract(
|
|
8487
|
+
stabilityPoolUtxo.address,
|
|
8488
|
+
{
|
|
8489
|
+
kind: "inline",
|
|
8490
|
+
value: serialiseStabilityPoolDatum({
|
|
8491
|
+
StabilityPool: {
|
|
8492
|
+
...stabilityPoolDatum,
|
|
8493
|
+
state: newPoolState
|
|
8494
|
+
}
|
|
8495
|
+
})
|
|
8496
|
+
},
|
|
8497
|
+
addAssets11(
|
|
8498
|
+
stabilityPoolUtxo.assets,
|
|
8499
|
+
negateAssets4(reward),
|
|
8500
|
+
mkAssetsOf8(iassetAssetClass, -withdrawnAmt + withdrawalFeeAmt)
|
|
8501
|
+
)
|
|
8502
|
+
).pay.ToAddressWithData(
|
|
8503
|
+
outputAddress,
|
|
8504
|
+
{
|
|
8505
|
+
kind: "inline",
|
|
8506
|
+
value: serialiseActionReturnDatum({
|
|
8507
|
+
IndigoStabilityPoolAccountClosure: {
|
|
8508
|
+
txHash: fromHex11(accountUtxo.txHash),
|
|
8509
|
+
outputIndex: BigInt(accountUtxo.outputIndex)
|
|
8510
|
+
}
|
|
8511
|
+
})
|
|
8512
|
+
},
|
|
8513
|
+
addAssets11(
|
|
8514
|
+
mkLovelacesOf5(lovelacesAmt2(accountUtxo.assets) - txFee),
|
|
8515
|
+
reward,
|
|
8516
|
+
mkAssetsOf8(iassetAssetClass, withdrawnAmt - withdrawalFeeAmt)
|
|
8517
|
+
)
|
|
8518
|
+
).setMinFee(txFee);
|
|
8519
|
+
}).exhaustive();
|
|
8520
|
+
return tx;
|
|
8373
8521
|
}
|
|
8374
|
-
async function
|
|
8375
|
-
const
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8522
|
+
async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid, currentSlot) {
|
|
8523
|
+
const draftTx = processSpRequestAuxiliary(
|
|
8524
|
+
stabilityPoolUtxo,
|
|
8525
|
+
accountUtxo,
|
|
8526
|
+
iAssetUtxo,
|
|
8527
|
+
allE2s2sSnapshotOrefs,
|
|
8528
|
+
sysParams,
|
|
8529
|
+
lucid,
|
|
8530
|
+
currentSlot,
|
|
8531
|
+
// Placeholder transation fee
|
|
8532
|
+
1n
|
|
8533
|
+
);
|
|
8534
|
+
const fee = (await (await draftTx).complete()).toTransaction().body().fee();
|
|
8535
|
+
return processSpRequestAuxiliary(
|
|
8536
|
+
stabilityPoolUtxo,
|
|
8537
|
+
accountUtxo,
|
|
8538
|
+
iAssetUtxo,
|
|
8539
|
+
allE2s2sSnapshotOrefs,
|
|
8540
|
+
sysParams,
|
|
8541
|
+
lucid,
|
|
8542
|
+
currentSlot,
|
|
8543
|
+
fee
|
|
8381
8544
|
);
|
|
8382
8545
|
}
|
|
8383
|
-
async function
|
|
8384
|
-
const
|
|
8385
|
-
|
|
8386
|
-
|
|
8546
|
+
async function createE2s2sSnapshots(stabilityPoolOref, sysParams, lucid) {
|
|
8547
|
+
const stabilityPoolRefScriptUtxo = matchSingle5(
|
|
8548
|
+
await lucid.utxosByOutRef([
|
|
8549
|
+
fromSystemParamsScriptRef(
|
|
8550
|
+
sysParams.scriptReferences.stabilityPoolValidatorRef
|
|
8551
|
+
)
|
|
8552
|
+
]),
|
|
8553
|
+
(_) => new Error("Expected a single stability pool Ref Script UTXO")
|
|
8387
8554
|
);
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8555
|
+
const snapshotE2s2sPolicyRefScriptUtxo = matchSingle5(
|
|
8556
|
+
await lucid.utxosByOutRef([
|
|
8557
|
+
fromSystemParamsScriptRef(
|
|
8558
|
+
sysParams.scriptReferences.authTokenPolicies.snapshotEpochToScaleToSumTokenRef
|
|
8559
|
+
)
|
|
8560
|
+
]),
|
|
8561
|
+
(_) => new Error("Expected a single snapshot e2s2s policy Ref Script UTXO")
|
|
8393
8562
|
);
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
|
|
8397
|
-
{ hash: sysParams.validatorHashes.treasuryHash, type: "Script" },
|
|
8398
|
-
assetClassToUnit4(asset)
|
|
8563
|
+
const spUtxo = matchSingle5(
|
|
8564
|
+
await lucid.utxosByOutRef([stabilityPoolOref]),
|
|
8565
|
+
(_) => new Error("Expected a single stability pool UTXO")
|
|
8399
8566
|
);
|
|
8400
|
-
const
|
|
8401
|
-
|
|
8567
|
+
const spDatum = parseStabilityPoolDatumOrThrow(getInlineDatumOrThrow(spUtxo));
|
|
8568
|
+
const [newSnapshotDatums, newAssetStates] = partitionEpochToScaleToSums(spDatum);
|
|
8569
|
+
if (newSnapshotDatums.length === 0) {
|
|
8570
|
+
throw new Error("There has to be a snapshot being created.");
|
|
8571
|
+
}
|
|
8572
|
+
const snapshotAc = fromSystemParamsAsset(
|
|
8573
|
+
sysParams.stabilityPoolParams.snapshotEpochToScaleToSumToken
|
|
8402
8574
|
);
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8575
|
+
const tx = lucid.newTx().readFrom([stabilityPoolRefScriptUtxo, snapshotE2s2sPolicyRefScriptUtxo]).collectFrom(
|
|
8576
|
+
[spUtxo],
|
|
8577
|
+
serialiseStabilityPoolRedeemer("RecordEpochToScaleToSum")
|
|
8578
|
+
).mintAssets(
|
|
8579
|
+
mkAssetsOf8(snapshotAc, BigInt(newSnapshotDatums.length)),
|
|
8580
|
+
Data42.void()
|
|
8581
|
+
).pay.ToContract(
|
|
8582
|
+
spUtxo.address,
|
|
8583
|
+
{
|
|
8584
|
+
kind: "inline",
|
|
8585
|
+
value: serialiseStabilityPoolDatum({
|
|
8586
|
+
StabilityPool: { ...spDatum, assetStates: newAssetStates }
|
|
8587
|
+
})
|
|
8588
|
+
},
|
|
8589
|
+
spUtxo.assets
|
|
8408
8590
|
);
|
|
8591
|
+
for (const newDatum of newSnapshotDatums) {
|
|
8592
|
+
tx.pay.ToContract(
|
|
8593
|
+
spUtxo.address,
|
|
8594
|
+
{
|
|
8595
|
+
kind: "inline",
|
|
8596
|
+
value: serialiseStabilityPoolDatum({
|
|
8597
|
+
SnapshotEpochToScaleToSum: newDatum
|
|
8598
|
+
})
|
|
8599
|
+
},
|
|
8600
|
+
mkAssetsOf8(snapshotAc, 1n)
|
|
8601
|
+
);
|
|
8602
|
+
}
|
|
8603
|
+
return tx;
|
|
8409
8604
|
}
|
|
8410
|
-
async function
|
|
8411
|
-
const
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
)
|
|
8605
|
+
async function annulRequest(accountUtxo, params, lucid) {
|
|
8606
|
+
const stabilityPoolRefScriptUtxo = matchSingle5(
|
|
8607
|
+
await lucid.utxosByOutRef([
|
|
8608
|
+
fromSystemParamsScriptRef(
|
|
8609
|
+
params.scriptReferences.stabilityPoolValidatorRef
|
|
8610
|
+
)
|
|
8611
|
+
]),
|
|
8612
|
+
(_) => new Error("Expected a single stability pool Ref Script UTXO")
|
|
8417
8613
|
);
|
|
8418
|
-
|
|
8419
|
-
|
|
8420
|
-
|
|
8421
|
-
|
|
8422
|
-
|
|
8423
|
-
|
|
8424
|
-
|
|
8425
|
-
|
|
8426
|
-
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
|
-
cborHex: "590a2a590a27010100229800aba2aba1aba0aab9faab9eaab9dab9cab9a488888888cc896600264653001300b00198059806000cdc3a4005300b0024888966002600460166ea800e33001300c3754007370e90024dc3a4001300b375400891111919912cc004c0140122b3001301337540170028b20288acc004c0240122b3001301337540170028b20288acc004c0180122b3001301337540170028b20288b202040408080660024602a602c0032259800800c52f5c11330153012301600133002002301700140512301530163016001911919800800801912cc004006297ae0899912cc004c01400a2660320046600800800313300400400140506030002603200280b24446466446600400400244b3001001801c4c8c96600266e440180062b30013371e00c0031375a60320050054059133004004301d00340586eb8c05c004c068005018191919800800803112cc004006007132325980099b910080018acc004cdc7804000c4dd5980d001401501744cc010010c07800d0171bae3018001301b0014064297adef6c6014800260206ea802644b30010018800c54cc04400840050104dd2a400091111111194c0048c00800644602530010029bae301f301c3754003375c601660386ea8005007488c8cc00400400c8966002003168992cc004cdd79811180f9baa00100489807180f9baa001899801801981180120383021001407c9112cc004c03c01e2646464b300100180dc4c966002604a00513259800800c07a2b30013026001899805a49364d7573742070726f6475636520636f6c6c6563746f72206f7574707574207769746820696e63726561736564204144412076616c75650098009b914881009b8f4881009bac300f3022375402f3374a90011981218051981200219812260103d87a80004bd7025eb812222332232330010010052259800800c528456600264b300130040018acc004cdd7980c18159baa0014c107d87b9fd87980ff008acc004cc8a600264b30013020302d37540031375a605c60626eacc0c4c0b8dd5000c5200040ac60600033756005375e606060620032259800981298171baa4c0103d87a8000899b890010028acc004cdc480080144cdc480119b80001482026fb80a294102c20584888966002007159800980100344cc00401120008a5040b91325980099baf4c101400030310018acc004cc008014dd69819181a9bab3032001898019ba630360048a5040bd15980099801002a4001130030078a5040bc8178c0d000d0320dd3002994c0040066eacc06cc0b0dd5001488cc0c0008cc0c0dd3000a5eb810011112cc00400a26600298103d87a80004bd6f7b63044c8cc8966002601e005159800980700144cc010c064cc0ccc0c400d2f5c00031330044c0103d87a800000540b9198008034006446600c0046606a00a002803102e1bae302e0013033003303100240bd13375e605c605e605e605e60566ea800530103d87a80008a5040a114a0814229410281816800c528c4cc008008c0b800502720563259800a508800c4c8c8cc00400400c896600200313302c337609801014000374c00697adef6c6089919912cc004c02c00a2b3001300a0028992cc004cdd7a6101a000374c003100289981819bb04c01014000374c0020048158c8cc004004dd59817002112cc00400626606266ec130010140004c010101004bd6f7b63044c8cc89660026020005159800980780144c96600266e1c0052001880144cc0d4cdd8261014000375066e00005200200240c06eb4c0c800e26606866ec13010140004c0101010000440bd1330340033300500500140bc6eb8c0bc004c0d0008c0c800503044cc0bccdd82601014000374c00c008815226605e0066600a00a0028150dd7181500098178011816800a056330293376098010140004c010101004bd6f7b63020483756602a604c6ea8025660026030604a6ea8006246466ebcc0acc0a0dd5181598141baa002001302a3027375400512323375e605660506ea8008004c0a8c09cdd500120464079023204630073756602060426ea8c040c084dd5000c0710221811800a0423300b37586044603e6ea80508cdd7981198101baa302330203754601e60406ea8004008c084c078dd51810980f1baa0013300137586040603a6ea80480362b3001301300789919803a49334d757374207370656e64207374616b696e67206d616e61676572207769746820446973747269627574652072656465656d657200332259800800c00a2b3001302400189919912cc004c05400626464b300130290028024590261bae302700130233754007159800980c800c56600260466ea800e005164091159800980b000c56600260466ea800e00516409115980099b874801800626464b300130290028024590261bad30270013023375400715980099b87480200062b3001302337540070028b20488acc004cdc3a401400315980098119baa003801459024456600266e1d200c0018acc004c08cdd5001c00a2c81222c8101020204040808101020204013375e00298103d87b8000302037540026464660020026eacc094c098c098c098c098c098c098c098c098c098c088dd500b91192cc004cdd78021811800c4c09000626600600660500048108c098004cdd2a400466044604660406ea8c08c0052f5c100240848108528198051bac3021301e37540264660086eacc038c07cdd51807180f9baa0010023020301d37540471332259800980a980f1baa001899912cc004c094006264b30013014302137540031323322598009814800c4c8cc004004dd61814801112cc004006264b3001301a30273754003132324a2b3001323300100130103756605a605c605c605c605c60546ea807c896600266e3cdd71817000801c528c4cc008008c0bc00502845268b204c375c605660506ea80062c8128c8cc004004dd6180b98141baa0072259800800c5300103d87a80008992cc006600266ebc00530103d87a8000a50a51409d10018998018019817001204e325980099b8f375c605a002017130123302c302d302e0014bd7045300103d87a8000409c6eb0c0b000502a44c8c8cc8966002605e007133006006302f0058b2058375c60580026eb8c0b0008c0b0004dd61815000a0508b204c375a604c002604e00260446ea80062c80f8c966002602a60426ea80062604a60446ea80062c80f8c038c084dd5180818109baa30240018b2044375c6044603e6ea8004c8cc030dd6180798101baa01523002301030213754002b30013011301e375498103d879800089198029bab300f30203754002007123371090004c004dd5980798101baa0019bae302330203754007375c601e60406ea800d00b20388b2038300a301d37540466040603a6ea8c080c074dd5198009bac3020301d375402401a80d101a0c01c01c6028602a00a60260088b2012180580098031baa00b8a4d13656400c2a660049201353c65787065637465643e20436f6c6c6563746f7220696e7075742063616e6e6f742068617665206e6f6e2d41444120617373657473001615330024912c3c65787065637465643e204d757374207370656e642073696e676c6520636f6c6c6563746f7220696e707574001601"
|
|
8433
|
-
};
|
|
8434
|
-
|
|
8435
|
-
// src/contracts/collector/scripts.ts
|
|
8436
|
-
var mkCollectorValidatorFromSP = (params) => {
|
|
8437
|
-
return {
|
|
8438
|
-
type: "PlutusV3",
|
|
8439
|
-
script: applyParamsToScript12(_collectorValidator.cborHex, [
|
|
8440
|
-
new Constr2(0, [
|
|
8441
|
-
new Constr2(0, [
|
|
8442
|
-
params.stakingManagerNFT[0].unCurrencySymbol,
|
|
8443
|
-
fromText8(params.stakingManagerNFT[1].unTokenName)
|
|
8444
|
-
]),
|
|
8445
|
-
new Constr2(0, [
|
|
8446
|
-
params.stakingToken[0].unCurrencySymbol,
|
|
8447
|
-
fromText8(params.stakingToken[1].unTokenName)
|
|
8448
|
-
]),
|
|
8449
|
-
new Constr2(0, [
|
|
8450
|
-
params.versionRecordToken[0].unCurrencySymbol,
|
|
8451
|
-
fromText8(params.versionRecordToken[1].unTokenName)
|
|
8452
|
-
])
|
|
8453
|
-
])
|
|
8454
|
-
])
|
|
8455
|
-
};
|
|
8456
|
-
};
|
|
8457
|
-
|
|
8458
|
-
// src/contracts/execute/types.ts
|
|
8459
|
-
import { Data as Data41 } from "@lucid-evolution/lucid";
|
|
8460
|
-
var ExecuteParamsSchema = Data41.Object({
|
|
8461
|
-
govNFT: AssetClassSchema2,
|
|
8462
|
-
upgradeToken: AssetClassSchema2,
|
|
8463
|
-
iAssetToken: AssetClassSchema2,
|
|
8464
|
-
collateralAssetToken: AssetClassSchema2,
|
|
8465
|
-
stabilityPoolToken: AssetClassSchema2,
|
|
8466
|
-
cdpCreatorToken: AssetClassSchema2,
|
|
8467
|
-
cdpToken: AssetClassSchema2,
|
|
8468
|
-
versionRecordToken: AssetClassSchema2,
|
|
8469
|
-
iassetValHash: Data41.Bytes(),
|
|
8470
|
-
cdpValHash: Data41.Bytes(),
|
|
8471
|
-
sPoolValHash: Data41.Bytes(),
|
|
8472
|
-
versionRegistryValHash: Data41.Bytes(),
|
|
8473
|
-
treasuryValHash: Data41.Bytes()
|
|
8474
|
-
});
|
|
8475
|
-
var ExecuteParams = ExecuteParamsSchema;
|
|
8476
|
-
function castExecuteParams(params) {
|
|
8477
|
-
return Data41.castTo(params, ExecuteParams);
|
|
8478
|
-
}
|
|
8479
|
-
|
|
8480
|
-
// src/contracts/execute/scripts.ts
|
|
8481
|
-
import {
|
|
8482
|
-
applyParamsToScript as applyParamsToScript13,
|
|
8483
|
-
applySingleCborEncoding
|
|
8484
|
-
} from "@lucid-evolution/lucid";
|
|
8485
|
-
|
|
8486
|
-
// src/validators/execute-validator.ts
|
|
8487
|
-
var _executeValidator = {
|
|
8488
|
-
type: "PlutusScriptV3",
|
|
8489
|
-
description: "Generated by Aiken",
|
|
8490
|
-
cborHex: "5931ec5931e9010100229800aba2aba1aba0aab9faab9eaab9dab9cab9a48888888a60022a66004921203c65787065637465643e20694173736574206e6f74207265666572656e63656400168a99801249283c65787065637465643e2053696e676c6520636f6c6c61746572616c20617373657420696e70757400168a998012491e3c65787065637465643e2053696e676c652069617373657420696e70757400168a99801249193c65787065637465643e204d697865642076657273696f6e7300168a99801249523c65787065637465643e205768656e2066756e64732066726f6d207472656173757279207265717565737465642069742068617320746f207370656e642061207574786f2066726f6d20747265617375727900168a99801249243c65787065637465643e204f6e6c792073696e676c65206578656375746520696e707574001648888896600264653001300f00198079808000cdc3a4005300f00248889660026004601e6ea800e2664530013015002980a980b001566002600260226ea801a2b30013012375400d149a2c809a2c8079222598009802180a1baa0028cc004c060c054dd50014c054dd500348c064c06800644646600200200644b30010018a5eb8226644b3001300500289980e80119802002000c4cc010010005018180e000980e800a03448888c8cc88cc89660020050158acc004c08800a26464b3001330013756601260406ea8018c024c080dd5013466002444646601800846004601c604a6ea800566002602460446ea8006246600a6eacc034c090dd5000801c48cdc42400130013756601a60486ea80066eb8c09cc090dd5001cdd7180698121baa003401881026e1d20049181218129812800c88c8cc00400400c88cc00c004c00800a4464b30013012001899192cc004c0a400a0091640986eb8c09c004c08cdd5001c566002602a00315980098119baa0038014590244590202040302137540049111119914c004c0a800a6002003259800980398139baa0018981598141baa0018b204a488a60026002601060546ea8c04cc0a8dd5001c8966002603660566ea800a26464646464646464646464653001303b0019bad303b00c9bad303b00b9bad303b00a9bad303b0099bad303b0089bad303b0079bad303b0069bad303b0059bad303b0049bad303b00248888888888966002608e01913301f304600e13301b00b0188b2088181d800981d000981c800981c000981b800981b000981a800981a00098198009819000981880098161baa0028b2052980e18149baa302d302e005488966002603860586ea800e264646464653001375a606a003375a606a00b375a606a007375a606a00491112cc004c0e80162660166072010330012303a303b303b303b303b303b303b303b0019181d181d981d981d800cdd2a40052259800800c40062a6606c004200281aa44b3001302730373754005132323322598009820001c0162c81e8dd6981e8009bad303d002303d001303837540051640d522598009813981b9baa0028991919912cc004c10000e00b1640f46eb8c0f4004dd7181e801181e800981c1baa0028b206a9b874801a6e1d20089b874802a6e1d200e9b87480326e2520044888888888888cc89660026601692125476f7620696e707574206d75737420757365207468652072696768742072656465656d6572005980080c44ca6002266ebc00530103d87b800098221baa00191192cc004c0dc00626464b3001304e00280245904b1bae304c00130483754007159800981d000c4c8c966002609c0050048b2096375c609800260906ea800e2c822904518231baa002488966002606e00513232323298009827800cdd698278024dd71827801a444b3001305300489919912cc004c10400a264b300130570018992cc004c10cc14cdd5000c4c8c8c8c8c8ca600260ba003375c60ba00d305d004982e801cc1740092222259800983180344cc094c1880284cc09400c4cc0940084cc0940044cc09401403a2c830060ba00260b800260b600260b400260b200260a86ea80062c8288c1580062c82a0c148dd5001c566002608800513259800982b800c4c966002608660a66ea800626464646464653001305d0019bae305d006982e8024c17400e60ba004911112cc004c18c01a26604a60c401426604a00626604a00426604a00226604a00a01d164180305d001305c001305b001305a00130590013054375400316414460ac00316415060a46ea800e2b300130310028992cc004c15c006264b3001304330533754003132323232323232323298009bad30600019bae30600099bad306000798300034c18001660c000930600039830001244444444b30013069009899815183400809981100289981500209981580189981580109981580080a4590660c180004c17c004c178004c174004c170004c16c004c168004c164004c150dd5000c59051182b000c5905418291baa0038acc004c05800a264b300130570018992cc004c10cc14cdd5000c4c8c8c8c8c8c8c8c8ca60026eb4c1800066eb8c1800266eb4c18001e60c000d306000598300024c18000e60c0004911111112cc004c1a402626605460d002026604400a2660540082660560062660560042660560020291641983060001305f001305e001305d001305c001305b001305a00130590013054375400316414460ac00316415060a46ea800e2b300130150028992cc004c15c006264b3001304330533754003132323232323232323298009bae30600019bae30600099830003cc18001a60c000b30600049bad30600039bad30600024888888896600260d201313302a306801013302b00613302b00513302b0041330410030148b20cc1830000982f800982f000982e800982e000982d800982d000982c800982a1baa0018b20a230560018b20a830523754007159800980a00144c96600260ae00313259800982198299baa001899191919191919191919194c004dd71831000cdd71831005cc18802660c40113062007992cc004c1800062b3001301f305f0018b44c148c17c00505d4590611baa3062006992cc004c1800062b3001301f305f0018b44c148c17c00505d4590611baa306200598310024dd69831001cdd6983100124444444444b3001306d00b899817183600a09981780409981780389981780309982280180c45906a0c188004c184004c180004c17c004c178004c174004c170004c16c004c168004c164004c150dd5000c59051182b000c5905418291baa0038acc004c04800a264b30013057001899814182b00080145905418291baa0038acc004c04c00a264b300130570018992cc004c10cc14cdd5000c4c8cc896600260b6003133034375860b400244b300100280444c8cc896600260c0003132598009826182e1baa001899192cc004c18c00a2600e60c60111641806eb8c184004c174dd5000c5905a182f800c5905d1bae305d001305e001375860b800482d22c82c0dd6982c000982c800982a1baa0018b20a230560018b20a83052375400715980099b874804000a26464b30013058002801c590551bae30560013052375400716413c827904f209e413c827904f209e413c609e6ea80044c966002608000313259800982b000c4c966002608460a46ea80062646464b3001305a002899912cc004c11cc15cdd500144c8c8c96600260be005133014305e003132598009825800c4c96600260c200313232598009827000c4c96600260c800313301930630010098b20c2305f37540051598009828800c4c8c8ca60026eb4c1940066eb4c19400e6eb4c194009222598009834802403a2c833060ca00260c800260be6ea800a2c82e105c182e9baa00130600018b20bc305c37540051598009827000c56600260b86ea800a00b16417516416482c8c168dd5000c5905c182e800982e800982c1baa0028b20aa30590031330330012259800801404e264b3001304830583754003132323298009bad305f0019bae305f0039bae305f00248896600260c60091300830630098b20c0182f800982f000982c9baa0018b20ac305b002416516415c6eb0c160004c160004c14cdd5000c59050182a800c5905318289baa0058acc004c10c0062b30013051375400b00c8b20a48b209c4138609e6ea8010c1480162c8280609e002609c002609a00260906ea80122b3001303a002899192cc004c13800a00b16412c6eb4c130004c120dd50024566002604e00515980098241baa004801c590494566002601800515980098241baa004801c59049459045208a4114822866004608e60886ea807409e294504144c96600266018921174d697865642070726f746f636f6c2076657273696f6e73003370e6eb4c08cc114dd500d9bad30013045375406115980099806249224d7573742065786563757465206166746572206566666563746976652064656c6179003259800981c18229baa001899b88337006eb4c090c118dd50189bad302430463754605e608c6ea8070dd6982498231baa0018a50410c6090608a6ea8c120c114dd5180798229baa0368acc004cc03124011143616e6e6f742062652065787069726564003259800981c18229baa001899b89375a6092608c6ea8004cdc01bad300f304637540626eb4c03cc118dd5181798231baa01c8a50410c6090608a6ea8c0b8c114dd5180798229baa0368cc0048c124c128c128c128c128c12800646092609460946094609460946094609460946094003375e980103d879800048896600264b3001303830483754600860926ea80d22b3001001820c4c966002609c005132332259800981e000c566002609a6ea800e005164139159800981f800c566002609a6ea800e0051641391598009816000c566002609a6ea800e0051641391598009808800c566002609a6ea800e0051641391598009808000c4c8c8c8ca600260a8003375a60a8007375a60a80049112cc004c16001226603260ae00e2b300130433053375400713232332259800982e001c0362c82c8dd6982c8009bae3059002305900130543754007164145164154305400130530013052001304d37540071598009807800c566002609a6ea800e005164139164128825104a2094412882504c010004c128dd500099804182698251baa0013756600860946ea80ee0848258c13000504a44cc0412414b5768656e206e6f207472656173757279207769746864726177616c207265717565737465642069742063616e2774207370656e6420616e79207574786f2066726f6d207472656173757279003375e6e9c005300101800041186605a6eb0c12cc120dd501c980819825182598261826182618261826182618261826182618261826182618241baa04e4bd704660026e952000911982619bb037520046ea00052f5bded8c1370090014dd2a4008911119912cc004cc88cc05d24012c54686520646174756d206f6620676f7665726e616e6365206d757374207570646174652070726f7065726c79003232598009820800c6600200900398039982a19191918069982b982c0019982b982c0011982b982c0009982b9ba8300b375a603c60aa6ea80acc164c164004c160004c15c004c148dd501425eb82600a60aa60a46ea816298103d87a800040191598009809000c6600200900398039982a1918059982a982b0009982a982b18299baa003305730570013052375405097ae09802982a98291baa058a60103d87a800040191598009809800c6600200900398039982a191918061982b182b8011982b182b8009982b1ba8300a375a606460a86ea80a8c160c160004c15c004c148dd501425eb82600a60aa60a46ea816298103d87a8000401919800813528528a09e413c827904f18281baa0013039305037540766eb0c144c148c148c138dd501f980b19828180319828182898271baa3051304e3754606e609c6ea809ccc14130103d87a80004bd7025eb82264b300133016490122546865207472616e73616374696f6e206d757374206d696e742070726f7065726c79003375e6016609e6ea8100dd34c0048c8cc004004008896600200314bd6f7b63044c8cc154cdd818290009ba63233001001375660a800444b30010018a5eb7bdb182264660b066ec0c154004dd419b8148000dd6982b00099801801982d001182c000a0ac3300300330570023055001414d304e37546070609e6ea80ea4446644b300130430038802c4c8c8cc00400401c8966002003133059337606ea4014dd3001a5eb7bdb1822646644b30013372201000515980099b8f0080028992cc004cdd7a60101a000374c003100289982e99bb037520126e9800400905819198008009bab305b0042259800800c4cc178cdd81ba9009375001697adef6c6089919912cc004cdc8806001456600266e3c03000a264b30013370e00266e05200000f880144cc188cdd81ba900d375066e0000403c00905d1bad305f00389983099bb037520186ea003801105c44cc18400ccc01401400505c1bae305c0013061002305f001417513305c337606ea4020dd300300220ae89982e00199802802800a0ae375c60ae00260b800460b400282c0cc02c00400d0511bae3055305237540046eb8c0ecc148dd50012444b300130410028cc00660026006600a607660a46ea8162601c60a46ea816290012002981818291baa058a4004800a2b300130310028cc004c00cc014c0ecc148dd502c4c06cc148dd502c520024005159800980a8014660026006600a607660a46ea8162600860a46ea8162900120028acc004c04c00a3300130033005303b305237540b1301c305237540b14800900144c00cc014c0ecc148dd502c209e413c827904f226602c921104661696c656420657865637574696f6e009800981c18279baa03a91829982a182a182a182a182a182a182a182a000c8c14cc150c150c150c150c150c150c150c150c150c15000644b300130403050375400513232323232323232329800982e800cdd7182e804cdd6982e8044c17401a60ba00b305d004982e801cc96600260b6003159800980d182d000c5a2609a60b400282c22c82e0dd5182e801244444444b30013066009899814183280789981400289981400209981400189981400109981f0040094590630c174004c170004c16c004c168004c164004c160004c15c004c158004c144dd500145904e4896600266e40008006298103d87980008acc004cdc7801000c530103d87a80008a6103d87b8000413882712222232598009822000c4ca6002601c660b0002660b0980103d87a80004bd704dd6182c982d182d182b1baa047982c982b1baa0074888c966002660429212153746162696c697479506f6f6c206f757470757420697320696e636f7272656374009800801cc088cc170c048cc170c088cc170c024c168dd503025eb80cc171300103d87a80004bd7025eb82601e660b86024660b86024660b860ba60b46ea8008cc171300118d8799fd8799f1b0de0b6b3a7640000ffd8799f00ff0000ff003305c4c10180004bd7025eb812f5c1300d3016305a37540c14c103d87a8000403915980098249bad3023305a37540611330214912370726f706f73656420694173736574206f757470757420697320696e636f727265637400330014a2980103d87a8000899810a48125496e636f72726563746c7920636f6e73756d6564207265666572656e636520696173736574003259800982f800c4c96600266ebc01cc17cc170dd5182f982e1baa3045305c3754003132598009826182e1baa0018992cc004c1880062646601a002264b3001304f0018acc004c148c17cdd5181518301baa0028acc004cc09d2412370726f706f73656420694173736574206f757470757420697320696e636f727265637400330074a26030660c460c660c06ea80092f5c113302749123636f6e73756d656420694173736574206f757470757420697320696e636f7272656374009800804cc0a0cc1880292f5c130153306230183306232323232323232301f33069306a00733069306a00633069306a00533069306a00433069306a00333069306a00233069306a001330699800a50a6103d87a8000a60103d8798000419060d660d600260d400260d200260d000260ce00260cc00260ca00260c06ea80092f5c097ae09809981f18301baa066a6103d87a8000405114a082ea294105d4566002607e003159800992cc004c140c180dd5000c4c068cc038dd7183218309baa009375c60c860c26ea8006294505e180818301baa0028acc004cc09d2412370726f706f73656420694173736574206f757470757420697320696e636f727265637400330074a0602060c06ea800a26604e92123636f6e73756d656420694173736574206f757470757420697320696e636f7272656374009800804cc0a0cc1880292f5c130153306230183306232323232323232301f33069306a00733069306a00633069306a00533069306a00433069306a00333069306a00233069306a00133069306a306b00133069301f33069306a3067375401e97ae04bd7018350009834800983400098338009833000983280098301baa0024bd7025eb826026607c60c06ea819a98103d87a8000405114a082ea294105d454cc1792411a537563682069617373657420616c7265616479206578697374730016417482e8c178dd5198061bae3062305f375400e6eb8c188c17cdd50009830800c5905f182e9baa0018b20b43033303a305c3754608a60b86ea80060aa82c8c1780062c82e260026eb0c174c168dd5025cc0e0c168dd50305300103d879800040e882ba2941057114c0040126046660ba00a97ae098081982e98099982e98099982e982f182d9baa0033305d4c10100003305d3044305b3754006660ba607260b66ea800ccc174c090c16cdd50019982e980b982d9baa0033305d3016305b3754006660bb3001002a6103d87a8000a60103d87980004160660ba00297ae04bd7025eb82601c607260b66ea818698103d87a8000403c301d330573005305537540b697ae08acc004c11c0062653001375860b260b460b400398009bac3059001981a182b1baa05ca6103d879800040d9301e330583006305637540b897ae0982c982b1baa007488896600260bc0071325980099baf003305e305b375460bc60b66ea8c110c16cdd5000c4c966002609660b66ea8006264b30013061001899198060008acc004cdc79bae3061305e37540026eb8c184c178dd5002c5660033001008981319830180b198300031983026103d87a80004bd7025eb826026660c0602c660c064646030660c460c6004660c460c6002660c4609260c06ea801ccc188c0f8c180dd500399831181498301baa00733062301c3060375400e660c4603660c06ea801cc190c190c190c190c190c190004c18c004c178dd5000a5eb812f5c13011303c305e37540c94c0103d87a8000404914a3153305c491253c65787065637465643e20694173736574206f757470757420697320696e636f72726563740016416d153305c4911e3c65787065637465643e204e6f742072656c6576616e74206961737365740016416c60c000316417860b86ea80062c82c8c0c8c0e4c16cdd51822182d9baa0018a9982ca49283c65787065637465643e204d6f64696679696e67206e6f6e2d7570677261646564204941737365740016416060ba00716416c3055375408d13259800981a80146600260b260ac6ea801e4464b3001304b30583754003133006375c608460b26ea800cdd71821182c9baa0028800a0ac33005375c60b660b06ea8008dd7182d982c1baa001980f1982c1803182b1baa05c4bd704c158dd5023a4445300130123305c0023305c4c103d87a80004bd704dd6182e982f182f000e60026eb0c174006607060b46ea818298103d879800040e89112cc0040060af132598009831001456600266ebc018c184c178dd51830982f1baa3047305e3754003132598009827182f1baa0018992cc004c1900062646601e0022b30013371e6eb8c190c184dd50009bae306430613754017159800cc00401a6052660c600e97ae0980b19831980c9983199180d198321832800998321ba83018375a609660c46ea8008c198c198004c184dd5000a5eb812f5c13014303f306137540cf4c103d87a80004055132324a2b30013051375a609660c46ea800a2b300198009bac3065306237540a7302b306237540d14c0103d8798000410915980099800a514c0103d87a80008a4d1533060491223c65787065637465643e2057726f6e6720636f6c6c61746572616c206f75747075740016417d1533060491243c65787065637465643e204e6f20636f6c6c61746572616c20617373657420696e7075740016418d13259800800c17a264b300130680028acc004cdd7806183398321baa306730643754609a60c86ea8006264b3001305730643754003132598009835000c4c8cc04800456600266e3cdd7183518339baa001375c60d460ce6ea80462b3001337106eb4c140c19cdd5003acc0056600266ebd6600260b260cc6ea8c084c19cdd5000c4c140c19cdd5000c4c96600260d800313259800982d98341baa0018992cc004c1b80062646602c0022b3001305d306a3754604a60d66ea8006260a860d66ea80062a660d2921253c65787065637465643e204e6f742074686520666972737420696e2074686520636861696e001641a060da0031641ac60d26ea80062c8330c0fcc118c1a0dd5182898341baa306b0018b20d298009bac3050306737540b13030306737540db4c0103d8798000411c8321300106d8799f4040ff008a51899baf30503067375402298106d8799f4040ff00419114804a2900820c88acc004c96600260ae003159800982d18339baa30223068375400515980099817a4812a70726f706f73656420636f6c6c61746572616c206173736574206f757470757420696e636f727265637400330074a26040660d460a260d06ea80092f5c113302f4912a636f6e73756d656420636f6c6c61746572616c206173736574206f757470757420696e636f7272656374009800806cc0c0cc1a80392f5c1301d3306a30303306a3232323232323232323029330733074009330733074008330733074007330733074006330733074005330733074004330733074003330733074002330733074001330739800a50a6103d87a8000a60103d879800041b860ea60ea00260e800260e600260e400260e200260e000260de00260dc00260da00260d06ea80092f5c097ae0980d981898341baa06ea6103d87a8000407114a0832a29410654566002608e003159800992cc004c160c1a0dd5000c4c088cc048c148c1a4dd5009983618349baa0018a514198602e60d06ea800a2b30013302f4912a70726f706f73656420636f6c6c61746572616c206173736574206f757470757420696e636f727265637400330074a0602e60d06ea800a26605e9212a636f6e73756d656420636f6c6c61746572616c206173736574206f757470757420696e636f7272656374009800806cc0c0cc1a80392f5c1301d3306a30303306a3232323232323232323029330733074009330733074008330733074007330733074006330733074005330733074004330733074003330733074002330733074001330733074307500133073302933073305a3071375403697ae04bd70183a000983980098390009838800983800098378009837000983680098341baa0024bd7025eb826036606260d06ea81ba98103d87a8000407114a0832a2941065454cc199241245375636820636f6c6c61746572616c20617373657420616c726561647920657869737473001641948328c198dd519808182818339baa011305030673754003149a2c83222a660ca921283c65787065637465643e204d617820636f6c6c61746572616c206173736574732072656163686564001641911533065491283c65787065637465643e204e6f742072656c6576616e7420636f6c6c61746572616c2061737365740016419060d200316419c60ca6ea80062c8310c0ecc108c190dd5182698321baa00182ea0c282fa0ca306600141913001375860ca60c46ea814e605660c46ea81a298103d8798000410882f88a6002011302b330650094bd704c060cc194c0accc194c06ccc194c198c18cdd500199832982618319baa00d3306530413063375401a660ca605860c66ea8034cc194c07cc18cdd500699832980f18319baa00d3306530153063375401a660ca605a60c66ea8034cc194c04cc18cdd500699832cc00400a98103d87a8000a60103d87980004180660ca00297ae04bd7025eb82602c605860c66ea81a698103d87a8000405d153305f4911e3c65787065637465643e2057726f6e6720696173736574206f757470757400164179153305f491173c65787065637465643e2057726f6e67206961737365740016417860c600316418460be6ea80062c82e0c0d4c0f0c178dd51823982f1baa00182ba0b682c20be3060001417845660026034005132980098079982c8009982ca6103d87a80004bd70660026eb0c168c15cdd50244c080c15cdd502ed300103d879800040dd305a305737540109112cc004c17800a264b30013375e00a60bc60b66ea8c178c16cdd51822182d9baa0018992cc004c138c16cdd5000c4c96600260c200313233009001159800acc004cdc79bae3061305e37540026eb8c184c178dd5002c4cdd79823982f1baa0013047305e375400b14a082da2b300198009bac303c305e375409f3026330600074bd704c04ccc180c098cc180c8c8c8c064cc18cc19000ccc18cc190008cc18cc190004cc18cc0a8c184dd500419831980e98309baa00833063301c30613754010660c6602660c26ea8020cc18cc0acc184dd500419831980898309baa008306530653065306530653065306500130640013063001305e375400297ae04bd704c044c09cc178dd5032530103d87a8000404914a3153305c4912c3c65787065637465643e20436f6c6c61746572616c206173736574206f757470757420696e636f72726563740016416d153305c491263c65787065637465643e20697272656c6576616e7420636f6c6c61746572616c2061737365740016416c60c000316417860b86ea80062c82c8c0c8c0e4c16cdd51822182d9baa00182a20b0305d0028b20b6180f1982c1803182b1baa05c4bd70456600260320051332259800982e000c4c966002609660b06ea80062b30013059375400313259800800c15a264b3001305f0028992cc004c12cc16cdd5000c4c96600260c20031323300c00115980099812a4810c57726f6e6720694173736574003371e6eb8c184c178dd50009bae3061305e3754011133025490117434450206f757470757420697320696e636f72726563740098009bac303c305e375409f3026330603016330603026330603018305e37540c897ae0330604c103d87a80004bd7025eb826026660c0604c660c0602c660c060c260bc6ea8020cc180c11cc178dd500419830181e182f1baa008330603027305e3754010660c0603460bc6ea8020cc1826002946980103d87a8000a60103d8798000416c660c130014a34c0103d87a8000a60103d8798000416c660c0603260bc6ea8020cc180c040c178dd5004198301814182f1baa00833060300e305e375401097ae04bd7025eb826022602060bc6ea8192980103d87a8000404914a082d8c1800062c82f0c170dd5000c590591819181c982d9baa3044305b3754003057417060ba00282da60026eb0c108c164dd50254c0dcc164dd502fd300103d879800040e51641691641586602c60b660b06ea8c16c004dd59809182c1baa0498b20b230593056375400f3001375860b260ac6ea811e602260ac6ea817298103d879800040d9159800980c00144cc896600260b80031325980099baf305c3059375460b860b26ea8c108c164dd500098109982d9809982c9baa05f4bd7044c96600266e1d20103059375400313259800982f800c4cc8966002609e60b86ea8006264b300130620018992cc004c138c178dd5000c4c8c8c8c8c8c8c8c8c8c8ca60026eb8c1b40066eb8c1b402e60da013306d0089836803cc96600260d600315980098151835000c5a260ba60d400283422c8360dd518368034c96600260d600315980098151835000c5a260ba60d400283422c8360dd51836802cc1b40126eb4c1b400e6eb4c1b4009222222222259800983c005c4cc0e4c1dc0504cc0e80204cc0e801c4cc0e80184cc14000c566002660769211643445020696e70757420697320696e636f7272656374005980099b8f375c60ee60e86ea8058dd7183b983a1baa01e899baf305d3074375402c60ba60e86ea807a294107144cc0ed24117434450206f757470757420697320696e636f72726563740098009bac3052307437540cb303c33076302c33076303c33076302e307437540f497ae0330764c103d87a80004bd7025eb826052660ec6078660ec64605a660ee60f0002660ee60f060f2002660ee60a660ea6ea807ccc1dcc0f8c1d4dd500f9983b9818983a9baa01f3307798009833983a1baa30303075375403f4c0103d87a8000a60103d879800041c8660ef3001306730743754604e60ea6ea807e980103d87a8000a60103d879800041c8660ee607e60ea6ea807ccc1dcc094c1d4dd500f9983b9817983a9baa01f3307730243075375403e97ae03074375402c97ae04bd704dd5982e983a1baa305d307437540394c0103d87a800040a114a0838a2c83a860da00260d800260d600260d400260d200260d000260ce00260cc00260ca00260c800260be6ea80062c82e0c1840062c82f8c174dd5000c5905a1bad305e00130323039305b3754608860b66ea800e2c82e0c168dd5000c590571980b982e182c9baa0013756602660b26ea812a2a660ae92011a3c65787065637465643e204d697865642076657273696f6e732e0016415860b600316416460b260ac6ea801e60026eb0c164c158dd5023cc020c158dd502e5300103d879800040d9159800980b80144c8cc07924012176657273696f6e5265636f7264206f757470757420697320696e636f72726563740098009bac303530573754091301f33059300f33059301f33059305a305b305b305b305b305b305b305b305b305b305b305b305737540ba97ae0330594c103d87a80004bd7025eb826018660b2601e660b260b460ae6ea8004cc164dd399198008009bac30413058375400444b30010018a5eb822660b66e9cc8cc170c174004cc170c174c168dd5182e982f000a5eb80dd6182e00099801001182e800a0b44bd7025eb826014604260ae6ea8176980103d87a8000402c60b260ac6ea801e2b300130160028a518a51414c829905320a6414c82988966002608c60ac6ea800a26464646464646464646465300130650019bae306500b9bad306500998328044c19401e60ca00d306500598328024dd69832801cc96600260c600315980098111831000c5a260aa60c400283022c8320dd5183280124444444444b3001307000b899818983780a0998148038998188030998190028998190020998190018992cc004c170006264b30013072001899819983880080c45906f18369baa00b8acc004c17c0062b3001306d37540170178b20dc8b20d441a860d66ea802a2c836860ca00260c800260c600260c400260c200260c000260be00260bc00260ba00260b800260ae6ea800a2c82a105220a43053375400a8a504130460a460a660a660a660a660a660a600314a0825888888c8c8cc00400401c896600200314a1159800992cc004c0100062b30013375e606660aa6ea800401e2b300133229800992cc004c11cc15cdd5000c4dd6982c182d9bab305b30583754003148001055182d000cdd58014dd7982d182d800c8966002609660b06ea8026266e2400400a2b30013371200200513371200466e0000520809bee028a50415882b1222259800801c566002600400d13300100448002294105844c96600266ebd3001014000305b0018acc004cc008014dd6982e182f9bab305c001898019ba630600048a50416515980099801002a4001130030078a50416482c8c17800d05c0dd3003194c0040066eacc0fcc158dd5001488cc168008cc168dd3000a5eb810011112cc00400a26600298103d87a80004bd6f7b63044c8cc896600266e452201000028acc004cdc7a4410000289980218099982e982d801a5eb80006266008980103d87a80000054161198008034006446600c004660be00a00280310581bae3058001305d003305b002416513375e603c60aa6ea800530103d87a80008a50414914a082922941052182b800c528c4cc008008c16000505120aa59800982018281baa004891919baf30563053375460ac60a66ea8008004c154c148dd5002c48c8cdd7982b18299baa00200130553052375400a8270966002942297adef6c6089982799bb03050304d37540026e98cc010dd7181b18269baa001480092f5bded8c0825114a0822914a082122941042452820842304830493049304930490018a504104446464660020020064464b30013375e008608e003130480018998018019826001208a304a001300c330460024bd7011192cc004c0d0006264b3001304a0018998061824800801c5904718229baa0038acc004c0dc006264b3001304a0018998059824800801c5904718229baa0038acc004c09000626464b3001304b0028024590481bae304900130453754007164108821104218219baa0024590370c0d4004c0d0004c0cc004c0c8004c0b4dd5001c5902a06644b300100180145660026056003133029302a001330299800a51a60103d87a8000a60103d8798000409097ae0801205040a026644b300100180145660026056003133029302a001330299800a50a6103d87a8000a60103d8798000409097ae0801205040a02a6604692130457870656374656420476f7620696e7075742065697468657220617320696e707574206f72207265662e20696e707574001698009bac300e3025375402d3028302537540574c0103d87980004015300100c981418129baa02ba60103d8798000401444464b30013018001899192cc004c0bc00a0091640b06eb8c0b4004c0a4dd5001c56600260360031323322598009818000c4cc024dd61817800912cc00400a00f19800804cc0c400a260026064004804902f45902d1bad302d001302e001302937540071640988130c09cdd500122a6603c921283c65787065637465643e20526571756972657320617574686564206578656375746520696e7075740016407444602730010029bae302430213754003375c601460426ea800500311119199119801001000912cc004006007132325980099b910060018acc004cdc7803000c4dd69813001401502344cc010010c0a800d0231bae30240013027001409464646600200200c44b3001001801c4c8c96600266e440200062b30013371e01000313756604e0050054091133004004302b00340906eb8c094004c0a00050260a5eb7bdb1805200080aa03e407c66002006603e60386ea8c07cc070dd50011bab301f30203020302030203020302030203020302000632330010010022259800800c5a264b30013375e6040603a6ea800402e2600c603a6ea8006266006006604200480d0c07c00501d1119802001119baf3020301d37546040603a6ea8c018c074dd50008011bac301c0034590120c040dd50019b87480022c8068601e00260146ea803e29344d95900701"
|
|
8491
|
-
};
|
|
8492
|
-
|
|
8493
|
-
// src/contracts/execute/scripts.ts
|
|
8494
|
-
var mkExecuteValidator = (params) => {
|
|
8495
|
-
return {
|
|
8496
|
-
type: "PlutusV3",
|
|
8497
|
-
script: applySingleCborEncoding(
|
|
8498
|
-
applyParamsToScript13(_executeValidator.cborHex, [
|
|
8499
|
-
castExecuteParams(params)
|
|
8500
|
-
])
|
|
8501
|
-
)
|
|
8502
|
-
};
|
|
8503
|
-
};
|
|
8504
|
-
var mkExecuteValidatorFromSP = (params) => {
|
|
8505
|
-
return {
|
|
8506
|
-
type: "PlutusV3",
|
|
8507
|
-
script: applySingleCborEncoding(
|
|
8508
|
-
applyParamsToScript13(_executeValidator.cborHex, [
|
|
8509
|
-
castExecuteParams({
|
|
8510
|
-
govNFT: fromSystemParamsAssetLucid(params.govNFT),
|
|
8511
|
-
upgradeToken: fromSystemParamsAssetLucid(params.upgradeToken),
|
|
8512
|
-
iAssetToken: fromSystemParamsAssetLucid(params.iAssetToken),
|
|
8513
|
-
collateralAssetToken: fromSystemParamsAssetLucid(
|
|
8514
|
-
params.collateralAssetToken
|
|
8515
|
-
),
|
|
8516
|
-
stabilityPoolToken: fromSystemParamsAssetLucid(
|
|
8517
|
-
params.stabilityPoolToken
|
|
8518
|
-
),
|
|
8519
|
-
cdpCreatorToken: fromSystemParamsAssetLucid(params.cdpCreatorToken),
|
|
8520
|
-
cdpToken: fromSystemParamsAssetLucid(params.cdpToken),
|
|
8521
|
-
versionRecordToken: fromSystemParamsAssetLucid(
|
|
8522
|
-
params.versionRecordToken
|
|
8523
|
-
),
|
|
8524
|
-
iassetValHash: params.iassetValHash,
|
|
8525
|
-
cdpValHash: params.cdpValHash,
|
|
8526
|
-
sPoolValHash: params.sPoolValHash,
|
|
8527
|
-
versionRegistryValHash: params.versionRegistryValHash,
|
|
8528
|
-
treasuryValHash: params.treasuryValHash
|
|
8614
|
+
const oldAccountDatum = parseAccountDatumOrThrow(
|
|
8615
|
+
getInlineDatumOrThrow(accountUtxo)
|
|
8616
|
+
);
|
|
8617
|
+
const tx = lucid.newTx().readFrom([stabilityPoolRefScriptUtxo]).collectFrom([accountUtxo], serialiseStabilityPoolRedeemer("AnnulRequest")).addSignerKey(toHex12(oldAccountDatum.owner));
|
|
8618
|
+
if (oldAccountDatum.request !== "Create") {
|
|
8619
|
+
tx.pay.ToContract(
|
|
8620
|
+
accountUtxo.address,
|
|
8621
|
+
{
|
|
8622
|
+
kind: "inline",
|
|
8623
|
+
value: serialiseStabilityPoolDatum({
|
|
8624
|
+
Account: {
|
|
8625
|
+
...oldAccountDatum,
|
|
8626
|
+
request: null
|
|
8627
|
+
}
|
|
8529
8628
|
})
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
owner: Data42.Bytes(),
|
|
8539
|
-
/** Milliseconds */
|
|
8540
|
-
biasTime: Data42.Integer(),
|
|
8541
|
-
/** Milliseconds */
|
|
8542
|
-
expirationPeriod: Data42.Integer()
|
|
8543
|
-
});
|
|
8544
|
-
var PriceOracleParams = PriceOracleParamsSchema;
|
|
8545
|
-
function castPriceOracleParams(params) {
|
|
8546
|
-
return Data42.castTo(params, PriceOracleParams);
|
|
8629
|
+
},
|
|
8630
|
+
mkAssetsOf8(
|
|
8631
|
+
fromSystemParamsAsset(params.stabilityPoolParams.accountToken),
|
|
8632
|
+
1n
|
|
8633
|
+
)
|
|
8634
|
+
);
|
|
8635
|
+
}
|
|
8636
|
+
return tx;
|
|
8547
8637
|
}
|
|
8548
8638
|
|
|
8549
8639
|
// src/contracts/rob/helpers.ts
|
|
8550
8640
|
import {
|
|
8551
8641
|
addAssets as addAssets12,
|
|
8552
8642
|
fromHex as fromHex12,
|
|
8553
|
-
toHex as
|
|
8643
|
+
toHex as toHex13
|
|
8554
8644
|
} from "@lucid-evolution/lucid";
|
|
8555
8645
|
|
|
8556
8646
|
// src/contracts/rob/types-new.ts
|
|
@@ -8559,7 +8649,7 @@ import {
|
|
|
8559
8649
|
AssetClassSchema as AssetClassSchema7,
|
|
8560
8650
|
OutputReferenceSchema as OutputReferenceSchema6
|
|
8561
8651
|
} from "@3rd-eye-labs/cardano-offchain-common";
|
|
8562
|
-
import { option as
|
|
8652
|
+
import { option as O17, function as F20 } from "fp-ts";
|
|
8563
8653
|
var RobOrderTypeSchema = TSchema19.Union(
|
|
8564
8654
|
TSchema19.Struct(
|
|
8565
8655
|
{
|
|
@@ -8615,21 +8705,21 @@ var RobRedeemerSchema = TSchema19.Union(
|
|
|
8615
8705
|
);
|
|
8616
8706
|
function parseRobDatum(datum) {
|
|
8617
8707
|
try {
|
|
8618
|
-
return
|
|
8708
|
+
return O17.some(
|
|
8619
8709
|
Data43.withSchema(RobDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
|
|
8620
8710
|
datum
|
|
8621
8711
|
)
|
|
8622
8712
|
);
|
|
8623
8713
|
} catch (_) {
|
|
8624
|
-
return
|
|
8714
|
+
return O17.none;
|
|
8625
8715
|
}
|
|
8626
8716
|
}
|
|
8627
8717
|
function parseRobDatumOrThrow(datum) {
|
|
8628
|
-
return
|
|
8718
|
+
return F20.pipe(
|
|
8629
8719
|
parseRobDatum(datum),
|
|
8630
|
-
|
|
8720
|
+
O17.match(() => {
|
|
8631
8721
|
throw new Error("Expected an ROB datum.");
|
|
8632
|
-
},
|
|
8722
|
+
}, F20.identity)
|
|
8633
8723
|
);
|
|
8634
8724
|
}
|
|
8635
8725
|
function serialiseRobDatum(d) {
|
|
@@ -8642,30 +8732,30 @@ function serialiseRobRedeemer(r) {
|
|
|
8642
8732
|
}
|
|
8643
8733
|
function parseRobRedeemer(redeemerCborHex) {
|
|
8644
8734
|
try {
|
|
8645
|
-
return
|
|
8735
|
+
return O17.some(
|
|
8646
8736
|
Data43.withSchema(RobRedeemerSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
|
|
8647
8737
|
redeemerCborHex
|
|
8648
8738
|
)
|
|
8649
8739
|
);
|
|
8650
8740
|
} catch (_) {
|
|
8651
|
-
return
|
|
8741
|
+
return O17.none;
|
|
8652
8742
|
}
|
|
8653
8743
|
}
|
|
8654
8744
|
function parseRobRedeemerOrThrow(redeemerCborHex) {
|
|
8655
|
-
return
|
|
8745
|
+
return F20.pipe(
|
|
8656
8746
|
parseRobRedeemer(redeemerCborHex),
|
|
8657
|
-
|
|
8747
|
+
O17.match(() => {
|
|
8658
8748
|
throw new Error("Expected an ROB redeemer.");
|
|
8659
|
-
},
|
|
8749
|
+
}, F20.identity)
|
|
8660
8750
|
);
|
|
8661
8751
|
}
|
|
8662
8752
|
|
|
8663
8753
|
// src/contracts/rob/helpers.ts
|
|
8664
8754
|
import {
|
|
8665
8755
|
readonlyArray as RA3,
|
|
8666
|
-
array as
|
|
8667
|
-
function as
|
|
8668
|
-
option as
|
|
8756
|
+
array as A11,
|
|
8757
|
+
function as F21,
|
|
8758
|
+
option as O18,
|
|
8669
8759
|
ord as Ord4
|
|
8670
8760
|
} from "fp-ts";
|
|
8671
8761
|
import { match as match18, P as P18 } from "ts-pattern";
|
|
@@ -8798,13 +8888,13 @@ function isFullyRedeemed(robAssets, robOrderType, robIasset) {
|
|
|
8798
8888
|
}).exhaustive();
|
|
8799
8889
|
}
|
|
8800
8890
|
function buildRedemptionsTx(redemptions, iasset, collateralAsset, price, redemptionReimbursementRatio, sysParams, tx, txOutputsBeforeCount, collateralAssetRefInputIdx, iassetRefInputIdx, oracleIdx) {
|
|
8801
|
-
return
|
|
8891
|
+
return F21.pipe(
|
|
8802
8892
|
redemptions,
|
|
8803
|
-
|
|
8893
|
+
A11.reduceWithIndex(
|
|
8804
8894
|
tx,
|
|
8805
8895
|
(idx, acc, [robUtxo, payoutAmt]) => {
|
|
8806
8896
|
const robDatum = parseRobDatumOrThrow(getInlineDatumOrThrow(robUtxo));
|
|
8807
|
-
if (
|
|
8897
|
+
if (toHex13(robDatum.iasset) !== toHex13(iasset)) {
|
|
8808
8898
|
throw new Error("Only same iAsset");
|
|
8809
8899
|
}
|
|
8810
8900
|
const [robOutputVal, sellOrderAllowedAssetsIdx] = match18(
|
|
@@ -8834,12 +8924,12 @@ function buildRedemptionsTx(redemptions, iasset, collateralAsset, price, redempt
|
|
|
8834
8924
|
);
|
|
8835
8925
|
return [resultVal, 0n];
|
|
8836
8926
|
}).with({ SellIAssetOrder: P18.select() }, (content) => {
|
|
8837
|
-
const allowedAssetIdx =
|
|
8927
|
+
const allowedAssetIdx = F21.pipe(
|
|
8838
8928
|
content.allowedCollateralAssets,
|
|
8839
8929
|
RA3.findIndex(
|
|
8840
8930
|
([asset, _]) => isSameAssetClass3(asset, collateralAsset)
|
|
8841
8931
|
),
|
|
8842
|
-
|
|
8932
|
+
O18.getOrElse(() => {
|
|
8843
8933
|
throw new Error("Doesn't allow required collateral asset.");
|
|
8844
8934
|
})
|
|
8845
8935
|
);
|
|
@@ -8900,26 +8990,26 @@ function buildRedemptionsTx(redemptions, iasset, collateralAsset, price, redempt
|
|
|
8900
8990
|
);
|
|
8901
8991
|
}
|
|
8902
8992
|
function calculateTotalCollateralForRedemption(iasset, collateralAsset, iassetPrice, allRobs, maxRobsInTx) {
|
|
8903
|
-
return
|
|
8993
|
+
return F21.pipe(
|
|
8904
8994
|
allRobs,
|
|
8905
|
-
|
|
8995
|
+
A11.filterMap(([utxo, datum]) => {
|
|
8906
8996
|
const isCorrectOrder = match18(datum.orderType).returnType().with(
|
|
8907
8997
|
{ BuyIAssetOrder: P18.select() },
|
|
8908
8998
|
(content) => isSameAssetClass3(content.collateralAsset, collateralAsset) && rationalToFloat(content.maxPrice) >= rationalToFloat(iassetPrice) && !isBuyOrderFullyRedeemed(utxo.assets, datum.orderType, iassetPrice)
|
|
8909
8999
|
).otherwise(() => false);
|
|
8910
|
-
if (
|
|
8911
|
-
return
|
|
9000
|
+
if (toHex13(datum.iasset) !== toHex13(iasset) || !isCorrectOrder) {
|
|
9001
|
+
return O18.none;
|
|
8912
9002
|
}
|
|
8913
9003
|
const collateralToSpend = robCollateralAmtToSpend(
|
|
8914
9004
|
utxo.assets,
|
|
8915
9005
|
datum.orderType
|
|
8916
9006
|
);
|
|
8917
|
-
return
|
|
9007
|
+
return O18.some(collateralToSpend);
|
|
8918
9008
|
}),
|
|
8919
9009
|
// From largest to smallest
|
|
8920
|
-
|
|
9010
|
+
A11.sort(Ord4.reverse(BigIntOrd)),
|
|
8921
9011
|
// We can fit only this number of redemptions with CDP open into a single Tx.
|
|
8922
|
-
|
|
9012
|
+
A11.takeLeft(maxRobsInTx),
|
|
8923
9013
|
sum
|
|
8924
9014
|
);
|
|
8925
9015
|
}
|
|
@@ -8928,10 +9018,10 @@ function randomRobsSubsetSatisfyingTargetCollateral(iasset, collateralAsset, tar
|
|
|
8928
9018
|
throw new Error("Must redeem and payout more than 0.");
|
|
8929
9019
|
}
|
|
8930
9020
|
const shuffled = randomiseFn(
|
|
8931
|
-
|
|
9021
|
+
F21.pipe(
|
|
8932
9022
|
allLrps,
|
|
8933
|
-
|
|
8934
|
-
([utxo, datum]) =>
|
|
9023
|
+
A11.filter(
|
|
9024
|
+
([utxo, datum]) => toHex13(datum.iasset) === toHex13(iasset) && match18(datum.orderType).with(
|
|
8935
9025
|
{ BuyIAssetOrder: P18.select() },
|
|
8936
9026
|
(content) => isSameAssetClass3(collateralAsset, content.collateralAsset) && rationalToFloat(content.maxPrice) >= rationalToFloat(iassetPrice)
|
|
8937
9027
|
).otherwise(() => false) && !isBuyOrderFullyRedeemed(utxo.assets, datum.orderType, iassetPrice)
|
|
@@ -9010,15 +9100,15 @@ function castRobParams(params) {
|
|
|
9010
9100
|
import {
|
|
9011
9101
|
addAssets as addAssets13,
|
|
9012
9102
|
fromHex as fromHex13,
|
|
9013
|
-
toHex as
|
|
9103
|
+
toHex as toHex14,
|
|
9014
9104
|
fromText as fromText9,
|
|
9015
9105
|
getInputIndices as getInputIndices4
|
|
9016
9106
|
} from "@lucid-evolution/lucid";
|
|
9017
9107
|
import {
|
|
9018
9108
|
readonlyArray as RA4,
|
|
9019
|
-
array as
|
|
9020
|
-
function as
|
|
9021
|
-
option as
|
|
9109
|
+
array as A12,
|
|
9110
|
+
function as F22,
|
|
9111
|
+
option as O19
|
|
9022
9112
|
} from "fp-ts";
|
|
9023
9113
|
import { unzip, zip } from "fp-ts/lib/Array";
|
|
9024
9114
|
import {
|
|
@@ -9084,7 +9174,7 @@ async function cancelRob(robOutRef, sysParams, lucid) {
|
|
|
9084
9174
|
(_) => new Error("Expected a single ROB UTXO.")
|
|
9085
9175
|
);
|
|
9086
9176
|
const robDatum = parseRobDatumOrThrow(getInlineDatumOrThrow(robUtxo));
|
|
9087
|
-
return lucid.newTx().readFrom([robScriptRefUtxo]).collectFrom([robUtxo], serialiseRobRedeemer("Cancel")).addSignerKey(
|
|
9177
|
+
return lucid.newTx().readFrom([robScriptRefUtxo]).collectFrom([robUtxo], serialiseRobRedeemer("Cancel")).addSignerKey(toHex14(robDatum.owner));
|
|
9088
9178
|
}
|
|
9089
9179
|
async function redeemRob(redemptionRobsData, priceOracleOutRef, iassetOutRef, collateralAssetOutRef, lucid, sysParams, currentSlot, pythMessage = void 0, pythStateOutRef = void 0) {
|
|
9090
9180
|
const robScriptRefUtxo = matchSingle(
|
|
@@ -9195,7 +9285,7 @@ async function adjustRob(lucid, robOutRef, adjustmentAmt, newLimitPrice, sysPara
|
|
|
9195
9285
|
const reward = assetClassValueOf10(robUtxo.assets, iassetAc);
|
|
9196
9286
|
return [buyContent.collateralAsset, mkAssetsOf10(iassetAc, reward)];
|
|
9197
9287
|
}).with({ SellIAssetOrder: P19.select() }, (content) => {
|
|
9198
|
-
const reward =
|
|
9288
|
+
const reward = F22.pipe(
|
|
9199
9289
|
content.allowedCollateralAssets,
|
|
9200
9290
|
RA4.reduce(
|
|
9201
9291
|
{},
|
|
@@ -9235,12 +9325,12 @@ async function adjustRob(lucid, robOutRef, adjustmentAmt, newLimitPrice, sysPara
|
|
|
9235
9325
|
return {
|
|
9236
9326
|
SellIAssetOrder: {
|
|
9237
9327
|
allowedCollateralAssets: content.allowedCollateralAssets.map(
|
|
9238
|
-
(entry) =>
|
|
9328
|
+
(entry) => F22.pipe(
|
|
9239
9329
|
newPrices,
|
|
9240
|
-
|
|
9330
|
+
A12.findFirst(
|
|
9241
9331
|
(newPrice) => isSameAssetClass4(newPrice[0], entry[0])
|
|
9242
9332
|
),
|
|
9243
|
-
|
|
9333
|
+
O19.match(
|
|
9244
9334
|
() => entry,
|
|
9245
9335
|
(newPrice) => [
|
|
9246
9336
|
entry[0],
|
|
@@ -9259,7 +9349,7 @@ async function adjustRob(lucid, robOutRef, adjustmentAmt, newLimitPrice, sysPara
|
|
|
9259
9349
|
mkAssetsOf10(depositAsset, adjustmentAmt),
|
|
9260
9350
|
negateAssets5(rewardVal)
|
|
9261
9351
|
)
|
|
9262
|
-
).addSignerKey(
|
|
9352
|
+
).addSignerKey(toHex14(robDatum.owner));
|
|
9263
9353
|
}
|
|
9264
9354
|
async function claimRob(lucid, robOutRef, sysParams) {
|
|
9265
9355
|
return adjustRob(lucid, robOutRef, 0n, void 0, sysParams);
|
|
@@ -9311,7 +9401,7 @@ import {
|
|
|
9311
9401
|
} from "@lucid-evolution/lucid";
|
|
9312
9402
|
|
|
9313
9403
|
// src/contracts/rob-leverage/helpers.ts
|
|
9314
|
-
import { array as
|
|
9404
|
+
import { array as A13, function as F23 } from "fp-ts";
|
|
9315
9405
|
import { Decimal as Decimal2 } from "decimal.js";
|
|
9316
9406
|
var MAX_REDEMPTIONS_WITH_CDP_OPEN = 4;
|
|
9317
9407
|
function approximateLeverageRedemptions(baseCollateral, targetLeverage, redemptionReimbursementRatio, debtMintingFeeRatio) {
|
|
@@ -9337,9 +9427,9 @@ function approximateLeverageRedemptions(baseCollateral, targetLeverage, redempti
|
|
|
9337
9427
|
};
|
|
9338
9428
|
}
|
|
9339
9429
|
function summarizeActualLeverageRedemptions(lovelacesForRedemptionWithReimbursement, redemptionReimbursementRatio, iassetPrice, redemptionLrps) {
|
|
9340
|
-
const redemptionDetails =
|
|
9430
|
+
const redemptionDetails = F23.pipe(
|
|
9341
9431
|
redemptionLrps,
|
|
9342
|
-
|
|
9432
|
+
A13.reduce(
|
|
9343
9433
|
{
|
|
9344
9434
|
remainingCollateralToSpend: lovelacesForRedemptionWithReimbursement,
|
|
9345
9435
|
redemptions: []
|
|
@@ -9393,9 +9483,9 @@ function summarizeActualLeverageRedemptions(lovelacesForRedemptionWithReimbursem
|
|
|
9393
9483
|
}
|
|
9394
9484
|
)
|
|
9395
9485
|
);
|
|
9396
|
-
const res =
|
|
9486
|
+
const res = F23.pipe(
|
|
9397
9487
|
redemptionDetails.redemptions,
|
|
9398
|
-
|
|
9488
|
+
A13.reduce(
|
|
9399
9489
|
{
|
|
9400
9490
|
redeemedCollateral: 0n,
|
|
9401
9491
|
payoutIAssets: 0n,
|
|
@@ -9866,7 +9956,7 @@ import {
|
|
|
9866
9956
|
validatorToScriptHash as validatorToScriptHash3
|
|
9867
9957
|
} from "@lucid-evolution/lucid";
|
|
9868
9958
|
import {
|
|
9869
|
-
assetClassToUnit as
|
|
9959
|
+
assetClassToUnit as assetClassToUnit6,
|
|
9870
9960
|
assetClassValueOf as assetClassValueOf11,
|
|
9871
9961
|
lovelacesAmt as lovelacesAmt4,
|
|
9872
9962
|
mkAssetsOf as mkAssetsOf13,
|
|
@@ -9877,7 +9967,7 @@ import {
|
|
|
9877
9967
|
import {
|
|
9878
9968
|
applyParamsToScript as applyParamsToScript16,
|
|
9879
9969
|
Constr as Constr3,
|
|
9880
|
-
toHex as
|
|
9970
|
+
toHex as toHex15
|
|
9881
9971
|
} from "@lucid-evolution/lucid";
|
|
9882
9972
|
var authPolicyData = {
|
|
9883
9973
|
type: "PlutusV2",
|
|
@@ -9887,7 +9977,7 @@ function mkAuthTokenPolicy(ac, tn) {
|
|
|
9887
9977
|
return {
|
|
9888
9978
|
type: authPolicyData.type,
|
|
9889
9979
|
script: applyParamsToScript16(authPolicyData.cborHex, [
|
|
9890
|
-
new Constr3(0, [
|
|
9980
|
+
new Constr3(0, [toHex15(ac.currencySymbol), toHex15(ac.tokenName)]),
|
|
9891
9981
|
tn
|
|
9892
9982
|
])
|
|
9893
9983
|
};
|
|
@@ -9931,7 +10021,7 @@ var mkIAssetValidatorFromSP = (params) => {
|
|
|
9931
10021
|
import { match as match20 } from "ts-pattern";
|
|
9932
10022
|
|
|
9933
10023
|
// tests/test-helpers.ts
|
|
9934
|
-
import { array as
|
|
10024
|
+
import { array as A14, function as F24, option as O20 } from "fp-ts";
|
|
9935
10025
|
async function runAndAwaitTxBuilder(lucid, transaction, extraSigners = []) {
|
|
9936
10026
|
const bTx = await transaction.complete();
|
|
9937
10027
|
const signatures = [await bTx.partialSign.withWallet()];
|
|
@@ -10315,7 +10405,7 @@ async function mintAuthTokenDirect(lucid, asset, tokenName, amount) {
|
|
|
10315
10405
|
const script = mkAuthTokenPolicy(asset, fromText11(tokenName));
|
|
10316
10406
|
const policyId = mintingPolicyToId2(script);
|
|
10317
10407
|
const address = await lucid.wallet().address();
|
|
10318
|
-
const utxos = (await lucid.utxosAtWithUnit(address,
|
|
10408
|
+
const utxos = (await lucid.utxosAtWithUnit(address, assetClassToUnit6(asset))).filter((utxo2) => assetClassValueOf11(utxo2.assets, asset) === 1n).sort((a, b) => Number(lovelacesAmt4(b.assets) - lovelacesAmt4(a.assets)));
|
|
10319
10409
|
if (utxos.length === 0) {
|
|
10320
10410
|
throw new Error("No utxos found");
|
|
10321
10411
|
}
|
|
@@ -10337,7 +10427,7 @@ import {
|
|
|
10337
10427
|
fromText as fromText13,
|
|
10338
10428
|
mintingPolicyToId as mintingPolicyToId3,
|
|
10339
10429
|
scriptHashToCredential as scriptHashToCredential4,
|
|
10340
|
-
toHex as
|
|
10430
|
+
toHex as toHex17,
|
|
10341
10431
|
validatorToScriptHash as validatorToScriptHash5
|
|
10342
10432
|
} from "@lucid-evolution/lucid";
|
|
10343
10433
|
import {
|
|
@@ -10349,7 +10439,7 @@ import {
|
|
|
10349
10439
|
import {
|
|
10350
10440
|
applyParamsToScript as applyParamsToScript18,
|
|
10351
10441
|
Constr as Constr4,
|
|
10352
|
-
toHex as
|
|
10442
|
+
toHex as toHex16
|
|
10353
10443
|
} from "@lucid-evolution/lucid";
|
|
10354
10444
|
var iassetPolicyData = {
|
|
10355
10445
|
type: "PlutusV2",
|
|
@@ -10359,7 +10449,7 @@ function mkIAssetTokenPolicy(ac) {
|
|
|
10359
10449
|
return {
|
|
10360
10450
|
type: iassetPolicyData.type,
|
|
10361
10451
|
script: applyParamsToScript18(iassetPolicyData.cborHex, [
|
|
10362
|
-
new Constr4(0, [
|
|
10452
|
+
new Constr4(0, [toHex16(ac.currencySymbol), toHex16(ac.tokenName)])
|
|
10363
10453
|
])
|
|
10364
10454
|
};
|
|
10365
10455
|
}
|
|
@@ -10565,7 +10655,7 @@ async function initPythConfig(lucid, initialAssets, pythStateAsset) {
|
|
|
10565
10655
|
throw error;
|
|
10566
10656
|
}
|
|
10567
10657
|
}
|
|
10568
|
-
const key = `${asset.name}/${
|
|
10658
|
+
const key = `${asset.name}/${toHex17(collateral.collateralAsset.currencySymbol)}.${toHex17(collateral.collateralAsset.tokenName)}`;
|
|
10569
10659
|
return {
|
|
10570
10660
|
[key]: {
|
|
10571
10661
|
params: val.pythFeedParams,
|
|
@@ -10617,8 +10707,8 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
|
|
|
10617
10707
|
};
|
|
10618
10708
|
const versionRecordTokenPolicy = mkVersionRecordTokenPolicy({
|
|
10619
10709
|
upgradeToken: {
|
|
10620
|
-
currencySymbol:
|
|
10621
|
-
tokenName:
|
|
10710
|
+
currencySymbol: toHex17(upgradeToken.currencySymbol),
|
|
10711
|
+
tokenName: toHex17(upgradeToken.tokenName)
|
|
10622
10712
|
}
|
|
10623
10713
|
});
|
|
10624
10714
|
const versionRecordToken = {
|
|
@@ -11132,39 +11222,39 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
|
|
|
11132
11222
|
}
|
|
11133
11223
|
|
|
11134
11224
|
// src/contracts/iasset/queries.ts
|
|
11135
|
-
import { toHex as
|
|
11225
|
+
import { toHex as toHex18 } from "@lucid-evolution/lucid";
|
|
11136
11226
|
import {
|
|
11137
|
-
assetClassToUnit as
|
|
11227
|
+
assetClassToUnit as assetClassToUnit7,
|
|
11138
11228
|
isSameAssetClass as isSameAssetClass5,
|
|
11139
|
-
matchSingle as
|
|
11229
|
+
matchSingle as matchSingle6
|
|
11140
11230
|
} from "@3rd-eye-labs/cardano-offchain-common";
|
|
11141
|
-
import { option as
|
|
11231
|
+
import { option as O21, array as A15, function as F25 } from "fp-ts";
|
|
11142
11232
|
async function findIAsset(lucid, sysParams, iassetName) {
|
|
11143
11233
|
const iassetUtxos = await lucid.utxosAtWithUnit(
|
|
11144
11234
|
createScriptAddress(
|
|
11145
11235
|
lucid.config().network,
|
|
11146
11236
|
sysParams.validatorHashes.iassetHash
|
|
11147
11237
|
),
|
|
11148
|
-
|
|
11238
|
+
assetClassToUnit7(
|
|
11149
11239
|
fromSystemParamsAsset(sysParams.cdpParams.iAssetAuthToken)
|
|
11150
11240
|
)
|
|
11151
11241
|
);
|
|
11152
|
-
return
|
|
11153
|
-
|
|
11242
|
+
return matchSingle6(
|
|
11243
|
+
F25.pipe(
|
|
11154
11244
|
iassetUtxos.map(
|
|
11155
|
-
(utxo) =>
|
|
11156
|
-
|
|
11157
|
-
|
|
11158
|
-
|
|
11159
|
-
if (
|
|
11160
|
-
return
|
|
11245
|
+
(utxo) => F25.pipe(
|
|
11246
|
+
O21.fromNullable(utxo.datum),
|
|
11247
|
+
O21.flatMap(parseIAssetDatum),
|
|
11248
|
+
O21.flatMap((datum) => {
|
|
11249
|
+
if (toHex18(datum.assetName) === toHex18(iassetName)) {
|
|
11250
|
+
return O21.some({ utxo, datum });
|
|
11161
11251
|
} else {
|
|
11162
|
-
return
|
|
11252
|
+
return O21.none;
|
|
11163
11253
|
}
|
|
11164
11254
|
})
|
|
11165
11255
|
)
|
|
11166
11256
|
),
|
|
11167
|
-
|
|
11257
|
+
A15.compact
|
|
11168
11258
|
),
|
|
11169
11259
|
(res) => new Error("Expected a single IAsset UTXO.: " + JSON.stringify(res))
|
|
11170
11260
|
);
|
|
@@ -11175,26 +11265,26 @@ async function findCollateralAsset(lucid, sysParams, iassetName, collateralAsset
|
|
|
11175
11265
|
lucid.config().network,
|
|
11176
11266
|
sysParams.validatorHashes.iassetHash
|
|
11177
11267
|
),
|
|
11178
|
-
|
|
11268
|
+
assetClassToUnit7(
|
|
11179
11269
|
fromSystemParamsAsset(sysParams.cdpParams.collateralAssetAuthToken)
|
|
11180
11270
|
)
|
|
11181
11271
|
);
|
|
11182
|
-
return
|
|
11183
|
-
|
|
11272
|
+
return matchSingle6(
|
|
11273
|
+
F25.pipe(
|
|
11184
11274
|
collateralAssetUtxos.map(
|
|
11185
|
-
(utxo) =>
|
|
11186
|
-
|
|
11187
|
-
|
|
11188
|
-
|
|
11189
|
-
if (isSameAssetClass5(datum.collateralAsset, collateralAsset) &&
|
|
11190
|
-
return
|
|
11275
|
+
(utxo) => F25.pipe(
|
|
11276
|
+
O21.fromNullable(utxo.datum),
|
|
11277
|
+
O21.flatMap(parseCollateralAssetDatum),
|
|
11278
|
+
O21.flatMap((datum) => {
|
|
11279
|
+
if (isSameAssetClass5(datum.collateralAsset, collateralAsset) && toHex18(iassetName) === toHex18(datum.iasset)) {
|
|
11280
|
+
return O21.some({ utxo, datum });
|
|
11191
11281
|
} else {
|
|
11192
|
-
return
|
|
11282
|
+
return O21.none;
|
|
11193
11283
|
}
|
|
11194
11284
|
})
|
|
11195
11285
|
)
|
|
11196
11286
|
),
|
|
11197
|
-
|
|
11287
|
+
A15.compact
|
|
11198
11288
|
),
|
|
11199
11289
|
(res) => new Error(
|
|
11200
11290
|
"Expected a single Collateral Asset UTXO.: " + JSON.stringify(res)
|
|
@@ -11212,7 +11302,7 @@ import {
|
|
|
11212
11302
|
OutputReferenceSchema as OutputReferenceSchema7
|
|
11213
11303
|
} from "@3rd-eye-labs/cardano-offchain-common";
|
|
11214
11304
|
import { TSchema as TSchema20, Data as Data51 } from "@evolution-sdk/evolution";
|
|
11215
|
-
import { option as
|
|
11305
|
+
import { option as O22, function as F26 } from "fp-ts";
|
|
11216
11306
|
import { Schema as Schema4 } from "effect";
|
|
11217
11307
|
var OpaqueData4 = Schema4.typeSchema(Data51.DataSchema);
|
|
11218
11308
|
var StableswapOrderDatumSchema = TSchema20.Struct({
|
|
@@ -11254,22 +11344,22 @@ function serialiseStableswapOrderDatum(d) {
|
|
|
11254
11344
|
}
|
|
11255
11345
|
function parseStableswapOrderDatum(datum) {
|
|
11256
11346
|
try {
|
|
11257
|
-
return
|
|
11347
|
+
return O22.some(
|
|
11258
11348
|
Data51.withSchema(
|
|
11259
11349
|
StableswapOrderDatumSchema,
|
|
11260
11350
|
DEFAULT_SCHEMA_OPTIONS
|
|
11261
11351
|
).fromCBORHex(datum)
|
|
11262
11352
|
);
|
|
11263
11353
|
} catch (_) {
|
|
11264
|
-
return
|
|
11354
|
+
return O22.none;
|
|
11265
11355
|
}
|
|
11266
11356
|
}
|
|
11267
11357
|
function parseStableswapOrderDatumOrThrow(datum) {
|
|
11268
|
-
return
|
|
11358
|
+
return F26.pipe(
|
|
11269
11359
|
parseStableswapOrderDatum(datum),
|
|
11270
|
-
|
|
11360
|
+
O22.match(() => {
|
|
11271
11361
|
throw new Error("Expected a Stableswap Order datum.");
|
|
11272
|
-
},
|
|
11362
|
+
}, F26.identity)
|
|
11273
11363
|
);
|
|
11274
11364
|
}
|
|
11275
11365
|
function serialiseStableswapOutputDatum(d) {
|
|
@@ -11286,22 +11376,22 @@ function serialiseStableswapOrderRedeemer(r) {
|
|
|
11286
11376
|
}
|
|
11287
11377
|
function parseStableswapOrderRedeemer(redeemerCborHex) {
|
|
11288
11378
|
try {
|
|
11289
|
-
return
|
|
11379
|
+
return O22.some(
|
|
11290
11380
|
Data51.withSchema(
|
|
11291
11381
|
StableswapOrderRedeemerSchema,
|
|
11292
11382
|
DEFAULT_SCHEMA_OPTIONS
|
|
11293
11383
|
).fromCBORHex(redeemerCborHex)
|
|
11294
11384
|
);
|
|
11295
11385
|
} catch (_) {
|
|
11296
|
-
return
|
|
11386
|
+
return O22.none;
|
|
11297
11387
|
}
|
|
11298
11388
|
}
|
|
11299
11389
|
function parseStableswapOrderRedeemerOrThrow(redeemerCborHex) {
|
|
11300
|
-
return
|
|
11390
|
+
return F26.pipe(
|
|
11301
11391
|
parseStableswapOrderRedeemer(redeemerCborHex),
|
|
11302
|
-
|
|
11392
|
+
O22.match(() => {
|
|
11303
11393
|
throw new Error("Expected a Stableswap Order redeemer.");
|
|
11304
|
-
},
|
|
11394
|
+
}, F26.identity)
|
|
11305
11395
|
);
|
|
11306
11396
|
}
|
|
11307
11397
|
|
|
@@ -11330,20 +11420,20 @@ import {
|
|
|
11330
11420
|
fromText as fromText15,
|
|
11331
11421
|
paymentCredentialOf as paymentCredentialOf3,
|
|
11332
11422
|
sortUTxOs as sortUTxOs2,
|
|
11333
|
-
toHex as
|
|
11423
|
+
toHex as toHex19
|
|
11334
11424
|
} from "@lucid-evolution/lucid";
|
|
11335
11425
|
import {
|
|
11336
11426
|
addressFromBech32 as addressFromBech323,
|
|
11337
11427
|
addressToBech32 as addressToBech323,
|
|
11338
11428
|
getInlineDatumOrThrow as getInlineDatumOrThrow6,
|
|
11339
|
-
matchSingle as
|
|
11429
|
+
matchSingle as matchSingle7,
|
|
11340
11430
|
mkAssetsOf as mkAssetsOf16,
|
|
11341
11431
|
mkLovelacesOf as mkLovelacesOf9,
|
|
11342
11432
|
lovelacesAmt as lovelacesAmt5,
|
|
11343
11433
|
isSameOutRef as isSameOutRef2,
|
|
11344
11434
|
assetClassValueOf as assetClassValueOf12
|
|
11345
11435
|
} from "@3rd-eye-labs/cardano-offchain-common";
|
|
11346
|
-
import { array as
|
|
11436
|
+
import { array as A16, function as F27 } from "fp-ts";
|
|
11347
11437
|
import { isEmpty } from "fp-ts/lib/Array";
|
|
11348
11438
|
async function createStableswapOrder(iasset, collateralAsset, amount, minting, poolDatum, params, lucid, destinationAddress, destinationInlineDatum, maxExecutionFee = BASE_MAX_EXECUTION_FEE, additionalLovelaces = 0n, maxFeeRatio) {
|
|
11349
11439
|
const myAddress = await lucid.wallet().address();
|
|
@@ -11397,7 +11487,7 @@ async function createStableswapOrder(iasset, collateralAsset, amount, minting, p
|
|
|
11397
11487
|
);
|
|
11398
11488
|
}
|
|
11399
11489
|
async function cancelStableswapOrder(stableswapOrderOref, sysParams, lucid) {
|
|
11400
|
-
const stableswapScriptRefUtxo =
|
|
11490
|
+
const stableswapScriptRefUtxo = matchSingle7(
|
|
11401
11491
|
await lucid.utxosByOutRef([
|
|
11402
11492
|
fromSystemParamsScriptRef(
|
|
11403
11493
|
sysParams.scriptReferences.stableswapValidatorRef
|
|
@@ -11405,7 +11495,7 @@ async function cancelStableswapOrder(stableswapOrderOref, sysParams, lucid) {
|
|
|
11405
11495
|
]),
|
|
11406
11496
|
(_) => new Error("Expected a single Stableswap Ref Script UTXO")
|
|
11407
11497
|
);
|
|
11408
|
-
const stableswapOrderUtxo =
|
|
11498
|
+
const stableswapOrderUtxo = matchSingle7(
|
|
11409
11499
|
await lucid.utxosByOutRef([stableswapOrderOref]),
|
|
11410
11500
|
(_) => new Error("Expected a single Stableswap Order UTXO.")
|
|
11411
11501
|
);
|
|
@@ -11415,10 +11505,10 @@ async function cancelStableswapOrder(stableswapOrderOref, sysParams, lucid) {
|
|
|
11415
11505
|
return lucid.newTx().readFrom([stableswapScriptRefUtxo]).collectFrom(
|
|
11416
11506
|
[stableswapOrderUtxo],
|
|
11417
11507
|
serialiseStableswapOrderRedeemer("CancelStableswapOrder")
|
|
11418
|
-
).addSignerKey(
|
|
11508
|
+
).addSignerKey(toHex19(stableswapOrderDatum.owner));
|
|
11419
11509
|
}
|
|
11420
11510
|
async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPoolOref, treasuryOref, sysParams, lucid) {
|
|
11421
|
-
const stableswapScriptRefUtxo =
|
|
11511
|
+
const stableswapScriptRefUtxo = matchSingle7(
|
|
11422
11512
|
await lucid.utxosByOutRef([
|
|
11423
11513
|
fromSystemParamsScriptRef(
|
|
11424
11514
|
sysParams.scriptReferences.stableswapValidatorRef
|
|
@@ -11426,13 +11516,13 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
|
|
|
11426
11516
|
]),
|
|
11427
11517
|
(_) => new Error("Expected a single Stableswap Ref Script UTXO")
|
|
11428
11518
|
);
|
|
11429
|
-
const cdpScriptRefUtxo =
|
|
11519
|
+
const cdpScriptRefUtxo = matchSingle7(
|
|
11430
11520
|
await lucid.utxosByOutRef([
|
|
11431
11521
|
fromSystemParamsScriptRef(sysParams.scriptReferences.cdpValidatorRef)
|
|
11432
11522
|
]),
|
|
11433
11523
|
(_) => new Error("Expected a single CDP Ref Script UTXO")
|
|
11434
11524
|
);
|
|
11435
|
-
const iAssetTokenPolicyRefScriptUtxo =
|
|
11525
|
+
const iAssetTokenPolicyRefScriptUtxo = matchSingle7(
|
|
11436
11526
|
await lucid.utxosByOutRef([
|
|
11437
11527
|
fromSystemParamsScriptRef(
|
|
11438
11528
|
sysParams.scriptReferences.iAssetTokenPolicyRef
|
|
@@ -11462,7 +11552,7 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
|
|
|
11462
11552
|
tokenName: mainOrderDatum.iasset
|
|
11463
11553
|
};
|
|
11464
11554
|
const collateralAc = mainOrderDatum.collateralAsset;
|
|
11465
|
-
const stableswapPoolUtxo =
|
|
11555
|
+
const stableswapPoolUtxo = matchSingle7(
|
|
11466
11556
|
await lucid.utxosByOutRef([stableswapPoolOref]),
|
|
11467
11557
|
(_) => new Error("Expected a single cdp UTXO")
|
|
11468
11558
|
);
|
|
@@ -11474,7 +11564,7 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
|
|
|
11474
11564
|
const orderDatum = parseStableswapOrderDatumOrThrow(
|
|
11475
11565
|
getInlineDatumOrThrow6(orderUtxo)
|
|
11476
11566
|
);
|
|
11477
|
-
if (
|
|
11567
|
+
if (toHex19(orderDatum.iasset) != toHex19(mainOrderDatum.iasset) || toHex19(orderDatum.collateralAsset.currencySymbol) != toHex19(mainOrderDatum.collateralAsset.currencySymbol) || toHex19(orderDatum.collateralAsset.tokenName) != toHex19(mainOrderDatum.collateralAsset.tokenName)) {
|
|
11478
11568
|
throw new Error("Wrong batch of orders");
|
|
11479
11569
|
}
|
|
11480
11570
|
const suppliedIasset = assetClassValueOf12(orderUtxo.assets, iassetAc);
|
|
@@ -11602,9 +11692,9 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
|
|
|
11602
11692
|
}
|
|
11603
11693
|
}
|
|
11604
11694
|
);
|
|
11605
|
-
const totalSwapInfo =
|
|
11695
|
+
const totalSwapInfo = F27.pipe(
|
|
11606
11696
|
ordersInfo,
|
|
11607
|
-
|
|
11697
|
+
A16.reduce(
|
|
11608
11698
|
{
|
|
11609
11699
|
suppliedCollateralAsset: 0n,
|
|
11610
11700
|
suppliedIasset: 0n,
|
|
@@ -11654,9 +11744,9 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
|
|
|
11654
11744
|
if (amountToMint !== 0n) {
|
|
11655
11745
|
tx.mintAssets(mkAssetsOf16(iassetAc, amountToMint), Data53.void());
|
|
11656
11746
|
}
|
|
11657
|
-
|
|
11747
|
+
F27.pipe(
|
|
11658
11748
|
ordersInfo,
|
|
11659
|
-
|
|
11749
|
+
A16.reduce(tx, (acc, orderInfo) => {
|
|
11660
11750
|
return acc.collectFrom(
|
|
11661
11751
|
[orderInfo.utxo],
|
|
11662
11752
|
isSameOutRef2(orderInfo.utxo, mainOrderUtxo) ? serialiseStableswapOrderRedeemer("BatchProcessStableswapOrders") : {
|
|
@@ -11709,7 +11799,7 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
|
|
|
11709
11799
|
return tx;
|
|
11710
11800
|
}
|
|
11711
11801
|
async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRef, newMintingFeeRatio, newRedemptionFeeRatio, sysParams, lucid) {
|
|
11712
|
-
const stableswapScriptRefUtxo =
|
|
11802
|
+
const stableswapScriptRefUtxo = matchSingle7(
|
|
11713
11803
|
await lucid.utxosByOutRef([
|
|
11714
11804
|
fromSystemParamsScriptRef(
|
|
11715
11805
|
sysParams.scriptReferences.stableswapValidatorRef
|
|
@@ -11717,17 +11807,17 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
|
|
|
11717
11807
|
]),
|
|
11718
11808
|
(_) => new Error("Expected a single Stableswap Ref Script UTXO")
|
|
11719
11809
|
);
|
|
11720
|
-
const cdpScriptRefUtxo =
|
|
11810
|
+
const cdpScriptRefUtxo = matchSingle7(
|
|
11721
11811
|
await lucid.utxosByOutRef([
|
|
11722
11812
|
fromSystemParamsScriptRef(sysParams.scriptReferences.cdpValidatorRef)
|
|
11723
11813
|
]),
|
|
11724
11814
|
(_) => new Error("Expected a single CDP Ref Script UTXO")
|
|
11725
11815
|
);
|
|
11726
|
-
const stableswapPool =
|
|
11816
|
+
const stableswapPool = matchSingle7(
|
|
11727
11817
|
await lucid.utxosByOutRef([stableswapPoolOutRef]),
|
|
11728
11818
|
(_) => new Error("Expected a single Stableswap Pool UTXO.")
|
|
11729
11819
|
);
|
|
11730
|
-
const stableswapFeeUtxo =
|
|
11820
|
+
const stableswapFeeUtxo = matchSingle7(
|
|
11731
11821
|
await lucid.utxosByOutRef([stableswapFeeOutRef]),
|
|
11732
11822
|
(_) => new Error("Expected a single Stableswap Fee UTXO.")
|
|
11733
11823
|
);
|
|
@@ -11760,7 +11850,7 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
|
|
|
11760
11850
|
value: serialiseStableswapPoolDatum(newStableswapPoolDatum)
|
|
11761
11851
|
},
|
|
11762
11852
|
stableswapPool.assets
|
|
11763
|
-
).addSignerKey(
|
|
11853
|
+
).addSignerKey(toHex19(stableswapPoolDatum.feeManager)).setMinFee(1038402n);
|
|
11764
11854
|
}
|
|
11765
11855
|
export {
|
|
11766
11856
|
AccountContentSchema,
|
|
@@ -11900,6 +11990,7 @@ export {
|
|
|
11900
11990
|
findAllTreasuryUtxos,
|
|
11901
11991
|
findAllTreasuryUtxosWithNonAdaAsset,
|
|
11902
11992
|
findCollateralAsset,
|
|
11993
|
+
findE2s2sSnapshots,
|
|
11903
11994
|
findIAsset,
|
|
11904
11995
|
findRandomCdpCreator,
|
|
11905
11996
|
findRandomNonAdminInterestCollector,
|
|
@@ -11907,6 +11998,8 @@ export {
|
|
|
11907
11998
|
findRandomTreasuryUtxoWithAsset,
|
|
11908
11999
|
findRandomTreasuryUtxoWithOnlyAda,
|
|
11909
12000
|
findRelevantE2s2sIdxs,
|
|
12001
|
+
findStabilityPool,
|
|
12002
|
+
findStabilityPoolAccount,
|
|
11910
12003
|
findStakingManager,
|
|
11911
12004
|
findStakingManagerByOutRef,
|
|
11912
12005
|
findStakingPositionByOutRef,
|