Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 102 additions & 32 deletions evm-tests/src/contracts/alpha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const IAlphaABI = [
"type": "uint16"
}
],
"name": "getAlphaPrice",
"name": "getAlphaInEmission",
"outputs": [
{
"internalType": "uint256",
Expand All @@ -28,12 +28,12 @@ export const IAlphaABI = [
"type": "uint16"
}
],
"name": "getMovingAlphaPrice",
"name": "getAlphaInPool",
"outputs": [
{
"internalType": "uint256",
"internalType": "uint64",
"name": "",
"type": "uint256"
"type": "uint64"
}
],
"stateMutability": "view",
Expand All @@ -47,7 +47,7 @@ export const IAlphaABI = [
"type": "uint16"
}
],
"name": "getTaoInPool",
"name": "getAlphaIssuance",
"outputs": [
{
"internalType": "uint64",
Expand All @@ -66,12 +66,12 @@ export const IAlphaABI = [
"type": "uint16"
}
],
"name": "getAlphaInPool",
"name": "getAlphaOutEmission",
"outputs": [
{
"internalType": "uint64",
"internalType": "uint256",
"name": "",
"type": "uint64"
"type": "uint256"
}
],
"stateMutability": "view",
Expand Down Expand Up @@ -104,7 +104,26 @@ export const IAlphaABI = [
"type": "uint16"
}
],
"name": "getAlphaIssuance",
"name": "getAlphaPrice",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint16",
"name": "netuid",
"type": "uint16"
}
],
"name": "getEMAPriceHalvingBlocks",
"outputs": [
{
"internalType": "uint64",
Expand All @@ -116,8 +135,14 @@ export const IAlphaABI = [
"type": "function"
},
{
"inputs": [],
"name": "getTaoWeight",
"inputs": [
{
"internalType": "uint16",
"name": "netuid",
"type": "uint16"
}
],
"name": "getMovingAlphaPrice",
"outputs": [
{
"internalType": "uint256",
Expand All @@ -128,20 +153,47 @@ export const IAlphaABI = [
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getRootNetuid",
"outputs": [
{
"internalType": "uint16",
"name": "",
"type": "uint16"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint16",
"name": "netuid",
"type": "uint16"
},
}
],
"name": "getSubnetMechanism",
"outputs": [
{
"internalType": "uint64",
"name": "tao",
"type": "uint64"
"internalType": "uint16",
"name": "",
"type": "uint16"
}
],
"name": "simSwapTaoForAlpha",
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint16",
"name": "netuid",
"type": "uint16"
}
],
"name": "getSubnetVolume",
"outputs": [
{
"internalType": "uint256",
Expand All @@ -158,14 +210,9 @@ export const IAlphaABI = [
"internalType": "uint16",
"name": "netuid",
"type": "uint16"
},
{
"internalType": "uint64",
"name": "alpha",
"type": "uint64"
}
],
"name": "simSwapAlphaForTao",
"name": "getTaoInEmission",
"outputs": [
{
"internalType": "uint256",
Expand All @@ -184,25 +231,25 @@ export const IAlphaABI = [
"type": "uint16"
}
],
"name": "getSubnetMechanism",
"name": "getTaoInPool",
"outputs": [
{
"internalType": "uint16",
"internalType": "uint64",
"name": "",
"type": "uint16"
"type": "uint64"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getRootNetuid",
"name": "getTaoWeight",
"outputs": [
{
"internalType": "uint16",
"internalType": "uint256",
"name": "",
"type": "uint16"
"type": "uint256"
}
],
"stateMutability": "view",
Expand All @@ -214,14 +261,19 @@ export const IAlphaABI = [
"internalType": "uint16",
"name": "netuid",
"type": "uint16"
},
{
"internalType": "uint64",
"name": "alpha",
"type": "uint64"
}
],
"name": "getEMAPriceHalvingBlocks",
"name": "simSwapAlphaForTao",
"outputs": [
{
"internalType": "uint64",
"internalType": "uint256",
"name": "",
"type": "uint64"
"type": "uint256"
}
],
"stateMutability": "view",
Expand All @@ -233,9 +285,27 @@ export const IAlphaABI = [
"internalType": "uint16",
"name": "netuid",
"type": "uint16"
},
{
"internalType": "uint64",
"name": "tao",
"type": "uint64"
}
],
"name": "getSubnetVolume",
"name": "simSwapTaoForAlpha",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getSumAlphaPrice",
"outputs": [
{
"internalType": "uint256",
Expand Down
37 changes: 37 additions & 0 deletions evm-tests/test/alpha.precompile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,43 @@ describe("Test Alpha Precompile", () => {
// Both should be defined and valid
assert.ok(alphaPrice !== undefined && movingAlphaPrice !== undefined);
});

it("Tao in / Alpha in / Alpha out are consistent for same subnet", async () => {
const taoInEmission = await publicClient.readContract({
abi: IAlphaABI,
address: toViemAddress(IALPHA_ADDRESS),
functionName: "getTaoInEmission",
args: [subnetId]
})

const alphaInEmission = await publicClient.readContract({
abi: IAlphaABI,
address: toViemAddress(IALPHA_ADDRESS),
functionName: "getAlphaInEmission",
args: [subnetId]
})

const alphaOutEmission = await publicClient.readContract({
abi: IAlphaABI,
address: toViemAddress(IALPHA_ADDRESS),
functionName: "getAlphaOutEmission",
args: [subnetId]
})

// all should be defined and valid
assert.ok(taoInEmission !== undefined && alphaInEmission !== undefined && alphaOutEmission !== undefined);
});

it("getSumAlphaPrice returns valid sum of alpha prices", async () => {
const sumAlphaPrice = await publicClient.readContract({
abi: IAlphaABI,
address: toViemAddress(IALPHA_ADDRESS),
functionName: "getSumAlphaPrice",
args: []
})

assert.ok(sumAlphaPrice !== undefined, "Sum alpha price should be defined");
})
});

describe("Pool Data Functions", () => {
Expand Down
Loading
Loading